/*! * Start Bootstrap - Simple Sidebar v6.0.5 (https://startbootstrap.com/template/simple-sidebar) * Copyright 2013-2022 Start Bootstrap * Licensed under MIT (https://github.com/StartBootstrap/startbootstrap-simple-sidebar/blob/master/LICENSE) */ // // Scripts // let dollarUSLocale = Intl.NumberFormat('en-US', { style: "currency", currency: "USD", }); $(function() { $('body').css('visibility','visible'); $('.input-money-negative').inputNumberFormat({ 'allowNegative': true }); $('.input-money').inputNumberFormat(); $('.input-integer').inputNumberFormat({ 'decimal': 0 }); }); function mostrar_bs_tooltips(){ var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]')) var tooltipList = tooltipTriggerList.map(function (tooltipTriggerEl) { return new bootstrap.Tooltip(tooltipTriggerEl) }) } window.addEventListener('DOMContentLoaded', event => { // Toggle the side navigation const sidebarToggle = document.body.querySelector('#sidebarToggle'); if (sidebarToggle) { // Uncomment Below to persist sidebar toggle between refreshes // if (localStorage.getItem('sb|sidebar-toggle') === 'true') { // document.body.classList.toggle('sb-sidenav-toggled'); // } sidebarToggle.addEventListener('click', event => { event.preventDefault(); document.body.classList.toggle('sb-sidenav-toggled'); localStorage.setItem('sb|sidebar-toggle', document.body.classList.contains('sb-sidenav-toggled')); }); } }); function maneja_error_swalert(result) { if (typeof result === 'string' || result instanceof String){ if ((result.indexOf("error") != -1 || result.indexOf("
") != -1) && result.indexOf("errorMsg") == -1 ) { Swal.fire({ title: 'Error!', html: result, icon: 'error', allowOutsideClick: false, confirmButtonText: 'OK' }) return false; } else { var result = eval('(' + result + ')'); if (result.errorMsg) { Swal.fire({ title: 'Error!', html: result.errorMsg, icon: 'error', allowOutsideClick: false, confirmButtonText: 'OK' }) return false; } else { return true; } } } else { result = JSON.stringify(result); if ((result.indexOf("error") != -1 || result.indexOf("
") != -1) ) { Swal.fire({ title: 'Error!', html: result, icon: 'error', allowOutsideClick: false, confirmButtonText: 'OK' }) return false; } else { var result = eval('(' + result + ')'); if (result.errorMsg) { Swal.fire({ title: 'Error!', html: result.errorMsg, icon: 'error', allowOutsideClick: false, confirmButtonText: 'OK' }) return false; } else { return true; } } } } function idioma_msg(datos, texto) { if(typeof datos[texto] === "undefined"){ return texto; } else { return msg_usuario_valido = datos[texto]; } } function toast(icono, mensaje){ Swal.fire({ icon: icono, html: mensaje, toast: true, position: 'top-right', iconColor: 'white', customClass: { popup: 'colored-toast' }, showConfirmButton: false, timer: 2500, timerProgressBar: true }) } function cambiaridioma(actual){ if(actual=='es') { var lang = 'en'; } else { var lang = 'es'; } //cambio el lenguaje window.location.search= "?lang="+lang; } function seleccionar_select(lista,on_off){ if(on_off==1){ //selecciona todo $('#'+lista+' option').each(function () { $(this).prop('selected', true); }); } else { //deselecciona todo y marca el primero var primero=true; $('#'+lista+' option').each(function () { if(primero){ $(this).prop('selected', true); primero=false; } else { $(this).prop('selected', false); } }); } } function moneyFormatter(value, row) { var estilo = ''; if(value<0){ estilo = 'color: red;'; } return '
' + dollarUSLocale.format(value) + '
' } function moneyBoldFormatter(value, row) { return '
' + dollarUSLocale.format(value) + '
' } function moneyFormatter_destacado(value, row) { return '
' + dollarUSLocale.format(value) + '
' } function pendingFormatter(value, row) { var estilo = ''; if(value == 'YES'){ estilo = 'font-weight: bold; color: red;'; } else { estilo = 'font-weight: bold; color: green;'; } return '
' + value + '
' } function lineaFormatter(value, row) { var estilo = ''; switch (value) { case 'MCA': estilo = 'font-weight: bold; color: blue;'; break; default: estilo = 'font-weight: bold; color: BlueViolet;'; break; } return '
' + value + '
' } function statusFormatter(value, row) { var estilo = 'font-weight: bold; color: '+row.tecCOLOR+';'; /* switch (value) { case 'CLOSED': estilo = 'font-weight: bold; color: blue;'; break; case 'LEGAL': estilo = 'font-weight: bold; color: red;'; break; case 'ACTIVE': estilo = 'font-weight: bold; color: green;'; break; default: estilo = 'font-weight: bold; color: BlueViolet;'; break; } */ if(value == 'ACTIVE' && (row.DESCUENTO > 0 || row.Collected_percent == 100 )){ estilo = 'font-weight: bold; color: black; background-color: #f2e452'; } return '
' + value + '
' } function PYMNTstatusFormatter(value, row) { var estilo = 'font-weight: bold; color: '+row.teaCOLOR+';'; /* switch (value) { case 'PYMNT PLAN': case 'RECALC PYMNT PLAN': estilo = 'font-weight: bold; color: blue;'; break; case 'ACCOUNT CLOSED': case 'ACCOUNT FROZEN': case 'NON-PERFORMING': case 'SUSPENDED (NSF)': estilo = 'font-weight: bold; color: red;'; break; case 'PERFORMING': estilo = 'font-weight: bold; color: green;'; break; default: estilo = 'font-weight: bold; color: BlueViolet;'; break; } */ if(value == 'ACTIVE' && (row.DESCUENTO > 0 || row.Collected_percent == 100 )){ estilo = 'font-weight: bold; color: black; background-color: #f2e452'; } return '
' + value + '
' } function AMstatusFormatter(value, row) { var estilo = ''; switch (value) { case 'PERFORMING': estilo = 'font-weight: bold; color: green;'; break; /* case 'DEFAULTED': estilo = 'font-weight: bold; color: red;'; break; case 'DELAYED': estilo = 'font-weight: bold; color: orange;'; break; case 'REDUCED': estilo = 'font-weight: bold; color: blue;'; break; */ default: estilo = 'font-weight: bold; color: red;'; break; } return '
' + value + '
' } function QmoraFormatter(value, row) { var estilo = ''; switch (value==0) { case true: estilo = ''; break; default: switch (true) { case value - row.Q_PAYMENTS_TRANSIT > 3: estilo = 'font-weight: bold; color: red;'; break; default: estilo = 'font-weight: bold; color: green;'; break; } break; } if(value==0 || row.teaDESCRIPCION == 'PERFORMING'){ value = ''; } return '
' + value + '
' } function percentFormatter(value, row){ return '
' + Math.round((Number(value) + Number.EPSILON) * 100) / 100 + ' %
' } function swal_alert(mensaje){ Swal.fire({ title: 'Message', html: mensaje, icon: 'warning', allowOutsideClick: false, confirmButtonText: 'OK' }) } function swal_error(mensaje){ Swal.fire({ title: 'Error', html: mensaje, icon: 'error', allowOutsideClick: false, confirmButtonText: 'OK' }) } function round(num){ return Math.round((num + Number.EPSILON) * 100) / 100 } function formatInvestors(investor){ if (!investor.id) { return investor.text; } //if (!investor.available) { return investor.text; } //console.log(investor); var color = ''; if(investor.id=='ID'){ color = 'bg-secondary text-white'; } else { if(investor.index % 2 !== 0){ color = 'bg-secondary bg-opacity-25'; } else { color = 'bg-primary bg-opacity-25'; } } var columnas = '
'; columnas = columnas + '
' + investor.id + '
'; columnas = columnas + '
' + investor.text + '
'; columnas = columnas + '
' + investor.contacto + '
'; /* columnas = columnas + '
'+ investor.days + '
'; columnas = columnas + '
'+ investor.roi + '
'; columnas = columnas + '
'+ investor.funded + '
'; columnas = columnas + '
'+ investor.invested + '
'; columnas = columnas + '
'+ investor.wat + '
'; columnas = columnas + '
'+ investor.delincuency + '
'; */ columnas = columnas + '
'; var format_inv = $(columnas); return format_inv; } function round(num, decimales){ return Number(num.toFixed(decimales)); } function columns_order(tbl_id){ var columnas = '
'; columnas+= '
'; columnas+= '
'; columnas+= '
'; columnas+= '
    '; $('#'+tbl_id+' thead th .th-inner').each(function(i, obj) { if(i>0){ //Primer columna i=0 son los botones de orden de columnas y de selección de columnas var texto = $(this).html(); // saco
    while (texto.includes('
    ') || texto.includes('
    ')) { texto = texto.replace('
    ',''); texto = texto.replace('
    ',''); } //console.log(texto); var campo = $(this).parent().data('field'); //console.log(campo); order_button_up = ''; order_button_down = ''; columnas+= '
  • '+order_button_up+texto+order_button_down+'
  • '; } }); columnas+= '
'; columnas+= '
'; columnas+= '
'; columnas+= '
'; columnas+= '
'; Swal.fire({ title: 'Columns Order', html: columnas, allowOutsideClick: false, showDenyButton: true, keydownListenerCapture: true, heightAuto: false, confirmButtonText: 'Order', denyButtonText: 'Cancel', customClass: 'swal-columns-order-height', }).then((result) => { if (result.isConfirmed) { //$("#overlay").show(); /* armo el orden de las columnas */ var columnas_ordenadas = []; columnas_ordenadas.push("0"); $('#'+tbl_id+'_columns_order li span').each(function(i, li_obj) { column = $(this).html(); orden = i+1; //console.log(orden+' '+column); columnas_ordenadas.push(column); }); //console.log(JSON.stringify(columnas_ordenadas)); $.post('/php/grid.state.php', { crud:'column-order-save', grid: 'mca', columnorder: columnas_ordenadas } , function(result) { $("#overlay").hide(); if (result.success) { //recargo página toast('success', 'Columns Order modified !!!'); location.reload(); } else { Swal.fire({ title: 'Error!', html: 'Error !!!

'+result.errorMsg, icon: 'error', allowOutsideClick: false, keydownListenerCapture: true, heightAuto: false, confirmButtonText: 'OK' }); } }, 'json').fail(function(xhr, textStatus, errorThrown) { $("#overlay").hide(); Swal.fire({ title: 'Error!', html: xhr.responseText + textStatus + errorThrown, icon: 'error', allowOutsideClick: false, keydownListenerCapture: true, heightAuto: false, confirmButtonText: 'OK' }); }); } }); } function column_order_up_down(this_li, up_down){ if(up_down==-1){ var $current = $(this_li).closest('li') var $previous = $current.prev('li'); if($previous.length !== 0){ $current.insertBefore($previous); } } else { var $current = $(this_li).closest('li') var $next = $current.next('li'); if($next.length !== 0){ $current.insertAfter($next); } } $(this_li).parent().parent().children().each(function () { //console.log($(this)); $(this).css("background-color","white"); $(this).css("color","black"); }); $current.css("background-color","black"); $current.css("color","white"); } function round(num, decimales){ return Number(num.toFixed(decimales)); } function espacios_select(select_id){ //console.log(select_id+'\n'); $("#"+select_id+" > option").each(function(){ var parts = $(this).text().split(' - '); var strLength = parts[0].length; var padLength = 35; for(var x=0; x<(padLength-strLength); x++){ parts[0] = parts[0]+' '; } var strLength = parts[1].length; var padLength = 10; for(var x=0; x<(padLength-strLength); x++){ parts[1] = ' '+parts[1]; } var strLength = parts[2].length; var padLength = 12; for(var x=0; x<(padLength-strLength); x++){ parts[2] = ' '+parts[2]; } var strLength = parts[3].length; var padLength = 12; for(var x=0; x<(padLength-strLength); x++){ parts[3] = ' '+parts[3]; } var strLength = parts[4].length; var padLength = 16; for(var x=0; x<(padLength-strLength); x++){ parts[4] = ' '+parts[4]; } var strLength = parts[5].length; var padLength = 16; for(var x=0; x<(padLength-strLength); x++){ parts[5] = ' '+parts[5]; } var strLength = parts[6].length; var padLength = 16; for(var x=0; x<(padLength-strLength); x++){ parts[6] = ' '+parts[6]; } $(this).text(parts[0].replace(/ /g, '\u00a0').substring(0,35)+' '+parts[1].replace(/ /g, '\u00a0')+' '+parts[2].replace(/ /g, '\u00a0')+' '+parts[3].replace(/ /g, '\u00a0')+' '+parts[4].replace(/ /g, '\u00a0')+' '+parts[5].replace(/ /g, '\u00a0')+' '+parts[6].replace(/ /g, '\u00a0')); }); } function money(value) { return dollarUSLocale.format(value); }