136 lines
6.0 KiB
PHP
136 lines
6.0 KiB
PHP
<?php
|
|
|
|
/*******************************************************************
|
|
|
|
PHP Class : /Controller/Table/Member/PointbarangController
|
|
Description : Master Point Penukanan Barang
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : May 19th, 2010.
|
|
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 PointbarangController {
|
|
|
|
private string $mode_detail;
|
|
private int $id_point;
|
|
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("InvPID", 0);
|
|
}
|
|
|
|
public function table_detail() {
|
|
if (in_array($this->mode_detail, ["insert","update","delete"])) {
|
|
$sql = new SQL($this->app);
|
|
$sql->set_table("inv_point_barang");
|
|
$sql->add_param("Point_TipeID");
|
|
$sql->add_param("Nama_Barang");
|
|
$sql->add_param("SatuanID");
|
|
$sql->add_param("Nilai_Barang");
|
|
$sql->add_param("Nilai_Point");
|
|
$sql->add_param("Aktif");
|
|
$sql->add_param_userid();
|
|
$sql->add_where("InvPID");
|
|
|
|
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_Barang");
|
|
$tsql = ''; $asql = [];
|
|
if (!empty($tcari)) {
|
|
$tsql = 'Nama_Barang LIKE ?';
|
|
$asql[] = '%'. $tcari .'%';
|
|
}
|
|
|
|
$obj = new Table($this->app);
|
|
$obj->set_table("inv_point_barang B LEFT JOIN inv_point_tipe T ON (B.Point_TipeID=T.Point_TipeID)", "B.*,T.Nama_Tipe", $tsql, $asql);
|
|
$obj->add_field("InvPID", "ID", "hid");
|
|
$obj->add_field("Nama_Tipe", "Tipe Point", "awr");
|
|
$obj->add_field("Nama_Barang", "Nama Barang", "awr");
|
|
$obj->add_field("Nilai_Barang", "Nilai Barang", "r", "rupiah");
|
|
$obj->add_field("Nilai_Point", "Nilai Point", "r", "rupiah");
|
|
$obj->add_field("Aktif", "Aktif", "c", "checkbox");
|
|
$obj->set_field_order("Nama_Barang", "A");
|
|
$obj->add_row_btn("clipboard", "Ubah", "PointBarangJS.detail_ubah");
|
|
$obj->add_row_btn("trash", "Hapus", "PointBarangJS.detail_hapus");
|
|
$obj->set_func_btn("PointBarangJS.detail_tambah", "+ Barang");
|
|
$this->app->json([ $obj->json_table("divDetail") ]);
|
|
}
|
|
|
|
public function form_barang() {
|
|
$atabel = [ 'InvPID'=>0, 'Point_TipeID'=>0, 'Nama_Barang'=>"", 'SatuanID'=>0, 'Nilai_Barang'=>0, 'Nilai_Point'=>0, 'Aktif'=>1];
|
|
if ($this->id_point > 0) {
|
|
$atabel = $this->db->fetchRow("SELECT * FROM inv_point_barang WHERE InvPID=?", [$this->id_point]);
|
|
}
|
|
|
|
$form = new Form($this->app);
|
|
$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," "]);
|
|
$tnama = $form->textbox("_", "Nama_Barang", $atabel['Nama_Barang'], true, true, "text");
|
|
$tsatuan = $form->option_db("_", "SatuanID", $atabel['SatuanID'], true, false, "para_satuan", ["SatuanID","Nama_Satuan"], "Aktif=1 ORDER BY Nama_Satuan", [0," "]);
|
|
$tnilai = $form->textbox("_", "Nilai_Barang", $atabel['Nilai_Barang'], true, false, "double");
|
|
$tpoint = $form->textbox("_", "Nilai_Point", $atabel['Nilai_Point'], true, false, "number");
|
|
$taktif = $form->radio("_", "Aktif", $atabel['Aktif'], true, false, [1=>"Aktif",0=>"Tidak"]);
|
|
$ajson['html'] = '
|
|
<div class="row mb-1">
|
|
<label class="col-sm-4 col-lg-3 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-3 col-form-label" for="Nama_Barang">Nama Barang</label>
|
|
<div class="col">'.$tnama.'</div>
|
|
</div>
|
|
<div class="row mb-1">
|
|
<label class="col-sm-4 col-lg-3 col-form-label" for="SatuanID">Satuan Barang</label>
|
|
<div class="col-sm-6 col-lg-5">'.$tsatuan.'</div>
|
|
</div>
|
|
<div class="row mb-1">
|
|
<label class="col-sm-4 col-lg-3 col-form-label" for="Nilai_Barang">Nilai Barang</label>
|
|
<div class="col-sm-6 col-lg-5">'.$tnilai.'</div>
|
|
</div>
|
|
<div class="row mb-1">
|
|
<label class="col-sm-4 col-lg-3 col-form-label" for="Nilai_Point">Point Barang</label>
|
|
<div class="col-sm-6 col-lg-5">'.$tpoint.'</div>
|
|
</div>
|
|
<div class="row mb-1">
|
|
<label class="col-sm-4 col-lg-3 col-form-label" for="Aktif">Status Aktif ?</label>
|
|
<div class="col d-flex gap-2">'.$taktif.'</div>
|
|
</div>
|
|
<input type="hidden" id="InvPID" value="'.$atabel['InvPID'].'" >
|
|
<input type="hidden" id="mode_detail" value="'.$this->mode_detail.'" >';
|
|
$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 Point Penukarang Barang</div><div class="card-body"><div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Barang" 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"> </div></div></div>
|
|
</div>'
|
|
]);
|
|
}
|
|
}
|