first commit
This commit is contained in:
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
App. Name : Inventory Advanced Systems
|
||||
Module : /apps/php/repo/beli_retur.php
|
||||
Desc. : PHP - Laporan Retur Pembelian
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : April 12th, 2011.
|
||||
Last Modified : July 4th, 2023.
|
||||
|
||||
(c) 2011 - 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" ) {
|
||||
$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 SupID='".$id_sup."'" : "";
|
||||
|
||||
// query data laporan
|
||||
if ($tipe=="R") {
|
||||
$db->Query("SELECT B.*,S.Nama_Sup FROM (SELECT SupID,SUM(-Total_Beli) Total_Retur FROM inv_beli WHERE Data_Beli=0 AND (Tgl_Beli BETWEEN '".$tglfrom."' AND '".$tglto."')".$tsql." GROUP BY SupID) B LEFT JOIN para_supplier S ON (B.SupID=S.SupID) ORDER BY S.Nama_Sup");
|
||||
} else {
|
||||
$db->Query("SELECT B.*,DATE_FORMAT(B.Tgl_Beli,'%d-%m-%Y') Tgl_Beli2,-B.Total_Beli Retur,S.Nama_Sup FROM (SELECT * FROM inv_beli WHERE Data_Beli=0 AND (Tgl_Beli BETWEEN '".$tglfrom."' AND '".$tglto."')".$tsql.") B LEFT JOIN para_supplier S ON (B.SupID=S.SupID) ORDER BY B.No_Beli");
|
||||
}
|
||||
}
|
||||
|
||||
if ( $data == "print" ) {
|
||||
Report_Header("LAPORAN ".($tipe=="R"?"REKAP":"DETAIL")." RETUR PEMBELIAN", $tglheader);
|
||||
|
||||
if ($id_sup>0) $header = "Nama Supplier : ".$asup['Nama_Sup'];
|
||||
if ($tipe=="R") {
|
||||
$header .= '<table class="garis"><thead><tr><th>No.</th><th>Nama Supplier</th><th>Total</th></tr></thead><tbody>';
|
||||
$_line = '<tr><td class="c">%s</td><td>%s</td><td class="r">%s</td></tr>';
|
||||
$_sline = '<tr><td class="c b" colspan="2">%s</td><td class="r b">%s</td></tr>';
|
||||
|
||||
$body = ''; $nomor = 1; $subtotal = 0;
|
||||
while ($db->Next()) {
|
||||
$subtotal += $db->Row("Total_Retur");
|
||||
$body .= sprintf($_line, $nomor++, $db->Row("Nama_Sup"), rupiah2($db->Row("Total_Retur")));
|
||||
}
|
||||
$body .= sprintf($_sline, "Jumlah", rupiah2($subtotal));
|
||||
|
||||
} else {
|
||||
$header .= '<table class="garis"><thead><tr><th>No. Nota</th><th>Tgl. Nota</th><th>Nama Supplier</th><th>Total</th><th>Catatan</th></tr></thead><tbody>';
|
||||
$_line = '<tr><td class="c">%s</td><td class="c">%s</td><td>%s</td><td class="r">%s</td><td>%s</td></tr>';
|
||||
$_sline = '<tr><td class="c b" colspan="3">%s</td><td class="r b">%s</td><td class="r b">%s</td></tr>';
|
||||
|
||||
$body = ''; $subtotal = 0;
|
||||
while ($db->Next()) {
|
||||
$subtotal += $db->Row("Retur");
|
||||
|
||||
$body .= sprintf($_line, $db->Row("No_Beli"), $db->Row("Tgl_Beli2"), $db->Row("Nama_Sup"), rupiah2($db->Row("Retur")), $db->Row("No_Faktur"));
|
||||
}
|
||||
$body .= sprintf($_sline, "Jumlah", rupiah2($subtotal), "");
|
||||
}
|
||||
|
||||
echo $header . $body . "</tbody></table>" . Report_Stamp(1, true);
|
||||
|
||||
} else if ( $data == "default") {
|
||||
$form = new Form($db);
|
||||
$form->radio("Tipe Laporan", "Tipe", "R", true, false, ["R"=>"Rekap","D"=>"Detail"]);
|
||||
$form->option_db("Nama Supplier", "SupID", 0, true, false, "para_supplier", ["SupID","Nama_Sup"], "TRUE ORDER BY Nama_Sup", [0,"SEMUA SUPPLIER"]);
|
||||
$form->datebox("Dari Tanggal", "Tgl_From", tgl_ymd(), true, false);
|
||||
$form->datebox("Sampai Tanggal", "Tgl_To", tgl_ymd(), true, false);
|
||||
$form->show(' _Tipe_ _SupID_ _Tgl_From_ _Tgl_To_ ');
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user