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.

151 lines
4.9 KiB
JavaScript

import { action } from "{js}ts-tagihan-action.js?v={time}";
import { idGenerator } from "{js}module-idgenerator.js?v={time}";
import { print } from '{js}ts-tagihan-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
};
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;
};
window.printFaktur = function (dat, y) {
let kode = dat.dataset.kode;
print(kode, y);
}
var objectForm = {
debug: true,
title: function () {
return 'Posting'
},
table: "mtagihan",
idform: "containerforms",
newkode: ``,
kode: 'kodetagihan',
// serverSide:true,
view: ['kodetagihan', 'rek1', 'rek', 'jurubayar', 'kodesp', 'tgl', 'userlog'],
dataSelect: ["*"],
queryTemp: "SELECT a.kodetagihan, a.jurubayar, a.kodesp, ifnull(sm.rekdebit, '-' ) rek, ifnull(sw.rekdebit, '-' ) rek1, ifnull(dt.tgl, '-' ) tgl, ifnull(dt.userlog, '-' ) userlog FROM ( SELECT * FROM mtagihan WHERE statusposting = 1 GROUP BY kodetagihan ) a LEFT JOIN debit_posting_sm sm ON a.kodetagihan = sm.posting LEFT JOIN debit_posting_sw sw ON a.kodetagihan = sw.posting LEFT JOIN debit_posting_date dt ON a.kodetagihan = dt.posting GROUP BY kodetagihan || ORDER BY kodetagihan DESC",
validasiForm: ['jurubayar'],
oncreate: function () {
_setval('tgl', tanggal().normal);
$('#jurubayar').val('').trigger('change');
},
disableEditor: function (a, b, c) {
return `
<div>
<button onclick="window.printFaktur(this, 'usp');" data-kode="${a}" class="btn btn-clear"><i class="icon-printer"></i> USP</button>
<button onclick="window.printFaktur(this, 'induk');" data-kode="${a}" class="btn btn-clear"><i class="icon-printer"></i> INDUK</button>
</div>
`;
},
onupdate: function (dt) {
globalThis['kode'].parent.setAttribute('readonly', true);
},
custcondition: function (a) {
return a + '';
}
, onviewonly: action,
custome: {
rek1: function (a) {
if (acc.cond(a, 'id').length > 0){
return a + ' - ' + acc.cond(a, 'id')[0].text;
}
return a;
},
rek: function (a) {
if (acc.cond(a, 'id').length > 0){
return a + ' - ' + acc.cond(a, 'id')[0].text;
}
return a;
}
,tgl: function (a) {
return a;
}
},
custOrder: ['userlog'],
_condDeleteStop: [
{ id: 'statusposting', val: '1' }
]
, data: [
{
title: 'Kode Tagihan',
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: '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', 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 () {
},
}
]
};