first commit
This commit is contained in:
@@ -0,0 +1,201 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Report/Inv/BarcodeController
|
||||
Description : Laporan Barcode Barang
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : October 28th, 2013.
|
||||
Last Modified : October 14th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Report\Inv;
|
||||
|
||||
use App\Utils\Invesa;
|
||||
use flight\Engine;
|
||||
use flight\database\SimplePdo;
|
||||
use flight\Session;
|
||||
use Webapp\Web\Form;
|
||||
use Webapp\Web\Param;
|
||||
use Webapp\Web\Table;
|
||||
|
||||
class BarcodeController {
|
||||
|
||||
private string $ip_addr;
|
||||
private int $id_cab;
|
||||
private int $id_grup;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session) {
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->ip_addr = $app->request()->ip;
|
||||
$this->id_cab = $session->get('APP_INV')['CABANGID'] ?? 0;
|
||||
$this->id_grup = $session->get('APP_INV')['ECERANID'] ?? 0;
|
||||
}
|
||||
|
||||
public function brow_produk() {
|
||||
$tcari = Param::Get("Cari_Produk");
|
||||
$tsql = ''; $asql = [$this->id_grup, 1];
|
||||
if (!empty($tcari)) {
|
||||
$tsql .= " AND Barcode_Nama LIKE ?";
|
||||
$asql[] = '%' . $tcari . '%';
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("inv_produk_join", "*", "Grup_MemberID=? AND Aktif=?".$tsql, $asql);
|
||||
$obj->add_field("InvID", "ID", "hid");
|
||||
$obj->add_field("SatuanID", "ID", "hid");
|
||||
$obj->add_field("VarianID", "ID", "hid");
|
||||
$obj->add_field("Kode_SKU", "SKU", "c");
|
||||
$obj->add_field("Kode_Barcode", "Barcode", "c");
|
||||
$obj->add_field("Nama_Lengkap", "Nama Barang", "awr");
|
||||
$obj->set_field_order("Kode_SKU", "A");
|
||||
$obj->set_func_select("RepoInvBarcodeJS.produk_select");
|
||||
$this->app->json([ $obj->db_table("divBrowProduk") ]);
|
||||
}
|
||||
|
||||
public function auto_produk() {
|
||||
$tcari = Param::Get("Auto_Query", "");
|
||||
$ajson['autodata'] = [];
|
||||
$bcode = 0; $arec = [];
|
||||
|
||||
// Cari by SKU + Barcode
|
||||
$_row = $this->db->fetchRow("SELECT P.InvID,P.Nama_Lengkap,CONCAT(P.SatuanID,':',P.VarianID,':',P.Kode_SKU) Data2 FROM (SELECT * FROM inv_produk_join WHERE Grup_MemberID=? AND Aktif=1 AND (Kode_SKU=? OR Kode_Barcode=?)) P", [$this->id_grup, $tcari, $tcari]);
|
||||
if ($_row) {
|
||||
$bcode = 1;
|
||||
$arec = $_row->getData();
|
||||
}
|
||||
if ($bcode === 1) {
|
||||
$ajson['autodata'][] = ['value'=>$arec['InvID'], 'text'=>$arec['Nama_Lengkap'], 'data'=>$arec['Data2'], 'bc'=>1];
|
||||
} else {
|
||||
$stat = $this->db->runQuery("SELECT P.InvID,P.Nama_Lengkap,P.Kode_SKU,CONCAT(P.SatuanID,':',P.VarianID,':',P.Kode_SKU) Data2 FROM (SELECT * FROM inv_produk_join WHERE Barcode_Nama LIKE ? AND Grup_MemberID=? AND Aktif=1) P ORDER BY P.Nama_Produk,P.Qty LIMIT 50", ['%'.$tcari.'%', $this->id_grup]);
|
||||
while ($row = $stat->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$ajson['autodata'][] = ['value'=>$row['InvID'], 'text'=>$row['Nama_Lengkap'], 'html'=>'<span class="text-primary">'.$row['Kode_SKU'].'</span> '.$row['Nama_Lengkap'], 'data'=>$row['Data2'], 'bc'=>0];
|
||||
}
|
||||
}
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function barcode() {
|
||||
$id_inv = Param::Int("InvID", 0);
|
||||
$id_sat = Param::Int("SatuanID", 0);
|
||||
$id_var = Param::Int("VarianID", 0);
|
||||
$qty = Param::Int("Qty", 3);
|
||||
$nkolom = (str_contains(Param::Get("Printer"), "XP")) ? 2 : 3;
|
||||
$nbaris = (int) ceil($qty / $nkolom);
|
||||
$ajson = [];
|
||||
|
||||
$barang = $this->db->fetchRow("SELECT Kode_SKU,Harga_Jual,LEFT(Nama_Lengkap,20) Nama FROM inv_produk_join WHERE InvID=? AND SatuanID=? AND VarianID=? AND Grup_MemberID=? ORDER BY Harga_Jual DESC LIMIT 1", [$id_inv, $id_sat, $id_var, $this->id_grup]);
|
||||
if ($barang) {
|
||||
$ajson = ['type' => "epl", 'config' => ['times' => 1], 'content' => $this->gen_bc_epl("Rp.".rupiah($barang->Harga_Jual), $barang->Nama, $barang->Kode_SKU, $nbaris, $nkolom)];
|
||||
}
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function load_printer() {
|
||||
$aprint = json_decode(stripslashes(Param::Get("Printer", "[]")), true);
|
||||
$avalue = [['value'=>"", 'html'=>"Pilih Printer"]];
|
||||
$tdefp = Param::Get("DefPrint", "");
|
||||
$this->db->runQuery("DELETE FROM app_printer WHERE IP=? AND CabID=?", [$this->ip_addr, $this->id_cab]);
|
||||
foreach ($aprint as $_val) {
|
||||
if (!empty($_val)) {
|
||||
$this->db->runQuery("INSERT IGNORE INTO app_printer SET IP=?,CabID=?,N_Printer=?,Defa=?", [$this->ip_addr, $this->id_cab, $_val, ($tdefp === $_val) ? 1 : 0]);
|
||||
}
|
||||
}
|
||||
$aprinter = $this->db->fetchAll("SELECT * FROM app_printer WHERE IP=? AND CabID=?", [$this->ip_addr, $this->id_cab]);
|
||||
foreach ($aprinter as $row) $avalue[] = ['value'=>$row['N_Printer'], 'html'=>$row['N_Printer']];
|
||||
$ajson[] = ['type'=>"option", 'id'=>"Printer", 'avalue'=>$avalue];
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$form = new Form($this->app);
|
||||
$tsku = $form->textbox("_", "Kode_SKU", null, false, false);
|
||||
$tproduk = $form->textauto("_", "Nama_Produk", ['value'=>0,'text'=>""], true, true, "nama barang");
|
||||
$tprt = $form->option_db("_", "Printer", "", true, false, "app_printer", ["N_Printer","N_Printer"], "IP='".$this->ip_addr."' AND CabID='".(string) $this->id_cab."'", [0,"Pilih Printer"]);
|
||||
$tqty = $form->textbox("_", "Qty", 3, true, false, "number");
|
||||
$ajson['html'] = '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label">Kode SKU</label>
|
||||
<div class="col-sm-6 col-lg-5">'.$tsku.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Nama_Produk">Nama Barang</label>
|
||||
<div class="col"><div class="input-group">'.$tproduk.'<button id="butBrowProduk" class="btn btn-info" type="button"><i class="bi-bag"></i></button></div></div>
|
||||
</div>
|
||||
<div class="row mb-1"><div class="col"><hr class="my-2"></div></div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Printer">Nama Printer</label>
|
||||
<div class="col"><div class="input-group">'.$tprt.'<button id="butLoadPrinter" class="btn btn-warning" type="button"><i class="bi-printer"></i></button></div></div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Qty">Jumlah Stiker</label>
|
||||
<div class="col-sm-5 col-lg-3"><div class="input-group">'.$tqty.Invesa::Form_Info("Untuk menghemat stiker, bisa gunakan jumlah cetak dalam kelipatan 3.").'</div></div>
|
||||
</div>
|
||||
<input type="hidden" id="InvID" value="0" >
|
||||
<input type="hidden" id="SatuanID" value="0" >
|
||||
<input type="hidden" id="VarianID" value="0" >';
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
private function gen_bc_epl(string $harga="", string $nama="", string $barc="", int $baris=1, int $kolom=3): array {
|
||||
if ($kolom == 2) {
|
||||
//q582
|
||||
$hasil = ['N',
|
||||
'Q120,24',
|
||||
'A6,99,3,3,1,1,N,"Cahaya"',
|
||||
'A26,83,3,3,1,1,N,"Masa"',
|
||||
'A14,1,0,2,1,1,N,"'.$nama.'"',
|
||||
'B54,22,0,1,2,5,60,N,"'.$barc.'"',
|
||||
'A64,75,0,4,1,1,N,"'.$harga.'"',
|
||||
'A238,22,1,3,1,1,N,"HSmart"',
|
||||
'A258,30,1,3,1,1,N,"RYN\'S"',
|
||||
'A293,99,3,3,1,1,N,"Cahaya"',
|
||||
'A313,83,3,3,1,1,N,"Masa"',
|
||||
'A301,1,0,2,1,1,N,"'.$nama.'"',
|
||||
'B341,22,0,1,2,5,60,N,"'.$barc.'"',
|
||||
'A351,72,0,4,1,1,N,"'.$harga.'"',
|
||||
'A525,22,1,3,1,1,N,"HSmart"',
|
||||
'A545,30,1,3,1,1,N,"RYN\'S"',
|
||||
'P'.$baris,
|
||||
''];
|
||||
|
||||
} else {
|
||||
//q960
|
||||
$hasil = ['N',
|
||||
'Q120,24',
|
||||
'A4,98,3,3,1,1,N,"Cahaya"',
|
||||
'A24,82,3,3,1,1,N,"Masa"',
|
||||
'A12,0,0,2,1,1,N,"'.$nama.'"',
|
||||
'B52,21,0,1,2,5,60,N,"'.$barc.'"',
|
||||
'A62,74,0,4,1,1,N,"'.$harga.'"',
|
||||
'A236,21,1,3,1,1,N,"HSmart"',
|
||||
'A256,29,1,3,1,1,N,"RYN\'S"',
|
||||
'A284,98,3,3,1,1,N,"Cahaya"',
|
||||
'A304,82,3,3,1,1,N,"Masa"',
|
||||
'A292,0,0,2,1,1,N,"'.$nama.'"',
|
||||
'B332,21,0,1,2,5,60,N,"'.$barc.'"',
|
||||
'A342,71,0,4,1,1,N,"'.$harga.'"',
|
||||
'A516,21,1,3,1,1,N,"HSmart"',
|
||||
'A536,29,1,3,1,1,N,"RYN\'S"',
|
||||
'A564,98,3,3,1,1,N,"Cahaya"',
|
||||
'A584,82,3,3,1,1,N,"Masa"',
|
||||
'A572,0,0,2,1,1,N,"'.$nama.'"',
|
||||
'B612,21,0,1,2,5,60,N,"'.$barc.'"',
|
||||
'A622,71,0,4,1,1,N,"'.$harga.'"',
|
||||
'A796,21,1,3,1,1,N,"HSmart"',
|
||||
'A816,29,1,3,1,1,N,"RYN\'S"',
|
||||
'P'.$baris,
|
||||
''];
|
||||
}
|
||||
return $hasil;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Report/Inv/HutangController
|
||||
Description : Laporan Hutang Supplier
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : July 17th, 2011.
|
||||
Last Modified : October 8th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Report\Inv;
|
||||
|
||||
use flight\Engine;
|
||||
use flight\database\SimplePdo;
|
||||
use flight\Session;
|
||||
use Webapp\Data\Xlsx;
|
||||
use Webapp\Printer\PrintHTML;
|
||||
use Webapp\Web\Form;
|
||||
use Webapp\Web\Param;
|
||||
|
||||
class HutangController {
|
||||
|
||||
private int $id_cab;
|
||||
private string $reg_name;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session) {
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->id_cab = Param::Int("CabID", 0);
|
||||
$this->reg_name = $session->get('WEB_APP')['REG_NAME'];
|
||||
}
|
||||
|
||||
private function prepare() {
|
||||
$apre = [
|
||||
'tipe' => Param::Get("Tipe", "R"), // R or D
|
||||
'id_sup' => Param::Int("SupID", 0),
|
||||
'tgl_from' => Param::Get("Tgl_From"),
|
||||
'tgl_to' => Param::Get("Tgl_To"),
|
||||
];
|
||||
|
||||
$apre['nama_sup'] = ($apre['id_sup'] > 0) ? ($this->db->fetchField("SELECT CONCAT(Nama_Sup,' (',Kode_Sup,')') Nama FROM para_supplier WHERE SupID=?", [$apre['id_sup']]) ?? '') : '';
|
||||
|
||||
// generate report header
|
||||
$apre['periode'] = $apre['tgl_from'] . ($apre['tgl_from'] !== $apre['tgl_to'] ? ' s/d '.$apre['tgl_to'] : '');
|
||||
|
||||
$tsql = ''; $asql = [tgl_sql2str($apre['tgl_from']), tgl_sql2str($apre['tgl_to'])];
|
||||
if ($this->id_cab > 0) {
|
||||
$tsql .= " AND CabID=?";
|
||||
array_push($asql, $this->id_cab);
|
||||
}
|
||||
if ($apre['id_sup'] > 0) {
|
||||
$tsql .= " AND SupID=?";
|
||||
array_push($asql, $apre['id_sup']);
|
||||
}
|
||||
|
||||
if ($apre['tipe'] === "R") {
|
||||
$apre['query'] = $this->db->runQuery("SELECT B.*,S.Nama_Sup FROM (SELECT SupID,SUM(Real_Beli) Total_Hutang,SUM(Total_Bayar+Total_Potong) Total_Bayar FROM inv_beli WHERE Lunas=0 AND (Tgl_Beli BETWEEN ? AND ?)".$tsql." GROUP BY SupID) B LEFT JOIN para_supplier S ON (B.SupID=S.SupID) ORDER BY S.Nama_Sup", $asql);
|
||||
} else {
|
||||
$apre['query'] = $this->db->runQuery("SELECT B.*,CONCAT(S.Nama_Sup,IF(B.Data_Beli=1,'',' <i>(Retur)</i>')) Nama_Sup,B.Real_Beli Total_Hutang,B.Total_Bayar+B.Total_Potong Total_Bayar FROM (SELECT * FROM inv_beli WHERE Lunas=0 AND (Tgl_Beli BETWEEN ? AND ?)".$tsql.") B LEFT JOIN para_supplier S ON (B.SupID=S.SupID) ORDER BY B.No_Beli", $asql);
|
||||
}
|
||||
return $apre;
|
||||
}
|
||||
|
||||
public function print() {
|
||||
$apre = $this->prepare();
|
||||
|
||||
$pre = new PrintHTML($this->app);
|
||||
$pre->add_title([strtoupper($this->reg_name), ($apre['tipe']==="R"?"REKAP":"DETAIL")." HUTANG SUPPLIER", "Periode : ".$apre['periode']]);
|
||||
|
||||
if ($apre['tipe'] === "R") {
|
||||
$pre->add_field("No.",10,"C");
|
||||
$pre->add_field("Nama Supplier",50,"L");
|
||||
$pre->add_field("Jumlah Faktur",20,"R","rupiah");
|
||||
$pre->add_field("Jumlah Bayar",20,"R","rupiah");
|
||||
$pre->add_field("Sisa Hutang",20,"R","rupiah");
|
||||
|
||||
if ($apre['id_sup'] > 0) $pre->add_sub_title("Nama Supplier : ".$apre['nama_sup']);
|
||||
|
||||
$pre->show_titles();
|
||||
$pre->show_headers();
|
||||
|
||||
$tot_hutang = 0; $tot_bayar = 0; $nomor = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_hutang += $row['Total_Hutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$pre->add_row([ ++$nomor, $row['Nama_Sup'], $row['Total_Hutang'], $row['Total_Bayar'], $row['Total_Hutang'] - $row['Total_Bayar'] ]);
|
||||
}
|
||||
$pre->add_span([ ["GRAND TOTAL",2,"R,B"],[$tot_hutang,1,"R,B","rupiah"],[$tot_bayar,1,"R,B","rupiah"],[$tot_hutang-$tot_bayar,1,"R,B","rupiah"] ]);
|
||||
|
||||
} else {
|
||||
$pre->add_field("No. Nota",30,"C");
|
||||
$pre->add_field("Tgl. Nota",30,"C", "tgl_sql2str");
|
||||
$pre->add_field("Nama Supplier",50,"L");
|
||||
$pre->add_field("Jumlah",20,"R","rupiah");
|
||||
$pre->add_field("Bayar",20,"R","rupiah");
|
||||
$pre->add_field("Sisa Hutang",20,"R","rupiah");
|
||||
|
||||
if ($apre['id_sup'] > 0) $pre->add_sub_title("Nama Supplier : ".$apre['nama_sup']);
|
||||
|
||||
$pre->show_titles();
|
||||
$pre->show_headers();
|
||||
|
||||
$tot_hutang = 0; $tot_bayar = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_hutang += $row['Total_Hutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$pre->add_row([ $row['No_Beli'], $row['Tgl_Beli'], $row['Nama_Sup'], $row['Total_Hutang'], $row['Total_Bayar'], $row['Total_Hutang'] - $row['Total_Bayar'] ]);
|
||||
}
|
||||
$pre->add_span([ ["GRAND TOTAL",3,"R,B"],[$tot_hutang,1,"R,B","rupiah"],[$tot_bayar,1,"R,B","rupiah"],[$tot_hutang-$tot_bayar,1,"R,B","rupiah"] ]);
|
||||
}
|
||||
$pre->add_stamp(1, true);
|
||||
$pre->show();
|
||||
}
|
||||
|
||||
public function excel() {
|
||||
$apre = $this->prepare();
|
||||
$xls = new Xlsx($this->app);
|
||||
$xls->set_meta([
|
||||
'title' => "Data Hutang Supplier",
|
||||
'desc' => "Export Data Hutang Supplier"
|
||||
]);
|
||||
$xls->add_title([ $this->reg_name, "DATA ".($apre['tipe']==="R"?"REKAP":"DETAIL")." HUTANG SUPPLIER", "Periode : ".$apre['periode'] ]);
|
||||
|
||||
if ($apre['tipe'] === "R") {
|
||||
$xls->add_field("No.", 5, "@integer");
|
||||
$xls->add_field("Nama Supplier", 25, "@text");
|
||||
$xls->add_field("Jumlah Faktur", 15, "#,##0.00");
|
||||
$xls->add_field("Jumlah Bayar", 15, "#,##0.00");
|
||||
$xls->add_field("Sisa Hutang", 15, "#,##0.00");
|
||||
$xls->add_sheet("".str_replace("s/d","-",$apre['periode']));
|
||||
|
||||
if ($apre['id_sup'] > 0) $xls->add_sub_title("Nama Supplier : ".$apre['nama_sup']);
|
||||
|
||||
$xls->show_titles();
|
||||
$xls->show_headers();
|
||||
|
||||
$tot_hutang = 0; $tot_bayar = 0; $nomor = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_hutang += $row['Total_Hutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$xls->add_row([ ++$nomor, $row['Nama_Sup'], $row['Total_Hutang'], $row['Total_Bayar'], $row['Total_Hutang'] - $row['Total_Bayar'] ]);
|
||||
}
|
||||
$xls->add_row_bold([ "", "GRAND TOTAL", $tot_hutang, $tot_bayar, $tot_hutang-$tot_bayar ]);
|
||||
|
||||
} else {
|
||||
$xls->add_field("No. Nota", 15, "@");
|
||||
$xls->add_field("Tgl. Nota", 12, "@date");
|
||||
$xls->add_field("Nama Supplier", 20, "@text");
|
||||
$xls->add_field("Jumlah", 15, "#,##0.00");
|
||||
$xls->add_field("Bayar", 15, "#,##0.00");
|
||||
$xls->add_field("Sisa Hutang", 15, "#,##0.00");
|
||||
$xls->add_sheet("".str_replace("s/d","-",$apre['periode']));
|
||||
|
||||
if ($apre['id_sup'] > 0) $xls->add_sub_title("Nama Supplier : ".$apre['nama_sup']);
|
||||
|
||||
$xls->show_titles();
|
||||
$xls->show_headers();
|
||||
|
||||
$tot_hutang = 0; $tot_bayar = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_hutang += $row['Total_Hutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$xls->add_row([ $row['No_Beli'], $row['Tgl_Beli'], $row['Nama_Sup'], $row['Total_Hutang'], $row['Total_Bayar'], $row['Total_Hutang'] - $row['Total_Bayar'] ]);
|
||||
}
|
||||
$xls->add_row_bold([ "", "", "GRAND TOTAL", $tot_hutang, $tot_bayar, $tot_hutang-$tot_bayar ]);
|
||||
}
|
||||
$xls->add_stamp(1, true);
|
||||
$xls->download("Data Hutang Supplier ".str_replace("s/d","-",$apre['periode']).".xlsx");
|
||||
unset($xls);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$form = new Form($this->app);
|
||||
$ttipe = $form->radio("_", "Tipe", "R", true, false, ["R"=>"Rekap","D"=>"Detail"]);
|
||||
$tcab = $form->option_db("_", "CabID", $this->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"]);
|
||||
$tfrom = $form->datebox("_", "Tgl_From", tgl_ymd(), true, false);
|
||||
$tto = $form->datebox("_", "Tgl_To", tgl_ymd(), true, false);
|
||||
$ajson['html'] = '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 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-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="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>';
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Report/Inv/LabelController
|
||||
Description : Cetak Label Harga
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : September 13th, 2014.
|
||||
Last Modified : October 16th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Report\Inv;
|
||||
|
||||
use flight\Engine;
|
||||
use flight\database\SimplePdo;
|
||||
use flight\Session;
|
||||
use Webapp\Web\Form;
|
||||
use Webapp\Web\Param;
|
||||
use Webapp\Web\Table;
|
||||
|
||||
class LabelController {
|
||||
|
||||
private string $mode;
|
||||
private string $mode_detail;
|
||||
private int $id_grup;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session) {
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->mode = Param::Get("mode", "");
|
||||
$this->mode_detail = Param::Get("mode_detail", "");
|
||||
$this->id_grup = $session->get('APP_INV')['ECERANID'] ?? 0;
|
||||
}
|
||||
|
||||
public function table_detail() {
|
||||
if ( $this->mode_detail === "empty" ) {
|
||||
$this->db->runQuery("TRUNCATE rep_label");
|
||||
} else if ( $this->mode_detail === "update" ) {
|
||||
$this->db->runQuery("UPDATE rep_label SET Nama_Produk=? WHERE ID=?", [Param::Get("Nama_Produk"), Param::Int("ID", 0)]);
|
||||
} else if ( $this->mode_detail === "delete" ) {
|
||||
$this->db->runQuery("DELETE FROM rep_label WHERE ID=?", [Param::Int("ID", 0)]);;
|
||||
} else if ( $this->mode_detail === "simpan-produk" ) {
|
||||
$list_id = Param::Get("List_CB_InvID", "0");
|
||||
if ($list_id !== "0") {
|
||||
$alist = explode(",", $list_id);
|
||||
$this->db->runQuery("INSERT INTO rep_label (InvID,Nama_Produk,Harga_Jual,UserID) SELECT InvID,LEFT(Nama_Produk,25),Harga_Jual,? FROM inv_produk_join WHERE InvID IN (?) AND Grup_MemberID=?", [$this->app->user()->id(), $alist, $this->id_grup]);
|
||||
}
|
||||
} else if ( $this->mode_detail === "simpan-grup" ) {
|
||||
$id_grup = Param::Int("Grup_InvID", 0);
|
||||
if ($id_grup > 0) {
|
||||
$this->db->runQuery("INSERT INTO rep_label (InvID,Nama_Produk,Harga_Jual,UserID) SELECT InvID,LEFT(Nama_Produk,25),Harga_Jual,? FROM inv_produk_join WHERE Aktif=1 AND Grup_MemberID=? AND Grup_InvID=? AND Harga_Jual>0", [$this->app->user()->id(), $this->id_grup, $id_grup]);
|
||||
}
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("rep_label", "*", "", []);
|
||||
$obj->add_field("ID", "No", "c");
|
||||
$obj->add_field("Nama_Produk", "Nama Barang", "awr");
|
||||
$obj->add_field("Harga_Jual", "Harga @", "r", "rupiah");
|
||||
$obj->set_field_order("ID", "D");
|
||||
$obj->add_row_btn("clipboard", "Ubah", "RepoInvLabelJS.detail_ubah");
|
||||
$obj->add_row_btn("trash", "Hapus", "RepoInvLabelJS.detail_hapus", "UserID", $this->app->user()->id());
|
||||
$obj->set_func_btn("RepoInvLabelJS.produk_brow", '<i class="bi-plus-lg me-1"></i> Barang');
|
||||
$obj->set_func_btn("RepoInvLabelJS.grup_brow", '<i class="bi-table me-1"></i> Browse');
|
||||
$ajson[] = $obj->json_table("divDetailTabel");
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function brow_grup() {
|
||||
$tcari = Param::Get("Cari_Grup");
|
||||
$tsql = ''; $asql = [];
|
||||
if (!empty($tcari)) {
|
||||
$tsql .= " AND CONCAT(Kode_Grup,Nama_Grup) LIKE ?";
|
||||
array_push($asql, '%' . $tcari . '%');
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("inv_produk_grup", "*", "Aktif=1".$tsql, $asql);
|
||||
$obj->add_field("Grup_InvID", "ID", "hid");
|
||||
$obj->add_field("Kode_Grup", "Kode", "c");
|
||||
$obj->add_field("Nama_Grup", "Nama Grup Barang", "awr");
|
||||
$obj->set_field_order("Kode_Grup", "A");
|
||||
$obj->set_func_select("RepoInvLabelJS.grup_select");
|
||||
$this->app->json([ $obj->db_table("divBrowGrup") ]);
|
||||
}
|
||||
|
||||
public function brow_produk() {
|
||||
$tcari = Param::Get("Cari_Produk");
|
||||
$tsql = ''; $asql = [];
|
||||
if (!empty($tcari)) {
|
||||
$tsql .= " AND Barcode_Nama LIKE ?";
|
||||
array_push($asql, '%' . $tcari . '%');
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("(SELECT * FROM inv_produk_join WHERE Aktif=1".$tsql." GROUP BY InvID,SatuanID,VarianID) P LEFT JOIN rep_label L ON (L.InvID=P.InvID)", "P.*,IF(IFNULL(L.InvID,0)=0,'N','Y') Pilih", "", $asql);
|
||||
$obj->add_field("InvID", "ID", "hid");
|
||||
$obj->add_field("SatuanID", "ID", "hid");
|
||||
$obj->add_field("VarianID", "ID", "hid");
|
||||
$obj->add_field("Kode_SKU", "SKU", "c");
|
||||
$obj->add_field("Kode_Barcode", "Barcode", "c");
|
||||
$obj->add_field("Nama_Lengkap", "Nama Barang", "awr");
|
||||
$obj->set_field_order("Kode_SKU", "A");
|
||||
$obj->add_row_checkbox("InvID", "Pilih", ['Y','N']);
|
||||
$this->app->json([ $obj->db_table("divBrowProduk") ]);
|
||||
}
|
||||
|
||||
public function form_detail() {
|
||||
$id = Param::Int("ID", 0);
|
||||
$atabel = [ 'ID'=>$id, 'Nama_Produk'=>"" ];
|
||||
if ($id > 0) {
|
||||
$_row = $this->db->fetchRow("SELECT * FROM rep_label WHERE ID=?", [$id]);
|
||||
if ($_row) $atabel = array_merge($atabel, $_row->getData());
|
||||
}
|
||||
|
||||
$form = new Form($this->app);
|
||||
$tproduk = $form->textbox("_", "Nama_Produk", $atabel['Nama_Produk'], true, false, "text");
|
||||
$ajson['html'] = '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Nama_Produk">Nama Barang</label>
|
||||
<div class="col">'.$tproduk.'</div>
|
||||
</div>
|
||||
<input type="hidden" id="ID" value="'.$atabel['ID'].'" >
|
||||
<input type="hidden" id="mode_detail" value="'.$this->mode_detail.'" >';
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function print() {
|
||||
$query = $this->db->runQuery("SELECT * FROM rep_label ORDER BY ID");
|
||||
if ($query->rowCount() === 0) return false;
|
||||
|
||||
$_head = '<table width="100%"><tr>';
|
||||
$_line = '<td class="center" style="font-size:16pt;height:100px;width:65mm;padding:10px;border: dashed 1px #000;font-family:verdana;"><div style="font-size:18pt;height:50px;padding-bottom:10px;">%s</div>%s</td>';
|
||||
$ni = 1; $nb = 1; $cont = "";
|
||||
while ($row = $query->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
if ($ni === 4) {
|
||||
if ($nb === 8) {
|
||||
$cont .= '</tr></table><p id="linebreak">................ page break ................</p><p id="pagebreak"> </p>' . $_head;
|
||||
$nb = 0;
|
||||
} else {
|
||||
$cont .= '</tr><tr>';
|
||||
}
|
||||
$ni = 1;
|
||||
$nb++;
|
||||
}
|
||||
$cont .= sprintf($_line, $row['Nama_Produk'], "Rp. ".rupiah($row['Harga_Jual']));
|
||||
$ni++;
|
||||
}
|
||||
if ($ni < 4) {
|
||||
while ($ni < 4) {
|
||||
$cont .= sprintf($_line, "", "");
|
||||
$ni++;
|
||||
}
|
||||
}
|
||||
echo '<p id="autopage"> </p>' . $_head . $cont . "</tr></table>";
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->app->json(['html' => '
|
||||
<div class="fade-in">
|
||||
<div class="card"><div class="card-body">
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link active" id="tx-tab" data-bs-toggle="tab" data-bs-target="#tx" type="button" role="tab" aria-controls="tx" aria-selected="true"><i class="bi-printer me-2"></i>Cetak Label Harga</button>
|
||||
</li>
|
||||
<li class="nav-item ms-auto">
|
||||
<button class="btn btn-warning mb-1 ms-2" id="butHapus" type="button"><i class="bi-trash me-2"></i>Hapus</button>
|
||||
<button class="btn btn-secondary mb-1 ms-2" id="butPrint" type="button"><i class="bi-printer me-2"></i>Cetak</button>
|
||||
<button class="btn btn-secondary mb-1 ms-2" id="butPreview" type="button"><i class="bi-display me-2"></i>Pratinjau</button>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="tab-content border border-top-0 p-3">
|
||||
<div class="tab-pane fade active show" id="tx" role="tabpanel" aria-labelledby="tx-tab">
|
||||
<div id="divDetailTabel"> </div>
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>'
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,245 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Report/Inv/PiutangController
|
||||
Description : Laporan Piutang Member
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : July 17th, 2011.
|
||||
Last Modified : October 8th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Report\Inv;
|
||||
|
||||
use flight\Engine;
|
||||
use flight\database\SimplePdo;
|
||||
use flight\Session;
|
||||
use Webapp\Data\Xlsx;
|
||||
use Webapp\Printer\PrintHTML;
|
||||
use Webapp\Web\Form;
|
||||
use Webapp\Web\Param;
|
||||
use Webapp\Web\Table;
|
||||
|
||||
class PiutangController {
|
||||
|
||||
private int $id_cab;
|
||||
private string $reg_name;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session) {
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->id_cab = Param::Int("CabID", 0);
|
||||
$this->reg_name = $session->get('WEB_APP')['REG_NAME'];
|
||||
}
|
||||
|
||||
public function brow_member() {
|
||||
$tcari = Param::Get("Cari_Member");
|
||||
$tsql = ''; $asql = [1];
|
||||
if (!empty($tcari)) {
|
||||
$tsql .= " AND CONCAT_WS(Kode_Member,Nama_Member,Alamat_Member,Telp_Member) LIKE ?";
|
||||
$asql[] = '%' . $tcari . '%';
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("para_member", "*,CONCAT(IF(Kode_Member='','',CONCAT(Kode_Member,' - ')),Nama_Member) Kode_Nama", "Aktif=?".$tsql, $asql);
|
||||
$obj->add_field("MemberID", "ID", "hid");
|
||||
$obj->add_field("Kode_Nama", "Kode_Nama", "hid");
|
||||
$obj->add_field("Kode_Member", "Kode", "c");
|
||||
$obj->add_field("Nama_Member", "Nama Member", "awr");
|
||||
$obj->add_field("Alamat_Member", "Alamat", "awr");
|
||||
$obj->add_field("Telp_Member", "Telp.", "awr");
|
||||
$obj->set_field_order("Nama_Member", "A");
|
||||
$obj->set_func_select("RepoInvPiutangJS.member_select");
|
||||
$this->app->json([ $obj->db_table("divBrowMember") ]);
|
||||
}
|
||||
|
||||
public function auto_member() {
|
||||
$tcari = Param::Get("Auto_Query", "");
|
||||
$ajson['autodata'] = [];
|
||||
|
||||
$stat = $this->db->runQuery("SELECT MemberID,Grup_MemberID,Kode_Member,Nama_Member,CONCAT(IF(Kode_Member='','',CONCAT(Kode_Member,' - ')),Nama_Member) Kode_Nama FROM para_member WHERE Aktif=1 AND CONCAT(Kode_Member,Nama_Member,Alamat_Member,Telp_Member) LIKE ? ORDER BY Nama_Member LIMIT 50", ['%'.$tcari.'%']);
|
||||
while ($row = $stat->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$ajson['autodata'][] = ['value'=>$row['MemberID'], 'text'=>$row['Kode_Nama'], 'html'=>'<span class="text-primary">'.$row['Kode_Member'].'</span> '.$row['Nama_Member'], 'data'=>0, 'bc'=>0];
|
||||
}
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
private function prepare() {
|
||||
$apre = [
|
||||
'tipe' => Param::Get("Tipe", "R"), // R or D
|
||||
'id_mem' => Param::Int("MemberID", 0),
|
||||
'tgl_from' => Param::Get("Tgl_From"),
|
||||
'tgl_to' => Param::Get("Tgl_To"),
|
||||
];
|
||||
|
||||
$apre['nama_mem'] = ($apre['id_mem'] > 0) ? ($this->db->fetchField("SELECT CONCAT(Nama_Member,' (',Kode_Member,')') Nama FROM para_member WHERE MemberID=?", [$apre['id_mem']]) ?? '') : '';
|
||||
|
||||
// generate report header
|
||||
$apre['periode'] = $apre['tgl_from'] . ($apre['tgl_from'] !== $apre['tgl_to'] ? ' s/d '.$apre['tgl_to'] : '');
|
||||
|
||||
$tsql = ''; $asql = [tgl_sql2str($apre['tgl_from']), tgl_sql2str($apre['tgl_to'])];
|
||||
if ($this->id_cab > 0) {
|
||||
$tsql .= " AND CabID=?";
|
||||
array_push($asql, $this->id_cab);
|
||||
}
|
||||
if ($apre['id_mem'] > 0) {
|
||||
$tsql .= " AND MemberID=?";
|
||||
array_push($asql, $apre['id_mem']);
|
||||
}
|
||||
|
||||
if ($apre['tipe'] === "R") {
|
||||
$apre['query'] = $this->db->runQuery("SELECT J.*,O.Nama_Member FROM (SELECT MemberID,SUM(Total_Jual-Total_Diskon) Total_Piutang,SUM(Total_Bayar+Total_Potong) Total_Bayar, SUM(Total_Jual-Total_Diskon-Total_Bayar-Total_Potong) Total_Sisa FROM inv_jual WHERE Lunas=0 AND (Tgl_Jual BETWEEN ? AND ?)".$tsql." GROUP BY MemberID) J LEFT JOIN para_member O ON (J.MemberID=O.MemberID) ORDER BY O.Nama_Member", $asql);
|
||||
} else {
|
||||
$apre['query'] = $this->db->runQuery("SELECT J.*,O.Nama_Member FROM (SELECT *,Total_Jual-Total_Diskon Total_Piutang,Total_Jual-Total_Diskon-Total_Bayar-Total_Potong Total_Sisa FROM inv_jual WHERE Lunas=0 AND (Tgl_Jual BETWEEN ? AND ?)".$tsql.") J LEFT JOIN para_member O ON (J.MemberID=O.MemberID) ORDER BY J.No_Jual", $asql);
|
||||
}
|
||||
return $apre;
|
||||
}
|
||||
|
||||
public function print() {
|
||||
$apre = $this->prepare();
|
||||
|
||||
$pre = new PrintHTML($this->app);
|
||||
$pre->add_title([strtoupper($this->reg_name), ($apre['tipe']==="R"?"REKAP":"DETAIL")." PIUTANG MEMBER", "Periode : ".$apre['periode']]);
|
||||
|
||||
if ($apre['tipe'] === "R") {
|
||||
$pre->add_field("No.",10,"C");
|
||||
$pre->add_field("Nama Member",50,"L");
|
||||
$pre->add_field("Jumlah Faktur",20,"R","rupiah");
|
||||
$pre->add_field("Jumlah Bayar",20,"R","rupiah");
|
||||
$pre->add_field("Sisa Piutang",20,"R","rupiah");
|
||||
|
||||
if ($apre['id_mem'] > 0) $pre->add_sub_title("Nama Member : ".$apre['nama_mem']);
|
||||
|
||||
$pre->show_titles();
|
||||
$pre->show_headers();
|
||||
|
||||
$tot_piutang = 0; $tot_bayar = 0; $nomor = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_piutang += $row['Total_Piutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$pre->add_row([ ++$nomor, $row['Nama_Member'], $row['Total_Piutang'], $row['Total_Bayar'], $row['Total_Sisa'] ]);
|
||||
}
|
||||
$pre->add_span([ ["GRAND TOTAL",2,"R,B"],[$tot_piutang,1,"R,B","rupiah"],[$tot_bayar,1,"R,B","rupiah"],[$tot_piutang-$tot_bayar,1,"R,B","rupiah"] ]);
|
||||
|
||||
} else {
|
||||
$pre->add_field("No. Nota",30,"C");
|
||||
$pre->add_field("Tgl. Nota",30,"C", "tgl_sql2str");
|
||||
$pre->add_field("Nama Member",50,"L");
|
||||
$pre->add_field("Jumlah",20,"R","rupiah");
|
||||
$pre->add_field("Bayar",20,"R","rupiah");
|
||||
$pre->add_field("Sisa Piutang",20,"R","rupiah");
|
||||
|
||||
if ($apre['id_mem'] > 0) $pre->add_sub_title("Nama Member : ".$apre['nama_mem']);
|
||||
|
||||
$pre->show_titles();
|
||||
$pre->show_headers();
|
||||
|
||||
$tot_piutang = 0; $tot_bayar = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_piutang += $row['Total_Piutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$pre->add_row([ $row['No_Jual'], $row['Tgl_Jual'], $row['Nama_Member'], $row['Total_Piutang'], $row['Total_Bayar'], $row['Total_Sisa'] ]);
|
||||
}
|
||||
$pre->add_span([ ["GRAND TOTAL",3,"R,B"],[$tot_piutang,1,"R,B","rupiah"],[$tot_bayar,1,"R,B","rupiah"],[$tot_piutang-$tot_bayar,1,"R,B","rupiah"] ]);
|
||||
}
|
||||
$pre->add_stamp(1, true);
|
||||
$pre->show();
|
||||
}
|
||||
|
||||
public function excel() {
|
||||
$apre = $this->prepare();
|
||||
$xls = new Xlsx($this->app);
|
||||
$xls->set_meta([
|
||||
'title' => "Data Piutang Member",
|
||||
'desc' => "Export Data Piutang Member"
|
||||
]);
|
||||
$xls->add_title([ $this->reg_name, "DATA ".($apre['tipe']==="R"?"REKAP":"DETAIL")." PIUTANG MEMBER", "Periode : ".$apre['periode'] ]);
|
||||
|
||||
if ($apre['tipe'] === "R") {
|
||||
$xls->add_field("No.", 5, "@integer");
|
||||
$xls->add_field("Nama Member", 25, "@text");
|
||||
$xls->add_field("Jumlah Faktur", 15, "#,##0.00");
|
||||
$xls->add_field("Jumlah Bayar", 15, "#,##0.00");
|
||||
$xls->add_field("Sisa Piutang", 15, "#,##0.00");
|
||||
$xls->add_sheet("".str_replace("s/d","-",$apre['periode']));
|
||||
|
||||
if ($apre['id_mem'] > 0) $xls->add_sub_title("Nama Member : ".$apre['nama_mem']);
|
||||
|
||||
$xls->show_titles();
|
||||
$xls->show_headers();
|
||||
|
||||
$tot_piutang = 0; $tot_bayar = 0; $nomor = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_piutang += $row['Total_Piutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$xls->add_row([ ++$nomor, $row['Nama_Member'], $row['Total_Piutang'], $row['Total_Bayar'], $row['Total_Sisa'] ]);
|
||||
}
|
||||
$xls->add_row_bold([ "", "GRAND TOTAL", $tot_piutang, $tot_bayar, $tot_piutang-$tot_bayar ]);
|
||||
|
||||
} else {
|
||||
$xls->add_field("No. Nota", 15, "@");
|
||||
$xls->add_field("Tgl. Nota", 12, "@date");
|
||||
$xls->add_field("Nama Member", 20, "@text");
|
||||
$xls->add_field("Jumlah", 15, "#,##0.00");
|
||||
$xls->add_field("Bayar", 15, "#,##0.00");
|
||||
$xls->add_field("Sisa Piutang", 15, "#,##0.00");
|
||||
$xls->add_sheet("".str_replace("s/d","-",$apre['periode']));
|
||||
|
||||
if ($apre['id_mem'] > 0) $xls->add_sub_title("Nama Member : ".$apre['nama_mem']);
|
||||
|
||||
$xls->show_titles();
|
||||
$xls->show_headers();
|
||||
|
||||
$tot_piutang = 0; $tot_bayar = 0;
|
||||
while ($row = $apre['query']->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$tot_piutang += $row['Total_Piutang'];
|
||||
$tot_bayar += $row['Total_Bayar'];
|
||||
$xls->add_row([ $row['No_Jual'], $row['Tgl_Jual'], $row['Nama_Member'], $row['Total_Piutang'], $row['Total_Bayar'], $row['Total_Sisa'] ]);
|
||||
}
|
||||
$xls->add_row_bold([ "", "", "GRAND TOTAL", $tot_piutang, $tot_bayar, $tot_piutang-$tot_bayar ]);
|
||||
}
|
||||
$xls->add_stamp(1, true);
|
||||
$xls->download("Data Piutang Member ".str_replace("s/d","-",$apre['periode']).".xlsx");
|
||||
unset($xls);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$form = new Form($this->app);
|
||||
$ttipe = $form->radio("_", "Tipe", "R", true, false, ["R"=>"Rekap","D"=>"Detail"]);
|
||||
$tcab = $form->option_db("_", "CabID", $this->id_cab, true, false, "para_cabang", ["CabID","Nama_Cab"], "Aktif=1 ORDER BY CabID", [0,"SEMUA CABANG"]);
|
||||
$tmem = $form->textauto("_", "Nama_Member", ['value'=>0,'text'=>"SEMUA MEMBER"], true, true, "nama member");
|
||||
$tfrom = $form->datebox("_", "Tgl_From", tgl_ymd(), true, false);
|
||||
$tto = $form->datebox("_", "Tgl_To", tgl_ymd(), true, false);
|
||||
$ajson['html'] = '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 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-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="Nama_Member">Nama Member</label>
|
||||
<div class="col"><div class="input-group">'.$tmem.'<button id="butBrowMember" class="btn btn-info" type="button"><i class="bi-people-fill"></i></button></div></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>
|
||||
<input type="hidden" id="MemberID" value="0" >';
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user