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.

1950 lines
61 KiB
JavaScript

const toBase64 = function (str) {
return window.btoa(unescape(encodeURIComponent(str)));
}
const fromBase64 = function (str) {
return decodeURIComponent(escape(window.atob(str)));
}
const _fullScreen = function () {
if (window.innerWidth > 1024) {
setTimeout(() => {
document.querySelector('.modern-nav-toggle').click();
try{
(function(){
if (window.table != undefined) {
window.table.draw(false);
}
})();
}catch(e){
console.log(e);
};
}, 1000);
}
};
Number.prototype.rp = function (a) {
var idr = new Intl.NumberFormat(undefined, {
style: 'currency',
currency: 'IDR',
minimumFractionDigits: 0,
maximumFractionDigits: 0,
});
var s = this;
if (s == null) {
s = 0;
}
var num = s.valueOf();
return idr.format(num).replace(/IDR/g, "Rp");
}
window._masterData = {};
window._master = function (n, a) {
if (window._masterData[n] == undefined) {
window._masterData[n] = JSON.parse(_id(a).innerHTML);
}
return window._masterData[n];
}
function uuid() {
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
);
}
function formatRupiah(angka, prefix) {
var topHead = "";
if (angka.toString()[0] == "-") {
topHead = "-";
}
var number_string = angka.replace(/[^,\d]/g, "").toString(),
split = number_string.split(","),
sisa = split[0].length % 3,
rupiah = split[0].substr(0, sisa),
ribuan = split[0].substr(sisa).match(/\d{3}/gi);
// tambahkan titik jika yang di input sudah menjadi angka ribuan
if (ribuan) {
var separator = sisa ? "." : "";
rupiah += separator + ribuan.join(".");
}
rupiah = split[1] != undefined ? rupiah + "," + split[1] : rupiah;
rupiah = topHead + rupiah;
return prefix == undefined ? rupiah : rupiah ? "" + rupiah : "";
}
const _id = function (id = '') {
return document.getElementById(id);
}
const _json = function (id = '') {
return JSON.parse(_id(id).innerHTML);
}
const _getThnBln = function (id = '') {
if (_val('bulan') && _val('tahun')){
return _val('tahun')+'-'+_val('bulan');
}
let g = tanggal().normal.split('-');
g.pop()
return g.join('-');
}
const _val = function (id = '', nilai = null) {
if (document.getElementById(id)){
if(!nilai){
return document.getElementById(id).value;
}
return document.getElementById(id).value = nilai;
}
return null;
}
const _valHTML = function (id = '') {
if (document.getElementById(id)){
return document.getElementById(id).innerHTML;
}
return null;
}
const _setHTML = function (id = '', html, multi=0) {
if(multi > 0){
Array.from(document.querySelector(id))
.forEach(function(o){
o.innerHTML = html;
})
return false;
}
if (document.getElementById(id)){
return document.getElementById(id).innerHTML = html;
}
return null;
}
const _month2 = ["Jan", "Feb", "Mar", "Apr", "Mei", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Des"];
const _3month = ["Mar", "Jun", "Sep","Des"];
const ucapanSelamat = function() {
var waktu = new Date().getHours();
var ucapan;
if (waktu >= 5 && waktu <= 11) {
ucapan = "Selamat Pagi!";
} else if (waktu >= 12 && waktu < 14) {
ucapan = "Selamat Siang!";
} else if (waktu >= 15 && waktu < 18) {
ucapan = "Selamat Sore!";
} else {
ucapan = "Selamat Malam!";
}
return ucapan;
}
const _dateIndo = function(...arg){
if(typeof tanggal == 'function'){
let date = arg.join('-');
return tanggal(arg).sekarang2;
}
return null
}
const _dateIndoLast = function(...arg){
if(typeof tanggal == 'function'){
let date = arg.join('-');
return tanggal( tanggal(arg).normal3 ).sekarang2;
}
return null
}
const _select = function (id = '') {
return document.querySelector(id);
}
const _selectAll = function (id = '') {
return document.querySelectorAll(id);
}
const _month = [
{
id: '01',
text: 'Jan'
}
, {
id: '02',
text: 'Feb'
}
, {
id: '03',
text: 'Mar'
}
, {
id: '04',
text: 'Apr'
}
, {
id: '05',
text: 'Mei'
}
, {
id: '06',
text: 'Jun'
}
, {
id: '07',
text: 'Jul'
}
, {
id: '08',
text: 'Aug'
}
, {
id: '09',
text: 'Sep'
}
, {
id: '10',
text: 'Okt'
}
, {
id: '11',
text: 'Nov'
}
, {
id: '12',
text: 'Des'
}
];
const cssLoader = function () {
var lod =
div()
.class('css-loader')
.css({
position: 'fixed',
top: 0,
left: 0,
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
width: '100vw',
height: '100vh',
zIndex: '9999999',
background: 'rgba(125,125,125,0.4)'
})
.child(
el('style').html(`
.lds-spinner {
color: official;
display: inline-block;
position: relative;
width: 80px;
height: 80px;
}
.lds-spinner div {
transform-origin: 40px 40px;
animation: lds-spinner 1.2s linear infinite;
}
.lds-spinner div:after {
content: " ";
display: block;
position: absolute;
top: 3px;
left: 37px;
width: 6px;
height: 18px;
border-radius: 20%;
background: #fff;
}
.lds-spinner div:nth-child(1) {
transform: rotate(0deg);
animation-delay: -1.1s;
}
.lds-spinner div:nth-child(2) {
transform: rotate(30deg);
animation-delay: -1s;
}
.lds-spinner div:nth-child(3) {
transform: rotate(60deg);
animation-delay: -0.9s;
}
.lds-spinner div:nth-child(4) {
transform: rotate(90deg);
animation-delay: -0.8s;
}
.lds-spinner div:nth-child(5) {
transform: rotate(120deg);
animation-delay: -0.7s;
}
.lds-spinner div:nth-child(6) {
transform: rotate(150deg);
animation-delay: -0.6s;
}
.lds-spinner div:nth-child(7) {
transform: rotate(180deg);
animation-delay: -0.5s;
}
.lds-spinner div:nth-child(8) {
transform: rotate(210deg);
animation-delay: -0.4s;
}
.lds-spinner div:nth-child(9) {
transform: rotate(240deg);
animation-delay: -0.3s;
}
.lds-spinner div:nth-child(10) {
transform: rotate(270deg);
animation-delay: -0.2s;
}
.lds-spinner div:nth-child(11) {
transform: rotate(300deg);
animation-delay: -0.1s;
}
.lds-spinner div:nth-child(12) {
transform: rotate(330deg);
animation-delay: 0s;
}
@keyframes lds-spinner {
0% {
opacity: 1;
}
100% {
opacity: 0;
}
}
`)
)
.child(
div().class('lds-spinner')
.html(`<div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div><div></div>`)
)
.get()
document.body.appendChild(lod)
return lod;
};
try{
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define([], factory);
} else if (typeof exports !== "undefined") {
factory();
} else {
var mod = {
exports: {}
};
factory();
global.FileSaver = mod.exports;
}
})(this, function () {
"use strict";
/*
* FileSaver.js
* A saveAs() FileSaver implementation.
*
* By Eli Grey, http://eligrey.com
*
* License : https://github.com/eligrey/FileSaver.js/blob/master/LICENSE.md (MIT)
* source : http://purl.eligrey.com/github/FileSaver.js
*/
// The one and only way of getting global scope in all environments
// https://stackoverflow.com/q/3277182/1008999
var _global = typeof window === 'object' && window.window === window ? window : typeof self === 'object' && self.self === self ? self : typeof global === 'object' && global.global === global ? global : void 0;
function bom(blob, opts) {
if (typeof opts === 'undefined') opts = {
autoBom: false
}; else if (typeof opts !== 'object') {
console.warn('Depricated: Expected third argument to be a object');
opts = {
autoBom: !opts
};
} // prepend BOM for UTF-8 XML and text/* types (including HTML)
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
if (opts.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
return new Blob([String.fromCharCode(0xFEFF), blob], {
type: blob.type
});
}
return blob;
}
function download(url, name, opts) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.responseType = 'blob';
xhr.onload = function () {
saveAs(xhr.response, name, opts);
};
xhr.onerror = function () {
console.error('could not download file');
};
xhr.send();
}
function corsEnabled(url) {
var xhr = new XMLHttpRequest(); // use sync to avoid popup blocker
xhr.open('HEAD', url, false);
xhr.send();
return xhr.status >= 200 && xhr.status <= 299;
} // `a.click()` doesn't work for all browsers (#465)
function click(node) {
try {
node.dispatchEvent(new MouseEvent('click'));
} catch (e) {
var evt = document.createEvent('MouseEvents');
evt.initMouseEvent('click', true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null);
node.dispatchEvent(evt);
}
}
var saveAs = _global.saveAs || // probably in some web worker
typeof window !== 'object' || window !== _global ? function saveAs() { }
/* noop */
// Use download attribute first if possible (#193 Lumia mobile)
: 'download' in HTMLAnchorElement.prototype ? function saveAs(blob, name, opts) {
var URL = _global.URL || _global.webkitURL;
var a = document.createElement('a');
name = name || blob.name || 'download';
a.download = name;
a.rel = 'noopener'; // tabnabbing
// TODO: detect chrome extensions & packaged apps
// a.target = '_blank'
if (typeof blob === 'string') {
// Support regular links
a.href = blob;
if (a.origin !== location.origin) {
corsEnabled(a.href) ? download(blob, name, opts) : click(a, a.target = '_blank');
} else {
click(a);
}
} else {
// Support blobs
a.href = URL.createObjectURL(blob);
setTimeout(function () {
URL.revokeObjectURL(a.href);
}, 4E4); // 40s
setTimeout(function () {
click(a);
}, 0);
}
} // Use msSaveOrOpenBlob as a second approach
: 'msSaveOrOpenBlob' in navigator ? function saveAs(blob, name, opts) {
name = name || blob.name || 'download';
if (typeof blob === 'string') {
if (corsEnabled(blob)) {
download(blob, name, opts);
} else {
var a = document.createElement('a');
a.href = blob;
a.target = '_blank';
setTimeout(function () {
click(a);
});
}
} else {
navigator.msSaveOrOpenBlob(bom(blob, opts), name);
}
} // Fallback to using FileReader and a popup
: function saveAs(blob, name, opts, popup) {
// Open a popup immediately do go around popup blocker
// Mostly only avalible on user interaction and the fileReader is async so...
popup = popup || open('', '_blank');
if (popup) {
popup.document.title = popup.document.body.innerText = 'downloading...';
}
if (typeof blob === 'string') return download(blob, name, opts);
var force = blob.type === 'application/octet-stream';
var isSafari = /constructor/i.test(_global.HTMLElement) || _global.safari;
var isChromeIOS = /CriOS\/[\d]+/.test(navigator.userAgent);
if ((isChromeIOS || force && isSafari) && typeof FileReader === 'object') {
// Safari doesn't allow downloading of blob urls
var reader = new FileReader();
reader.onloadend = function () {
var url = reader.result;
url = isChromeIOS ? url : url.replace(/^data:[^;]*;/, 'data:attachment/file;');
if (popup) popup.location.href = url; else location = url;
popup = null; // reverse-tabnabbing #460
};
reader.readAsDataURL(blob);
} else {
var URL = _global.URL || _global.webkitURL;
var url = URL.createObjectURL(blob);
if (popup) popup.location = url; else location.href = url;
popup = null; // reverse-tabnabbing #460
setTimeout(function () {
URL.revokeObjectURL(url);
}, 4E4); // 40s
}
};
_global.saveAs = saveAs.saveAs = saveAs;
if (typeof module !== 'undefined') {
module.exports = saveAs;
}
});
}catch(e){
}
window._printDoc = function (res) {
var printV = null;
if (document.querySelector('#printDocuPageLay') == undefined) {
printV = el('iframe').id('printDocuPageLay').css('display', 'none').get();
document.body.appendChild(printV)
} else {
printV = globalThis['printDocuPageLay'].parent
}
var win1 = printV.contentWindow;
win1.document.open()
win1.document.write(res)
win1.document.close()
win1.print()
}
window._exportExcel = function (content, title) {
content = new Blob([content], {
type: 'application/vdn.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8'
});
saveAs(content, title + '.xls');
};
const AuditDev = function (validasi = '', urlapp = '') {
return {
urlsave: "https://indowebs.my.id/admin/api/save",
getnew: "https://s-feed.com/simanis/api/regist",
token: "https://s-feed.com/simanis/api/getToken",
masterlink: "?key=master-api&value=",
data: {
regist: false,
table: "",
limit: "",
order: "",
select: " * ",
condition: "",
setCreate: 0,
leftJoin: "",
saveset: 0,
updatedata: null,
obj: null
},
table: function (a) {
this.data.table = a;
return this;
},
group: function (arr = []) {
this.data.groupby = arr;
return this;
},
regist: function () {
this.data.regist = true;
return this;
},
condition: function (a = []) {
var sp = " WHERE ";
sp += a.map(function (x, i) {
return ` ${x.opsi} ${x.data[0]} ${x.data[1]} ${x.data[2]} `;
}).join(" ")
this.data.condition = sp;
return this;
},
like: function (a = []) {
var sp = " ";
if (this.data.condition != "") {
sp = "";
} else {
sp = " WHERE ";
}
sp += a.map(function (x, i) {
return ` ${x.opsi} ${x.data[0]} ${x.data[1]} ${x.data[2]} `;
}).join(" ")
if (this.data.condition != "") {
this.data.condition += ' AND (' + sp + ')';
} else {
this.data.condition += sp;
}
return this;
},
select: function (a) {
this.data.select = a;
return this;
},
delete: function () {
var up = " DELETE FROM " + this.data.table + " ";
up += this.data.condition;
this.data.updatedata = up;
return this;
},
update: function (a = {}) {
function escapeHtml(text) {
return text
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/'/g, "&#039;");
}
var up = " UPDATE " + this.data.table + " SET ";
up += Object.keys(a).map(function (x, s) {
return ` ${x} = '${a[x]}' `;
}).join(",")
up += this.data.condition;
this.data.updatedata = up;
return this;
},
leftJoin: function (a = []) {
this.data.leftJoin = '';
var pp = this;
a.forEach(function (y, i) {
pp.data.leftJoin += " LEFT JOIN " + y[0] + " ON " + y[1] + " " + y[2] + " " + y[3] + " ";
})
return this;
},
order: function (a, b = "DESC") {
this.data.order = ` ORDER BY ${a} ${b} `;
return this;
},
limit: function (a, b) {
this.data.limit = ` LIMIT ${a}, ${b} `;
return this;
},
save: function (obj = {}) {
function escapeHtml(text) {
return text
.replace(/&/g, "&amp;")
.replace(/</g, "&lt;")
.replace(/>/g, "&gt;")
.replace(/'/g, "&#039;");
}
this.data.obj = obj;
var dat = Object.keys(obj);
var dd = dat.map(function (x, c) {
return '\'' + obj[x] + '\'';
}).join(",");
this.data.saveset = 1;
this.data.save = `INSERT INTO ${this.data.table} (${dat.join(",")}) VALUES (${dd}) `;
return this;
}
, createTable: function (a = {}) {
this.data.setCreate = 1;
this.data.createTable = "CREATE TABLE " + this.data.table + " (";
this.data.createTable += " id INT(11) UNSIGNED AUTO_INCREMENT PRIMARY KEY, ";
var pp = this;
Object.keys(a).forEach(function (x, i) {
if (i == (Object.keys(a).length - 1)) {
pp.data.createTable += " " + x + " " + a[x] + " ";
} else {
pp.data.createTable += " " + x + " " + a[x] + " , ";
}
})
this.data.createTable += " ) ";
return this;
},
text2Binary: function (string) {
return string.split('').map(function (char) {
return char.charCodeAt(0).toString(2);
}).join('2');
},
nextIncrement: function () {
this.data.nextIncrement = `SELECT auto_increment AS increment FROM INFORMATION_SCHEMA.TABLES WHERE table_name = '${this.data.table}'`;
return this;
},
master: function (data, func, unsafe = 0) {
if (unsafe == 0) {
var loco = this;
xdb('epost', ['dataMaster'], 7, function (s) {
s.read('dataMaster', 'master', function (s) {
if (s != null) {
$.ajax({
url: loco.masterlink + '/' + loco.text2Binary(JSON.stringify(data)),
success: function (res) {
res = JSON.parse(res)
globalThis.dataMaster = res;
setTimeout(function () {
func()
})
xdb('epostadmin', ['dataMaster'], 7, function (s) {
s.add('dataMaster', { id: 'master', data: res })
});
},
error: function (xhr, ajaxOptions, thrownError) {
Array.from(document.querySelectorAll('.css-loader')).forEach(function(e){
e.remove();
});
Swal('warning', 'Connectioin lost,please try again', 'warning');
throw 'error connection';
}
})
} else {
$.ajax({
url: loco.masterlink + '/' + loco.text2Binary(JSON.stringify(data)),
success: function (res) {
res = JSON.parse(res)
globalThis.dataMaster = res;
func()
xdb('epostadmin', ['dataMaster'], 7, function (s) {
s.add('dataMaster', { id: 'master', data: res })
});
},
error: function (xhr, ajaxOptions, thrownError) {
Array.from(document.querySelectorAll('.css-loader')).forEach(function (e) {
e.remove();
});
Swal('warning', 'Connectioin lost,please try again', 'warning');
throw 'error connection';
}
})
}
})
});
} else {
var loco = this;
$.ajax({
url: loco.masterlink + '/' + loco.text2Binary(JSON.stringify(data)),
success: function (res) {
res = JSON.parse(res);
func()
globalThis.dataMaster = res;
},
error: function (xhr, ajaxOptions, thrownError) {
}
})
}
}
, getToken: function (a) {
$.ajax({
url: this.token + '/' + this.text2Binary(JSON.stringify(a)),
success: function (res) {
if (res.includes('nodata')) {
alert('maaf user tidak terdaftar')
} else {
res = JSON.parse(res);
localStorage.setItem('loginCond', res.token);
location.href = "#/";
}
},
error: function (xhr, ajaxOptions, thrownError) {
}
})
return this;
},
get: function (func, qr = null) {
var ck = this;
var query = "";
var nTable = this.data.table;
var groupby = '';
if (this.data.groupby != undefined) {
if (this.data.groupby.length > 0) {
groupby = " GROUP BY " + this.data.groupby.join(",");
}
}
query = ` SELECT ${this.data.select} FROM (SELECT * FROM ${nTable} ${groupby} ) a ${this.data.leftJoin} ${this.data.condition} ${this.data.order} ${this.data.limit} `;
if (qr != null) {
query = qr.replace(/\n/g, ' ');
}
if (this.data.setCreate == 1) {
query = this.data.createTable;
}
if (this.data.saveset == 1) {
query = this.data.save;
}
if (this.data.updatedata != null) {
query = this.data.updatedata;
}
if (this.data.nextIncrement != null) {
query = this.data.nextIncrement;
}
if (query.indexOf("SELECT") != -1) {
upload('{{PATH}}/db/api', '', 'qr.data', toBase64(query), (a) => { }, (b) => {
var res = JSON.parse(b);
func(res.data, res.count, ck)
});
} else {
upload('{{PATH}}/db/api', '', 'qr.data', toBase64(query), (a) => { }, (b) => {
var res = b;
if (res.includes('simpan')) {
func('disimpan', ck)
} else {
res = JSON.parse(res)
func(res.data, res.count, ck)
}
});
}
return this;
}
}
}
const AuditDevQuery = function (a, func) {
AuditDev('').get(func, a);
};
(function () {
var t = Array.from(document.querySelectorAll('.menu-title')).forEach(function (t) {
var r = t.parentNode;
if (location.href.indexOf(r.href) != -1) {
r.parentNode.className = 'active';
} else {
r.parentNode.className = '';
}
})
})();
const timestamp = function () {
var v = new Date();
return tanggal().normal + ' ' + v.toTimeString().split(' ')[0];
};
(function stillAlive() {
var es = el('script')
es.src('{{PATH}}/alive')
es.load(function(e){
var f = e.el;
setTimeout(function(){
f.remove();
stillAlive();
},5000)
});
document.head.appendChild(es.get());
})();
const modaluser = $("#useractivemodal");
const saveuser = $("#saveuser");
const profileinfo = $("#infoprofile");
const logoutEl = document.getElementById('logoutaction');
saveuser.on('click',function(){
var ff = Array.from(document.querySelectorAll('.user-i'));
var update = ' UPDATE username SET ';
update += ff.map(function (ik, i) {
return ` ${ik.name} = "${ik.value}" `;
}).join(" , ");
update += ` WHERE username = "${username}"`;
AuditDevQuery(update, function(){
logoutEl.click();
});
})
window._EditProfile = function(){
AuditDevQuery(`SELECT * FROM username WHERE username = '${username}'`, function(sx){
if (sx.length > 0){
sx = sx[0];
var demo = sx.demo;
if(demo == 1){
profileinfo.html('Anda ada di mode demo!');
}
var ff = Array.from(document.querySelectorAll('.user-i'));
ff.forEach(function(ik,i){
var nm = ik.name;
ik.value = sx[nm];
if(demo == 1){
ik.setAttribute('readonly',true)
}
})
modaluser.modal('show');
}
});
};
const listPinjam = [{ "id": "REG", "text": "USP Reguler" }, { "id": "USP1", "text": "USP 1 (Pembiayaan Elektronik)" }, { "id": "USP2", "text": "USP 2 (Pembiayaan Sepeda Motor)" }, { "id": "USP3", "text": "USP 3 (Pembiayaan Haji/ Umroh)" }, { "id": "KHUSUS", "text": "USP KHUSUS" }]
window._ObjectKeysToArray = function(a){
return Object.keys(a).filter(function(x){
if(Array.isArray(a[x])){
return x;
}
}).map(function(s){
return a[s];
})
};
Array.prototype.getItemArrayNum = function(num) {
return this.map(function(s){
return s[num]
})
}
Array.prototype.getString = function(num) {
return this.filter(function(s){
if(typeof s === 'string'){
return s
}
})
}
Array.prototype.notDate = function(num) {
var ty = this.filter(function(s){
if (Number.isNaN(tanggal(s).angka) === true){
return s
}
})
return ty;
}
const BLNID = {
"Januari" : "01",
"Pebruari" : "02",
"Maret" : "03",
"April" : "04",
"Mei" : "05",
"Juni" : "06",
"Juli" : "07",
"Agustus" : "08",
"September" : "09",
"Oktober" : "10",
"Nopember" : "11",
"November" : "11",
"Desember" : "12"
}
Array.prototype.fixMonth = function() {
var ty = this.map(function(s){
if(s === '-'){
return '0000-00-00';
}else{
var e = s;
Object.keys(BLNID).forEach(function(j){
e = e.replaceAll(j, BLNID[j]);
});
e = e.split(' ');
e = e[2]+'-'+e[1]+'-'+e[0];
return e;
}
});
return ty;
}
String.prototype.fixMonth = function() {
var s = this;
if (s === '-') {
return '0000-00-00';
} else {
var e = s;
Object.keys(BLNID).forEach(function (j) {
e = e.replaceAll(j, BLNID[j]);
});
if(e.indexOf('-') != -1){
return e;
}
e = e.split(' ');
if(e.length > 1){
e = e[2] + '-' + e[1] + '-' + e[0];
}else{
e = e[0]+'-00-00';
}
return e;
}
}
String.prototype.replaceMonth = function() {
var s = this;
if (s === '-') {
return '0000-00-00';
} else {
var e = s;
Object.keys(BLNID).forEach(function (j) {
e = e.replaceAll(j, BLNID[j]);
});
return e;
}
}
Array.prototype.ArrayHtmlToElement = function (num,select,kode) {
return this.map(function (s) {
return (function(c){
console.log(c);
if(c != null){
return c.dataset[kode];
}else{
return c;
}
return c;
})(el('div').html(s[num]).get().querySelector(select));
}).filter(function(g){
if(g != null){
return g;
}
})
};
const DeleteTable = function(table, cond, validasi){
var link = location.href;
var origin = location.origin+validasi;
if(link === origin){
if(typeof cond === 'object'){
if(Object.keys(cond).length > 0){
var w = ' WHERE ';
w += Object.keys(cond).map(function(s){
return ` \`${s}\` = "${cond[s].replace(/\"/g,"\\\"")}" `;
}).join(",");
return `DELETE FROM \`${table}\` ${w} `;
}
return `DELETE FROM \`${table}\` `;
}
}
}
Array.prototype.ToInsert = function (table = 'test', wht = '') {
var s = this;
if(s.length > 0){
var y = Object.keys(s[0]);
var x = '';
x += 'INSERT INTO ';
x += table;
x += '(';
x += y.map(function(u){
return ` \`${u}\` `
}).join(',');
x += ')';
x += '\n';
x += 'SELECT ';
x += y.map(function(g){
return `a.${g}`;
});
x += ' FROM (';
x += s.map(function(w){
var f = ` SELECT `;
f += y.map(function(q){
if (w[q] != null){
return `"${w[q].toString().replace(/\"/g,"\\\"")}" \`${q}\``;
}else{
return `"-" \`${q}\``;
}
}).join(",");
return f;
}).join("\n UNION ALL \n")
x += ') a';
if (Array.isArray(wht)){
x += ` LEFT JOIN ${table} ON `
x += wht.map(function(whtx){
return ` ${table}.${whtx} = a.${whtx} `;
}).join(" AND ");
x += ` WHERE `;
x += wht.map(function(whtx){
return ` ${table}.${whtx} IS NULL `;
}).join(" AND ");
}
return x;
} else {
return [];
}
};
Array.prototype.ToSelect = function (table = 'test', wht = '') {
var s = this;
if(s.length > 0){
var y = Object.keys(s[0]);
var x = '';
x += 'SELECT ';
x += y.map(function(g){
return `a.${g}`;
});
x += ' FROM (';
x += s.map(function(w){
var f = ` SELECT `;
f += y.map(function(q){
if (w[q] != null){
return `"${w[q].toString().replace(/\"/g,"\\\"")}" \`${q}\``;
}else{
return `"-" \`${q}\``;
}
}).join(",");
return f;
}).join("\n UNION ALL \n")
x += ') a';
if (Array.isArray(wht)){
x += ` LEFT JOIN ${table} ON `
x += wht.map(function(whtx){
return ` ${table}.${whtx} = a.${whtx} `;
}).join(" AND ");
x += ` WHERE `;
x += wht.map(function(whtx){
return ` ${table}.${whtx} IS NULL `;
}).join(" AND ");
}
return x;
} else {
return [];
}
};
Array.prototype.removeDuplicate = function (b = ['kode','nama']) {
var t = [].concat(this);
var n = [];
var nr = [];
t.forEach(function(o){
if(typeof o === 'string'){
if(n.indexOf(o) == -1){
n.push(o);
nr.push(o);
};
};
if(typeof o === 'object'){
var f = '';
var g = {};
b.forEach(function(u){
f += o[u];
g[u] = o[u];
});
if(n.indexOf(f) == -1){
n.push(f);
nr.push(g);
};
};
});
return nr;
}
const removeDuplicate = function (dat = [], b = ['kode','nama'], c = ['id', 'text']) {
var t = dat;
var n = [];
var nr = [];
t.forEach(function(o){
if(typeof o === 'string'){
if(n.indexOf(o) == -1){
n.push(o);
nr.push(o);
};
};
if(typeof o === 'object'){
var f = '';
var g = {};
b.forEach(function(u, i){
f += o[u];
g[u] = o[u];
if(c[i] != undefined){
g[c[i]] = o[u];
}
});
if(n.indexOf(f) == -1){
n.push(f);
nr.push(g);
};
};
});
return nr;
};
Array.prototype.makeMaster = function (a,b) {
var t = this;
var n = t.map(function(s){
var x = {}
x[a] = s;
x[b] = s;
return x
})
return n;
}
function ExcelDateToJSDate(serial) {
var utc_days = Math.floor(serial - 25569);
var utc_value = utc_days * 86400;
var date_info = new Date(utc_value * 1000);
var fractional_day = serial - Math.floor(serial) + 0.0000001;
var total_seconds = Math.floor(86400 * fractional_day);
var seconds = total_seconds % 60;
total_seconds -= seconds;
var hours = Math.floor(total_seconds / (60 * 60));
var minutes = Math.floor(total_seconds / 60) % 60;
return new Date(date_info.getFullYear(), date_info.getMonth(), date_info.getDate(), hours, minutes, seconds);
}
const _textArea = function (a, b, c, d, l = '250px', type = 'text') {
if (a == null) {
a = '-';
}
return `
<div style="min-width:${l};position:relative;height:28px;display:grid; grid-template-columns: auto 20px;">
<div data-kode="note-`+ b[c] + `" class="data-show">` + a + `</div>
<div style="text-align:center;"><i class="icon-note"></i></div>
<div data-toggle="tooltip" data-placement="left" title="click to edit" style="position:absolute;top:0; left:0; width: 100%; height: 100%; z-index:2;cursor:pointer;" data-name="`+ d + `" data-type="` + type + `" data-action-table="` + b[c] + `"></div>
</div>
`;
}
const _nowhitespace = function (a) {
return `<span style="white-space:nowrap;">${a}</span>`
}
const _trashTable = function (a,b,c) {
return `
<button data-id="${c}" data-kode="${a}" class="btn btn-sm btn-clear hapus" style="color:red;"><i class="icon-trash"></i></button>
`;
};
const _deleteAction = function (a,b,c) {
return `
<button onclick="window._delClicked?window._delClicked('${a}'):console.log('no action');" class="btn btn-sm btn-clear" style="color:red;"><i class="icon-trash"></i></button>
`;
};
const _standardTableAct = function (a,b,c) {
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>
`;
};
const _deleteOnlyTableAct = function (a,b,c) {
return `
<button data-id="${c}" data-kode="${a}" class="btn btn-sm btn-clear hapus" style="color:red;"><i class="icon-trash"></i></button>
`;
};
const statusTagihan = [
{id:"0",text:"Prosses"}
,{id:"1",text:"Telah diproses"}
];
const replaceFromMaster = function (master, id,val,row){
var txt = '';
if(!Array.isArray(master)){
master = [];
}
master.forEach(function(s){
if(s[id] == val){
txt = s[row]
}
})
return txt;
};
const _getElement = function (cond) {
return {
el: Array.from(document.querySelectorAll(cond)).map(function (w) {
return {
el: w,
data: (function (w) {
var z = {};
Object.keys(w.dataset).forEach(function (o) {
z[o] = w.dataset[o];
});
return z;
})(w),
click: function () {
this.el.click();
return this;
}
}
}),
findData: function (name, val) {
this.el = this.el.filter(function (po) {
if (po.data[name] == val) {
return po;
}
});
return this;
},
click: function () {
this.el.reverse().forEach(function (x) {
x.el.click();
})
return this;
}
, focus: function () {
this.el.reverse().forEach(function (x) {
x.el.focus();
})
return this;
}
}
};
const scrollIntoViewWithOffset = (selector, offset) => {
window.scrollTo({
behavior: 'smooth',
top:
selector.getBoundingClientRect().top -
document.body.getBoundingClientRect().top -
offset,
})
}
window.mobileCheck = function () {
let check = false;
(function (a) { if (/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true; })(navigator.userAgent || navigator.vendor || window.opera);
return check;
};
Array.prototype.removeItemObject = function(a){
var t = this;
var x = t.map(function(s){
delete s[a];
return s;
})
return t;
}
Array.prototype.renameItemObject = function(a, b){
var t = this;
var x = t.map(function(s){
s[b] = s[a];
return s;
})
return t;
}
Array.prototype.log = function(){
var t = this;
console.log(JSON.stringify(t));
return t;
}
const _ff = {
select: function (a) {
var ct = div().class('form-group roms').css('margin', '0');
var inpt = el('select').class('form-control form-s').name(a.name).id('s-' + a.name + Date.now())
.css('height', '38px');
if (a.readonly == true) {
inpt.attr('readonly', 'true')
.css({
background: '#2E7D32',
color: '#fff'
});
};
inpt.child(
el('option').val('').html('Pilih Data')
);
if (a.action != undefined) {
inpt.load(a.action);
};
a.data.forEach(function (dt) {
inpt.child(
el('option').val(dt.id).html(dt.id + '-' + dt.text)
);
});
if (a.val != undefined) {
inpt.addModule('val', a.val);
};
inpt.load(function (s) {
var id = s.el.id;
$('#' + id).select2();
if (s.el.val != undefined) {
$('#' + id).val(s.el.val).trigger('change');
};
// If readonly, also style select2
if (a.readonly == true) {
setTimeout(function() {
var sel2 = document.querySelector('#select2-' + id + '-container');
if(sel2) {
sel2.parentElement.style.background = '#2E7D32';
sel2.parentElement.style.color = '#fff';
}
}, 200);
}
});
ct.child(
inpt
);
return ct.get();
},
num: function (a) {
var ct = div().class('form-group').css('margin', '0');
var inpt = el('input').type('text')
.class('form-control form-s numbers').attr('num', true).name(a.name).id('s-' + a.name + Date.now()).hold('0').css({
textAlign: 'right',
height: '38px'
});
if (a.readonly == true) {
inpt.attr('readonly', 'true')
.css({
background: '#2E7D32',
color: '#fff'
});
};
if (a.val != undefined) {
inpt.val(Number(a.val).currency(0));
}
inpt.load(function (e) {
e.el.addEventListener('keyup', function () {
var c = this.value;
var pis = c.length - 1;
if (c[pis] == ".") {
c = c.substr(0, pis) + ",";
}
c = c.replace(/\./g, "");
this.value = formatRupiah(c, "");
}, false);
});
ct.child(
inpt
);
return ct.get();
},
text: function (a) {
var ct = div().class('form-group').css('margin', '0');
var inpt = el('input').type('text')
.class('form-control form-s').css({
textAlign: 'left !important',
height: '38px'
}).name(a.name).id('s-' + a.name + Date.now()).hold('keterangan...')
if (a.readonly == true) {
inpt.attr('readonly', 'true')
.css({
background: '#2E7D32',
color: '#fff'
});
};
if (a.val != undefined) {
inpt.val(a.val);
};
ct.child(
inpt
);
return ct.get();
}
};
Array.prototype.addItemObject = function(a,val){
let t = [].concat(this);
let x = t.map(function(s){
if(Array.isArray(val)){
s[a] = val.map(function(c){
if( s[c] != undefined && s[c] != null ){
return s[c];
}
return c;
}).join('');
}else{
s[a] = val;
}
return s;
})
return t;
}
const _App = (function(){
var o = {}
o.QZprinter = function(a = false){
localStorage.setItem('active-print-direct', a)
}
o.qzStatus = function(){
return qz.websocket.isActive();
}
o.posprint = function(a){
localStorage.setItem('print-pos', a);
return this;
}
o.posprintget = function(a){
return localStorage.getItem('print-pos');
}
o.MultiDB = function(query, callback){
if(Array.isArray(query)){
query = JSON.stringify(query);
};
upload('{{PATH}}/db/api/multiple', '', 'qr.data', btoa(query), (a) => { }, (b) => {
if(typeof callback === 'function'){
callback();
}
});
}
o.ArrayObjectToArray = function(a, n){
if(Array.isArray(a) && Array.isArray(n)){
return a.map(function(ax){
var t = [];
n.forEach(function(g){
if(ax[g] != null || ax != undefined){
t.push(ax[g]);
}else{
t.push('');
}
})
return t;
})
}
return [];
}
o.pushTable = function(a,b, c){
if(window[a] != undefined && typeof window[a] === 'object'){
if(Array.isArray(b)){
window[a].clear();
b.forEach(function(ax, i){
if(Array.isArray(ax)){
var n = ax;
if(Array.isArray(c)){
n = n.map(function(m, s){
if(c[s] != null && typeof c[s] === 'function'){
return c[s](m, n);
}
return m;
});
};
window[a].row.add(n);
};
})
window[a].draw(1);
}
}
}
o.clearTable = function(a){
if(window[a] != undefined && typeof window[a] === 'object'){
window[a].clear();
window[a].draw(1);
}
}
return o;
})();
const callUserFunc = function(a,par){
if(window[a+'_globals_func_dev'] != undefined && typeof window[a+'_globals_func_dev'] === 'function' ){
if(par === undefined){
par = [];
}
return window[a+'_globals_func_dev'](...par);
}else{
if(Swal != undefined){
Swal('Warning', 'tidak dapat di prosess', 'warning');
}else{
alert('tidak dapat di prosses');
}
}
}
const createUserFunc = function(a,func){
if(typeof func === 'function'){
window[a+'_globals_func_dev'] = func;
}else{
if(Swal != undefined){
Swal('Warning', 'bukan function', 'warning');
}else{
alert('tidak dapat di prosses');
}
}
}
createUserFunc('keterangan', function(a,b){
return a+' '+tanggal(b).sekarang2.split(' ').filter(function (o, i) {
if (i > 0) {
return o;
}
}).join(' ');
})
Array.prototype.singleItem = function(a){
var f = this;
if(f.length > 0){
if(f[0][a] != null){
return f[0][a];
}
return '';
}
return '';
}
Array.prototype.ToUpdate = function (table = 'test', wht = 'kode') {
var s = this;
if (s.length > 0) {
var y = Object.keys(s[0]);
var x = '';
x += 'UPDATE ';
x += table;
x += ' aa , ( ';
x += 'SELECT ';
x += y.map(function (g) {
return `a.${g}`;
});
x += ' FROM (';
x += s.map(function (w) {
var f = ` SELECT `;
f += y.map(function (q) {
return `"${w[q].toString().replace(/\"/g, "\\\"")}" \`${q}\``;
}).join(",");
return f;
}).join("\n UNION ALL \n")
x += ') a ) bb SET ';
x += y.map(function(c){
return ` aa.${c} = bb.${c}`
}).join(',');
x += ' WHERE ';
if (Array.isArray(wht)){
x += wht.map(function(whtx){
return ` aa.${whtx} = bb.${whtx} `;
}).join(" AND ");
}else{
x += ` aa.${wht} = bb.${wht} `;
}
return x;
} else {
return [];
}
};
window._insertAfter = function(newNode, existingNode) {
existingNode.parentNode.insertBefore(newNode, existingNode.nextSibling);
}
window._insertBefore = function(newNode, existingNode) {
existingNode.parentNode.insertBefore(newNode, existingNode);
}
function _parentForm(tag){
return globalThis[tag].parent.parentNode.parentNode;
}
Array.prototype.like = function (columnName, searchValues) {
// Membuat salinan array untuk menghindari perubahan pada array asli
var newArray = this.slice();
// Mencari indeks kolom berdasarkan nama kolom
var columnIndex = Object.keys(newArray[0]).indexOf(columnName);
// Jika nama kolom ditemukan
if (columnIndex !== -1) {
// Mencari data berdasarkan nilai pada kolom yang ditentukan
var results = newArray.filter(function (item) {
if (Array.isArray(searchValues)) {
var f = searchValues.filter(function (x) {
if (item[columnName].indexOf(x) != -1) {
return item;
}
});
if (f.length > 0) {
return item;
}
} else {
if (item[columnName].indexOf(searchValues) != -1) {
return item;
}
}
});
return results;
} else {
// Jika nama kolom tidak ditemukan, kembalikan array kosong
return [];
}
};
window.popupCenter = ({ url, title, w, h }) => {
// Fixes dual-screen position Most browsers Firefox
const dualScreenLeft = window.screenLeft !== undefined ? window.screenLeft : window.screenX;
const dualScreenTop = window.screenTop !== undefined ? window.screenTop : window.screenY;
const width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
const height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
const systemZoom = width / window.screen.availWidth;
const left = (width - w) / 2 / systemZoom + dualScreenLeft
const top = (height - h) / 2 / systemZoom + dualScreenTop
const newWindow = window.open(url, title,
`
scrollbars=yes,
width=${w / systemZoom},
height=${h / systemZoom},
top=${top},
left=${left}
`
)
if (window.focus) newWindow.focus();
}
Object.defineProperty(String.prototype, 'capitalFirst', {
value: function () {
var temp = this;
temp = (function qw(temp) {
if (temp[0] == " ") {
return qw(temp.slice(1));
}
return temp;
})(temp);
var c = temp.charAt(0).toUpperCase()
var d = temp.slice(1).toLowerCase()
return c+d;
},
enumerable: false
});
Number.prototype.pembilang = function() {
var s = this;
var nilai = s.valueOf();
return (function pembilang(nilai) {
nilai = Math.abs(nilai);
var simpanNilaiBagi = 0;
var huruf = ["", "Satu", "Dua", "Tiga", "Empat", "Lima", "Enam", "Tujuh", "Delapan", "Sembilan", "Sepuluh", "Sebelas"];
var temp = "";
if (nilai < 12) {
temp = " " + huruf[nilai];
}
else if (nilai < 20) {
temp = pembilang(nilai - 10) + " Belas";
}
else if (nilai < 100) {
simpanNilaiBagi = Math.floor(nilai / 10);
temp = pembilang(simpanNilaiBagi) + " Puluh" + pembilang(nilai % 10);
}
else if (nilai < 200) {
temp = " Seratus" + pembilang(nilai - 100);
}
else if (nilai < 1000) {
simpanNilaiBagi = Math.floor(nilai / 100);
temp = pembilang(simpanNilaiBagi) + " Ratus" + pembilang(nilai % 100);
}
else if (nilai < 2000) {
temp = " Seribu" + pembilang(nilai - 1000);
}
else if (nilai < 1000000) {
simpanNilaiBagi = Math.floor(nilai / 1000);
temp = pembilang(simpanNilaiBagi) + " Ribu" + pembilang(nilai % 1000);
}
else if (nilai < 1000000000) {
simpanNilaiBagi = Math.floor(nilai / 1000000);
temp = pembilang(simpanNilaiBagi) + " Juta" + pembilang(nilai % 1000000);
}
else if (nilai < 1000000000000) {
simpanNilaiBagi = Math.floor(nilai / 1000000000);
temp = pembilang(nilai / 1000000000000) + " Triliun" + pembilang(nilai % 1000000000000);
}
return temp;
})(nilai);
};
Number.prototype.numToAlpabet = function () {
let angka = this.valueOf();
if (angka <= 0) {
return "Angka harus lebih besar dari 0";
}
let result = "";
while (angka > 0) {
const remainder = (angka - 1) % 26;
result = String.fromCharCode(97 + remainder) + result;
angka = Math.floor((angka - 1) / 26);
}
return result;
};
Object.defineProperty(Number.prototype, "numToAlpabet", { writable: false });
Object.defineProperty(String.prototype, "hitungTanggal", {
value: function (bulan) {
// Validasi format tanggal
if (!/^\d{4}-\d{2}$/.test(this)) {
return "Format tanggal tidak valid";
}
// Memisahkan tahun dan bulan dari string
const [tahun, bulanStr] = this.split('-');
const bulanInt = parseInt(bulanStr, 10);
if (isNaN(bulanInt)) {
return "Bulan tidak valid";
}
// Menghitung tahun dan bulan baru
let newTahun = parseInt(tahun, 10);
let newBulan = bulanInt + bulan;
// Penanganan jika hasil bulan negatif
while (newBulan <= 0) {
newBulan += 12;
newTahun--;
}
// Konversi bulan menjadi string dengan format "MM"
newBulan = newBulan.toString().padStart(2, '0');
return `${newTahun}-${newBulan}`;
},
writable: false, // Membuat metode tidak dapat diubah
configurable: false, // Membuat metode tidak dapat dikonfigurasi ulang
enumerable: false // Membuat metode tidak terdaftar dalam perulangan objek
});
Object.defineProperty(String.prototype, 'toJson', {
value: function () {
try {
return JSON.parse(this);
} catch (error) {
throw new Error('String is not valid JSON');
}
},
configurable: false
});
// export excel
const tableToExcel = (function () {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--><meta http-equiv="content-type" content="text/plain; charset=UTF-8"/></head><body><table>{table}</table></body></html>'
, base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
return function (table, name, filename) {
if (!table.nodeType) table = document.getElementById(table);
let HTMLDataQ = Array.from(table.children).map(function (q) {
let g = Array.from(q.children).map(function(e){
return `<tr>${e.innerHTML}</tr>`;
}).join('');
return g;
}).join('');
let HTMLDataH = Array.from(table.children).map(function (q) {
let g = Array.from(q.children).map(function(e){
let gc = Array.from( e.children )
.map(function(o){
if(o.className === 'number'){
let h = o;
h.innerHTML = h.innerHTML.number();
return h.outerHTML;
}else{
return o.outerHTML
}
}).join("");
return `<tr>${gc}</tr>`;
}).join('');
return g;
}).join('');
var ctx = { worksheet: name || 'Worksheet', table: HTMLDataH }
if(typeof saveAs === 'function'){
if(filename){
saveAs(uri + base64(format(template, ctx)), filename);
}else{
saveAs(uri + base64(format(template, ctx)), 'nama');
}
}else{
window.location.href = uri + base64( format(template, ctx) )
}
}
})();
const loaderCssCek = function(){
let s = Array.from(document.querySelectorAll('.css-loader'));
if(s.length === 0){
cssLoader();
}
}
const loaderCssRemove = delay(function(){
let s = Array.from(document.querySelectorAll('.css-loader'));
if(s.length > 0 ){
s.forEach(function(o){
o.remove();
})
}
},300);
const RP = new Intl.NumberFormat('idr', {
style: 'currency',
currency: 'IDR',
});
const RUPIAH = function(a){
let [c,v] = RP.format(a).split(".");
return c.replace(/IDR/gi, 'Rp').replace(/\,/gi, ".")+(v? ","+v:"");
}
const Confirm = function(a='',b='',c=null, d='warning'){
Swal({
title: a,
text: b,
type: d,
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 () {
typeof c === 'function' ? c():null;
}, false);
}
// Inject global style for Select2 height fix
newStyle(`
.select2-container .select2-selection--single {
height: 38px !important;
min-height: 38px !important;
padding: 0 !important;
display: flex;
align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
line-height: 38px !important;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
height: 38px !important;
}
`);