207 lines
7 KiB
JavaScript
207 lines
7 KiB
JavaScript
/***** GESTIONE MODIFICA E NUOVO CLIENTE TRAMITE MODAL ***/
|
|
/* V. 2.0
|
|
15-7-2021 corretto datemask... tolto tutto quello dopo postsubmitaj. secondo me non serve ma devo capire quando facciamo la fetch
|
|
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");
|
|
postSubmitAj();
|
|
}
|
|
|
|
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
/* Salvataggio nuovi dati tramite fetch */
|
|
/***************************************************************/
|
|
/***************************************************************/
|
|
function saveClifor() {
|
|
debugger;
|
|
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();
|