first commit
This commit is contained in:
@@ -0,0 +1,170 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
App. Name : INVENTORY AND SALES SYSTEMS
|
||||
Module : /apps/php/repo/label.php
|
||||
Desc. : PHP - Cetak Label Harga Barang
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : September 13th, 2014.
|
||||
Last Modified : October 5th, 2025.
|
||||
|
||||
(c) 2014 - 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\Table;
|
||||
use siaupheng\fonia3\Web\Form;
|
||||
|
||||
$db = $db ?? new MySQL();
|
||||
$ajson = [];
|
||||
$data = Param::Get("data");
|
||||
$mode_detail = Param::Get("mode_detail");
|
||||
$id_cab = Param::Get("CabID", 0);
|
||||
$id_grup = Param::Get("Grup_InvID", 0);
|
||||
|
||||
if ( $data == "master" ) {
|
||||
} else if ( $data == "tabel-detail" ) {
|
||||
if ($mode_detail == "empty") {
|
||||
$db->Query("TRUNCATE rep_label");
|
||||
} else if ($mode_detail == "update") {
|
||||
$db->Query("UPDATE rep_label SET Nama_Produk='".$db->SafeSQL(Param::Get("Nama_Produk"))."' WHERE ID='".Param::Get("ID",0)."'");
|
||||
} else if ($mode_detail == "delete") {
|
||||
$db->Query("DELETE FROM rep_label WHERE ID='".Param::Get("ID",0)."'");
|
||||
} else if ($mode_detail == "simpan-produk") {
|
||||
$alist = Param::Get_ArrayCBOX();
|
||||
foreach ($alist as $_key => $_val) {
|
||||
if ($_val=="Y") {
|
||||
$_adata = explode(":", $_key); $arec = [];
|
||||
$db->Query("SELECT LEFT(P.Nama_Produk,25) Nama_Produk,P.Harga_Jual FROM vi_inv_produk P WHERE P.InvID='".$_adata[0]."' AND P.SatuanID='".$_adata[1]."'");
|
||||
if ($db->Next()) $arec = $db->AllRow();
|
||||
if (count($arec) > 0) {
|
||||
$db->Query("INSERT INTO rep_label SET Nama_Produk='".$db->SafeSQL($arec['Nama_Produk'])."',Harga_Jual='".$arec['Harga_Jual']."',UserID='".user_id()."'");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($mode_detail == "simpan-grup") {
|
||||
if ($id_grup > 0) {
|
||||
$db->Query("INSERT INTO rep_label SELECT NULL,LEFT(P.Nama_Produk,25),P.Harga_Jual,'".user_id()."' FROM vi_inv_produk P WHERE P.Aktif=1 AND P.Grup_InvID='".$id_grup."' AND P.Harga_Jual>0");
|
||||
}
|
||||
}
|
||||
|
||||
$obj = new Table($db);
|
||||
$obj->set_query("SELECT * FROM rep_label");
|
||||
$obj->add_field("ID", "ID", "hid");
|
||||
$obj->add_field("Nama_Produk", "Nama Barang", "awr");
|
||||
$obj->add_field("Harga_Jual", "Harga @", "r", "rupiah");
|
||||
$obj->set_field_order("ID", "A");
|
||||
$obj->add_row_btn("clipboard", "Ubah", "RepoLabelJS.detail_ubah");
|
||||
$obj->add_row_btn("trash", "Hapus", "RepoLabelJS.detail_hapus", "UserID", user_id());
|
||||
$obj->set_func_btn("RepoLabelJS.produk_brow", '<i class="bi-plus-lg me-1"></i> Item');
|
||||
$obj->set_func_btn("RepoLabelJS.grup_brow", '<i class="bi-table me-1"></i> Grup');
|
||||
$obj->set_func_navi("RepoLabelJS.data_query('tabel-detail')");
|
||||
$ajson[] = $obj->json_table("divDetailTabel");
|
||||
|
||||
} else if ( $data == "brow-produk" ) {
|
||||
$tcari = trim(Param::Get("Cari_Produk"));
|
||||
$tsql = ($tcari=="") ? "" : " AND CONCAT(P.Kode_Barcode,P.Nama_Produk) LIKE '%".$tcari."%'";
|
||||
|
||||
$obj = new Table($db);
|
||||
$obj->set_table("vi_inv_produk P", "P.*,CONCAT(P.InvID,':',P.SatuanID) ID2", "P.Harga_Jual>0 AND P.Aktif=1".$tsql);
|
||||
$obj->add_field("ID2", "ID", "hid");
|
||||
$obj->add_field("Kode_SKU", "SKU", "c");
|
||||
$obj->add_field("Nama_Produk", "Nama Barang", "awr");
|
||||
$obj->add_field("Nama_Satuan", "Satuan", "l");
|
||||
$obj->add_field("Harga_Jual", "Harga @", "r", "rupiah");
|
||||
$obj->set_field_order("Kode_SKU", "A");
|
||||
$obj->add_row_checkbox("ID2", "Pilih", ["Y","N"]);
|
||||
$obj->set_func_navi("RepoLabelJS.data_query('brow-produk')");
|
||||
$ajson[] = $obj->db_table("divBrowProduk", 8);
|
||||
|
||||
} else if ( $data == "brow-grup" ) {
|
||||
$tcari = trim(Param::Get("Cari_Grup"));
|
||||
$tsql = ($tcari=="") ? "" : " AND CONCAT(P.Kode_Grup,P.Nama_Grup) LIKE '%".$tcari."%'";
|
||||
|
||||
$obj = new Table($db);
|
||||
$obj->set_table("inv_produk_grup P", "P.*", "P.Aktif=1".$tsql);
|
||||
$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->add_row_btn("save", "Pilih", "RepoLabelJS.grup_select");
|
||||
$obj->set_func_navi("RepoLabelJS.data_query('brow-grup')");
|
||||
$ajson[] = $obj->db_table("divBrowGrup");
|
||||
|
||||
} else if ($data == "detail-tx") {
|
||||
$ajson = ['error'=>"", 'html'=>""];
|
||||
$atabel = ['ID'=>Param::Get("ID",0), 'Nama_Produk'=>""];
|
||||
$db->Query("SELECT * FROM rep_label WHERE ID='".$atabel['ID']."' LIMIT 1");
|
||||
if ($db->Next()) $atabel = array_merge($atabel, $db->AllRow());
|
||||
|
||||
$form = new Form($db);
|
||||
$tproduk = $form->textbox("_", "Nama_Produk", $atabel['Nama_Produk'], true, false, "text");
|
||||
$ajson['html'] = '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-5 col-lg-3 col-form-label" for="Nama_Produk">Nama Barang</label>
|
||||
<div class="col">'.$tproduk.'</div>
|
||||
</div>
|
||||
<input type="hidden" id="mode_detail" value="'.$mode_detail.'" >
|
||||
<input type="hidden" id="ID" value="'.$atabel['ID'].'" >';
|
||||
|
||||
} else if ( $data == "default") {
|
||||
echo '
|
||||
<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>';
|
||||
}
|
||||
|
||||
if ( $data == "print" ) {
|
||||
$db->Query("SELECT * FROM rep_label ORDER BY ID");
|
||||
if ($db->RecordCount()==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 = $nb = 1; $cont = "";
|
||||
while ($db->Next()) {
|
||||
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, $db->Row("Nama_Produk"), "Rp. ".rupiah($db->Row("Harga_Jual")));
|
||||
$ni++;
|
||||
}
|
||||
if ($ni < 4) {
|
||||
while ($ni < 4) {
|
||||
$cont .= sprintf($_line, "", "");
|
||||
$ni++;
|
||||
}
|
||||
}
|
||||
echo '<p id="autopage"> </p>' . $_head . $cont . "</tr></table>";
|
||||
}
|
||||
|
||||
send_json($ajson);
|
||||
?>
|
||||
Reference in New Issue
Block a user