first commit
This commit is contained in:
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
App. Name : INVENTORY AND SALES SYSTEMS
|
||||
Module : /apps/php/repo/stok_akhir.php
|
||||
Desc. : PHP - Laporan Stok Akhir Barang
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : January 24th, 2011.
|
||||
Last Modified : October 1st, 2025.
|
||||
|
||||
(c) 2011 - 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"])) {
|
||||
$id_sup = Param::Get("SupID", 0);
|
||||
$id_grup = Param::Get("Grup_InvID", 0);
|
||||
$tgl = Param::Get("Tanggal");
|
||||
$m_urut = Param::Get("Urut", "B");
|
||||
$is_harga = Param::Get("Harga", "Y");
|
||||
$is_min = Param::Get("Min_Stok", "N");
|
||||
$min_qty = Param::Get("Min_Qty", 0);
|
||||
|
||||
$nama_sup = ""; $nama_grup = "";
|
||||
if ($id_sup > 0) {
|
||||
$db->Query("SELECT CONCAT(Nama_Sup,' (',Kode_Sup,')') Nama FROM para_supplier WHERE SupID='".$id_sup."' LIMIT 1");
|
||||
if ($db->Next()) $nama_sup = $db->Row("Nama");
|
||||
}
|
||||
if ($id_grup > 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 = $tgl;
|
||||
$tgl = tgl_sql2str($tgl);
|
||||
|
||||
$tsql1 = ($id_sup==0) ? "" : " LEFT JOIN inv_produk_sup S ON (D.InvID=S.InvID)";
|
||||
$tsql2 = ($id_sup==0) ? "" : " AND S.SupID='".$id_sup."'";
|
||||
$tsql2 .= ($id_grup==0) ? "" : " AND P.Grup_InvID='".$id_grup."'";
|
||||
$tsql2 .= ($is_min=="N") ? "" : " AND D.Stok<='".$min_qty."'";
|
||||
$tsql3 = ($id_cab==0) ? "" : " AND CabID='".$id_cab."'";
|
||||
$torder = ($m_urut=="B") ? " P.Nama_Produk" : " Total";
|
||||
|
||||
// query data laporan
|
||||
$db->Query("SELECT P.Nama_Produk,P.Satuan_Normal,P.Satuan_Stok,D.Stok Jumlah,P.Harga_Pokok,D.Stok*P.Harga_Pokok Total,P.Qty Kali FROM (SELECT InvID,SUM(Stok) Stok FROM inv_detail WHERE Tgl_Ref<='".$tgl."'".$tsql3." GROUP BY InvID) D LEFT JOIN vi_inv_produk2 P ON (P.InvID=D.InvID) ".$tsql1." WHERE (NOT (D.Stok=0 AND P.Aktif=0)) AND (P.InvID IS NOT NULL)".$tsql2." ORDER BY".$torder);
|
||||
}
|
||||
|
||||
if ( $data == "print" ) {
|
||||
Report_Header("STOK AKHIR BARANG", "Periode : ".$tglheader);
|
||||
$pre = new \siaupheng\fonia3\Printer\PrintHTML();
|
||||
|
||||
$pre->add_field("No.",10,"C");
|
||||
$pre->add_field("Nama Barang",150,"L");
|
||||
$pre->add_field("Stok",80,"R","rupiah");
|
||||
$nkol = 3;
|
||||
if ($is_harga=="Y") {
|
||||
$pre->add_field("Harga",50,"R","rupiah");
|
||||
$pre->add_field("Total",50,"R","rupiah");
|
||||
$nkol = 5;
|
||||
}
|
||||
|
||||
if ($id_sup>0) $pre->add_span(array("Nama Supplier : ".$nama_sup,$nkol,"L,B"));
|
||||
if ($id_grup>0) $pre->add_span(array("Grup Barang : ".$nama_grup,$nkol,"L,B"));
|
||||
|
||||
$tot_stok = 0; $nomor = 0;
|
||||
while ($db->Next()) {
|
||||
$tot_stok += $db->Row("Total");
|
||||
$_row = array(++$nomor, $db->Row("Nama_Produk"), Format_Stok($db->Row("Jumlah",0),$db->Row("Kali",0),$db->Row("Satuan_Normal"),$db->Row("Satuan_Stok")));
|
||||
if ($is_harga=="Y") $_row[] = $db->Row("Harga_Pokok"); $_row[] = $db->Row("Total");
|
||||
$pre->add_value($_row);
|
||||
}
|
||||
if ($is_harga=="Y") $pre->add_span(array("TOTAL",4,"R,B"),array($tot_stok,1,"R,B","rupiah"));
|
||||
$pre->add_stamp(1, true);
|
||||
$pre->show();
|
||||
|
||||
} else if ( $data == "export" ) {
|
||||
$xls = new SimpleXLS([
|
||||
'title'=>"Data Stok Akhir Barang",
|
||||
'desc'=>"Export Data Stok Akhir Barang"
|
||||
]);
|
||||
|
||||
$xls->add_header($_SESSION['__WEB_APP']['REG_NAME']);
|
||||
$xls->add_header("DATA STOK AKHIR BARANG");
|
||||
$xls->add_header("Periode : ".$tglheader);
|
||||
|
||||
$xls->add_field("No.", 10, "C");
|
||||
$xls->add_field("Nama Barang", 60, "L");
|
||||
$xls->add_field("Stok", 20, "R,N");
|
||||
$nkol = 3;
|
||||
if ($is_harga=="Y") {
|
||||
$xls->add_field("Harga", 20, "R,N");
|
||||
$xls->add_field("Total", 20, "R,N");
|
||||
$nkol = 5;
|
||||
}
|
||||
$xls->add_sheet("".str_replace("S/D","-",$tglheader), true);
|
||||
|
||||
if ($id_sup>0) $xls->add_span(["Nama Supplier : ".$nama_sup,$nkol,"L"]);
|
||||
if ($id_grup>0) $xls->add_span(["Grup Barang : ".$nama_grup,$nkol,"L"]);
|
||||
|
||||
$tot_stok = 0; $nomor = 0;
|
||||
while ($db->Next()) {
|
||||
$tot_stok += $db->Row("Total");
|
||||
$_row = array(++$nomor, $db->Row("Nama_Produk"), Format_Stok($db->Row("Jumlah",0),$db->Row("Kali",0),$db->Row("Satuan_Normal"),$db->Row("Satuan_Stok")));
|
||||
if ($is_harga=="Y") $_row[] = $db->Row("Harga_Pokok"); $_row[] = $db->Row("Total");
|
||||
$xls->add_value($_row);
|
||||
}
|
||||
if ($is_harga=="Y") $xls->add_span(array("TOTAL",4,"R,B"),array($tot_stok,1,"R,N,B"));
|
||||
$xls->add_stamp(1, true);
|
||||
$xls->send("Data Stok Akhir Barang ".str_replace("S/D","-",$tglheader).".xlsx");
|
||||
unset($xls);
|
||||
|
||||
} else if ( $data == "default") {
|
||||
$form = new Form($db);
|
||||
$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"]);
|
||||
$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"]);
|
||||
$ttgl = $form->datebox("_", "Tanggal", tgl_ymd(), true, false);
|
||||
$turut = $form->radio("_", "Urut", "B", true, false, ["B"=>"Nama Barang","J"=>"Jumlah / Nilai"]);
|
||||
$tharga = $form->radio("_", "Harga", "Y", true, false, ["Y"=>"Ya","N"=>"Tidak"]);
|
||||
$tstok = $form->radio("_", "Min_Stok", "N", true, false, ["Y"=>"Ya","N"=>"Tidak"], null, "RepoStokAkhirJS.oc_MinStok();");
|
||||
$tqty = $form->textbox("_", "Min_Qty", 0, false, false, "double");
|
||||
|
||||
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">'.$tsup.'</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="Tanggal">Tanggal Stok</label>
|
||||
<div class="col-sm-6 col-lg-5">'.$ttgl.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Urut">Urut Berdasarkan</label>
|
||||
<div class="col col-form-label">'.$turut.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Harga">Cetak Harga ?</label>
|
||||
<div class="col col-form-label">'.$tharga.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Min_Stok">Batas Maximum ?</label>
|
||||
<div class="col-sm-4 col-lg-3 col-form-label">'.$tstok.'</div>
|
||||
<div class="col-sm-4 col-lg-3">'.$tqty.'</div>
|
||||
</div>';
|
||||
}
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user