404 lines
12 KiB
JavaScript
Vendored
404 lines
12 KiB
JavaScript
Vendored
// Currency Separator
|
|
var commaCounter = 10;
|
|
|
|
function numberSeparator(Number) {
|
|
Number += '';
|
|
|
|
for (var i = 0; i < commaCounter; i++) {
|
|
Number = Number.replace(',', '');
|
|
}
|
|
|
|
x = Number.split('.');
|
|
y = x[0];
|
|
z = x.length > 1 ? '.' + x[1] : '';
|
|
var rgx = /(\d+)(\d{3})/;
|
|
|
|
while (rgx.test(y)) {
|
|
y = y.replace(rgx, '$1' + ',' + '$2');
|
|
}
|
|
commaCounter++;
|
|
return y + z;
|
|
}
|
|
|
|
function setIndoDate(n){
|
|
if (n){
|
|
arrDate = n.split("-");
|
|
return arrDate[2] + "/" + arrDate[1] + "/" + arrDate[0];
|
|
}else{
|
|
return "";
|
|
}
|
|
}
|
|
|
|
function setIndoDateOracle(n){
|
|
if (n){
|
|
arrDateSpace = n.split(" ");
|
|
arrDate = arrDateSpace[0].split("-");
|
|
return arrDate[2] + "/" + arrDate[1] + "/" + arrDate[0];
|
|
}else{
|
|
return "-";
|
|
}
|
|
}
|
|
|
|
// Set Currency Separator to input fields
|
|
$(document).on('keypress , paste', '.number-separator', function (e) {
|
|
if (/^-?\d*[,.]?(\d{0,3},)*(\d{3},)?\d{0,3}$/.test(e.key)) {
|
|
$('.number-separator').on('input', function () {
|
|
e.target.value = numberSeparator(e.target.value);
|
|
});
|
|
} else {
|
|
e.preventDefault();
|
|
return false;
|
|
}
|
|
});
|
|
|
|
function setDatePicker(input){
|
|
$(input).datetimepicker({
|
|
format: "DD/MM/YYYY",
|
|
useCurrent: false
|
|
})
|
|
}
|
|
|
|
function setDateRangePicker(input1, input2){
|
|
$(input1).datetimepicker({
|
|
format: "DD/MM/YYYY",
|
|
useCurrent: false
|
|
})
|
|
$(input1).on("change.datetimepicker", function (e) {
|
|
$(input2).val("")
|
|
$(input2).datetimepicker('minDate', e.date);
|
|
})
|
|
$(input2).datetimepicker({
|
|
format: "DD/MM/YYYY",
|
|
useCurrent: false
|
|
})
|
|
}
|
|
|
|
function setMonthPicker(input){
|
|
$(input).datetimepicker({
|
|
format: "MM",
|
|
useCurrent: false,
|
|
viewMode: "months"
|
|
})
|
|
}
|
|
|
|
function setYearPicker(input){
|
|
$(input).datetimepicker({
|
|
format: "YYYY",
|
|
useCurrent: false,
|
|
viewMode: "years"
|
|
})
|
|
}
|
|
|
|
function setYearRangePicker(input1, input2){
|
|
$(input1).datetimepicker({
|
|
format: "YYYY",
|
|
useCurrent: false,
|
|
viewMode: "years"
|
|
})
|
|
$(input1).on("change.datetimepicker", function (e) {
|
|
$(input2).val("")
|
|
$(input2).datetimepicker('minDate', e.date);
|
|
})
|
|
$(input2).datetimepicker({
|
|
format: "YYYY",
|
|
useCurrent: false,
|
|
viewMode: "years"
|
|
})
|
|
}
|
|
|
|
$('body').on('focus',".indo_date", function(){
|
|
$(this).daterangepicker({
|
|
singleDatePicker: true,
|
|
showDropdowns: true,
|
|
minYear: 1990,
|
|
locale: {
|
|
format: 'DD/MM/YYYY'
|
|
},
|
|
drops: "down",
|
|
autoApply: true,
|
|
});
|
|
|
|
$(this).on("keypress",function(){
|
|
return false;
|
|
})
|
|
});
|
|
|
|
$("body").on('keyup', ".number-separator-indo", function(){
|
|
var n = parseFloat($(this).val().replace(/\D/g,''),10);
|
|
$(this).val(new Intl.NumberFormat('id-ID').format(n));
|
|
});
|
|
|
|
var replaceValue = (n) =>{
|
|
n = n == "" ? "0" : n;
|
|
return parseFloat(n.replace(/\D/g,''),10);
|
|
}
|
|
|
|
function separateNumberIndo(n){
|
|
return new Intl.NumberFormat('id-ID').format(n)
|
|
}
|
|
|
|
calculate = () =>{
|
|
let gajiPokok = replaceValue($("#rincian_gaji_pokok").val());
|
|
let tunjangan_suami_istri = replaceValue($("#rincian_tunjangan_suami_istri").val());
|
|
let tunjangan_anak = replaceValue($("#rincian_tunjangan_anak").val());
|
|
let tunjangan_lain = replaceValue($("#rincian_tunjangan_lain").val());
|
|
let tunjangan_jabatan = replaceValue($("#rincian_tunjangan_jabatan").val());
|
|
let tunjangan_beras = replaceValue($("#rincian_tunjangan_beras").val());
|
|
let tunjangan_pph = replaceValue($("#rincian_tunjangan_pph").val());
|
|
let pembulatan = replaceValue($("#rincian_pembulatan").val());
|
|
let potongan_beras = replaceValue($("#rincian_potongan_beras").val());
|
|
let potongan_iuran_pfk = replaceValue($("#rincian_potongan_iuran_pfk").val());
|
|
let potongan_pph = replaceValue($("#rincian_potongan_pph").val());
|
|
let potongan_lain = replaceValue($("#rincian_potongan_lain").val());
|
|
// console.log(gajiPokok);
|
|
let totGajiKotor = gajiPokok + tunjangan_suami_istri + tunjangan_anak + tunjangan_lain + tunjangan_jabatan + tunjangan_beras + tunjangan_pph + pembulatan;
|
|
let totPotongan = potongan_beras + potongan_iuran_pfk + potongan_pph + potongan_lain;
|
|
let totGajiBersih = totGajiKotor - totPotongan;
|
|
// console.log(totGajiBersih);
|
|
$("#rincian_total_potongan").val(separateNumberIndo(totPotongan));
|
|
$("#rincian_total_gaji_kotor").val(separateNumberIndo(totGajiKotor));
|
|
$("#rincian_total_gaji_bersih").val(separateNumberIndo(totGajiBersih));
|
|
}
|
|
|
|
$(document).on("change", ".calculate_field", function(){
|
|
calculate();
|
|
});
|
|
|
|
calculateDebt = () =>{
|
|
let total = 0;
|
|
if ($(".calculate_field_debt").length == 0){
|
|
$("#rincian_utang_total").val(0);
|
|
$("#rincian_utang_angsur").val(0);
|
|
$("#sisa_utang").val(0);
|
|
$(".uraian_debt").prop("required", false);
|
|
}else{
|
|
$(".calculate_field_debt").each(function(i,x){
|
|
let val = $($(".calculate_field_debt")[i]).val();
|
|
total += replaceValue(val);
|
|
});
|
|
|
|
$("#rincian_utang_total").val(separateNumberIndo(total));
|
|
|
|
let totalUtang = replaceValue($("#rincian_utang_total").val());
|
|
let totalAngsur = replaceValue($("#rincian_utang_angsur").val());
|
|
$("#sisa_utang").val(separateNumberIndo(totalUtang - totalAngsur));
|
|
if (total > 0){
|
|
$(".uraian_debt").prop("required", true);
|
|
}
|
|
}
|
|
}
|
|
|
|
$(document).on("change", ".calculate_field_debt", function(){
|
|
calculateDebt();
|
|
});
|
|
|
|
|
|
$('.skpd_search').select2({
|
|
placeholder: 'Pilih SKPD',
|
|
ajax: {
|
|
url: '/skpd-search',
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
return {
|
|
results: $.map(data, function (item) {
|
|
return {
|
|
text: item.name,
|
|
id: item.id
|
|
}
|
|
})
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
});
|
|
|
|
$('.prog_search').select2({
|
|
placeholder: 'Pilih Program',
|
|
ajax: {
|
|
url: '/item-search-prog',
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
return {
|
|
results: $.map(data, function (item) {
|
|
return {
|
|
text: item.name,
|
|
id: item.id
|
|
}
|
|
})
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
});
|
|
|
|
$('.keg_search').select2({
|
|
placeholder: 'Pilih Kegiatan',
|
|
ajax: {
|
|
url: '/item-search-keg',
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
return {
|
|
results: $.map(data, function (item) {
|
|
return {
|
|
text: item.name,
|
|
id: item.id
|
|
}
|
|
})
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
});
|
|
|
|
$('.sk_search').select2({
|
|
placeholder: 'Pilih Sub Kegiatan',
|
|
ajax: {
|
|
url: '/item-search-sk',
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
return {
|
|
results: $.map(data, function (item) {
|
|
return {
|
|
text: item.name,
|
|
id: item.id
|
|
}
|
|
})
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
});
|
|
|
|
$('.rsk_search').select2({
|
|
placeholder: 'Pilih Rinci Sub Kegiatan',
|
|
ajax: {
|
|
url: '/item-search-rsk',
|
|
dataType: 'json',
|
|
delay: 250,
|
|
processResults: function (data) {
|
|
return {
|
|
results: $.map(data, function (item) {
|
|
return {
|
|
text: item.name,
|
|
id: item.id
|
|
}
|
|
})
|
|
};
|
|
},
|
|
cache: true
|
|
}
|
|
});
|
|
|
|
$(document).on("click",".modalButton",function (e){
|
|
$("#overlayLoader").removeClass("d-flex");
|
|
$("#overlayLoader").addClass("d-flex");
|
|
$('.modal-body').html("<table class='table table-striped' width='100%'><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr><tr><td></td></tr></table>");
|
|
$(".modal-dialog").removeClass("modal-xl modal-lg")
|
|
$(".modal-dialog").addClass($(this).attr("modal-target"));
|
|
$('#modal-default')
|
|
.modal('show')
|
|
.find('.modal-body')
|
|
.load($(this).attr('href'),function(){
|
|
$("#overlayLoader").removeClass("d-flex");
|
|
$("#overlayLoader").hide();
|
|
});
|
|
if ($(this).attr('title')!== null) {
|
|
$('.modal-title').html($(this).attr('title'));
|
|
}
|
|
if ($(this).attr('size')!== null){
|
|
$('.modal-dialog').addClass($(this).attr('size'));
|
|
}
|
|
e.preventDefault();
|
|
});
|
|
|
|
$(document).on("submit",".form-delete",function (e){
|
|
e.preventDefault();
|
|
let test = Swal.fire({
|
|
title: 'Data akan dihapus?',
|
|
showDenyButton: true,
|
|
showCancelButton: false,
|
|
confirmButtonText: 'Ya',
|
|
denyButtonText: "Tidak",
|
|
icon: "warning",
|
|
}).then((result) => {
|
|
/* Read more about isConfirmed, isDenied below */
|
|
if (result.isConfirmed) {
|
|
e.currentTarget.submit();
|
|
}
|
|
})
|
|
});
|
|
|
|
var url = window.location;
|
|
url = url + "";
|
|
const allLinks = document.querySelectorAll('.nav-item a');
|
|
// const currentLink = [...allLinks].filter(e => {
|
|
// return url.indexOf(e.href) > -1) {
|
|
// return e.href == url;
|
|
// }
|
|
// });
|
|
let currentLink = "";
|
|
allLinks.forEach((val, idx) => {
|
|
if (url.indexOf(val.href) > -1){
|
|
currentLink = val;
|
|
}
|
|
})
|
|
|
|
$(currentLink).addClass("active")
|
|
$(".has-treeview").removeClass("menu-open active");
|
|
$(currentLink).closest(".has-treeview").addClass("menu-open active");
|
|
$($(currentLink).closest(".has-treeview")).children("a.nav-link").addClass("active");
|
|
$($(currentLink).closest(".nav-treeview")).closest("li.nav-item").addClass("menu-open");
|
|
$($(currentLink).closest(".nav-treeview")).parentsUntil(".nav-sidebar > .nav-treeview").addClass('menu-open');
|
|
$("#span_count_notif").hide();
|
|
refreshNotif = ()=>{
|
|
$.ajax({
|
|
url: "/notif/get-notif",
|
|
headers: { 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content') },
|
|
type: "json",
|
|
method: "POST",
|
|
success: function(data){
|
|
$("#span_count_notif").hide();
|
|
if (data.length>0){
|
|
$("#span_count_notif").html(data.length);
|
|
$("#span_count_notif").show();
|
|
$listElm = "";
|
|
$.each(data, function(x,y){
|
|
$listElm = `<a href="`+y.url+`" class="dropdown-item">
|
|
<div class="media">
|
|
<div class="media-body">
|
|
<h3 class="dropdown-item-title"><strong>`+ y.jenis +`</strong>
|
|
<span class="float-right text-sm text-danger"></span>
|
|
</h3>
|
|
<p class="text-sm">`+y.message+`</p>
|
|
</div>
|
|
</div>
|
|
</a>
|
|
<div class="dropdown-divider"></div>`;
|
|
});
|
|
$listElm += `<a href="/notif" class="dropdown-item dropdown-footer">Lihat semua Notifikasi</a>`;
|
|
$("#list_notif").html($listElm);
|
|
}
|
|
}
|
|
})
|
|
}
|
|
refreshNotif();
|
|
|
|
$.extend( $.fn.dataTable.ext.classes, {
|
|
sProcessing: "dataTables_processing",
|
|
});
|
|
|
|
$(window).resize(function(){
|
|
$($.fn.dataTable.tables(true)).DataTable().columns.adjust();
|
|
});
|
|
|
|
$(window).on("#barButton", "click",()=>{
|
|
$(window).resize();
|
|
$($.fn.dataTable.tables(true)).DataTable().columns.adjust();
|
|
$.fn.dataTable
|
|
.tables( { visible: true, api: true } )
|
|
.columns.adjust();
|
|
}); |