first commit

This commit is contained in:
2026-10-29 13:34:31 +07:00
commit 45e4595c57
255 changed files with 35457 additions and 0 deletions
@@ -0,0 +1,223 @@
<?php
/*******************************************************************
PHP Class : /Controller/Table/Member/PointskemaController
Description : Master Skema Point Member
Created By : Siau Pheng ([email protected]).
Created Date : September 28th, 2014.
Last Modified : September 4th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
declare(strict_types=1);
namespace App\Controller\Table\Member;
use App\Utils\Invesa;
use flight\Engine;
use flight\database\SimplePdo;
use Webapp\DB\SQL;
use Webapp\Web\Form;
use Webapp\Web\Param;
use Webapp\Web\Table;
class PointskemaController {
private string $mode_detail;
private int $id_point;
private string $kode_barang;
protected Engine $app;
protected SimplePdo $db;
public function __construct(Engine $app, SimplePdo $db) {
$this->app = $app;
$this->db = $db;
$this->mode_detail = Param::Get("mode_detail", "");
$this->id_point = (int) Param::Get("PointID", 0);
$this->kode_barang = (string) Param::Get("Kode_Barang", "");
}
public function table_detail() {
if (in_array($this->mode_detail, ["insert","update","delete"])) {
$sql = new SQL($this->app);
$sql->set_table("inv_point");
$sql->add_param("Point_TipeID");
$sql->add_param("KartuID");
$sql->add_param("CabID");
$sql->add_param("Grup_MemberID");
$sql->add_param("Nilai_Jual");
$sql->add_param("Grup_Barang");
$sql->add_param("Kode_Barang");
$sql->add_param_date("Tgl_Mulai");
$sql->add_param("Aktif");
$sql->add_param_userid();
$sql->add_where("PointID");
if ($this->mode_detail === "insert") {
$sql->InsertDB();
} else if ($this->mode_detail === "update") {
$sql->UpdateDB();
} else if ($this->mode_detail === "delete") {
$sql->DeleteDB();
}
}
$tcari = Param::Get("Cari_Skema");
$tsql = ''; $asql = [];
if (!empty($tcari)) {
$tsql = 'CONCAT_WS(G.Nama_Grup,T.Nama_Tipe) LIKE ?';
$asql[] = '%'. $tcari .'%';
}
$obj = new Table($this->app);
$obj->set_table("inv_point P LEFT JOIN para_member_grup G ON (G.Grup_MemberID=P.Grup_MemberID) LEFT JOIN para_cabang C ON (P.CabID=C.CabID) LEFT JOIN para_rek_pos K ON (P.KartuID=K.KartuID) LEFT JOIN inv_point_tipe T ON (P.Point_TipeID=T.Point_TipeID)", "P.*,IF(P.KartuID=0,'SEMUA JENIS',K.Nama_Kartu) Nama_Kartu,IF(P.Grup_MemberID=0,'SEMUA GRUP',G.Nama_Grup) Nama_Grup,IF(P.CabID=0,'SEMUA CABANG',C.Nama_Cab) Nama_Cab,T.Nama_Tipe", $tsql, $asql);
$obj->add_field("PointID", "ID", "hid");
$obj->add_field("Nama_Tipe", "Tipe", "l");
$obj->add_field("Nama_Cab", "Cabang", "l");
$obj->add_field("Nama_Kartu", "Pembayaran", "l");
$obj->add_field("Nama_Grup", "Grup Member", "l");
$obj->add_field("Grup_Barang", "Grup Barang", "awr");
$obj->add_field("Nilai_Jual", "Nominal (Rp.)", "r", "rupiah");
$obj->add_field("Tgl_Mulai", "Tgl. Mulai", "c", "sqltgl", "", "val-tgl");
$obj->add_field("Aktif", "Aktif", "c", "checkbox");
$obj->set_field_order("Nama_Tipe", "A");
$obj->add_row_btn("clipboard", "Ubah", "PointSkemaJS.detail_ubah");
$obj->add_row_btn("trash", "Hapus", "PointSkemaJS.detail_hapus");
$obj->set_func_btn("PointSkemaJS.detail_tambah", "+ Skema Point");
$this->app->json([ $obj->json_table("divDetail") ]);
}
public function table_barang() {
$ainv = (empty($this->kode_barang)) ? [] : explode(",", $this->kode_barang);
if (in_array($this->mode_detail, ["insert","delete"])) {
$id_inv = Param::Get("InvID", 0);
if ($this->mode_detail === "insert") {
if (!in_array($id_inv, $ainv)) $ainv[] = $id_inv;
} else if ($this->mode_detail === "delete") {
if (($key = array_search($id_inv, $ainv)) !== false) unset($ainv[$key]);
}
}
$tsql = 'FALSE'; $asql = [];
if (count($ainv) > 0) {
$tsql = 'InvID IN (?)';
$asql[] = $ainv;
}
$obj = new Table($this->app);
$obj->set_table("inv_produk", "*,1 Hapus", $tsql, $asql);
$obj->add_field("InvID", "ID", "hid");
$obj->add_field("Nama_Produk", "Nama Barang", "awr");
$obj->add_row_btn("trash", "Hapus", "PointSkemaJS.barang_hapus");
$this->app->json([ $obj->json_table("divBarang"), ['type'=>"form", 'id'=>"Kode_Barang", 'value'=>implode(',', $ainv)] ]);
}
public function auto_produk() {
$tcari = Param::Get("Auto_Query");
$ajson['autodata'] = [];
$bcode = 0; $arec = [];
// Cari by SKU & Barcode
$arec = $this->db->fetchRow("SELECT V.InvID,P.Nama_Produk FROM (SELECT * FROM inv_produk_varian WHERE Kode_SKU=? OR Kode_Barcode=? LIMIT 1) V LEFT JOIN inv_produk P ON (P.InvID=V.InvID) WHERE P.Aktif=1", [$tcari, $tcari]);
if (is_array($arec) && count($arec) > 0) $bcode = 1;
if ($bcode === 1) {
$ajson['autodata'][] = ['value'=>$arec['InvID'], 'text'=>$arec['Nama_Produk'], 'data'=>0, 'bc'=>1];
} else {
// Cari by Nama
$stat = $this->db->runQuery("SELECT InvID,Nama_Produk FROM inv_produk WHERE Aktif=1 AND Nama_Produk LIKE ? ORDER BY Nama_Produk LIMIT 50", ['%'.$tcari.'%']);
while ($row = $stat->fetch(SimplePdo::FETCH_ASSOC)) {
$ajson['autodata'][] = ['value'=>$row['InvID'], 'text'=>$row['Nama_Produk'], 'html'=>$row['Nama_Produk'], 'data'=>0, 'bc'=>0];
}
}
$this->app->json($ajson);
}
public function form_skema() {
$atabel = [ 'PointID'=>0,'CabID'=>0,'Grup_MemberID'=>0,'Point_TipeID'=>0,'KartuID'=>0,'Grup_Barang'=>"",'Kode_Barang'=>"",'Nilai_Jual'=>0,'Tgl_Mulai'=>tgl_ymd(),'Aktif'=>1 ];
if ($this->id_point > 0) {
$atabel = $this->db->fetchRow("SELECT * FROM inv_point WHERE PointID=?", [$this->id_point]);
}
$form = new Form($this->app);
$tcab = $form->option_db("_", "CabID", $atabel['CabID'], true, false, "para_cabang", ["CabID","Nama_Cab"], "Aktif=1 ORDER BY Nama_Cab", [0,"SEMUA CABANG"]);
$tgrup = $form->option_db("_", "Grup_MemberID", $atabel['Grup_MemberID'], true, false, "para_member_grup", ["Grup_MemberID","Nama_Grup"], "Aktif=1 ORDER BY Nama_Grup", [0,"SEMUA GRUP"]);
$ttipe = $form->option_db("_", "Point_TipeID", $atabel['Point_TipeID'], true, false, "inv_point_tipe", ["Point_TipeID","Nama_Tipe"], "Aktif=1 ORDER BY Point_TipeID", [0,"&nbsp;"]);
$tkartu = $form->option_db("_", "KartuID", $atabel['KartuID'], true, false, "para_rek_pos", ["KartuID","Nama_Kartu"], "Aktif=1", [0,"SEMUA JENIS PEMBAYARAN"]);
$t_grup = $form->textbox("_", "Grup_Barang", $atabel['Grup_Barang'], false, false, "text");
$t_brg = $form->textbox("_", "Kode_Barang", $atabel['Kode_Barang'], false, false, "text");
$t_nilai = $form->textbox("_", "Nilai_Jual", $atabel['Nilai_Jual'], true, false, "double");
$ttglmulai = $form->datebox("_", "Tgl_Mulai", $atabel['Tgl_Mulai'], true, false);
$taktif = $form->radio("_", "Aktif", $atabel['Aktif'], true, false, ['1'=>"Ya",'0'=>"Tidak"]);
$ajson['html'] = '
<div class="row mb-1">
<label class="col-sm-4 col-lg-2 col-form-label" for="Point_TipeID">Tipe Point</label>
<div class="col">'.$ttipe.'</div>
</div>
<div class="row mb-1">
<label class="col-sm-4 col-lg-2 col-form-label" for="CabID">Nama Cabang</label>
<div class="col-sm-8 col-lg-4">'.$tcab.'</div>
<label class="col-sm-4 col-lg-2 col-form-label" for="Grup_MemberID">Grup Member</label>
<div class="col-sm-8 col-lg-4">'.$tgrup.'</div>
</div>
<div class="row mb-1"><div class="col"><hr class="my-1"></div></div>
<div class="row mb-1">
<label class="col-sm-4 col-lg-2 col-form-label">Grup Barang</label>
<div class="col"><div class="input-group">'.$t_grup.'<button id="butBrow1" class="btn btn-info" type="button"><i class="bi-search"></i></button></div></div>
</div>
<div class="row mb-1">
<label class="col-sm-4 col-lg-2 col-form-label">Daftar Barang</label>
<div class="col"><div class="input-group">'.$t_brg.'<button id="butBrow2" class="btn btn-info" type="button"><i class="bi-search"></i></button></div></div>
</div>
<div class="row mb-1">
<label class="col-sm-4 col-lg-2 col-form-label" for="Nilai_Jual">Nominal Penjualan</label>
<div class="col-sm-8 col-lg-4"><div class="input-group">'.$t_nilai.Invesa::Form_Info("Jumlah Nominal Penjualan untuk Memperoleh Point (berlaku kelipatan). Contoh : Rp 100.000").'</div></div>
<label class="col-sm-4 col-lg-2 col-form-label" for="Tgl_Mulai">Tanggal Mulai</label>
<div class="col-sm-8 col-lg-4">'.$ttglmulai.'</div>
</div>
<div class="row mb-1">
<label class="col-sm-4 col-lg-2 col-form-label" for="KartuID">Jenis Pembayaran</label>
<div class="col-sm-8 col-lg-4">'.$tkartu.'</div>
<label class="col-sm-4 col-lg-2 col-form-label" for="Aktif">Status Aktif ?</label>
<div class="col d-flex gap-2">'.$taktif.'</div>
</div>
<input type="hidden" id="PointID" value="'.$atabel['PointID'].'" >
<input type="hidden" id="mode_detail" value="'.$this->mode_detail.'" >';
$this->app->json($ajson);
}
public function form_grup() {
$agrup = explode(",", Param::Get("Grup_Barang","0"));
$ajson['html'] = '<table class="table table-striped table-bordered table-hover" id="tabGrupList"><thead><tr><th>Nama Grup Barang</th><th>Aksi</th></tr></thead><tbody>';
$stat = $this->db->runQuery("SELECT * FROM inv_produk_grup ORDER BY Nama_Grup");
while ($row = $stat->fetch(SimplePdo::FETCH_ASSOC)) {
$checked = (in_array($row['Grup_InvID'], $agrup)) ? "checked" : "";
$ajson['html'] .= sprintf('<tr><td class="l">%s</td><td class="c"><input class="form-check-input" type="checkbox" value="%s" %s/></td></tr>', $row['Nama_Grup'], $row['Grup_InvID'], $checked);
}
$ajson['html'] .= '</tbody></table>';
$this->app->json($ajson);
}
public function form_barang() {
$form = new Form($this->app);
$tnama = $form->textauto("_", "Nama_Produk", [], true, true, "ketik nama produk");
$ajson['html'] = '
<div class="row mb-1">
<label class="col-sm-4 col-lg-2 col-form-label" for="Nama_Produk">Nama Barang</label>
<div class="col">'.$tnama.'</div>
</div>
<div id="divBarang">&nbsp;</div>
<input type="hidden" id="InvID" value="0" >';
$this->app->json($ajson);
}
public function index() {
$this->app->json(['html' => '
<div class="fade-in">
<div class="card"><div class="card-header custom-style">Daftar Skema Point Member</div><div class="card-body"><div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Skema" placeholder="Kunci Pencarian" type="text"><button class="btn btn-info shadow-none" type="button" id="butSearch">Cari</button><button class="btn btn-secondary shadow-none" type="button" id="butAll">Semua</button></div></div></div><div id="divDetail">&nbsp;</div></div></div>
</div>'
]);
}
}