first commit

This commit is contained in:
2026-01-22 15:30:17 +07:00
commit a971b97d88
181 changed files with 22279 additions and 0 deletions
+152
View File
@@ -0,0 +1,152 @@
<?php
/*******************************************************************
Module : /apps/php/repo/supervisi.php
Desc. : PHP - Laporan Supervisi
Created By : Siau Pheng ([email protected]).
Created Date : June 1st, 2013.
Last Modified : March 26th, 2023.
(c) 2013 - 2023, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
require_once(__DIR__."/../../../../../vendor/autoload.php");
require_once(__DIR__."/../func/ias.php");
require_once(__DIR__."/../func/report.php");
use siaupheng\fonia3\DB\MySQL;
use siaupheng\fonia3\DB\SQL;
use siaupheng\fonia3\Web\Param;
use siaupheng\fonia3\Web\Form;
$db = (is_resource($db)) ? $db : new MySQL();
$ajson = [];
$data = Param::Get("data");
if ( $data == "print" || $data == "export") {
$id_user = Param::Get("UserID", 0);
$tgl_from = Param::Get("Tgl_From");
$tgl_to = Param::Get("Tgl_To");
$auser = [];
if ($id_user>0) {
$db->Query("SELECT Nama FROM app_operator WHERE UserID='".$id_user."'");
if ($db->Next()) $auser = $db->AllRow();
}
// generate report header
$tglheader = "Periode : ".$tgl_from;
if ($tgl_from!==$tgl_to) $tglheader .= " s/d ".$tgl_to;
$tgl_from = tgl_sql2str($tgl_from);
$tgl_to = tgl_sql2str($tgl_to);
// query data laporan
$tsql = ($id_user>0) ? " AND UserID='".$id_user."'" : " AND UserID>1";
$db->Query("SELECT UPPER(O.Nama) Nama_User,UPPER(M.Judul) Menu,DATE_FORMAT(A.Tanggal,'%d-%m-%Y %H:%i:%s') Tanggal2,A.Catatan,UPPER(S.Nama) Nama_Super FROM (SELECT * FROM app_auth WHERE Auth=1 AND (Tanggal BETWEEN '".$tgl_from." 00:00:00' AND '".$tgl_to." 23:59:59')".$tsql.") A LEFT JOIN app_operator O ON (O.UserID=A.UserID) LEFT JOIN app_operator S ON (S.UserID=A.SuperID) LEFT JOIN app_menu M ON (M.Kode=A.Kode) ORDER BY A.Tanggal");
}
if ( $data == "print" ) {
Report_Header("LAPORAN SUPERVISI APLIKASI", $tglheader);
if ($id_user>0) $header = '<p>Nama Pengguna : '.$auser['Nama'].'</p>';
$header .= '<table class="garis"><thead><tr><th>No.</th><th>Tanggal / Jam</th><th>Menu Aplikasi</th><th>Catatan</th><th>Operator</th><th>Supervisi</th></tr></thead><tbody>';
$_line = '<tr><td class="c">%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>';
$body = ''; $nomor = 1;
while ($db->Next()) {
$body .= sprintf($_line, $nomor++, $db->Row("Tanggal2"), $db->Row("Menu"), $db->Row("Catatan"), $db->Row("Nama_User"), $db->Row("Nama_Super"));
}
echo $header . $body . "</tbody></table>" . Report_Stamp(1, true);
} else if ( $data == "export" ) {
\PhpOffice\PhpSpreadsheet\Cell\Cell::setValueBinder( new \PhpOffice\PhpSpreadsheet\Cell\AdvancedValueBinder() );
$styleTxt = [
'numberFormat' => ['formatCode' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT]
];
$styleNum = [
'numberFormat' => ['formatCode' => \PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED2]
];
$ssheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
$ssheet->getProperties()
->setCreator($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER'])
->setLastModifiedBy($_SESSION['__WEB_APP']['APP_NAME']." v".$_SESSION['__WEB_APP']['APP_VER'])
->setTitle("Data Supervisi")
->setCompany($_SESSION['__WEB_APP']['REG_NAME']);
$sheet = $ssheet->getActiveSheet();
$sheet->setTitle("Data Supervisi");
// header
$styleHeader = [
'font' => ['bold' => true],
'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER]
];
$sheet->setCellValue("A1", strtoupper($_SESSION['__WEB_APP']['REG_NAME']));
$sheet->mergeCells('A1:F1');
$sheet->setCellValue("A2", "LAPORAN SUPERVISI APLIKASI");
$sheet->mergeCells('A2:F2');
$sheet->setCellValue("A3", $tglheader);
$sheet->mergeCells('A3:F3');
$sheet->getStyle('A1:F3')->applyFromArray($styleHeader);
// table header
$sheet->getColumnDimension('A')->setWidth(8);
$sheet->getColumnDimension('B')->setWidth(25);
$sheet->getColumnDimension('C')->setWidth(80);
$sheet->getColumnDimension('D')->setWidth(25);
$sheet->getColumnDimension('E')->setWidth(15);
$sheet->getColumnDimension('F')->setWidth(15);
$baris = 5;
if ($id_user>0) {
$sheet->setCellValue("A".$baris, "Nama Pengguna : ".$auser['Nama']);
$baris++;
}
$styleTableH = [
'font' => ['bold' => true],
'alignment' => ['horizontal' => \PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER, 'vertical' => \PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER, 'wrapText' => true],
'fill' => ['fillType' => \PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID, 'startColor' => ['rgb'=>"D0D0D0"]],
'borders' => ['allBorders' => ['borderStyle' => \PhpOffice\PhpSpreadsheet\Style\Border::BORDER_THIN, 'color' => ['rgb'=>"C0C0C0"]]]
];
$sheet->setCellValue("A".$baris, "No.");
$sheet->setCellValue("B".$baris, "Tanggal / Jam");
$sheet->setCellValue("C".$baris, "Menu Aplikasi");
$sheet->setCellValue("D".$baris, "Catatan");
$sheet->setCellValue("E".$baris, "Operator");
$sheet->setCellValue("F".$baris, "Supervisi");
$sheet->getStyle('A'.$baris.':F'.$baris)->applyFromArray($styleTableH);
$baris++; $nomor = 1;
while ($db->Next()) {
$sheet->setCellValue("A".$baris, $nomor++);
$sheet->setCellValue("B".$baris, $db->Row("Tanggal2"));
$sheet->setCellValue("C".$baris, $db->Row("Menu"));
$sheet->setCellValue("D".$baris, $db->Row("Catatan"));
$sheet->setCellValue("E".$baris, $db->Row("Nama_User"));
$sheet->setCellValue("F".$baris, $db->Row("Nama_Super"));
$baris++;
}
$sheet->getSheetView()->setZoomScale(75);
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
header('Content-Disposition: attachment;filename="Data Supervisi.xlsx"');
header('Cache-Control: max-age=0');
$writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($ssheet, 'Xlsx');
$writer->save('php://output');
$ssheet->disconnectWorksheets();
unset($ssheet);
unset($writer);
} else if ( $data == "default") {
$form = new Form($db);
$form->option_db("Nama Pengguna", "UserID", 0, true, false, "app_operator", ["UserID","Nama"], "UserID>1 ORDER BY Nama", [0,"SEMUA PENGGUNA"]);
$form->datebox("Dari Tanggal", "Tgl_From", tgl_ymd(), true, false);
$form->datebox("Sampai Tanggal", "Tgl_To", tgl_ymd(), true, false);
$form->show(' _UserID_ _Tgl_From_ _Tgl_To_ ');
}
?>