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.

190 lines
5.1 KiB
JavaScript

const getQuery = function (qr) {
return new Promise((resolve, reject) => {
try {
AuditDevQuery(qr, function (data) {
resolve(data)
})
} catch (e) {
reject(e)
}
})
}
var mainObj = {
title: function () {
return 'Main Rek. COA '
},
table: "mainacc",
idform: "containerforms",
newkode: ``,
kode: 'kode',
view: ['kode', 'nama', 'dk', 'kel'],
columnsExport: [1, 2, 3],
noAction: true,
dataSelect: ["*"],
queryTemp: "SELECT {select} FROM mainacc || ORDER BY kode ASC",
custome: {
kel: function (a) {
let [data] = _json('paruskas').cond(a, 'id')
return data ? data.text : '-';
}
},
custButton: function (a, i) {
return `
<button data-id="${i}" data-kode="${a.kode}" class="btn btn-sm btn-clear edit" style="color:green;">
<i class="icon-note"></i>
</button>
<button data-id="${i}" data-kode="${a.kode}" class="btn btn-sm btn-clear hapus" style="color:red;">
<i class="icon-trash"></i>
</button>
`;
},
beforeDelete: async function (data) {
let cek = await getQuery(`
SELECT sum(1) total FROM (
SELECT DISTINCT rekdebit kode FROM lap_bb a
UNION
SELECT DISTINCT rekkredit kode FROM lap_bb a
) a
LEFT JOIN acc ON a.kode = acc.kode
WHERE acc.main = '${data.kode}'
`);
if(cek.length > 0){
swal('Peringatan', 'Data ini masih digunakan di data lain', 'warning');
throw 'stop action';
}
},
validasiForm: ['kode', 'nama', 'dk', 'mainkel', 'kel', 'subkel'],
oncreate: function (a) {
$('select#dk').val('').trigger('change');
globalThis['username'].parent.value = username;
globalThis['userlog'].parent.value = timestamp();
if (typeof _radioAct != 'undefined') {
_radioAct.setVal('ekuitas', 0)
_radioAct.setVal('dk', 'D')
}
},
onupdate: function (dt) {
globalThis['username'].parent.value = username;
globalThis['userlog'].parent.value = timestamp();
(async () => {
let cek = await getQuery(`
SELECT sum(1) total FROM (
SELECT DISTINCT rekdebit kode FROM lap_bb a
UNION
SELECT DISTINCT rekkredit kode FROM lap_bb a
) a
LEFT JOIN acc ON a.kode = acc.kode
WHERE acc.main = '${dt.kode}'
`);
if (cek.length > 0) {
document.querySelector('button.simpan').style.display = 'none';
throw 'stop action';
}
})();
},
data: [
{
title: 'Kode',
type: 'text',
name: 'kode',
row: 12,
readonly: false,
action: function () {
},
}
, {
title: 'Nama COA',
type: 'text',
name: 'nama',
row: 12,
readonly: false,
action: function () {
},
}
, {
title: 'D/K',
type: 'radio',
name: 'dk',
row: 12,
readonly: false,
data: [{ id: 'D', text: 'Debit' }, { id: 'K', text: 'Kredit' }],
action: function () {
},
}
, {
title: 'Kategori Utama',
type: 'radio',
name: 'mainkel',
row: 12,
readonly: false,
data: _json('pmainacc').map(function (s) { return { id: s.main, text: s.main } }),
action: function () {
},
}
, {
title: 'Sub Kategori Utama',
type: 'radio',
name: 'subkel',
down: true,
downcols: 3,
row: 12,
readonly: false,
data: _json('psubacc').map(function (s) { return { id: s.nama, text: s.nama } }),
action: function () {
},
}
, {
title: 'Kel. Arus Kas',
type: 'radio',
name: 'kel',
row: 12,
readonly: false,
data: _json('paruskas'),
action: function () {
},
}
, {
title: 'Set Ekuitas',
type: 'radio',
name: 'ekuitas',
row: 12,
readonly: false,
data: [{ id: '0', text: 'Bukan Ekuitas' }, { id: '1', text: 'Ekuitas' }],
action: function () {
},
}
, {
title: 'username',
type: 'text',
display: 'none',
name: 'username',
row: 12,
readonly: false,
action: function () {
},
}
, {
title: 'userlog',
type: 'text',
display: 'none',
name: 'userlog',
row: 12,
readonly: false,
action: function () {
},
}
]
};
objectForm = mainObj;