first commit
This commit is contained in:
@@ -0,0 +1,311 @@
|
||||
/*******************************************************************
|
||||
|
||||
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.
|
||||
|
||||
*******************************************************************/
|
||||
|
||||
var GELGajiJS = {
|
||||
PHP: '',
|
||||
KODE: '',
|
||||
|
||||
index: function(q){
|
||||
$('#butTambah').click(() => this.tx_tambah());
|
||||
$('#butUbah').click(() => this.tx_ubah());
|
||||
$('#butHapus').click(() => this.tx_hapus());
|
||||
$('#butSimpan').click(() => this.tx_simpan());
|
||||
$('#butBatal').click(() => this.tx_batal());
|
||||
$('#butPrint').click(() => this.tx_print());
|
||||
this.data_query('master', 'view', ((typeof(q)!=='undefined') ? q : ''));
|
||||
},
|
||||
|
||||
tx_brow: function(){
|
||||
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_TX" 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="divBrowTX"> </div>');
|
||||
this.winBTX = FoniaJS.showWindow('BTX', 'Daftar Transaksi', _isi, 'xl', '', () => {
|
||||
$('#winBTX')
|
||||
.find('#Cari_TX').keydown((e) => {
|
||||
var key = e.keyCode || e.which || 0;
|
||||
if (key==13 && e.target.value!='') this.data_query('brow-tx');
|
||||
}).end()
|
||||
.find('#butSearch').click(() => this.data_query('brow-tx')).end()
|
||||
.find('#butAll').click(() => {
|
||||
$('#winBTX').find('#Cari_TX').val('');
|
||||
this.data_query('brow-tx');
|
||||
});
|
||||
this.data_query('brow-tx');
|
||||
FoniaJS.setFocus('#Cari_TX');
|
||||
});
|
||||
},
|
||||
|
||||
tx_select: function(acell){
|
||||
FoniaJS.closeWindow(this.winBTX);
|
||||
$('#No_Gaji').val(acell[0]);
|
||||
this.data_query('master', 'view');
|
||||
},
|
||||
|
||||
tx_tambah: function(){
|
||||
this.data_query('master', 'add');
|
||||
},
|
||||
|
||||
tx_ubah: function(){
|
||||
if (!$('#No_Gaji').val()){
|
||||
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
|
||||
return;
|
||||
}
|
||||
FoniaJS.showAuth(() => this.data_query('master', 'edit'), this, 'EDIT '+$('#No_Gaji').val());
|
||||
},
|
||||
|
||||
tx_hapus: function(){
|
||||
if (!$('#No_Gaji').val()){
|
||||
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
|
||||
return;
|
||||
}
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan hapus <strong>'+$('#No_Gaji').val()+'</strong> ?', () => {
|
||||
FoniaJS.showAuth(() => {
|
||||
new Request({
|
||||
url: this.PHP + '/proses_hapus',
|
||||
sendParam: ['No_Gaji'],
|
||||
onSuccess: (adata) => {
|
||||
if (adata.status==true){
|
||||
$('#No_Gaji').val('');
|
||||
this.data_query('master', 'view');
|
||||
FoniaJS.showInfo('Proses hapus data sukses!');
|
||||
}else{
|
||||
FoniaJS.showInfo('Ada masalah dalam proses hapus data!');
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
}, this, 'DELETE '+$('#No_Gaji').val());
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
tx_simpan: function(){
|
||||
this.data_query('master', 'save');
|
||||
},
|
||||
|
||||
tx_batal: function(){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Yakin akan membatalkan ?', () => {
|
||||
this.data_query('master', 'cancel');
|
||||
$('#No_Gaji').val('');
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
tx_print: function(){
|
||||
if (!$('#No_Gaji').val()){
|
||||
FoniaJS.showError("Silakan masukkan Nomor Transaksi !");
|
||||
return;
|
||||
}
|
||||
this.winBCetak = FoniaJS.showWindow('BCetak', 'Daftar Pilihan Cetak Slip Gaji', '<div id="divBrowCetak"> </div>', 'lg', [{},{i:'butTutup'},{i:'butWCetak',v:'Cetak',c:'success'}], () => {
|
||||
$('#winBCetak').find('#butWCetak').click(() => this.tx_print_exec());
|
||||
this.data_query('brow-cetak');
|
||||
});
|
||||
},
|
||||
|
||||
tx_print_exec: function(){
|
||||
var cetak = new PrinterPos('report/nota/gaji');
|
||||
cetak.add_param("Nomor_Cetak", $('#No_Gaji').val());
|
||||
cetak.exec();
|
||||
FoniaJS.closeWindow(this.winBCetak);
|
||||
},
|
||||
|
||||
karya_brow: function(){
|
||||
var _isi = new String('<div class="row mb-1"><div class="col"><div class="input-group"><input class="form-control" id="Cari_Karya" 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="divBrowKarya"> </div>');
|
||||
this.winBKarya = FoniaJS.showWindow('BKarya', 'Daftar Karyawan', _isi, 'lg', '', () => {
|
||||
$('#winBKarya')
|
||||
.find('#Cari_Karya').keydown((e) => {
|
||||
var key = e.keyCode || e.which || 0;
|
||||
if (key==13 && e.target.value!='') this.data_query('brow-karya');
|
||||
}).end()
|
||||
.find('#butSearch').click(() => this.data_query('brow-karya')).end()
|
||||
.find('#butAll').click(() => {
|
||||
$('#winBKarya').find('#Cari_Karya').val('');
|
||||
this.data_query('brow-karya');
|
||||
});
|
||||
this.data_query('brow-karya');
|
||||
FoniaJS.setFocus('#Cari_Karya');
|
||||
});
|
||||
},
|
||||
|
||||
karya_select: function(acell){
|
||||
FoniaJS.closeWindow(this.winBKarya);
|
||||
this.detail_gaji('insert', 0, acell[0]);
|
||||
},
|
||||
|
||||
detail_gaji: function(mode, ID, KaryaID){
|
||||
new Request({
|
||||
url: this.PHP + '/form_gaji',
|
||||
sendParam: ['mode','mode_detail='+mode,'No_Gaji','ID='+ID,'KaryaID='+KaryaID],
|
||||
onSuccess: (a) => {
|
||||
this.winDetail = FoniaJS.showWindow('Detail', 'Detail Gaji Karyawan', a.html, 'lg', [{},{i:'butTutup'},{i:'butWSimpan',v:'Simpan',c:'success'}], () => {
|
||||
FoniaJS.AutoComplete('#Nama_Karya', this.PHP + '/auto_karya', ['No_Gaji'], {'selectFunc': this.Karya_Comp});
|
||||
$('#winDetail')
|
||||
.find('#butWSimpan').click(() => this.detail_simpan()).end()
|
||||
.find('#Qty_Harian').keyup((e) => {
|
||||
this.Hitung_Detail();
|
||||
if (e.target.value == 0) return false;
|
||||
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Qty_Lembur');
|
||||
}).end()
|
||||
.find('#Qty_Lembur').keyup((e) => {
|
||||
this.Hitung_Detail();
|
||||
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Qty_BonusM');
|
||||
}).end()
|
||||
.find('#Qty_BonusM').keyup((e) => {
|
||||
this.Hitung_Detail();
|
||||
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Qty_BonusB');
|
||||
}).end()
|
||||
.find('#Qty_BonusB').keyup((e) => {
|
||||
this.Hitung_Detail();
|
||||
if (-1!==$.inArray(e.which, [13,9])) FoniaJS.setFocus('#Total_Potong');
|
||||
}).end()
|
||||
.find('#Total_Potong').keyup((e) => {
|
||||
this.Hitung_Detail();
|
||||
if (e.which==13) this.detail_simpan();
|
||||
});
|
||||
if (mode == 'insert' && KaryaID == 0) {
|
||||
FoniaJS.setFocus('#Nama_Karya');
|
||||
} else {
|
||||
this.Hitung_Detail();
|
||||
FoniaJS.setFocus('#Qty_Harian');
|
||||
}
|
||||
});
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
detail_tambah: function(){
|
||||
this.detail_gaji('insert', 0, 0);
|
||||
},
|
||||
|
||||
detail_ubah: function(acell){
|
||||
this.detail_gaji('update', acell[0], acell[1]);
|
||||
},
|
||||
|
||||
detail_hapus: function(acell){
|
||||
FoniaJS.showConfirm('Konfirmasi', 'Hapus item <strong>"'+acell[2]+'"</strong> ?', () => {
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/table_detail',
|
||||
sendParam: ['mode','mode_detail=delete','No_Gaji','ID='+acell[0]]
|
||||
}).send();
|
||||
}, 'danger');
|
||||
},
|
||||
|
||||
detail_simpan: function(){
|
||||
if (parseInt($('#KaryaID').val())==0) {
|
||||
FoniaJS.showError('Silakan masukkan Nama Karyawan !');
|
||||
return;
|
||||
}
|
||||
if (FoniaJS.StrToFloat($('#Total_Potong').val()) > FoniaJS.StrToFloat($('#Total_Pinjam').val())) {
|
||||
FoniaJS.showError('Jumlah Potongan melebihi Jumlah Pinjaman !');
|
||||
}
|
||||
var _mdetail = $('#mode_detail').val();
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/table_detail',
|
||||
sendParam: ['mode','mode_detail','No_Gaji','KaryaID','Qty_Harian','Gaji_Harian','Qty_Lembur','Lembur_Harian','Qty_BonusM','Qty_BonusB','Bonus_Minggu','Bonus_Bulan','Total_Potong','CatatKar','ID'],
|
||||
onSuccess: () => {
|
||||
if (_mdetail=='insert') { this.detail_tambah(); } else FoniaJS.closeWindow(this.winDetail);
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
data_query: function(tipe, mode, kd_tx){
|
||||
if (tipe=="master"){
|
||||
var sparam = ['mode='+mode,'No_Gaji'+((typeof(kd_tx)!=='undefined')?'='+kd_tx:'')];
|
||||
if ((mode ?? '')=='save') sparam = ['mode=save','No_Gaji','Tgl_Gaji','CabID','Tahun','Bulan','Minggu','Catatan='+encodeURIComponent($('#Catatan').val())];
|
||||
new Request({
|
||||
url: this.PHP + '/form_master',
|
||||
sendParam: sparam,
|
||||
onSuccess: (ajson) => {
|
||||
$('#divTXMaster').html(ajson.html);
|
||||
$('#butBrow').click(() => this.tx_brow());
|
||||
$('#No_Gaji').keyup((e) => {
|
||||
if ((e.which || e.keyCode) == 13) {
|
||||
if (($("#No_Gaji")) && ($("#No_Gaji").val() !== '')) this.data_query('master');
|
||||
}
|
||||
});
|
||||
this.data_query('tabel-detail');
|
||||
if ($.inArray($("#mode").val(),['add','edit']) !== -1) {
|
||||
$('#butBrow').prop('disabled', true).removeClass('btn-info').addClass('btn-secondary');
|
||||
$('#butTambah').addClass('d-none');
|
||||
$('#butUbah').addClass('d-none');
|
||||
$('#butHapus').addClass('d-none');
|
||||
$('#butPrint').addClass('d-none');
|
||||
$('#butSimpan').removeClass('d-none');
|
||||
$('#butBatal').removeClass('d-none');
|
||||
} else {
|
||||
$('#butBrow').prop('disabled', false).removeClass('btn-secondary').addClass('btn-info');
|
||||
$('#butTambah').removeClass('d-none');
|
||||
$('#butUbah').removeClass('d-none');
|
||||
$('#butHapus').removeClass('d-none');
|
||||
$('#butPrint').removeClass('d-none');
|
||||
$('#butSimpan').addClass('d-none');
|
||||
$('#butBatal').addClass('d-none');
|
||||
}
|
||||
}
|
||||
}).send();
|
||||
} else if (tipe=="tabel-detail"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/table_detail',
|
||||
sendParam: ['mode','No_Gaji']
|
||||
}).send();
|
||||
} else if (tipe=="brow-tx"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/brow_tx',
|
||||
sendParam: ['Cari_TX'],
|
||||
onSuccess: () => FoniaJS.setFocus('#Cari_TX')
|
||||
}).send();
|
||||
} else if (tipe=="brow-karya"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/brow_karya',
|
||||
sendParam: ['No_Gaji','Cari_Karya'],
|
||||
onSuccess: () => FoniaJS.setFocus('#Cari_Karya')
|
||||
}).send();
|
||||
} else if (tipe=="brow-cetak"){
|
||||
new Request.JSONF({
|
||||
url: this.PHP + '/brow_cetak',
|
||||
sendParam: ['No_Gaji']
|
||||
}).send();
|
||||
}
|
||||
},
|
||||
|
||||
Karya_Comp: function(item){
|
||||
var adata = item.data.split(':');
|
||||
$('#KaryaID').val(item.value);
|
||||
$('#Gaji_Harian').val(FoniaJS.FloatToStr(adata[0]));
|
||||
$('#Total_Pinjam').val(FoniaJS.FloatToStr(adata[1]));
|
||||
FoniaJS.setFocus('#Qty_Harian');
|
||||
},
|
||||
|
||||
oc_Minggu: function(){
|
||||
new Request({
|
||||
url: this.PHP + '/option_minggu',
|
||||
sendParam: ['Tahun','Bulan'],
|
||||
onSuccess: (adata) => {
|
||||
if (!adata.option) return false;
|
||||
$('#Minggu').empty();
|
||||
adata.option.map((val) => {
|
||||
$('#Minggu').append(new Option(val['label'],val['value'],false))
|
||||
});
|
||||
$('#Minggu').trigger('change');
|
||||
}
|
||||
}).send();
|
||||
},
|
||||
|
||||
Hitung_Detail: function(){
|
||||
var dgaji = FoniaJS.StrToFloat($('#Qty_Harian').val()) * FoniaJS.StrToFloat($('#Gaji_Harian').val());
|
||||
var dlemb = FoniaJS.StrToFloat($('#Qty_Lembur').val()) * FoniaJS.StrToFloat($('#Lembur_Harian').val());
|
||||
var dbon1 = FoniaJS.StrToFloat($('#Qty_BonusM').val()) * FoniaJS.StrToFloat($('#Bonus_Minggu').val());
|
||||
var dbon2 = FoniaJS.StrToFloat($('#Qty_BonusB').val()) * FoniaJS.StrToFloat($('#Bonus_Bulan').val());
|
||||
var dpoto = FoniaJS.StrToFloat($('#Total_Potong').val());
|
||||
$('#Tot_Gaji').val(FoniaJS.FloatToStr(dgaji));
|
||||
$('#Tot_Lembur').val(FoniaJS.FloatToStr(dlemb));
|
||||
$('#Tot_Bonus1').val(FoniaJS.FloatToStr(dbon1));
|
||||
$('#Tot_Bonus2').val(FoniaJS.FloatToStr(dbon2));
|
||||
$('#Jumlah').val(FoniaJS.FloatToStr(dgaji+dlemb+dbon1+dbon2-dpoto));
|
||||
}
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user