Files
cmasa/app/Controller/Table/Member/MembergrupController.php
T
2026-10-29 13:34:31 +07:00

116 lines
4.6 KiB
PHP

<?php
/*******************************************************************
PHP Class : /Controller/Table/Member/MembergrupController
Description : Master Grup Member
Created By : Siau Pheng ([email protected]).
Created Date : May 19th, 2010.
Last Modified : September 3rd, 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 MembergrupController {
private string $mode_detail;
private int $id_grup;
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_grup = (int) Param::Get("Grup_MemberID", 0);
}
public function table_detail() {
if (in_array($this->mode_detail, ["insert","update","delete"])) {
$sql = new SQL($this->app);
$sql->set_table("para_member_grup");
$sql->add_param("Kode_Grup");
$sql->add_param("Nama_Grup");
$sql->add_param("Aktif");
$sql->add_param_userid();
$sql->add_where("Grup_MemberID");
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_Member");
$tsql = ''; $asql = [];
if (!empty($tcari)) {
$tsql = 'CONCAT(Kode_Grup,Nama_Grup) LIKE ?';
$asql[] = '%'. $tcari .'%';
}
$obj = new Table($this->app);
$obj->set_table("para_member_grup", "*", $tsql, $asql);
$obj->add_field("Grup_MemberID", "ID", "hid");
$obj->add_field("Kode_Grup", "Kode");
$obj->add_field("Nama_Grup", "Nama Grup Member", "awr");
$obj->add_field("Aktif", "Aktif", "c", "checkbox");
$obj->set_field_order("Kode_Grup", "A");
$obj->add_row_btn("clipboard", "Ubah", "MemberGrupJS.detail_ubah");
$obj->add_row_btn("trash", "Hapus", "MemberGrupJS.detail_hapus");
$obj->set_func_btn("MemberGrupJS.detail_tambah", "+ Grup Member");
$this->app->json([ $obj->json_table("divDetail") ]);
}
public function form_grup() {
$atabel = Invesa::A_Member_Grup();
if ($this->id_grup > 0) {
$atabel = $this->db->fetchRow("SELECT * FROM para_member_grup WHERE Grup_MemberID=?", [$this->id_grup]);
}
$form = new Form($this->app);
$tkode = $form->textbox("_", "Kode_Grup", $atabel['Kode_Grup'], true, true, "text", "kode grup member");
$tnama = $form->textbox("_", "Nama_Grup", $atabel['Nama_Grup'], true, true, "text", "nama grup member");
$taktif = $form->radio("_", "Aktif", $atabel['Aktif'], true, true, ['1'=>"Aktif",'0'=>"Tidak"]);
$ajson['html'] = '
<div class="row mb-1">
<label class="col-sm-4 col-lg-3 col-form-label" for="Kode_Grup">Kode Grup Member</label>
<div class="col-sm-6 col-lg-5">'.$tkode.'</div>
</div>
<div class="row mb-1">
<label class="col-sm-4 col-lg-3 col-form-label" for="Nama_Grup">Nama Grup Member</label>
<div class="col">'.$tnama.'</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="Grup_MemberID" value="'.$atabel['Grup_MemberID'].'" >
<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 Grup Member</div><div class="card-body"><div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Member" 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>'
]);
}
}