first commit
This commit is contained in:
@@ -0,0 +1,492 @@
|
||||
<?php
|
||||
|
||||
/*******************************************************************
|
||||
|
||||
PHP Class : /Controller/Gel/GajiController
|
||||
Description : Transaksi Perhitungan Gaji
|
||||
Created By : Siau Pheng ([email protected]).
|
||||
Created Date : September 17th, 2014.
|
||||
Last Modified : September 13th, 2026.
|
||||
|
||||
(c) 3FONIA Software; WWW.3FONIA.COM.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Controller\Gel;
|
||||
|
||||
use App\Utils\Gel;
|
||||
use flight\Engine;
|
||||
use flight\database\SimplePdo;
|
||||
use flight\Session;
|
||||
use Webapp\DB\SQL;
|
||||
use Webapp\Web\Form;
|
||||
use Webapp\Web\Param;
|
||||
use Webapp\Web\Table;
|
||||
|
||||
class GajiController {
|
||||
|
||||
private array $web_app;
|
||||
private array $app_gel;
|
||||
private int $id_cab;
|
||||
private string $mode;
|
||||
private string $mode_detail;
|
||||
private string $no_gaji;
|
||||
private Gel $gel;
|
||||
protected Engine $app;
|
||||
protected SimplePdo $db;
|
||||
|
||||
public function __construct(Engine $app, SimplePdo $db, Session $session) {
|
||||
$this->app = $app;
|
||||
$this->db = $db;
|
||||
$this->web_app = (array) $session->get('WEB_APP');
|
||||
$this->app_gel = (array) $session->get('APP_GEL');
|
||||
$this->id_cab = Param::Int("CabID", $session->get('APP_INV')['CABANGID']);
|
||||
$this->mode = Param::Get("mode", "");
|
||||
$this->mode_detail = Param::Get("mode_detail", "");
|
||||
$this->no_gaji = Param::Get("No_Gaji", "");
|
||||
$this->gel = new Gel($app);
|
||||
}
|
||||
|
||||
public function table_detail() {
|
||||
if (in_array($this->mode_detail, ["insert","update","delete"])) {
|
||||
$sql = new SQL($this->app);
|
||||
$sql->set_table("tmp_gaji_detail");
|
||||
$sql->add_param("KaryaID");
|
||||
$sql->add_param("Qty_Harian");
|
||||
$sql->add_param("Gaji_Harian");
|
||||
$sql->add_param("Total_Gaji", "Qty_Harian*Gaji_Harian", true);
|
||||
$sql->add_param("Qty_Lembur");
|
||||
$sql->add_param("Lembur_Harian");
|
||||
$sql->add_param("Total_Lembur", "Qty_Lembur*Lembur_Harian", true);
|
||||
$sql->add_param("Qty_BonusM");
|
||||
$sql->add_param("Qty_BonusB");
|
||||
$sql->add_param("Bonus_Minggu");
|
||||
$sql->add_param("Bonus_Bulan");
|
||||
$sql->add_param("Total_BonusM", "Qty_BonusM*Bonus_Minggu", true);
|
||||
$sql->add_param("Total_BonusB", "Qty_BonusB*Bonus_Bulan", true);
|
||||
$sql->add_param("Total_Potong");
|
||||
$sql->add_param("Total_Semua", "Total_Gaji+Total_Lembur+Total_BonusM+Total_BonusB-Total_Potong", true);
|
||||
$sql->add_param("Catatan", Param::Get("CatatKar"));
|
||||
$sql->add_param_unix();
|
||||
$sql->add_param_userid();
|
||||
$sql->add_where("ID");
|
||||
$sql->add_where("No_Gaji", $this->no_gaji);
|
||||
|
||||
if ($this->mode_detail === "insert") {
|
||||
$sql->add_param("No_Gaji");
|
||||
$sql->InsertDB();
|
||||
} else if ($this->mode_detail === "update") {
|
||||
$sql->UpdateDB();
|
||||
} else if ($this->mode_detail === "delete") {
|
||||
$sql->DeleteDB();
|
||||
}
|
||||
}
|
||||
|
||||
$tsql = ''; $asql = [$this->no_gaji]; $qtabel = "gel_gaji_detail";
|
||||
if (in_array($this->mode, ["add","edit"])) {
|
||||
if ($this->mode === "add") { $tsql = " AND Unix=?"; $asql[] = $this->app->user()->unix(); }
|
||||
$qtabel = "tmp_gaji_detail";
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("(SELECT * FROM ".$qtabel.' WHERE No_Gaji=?'.$tsql.") D LEFT JOIN para_karyawan P ON (D.KaryaID=P.KaryaID)", "D.*,P.Nama_Karya,(P.Total_Pinjam-D.Total_Potong) Sisa_Pinjam", "", $asql);
|
||||
$obj->set_footer("SUM(Total_Semua) Total_Semua");
|
||||
$obj->add_field("ID", "ID", "hid");
|
||||
$obj->add_field("KaryaID", "KaryaID", "hid");
|
||||
$obj->add_field("Nama_Karya", "Nama Karyawan", "awr");
|
||||
$obj->add_field("Qty_Harian", "Hari", "r", "rupiah");
|
||||
$obj->add_field("Total_BonusM", "Bonus MG", "r", "rupiah");
|
||||
$obj->add_field("Total_BonusB", "Bonus BLN", "r", "rupiah");
|
||||
$obj->add_field("Total_Potong", "Potongan", "r", "rupiah");
|
||||
$obj->add_field("Total_Semua", "Gaji Bersih", "r", "rupiah", "rupiah");
|
||||
$obj->add_field("Catatan", "Catatan", "awr");
|
||||
$obj->set_field_order("Nama_Karya", "A");
|
||||
if (in_array($this->mode, ["add","edit"])) {
|
||||
$obj->add_row_btn("clipboard", "Ubah", "GELGajiJS.detail_ubah");
|
||||
$obj->add_row_btn("trash", "Hapus", "GELGajiJS.detail_hapus", "Unix", $this->app->user()->unix());
|
||||
$obj->set_func_btn("GELGajiJS.detail_tambah", '<i class="bi-plus-lg me-1"></i> Karyawan');
|
||||
$obj->set_func_btn("GELGajiJS.karya_brow", '<i class="bi-table me-1"></i> Browse');
|
||||
}
|
||||
$this->app->json([ $obj->json_table("divDetailTabel") ]);
|
||||
}
|
||||
|
||||
public function brow_tx() {
|
||||
$tcari = Param::Get("Cari_TX");
|
||||
$tsql = ''; $asql = [];
|
||||
if (!empty($tcari)) {
|
||||
$tsql .= "CONCAT(No_Gaji,DATE_FORMAT(Tgl_Gaji,'%d-%m-%Y'),Catatan) LIKE ?";
|
||||
$asql[] = '%' . $tcari . '%';
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("gel_gaji", "*,CONCAT(LPAD(Bulan,2,'0'),'-',Tahun) BLTH,(Total_Gaji+Total_Bonus-Total_Potong) Jumlah", $tsql);
|
||||
$obj->add_field("No_Gaji", "No. Trans", "c");
|
||||
$obj->add_field("Tgl_Gaji", "Tgl. Trans", "c", "sqltgl", "", "val-tgl");
|
||||
$obj->add_field("Minggu", "MG", "c");
|
||||
$obj->add_field("BLTH", "Bulan", "c");
|
||||
$obj->add_field("Total_Gaji", "Total Gaji", "r", "rupiah");
|
||||
$obj->add_field("Total_Bonus", "Total Bonus", "r", "rupiah");
|
||||
$obj->add_field("Total_Potong", "Potongan", "r", "rupiah");
|
||||
$obj->add_field("Jumlah", "TOTAL", "r", "rupiah");
|
||||
$obj->set_field_order("No_Gaji", "D");
|
||||
$obj->set_func_select("GELGajiJS.tx_select");
|
||||
$this->app->json([ $obj->db_table("divBrowTX") ]);
|
||||
}
|
||||
|
||||
public function brow_cetak() {
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("(SELECT * FROM gel_gaji_detail WHERE No_Gaji=?) D LEFT JOIN para_karyawan P ON (D.KaryaID=P.KaryaID)", "D.*,P.Nama_Karya, 'N' Cek", "", [$this->no_gaji]);
|
||||
$obj->add_field("ID", "ID", "hid");
|
||||
$obj->add_field("Nama_Karya", "Nama Karyawan", "awr");
|
||||
$obj->add_field("Total_Gaji", "Total Gaji", "r", "rupiah");
|
||||
$obj->add_field("Total_Semua", "Gaji Bersih", "r", "rupiah");
|
||||
$obj->add_field("Catatan", "Catatan", "awr");
|
||||
$obj->add_row_checkbox("ID", "Cek");
|
||||
$obj->set_field_order("Nama_Karya", "A");
|
||||
$this->app->json([ $obj->db_table("divBrowCetak") ]);
|
||||
}
|
||||
|
||||
public function brow_karya() {
|
||||
$tcari = Param::Get("Cari_Karya");
|
||||
$tsql = ''; $asql = [$this->no_gaji];
|
||||
if (!empty($tcari)) {
|
||||
$tsql .= " AND Nama_Karya LIKE ?";
|
||||
$asql[] = '%' . $tcari . '%';
|
||||
}
|
||||
|
||||
$obj = new Table($this->app);
|
||||
$obj->set_table("para_karyawan", "*", "Aktif=1 AND KaryaID NOT IN (SELECT KaryaID FROM tmp_gaji_detail WHERE No_Gaji=?)".$tsql, $asql);
|
||||
$obj->add_field("KaryaID", "ID", "hid");
|
||||
$obj->add_field("Nama_Karya", "Nama Karyawan", "awr");
|
||||
$obj->add_field("Gaji_Harian", "Gaji Harian", "r", "rupiah");
|
||||
$obj->add_field("Total_Pinjam", "Total Pinjaman", "r", "rupiah");
|
||||
$obj->set_field_order("Nama_Karya", "A");
|
||||
$obj->set_func_select("GELGajiJS.karya_select");
|
||||
$this->app->json([ $obj->db_table("divBrowKarya") ]);
|
||||
}
|
||||
|
||||
public function auto_karya() {
|
||||
$tcari = Param::Get("Auto_Query");
|
||||
$ajson['autodata'] = [];
|
||||
$stat = $this->db->runQuery("SELECT KaryaID,Nama_Karya,CONCAT(Gaji_Harian,':',Total_Pinjam) Data2 FROM para_karyawan WHERE Aktif=1 AND KaryaID NOT IN (SELECT KaryaID FROM tmp_gaji_detail WHERE No_Gaji=?) AND Nama_Karya LIKE ? ORDER BY Nama_Karya LIMIT 50", [$this->no_gaji, '%'.$tcari.'%']);
|
||||
while ($row = $stat->fetch(SimplePdo::FETCH_ASSOC)) {
|
||||
$ajson['autodata'][] = ['value'=>$row['KaryaID'], 'text'=>$row['Nama_Karya'], 'data'=>$row['Data2'], 'bc'=>0];
|
||||
}
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function form_master() {
|
||||
$ajson = [ 'error'=>"", 'html'=>"" ];
|
||||
$atabel = [ 'No_Gaji'=>"", 'CabID'=>$this->id_cab, 'Tgl_Gaji'=>"", 'Minggu'=>date('W'), 'Bulan'=>date('n'), 'Tahun'=>date('Y'), 'Catatan'=>"" ];
|
||||
|
||||
if ($this->mode === "add") {
|
||||
$atabel['No_Gaji'] = "GJ-BARU#".(string) $this->web_app['SERVER_ID']. $this->app->user()->id(3);
|
||||
$atabel['Tgl_Gaji'] = tgl_ymd();
|
||||
$this->no_gaji = "";
|
||||
|
||||
} else if ($this->mode === "edit") {
|
||||
$this->Gaji_Copy($this->no_gaji);
|
||||
|
||||
} else if ($this->mode === "save") {
|
||||
$no_lama = $this->no_gaji;
|
||||
$tgl_gaji = Param::Get("Tgl_Gaji");
|
||||
$b_baru = str_contains($no_lama, "BARU");
|
||||
if ($b_baru) $this->no_gaji = $this->Gaji_Baru($this->id_cab, $tgl_gaji, true);
|
||||
$this->Gaji_Save($this->no_gaji, $b_baru, $no_lama);
|
||||
|
||||
$agaji = $this->db->fetchRow("SELECT SUM(Total_Gaji+Total_Lembur) Gaji, SUM(Total_BonusM+Total_BonusB) Bonus, SUM(Total_Potong) Potong FROM gel_gaji_detail WHERE No_Gaji=?", [$this->no_gaji]) ?? ['Gaji'=>0, 'Bonus'=>0, 'Potong'=>0];
|
||||
|
||||
$sql = new SQL($this->app);
|
||||
$sql->set_table("gel_gaji");
|
||||
$sql->add_param_date("Tgl_Gaji");
|
||||
$sql->add_param("Total_Gaji", $agaji['Gaji']);
|
||||
$sql->add_param("Total_Bonus", $agaji['Bonus']);
|
||||
$sql->add_param("Total_Potong", $agaji['Potong']);
|
||||
$sql->add_param("Minggu");
|
||||
$sql->add_param("Bulan");
|
||||
$sql->add_param("Tahun");
|
||||
$sql->add_param("CabID");
|
||||
$sql->add_param("Catatan");
|
||||
$sql->add_param_stamp();
|
||||
$sql->add_param_userid();
|
||||
$sql->add_where("No_Gaji", $this->no_gaji);
|
||||
$sql->UpdateDB();
|
||||
|
||||
// PROSES POSTING GL
|
||||
$ainfo = $this->db->fetchRow("SELECT *,Total_Gaji+Total_Bonus Gaji FROM gel_gaji WHERE No_Gaji=?", [$this->no_gaji]);
|
||||
$ajurnal = [
|
||||
'Kode_Jurnal' => $this->no_gaji,
|
||||
'TipeID' => 14,
|
||||
'CabID' => $this->id_cab,
|
||||
'Tanggal' => $tgl_gaji,
|
||||
'Kode_Ref' => $this->no_gaji,
|
||||
'Catatan' => "Pembayaran Gaji : ".$ainfo['No_Gaji']." / Minggu ".$ainfo['Minggu'].", Bulan ".bulan_array()[$ainfo['Bulan']]." ".$ainfo['Tahun']
|
||||
];
|
||||
$adetail = [
|
||||
[
|
||||
'Kode_Rek' => $this->app_gel['BIAYA_GAJI'],
|
||||
'DK' => "D",
|
||||
'Jumlah' => $ainfo['Gaji']
|
||||
],
|
||||
[
|
||||
'Kode_Rek' => $this->app_gel['KAS_TUNAI'],
|
||||
'DK' => "K",
|
||||
'Jumlah' => (float) $ainfo['Gaji'] - (float) $ainfo['Total_Potong']
|
||||
]
|
||||
];
|
||||
|
||||
$this->db->delete("gel_karyawan", "Kode_Jurnal=?", [$this->no_gaji]);
|
||||
if ((float) $ainfo['Total_Potong'] > 0) {
|
||||
$apotong = $this->db->fetchAll("SELECT KaryaID,Total_Potong FROM gel_gaji_detail WHERE No_Gaji=? AND Total_Potong>0", [$this->no_gaji]);
|
||||
foreach($apotong as $_key => $val) {
|
||||
$this->db->insert("gel_karyawan", [ 'No_Trans'=>$this->gel->Karya_Baru($tgl_gaji), 'Tgl_Trans'=>$ainfo['Tgl_Gaji'], 'KaryaID'=>$val['KaryaID'], 'Kode_Jurnal'=>$this->no_gaji, 'Total_Bayar'=>$val['Total_Potong'], 'Catatan'=>'Potong Gaji : '.$this->no_gaji, 'Kunci'=>1, 'UserID'=>$this->app->user()->id() ]);
|
||||
$adetail[] = [
|
||||
'Kode_Rek' => $this->app_gel['PIU_KARYA'],
|
||||
'DK' => "K",
|
||||
'Jumlah' => $val['Total_Potong']
|
||||
];
|
||||
// UPDATE KE KARYAWAN
|
||||
$ipinjam = $this->db->fetchField("SELECT SUM(Total_Pinjam-Total_Bayar) FROM gel_karyawan WHERE KaryaID=?", [$val['KaryaID']]) ?? 0;
|
||||
$this->db->runQuery("UPDATE para_karyawan SET Total_Pinjam=? WHERE KaryaID=?", [$ipinjam, $val['KaryaID']]);
|
||||
}
|
||||
}
|
||||
$this->gel->Jurnal_Post($ajurnal, $adetail);
|
||||
$this->mode = "view";
|
||||
|
||||
} else if ($this->mode === "cancel") {
|
||||
$this->Gaji_Cancel($this->no_gaji);
|
||||
$this->mode = "view";
|
||||
$this->no_gaji = "";
|
||||
}
|
||||
|
||||
if (!empty($this->no_gaji) && $this->mode !== "cancel") {
|
||||
$row = $this->db->fetchRow("SELECT * FROM gel_gaji WHERE No_Gaji='".$this->no_gaji."'");
|
||||
if ($row) {
|
||||
$atabel = $row;
|
||||
} else {
|
||||
$ajson['error'] = "Nomor Transaksi belum ada / tidak diketemukan !";
|
||||
}
|
||||
}
|
||||
|
||||
$enable = in_array($this->mode, ["add","edit"]) ? true : false;
|
||||
$form = new Form($this->app);
|
||||
$tno = $form->textbox("_", "No_Gaji", $atabel['No_Gaji'], !$enable, false, "text", "nomor transaksi");
|
||||
$ttgl = $form->datebox("_", "Tgl_Gaji", $atabel['Tgl_Gaji'], $enable, false);
|
||||
$tcab = $form->option_db("_", "CabID", $atabel['CabID'], $enable, false, "para_cabang", ["CabID","Nama_Cab"], "Aktif=1 ORDER BY CabID");
|
||||
$tmg = $form->option("_", "Minggu", $atabel['Minggu'], $enable, false, $this->range_minggu((int) $atabel['Bulan'], (int) $atabel['Tahun']));
|
||||
$tbln = $form->option("_", "Bulan", $atabel['Bulan'], $enable, false, bulan_array(), null, "GELGajiJS.oc_Minggu()");
|
||||
$tthn = $form->option("_", "Tahun", $atabel['Tahun'], $enable, false, $this->gel->Tahun_Array(), null, "GELGajiJS.oc_Minggu()");
|
||||
$tcatat = $form->textbox("_", "Catatan", stripslashes($atabel['Catatan']), $enable, false, "text", "catatan gaji");
|
||||
$ajson['html'] = '
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-lg-6">
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-5 col-lg-3 col-form-label" for="No_Gaji">Nomor Transaksi</label>
|
||||
<div class="col-sm-7 col-lg-7"><div class="input-group">'.$tno.'<button id="butBrow" class="btn btn-info" type="button"><i class="bi-search"></i></button></div></div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-5 col-lg-3 col-form-label" for="Tgl_Gaji">Tanggal Transaksi</label>
|
||||
<div class="col-sm-7 col-lg-5">'.$ttgl.'</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-lg-6">
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-5 col-lg-3 col-form-label" for="CabID">Nama Cabang</label>
|
||||
<div class="col">'.$tcab.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-5 col-lg-3 col-form-label" for="Bulan">Periode / Minggu</label>
|
||||
<div class="col"><div class="input-group">'.$tbln.$tthn.'<span class="input-group-text px-2">/</span>'.$tmg.'</div></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-3 col-lg-2 col-form-label" for="Catatan" style="width:12.5%;">Deskripsi</label>
|
||||
<div class="col">'.$tcatat.'</div>
|
||||
</div>
|
||||
<div class="row mb-1"><div class="col"><hr class="my-1"></div></div>
|
||||
<input type="hidden" id="Lembur" value="'.$this->app_gel['LEMBUR'].'" >
|
||||
<input type="hidden" id="Bonus1" value="'.$this->app_gel['BONUS1'].'" >
|
||||
<input type="hidden" id="Bonus2" value="'.$this->app_gel['BONUS2'].'" >
|
||||
<input type="hidden" id="mode" value="'.$this->mode.'" >';
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function form_gaji() {
|
||||
$id = (int) Param::Get("ID", 0);
|
||||
$atabel = [ 'ID'=>$id, 'KaryaID'=>Param::Get("KaryaID"), 'Nama_Karya'=>"", 'Qty_Harian'=>0, 'Gaji_Harian'=>0, 'Qty_Lembur'=>0, 'Lembur_Harian'=>$this->app_gel['LEMBUR'], 'Qty_BonusM'=>0, 'Qty_BonusB'=>0, 'Bonus_Minggu'=>$this->app_gel['BONUS1'], 'Bonus_Bulan'=>$this->app_gel['BONUS2'], 'Total_Potong'=>0, 'Total_Pinjam'=>0, 'Tot_Gaji'=>0, 'Tot_Lembur'=>0, 'Tot_Bonus1'=>0, 'Tot_Bonus2'=>0, 'Jumlah'=>0, 'Catatan'=>"" ];
|
||||
if ($id > 0) {
|
||||
$_agaji = $this->db->fetchRow("SELECT * FROM tmp_gaji_detail WHERE No_Gaji=? AND ID=?", [$this->no_gaji, $id]);
|
||||
if ($_agaji) $atabel = array_merge($atabel, $_agaji->getData());
|
||||
}
|
||||
if (!empty($atabel['KaryaID'])) {
|
||||
$_akary = $this->db->fetchRow("SELECT Nama_Karya,Gaji_Harian,Total_Pinjam FROM para_karyawan WHERE KaryaID=?", [$atabel['KaryaID']]);
|
||||
if ($_akary) $atabel = array_merge($atabel, $_akary->getData());
|
||||
}
|
||||
|
||||
$form = new Form($this->app);
|
||||
$tnama = $form->textauto("_", "Nama_Karya", ['value'=>$atabel['KaryaID'],'text'=>$atabel['Nama_Karya']], true, true, "ketik nama karyawan");
|
||||
$tqty_har = $form->textbox("_", "Qty_Harian", $atabel['Qty_Harian'], true, true, "double");
|
||||
$tqty_lem = $form->textbox("_", "Qty_Lembur", $atabel['Qty_Lembur'], true, true, "double");
|
||||
$tqty_bm = $form->textbox("_", "Qty_BonusM", $atabel['Qty_BonusM'], true, true, "double");
|
||||
$tqty_bb = $form->textbox("_", "Qty_BonusB", $atabel['Qty_BonusB'], true, true, "double");
|
||||
$tpotong = $form->textbox("_", "Total_Potong", $atabel['Total_Potong'], true, true, "double");
|
||||
$tgj_hari = $form->textbox("_", "Gaji_Harian", $atabel['Gaji_Harian'], false, false, "double");
|
||||
$tlb_hari = $form->textbox("_", "Lembur_Harian", $atabel['Lembur_Harian'], false, false, "double");
|
||||
$tbon_m = $form->textbox("_", "Bonus_Minggu", $atabel['Bonus_Minggu'], false, false, "double");
|
||||
$tbon_b = $form->textbox("_", "Bonus_Bulan", $atabel['Bonus_Bulan'], false, false, "double");
|
||||
$ttot_gaji = $form->textbox("_", "Tot_Gaji", $atabel['Tot_Gaji'], false, false, "double");
|
||||
$ttot_lemb = $form->textbox("_", "Tot_Lembur", $atabel['Tot_Lembur'], false, false, "double");
|
||||
$ttot_bon1 = $form->textbox("_", "Tot_Bonus1", $atabel['Tot_Bonus1'], false, false, "double");
|
||||
$ttot_bon2 = $form->textbox("_", "Tot_Bonus2", $atabel['Tot_Bonus2'], false, false, "double");
|
||||
$tjumlah = $form->textbox("_", "Jumlah", $atabel['Jumlah'], false, false, "double");
|
||||
$tcatat = $form->textbox("_", "CatatKar", $atabel['Catatan'], true, true, "text");
|
||||
$ajson['html'] = '
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Nama_Karya">Nama Karyawan</label>
|
||||
<div class="col">'.$tnama.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Qty_Harian">Hari Kerja</label>
|
||||
<div class="col-sm-4 col-lg-5"><div class="input-group">'.$tqty_har.$tgj_hari.'</div></div>
|
||||
<div class="col-sm-4 col-lg-4">'.$ttot_gaji.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Qty_Lembur">Hari Lembur</label>
|
||||
<div class="col-sm-4 col-lg-5"><div class="input-group">'.$tqty_lem.$tlb_hari.'</div></div>
|
||||
<div class="col-sm-4 col-lg-4">'.$ttot_lemb.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Qty_BonusM">Bonus Mingguan</label>
|
||||
<div class="col-sm-4 col-lg-5"><div class="input-group">'.$tqty_bm.$tbon_m.'</div></div>
|
||||
<div class="col-sm-4 col-lg-4">'.$ttot_bon1.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="Qty_BonusB">Bonus Bulanan</label>
|
||||
<div class="col-sm-4 col-lg-5"><div class="input-group">'.$tqty_bb.$tbon_b.'</div></div>
|
||||
<div class="col-sm-4 col-lg-4">'.$ttot_bon2.'</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-8 col-lg-8 col-form-label" for="Total_Potong">Potongan Pinjaman</label>
|
||||
<div class="col-sm-4 col-lg-4">'.$tpotong.'</div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-8 col-lg-8 col-form-label">Gaji Bersih (setelah potongan)</label>
|
||||
<div class="col-sm-4 col-lg-4">'.$tjumlah.'</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-8 col-lg-8 col-form-label">Jumlah Sisa Pinjaman</label>
|
||||
<div class="col-sm-4 col-lg-4"><input type="double" class="form-control text-danger double" id="Total_Pinjam" name="Total_Pinjam" value="'.uang($atabel['Total_Pinjam']).'" readonly=""></div>
|
||||
</div>
|
||||
<div class="row mb-1">
|
||||
<label class="col-sm-4 col-lg-3 col-form-label" for="CatatKar">Catatan / Informasi</label>
|
||||
<div class="col">'.$tcatat.'</div>
|
||||
</div>
|
||||
<input type="hidden" id="ID" value="'.$atabel['ID'].'" >
|
||||
<input type="hidden" id="KaryaID" value="'.$atabel['KaryaID'].'" >
|
||||
<input type="hidden" id="mode_detail" value="'.$this->mode_detail.'" >';
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function proses_hapus() {
|
||||
$this->db->runQuery("DELETE FROM gel_gaji WHERE No_Gaji=?", [$this->no_gaji]);
|
||||
$this->db->runQuery("DELETE FROM gel_gaji_detail WHERE No_Gaji=?", [$this->no_gaji]);
|
||||
// PROSES POSTING GL
|
||||
$this->db->runQuery("DELETE FROM gel_jurnal WHERE Kode_Jurnal=?", [$this->no_gaji]);
|
||||
$this->db->runQuery("DELETE FROM gel_jurnal_detail WHERE Kode_Jurnal=?", [$this->no_gaji]);
|
||||
$this->db->runQuery("DELETE FROM gel_karyawan WHERE Kode_Jurnal=?", [$this->no_gaji]);
|
||||
$this->app->json([ 'status' => true ]);
|
||||
}
|
||||
|
||||
public function option_minggu() {
|
||||
$amg = $this->range_minggu((int) Param::Get("Bulan"), (int) Param::Get("Tahun"));
|
||||
$ajson['option'] = [];
|
||||
foreach($amg as $_key => $_val) {
|
||||
$ajson['option'][] = ['value' => $_key, 'label' => $_val];
|
||||
}
|
||||
$this->app->json($ajson);
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->app->json(['html' => '
|
||||
<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-journal-bookmark me-2"></i>Transaksi Gaji Karyawan</button>
|
||||
</li>
|
||||
<li class="nav-item ms-auto">
|
||||
<button class="btn btn-primary mb-1 ms-2" id="butTambah" type="button"><i class="bi-plus-lg me-2"></i>Tambah</button>
|
||||
<button class="btn btn-info mb-1 ms-2" id="butUbah" type="button"><i class="bi-clipboard me-2"></i>Ubah</button>
|
||||
<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-danger mb-1 ms-2" id="butBatal" type="button"><i class="bi-x-lg me-2"></i>Batal</button>
|
||||
<button class="btn btn-success mb-1 ms-2" id="butSimpan" type="button"><i class="bi-save me-2"></i>Simpan</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="divTXMaster"> </div>
|
||||
<div id="divDetailTabel"> </div>
|
||||
</div>
|
||||
</div>
|
||||
</div></div>
|
||||
</div>'
|
||||
]);
|
||||
}
|
||||
|
||||
private function Gaji_Baru(int $id_cab = 0, string $tgl = "", bool $save = false) {
|
||||
if (empty($tgl)) {
|
||||
$tno = "J" . date("y") . abjad(date("n"));
|
||||
} else {
|
||||
$tmp = explode("-", $tgl);
|
||||
$tno = "J" . substr($tmp[2],2,2) . abjad((int) $tmp[1]);
|
||||
}
|
||||
$tno .= $this->web_app['SERVER_ID'] . $id_cab;
|
||||
$ino = (int) $this->db->fetchField("SELECT MAX(RIGHT(No_Gaji,5)) FROM gel_gaji WHERE No_Gaji LIKE ?", [$tno.'%']) ?? 0;
|
||||
$tno .= isi_nol(++$ino, 5);
|
||||
if ($save===true) $this->db->insert("gel_gaji", [ 'No_Gaji'=>$tno ]);
|
||||
return $tno;
|
||||
}
|
||||
|
||||
private function Gaji_Copy(string $no_gaji, bool $unix = false): void {
|
||||
if (empty($no_gaji)) return;
|
||||
$this->Gaji_Cancel($no_gaji);
|
||||
$this->db->runQuery("INSERT INTO tmp_gaji_detail (No_Gaji,KaryaID,Qty_Harian,Gaji_Harian,Total_Gaji,Qty_Lembur,Lembur_Harian,Total_Lembur,Qty_BonusM,Qty_BonusB,Bonus_Minggu,Bonus_Bulan,Total_BonusM,Total_BonusB,Total_Potong,Total_Semua,Catatan,UserID,Unix) SELECT No_Gaji,KaryaID,Qty_Harian,Gaji_Harian,Total_Gaji,Qty_Lembur,Lembur_Harian,Total_Lembur,Qty_BonusM,Qty_BonusB,Bonus_Minggu,Bonus_Bulan,Total_BonusM,Total_BonusB,Total_Potong,Total_Semua,Catatan,UserID,'".(($unix)?$this->app->user()->unix():0)."' FROM gel_gaji_detail WHERE No_Gaji=?", [$no_gaji]);
|
||||
}
|
||||
|
||||
private function Gaji_Save(string $no_gaji, bool $is_baru = false, ?string $no_lama = ""): void {
|
||||
if (empty($no_gaji)) return;
|
||||
$this->db->delete("gel_gaji_detail", "No_Gaji=?", [$no_gaji]);
|
||||
if ($is_baru) {
|
||||
$this->Gaji_Cancel($no_gaji);
|
||||
$this->db->runQuery("UPDATE tmp_gaji_detail SET No_Gaji=? WHERE No_Gaji=? AND Unix=?", [$no_gaji, $no_lama, $this->app->user()->unix()]);
|
||||
}
|
||||
$this->db->runQuery("INSERT INTO gel_gaji_detail (No_Gaji,KaryaID,Qty_Harian,Gaji_Harian,Total_Gaji,Qty_Lembur,Lembur_Harian,Total_Lembur,Qty_BonusM,Qty_BonusB,Bonus_Minggu,Bonus_Bulan,Total_BonusM,Total_BonusB,Total_Potong,Total_Semua,Catatan,UserID) SELECT No_Gaji,KaryaID,Qty_Harian,Gaji_Harian,Total_Gaji,Qty_Lembur,Lembur_Harian,Total_Lembur,Qty_BonusM,Qty_BonusB,Bonus_Minggu,Bonus_Bulan,Total_BonusM,Total_BonusB,Total_Potong,Total_Semua,Catatan,UserID FROM tmp_gaji_detail WHERE No_Gaji=?", [$no_gaji]);
|
||||
$this->Gaji_Cancel($no_gaji);
|
||||
}
|
||||
|
||||
private function Gaji_Cancel(string $no_gaji = ""): void {
|
||||
if (empty($no_gaji)) return;
|
||||
$this->db->delete("tmp_gaji_detail", "No_Gaji=?", [$no_gaji]);
|
||||
}
|
||||
|
||||
private function range_minggu(int $bln=1, int $tahun=2010): array {
|
||||
$nawal = date('W', mktime(0,0,0,$bln,1,$tahun)) - 1;
|
||||
$nakhir = date('W', mktime(0,0,0,$bln+1,1,$tahun)) * 1;
|
||||
$amg = [];
|
||||
if ($nawal > $nakhir) {
|
||||
$amg[$nawal] = "Minggu ".$nawal;
|
||||
$nawal = 1;
|
||||
}
|
||||
for ($x = $nawal; $x <= $nakhir; $x++) {
|
||||
$amg[$x] = "Minggu ".$x;
|
||||
}
|
||||
return $amg;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user