191 lines
6.4 KiB
JavaScript
191 lines
6.4 KiB
JavaScript
var cId;
|
|
class Loading {
|
|
static show() {
|
|
$("#loading").show();
|
|
}
|
|
|
|
static hide() {
|
|
$("#loading").hide();
|
|
}
|
|
}
|
|
|
|
//Block Function
|
|
function setprivileges(privkd, privflag, loginkd, menukd, menunm) {
|
|
if (privflag === "1") {
|
|
privflag = "0";
|
|
}
|
|
else if (privflag === "0") {
|
|
privflag = "1";
|
|
}
|
|
$.post("/bil_privileges/AsyncSetPrivileges",
|
|
{
|
|
BIL_PRIVILEGES_KD: privkd,
|
|
BIL_PRIVILEGES_FLAG: privflag,
|
|
BIL_LOGIN_KD: loginkd,
|
|
BIL_PRIV_MENU_KD: menukd,
|
|
BIL_PRIVILEGES_NM: menunm
|
|
}, function (result) {
|
|
$("#divloadpriv").load("/bil_kelompok_menu/partialIndex", { id: loginkd });
|
|
});
|
|
|
|
}
|
|
function addCommas(nStr) {
|
|
nStr += '';
|
|
x = nStr.split('.');
|
|
x1 = x[0];
|
|
x2 = x.length > 1 ? '.' + x[1] : '';
|
|
var rgx = /(\d+)(\d{3})/;
|
|
while (rgx.test(x1)) {
|
|
x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
|
}
|
|
return x1 + x2;
|
|
}
|
|
function calculateHargaSatuan(total, qty, txtbox, ppn, disc) {
|
|
var Tdiscnom = parseInt(total) - (total * (disc / 100));
|
|
var nppn = parseInt(Tdiscnom) + parseInt(Tdiscnom * (ppn / 100));
|
|
var hargaSatuan = nppn / qty;
|
|
$(txtbox).val(hargaSatuan);
|
|
}
|
|
function calculateHargaWhdisc(total, qty, txtbox, ppn, disc) {
|
|
var Tdiscnom = parseInt(total) - (total * (0 / 100));
|
|
var nppn = parseInt(Tdiscnom) + parseInt(Tdiscnom * (ppn / 100));
|
|
var hargaSatuan = nppn / qty;
|
|
$(txtbox).val(hargaSatuan);
|
|
}
|
|
|
|
function cetakPDF(path) {
|
|
Loading.show();
|
|
$.get(path, function (data) {
|
|
fetch('/pdfgenerator/pdf1', {
|
|
method: 'POST',
|
|
headers: {
|
|
Accept: 'arraybuffer',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
//you need to use json here
|
|
body: JSON.stringify({ pathhtml: btoa(unescape(encodeURIComponent(data))) })
|
|
})
|
|
.then(response => response.blob())
|
|
.then(data => {
|
|
var popup = window.open(URL.createObjectURL(data), "_blank", "height=500,width=750");
|
|
Loading.hide();
|
|
});
|
|
}).done(function () {
|
|
|
|
}).fail(function () {
|
|
Loading.hide();
|
|
});
|
|
}
|
|
function cetakSurkon(nokontrol) {
|
|
$('#loading').show();
|
|
$.post("/wsbpjs/NewCekSuratKontrolSingle",
|
|
{
|
|
nokontrol: nokontrol
|
|
}, function (result) {
|
|
try {
|
|
var inString = jQuery.parseJSON(result)
|
|
addToast(inString.code, inString.message);
|
|
console.log(inString.data);
|
|
if (inString.code == 200) {
|
|
fetch('/pdfgenerator/pdfsurkon', {
|
|
method: 'POST',
|
|
headers: {
|
|
Accept: 'arraybuffer',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
//you need to use json here
|
|
body: JSON.stringify({ pathhtml: btoa(unescape(encodeURIComponent(result))) })
|
|
})
|
|
.then(response => response.blob())
|
|
.then(data => {
|
|
var popup = window.open(URL.createObjectURL(data), "_blank", "height=500,width=750");
|
|
$('#loading').hide();
|
|
});
|
|
|
|
}
|
|
}
|
|
catch (e) {
|
|
alert(e);
|
|
}
|
|
|
|
}).done(function () {
|
|
$('#loading').hide();
|
|
}).fail(function (e) {
|
|
$('#loading').hide();
|
|
});
|
|
}
|
|
function enableTrx(selector) {
|
|
if ($("#BIL_GUDANG_PERMINTAAN_SUBUNIT").val() != "" && $("#BIL_GUDANG_PERMINTAAN_TGL").val() != "" && $("#BIL_GUDANG_PERMINTAAN_TGL_TERIMA").val() != "") {
|
|
$("[data-mutasibrg]").removeAttr("disabled");
|
|
}
|
|
else {
|
|
$("[data-mutasibrg]").attr("disabled", "disabled");
|
|
}
|
|
}
|
|
function printKronis(norj, remark) {
|
|
//var newWin = window.open('/bil_rincian_farmasi_rj/PartialNotaKronis?id=' + norj+'&remark='+remark, '_blank', 'Print-Window');
|
|
$.get('/bil_rincian_farmasi_rj/PartialNotaKronis/', { id: norj, remark: remark }, function (data) {
|
|
var opt = {
|
|
margin: 1,
|
|
filename: 'myfile.pdf',
|
|
image: { type: 'png' },
|
|
html2canvas: { scale: 2 },
|
|
jsPDF: { unit: 'cm', format: 'A4', orientation: 'p' },
|
|
|
|
};
|
|
|
|
// New Promise-based usage:
|
|
//html2pdf().set(opt).from(element).save();
|
|
html2pdf().set(opt).from(data).toPdf().get('pdf').then(function (pdfObj) {
|
|
// pdfObj has your jsPDF object in it, use it as you please!
|
|
// For instance (untested):
|
|
//pdfObj.autoPrint();
|
|
window.open(pdfObj.output('bloburl'), '_blank', "print-window");
|
|
});
|
|
|
|
});
|
|
}
|
|
function clearform(container) {
|
|
var $container = $(container);
|
|
|
|
// Clear semua input text, email, password, textarea
|
|
$container.find('input[type="text"],input[type="number"], input[type="email"], input[type="password"], input[type="hidden"], textarea').val('');
|
|
|
|
// Clear semua select dropdown (single dan multiple)
|
|
$container.find('select').prop('selectedIndex', 0);
|
|
}
|
|
function CetakKlaim(pathklaim, pathsep, pathlab, noreg) {
|
|
//Rincian
|
|
$('#loading').show();
|
|
var btoarincian;
|
|
var btoalab;
|
|
$.get(pathklaim, function (datarincian) {
|
|
btoarincian = datarincian
|
|
//Lab
|
|
$.get(pathlab, function (datalab) {
|
|
btoalab = datalab
|
|
|
|
$.get(pathsep, function (data) {
|
|
fetch('/pdfgenerator/pdfclaim', {
|
|
method: 'POST',
|
|
headers: {
|
|
Accept: 'arraybuffer',
|
|
'Content-Type': 'application/json',
|
|
},
|
|
//you need to use json here
|
|
body: JSON.stringify({ pathrincian: btoa(unescape(encodeURIComponent(btoarincian))), pathsep: btoa(unescape(encodeURIComponent(data))), pathlab: btoa(unescape(encodeURIComponent(btoalab))), noreg: noreg })
|
|
})
|
|
.then(response => response.blob())
|
|
.then(data => {
|
|
var popup = window.open(URL.createObjectURL(data), "_blank", "height=500,width=750");
|
|
$('#loading').hide();
|
|
});
|
|
});
|
|
});
|
|
}).done(e => {
|
|
|
|
}).fail(e => {
|
|
$('#loading').hide();
|
|
});
|
|
}
|