first commit
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
App. Name : INVENTORY AND SALES SYSTEMS
|
||||
Module : /apps/php/repo/hutang_bayar.php
|
||||
Desc. : PHP - Laporan Pembayaran Hutang
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : May 18th, 2012.
|
||||
Last Modified : October 19th, 2025.
|
||||
|
||||
(c) 2012 - 2025, 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
require_once(__DIR__."/../../../../../vendor/autoload.php");
|
||||
require_once(__DIR__."/../func.iss.php");
|
||||
|
||||
use siaupheng\fonia3\DB\MySQL;
|
||||
use siaupheng\fonia3\Web\Param;
|
||||
use siaupheng\fonia3\Web\Form;
|
||||
use siaupheng\fonia3\Data\SimpleXLS;
|
||||
|
||||
$db = $db ?? new MySQL();
|
||||
$ajson = [];
|
||||
$data = Param::Get("data");
|
||||
$id_cab = Param::Get("CabID", 0);
|
||||
|
||||
if (in_array($data, ["print","export"])) {
|
||||
$tipe = Param::Get("Tipe", "R"); // R or D
|
||||
$id_sup = Param::Get("SupID", 0);
|
||||
$tglfrom = Param::Get("Tgl_From");
|
||||
$tglto = Param::Get("Tgl_To");
|
||||
|
||||
// generate report header
|
||||
$tglheader = $tglfrom;
|
||||
if ($tglfrom!==$tglto) $tglheader .= " S/D ".$tglto;
|
||||
$tglfrom = tgl_sql2str($tglfrom);
|
||||
$tglto = tgl_sql2str($tglto);
|
||||
|
||||
$tsql = ($id_cab==0) ? "" : " AND CabID='".$id_cab."'";
|
||||
$tsql .= ($id_sup==0) ? "" : " AND SupID='".$id_sup."'";
|
||||
|
||||
if ($tipe=="R") {
|
||||
$db->Query("SELECT Tgl_Bayar,SUM(Total_Bayar) Total_Bayar FROM inv_beli_lunas WHERE (Tgl_Bayar BETWEEN '".$tglfrom."' AND '".$tglto."')".$tsql." GROUP BY Tgl_Bayar ORDER BY Tgl_Bayar");
|
||||
} else {
|
||||
$db->Query("SELECT L.*,S.Nama_Sup FROM (SELECT * FROM inv_beli_lunas WHERE (Tgl_Bayar BETWEEN '".$tglfrom."' AND '".$tglto."')".$tsql.") L LEFT JOIN para_supplier S ON (S.SupID=L.SupID) ORDER BY L.Tgl_Bayar");
|
||||
}
|
||||
}
|
||||
|
||||
if ( $data == "print" ) {
|
||||
Report_Header(($tipe=="R"?"REKAP":"DETAIL")." PEMBAYARAN SUPPLIER", "Periode : ".$tglheader);
|
||||
$pre = new \siaupheng\fonia3\Printer\PrintHTML();
|
||||
|
||||
if ($tipe=="R") {
|
||||
$pre->add_field("No.",10,"C");
|
||||
$pre->add_field("Tanggal",30,"C","sqltgl");
|
||||
$pre->add_field("Keterangan",80,"L");
|
||||
$pre->add_field("Jumlah",20,"R","rupiah");
|
||||
|
||||
$sub_tot = 0; $nomor = 0;
|
||||
while ($db->Next()) {
|
||||
$sub_tot += $db->Row("Total_Bayar");
|
||||
$pre->add_value(++$nomor, $db->Row("Tgl_Bayar"), "Pembayaran Hutang Supplier", $db->Row("Total_Bayar"));
|
||||
}
|
||||
$pre->add_span(array("GRAND TOTAL",3,"R,B"),array($sub_tot,1,"R,B","rupiah"));
|
||||
|
||||
} else {
|
||||
$pre->add_field("Tanggal",30,"C","sqltgl");
|
||||
$pre->add_field("No. Transaksi",20,"L");
|
||||
$pre->add_field("Nama Supplier",150,"L");
|
||||
$pre->add_field("Jumlah",30,"R","rupiah");
|
||||
|
||||
$sub_tot = 0;
|
||||
while ($db->Next()) {
|
||||
$sub_tot += $db->Row("Total_Bayar");
|
||||
$pre->add_value($db->Row("Tgl_Bayar"), $db->Row("No_Beli"), $db->Row("Nama_Sup"), $db->Row("Total_Bayar"));
|
||||
}
|
||||
$pre->add_span(array("GRAND TOTAL",3,"R,B"),array($sub_tot,1,"R,B","rupiah"));
|
||||
}
|
||||
$pre->add_stamp(1, true);
|
||||
$pre->show();
|
||||
|
||||
} else if ( $data == "export" ) {
|
||||
$xls = new SimpleXLS([
|
||||
'title'=>"Data Pembayaran Supplier",
|
||||
'desc'=>"Export Data Pembayaran Supplier"
|
||||
]);
|
||||
|
||||
$xls->add_header("<b>".$_SESSION['__WEB_APP']['REG_NAME']."</b>");
|
||||
$xls->add_header("<b>DATA ".($tipe=="R"?"REKAP":"DETAIL")." PEMBAYARAN SUPPLIER</b>");
|
||||
$xls->add_header("Periode : ".$tglheader);
|
||||
|
||||
if ($tipe=="R") {
|
||||
$xls->add_field("No.", 5, "C");
|
||||
$xls->add_field("Tanggal", 12, "C", "tgl_sql2str");
|
||||
$xls->add_field("Keterangan", 50, "L");
|
||||
$xls->add_field("Jumlah", 15, "R,N");
|
||||
$xls->add_sheet("".str_replace("S/D","-",$tglheader), true);
|
||||
|
||||
$sub_tot = 0; $nomor = 0;
|
||||
while ($db->Next()) {
|
||||
$sub_tot += $db->Row("Total_Bayar");
|
||||
$xls->add_value(++$nomor, $db->Row("Tgl_Bayar"), "Pembayaran Hutang Supplier", $db->Row("Total_Bayar"));
|
||||
}
|
||||
$xls->add_span(array("GRAND TOTAL",3,"R,B"),array($sub_tot,1,"R,B,N"));
|
||||
|
||||
} else {
|
||||
$xls->add_field("Tanggal", 12, "C", "tgl_sql2str");
|
||||
$xls->add_field("No. Transaksi", 15, "L");
|
||||
$xls->add_field("Nama Supplier", 50, "L");
|
||||
$xls->add_field("Jumlah", 15, "R,N");
|
||||
$xls->add_sheet("".str_replace("S/D","-",$tglheader), true);
|
||||
|
||||
$sub_tot = 0;
|
||||
while ($db->Next()) {
|
||||
$sub_tot += $db->Row("Total_Bayar");
|
||||
$xls->add_value($db->Row("Tgl_Bayar"), $db->Row("No_Beli"), $db->Row("Nama_Sup"), $db->Row("Total_Bayar"));
|
||||
}
|
||||
$xls->add_span(array("GRAND TOTAL",3,"R,B"),array($sub_tot,1,"R,B,N"));
|
||||
}
|
||||
$xls->add_stamp(1, true);
|
||||
$xls->send("Data Pembayaran Supplier ".str_replace("S/D","-",$tglheader).".xlsx");
|
||||
unset($xls);
|
||||
|
||||
} else if ( $data == "default") {
|
||||
$form = new Form($db);
|
||||
$ttipe = $form->radio("_", "Tipe", "R", true, false, ["R"=>"Rekap","D"=>"Detail"]);
|
||||
$tcab = $form->option_db("_", "CabID", $id_cab, true, false, "para_cabang", ["CabID","Nama_Cab"], "Aktif=1 ORDER BY CabID", [0,"SEMUA CABANG"]);
|
||||
$tsup = $form->option_db("_", "SupID", 0, true, false, "para_supplier", ["SupID","Nama_Sup"], "Aktif=1 ORDER BY Nama_Sup", [0,"SEMUA SUPPLIER"]);
|
||||
$tfrom = $form->datebox("_", "Tgl_From", tgl_ymd(), true, false);
|
||||
$tto = $form->datebox("_", "Tgl_To", tgl_ymd(), true, false);
|
||||
echo '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Tipe">Tipe Laporan</label>
|
||||
<div class="col col-form-label">'.$ttipe.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="CabID">Nama Cabang</label>
|
||||
<div class="col">'.$tcab.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="SupID">Nama Supplier</label>
|
||||
<div class="col">'.$tsup.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Tgl_From">Dari Tanggal</label>
|
||||
<div class="col-sm-8 col-lg-5">'.$tfrom.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Tgl_To">Sampai Tgl</label>
|
||||
<div class="col-sm-8 col-lg-5">'.$tto.'</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user