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.
311 lines
9.3 KiB
JavaScript
311 lines
9.3 KiB
JavaScript
import { insertNode, counter, addButton } from '{js}bb-add.js?v={time}';
|
|
import { crons } from '{js}bb-cron.js?v={time}';
|
|
var acc = _json('acc').map(function(a){
|
|
return {
|
|
id:a.kode,
|
|
text:a.nama,
|
|
app:a.app,
|
|
}
|
|
})
|
|
var mainObj = {
|
|
title: function () {
|
|
return 'Jurnal Memorial ';
|
|
},
|
|
table: "totbb",
|
|
idform: "containerforms",
|
|
newkode: `SELECT LPAD( (ifnull((SELECT kode FROM totbb ORDER BY kode DESC LIMIT 1),0) + 1), 10,0) kode`,
|
|
kode: 'kode',
|
|
filldate: true,
|
|
datekode: 'tgl',
|
|
deleteOnly: false,
|
|
view: ['tgl', 'kode', 'keterangan', 'debit', 'kredit'],
|
|
disableEditor: function (a, b, c) {
|
|
let dayNow = tanggal(tanggal().normal).milisecond;
|
|
let datTransaction = tanggal(b.tgl).milisecond;
|
|
if (datTransaction < dayNow) {
|
|
return `
|
|
<button data-id="${c}" data-kode="${a}" class="btn btn-sm btn-clear edit" style="color:red;"><i class="icon-note"></i></button>
|
|
`;
|
|
} else {
|
|
return `
|
|
<button data-id="${c}" data-kode="${a}" class="btn btn-sm btn-clear edit" style="color:red;"><i class="icon-note"></i></button>
|
|
<button data-id="${c}" data-kode="${a}" class="btn btn-sm btn-clear hapus" style="color:red;"><i class="icon-trash"></i></button>
|
|
`;
|
|
}
|
|
},
|
|
beforeDelete: async function (data) {
|
|
let dayNow = tanggal(tanggal().normal).milisecond;
|
|
let datTransaction = tanggal(data.tgl).milisecond;
|
|
console.log(data.tgl);
|
|
console.log(datTransaction, dayNow);
|
|
if (datTransaction < dayNow) {
|
|
console.log("lewat");
|
|
swal('Warning', 'Maaf transaksi lewat dari 1 hari. Data tidak dapat dihapus. Silakan hubungi Admin.', 'warning')
|
|
throw "stop action";
|
|
}
|
|
},
|
|
custome: {
|
|
debit: function (a, b) {
|
|
if (b === 'update') {
|
|
return a.number().currency(0).replace(/\./g, ',');
|
|
} else {
|
|
return a.number(2).currency(0).replace(/\./g, ',');
|
|
};
|
|
}
|
|
, kredit: function (a, b) {
|
|
if (b === 'update') {
|
|
return a.number().currency(0).replace(/\./g, ',');
|
|
} else {
|
|
return a.number(2).currency(0).replace(/\./g, ',');
|
|
};
|
|
}
|
|
},
|
|
columnsExport: [1, 2, 3, 4, 5],
|
|
dataSelect: ["*"],
|
|
queryTemp: "SELECT {select} FROM totbb || ORDER BY tgl DESC",
|
|
validasiForm: ['app', 'kode', 'keterangan', 'debit', 'kredit'],
|
|
oncreate: function (a) {
|
|
counter.remove();
|
|
_setval('app', 'acc');
|
|
$('select#dk').val('').trigger('change');
|
|
_setval('tgl', tanggal().normal);
|
|
globalThis['username'].parent.value = dataApi.username;
|
|
globalThis['userlog'].parent.value = timestamp();
|
|
|
|
// area sub insert
|
|
if (globalThis['propertiadd'] == undefined) {
|
|
var content = div().id('contentprop');
|
|
var ii = insertNode().id('propertiadd');
|
|
ii.get().appendChild(div().id('headadd').get());
|
|
ii.get().appendChild(content.get());
|
|
ii.get().appendChild(
|
|
div().css({ textAlign: 'center' }).child(
|
|
el('button').click(function () { addButton() }).class('btn mt-1 btn-sm btn-primary').text('Tambah Jurnal')
|
|
).get()
|
|
);
|
|
};
|
|
globalThis['contentprop'].parent.innerHTML = '';
|
|
},
|
|
onupdate: function (dt) {
|
|
globalThis['username'].parent.value = dataApi.username;
|
|
globalThis['userlog'].parent.value = timestamp();
|
|
if (globalThis['propertiadd'] == undefined) {
|
|
var content = div().id('contentprop');
|
|
var ii = insertNode().id('propertiadd');
|
|
ii.get().appendChild(div().id('headadd').get());
|
|
ii.get().appendChild(content.get());
|
|
ii.get().appendChild(
|
|
div().css({ textAlign: 'center' }).child(
|
|
el('button').click(function () { addButton() }).class('btn mt-1 btn-sm btn-primary').text('Tambah Jurnal')
|
|
).get()
|
|
);
|
|
};
|
|
var t = cssLoader();
|
|
globalThis['contentprop'].parent.innerHTML = '';
|
|
AuditDevQuery(`SELECT * FROM bb WHERE kode = '${dt.kode}'`, function (r) {
|
|
t.remove();
|
|
r.forEach(function (t) {
|
|
addButton(t);
|
|
})
|
|
});
|
|
},
|
|
data: [
|
|
{
|
|
title: 'App',
|
|
type: 'select',
|
|
name: 'app',
|
|
row: 4,
|
|
readonly: true,
|
|
textonly: true,
|
|
data: AppData2,
|
|
action: function (e) {
|
|
_Evchange(e, function () {
|
|
var v = _getval('app');
|
|
var m = acc.sortArrayObjectAsc('id');
|
|
if (v.indexOf('acc') == -1 || v.indexOf('usp') == -1) {
|
|
m = m.like('app', v);
|
|
}
|
|
if (_id('propertiadd') != undefined) {
|
|
_setoptionmulti('propertiadd', 'rekdebit', m);
|
|
_setoptionmulti('propertiadd', 'rekkredit', m);
|
|
}
|
|
})
|
|
},
|
|
}
|
|
, {
|
|
title: 'Kode',
|
|
type: 'text',
|
|
name: 'kode',
|
|
row: 4,
|
|
readonly: true,
|
|
action: function () {
|
|
|
|
},
|
|
}
|
|
, {
|
|
title: 'Tanggal',
|
|
type: 'date',
|
|
name: 'tgl',
|
|
row: 4,
|
|
readonly: false,
|
|
action: function () {
|
|
|
|
},
|
|
}
|
|
, {
|
|
title: 'Keterangan',
|
|
type: 'text',
|
|
name: 'keterangan',
|
|
row: 12,
|
|
readonly: false,
|
|
action: function () {
|
|
|
|
},
|
|
}
|
|
, {
|
|
title: 'Debit',
|
|
type: 'number',
|
|
name: 'debit',
|
|
row: 6,
|
|
readonly: true,
|
|
action: function () {
|
|
|
|
},
|
|
}
|
|
, {
|
|
title: 'Kredit',
|
|
type: 'number',
|
|
name: 'kredit',
|
|
row: 6,
|
|
readonly: true,
|
|
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;
|
|
_id('underground').appendChild(
|
|
div().html(`
|
|
<table id="tabledata" class="display" style="width:100%">
|
|
<thead style="min-width:100%">
|
|
<tr id="headn1">
|
|
<th>#</th>
|
|
<th>Tanggal</th>
|
|
<th>Kode</th>
|
|
<th>Keterangan</th>
|
|
<th>Debit</th>
|
|
<th>Kredit</th>
|
|
</tr>
|
|
</thead>
|
|
<tfoot style="min-width:100%" >
|
|
<tr id="headn2">
|
|
<th>#</th>
|
|
<th>Tanggal</th>
|
|
<th>Kode</th>
|
|
<th>Keterangan</th>
|
|
<th>Debit</th>
|
|
<th>Kredit</th>
|
|
</tr>
|
|
</tfoot>
|
|
</table>
|
|
`).get()
|
|
);
|
|
|
|
globalThis._validasi = function () {
|
|
var d = globalThis['debit'].parent.value.number();
|
|
var k = globalThis['kredit'].parent.value.number();
|
|
if (d != k) {
|
|
Swal('Warning', 'Jurnal harus balance', 'warning');
|
|
throw 'jurnal harus balance';
|
|
}
|
|
};
|
|
|
|
globalThis._update = function () {
|
|
var q = [];
|
|
if (globalThis.insertS != undefined) {
|
|
q.push(globalThis.insertS);
|
|
};
|
|
if (globalThis.updateS != undefined) {
|
|
q.push(globalThis.updateS);
|
|
};
|
|
if (globalThis.insertSq != undefined) {
|
|
q.push(globalThis.insertSq);
|
|
};
|
|
if (globalThis.updateSq != undefined) {
|
|
q.push(globalThis.updateSq);
|
|
};
|
|
var dp = cssLoader();
|
|
var c = 0;
|
|
(function gld() {
|
|
if (c < q.length) {
|
|
AuditDevQuery(q[c], function () {
|
|
c++;
|
|
gld();
|
|
})
|
|
} else {
|
|
dp.remove();
|
|
}
|
|
})();
|
|
};
|
|
|
|
globalThis._insert = function () {
|
|
var q = [];
|
|
if (globalThis.insertS != undefined) {
|
|
q.push(globalThis.insertS);
|
|
};
|
|
if (globalThis.updateS != undefined) {
|
|
q.push(globalThis.updateS);
|
|
};
|
|
if (globalThis.insertSq != undefined) {
|
|
q.push(globalThis.insertSq);
|
|
};
|
|
if (globalThis.updateSq != undefined) {
|
|
q.push(globalThis.updateSq);
|
|
};
|
|
var dp = cssLoader();
|
|
var c = 0;
|
|
(function gld() {
|
|
if (c < q.length) {
|
|
AuditDevQuery(q[c], function () {
|
|
c++;
|
|
gld();
|
|
});
|
|
} else {
|
|
dp.remove();
|
|
}
|
|
})();
|
|
};
|
|
globalThis._delete = function (kode) {
|
|
var dp = cssLoader();
|
|
AuditDevQuery(`DELETE FROM bb WHERE kode = "${kode}" `, function (a) {
|
|
AuditDevQuery(`DELETE FROM lap_bb WHERE kode = "${kode}" `, function (a) {
|
|
dp.remove();
|
|
});
|
|
});
|
|
};
|
|
|
|
crons(); |