first commit

This commit is contained in:
2026-01-22 13:38:42 +07:00
commit ab311c5c95
91 changed files with 8064 additions and 0 deletions
+143
View File
@@ -0,0 +1,143 @@
<?php
/*******************************************************************
App. Name : INVENTORY AND SALES SYSTEMS
Module : /apps/php/repo/jual_rekap.php
Desc. : PHP - Laporan Rekap Penjualan
Created By : Siau Pheng ([email protected]).
Created Date : May 9th, 2013.
Last Modified : October 4th, 2025.
(c) 2013 - 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", $_SESSION['__APP_INV']['CABANGID']);
if (in_array($data, ["print","export"])) {
$id_sup = Param::Get("SupID", 0);
$id_grup = Param::Get("Grup_InvID", 0);
$tglfrom = Param::Get("Tgl_From");
$tglto = Param::Get("Tgl_To");
$nama_sup = $nama_grup = "";
if ($id_sup>0) {
$db->Query("SELECT Nama_Sup Nama FROM para_supplier WHERE SupID='".$id_sup."' LIMIT 1");
if ($db->Next()) $nama_sup = $db->Row("Nama");
}
if ($id_grup>0 && $id_sup==0) {
$db->Query("SELECT Nama_Grup Nama FROM inv_produk_grup WHERE Grup_InvID='".$id_grup."' LIMIT 1");
if ($db->Next()) $nama_grup = $db->Row("Nama");
}
// generate report header
$tglheader = $tglfrom;
if ($tglfrom!==$tglto) $tglheader .= " S/D ".$tglto;
$tglfrom = tgl_sql2str($tglfrom);
$tglto = tgl_sql2str($tglto);
$tjoin = "";
$tsql = " D.Jumlah<>0";
$tsql .= ($id_grup>0 && $id_sup==0) ? " AND P.Grup_InvID=".$id_grup : "";
if ($id_sup>0) {
$tsql .= " AND U.SupID='".$id_sup."'";
$tjoin .= " LEFT JOIN inv_produk_sup U ON (U.InvID=D.InvID AND U.SupID='".$id_sup."')";
}
$tsql2 = ($id_cab==0) ? "" : " AND CabID='".$id_cab."'";
// query data laporan
$db->Query("SELECT P.Kode_SKU,P.Nama_Produk,P.Nama_Satuan,D.Qty,D.Jumlah FROM (SELECT InvID,SatuanID,SUM(-Qty) Qty,SUM(-Qty*Harga_Jual) Jumlah FROM inv_detail WHERE (Tgl_Ref BETWEEN '".$tglfrom."' AND '".$tglto."') AND NotaID IN (5,6)".$tsql2." GROUP BY InvID, SatuanID) D LEFT JOIN vi_inv_produk P ON (D.InvID=P.InvID AND D.SatuanID=P.SatuanID)".$tjoin." WHERE ".$tsql." ORDER BY P.Kode_SKU");
}
if ( $data == "print" ) {
Report_Header("REKAP PENJUALAN", "Periode : ".$tglheader);
$pre = new \siaupheng\fonia3\Printer\PrintHTML();
$pre->add_field("No.",10,"C");
$pre->add_field("Kode SKU",20,"C");
$pre->add_field("Nama Barang",120,"L");
$pre->add_field("Qty",80,"R","rupiah2");
$pre->add_field("Jumlah",50,"R","rupiah2");
if ($id_sup>0) $pre->add_span(array("Nama Supplier : ".$nama_sup,5,"L,B"));
if ($id_grup>0 && $id_sup==0) $pre->add_span(array("Grup Barang : ".$nama_grup,5,"L,B"));
$nomor = 0;
while ($db->Next()) {
$pre->add_value(++$nomor, $db->Row("Kode_SKU"), $db->Row("Nama_Produk"), $db->Row("Qty"), $db->Row("Jumlah"));
}
$pre->add_stamp(1, true);
$pre->show();
} else if ( $data == "export" ) {
$xls = new SimpleXLS([
'title'=>"Data Rekap Penjualan",
'desc'=>"Export Data Rekap Penjualan"
]);
$xls->add_header($_SESSION['__WEB_APP']['REG_NAME']);
$xls->add_header("DATA REKAP PENJUALAN");
$xls->add_header("Periode : ".$tglheader);
$xls->add_field("No.", 10, "C");
$xls->add_field("Kode SKU", 12, "L");
$xls->add_field("Nama Barang", 80, "L");
$xls->add_field("Qty", 20, "R,N");
$xls->add_field("Jumlah", 20, "R,N");
$xls->add_sheet("".str_replace("S/D","-",$tglheader), true);
if ($id_sup>0) $xls->add_span(["Nama Supplier : ".$nama_sup,5,"L"]);
if ($id_grup>0 && $id_sup==0) $xls->add_span(["Grup Barang : ".$nama_grup,5,"L"]);
$nomor = 0;
while ($db->Next()) {
$xls->add_value(++$nomor, $db->Row("Kode_SKU"), $db->Row("Nama_Produk"), $db->Row("Qty"), $db->Row("Jumlah"));
}
$xls->add_stamp(1, true);
$xls->send("Data Rekap Penjualan ".str_replace("S/D","-",$tglheader).".xlsx");
unset($xls);
} else if ( $data == "default") {
$form = new Form($db);
$tcab = $form->option_db("_", "CabID", $id_cab, false, 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"]);
$tgrup = $form->option_db("_", "Grup_InvID", 0, true, false, "inv_produk_grup", ["Grup_InvID","Nama_Grup"], "Aktif=1 ORDER BY Nama_Grup", [0,"SEMUA GRUP"]);
$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="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"><div class="input-group">'.$tsup.Form_Info("Jika Nama Supplier dipilih, Filter Grup Barang akan diabaikan.").'</div></div>
</div>
<div class="row mb-1">
<label class="col-sm-4 col-lg-3 col-form-label" for="Grup_InvID">Grup Barang</label>
<div class="col">'.$tgrup.'</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-6 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 Tanggal</label>
<div class="col-sm-6 col-lg-5">'.$tto.'</div>
</div>';
}
?>