128 lines
5.1 KiB
PHP
128 lines
5.1 KiB
PHP
<?php
|
|
|
|
/*******************************************************************
|
|
|
|
App. Name : Inventory Advanced Systems
|
|
Module : /apps/php/repo/hutang.php
|
|
Desc. : PHP - Laporan Hutang Supplier
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : July 17th, 2011.
|
|
Last Modified : October 22nd, 2015.
|
|
|
|
(c) 2011 - 2015, 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\Table;
|
|
use siaupheng\fonia3\Web\Form;
|
|
use siaupheng\fonia3\Printer\PrintHTML;
|
|
|
|
$db = (is_resource($db)) ? $db : new MySQL();
|
|
$ajson = [];
|
|
$data = Param::Get("data");
|
|
|
|
if ( $data == "print" || $data == "export" ) {
|
|
$tipe = Param::Get("Tipe"); // R or D
|
|
$id_sup = Param::Get("SupID", 0);
|
|
$tglfrom = Param::Get("Tgl_From");
|
|
$tglto = Param::Get("Tgl_To");
|
|
$asup = [];
|
|
if ($id_sup > 0) {
|
|
$db->Query("SELECT * FROM para_supplier WHERE SupID='".$id_sup."' LIMIT 1");
|
|
if ($db->Next()) $asup = $db->AllRow();
|
|
}
|
|
|
|
// generate report header
|
|
$tglheader = "Periode : ".$tglfrom;
|
|
if ($tglfrom!==$tglto) $tglheader .= " S/D ".$tglto;
|
|
$tglfrom = tgl_sql2str($tglfrom);
|
|
$tglto = tgl_sql2str($tglto);
|
|
|
|
$tsql = ($id_sup>0) ? " AND B.SupID='".$id_sup."'" : "";
|
|
|
|
if ($tipe=="R") {
|
|
$db->Query("SELECT S.Nama_Sup,SUM(B.Total_Beli-B.Total_Diskon) Total_Hutang FROM inv_beli B LEFT JOIN para_supplier S ON (B.SupID=S.SupID) WHERE B.Lunas=0 AND (B.Tgl_Beli BETWEEN '".$tglfrom."' AND '".$tglto."')".$tsql." GROUP BY B.SupID ORDER BY S.Nama_Sup");
|
|
} else {
|
|
$db->Query("SELECT B.*,DATE_FORMAT(B.Tgl_Beli,'%d-%m-%Y') Tgl_Beli2,CONCAT(S.Nama_Sup,IF(B.Data_Beli=1,'',' <i>(Retur)</i>')) Nama_Sup,B.Total_Beli-B.Total_Diskon Total_Hutang FROM inv_beli B LEFT JOIN para_supplier S ON (B.SupID=S.SupID) WHERE B.Lunas=0 AND (B.Tgl_Beli BETWEEN '".$tglfrom."' AND '".$tglto."')".$tsql." ORDER BY B.No_Beli");
|
|
}
|
|
}
|
|
|
|
if ( $data == "print" ) {
|
|
Report_Header("LAPORAN ".($tipe=="R"?"REKAP":"DETAIL")." HUTANG SUPPLIER", $tglheader);
|
|
$pre = new PrintHTML();
|
|
$pre->set_css("garis");
|
|
|
|
if ($tipe=="R") {
|
|
$pre->add_field("NO.",10,"C");
|
|
$pre->add_field("NAMA SUPPLIER",120);
|
|
$pre->add_field("JUMLAH HUTANG",30,"R","uang");
|
|
$pre->add_field("JUMLAH BAYAR",30,"R","uang");
|
|
$pre->add_field("SISA HUTANG",30,"R","uang");
|
|
|
|
if ($supid>0) $pre->add_span(array("NAMA SUPPLIER",2,"L,NB"),array(": ".$asup['Nama_Sup'],3,"L,NB"));
|
|
$pre->show_fields();
|
|
|
|
$tot_hut = $tot_bayar = $nomor = 0;
|
|
while ($db->Next()) {
|
|
$nomor++;
|
|
$tot_hut += $db->Row("Total_Hutang");
|
|
$tot_bayar += 0;
|
|
$pre->add_value($nomor, $db->Row("Nama_Sup"), $db->Row("Total_Hutang"), 0, $db->Row("Total_Hutang"));
|
|
}
|
|
$pre->add_span(array("",1),array("GRAND TOTAL",1,"L,B"),array($tot_hut,1,"R,B","uang"),array($tot_bayar,1,"R,B","uang"),array($tot_hut-$tot_bayar,1,"R,B","uang"));
|
|
|
|
} else {
|
|
$pre->add_field("NO. NOTA",10,"C");
|
|
$pre->add_field("TGL. BELI",10,"C");
|
|
$pre->add_field("NAMA SUPPLIER",120);
|
|
$pre->add_field("JUMLAH HUTANG",30,"R","uang");
|
|
|
|
if ($supid>0) $pre->add_span(array("NAMA SUPPLIER",2,"L,NB"),array(": ".$nama_sup,2,"L,NB"));
|
|
$pre->show_fields();
|
|
|
|
$subtotal = 0;
|
|
while ($db->Next()) {
|
|
$subtotal += $db->Row("Total_Hutang");
|
|
$pre->add_value($db->Row("No_Beli"), $db->Row("Tgl_Beli2"), $db->Row("Nama_Sup"), $db->Row("Total_Hutang"));
|
|
}
|
|
$pre->add_span(array("GRAND TOTAL",3,"L,B"),array($subtotal,1,"R,B","uang"));
|
|
}
|
|
$pre->add_stamp(1, true);
|
|
$pre->show();
|
|
|
|
} else if ( $data == "default") {
|
|
$form = new Form($db);
|
|
$ttipe = $form->radio("_", "Tipe", "R", true, false, ["R"=>"Rekap","D"=>"Detail"]);
|
|
$tsup = $form->option_db("_", "SupID", 0, true, false, "para_supplier", ["SupID","Nama_Sup"], "TRUE ORDER BY Nama_Sup", [0,"SEMUA SUPPLIER"]);
|
|
$ttglfrom = $form->datebox("_", "Tgl_From", tgl_ymd(), true, false);
|
|
$ttglto = $form->datebox("_", "Tgl_To", tgl_ymd(), true, false);
|
|
echo '
|
|
<div class="row mb-1">
|
|
<label class="col-sm-5 col-lg-3 col-form-label" for="Tipe">Tipe Laporan</label>
|
|
<div class="col">'.$ttipe.'</div>
|
|
</div>
|
|
<div class="row mb-1">
|
|
<label class="col-sm-5 col-lg-3 col-form-label" for="SupID">Nama Supplier</label>
|
|
<div class="col">'.$tsup.'</div>
|
|
</div>
|
|
<div class="row mb-1"><div class="col"><hr class="my-1"></div></div>
|
|
<div class="row mb-1">
|
|
<label class="col-sm-5 col-lg-3 col-form-label" for="Tgl_From">Dari Tanggal</label>
|
|
<div class="col">'.$ttglfrom.'</div>
|
|
</div>
|
|
<div class="row mb-1">
|
|
<label class="col-sm-5 col-lg-3 col-form-label" for="Tgl_To">Sampai Tanggal</label>
|
|
<div class="col">'.$ttglto.'</div>
|
|
</div>';
|
|
|
|
}
|
|
|
|
?>
|