var xmlHTTPrequestArticoliOrdiniSysint = [];
async function modificaPrezzoLogistica(codart, idRigaOrdine, codiceCliente) {
var parametri = new URLSearchParams();
parametri.append("azione", "mostraFormModificaPrezzoLogistica");
parametri.append("codart", codart);
parametri.append("idRigaOrdine", idRigaOrdine);
parametri.append("codiceCliente", codiceCliente);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.json())
.then(data => {
if (data.error === "no") {
mostraModalPersonalizzazionePrezzoLogistica(data.data);
} else {
alert(data.message);
}
})
.catch(error => {
alert("Errore nella richiesta. " + error);
})
.finally(() => {
});
}
function azzeraQuantitaArticoloSpecificoInGiro(codart, idGiro){
if(!confirm("Vuoi azzerare questa quantita?")){
return;
}
var parametri = new URLSearchParams();
parametri.append("azione", "azzeraQuantitaArticoloSpecificoInGiro");
parametri.append("codart", codart);
parametri.append("idGiro", idGiro);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => {
if (!response.ok) {
// Controllo se il server ha restituito un errore
if (response.status === 500) {
console.error('Errore del server (500): ', response);
} else {
console.error('Errore HTTP:', response.status);
}
return; // Esci senza processare il risultato
}
return response.json(); // Elabora il risultato solo se la risposta è OK
})
.then(data => {
if (data.error === "no") {
alert("Articolo correttamente azzerato.");
const contenitore = document.getElementById(`codiceart${codart}_0`);
if(contenitore){
contenitore.style = "text-decoration: line-through;";
}
} else {
alert(data.message);
}
})
.catch(error => {
//alert("Errore nella richiesta. " + error);
console.error("Errore nella richiesta. " + error);
})
}
function assegnaOrdineADeposito(idDeposito, idOrdineSysint){
var parametri = new URLSearchParams();
parametri.append("azione", "assegnaOrdineAdAltroDeposito");
parametri.append("idOrdineSysint", idOrdineSysint);
parametri.append("idDeposito", idDeposito);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.json())
.then(data => {
if (data.error === "no") {
mostra_popup_resp(data.message);
ricarica_ordine_in_lista(idOrdineSysint, "");
} else {
alert(data.message);
}
})
.catch(error => {
alert("Errore nella richiesta. " + error);
})
.finally(() => {
});
}
function mostraFormAssegnazioneOrdineAdAltroDeposito(idOrdineSysint){
var parametri = new URLSearchParams();
parametri.append("azione", "mostraFormAssegnazioneOrdineAdAltroDeposito");
parametri.append("idOrdineSysint", idOrdineSysint);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.json())
.then(data => {
if (data.error === "no") {
mostra_popup_resp(data.message);
} else {
alert(data.message);
}
})
.catch(error => {
alert("Errore nella richiesta. " + error);
})
.finally(() => {
});
}
function eliminaAzioneMarketingSmaltimentoScorte(idAzione){
if(!confirm("Vuoi davvero eliminare questa azione?")) {
return false;
}
if(idAzione === ""){
alert("Errore nel passaggio dei dati. Riprova.");
return false;
}
var parametri = new URLSearchParams();
parametri.append("azione", "eliminaAzioneVenditaArticoliGiacenti");
parametri.append("idAzione", idAzione);
const queryString = parametri.toString();
const url = "API-productsArchivioCompleto";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => {
return response.text();
})
.then(html => {
creaPopup("eliminazioneAzione" + idAzione, html);
const articoli = document.querySelector('div.azioneSmaltimento[data-id="'+idAzione+'"]');
const parentElement = articoli.parentNode;
parentElement.removeChild(articoli);
})
.catch(error => {
alert("Errore nella richiesta. " + error);
});
}
function confermaInserimentoAzioneVenditaArticoliGiacenti(action){
var productIdAzioneSmaltimento = document.getElementById("productIdAzioneSmaltimento").value;
var titoloAzioneSmaltimento = document.getElementById("titoloAzioneSmaltimento").value;
var venditaOnlineAzioneSmaltimento = document.getElementById("venditaOnlineAzioneSmaltimento").checked;
var venditaReteAzioneSmaltimento = document.getElementById("venditaReteAzioneSmaltimento").checked;
var descrizioneAzioneSmaltimento = document.getElementById("descrizioneAzioneSmaltimento").value;
var dataAnalisiAzioneSmaltimento = document.getElementById("dataAnalisiAzioneSmaltimento").value;
var actionId = document.getElementById("actionId").value;
if( productIdAzioneSmaltimento === "" ) {
return false;
}
if (venditaOnlineAzioneSmaltimento === false && venditaReteAzioneSmaltimento === false){
alert("Seleziona almeno un canale di vendita.");
return false;
}
if (titoloAzioneSmaltimento === "" || descrizioneAzioneSmaltimento === "" || dataAnalisiAzioneSmaltimento === "") {
alert("Inserisci i campi richiesti.");
return false;
}
const selectedDate = new Date(dataAnalisiAzioneSmaltimento);
const today = new Date();
// Imposta l'ora di oggi a mezzanotte
today.setHours(0, 0, 0, 0);
// Imposta il timestamp di domani
const domani = new Date(today);
domani.setDate(today.getDate() + 1);
// Controlla se la data selezionata è prima di domani
if (selectedDate < domani) {
alert("devi impostare una data che sia almeno domani.");
return false;
}
const url = "API-productsArchivioCompleto";
const params = new URLSearchParams();
params.append("azione", "memorizzaAzioneMarketingSmaltimentoScorte");
params.append("action", action);
params.append("actionId", actionId);
params.append("productIdAzioneSmaltimento", productIdAzioneSmaltimento);
params.append("titoloAzioneSmaltimento", titoloAzioneSmaltimento);
params.append("venditaOnlineAzioneSmaltimento", venditaOnlineAzioneSmaltimento);
params.append("venditaReteAzioneSmaltimento", venditaReteAzioneSmaltimento);
params.append("descrizioneAzioneSmaltimento", descrizioneAzioneSmaltimento);
params.append("dataAnalisiAzioneSmaltimento", dataAnalisiAzioneSmaltimento);
const queryString = params.toString();
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => {
return response.text();
})
.then(html => {
document.getElementById("popup_resp_TESTO").innerHTML=html;
document.getElementById("ulterioriInfoAzioniMarketing"+productIdAzioneSmaltimento).innerHTML = "";
getElencoAzioniMarketingSmaltimentoScorte(productIdAzioneSmaltimento);
})
.catch(error => {
alert("Errore nella richiesta. " + error);
});
}
function mostraFormImpostaAzioneMarketingSmaltimentoGiacenze(productsId, azioneId){
if(azioneId === undefined){
azioneId = "";
}
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestCliProducts=new XMLHttpRequest();
}
else { // code for IE6, IE5
xmlHTTPrequestCliProducts=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestCliProducts.onreadystatechange=function() {
if (xmlHTTPrequestCliProducts.readyState === 4 && xmlHTTPrequestCliProducts.status === 200) {
var div = document.getElementById("popup_resp_TESTO");
div.innerHTML=xmlHTTPrequestCliProducts.responseText.trim();
// Eseguiamo gli script
var scripts = div.querySelectorAll('script');
scripts.forEach(function(script) {
var newScript = document.createElement('script');
newScript.text = script.text;
document.head.appendChild(newScript);
});
}
};
parametri = 'azione=mostraFormImpostaAzioneMarketingSmaltimentoGiacenze';
parametri += '&productsId=' + productsId;
parametri += '&azioneId=' + azioneId;
xmlHTTPrequestCliProducts.open("POST","API-productsArchivioCompleto",true);
xmlHTTPrequestCliProducts.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHTTPrequestCliProducts.send(parametri);
$("div#oscuramento_nero").css("display","block");
}
function sostituisciArticoloObsoletoAdArtNormaleInLogistica(sostituzioneObj){
//alert("Aggiungi l'articolo direttamente in GEORDC e poi fai la sincronizzazione");
//return;
/*
$parametriSostituzione = [
"codiceOrdine" => $this->getId(),
"articoloNormaleDaSostituire" => $resart[1],
"articoloObsoletoInSostituzione" => $value->getArticoloObsoletoAlternativo(),
"quantita" => $resart[3],
"prezzoProposto" => $value->getPrezzo(),
];
*/
const { codiceOrdine, articoloNormaleDaSostituire, articoloObsoletoInSostituzione, quantita, prezzoProposto, giro, idRigaArticolo } = sostituzioneObj;
if(!confirm("Sostituzione di " + articoloNormaleDaSostituire + " con " + articoloObsoletoInSostituzione + ". Confermi?")){
return false;
}
const url = "API-gestione-ordini-logistica.php";
const params = new URLSearchParams();
params.append("azione", "elimina_articolo_in_ordine");
params.append("id_articolo", idRigaArticolo);
params.append("id_ordine", codiceOrdine);
const queryString = params.toString();
// Invia la richiesta POST
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => {
return response.text();
})
.then(html => {
//aggiungiamo il nuovo articolo
const urlAggiunta = "funzioni_aggiungi_articolo_ad_ordine_ajax.php";
const paramsAggiunta = new URLSearchParams();
paramsAggiunta.append("quantita_codbar", quantita);
paramsAggiunta.append("quantita_art_Sel_in_arrivo", 0);
paramsAggiunta.append("merce_in_arrivo", 1);
paramsAggiunta.append("giro", giro);
paramsAggiunta.append("id_ordine", codiceOrdine);
paramsAggiunta.append("ARTICOLO_IN_AGGIUNTA", 1);
paramsAggiunta.append("id_ordine_aperto", codiceOrdine);
paramsAggiunta.append("codice_art_VECCHIO", articoloObsoletoInSostituzione);
paramsAggiunta.append("aggiuntaDaProceduraPerObsoleti", articoloNormaleDaSostituire);
const queryStringAggiunta = paramsAggiunta.toString();
fetch(urlAggiunta, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryStringAggiunta
})
.then(response => {
return response.text();
})
.then(html => {
ricarica_ordine_in_lista(codiceOrdine, "");
alert("Ricordati di fare le modifiche in Sysint!");
})
.catch(error => {
alert("Errore nella richiesta. " + error);
});
})
.catch(error => {
alert("Errore nella richiesta. " + error);
});
}
function mostraClientiCheAcquistanoUnProdottoInUnDatoMese(productsId, mese, anno, idDepositoSysintDaConsiderareJSON = "")
{
if (idDepositoSysintDaConsiderareJSON === undefined) {
idDepositoSysintDaConsiderareJSON = "";
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestCliProducts=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequestCliProducts=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestCliProducts.onreadystatechange=function() {
if (xmlHTTPrequestCliProducts.readyState === 4 && xmlHTTPrequestCliProducts.status === 200) {
creaPopup("clientiAcquistatoInUnMese", xmlHTTPrequestCliProducts.responseText.trim());
}
}
parametri = 'azione=2';
parametri += '&productsId=' + productsId;
parametri += '&mese=' + mese;
parametri += '&anno=' + anno;
parametri += '&idDepositoSysintDaConsiderareJSON=' + idDepositoSysintDaConsiderareJSON;
xmlHTTPrequestCliProducts.open("POST","API-productsArchivioCompleto",true);
xmlHTTPrequestCliProducts.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHTTPrequestCliProducts.send(parametri);
}
function scegliArticoloInSostituzionePerSmaltimentoGiacenze(productsId){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestCliProducts=new XMLHttpRequest();
}
else { // code for IE6, IE5
xmlHTTPrequestCliProducts=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestCliProducts.onreadystatechange=function() {
if (xmlHTTPrequestCliProducts.readyState === 4 && xmlHTTPrequestCliProducts.status === 200) {
var div = document.getElementById("popup_resp_TESTO");
div.innerHTML=xmlHTTPrequestCliProducts.responseText.trim();
// Eseguiamo gli script
var scripts = div.querySelectorAll('script');
scripts.forEach(function(script) {
var newScript = document.createElement('script');
newScript.text = script.text;
document.head.appendChild(newScript);
});
}
}
parametri = 'azione=scegliArticoloInSostituzionePerSmaltimentoGiacenze';
parametri += '&productsId=' + productsId;
xmlHTTPrequestCliProducts.open("POST","API-productsArchivioCompleto",true);
xmlHTTPrequestCliProducts.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xmlHTTPrequestCliProducts.send(parametri);
$("div#oscuramento_nero").css("display","block");
}
function mostraStoriaProdottoInTuttiIDepositi(productId, idDepositoSysintDaConsiderareJSON = ""){
if (idDepositoSysintDaConsiderareJSON === undefined) {
idDepositoSysintDaConsiderareJSON = "";
}
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestGiacenzeMaga = new XMLHttpRequest();
}
else {
// code for IE6, IE5
xmlHTTPrequestGiacenzeMaga = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestGiacenzeMaga.onreadystatechange = function() {
if (xmlHTTPrequestGiacenzeMaga.readyState==4 && xmlHTTPrequestGiacenzeMaga.status==200) {
var div = document.getElementById("popup_resp_TESTO");
div.innerHTML=xmlHTTPrequestGiacenzeMaga.responseText;
// Eseguiamo gli script
var scripts = div.querySelectorAll('script');
scripts.forEach(function(script) {
var newScript = document.createElement('script');
newScript.text = script.text;
document.head.appendChild(newScript);
});
}
}
/*
xmlHTTPrequestGiacenzeMaga.onload = () => {
if (xmlHTTPrequestGiacenzeMaga.status === 200) {
// La risposta è pronta
const risposta = xmlHTTPrequestGiacenzeMaga.responseText;
// Inserisci la risposta nel DOM
document.getElementById('popup_resp_TESTO').innerHTML = risposta;
} else {
console.error('Si è verificato un errore:', xmlHTTPrequestGiacenzeMaga.statusText);
}
};
*/
xmlHTTPrequestGiacenzeMaga.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequestGiacenzeMaga.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=mostraStoriaProdottoInTuttiIMagazzini";
parametri += "&productId="+ productId;
parametri += '&idDepositoSysintDaConsiderareJSON=' + idDepositoSysintDaConsiderareJSON;
xmlHTTPrequestGiacenzeMaga.send(parametri);
//$("div#oscuramento").css("display","block");
}
function selezionaDepositoArticoliLentaRotazione(actionRequest, idMagazzinoSysintValue, idMagazzinoSysintChecked) {
//quando l'actionRequest è show, non importano gli altri due parametri, perchè è solo visualizzazione
//quando invece actionRequest è qualsiasi altro valore, allora siamo in modifica
//document.getElementById("oscuramento_nero").style.display="block";
//document.getElementById("popup_resp").style.display="block";
//document.getElementById("popup_resp_TESTO").style.display="block";
//document.getElementById("popup_resp_TESTO").innerHTML='Caricamento depositi selezionati ';
document.getElementById('overlaySelezionaDeposito').style.display = 'flex';
if(actionRequest === "show"){
var action = "show";
} else {
if(idMagazzinoSysintChecked === true) {
var action = "add";
} else {
var action = "delete";
}
}
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttpSelezioneMagazzini=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttpSelezioneMagazzini=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttpSelezioneMagazzini.onreadystatechange=function() {
if (xmlhttpSelezioneMagazzini.readyState==4 && xmlhttpSelezioneMagazzini.status==200) {
document.getElementById("testoSupplementareInfo").innerHTML = xmlhttpSelezioneMagazzini.responseText;
//document.getElementById("oscuramento_nero").style.display="none";
//document.getElementById("popup_resp").style.display="none";
document.getElementById('overlaySelezionaDeposito').style.display = 'none';
return 1;
}
}
var parametri = '';
xmlhttpSelezioneMagazzini.open("POST","API-gestione-ordini-logistica",true);
xmlhttpSelezioneMagazzini.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=impostaMagazzinoDaConsiderareArticoliLentaRotazione";
parametri += "&idMagazzinoSysint="+ idMagazzinoSysintValue;
parametri += "&action="+ action;
xmlhttpSelezioneMagazzini.send(parametri);
}
function mostraIndiciClienteImpostazioniOrdini(codiceCliente){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestGIRIPreparatori = new XMLHttpRequest();
}
else {
// code for IE6, IE5
xmlHTTPrequestGIRIPreparatori = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestGIRIPreparatori.onreadystatechange = function() {
if (xmlHTTPrequestGIRIPreparatori.readyState==4 && xmlHTTPrequestGIRIPreparatori.status==200) {
document.getElementById("popup_resp_TESTO").innerHTML=xmlHTTPrequestGIRIPreparatori.responseText;
}
}
xmlHTTPrequestGIRIPreparatori.open("POST","API-recupero_crediti",true);
xmlHTTPrequestGIRIPreparatori.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=showIndiciCliente";
parametri += "&codiceCliente="+ codiceCliente;
xmlHTTPrequestGIRIPreparatori.send(parametri);
//$("div#oscuramento").css("display","block");
}
function mostraPopupInformativoOrdiniSospesi(giroArrayJson){
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttpOrdini=new XMLHttpRequest();
}
else {
// code for IE6, IE5
xmlhttpOrdini=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttpOrdini.onreadystatechange=function() {
if (xmlhttpOrdini.readyState==4 && xmlhttpOrdini.status==200) {
if( xmlhttpOrdini.responseText.trim() != "") {
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='';
document.getElementById("popup_resp_TESTO").innerHTML=xmlhttpOrdini.responseText;
}
return 1;
}
}
var parametri = '';
xmlhttpOrdini.open("POST","API-gestione-ordini-logistica",true);
xmlhttpOrdini.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=verificaMerceOrdiniSospesi";
parametri += "&giroArrayJson="+ giroArrayJson;
xmlhttpOrdini.send(parametri);
}
function mostraDettagliOrdineOnline(idOrdine) {
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='';
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp1=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp1.onreadystatechange=function()
{
if (xmlhttp1.readyState==4 && xmlhttp1.status==200)
{
document.getElementById("popup_resp_TESTO").innerHTML=xmlhttp1.responseText;
return 1;
}
}
var parametri = '';
xmlhttp1.open("POST","API-gestione-ordini-logistica",true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=mostraDettagliOrdineOnline";
parametri += "&idOrdine="+ idOrdine;
xmlhttp1.send(parametri);
}
function settaOrdineComeGiaConsegnato(checked, idOrdine){
if(checked){
var testo = "Vuoi settare questo ordine come RICEVUTO?";
var ordineConfermato = "si"
} else {
var testo = "Vuoi settare questo ordine come ANCORA DA RICEVERE?";
var ordineConfermato = "no"
}
if(!confirm(testo)){
return false;
}
document.getElementById("oscuramento_nero").style.display="block";
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp1=new XMLHttpRequest();
} else {// code for IE6, IE5
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp1.onreadystatechange=function(){
if (xmlhttp1.readyState==4 && xmlhttp1.status==200) {
location.reload();
return 1;
}
}
xmlhttp1.open("POST","API-gestione-ordini-logistica",true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=settaOrdineComeRicevuto";
parametri += "&idOrdine="+ idOrdine;
parametri += "&ordineConfermato="+ ordineConfermato;
xmlhttp1.send(parametri);
}
function mostraVendutoDiRiferimento(idOrdine) {
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='';
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp1=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp1.onreadystatechange=function(){
if (xmlhttp1.readyState==4 && xmlhttp1.status==200) {
document.getElementById("popup_resp_TESTO").innerHTML=xmlhttp1.responseText;
return 1;
}
}
var parametri = '';
xmlhttp1.open("POST","API-gestione-ordini-logistica",true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=mostraVendutoDiRiferimento";
parametri += "&idOrdine="+ idOrdine;
xmlhttp1.send(parametri);
}
function modificaScortaMinimaImpostataDepositoSelezionato(form, riferimentoRiga){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
const quantita_richiesta = form.quantita_richiesta.value;
const codice_articolo = form.codice_articolo.value;
const tipoDiCalcoloScortaMinima = form.tipoDiCalcoloScortaMinima.value;
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp1=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp1.onreadystatechange=function(){
if (xmlhttp1.readyState==4 && xmlhttp1.status==200) {
var response = JSON.parse(xmlhttp1.responseText);
if (response.success) {
var idTabella = 'tableScorteMinimeImpostate'; // Sostituisci con l'ID effettivo della tabella
var table = $('#' + idTabella).DataTable();
//var rowIndex = table.row('[data-id="' + riferimentoRiga + '"]').index();
var rowIndex = -1;
var rows = table.rows().nodes();
for (var i = 0; i < rows.length; i++) {
if(rows[i].cells[1].textContent === codice_articolo){
rowIndex = $(rows[i]).data('id');
break; // Esci dal ciclo dopo aver trovato il primo match
}
}
if (rowIndex !== -1) {
var row = table.row(rowIndex).node(); // Ottieni il nodo della riga
var dataId = $(row).attr('data-id'); // Estrai l'attributo data-id dalla riga
const indexColonna = {
"4": quantita_richiesta,
"5": "",
"6": tipoDiCalcoloScortaMinima,
};
for (const chiave in indexColonna) {
const valore = indexColonna[chiave];
table.cell(rowIndex, chiave).data(valore).draw();
const cell = table.cell(rowIndex, chiave).node(); // Ottieni la cella
$(cell).css({ 'background-color': '#FFEA01',
'transition': 'background-color 0.5s ease'}); // Imposta il colore di sfondo a giallo
setTimeout(function() {
$(cell).css({ 'background-color': '',
'transition': 'background-color 0.5s ease'}); // Rimuove il colore di sfondo
}, 2000); // 2000 ms = 2 secondi
}
}
} else {
alert("Error: " + response.message);
}
document.getElementById("popup_resp_TESTO").innerHTML = response.message;
return;
}
}
xmlhttp1.open("POST","API-gestione-ordini-logistica",true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=impostaValoreScortaMinimaProdotto";
parametri += "&productId="+ codice_articolo;
parametri += "&valoreNuovo="+ quantita_richiesta;
parametri += "&tipoDiCalcoloScortaMinima="+ tipoDiCalcoloScortaMinima;
xmlhttp1.send(parametri);
}
function mostraSuggerimentiGestioneScorteDeposito(){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp1=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp1.onreadystatechange=function(){
if (xmlhttp1.readyState===4 && xmlhttp1.status===200) {
document.getElementById("popup_resp_TESTO").innerHTML=xmlhttp1.responseText;
return 1;
}
}
xmlhttp1.open("POST","API-gestione-ordini-logistica",true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=mostraSuggerimentiGestioneScorte";
xmlhttp1.send(parametri);
}
function mostraFormValoreScortaMinimaProdotto(productId, riferimentoRiga) {
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp1=new XMLHttpRequest();
}
else {// code for IE6, IE5
xmlhttp1=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp1.onreadystatechange=function(){
if (xmlhttp1.readyState===4 && xmlhttp1.status===200) {
document.getElementById("popup_resp_TESTO").innerHTML=xmlhttp1.responseText;
return 1;
}
}
xmlhttp1.open("POST","API-gestione-ordini-logistica",true);
xmlhttp1.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=mostraFormValoreScortaMinimaProdotto";
parametri += "&productId="+ productId;
parametri += "&riferimentoRiga="+ riferimentoRiga;
xmlhttp1.send(parametri);
}
function controllo_aut_modifiche_giro(giro,azione) {
//azione=1 inizializzazione ad inzio pagina
//azione=2 controllo aggiornamenti
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else {
// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4 && xmlhttp.status==200) {
//funziondocument.getElementById("div_settori").innerHTML=xmlhttp.responseText;
//$("div#oscuramento").css("display","none");
if(azione==1) {
document.getElementById('counter_modifiche').value= xmlhttp.responseText.trim();
window.setInterval("controllo_aut_modifiche_giro('"+giro+"','2')", 180000); //180.000 ms= 3 minuti
}
else {
if(xmlhttp.responseText.trim()!=document.getElementById('counter_modifiche').value) {
alert("ATTENZIONE! SONO STATE FATTE MODIFICHE AL GIRO! AGGIORNA LA PAGINA.");
return 9;
}
}
}
}
xmlhttp.open("GET","funzioni_gestione_ordini_verifica_modifiche_giri.php?giro="+giro,true);
xmlhttp.send();
//$("div#oscuramento").css("display","block");
//LEGGIAMO IL VALORE DEL FILE INERENTE AL GIRO
}
function confermaDatiAccompagnatoriSpedizione(idOrdine)
{
//numeroColli
//pesoColli
var numeroColli = document.getElementById("numeroColli"+idOrdine).value.trim();
var pesoColli = document.getElementById("pesoColli"+idOrdine).value.trim();
document.getElementById("numeroColli"+idOrdine).style = "background-color : white ";
document.getElementById("pesoColli"+idOrdine).style = "background-color : white ";
pesoColli = pesoColli.replace(",",".");
/*
if(isNaN(numeroColli) )
{
document.getElementById("numeroColli"+idOrdine).style = "background-color : red ";
alert("Numero Colli: valore Errato. Riprova.");
return;
}
*/
if(isNaN(pesoColli) )
{
document.getElementById("pesoColli"+idOrdine).style = "background-color : red ";
alert("Peso Colli: valore errato. Ricorda di usare il punto come separatore dei decimali. Riprova.");
return;
}
document.getElementById("oscuramento_nero").style.display="block";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestDatiAggiuntivi = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequestDatiAggiuntivi = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestDatiAggiuntivi.onreadystatechange = function()
{
if (xmlHTTPrequestDatiAggiuntivi.readyState==4 && xmlHTTPrequestDatiAggiuntivi.status==200)
{
var result = xmlHTTPrequestDatiAggiuntivi.responseText.trim();
var resArray = result.split(";");
if(resArray[0] == '0')
{
document.getElementById("numeroColli"+idOrdine).style = "background-color : red ";
document.getElementById("pesoColli"+idOrdine).style = "background-color : red ";
}
else
{
document.getElementById("numeroColli"+idOrdine).style = "background-color : #28a745 ";
document.getElementById("pesoColli"+idOrdine).style = "background-color : #28a745 ";
}
document.getElementById("risultatoAggiornamentoDatiAgg"+idOrdine).innerHTML = resArray[1];
document.getElementById("oscuramento_nero").style.display="none";
}
}
xmlHTTPrequestDatiAggiuntivi.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequestDatiAggiuntivi.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=6";
parametri += "&numeroColli="+ numeroColli;
parametri += "&pesoColli="+ pesoColli;
parametri += "&idOrdine="+ idOrdine;
xmlHTTPrequestDatiAggiuntivi.send(parametri);
//$("div#oscuramento").css("display","block");
}
function stampaUltimeEtichetteChiusuraGiri(numeroEtichette, nomeContenitore)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestGIRIPreparatori = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequestGIRIPreparatori = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestGIRIPreparatori.onreadystatechange = function()
{
if (xmlHTTPrequestGIRIPreparatori.readyState==4 && xmlHTTPrequestGIRIPreparatori.status==200)
{
document.getElementById(nomeContenitore).innerHTML = xmlHTTPrequestGIRIPreparatori.responseText;
}
}
xmlHTTPrequestGIRIPreparatori.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequestGIRIPreparatori.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=5";
parametri += "&numeroEtichette="+ numeroEtichette;
xmlHTTPrequestGIRIPreparatori.send(parametri);
//$("div#oscuramento").css("display","block");
}
function settaEtichettaVerificata (checked, idEtichetta){
var valoreAggiornamento = 0;
if(checked == true){
valoreAggiornamento = 1;
}
document.getElementById("oscuramento_nero").style.display="block";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestGIRIPreparatori = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequestGIRIPreparatori = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestGIRIPreparatori.onreadystatechange = function()
{
if (xmlHTTPrequestGIRIPreparatori.readyState==4 && xmlHTTPrequestGIRIPreparatori.status==200){
document.getElementById("oscuramento_nero").style.display="none";
}
}
xmlHTTPrequestGIRIPreparatori.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequestGIRIPreparatori.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=8";
parametri += "&idEtichetta="+ idEtichetta;
parametri += "&valoreAggiornamento="+ valoreAggiornamento;
xmlHTTPrequestGIRIPreparatori.send(parametri);
}
function cambio_pedana()
{
if(document.getElementById("numero_articoli_in_pedana").innerHTML=='0')
{
alert("Non puoi cambiare pedana perche in quella corrnte non c'e' nessun articolo.");
}
else
{
document.getElementById("pedana_in_corso").value=parseInt(document.getElementById("pedana_in_corso").value)+1;
document.getElementById("numero_articoli_in_pedana").innerHTML=0;
document.getElementById("numero_pedana").innerHTML=document.getElementById("pedana_in_corso").value;
}
}
function mostra_nascondi_ordini_clienti(div)
{
if(document.getElementById(div).style.display=='none')
{
document.getElementById(div).style.display='block';
}
else
{
document.getElementById(div).style.display='none';
}
}
function visualizza_tutti_gli_ordini(elenco_ordini)
{
for(i=0;i';
document.getElementById("popup_resp").style.display="block";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequest = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequest.onreadystatechange = function()
{
if (xmlHTTPrequest.readyState===4 && xmlHTTPrequest.status===200)
{
document.getElementById("popup_resp_TESTO").innerHTML = xmlHTTPrequest.responseText;
}
}
xmlHTTPrequest.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=addNotePermanentiCliente";
parametri += "&codCliente="+ codCliente;
xmlHTTPrequest.send(parametri);
//$("div#oscuramento").css("display","block");
}
function storeNewNotaPermanente(codCliente, annotazione){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
document.getElementById("popup_resp").style.display="block";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequest = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequest.onreadystatechange = function()
{
if (xmlHTTPrequest.readyState==4 && xmlHTTPrequest.status==200)
{
document.getElementById("popup_resp_TESTO").innerHTML = xmlHTTPrequest.responseText;
refreshNotaPermanente(codCliente);
}
}
xmlHTTPrequest.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=storeNewNotePermanentiCliente";
parametri += "&codCliente="+ codCliente;
parametri += "&annotazione="+ annotazione;
xmlHTTPrequest.send(parametri);
//$("div#oscuramento").css("display","block");
}
function deleteNewNotaPermanente(codCliente, idNotaDaEliminare){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
document.getElementById("popup_resp").style.display="block";
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequest = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequest.onreadystatechange = function()
{
if (xmlHTTPrequest.readyState==4 && xmlHTTPrequest.status==200)
{
document.getElementById("popup_resp_TESTO").innerHTML = xmlHTTPrequest.responseText;
refreshNotaPermanente(codCliente);
}
}
xmlHTTPrequest.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=deleteNotePermanentiCliente";
parametri += "&codCliente=" + codCliente;
parametri += "&idNotaDaEliminare=" + idNotaDaEliminare;
xmlHTTPrequest.send(parametri);
//$("div#oscuramento").css("display","block");
}
function refreshNotaPermanente(codCliente){
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequest = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequest = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequest.onreadystatechange = function()
{
if (xmlHTTPrequest.readyState==4 && xmlHTTPrequest.status==200)
{
//document.getElementById("annotazioniPermanenti" + codCliente).innerHTML = xmlHTTPrequest.responseText;
var array = document.getElementsByClassName("annotazioniPermanenti" + codCliente);
for(i = 0; i< array.length; i ++){
array[i].innerHTML = xmlHTTPrequest.responseText;
}
}
}
xmlHTTPrequest.open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=getElencoNotePermanentiCliente";
parametri += "&codCliente=" + codCliente;
xmlHTTPrequest.send(parametri);
//$("div#oscuramento").css("display","block");
}
function caricaArticoliOrdineSysintAJAX(idOrdine, nomeContenitore)
{
document.getElementById(nomeContenitore).innerHTML='
CARICAMENTO ARTICOLI
';
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlHTTPrequestArticoliOrdiniSysint[idOrdine] = new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlHTTPrequestArticoliOrdiniSysint[idOrdine] = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHTTPrequestArticoliOrdiniSysint[idOrdine].onreadystatechange = function()
{
if (xmlHTTPrequestArticoliOrdiniSysint[idOrdine].readyState===4 && xmlHTTPrequestArticoliOrdiniSysint[idOrdine].status===200) {
document.getElementById(nomeContenitore).innerHTML = xmlHTTPrequestArticoliOrdiniSysint[idOrdine].responseText;
let div = document.createElement('div');
div.innerHTML = xmlHTTPrequestArticoliOrdiniSysint[idOrdine].responseText;
// Eseguiamo gli script
var scripts = div.querySelectorAll('script');
scripts.forEach(function(script) {
var newScript = document.createElement('script');
newScript.text = script.text;
document.head.appendChild(newScript);
});
}
};
xmlHTTPrequestArticoliOrdiniSysint[idOrdine].open("POST","API-gestione-ordini-logistica",true);
xmlHTTPrequestArticoliOrdiniSysint[idOrdine].setRequestHeader("Content-type","application/x-www-form-urlencoded");
var parametri = "azione=caricaArticoliOrdine";
parametri += "&idOrdine="+ idOrdine;
xmlHTTPrequestArticoliOrdiniSysint[idOrdine].send(parametri);
//$("div#oscuramento").css("display","block");
}
function bloccaConsegnaImportoNonSufficiente(idOrdineSysint, motivazione){
var parametri = new URLSearchParams();
parametri.append("azione", "autorizzaNonostanteImportoNonSufficiente");
parametri.append("idOrdineSysint", idOrdineSysint);
parametri.append("motivazione", motivazione);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.json())
.then(data => {
if (data.error === "no") {
ricarica_ordine_in_lista(idOrdineSysint, "");
} else {
alert(data.message);
}
})
.catch(error => {
alert("Errore nella richiesta. " + error);
})
.finally(() => {
});
}
function mostraOrdiniGiro(codiceEtichetta){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
var parametri = new URLSearchParams();
parametri.append("azione", "mostraOrdiniGiro");
parametri.append("codiceEtichetta", codiceEtichetta);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.json())
.then(data => {
if (data.error === "no") {
document.getElementById("popup_resp_TESTO").innerHTML=data.message;
} else {
alert(data.message);
}
})
.catch(error => {
alert("Errore nella richiesta. " + error);
})
.finally(() => {
});
}
function scaricaPdfLottiGiro() {
const checkboxes = document.querySelectorAll('input[name="selected_ids[]"]:checked');
const selectedIds = Array.from(checkboxes).map(cb => cb.value);
if (selectedIds.length === 0) {
alert("Seleziona almeno un ordine.");
return;
}
var ordiniJson = JSON.stringify(selectedIds);
var parametri = new URLSearchParams();
parametri.append("azione", "scaricaPdfLottiGiro");
parametri.append("ordiniJson", ordiniJson);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
// Esegui la chiamata fetch
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.blob()) // Ottieni il PDF come blob
.then(blob => {
// Creare un URL temporaneo per il blob
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = "lotti_giro.pdf"; // Imposta il nome del file
link.click(); // Simula il click per scaricare il PDF
})
.catch(error => {
alert("Errore nella richiesta. " + error);
});
}
function mostraPannelloSincronizzaOrdiniClientiSysint(){
let div = document.getElementById("selezionaDataSincronizzazioneOrdini");
if(div){
if(div.style.display === "none"){
$("div#selezionaDataSincronizzazioneOrdini").slideDown("slow");
div.style.display = "block";
} else {
$("div#selezionaDataSincronizzazioneOrdini").slideUp("fast");
div.style.display = "none";
}
} else {
if(confirm("Pannello per la selezione della data non trovato. Procedo comunque con la sincronizzazione della data odierna?")){
sincronizzaOrdiniClientiSysint();
}
}
}
function sincronizzaOrdiniClientiSysint(data){
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
var parametri = new URLSearchParams();
parametri.append("azione", "sincronizzaDocumentiSysint");
parametri.append("data", dataDocumenti);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.json())
.then(data => {
if (data.error === "no") {
document.getElementById("popup_resp_TESTO").innerHTML=data.message;
} else {
alert(data.message);
}
})
.catch(error => {
alert("Errore nella richiesta. " + error);
})
.finally(() => {
});
}
function sblocca_consegna_sottocosto(id_ordine){
document.getElementById("oscuramento_nero").style.display="block";
var parametri = new URLSearchParams();
parametri.append("azione", "autorizzaOrdineSottocosto");
parametri.append("codice_ordine", id_ordine);
const queryString = parametri.toString();
const url = "API-gestione-ordini-logistica";
fetch(url, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: queryString
})
.then(response => response.json())
.then(data => {
if (data.error === "no") {
document.getElementById("modifica_giro_ordineBLOCCATO"+id_ordine).innerHTML = data.selectGiro;
document.getElementById("vendita_sottocosto_pulsante"+id_ordine).innerHTML='';
} else {
alert(data.message);
}
})
.catch(error => {
alert("Errore nella richiesta. " + error);
})
.finally(() => {
document.getElementById("oscuramento_nero").style.display="none";
});
}
function invia_modulo_conferma_azione(azione)
{
//1 posticipa
//2 elimina
document.getElementById("azione_massiva").value=azione;
document.conferma_massiva_form.action = "gestione_ordini_sysint.php";
document.conferma_massiva_form.submit();
}
function conferma_massiva()
{
var i = 0;
var flag;
var modulo = document.getElementsByTagName("input");
flag=0;
document.getElementById("elenco_ordini_massivi").value='';
for (i=0; i
INSERISCI LA DESTINAZIONE DIVERSA
';
document.getElementById("popup_resp").style.display="block";
}
else
{
alert("Per modificare gli ordini devi essere loggato come amministratore");
}
}
function aggiungi_nota_ordine(div, cod_ordine, disabled)
{
if(disabled.trim()!='disabled')
{
destinazione_esistente= document.getElementById(div).innerHTML;
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
INSERISCI LA NOTA PER IL CLIENTE
';
document.getElementById("popup_resp").style.display="block";
}
else
{
alert("Per modificare gli ordini devi essere loggato come amministratore");
}
}
function memorizza_nota_cliente(div, cod_ordine)
{
note_ordine_cliente=document.getElementById("NOTA_ORDINE_text").value;
if(note_ordine_cliente.trim()!='')
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(div).innerHTML=note_ordine_cliente;
//document.getElementById(div).style.display='none';
$("div#caricamento").css("display","none");
document.getElementById("popup_resp").style.display="none";
document.getElementById("oscuramento_nero").style.display="none";
}
}
xmlhttp.open("GET","funzioni_gestione_ordini_aggiungi_nota.php?codice_ordine="+cod_ordine+"¬e_ordine_cliente="+note_ordine_cliente,true);
xmlhttp.send();
//$("div#oscuramento").css("display","block");
}
else
{
alert("La destinazione che hai inserito sembra essere vuota. Verifica per favore.");
}
}
function memorizza_destinazione_diversa(div, cod_ordine)
{
destinazione_inserita=document.getElementById("destinazione_diversa_text").value;
if(destinazione_inserita.trim()!='')
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(div).innerHTML='' +destinazione_inserita;
//document.getElementById(div).style.display='none';
$("div#caricamento").css("display","none");
document.getElementById("popup_resp").style.display="none";
document.getElementById("oscuramento_nero").style.display="none";
}
}
xmlhttp.open("GET","funzioni_gestione_ordini_aggiungi_destinazione.php?codice_ordine="+cod_ordine+"&destinazione="+destinazione_inserita,true);
xmlhttp.send();
//$("div#oscuramento").css("display","block");
}
else
{
alert("La destinazione che hai inserito sembra essere vuota. Verifica per favore.");
}
}
function mostra_nascondi_dettagli_ordine(div)
{
if(document.getElementById(div).style.display=='none')
{
document.getElementById(div).style.display='block';
}
else
{
document.getElementById(div).style.display='none';
}
}
function ordine_confermata_completezza(codice_ordine)
{
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//funziondocument.getElementById("div_settori").innerHTML=xmlhttp.responseText;
$("div#oscuramento_nero").css("display","none");
$("div#ordine_potenzialmente_aperto"+codice_ordine).css("display","none");
document.getElementById("flag_conf_compl"+codice_ordine).value=0;
}
}
xmlhttp.open("GET","funzioni_gestione_ordini_ord_apert_ajax.php?codice_ordine="+codice_ordine,true);
xmlhttp.send();
$("div#oscuramento_nero").css("display","block");
}
function mostra_nascondi_ultime_etichette()
{
if(document.getElementById("elenco_etichette").style.display=="block")
{
$("div#elenco_etichette").slideUp("fast");
document.getElementById("elenco_etichette").style.display="none";
}
else
{
$("div#elenco_etichette").slideDown("slow");
document.getElementById("elenco_etichette").style.display="block";
}
}
function mostra_nascondi_dettagli_ordine(div)
{
if(document.getElementById(div).style.display=='none')
{
document.getElementById(div).style.display='block';
}
else
{
document.getElementById(div).style.display='none';
}
}
function abilita_tasto_conferma(codice)
{
if(codice!=0)
{
document.getElementById("tasto_conferma").disabled=false;
}
else
{
document.getElementById("tasto_conferma").disabled=true;
}
}
function visualizzazione(n)
{
var x = document.createElement("INPUT");
x.setAttribute("type", "hidden");
x.setAttribute("value", n);
x.setAttribute("name", "tipo_visualizzazione");
x.setAttribute("id", "tipo_visualizzazione");
document.getElementById("form_filtri").appendChild(x);
document.getElementById("form_filtri").submit();
return;
document.getElementById("tipo_visualizzazione").value = n;
if(document.getElementById("tipo_visualizzazione").value == n ) {
document.getElementById("form_filtri").submit();
} else {
alert("Errore");
}
}
function informazioni_sincronizzazione_dati()
{
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//funziondocument.getElementById("div_settori").innerHTML=xmlhttp.responseText;
document.getElementById("popup_resp_TESTO").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","funzioni_gestione_ordini_vis_ultimi_ordseq_ajax.php",true);
xmlhttp.send();
$("div#oscuramento_nero").css("display","block");
}
function cerca_consegna_giri_chiusi()
{
testo_ricerca=document.getElementById("cerca_cons").value;
if(testo_ricerca.trim().length<3 || testo_ricerca=='')
{
alert("Inserisci un testo valido per la ricerca. Devi mettere almeno 3 lettere");
return;
}
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='
';
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//funziondocument.getElementById("div_settori").innerHTML=xmlhttp.responseText;
document.getElementById("popup_resp_TESTO").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","funzioni_cerca_ordine_confermato_ajax.php?testo_ricerca="+testo_ricerca,true);
xmlhttp.send();
$("div#oscuramento_nero").css("display","block");
}
function cambia_colore_marker(colore,codordine)
{
//alert (colore);
if(colore == undefined)
{
colore='000000';
alert("Impossibile modificare il colore del marker. L'ordine e' stato tuttavia correttamente assegnato.");
}
var pinColor = colore;
var pinImage = new google.maps.MarkerImage("http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld=%E2%80%A2|" + pinColor);
window['marker_'+codordine].setIcon(pinImage);
infoWindow.close(map);
}
function verifica_flag_modifica_giro(nome_select, codice_ordine)
{
if(document.getElementById("flag_conf_compl"+codice_ordine).value==1 )
{
document.getElementById(nome_select).style.display="none";
alert("ATTENZIONE! Quest'ordine sembra esportato solo parzialmente, quindi alcuni articoli potrebbero non essere presenti nell'ordine. \nE' indispensabile che verichi che l'ordine presente su Sysint sia uguale a quello esportato.")
document.getElementById(nome_select).style.display="inline-block";
}
}
function modifica_giro_ordine(giro, codice_ordine, cod_cli, crediti)
{
if (crediti==1 )
{
if(!confirm('Il cliente risulta bloccato. Hai verificato/chiesto all amministrazione se si puo consegnare?'))
{
return;
}
}
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
//funziondocument.getElementById("div_settori").innerHTML=xmlhttp.responseText;
$("div#oscuramento_nero").css("display","none");
//se presente, cambia colore al marker
//alert("prova");
var element = document.getElementById("marker_"+codice_ordine);
//if(typeof(element) != 'undefined' && element != null)
{
//alert(typeof(element) );
cambia_colore_marker(colori_giri[giro],codice_ordine);
}
}
}
xmlhttp.open("GET","funzioni_gestione_ordini_ajax.php?giro="+giro+"&codice_ordine="+codice_ordine+"&cod_cli="+cod_cli+"&crediti="+crediti,true);
xmlhttp.send();
$("div#oscuramento_nero").css("display","block");
}
function elimina_coordinate_cliente(id_coordinate, nome_marker)
{
if(confirm("Vuoi eliminare le coordinate del cliente selezionato?"))
{
document.getElementById("oscuramento_nero").style.display="block";
document.getElementById("popup_resp_TESTO").innerHTML='