291 lines
8.9 KiB
JavaScript
291 lines
8.9 KiB
JavaScript
/***** GESTIONE MODIFICA E NUOVO CLIENTE TRAMITE MODAL ***/
|
|
/* V. 1.0
|
|
06-7-2021 */
|
|
/** vedere come è gestita su ab-document.js**/
|
|
/** ha bisogno di un mapping returnItems tra i campi del form di partenza e la modal che salva e modifica i dati */
|
|
|
|
|
|
/***** ROBA VECCHIA!!!!!*/
|
|
function nuovoCliforXX(RI) {
|
|
var f = document.main;
|
|
var CF = f.flgClienteFornitore.value;
|
|
clrField('main', 'id_clifor', 'descrizioneClifor');
|
|
//alert(RI);
|
|
if (CF == "F") {
|
|
theAction = webApp + "/admin/anag/Fornitore.abl?cmd=ni&sw=1&RI=" + RI;
|
|
wCliente = window.open(theAction, "Nuovo_Fornitore", "width=810,height=600,status=yes,resizable=yes,top=100,left=100,scrollbars=yes");
|
|
} else {
|
|
theAction = webApp + "/admin/anag/Cliente.abl?cmd=ni&sw=1&RI=" + RI;
|
|
wCliente = window.open(theAction, "Nuovo_Cliente", "width=840,height=600,status=yes,resizable=yes,top=100,left=100,scrollbars=yes");
|
|
}
|
|
//f.descrizioneCli.value="";
|
|
//f.id_clifor.value="";
|
|
wCliente.focus();
|
|
}
|
|
/***** ROBA VECCHIA!!!!!*/
|
|
function modifyCliforXX(RI) {
|
|
var f = document.main;
|
|
//alert(f.id_cliente.value);
|
|
if (f.id_clifor.value != "" && f.id_clifor.value != 0) {
|
|
var CF = f.flgClienteFornitore.value;
|
|
if (CF == "F") {
|
|
theAction = webApp + "/admin/anag/Fornitore.abl?cmd=md&sw=1&id_clifor=" + f.id_clifor.value + "&RI=" + RI;
|
|
wCliente = window.open(theAction, "Modifica_Fornitore", "width=810,height=600,status=yes,resizable=yes,top=100,left=100,scrollbars=yes");
|
|
} else {
|
|
theAction = webApp + "/admin/anag/Cliente.abl?cmd=md&sw=1&id_clifor=" + f.id_clifor.value + "&RI=" + RI;
|
|
wCliente = window.open(theAction, "Modifica_Cliente", "width=810,height=600,status=yes,resizable=yes,top=100,left=100,scrollbars=yes");
|
|
}
|
|
|
|
wCliente.focus();
|
|
}
|
|
}
|
|
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
/** NUOVO CLIENTE FORNITORE SU MODAL*/
|
|
/* vedi _inc_cliforE.jsp */
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
function newCli(form, retItems) {
|
|
$("#cliforRetForm").val(form);
|
|
$("#cliforRetItems").val(JSON.stringify(retItems));
|
|
|
|
Ab.fetch("../anag/Cliente.abl", "cmd=ni&sw=1", "cliforContainer", "postLoadClifor()", true);
|
|
}
|
|
|
|
function newFor(form, retItems) {
|
|
$("#cliforRetForm").val(form);
|
|
$("#cliforRetItems").val(JSON.stringify(retItems));
|
|
|
|
Ab.fetch("../anag/Fornitore.abl", "cmd=ni&sw=1", "cliforContainer", "postLoadClifor()", true);
|
|
}
|
|
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
/* MODIFICA CLIENTE SU MODAL */
|
|
/** carica i dati tramite una fetch e li mette nel div cliforContainer*/
|
|
/* vedi _inc_cliforE.jsp */
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
function modCli(form, retItems) {
|
|
|
|
var id = $("#id_clifor").val();
|
|
|
|
$("#cliforRetForm").val(form);
|
|
$("#cliforRetItems").val(JSON.stringify(retItems));
|
|
|
|
if (id != "") {
|
|
//sw=1 chiama la pagina cliforE.jsp che carico in cliforcontainer
|
|
Ab.fetch("../anag/Cliente.abl", "cmd=md&sw=1&id_clifor=" + id, "cliforContainer", "postLoadClifor()", true);
|
|
} else {
|
|
swal("Errore!", "Selezionare un cliente/fornitore!", "error");
|
|
}
|
|
}
|
|
function modFor(form, retItems) {
|
|
|
|
var id = $("#id_clifor").val();
|
|
|
|
$("#cliforRetForm").val(form);
|
|
$("#cliforRetItems").val(JSON.stringify(retItems));
|
|
|
|
if (id != "") {
|
|
//sw=1 chiama la pagina cliforE.jsp che carico in cliforcontainer
|
|
Ab.fetch("../anag/Fornitore.abl", "cmd=md&sw=1&id_clifor=" + id, "cliforContainer", "postLoadClifor()", true);
|
|
} else {
|
|
swal("Errore!", "Selezionare un cliente/fornitore!", "error");
|
|
}
|
|
}
|
|
/*** generica **/
|
|
function modClifor(form, retItems) {
|
|
|
|
var id = $("#id_clifor").val();
|
|
|
|
$("#cliforRetForm").val(form);
|
|
$("#cliforRetItems").val(JSON.stringify(retItems));
|
|
|
|
if (id != "" && id != 0) {
|
|
//sw=1 chiama la pagina cliforE.jsp che carico in cliforcontainer
|
|
Ab.fetch("../anag/Clifor.abl", "cmd=md&sw=1&id_clifor=" + id, "cliforContainer", "postLoadClifor()", true);
|
|
} else {
|
|
swal("Errore!", "Selezionare un cliente/fornitore!", "error");
|
|
}
|
|
}
|
|
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
/** SEMPLICEMENTE POPUP MODAL CON CLIENTE */
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
function postLoadClifor() {
|
|
$('#cliforModalDialog').modal("show");
|
|
}
|
|
|
|
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
/* Salvataggio nuovi dati tramite fetch */
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
function saveClifor() {
|
|
if (Ab.validateForm('cognome', 'Cognome / Ragione Sociale', 'R')) {
|
|
var campiClifor = $("#cliforModal").serialize();
|
|
|
|
Ab.fetch("../anag/Clifor.abl", "cmd=asq&act=save&sw=1&" + campiClifor, "cliforContainer", "postSave()");
|
|
}
|
|
}
|
|
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
/* Callback del salvataggio nuovi dati: legge i campi da caricare che sono stati inseriti (come json) nel campo cliforRetItems*/
|
|
/* come oggetti chiave (campo della form chiamante) / valore (campo della form nella modal dei clienti)*/
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
function postSave(response) {
|
|
var form = "#" + $("#cliforRetForm").val(),
|
|
retItems = JSON.parse($("#cliforRetItems").val());
|
|
|
|
for (var i = 0, len = retItems.length; i < len; i++) {
|
|
var item = retItems[i];
|
|
|
|
//console.log( item.formField + " - " + $("#"+item.formField, form).val() + " / " + item.modalField + " - " + $("#"+item.modalField, "#cliforModal").val() + " / " + $("#"+item.formField, form).prop('tagName'));
|
|
|
|
$("#" + item.formField, form).val($("#" + item.modalField, "#cliforModal").val());
|
|
}
|
|
|
|
$('#cliforModalDialog').modal('hide');
|
|
//richiamo se c'è postSaveCliforCaller
|
|
|
|
if(funcExists("postSaveCliforCaller")){
|
|
setTimeout(function () {
|
|
{
|
|
|
|
postSaveCliforCaller();
|
|
|
|
}
|
|
|
|
}, 300);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
function funcExists(fname)
|
|
{
|
|
return (typeof window[fname] === 'function');
|
|
}
|
|
|
|
|
|
|
|
function postClickICheckE() {
|
|
aziendaClickE();
|
|
}
|
|
|
|
function aziendaClickE() {
|
|
//checkBoxes();
|
|
|
|
//var rowNascita=Ab.prendiElementoDaId('nascita');
|
|
//var l_flgAzienda=Ab.prendiElementoDaId('flgAzienda').value;
|
|
//if(l_flgAzienda==1)
|
|
//alert($("#flgAzienda").val());
|
|
if ($("#flgAzienda").val() == 0) {
|
|
//rowNascita.style.display="none";
|
|
$("#nascitaRow").removeClass("hide");
|
|
$("#aziendaRow").addClass("hide");
|
|
} else {
|
|
//rowNascita.style.display="block";
|
|
$("#nascitaRow").addClass("hide");
|
|
$("#aziendaRow").removeClass("hide");
|
|
}
|
|
}
|
|
|
|
|
|
//postSubmitAj();
|
|
|
|
|
|
$(document).ready(function () {
|
|
|
|
//iCheck for checkbox and radio inputs
|
|
if ($('input[type="checkbox"].minimal, input[type="radio"].minimal')) {
|
|
$('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
|
|
checkboxClass: 'icheckbox_minimal-blue',
|
|
radioClass: 'iradio_minimal-blue',
|
|
focusClass: 'hover'
|
|
});
|
|
}
|
|
//Datemask dd/mm/yyyy
|
|
if ($(".datemask")) {
|
|
$(".datemask").inputmask( { alias: "datetime", inputFormat: "dd/mm/yyyy",
|
|
"placeholder": "gg/mm/aaaa"
|
|
});
|
|
}
|
|
//numero con 2 decimali (default)
|
|
if ($(".numberinput")) {
|
|
$(".numberinput").numeric({
|
|
decimalPlaces: 2,
|
|
decimal: ","
|
|
});
|
|
}
|
|
//numero intero
|
|
if ($(".numberinput0")) {
|
|
$(".numberinput0").numeric();
|
|
}
|
|
//time
|
|
if ($(".timemask")) {
|
|
$(".timemask").inputmask("h:s", {
|
|
"placeholder": "hh:mm"
|
|
});
|
|
}
|
|
//email mask
|
|
if ($(".emailmask")) {
|
|
$(".emailmask").inputmask({
|
|
mask: "*{1,20}[.*{1,20}][.*{1,20}][.*{1,20}]@*{1,20}[.*{2,6}][.*{1,2}]",
|
|
greedy: false,
|
|
onBeforePaste: function (pastedValue, opts) {
|
|
pastedValue = pastedValue.toLowerCase();
|
|
return pastedValue.replace("mailto:", "");
|
|
},
|
|
definitions: {
|
|
'*': {
|
|
validator: "[0-9A-Za-z!#$%&'*+/=?^_`{|}~\-]",
|
|
cardinality: 1,
|
|
casing: "lower"
|
|
}
|
|
}
|
|
});
|
|
}
|
|
//color picker
|
|
if ($(".colorpicker")) {
|
|
$(".colorpicker").colorpicker();
|
|
}
|
|
// GESTIONE CHECKBOXES
|
|
|
|
$(":checkbox").on("focus", null, null, function () {
|
|
if ($("#currentFocus"))
|
|
$("#currentFocus").val(this.id);
|
|
});
|
|
//
|
|
$(":checkbox").on("ifChanged", null, null, function () {
|
|
//dataChanged();
|
|
var name = $(this).attr("name").replace("ck", "");
|
|
// controllo lo stato della checkbox e valorizzo la input
|
|
if ($(this).is(":checked")) {
|
|
$("#" + name).val(1);
|
|
} else {
|
|
$("#" + name).val(0);
|
|
}
|
|
//eseguo l'onchange sul campo text corrispondente
|
|
//se funziona evito postClickICheck
|
|
|
|
$("#" + name).change();
|
|
|
|
/*if (typeof postClickICheckCR == 'function') {
|
|
postClickICheckCR(name);
|
|
}
|
|
*/
|
|
|
|
//if (postClickICheck)
|
|
// postClickICheck();
|
|
});
|
|
});
|