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 '
'.$tcab.'
'.$tsup.'
'.$tgrup.'
'.$ttgl.'
'.$turut.'
'.$tharga.'
'.$tstok.'
'.$tqty.'
'; } ?>