123 lines
5.3 KiB
PHP
123 lines
5.3 KiB
PHP
<?php
|
|
|
|
/*******************************************************************
|
|
|
|
App. Name : Inventory Advanced Systems
|
|
Module : /apps/php/repo/outlet.php
|
|
Desc. : PHP - Laporan Daftar Outlet
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : March 25th, 2011.
|
|
Last Modified : August 8th, 2024.
|
|
|
|
(c) 2011 - 2024, 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;
|
|
use avadim\FastExcelWriter\Excel;
|
|
|
|
$db = (is_resource($db)) ? $db : new MySQL();
|
|
$ajson = [];
|
|
$data = Param::Get("data");
|
|
|
|
if ( $data == "print" || $data == "export") {
|
|
$id_outlet = Param::Get("Grup_OutletID", 0); $aout = [];
|
|
$id_grup = Param::Get("Grup_InvID", 0); $agrup = [];
|
|
$aktif = Param::Get("Aktif", "X");
|
|
if ($id_outlet>0) {
|
|
$db->Query("SELECT * FROM para_outlet_grup WHERE Grup_OutletID='".$id_outlet."'");
|
|
if ($db->Next()) $aout = $db->AllRow();
|
|
}
|
|
if ($id_grup>0) {
|
|
$db->Query("SELECT * FROM inv_produk_grup WHERE Grup_InvID='".$id_grup."'");
|
|
if ($db->Next()) $agrup = $db->AllRow();
|
|
}
|
|
if ($aktif<>"X") $nama_aktif = ($aktif=="Y") ? "AKTIF" : "TIDAK AKTIF";
|
|
|
|
// generate report header
|
|
$tglheader = "Tanggal Cetak : ".Param::Get("Tgl_Cetak");
|
|
$tsql = ($id_outlet==0) ? "" : " AND O.Grup_OutletID='".$id_outlet."'";
|
|
$tsql .= ($id_grup==0) ? "" : " AND P.Grup_InvID='".$id_grup."'";
|
|
$tsql .= ($aktif=="X") ? "" : " AND O.Aktif='".(($aktif=="Y")?1:0)."'";
|
|
$tsql = ($tsql == "") ? " TRUE" : substr($tsql,4);
|
|
$ljoin = ($id_grup==0) ? "" : " LEFT JOIN inv_jual J ON (J.OutletID=O.OutletID) LEFT JOIN inv_detail D ON (D.No_Ref=J.No_Jual) LEFT JOIN inv_produk P ON (P.InvID=D.InvID)";
|
|
$lgrup = ($id_grup==0) ? "" : " GROUP BY O.OutletID";
|
|
|
|
// query data laporan
|
|
$db->Query("SELECT O.*,IF(O.No_NPWP=0,O.No_NIK,O.No_NPWP) No_NPWP_NIK FROM para_outlet O ".$ljoin." WHERE ".$tsql." ".$lgrup." ORDER BY O.Nama_Outlet");
|
|
}
|
|
|
|
if ( $data == "print" ) {
|
|
Report_Header("LAPORAN DAFTAR OUTLET", $tglheader);
|
|
|
|
if ($id_outlet>0) $header = '<p>Nama Grup Outlet : '.$aout['Nama_Grup'].'</p>';
|
|
if ($id_grup>0) $header .= '<p>Nama Grup Produk : '.$agrup['Nama_Grup'].'</p>';
|
|
if ($aktif<>"X") $header .= '<p>Status Aktif : '.$nama_aktif.'</p>';
|
|
$header .= '<table class="garis"><thead><tr><th>No.</th><th>Nama Outlet</th><th>NPWP</th><th>Alamat</th><th>Kota</th></tr></thead><tbody>';
|
|
$_line = '<tr><td class="c">%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("Nama_Outlet"), $db->Row("No_NPWP_NIK"), $db->Row("Alamat_Outlet"), $db->Row("Kota_Outlet"));
|
|
$nomor++;
|
|
}
|
|
|
|
echo $header . $body . "</tbody></table>" . Report_Stamp(1, true);
|
|
|
|
} else if ( $data == "export" ) {
|
|
$excel = Excel::create(['Daftar Outlet']);
|
|
$excel->setCompany($_SESSION['__WEB_APP']['REG_NAME']);
|
|
$excel->setAuthor($_SESSION['__WEB_APP']['APP_NAMES']);
|
|
$sheet = $excel->getSheet();
|
|
|
|
$rep_header = [
|
|
'font' => ['style' => 'bold'],
|
|
'text-align' => 'center', 'vertical-align' => 'center'
|
|
];
|
|
$sheet->writeTo('A1:E1', $_SESSION['__WEB_APP']['REG_NAME'], $rep_header);
|
|
$sheet->writeTo('A2:E2', "LAPORAN DAFTAR OUTLET", $rep_header);
|
|
$sheet->writeTo('A3:E3', $tglheader, $rep_header);
|
|
$sheet->nextRow();
|
|
|
|
if ($id_outlet>0) $sheet->writeRow(["Nama Grup Outlet : ".$aout['Nama_Grup']]);
|
|
if ($id_grup>0) $sheet->writeRow(["Nama Grup Produk : ".$agrup['Nama_Grup']]);
|
|
if ($aktif<>"X") $sheet->writeRow(["Status Aktif : ".$nama_aktif]);
|
|
|
|
$tab_header = [
|
|
'font' => ['style' => 'bold'],
|
|
'text-align' => 'center', 'vertical-align' => 'center',
|
|
'fill' => '#ddd'
|
|
];
|
|
$sheet->writeHeader(['No', 'Nama Outlet', 'NPWP', 'Alamat', 'Kota'], $tab_header);
|
|
$sheet->setColOptions([
|
|
'A' => ['format' => "@integer", 'width' => 8],
|
|
'B' => ['format' => "@text", 'width' => 25],
|
|
'C' => ['format' => "@text", 'width' => 25],
|
|
'D' => ['format' => "@text", 'width' => 80],
|
|
'E' => ['format' => "@text", 'width' => 15],
|
|
]);
|
|
|
|
$nomor = 1;
|
|
while ($db->Next()) {
|
|
$sheet->writeRow([$nomor++, $db->Row("Nama_Outlet"), $db->Row("No_NPWP_NIK"), $db->Row("Alamat_Outlet"), $db->Row("Kota_Outlet")]);
|
|
}
|
|
$excel->output("Daftar Outlet.xlsx");
|
|
|
|
} else if ( $data == "default") {
|
|
$form = new Form($db);
|
|
$form->option_db("Grup Outlet", "Grup_OutletID", 0, true, false, "para_outlet_grup", ["Grup_OutletID","Nama_Grup"], "Aktif=1 ORDER BY Nama_Grup", [0,"SEMUA GRUP OUTLET"]);
|
|
$form->option_db("Grup Produk", "Grup_InvID", 0, true, false, "inv_produk_grup", ["Grup_InvID","Nama_Grup"], "Aktif=1 ORDER BY Nama_Grup", [0,"SEMUA GRUP PRODUK"]);
|
|
$form->radio("Status Aktif", "Aktif", "X", true, false, ['Y'=>"Ya",'N'=>"Tidak",'X'=>"Semua"]);
|
|
$form->datebox("Tanggal Cetak", "Tgl_Cetak", tgl_ymd(), true, false);
|
|
$form->show(' _Grup_OutletID_ _Grup_InvID_ _Aktif_ _Tgl_Cetak_ ');
|
|
}
|
|
|
|
?>
|