app = $app; $this->db = $db; $this->mode_detail = Param::Get("mode_detail", ""); $this->id_grup = (int) Param::Get("Grup_InvID", 0); } public function table_detail() { if (in_array($this->mode_detail, ["insert","update","delete"])) { $sql = new SQL($this->app); $sql->set_table("inv_produk_grup"); $sql->add_param("Kode_Grup"); $sql->add_param("Nama_Grup"); $sql->add_param("Margin"); $sql->add_param("Aktif"); $sql->add_param_userid(); $sql->add_where("Grup_InvID"); 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_Grup"); $tsql = ''; $asql = []; if (!empty($tcari)) { $tsql = 'CONCAT(Kode_Grup,Nama_Grup) LIKE ?'; $asql[] = '%'. $tcari .'%'; } $obj = new Table($this->app); $obj->set_table("inv_produk_grup", "*", $tsql, $asql); $obj->add_field("Grup_InvID", "ID", "hid"); $obj->add_field("Kode_Grup", "Kode Grup", "l"); $obj->add_field("Nama_Grup", "Nama Grup Barang", "awr"); $obj->add_field("Margin", "Margin (%)", "r"); $obj->add_field("Aktif", "Aktif", "c", "checkbox"); $obj->set_field_order("Kode_Grup", "A"); $obj->add_row_btn("clipboard", "Ubah", "ProdukGrupJS.detail_ubah"); $obj->add_row_btn("trash", "Hapus", "ProdukGrupJS.detail_hapus"); $obj->set_func_btn("ProdukGrupJS.detail_tambah", "+ Grup Produk"); $this->app->json([ $obj->json_table("divDetail") ]); } public function form_grup() { $atabel = ['Grup_InvID'=>0, 'Kode_Grup'=>"", 'Nama_Grup'=>"", 'Margin'=>0, 'Aktif'=>1]; if ($this->id_grup > 0) { $atabel = $this->db->fetchRow("SELECT * FROM inv_produk_grup WHERE Grup_InvID=?", [$this->id_grup]); } $form = new Form($this->app); $tkode = $form->textbox("_", "Kode_Grup", $atabel['Kode_Grup'], true, true, "text", "kode grup produk"); $tnama = $form->textbox("_", "Nama_Grup", $atabel['Nama_Grup'], true, true, "text", "nama grup produk"); $tmargin = $form->textbox("_", "Margin", $atabel['Margin'], true, true, "double", "margin minimum"); $taktif = $form->radio("_", "Aktif", $atabel['Aktif'], true, true, ['1'=>"Aktif",'0'=>"Tidak"]); $ajson['html'] = '
'.$tkode.'
'.$tnama.'
'.$tmargin.'
'.$taktif.'
'; $this->app->json($ajson); } public function index() { $this->app->json(['html' => '
Daftar Grup Barang
 
' ]); } }