You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

252 lines
7.6 KiB
JavaScript

import { action, prosesPenarikan } from "{js}ts-penarikan-action.js?v={time}";
import { idGenerator } from "{js}module-idgenerator.js?v={time}";
import { print } from '{js}ts-penarikan-print.js?v={time}';
String.prototype.extractText = function () {
let text = this.match(/[a-zA-Z]+/g); // Menggunakan regular expression untuk mencocokkan teks
return text ? text.join(' ') : ''; // Menggabungkan teks yang cocok menjadi satu string
};
window.printFaktur = function (dat, y) {
let kode = dat;
print(kode, y);
}
window._delClicked = function(a){
Confirm(`Warning`, 'apa anda yakin ingin menghapus transaksi', function(){
if(a && a != '' && a.indexOf('P-') != -1){
let cs = cssLoader();
AuditDevQuery(`
DELETE FROM lap_bb WHERE posting = '${a}'
[;]
DELETE FROM msimpan WHERE posting = '${a}'
[;]
DELETE FROM mpenarikan WHERE kodetagihan = '${a}'
`, function(){
cs.remove();
swal('Info', 'Berhasil di proses');
_load()
})
}else{
swal('Info', 'Gagal di proses');
}
})
}
const idTagihan = function (nama = "nama") {
const date = new Date();
const year = date.getFullYear().toString().substr(-2);
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
const formattedId = `${nama}-${year}${month}${day}${hours}${minutes}${seconds}`;
return formattedId;
};
// Mendefinisikan fungsi yang akan menjadi properti global
function prosesUlangPenarikan(param) {
prosesPenarikan(param);
}
// Menggunakan Object.defineProperty untuk membuat properti yang tidak bisa diubah
Object.defineProperty(window, 'prosesUlangPenarikan', {
value: prosesUlangPenarikan,
writable: false,
configurable: false,
});
var objectForm = {
debug: true,
title: function () {
return 'Penarikan'
},
table: "mpenarikan",
idform: "containerforms",
newkode: ``,
serverSide: true,
kode: 'kodetagihan',
view: ['kodetagihan', 'cash', 'jurubayar', 'tgl', 'statusposting', 'userlog'],
dataSelect: [" a.*, (SELECT cash FROM msimpan WHERE posting = a.kodetagihan LIMIT 1) cash "],
queryTemp: `SELECT
{select} FROM (SELECT *
FROM mpenarikan GROUP BY kodetagihan) a
|| ORDER BY kodetagihan DESC`,
validasiForm: ['cash','kodesp','jurubayar'],
oncreate: function () {
console.log(acc[1]);
_setval('cash', acc[1].id);
_setval('tgl', tanggal().normal);
_setval('kodesp', 'TK');
$('#jurubayar').val('').trigger('change');
},
disableEditor: function (a, b, c) {
console.log(b)
if (b.statusposting == 1){
return `
<button class="btn btn-clear" onclick="window.printFaktur('${a}')" > Cetak Penarikan</div>
`;
}else{
return _deleteAction(a, b, c) + `
<button class="btn btn-clear" onclick="window.printFaktur('${a}')" > Cetak Penarikan</div>
`;
}
},
onupdate: function (dt) {
globalThis['kode'].parent.setAttribute('readonly', true);
},
custcondition: function (a) {
return a + '';
}
, onviewonly: action,
custome: {
statusposting: function (a) {
if (a == null) {
return '-';
}
return replaceFromMaster(statusTagihan, 'id', a, 'text');
}
,cash: function (a) {
if(a == null){
return '-';
}
if(acc.cond(a, 'id').length > 0){
return a+' - '+acc.cond(a, 'id')[0].text;
}
return a;
}
},
custOrder: ['userlog', 'kodetagihan'],
_condDeleteStop: [
{ id: 'statusposting', val: '1' }
]
, _delete : function(s){
Swal({
title: "Apa kamu yakin?",
text: "Data ini akan di hapus dari system!",
type: "warning",
showCancelButton: true,
confirmButtonColor: '#DD6B55',
confirmButtonText: 'Ya, Saya yakin!',
cancelButtonText: "Tidak, Batalkan!",
closeOnConfirm: false,
closeOnCancel: false
},
function (isConfirm) {
if (isConfirm) {
swal("Cancelled", "Your imaginary file is safe :)", "error");
} else {
swal("Cancelled", "Your imaginary file is safe :)", "error");
e.preventDefault();
}
});
setTimeout(() => {
document.querySelector('.swal2-cancel').focus()
}, 100);
document.querySelector('.swal2-confirm').addEventListener('click', function () {
console.log(s)
$.ajax({
url: `/usp/cancel/posting/penarikan/`+s,
success: function(){
Swal('info', 'Data berhasil di di hapus', 'info');
window._load();
}
})
}, false)
}
, data: [
{
title: 'Kode Penarikan',
type: 'text',
name: 'kodetagihan',
row: 12,
info: 'kode akan di generate otomatis setelah juru bayar diisi',
readonly: true,
action: function () {
},
}
, {
title: 'Tgl. Transaksi',
type: 'date',
name: 'tgl',
row: 12,
line: 120,
readonly: false,
action: function () {
},
}
, {
title: 'Simpanan',
type: 'select',
name: 'kodesp',
row: 12,
data: simpanan,
line: 120,
readonly: false,
action: function () {
},
}
, {
title: 'Bayar dari',
type: 'select',
name: 'cash',
row: 12,
data: acc.map((c)=> { return {id:c.kode, text: c.nama} }),
line: 120,
readonly: false,
action: function () {
},
}
, {
title: 'Juru Bayar',
type: 'select',
name: 'jurubayar',
row: 12,
line: 120,
readonly: false,
data: JSON.parse(_id('munit').innerHTML),
action: function (a) {
if (typeof _Evchange != 'undefined') {
_Evchange(a, function () {
let val = this.value
.toUpperCase()
.extractText()
.replace(/\ /g, '')
.substring(0, 3);
if (val != '') {
_setVal('kodetagihan', 'P-'+idTagihan(val));
}
});
} else {
Swal('Info', '_Evchange tidak di load dengan benar', 'warning');
}
},
}
, {
title: 'Kasir',
type: 'text',
name: 'kasir',
row: 6,
readonly: true,
action: function () {
},
}
, {
title: 'Jam',
type: 'text',
name: 'jam',
row: 6,
readonly: true,
action: function () {
},
}
]
};