// colore bianco - per ripristino colore normale/ abilitare l'editazione var NORMAL_COLOR="#FFFFFF"; // colore rosso - per segnalazione errore var ERROR_COLOR="#FE2E2E"; // colore giallo - per segnalazione attenzione var WARNING_COLOR="#FFFF80"; // colore grigio - per impostare il campo readOnly/disable var DISABLE_COLOR="#E6E6E6"; // colore verde - per segnalazione riconoscimento dato var ACK_COLOR="#2FFF2F"; // *********** // Marco D. - Inizio // Marco D. - Fine // *********** //Verifica obbligatorieta' radio e check box //Author: Luca Tonello //Version 1.0.0. 17-mag-2005 function verificaObbCR(field) { var flagObb = false; if(field.checked == true){ flagObb=true; } else { for (i = 0; i < field.length; i++) { if(field[i].checked == true){ flagObb=true; break; } } } return flagObb; } //Ritorna valore di un radio o un check box //Author: Luca Tonello //Version 1.0.0. 31-gen-2007 function getCheckedValue(radioObj) { if(!radioObj) return ""; var radioLength = radioObj.length; if(radioLength == undefined) if(radioObj.checked) return radioObj.value; else return ""; for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } //Dato un radiobox o un checkbox e un valore, checca il radio corrispondente al valore in input // Campo : document.NomeForm.NomeElemento // Valore da selezionare //Author: Servetti Alessandro //Version: 1.0.0 24/10/07 function checkObject(prField,valore){ var value = ""; var i; if(prField.value==valore){ prField[j].checked = true; } else { if(prField.length>0){ for(j=0;j=n ; } /*if( debugStep == 1){ alert( 'checkAtLeastNCharInFields'+fieldsId[i] +':' + fieldsTrimmedValue[i] + ':' + fieldWithEnoughChars); }*/ } if( fieldWithEnoughChars ){ controlloOK = true; } //alert( "Bye from: CheckAtLeastNCharInFields" ); } return controlloOK; } function checkVoidFields( fieldsId, n, msg ){ /*if( debugStep == 1 ){ alert( 'Debug checkVoidFields' ); }*/ var controlloOK = checkAtLeastNCharInFields( fieldsId, n, false, '' ); if(!controlloOK){ impostaErroreIdV( fieldsId, msg ); } return controlloOK; } function checkVoidFieldsAll( fieldsId, n, msg ){ /*if( debugStep == 1 ){ alert( 'Debug checkVoidFields' ); }*/ var controlloOK = checkAtLeastNCharInFields( fieldsId, n, true, msg ); return controlloOK; } /*===============================================================================================================* * mostra nascondi TD pulsanti *===============================================================================================================*/ function nascondiPulsanteId( idTD ){ nascondiPulsanteObj( document.getElementById( idTD) ); } function mostraPulsanteId( idTD ){ mostraPulsanteObj( document.getElementById( idTD ) ); } function nascondiPulsanteObj( obj ){ if( obj != null ){ obj.style.display="none"; } } function mostraPulsanteObj( obj ){ if(obj!=null){ obj.style.display=""; } } //lancia interrogazione tabelle (modale per IE, normale altri browser) //Parametri: // preCodice: precodice file tabelle (Es. NA --> Nazioni) // parIdCampoCod: ID campo del chiamante in cui verra' restituito il codice // parIdCampoDesc: ID campo del chiamante in cui verra' restituita la descrizione // (facoltativo: se passato vuoto, non verra' restituita la descrizione) // parTitolo: titolo della finestra popup //Author: Maurizio Rosso //Version 1.0.0. 24/05/2005 function callIntTab(parPrecodice, parIdCampoCod, parIdCampoDesc, parTitolo){ var url= '../servlet/serIntTabelle' + '?preCodice=' + parPrecodice + '&codice=' + document.getElementById(parIdCampoCod).value + '&idCampoCod=' + parIdCampoCod + '&idCampoDesc=' +parIdCampoDesc + '&titolo=' + parTitolo var wdwName = parTitolo.replace(/ /g, ''); var larghezza = 410 var altezza =440; interrPopup(url, wdwName, larghezza, altezza); } //filtro per richiamare altre callInt per i campi dinamici in EleValDinamiciCrm.makeInput (estensioni, questionari, contratti, ...) //Parametri: // parPfCodDes: pf che decodifica serve per individuare la callIntxyzt da effettuare // parIdCampoCod: ID campo del chiamante in cui verra' restituito il codice // parIdCampoDesc: ID campo del chiamante in cui verra' restituita la descrizione // (facoltativo: se passato vuoto, non verra' restituita la descrizione) // parTitolo: titolo della finestra popup //Author: BN //Version 1.0.0. 19/11/2007 function callIntTabValDin(parPfCodDes, parIdCampoCod, parIdCampoDesc, parTitolo){ parPfCodDes = trim(parPfCodDes); if( parPfCodDes == "PF0400.BA" ){ //DECOFICA BANCHE callIntTab( 'BA', parIdCampoCod, parIdCampoDesc, parTitolo ); }else if( parPfCodDes == "PF0400.PA" ){ //MODALITA' PAGAMENTO callIntTab( 'PA', parIdCampoCod, parIdCampoDesc, parTitolo ); }else if( parPfCodDes == "PF0400.PV" ){ //AGENTE callIntTab( 'PV', parIdCampoCod, parIdCampoDesc, parTitolo ); }else if( parPfCodDes == "PF0400.UN" ){ //DECOFICA UNITA' OPERATIVA callIntTab( 'UN', parIdCampoCod, parIdCampoDesc, parTitolo ); //i seguenti devono essere gli stessi in conFilesCampi }else if( parPfCodDes == "AWCMT01" ){ //Tipi Recapiti callIntTipiRecapiti( parIdCampoCod, parIdCampoDesc, parTitolo ); }else if( parPfCodDes == "AWCMT02" ){ //Tipi Soggetto callIntTipiSoggetto( parIdCampoCod, parIdCampoDesc, parTitolo ); }else if( parPfCodDes == "AWCMT03" ){ //Tipi Titoli callIntTitoliPersona(parIdCampoCod, parIdCampoDesc, parTitolo ); }else if( parPfCodDes == "AWCMT05" ){ //Settori Merciologici }else if( parPfCodDes == "AWCMT06" ){ //Tipologie Preferenze callIntTipiPreferenze(parIdCampoCod, parIdCampoDesc, parTitolo); }else if( parPfCodDes == "AWCMT09" ){ //Carte Fedelta' }else if( parPfCodDes == "AWCMT10" ){ //Reparti callIntReparti(parIdCampoCod, parIdCampoDesc, parTitolo); }else if( parPfCodDes == "AWCMT11" ){ //Valutazioni callIntValutazioni(parIdCampoCod, parIdCampoDesc, parTitolo); }else if( parPfCodDes == "AWCMT12" ){ //Potenzialita callIntPotenzialita(parIdCampoCod, parIdCampoDesc, parTitolo); }else if( parPfCodDes == "AWCMT13" ){ //Sottoscrizioni callIntSottoscrizioni(parIdCampoCod, parIdCampoDesc, parTitolo); }else if( parPfCodDes == "AWCMT14" ){ //Nominativi }else if( parPfCodDes == "AWCMT16" ){ //Lingue Conoscute }else if( parPfCodDes == "AWCMT17" ){ //Priorit� Chiamate }else if( parPfCodDes == "AWCMT18" ){ //Categorie Ospiti callIntCategorieOspiti(parIdCampoCod, parIdCampoDesc, parTitolo); }else if( parPfCodDes == "AWCMT19" ){ //Stati Operativi Anagrafica callIntStatiOperativi(parIdCampoCod, parIdCampoDesc, parTitolo); } else { // Tabella Utente if ((parPfCodDes.length) > 7) { if (parPfCodDes.substring(0,7) == "AWCMT45") { // Tabella Utente var parPfCampoPreCod = parPfCodDes.substring(8); // Precodice callIntTabellaUtente(parPfCampoPreCod, parIdCampoCod, parIdCampoDesc, parTitolo); } } } } // centra una finestra //Author: Maurizio Rosso //Version 1.0.0. 24/05/2005 function interrPopup(url, wdwName,larghezza, altezza) { interrPopupScroll( url, wdwName, larghezza, altezza, false ); } function interrPopupScroll(url, wdwName,larghezza, altezza, scrollbars ) { var debugStep = -1; var w = window.screen.width; var h = window.screen.height; var cntx = Math.round((w - larghezza) / 2); var cnty = Math.round((h - altezza) / 2); if( debugStep >= 1 ){ alert( "Hullo from interrPopupScroll("+url+","+wdwName+","+larghezza+","+altezza+","+scrollbars+")" ); } //if(window.showModalDialog){ // wdwPopup=window.showModalDialog(url,window,'dialogWidth: ' + larghezza + 'px; dialogHeight: ' + altezza + 'px; center: 1; scroll: 0; help: 0; status: 0;'); // } //else{ // Qr=document.getSelection(); // if(!Qr){ //wdwName e' un nome di oggetto javascritp, non deve avere caratteri strani, in particolare IE7 si blocca a questo punto, per sicurezza occorre: wdwName=wdwName.replace(/[^_a-zA-Z0-9]/g, '_' ); wdwOpt = 'left=' + cntx + ',top=' + cnty + ',width=' + larghezza + ',height=' + altezza; if( scrollbars ){ wdwOpt += ',scrollbars=yes' }else{ wdwOpt += ',scrollbars=no' } wdwOpt += ', status=no, menubar=no, resizable=no, modal=yes, dialog=yes'; if( debugStep >= 1 ){ alert( wdwOpt ); } wdwPopup=window.open (url, wdwName, wdwOpt ); if( debugStep >= 1 ){ alert( "wdwPopup:" + wdwPopup ); } wdwPopup.focus(); // } // } } /* Le seguenti funzioni di manipolazione date prevedono che le date in input possano essere scritte nei seguenti formati: ggmmaa ggmmaaaa gg/mm/aa gg/mm/aaaa */ // Funzione addGiorni: restituisce "nuovadata" nel formato gg/mm/aaaa aggiungendo "giorni" // a "dataString" //Author: Maurizio Rosso //Version 1.0.1. 02-nov-2006 (corretto bug su cambio ora) function addGiorni(parIdCampoData, giorni){ var dataString=document.getElementById(parIdCampoData).value; aaaaMmGg(dataString); var data = new Date(aa,mm-1,gg); data.setDate(data.getDate()+giorni); var mese = String(parseInt(data.getMonth()) + 1); if (parseInt(data.getMonth()) < 9) mese = '0' + mese; var giorno = String(parseInt(data.getDate())); if (parseInt(data.getDate()) < 10) giorno = '0' + giorno; var nuovadata=giorno + '/' + mese + '/' + data.getFullYear(); return nuovadata; } // Funzione addMesi: restituisce "nuovadata" nel formato gg/mm/aaaa aggiungendo "mesi" // a "dataString" (se il giorno ? maggiore della fine mese di arrivo imposta la fine mese) //Author: Maurizio Rosso //Version 1.0.1. 20-dic-2006 function addMesi(parIdCampoData, mesi){ var dd = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); var dataString=document.getElementById(parIdCampoData).value; aaaaMmGg(dataString); // aggiunge i mesi var anno = parseInt(aa); var mese=parseInt(mm)+mesi; var giorno=parseInt(gg); // eventuale incremento anni if (mese>12){ anno= anno+mese/12; mese = mese % 12; } // calcolo fine mese var daysInMonth = dd[mese-1]; if (mese == 2) { if (anno % 4 == 0 && anno % 100 != 0 || anno % 400 == 0) daysInMonth++ } // se giorno supera fine mese, imposta fine mese if (giorno>daysInMonth){ giorno=daysInMonth; } // mese a due cifre if (mese < 10){ mese = '0' + mese; } // giorno a due cifre if (giorno < 10){ giorno = '0' + giorno; } var nuovadata=giorno + '/' + mese + '/' + anno; return nuovadata; } // Funzione diffDate: // passa il value dei campi "parIdCampoData1" e "parIdCampoData2" // utilizza la "diffDateValue" per fare il calcolo. function diffDate(parIdCampoData1, parIdCampoData2){ var dataString1=document.getElementById(parIdCampoData1).value; var dataString2=document.getElementById(parIdCampoData2).value; var numGiorni = diffDateValue(dataString1, dataString2); return numGiorni; } // Funzione diffDateValue: restituisce "numerogiorni" calcolando la differenza tra "valCampoData1" e "valCampoData2" // restituisce la differenza in giorni tra la data "dataString2" e "dataString1": // ATTENZIONE - puo' tornare anche un valore negativo! // es.: data1: 10/01/06 e data2: 22/01/06 -> 22 gg // es.: data1: 10/01/06 e data2: 09/01/06 -> -1 gg function diffDateValue(valCampoData1, valCampoData2){ var dataString1=valCampoData1; var dataString2=valCampoData2; aaaaMmGg(dataString1); var data1 = new Date(aa,mm-1,gg); aaaaMmGg(dataString2); var data2 = new Date(aa,mm-1,gg); // numerogiorni = parseInt(Math.abs(data2.getTime()-data1.getTime())/(3600*24000),10); var numGiorni = ((data2.getTime()-data1.getTime())/(3600*24000)); numGiorni = arrotonda(numGiorni,0); return numGiorni; } // Funzione checkData: controllo validita' data // parametri: parIdCampoData: ID del campo data da controllare // parIdCampoGioSett: ID del campo che conterra' il nome del giorno della settimana // (facoltativo: se uguale a '' non verra' decodificato il giorno della settimana) // parMsgErrore: messaggio di errore in caso di data formalmente errata //Author: Maurizio Rosso //Version 1.0.0. 15-giu-2005 // parNascita: "Y" o null - se "Y", significa che si tratta di una data di nascita // quindi c'? la questione del secolo // (facoltativo: se uguale a '' non verra' considerato) //Author: Marco Damilano //Version 1.0.0. 28-mar-2005 function checkData(parIdCampoData, parIdCampoGioSett, parMsgErrore, parNascita){ var debugStep = -1; if( debugStep >= 1 ){ alert( 'Hullo from chekData("'+parIdCampoData+'")!' ); } // se campo readOnly (non editabile), allora non faccio il controllo if (document.getElementById(parIdCampoData).readOnly==true){ return true; } var ggw = new Array("Domenica", "Lunedi'", "Martedi'", "Mercoledi'", "Giovedi'", "Venerdi'", "Sabato"); var dataString=document.getElementById(parIdCampoData).value; if( debugStep >= 1 ){ alert( ' 1) checkData:' + dataString ); } dataString = trim(dataString); if (dataString==""){ document.getElementById(parIdCampoData).value=""; document.getElementById(parIdCampoData).style.backgroundColor=NORMAL_COLOR; document.getElementById(parIdCampoData).title=""; return true; } if( debugStep >=1 ){ alert( ' 4) checkData' ); } aaaaMmGg(dataString, parNascita); data = new Date(aa,mm-1,gg); if(data.getDate()==gg && data.getMonth()+1==mm && (data.getFullYear()==aa)){ DataOK=true; if (parIdCampoGioSett!=''){ document.getElementById(parIdCampoGioSett).value= ggw[data.getDay()]; } document.getElementById(parIdCampoData).value=gg + '/' + mm + '/' +aa; document.getElementById(parIdCampoData).style.backgroundColor=NORMAL_COLOR; document.getElementById(parIdCampoData).title=""; } else { DataOK=false; if (parIdCampoGioSett!=''){ document.getElementById(parIdCampoGioSett).value= ""; } document.getElementById(parIdCampoData).style.backgroundColor=ERROR_COLOR; // document.getElementById(parIdCampoData).focus(); document.getElementById(parIdCampoData).title=parMsgErrore; } return DataOK } // Funzione AaaaMmGg: restituisce aa(4), mm(2), gg(2) leggendo la data "dataString" //Author: Maurizio Rosso //Version 1.0.0. 15-giu-2005 // se il test ? per una data di nascita, il secolo dovr? essere "esistente" (il futuro non esiste) //Author: Marco Damilano //Version 1.0.1. 28-mar-2006 function aaaaMmGg(dataString, parNascita){ if (/^(\d\d)\/(\d\d)\/(\d\d){1,2}$/.test(dataString)) { gg = (RegExp.$1) mm = (RegExp.$2) aa = (RegExp.$3) } else { gg = dataString.substr(0,2) mm = dataString.substr(2,2) if ((dataString.length)==6) aa = dataString.substr(4,2) else aa = dataString.substr(4,4) } if (aa.length==2) { if (parNascita==null){ // aa = '20' + aa if (aa > 70){ aa = '19' + aa; } else { aa = '20' + aa; } } else { var oggi = new Date(); var anno = oggi.getFullYear() + ""; var annoSenzaSecolo = anno.substr(2,2) * 1; var aaNum = aa * 1; if (aaNum>annoSenzaSecolo){ aa = '19' + aa; } else { aa = '20' + aa; } } } return aa,mm,gg } // converte un importo in un double // es.: -10.500,33 -> 10500.33 function formatImportoInDouble (stringImp){ if (stringImp==""){ return 0.0; } var pos; stringImp=stringImp.replace(/\./g, ''); var segno = stringImp.indexOf("-",0); stringImp=stringImp.replace(/\-/g, ''); var pos=stringImp.indexOf(","); var prima; var dopo; prima=stringImp.substring(0,pos); dopo= stringImp.substring(pos+1,stringImp.length); var tempImp = prima + "." + dopo; var doubleImp = 0.0; if (segno != -1){ // se negativo doubleImp = tempImp * -1.0; } else { doubleImp = tempImp * 1.0; } return doubleImp; } // Funzione formatNumero: formatta un numero inserendo i punti migliaia, la virgola decimali ed il numero corretto // di decimali // parametri: parIdCampoImporto: ID del campo importo da formattare // parDeciin: numero cifre decimali // parMsgErrore: messaggio di errore in caso di campo non numerico // parTipoPrimoParametro -"I/C" (Id, Campo -> l'oggetto vero e proprio) //Author: Maurizio Rosso //Version 1.0.0. 15-giu-2005 function formatNumero(parIdCampoImporto, parInteri, parDeciin, parMsgErrore,parTipoPrimoParametro){ var stringa=""; var numdec = parseInt(parDeciin); var interi; var decimali; var lun; var v; var s; var numeroFmt = ""; var quanti; var campo=null; if (parTipoPrimoParametro==null || parTipoPrimoParametro!="C"){ campo=document.getElementById(parIdCampoImporto); } else { campo=parIdCampoImporto; } if (checkNumero(campo,parInteri,parMsgErrore,'C')==true){ stringa=campo.value; lun = stringa.length; // se scrive XXXXX.YY -> XX.XXX,YY // se scrive X.Y -> X,Y0 var pPunto=stringa.indexOf(".",0); if (pPunto!=-1 && lun>2 && (pPunto==(lun-2) || pPunto==(lun-3))){ stringa=stringa.substr(0,pPunto)+","+stringa.substr(pPunto+1,lun-(pPunto+1)); } // elimina i punti delle migliaia stringa=stringa.replace(/\./g, ''); // verifica esistenza segno e lo elimina s = stringa.indexOf("-",0); stringa=stringa.replace(/\-/g, ''); // verifica posizione virgola v = stringa.indexOf(",",0); // ricalcola lungh stringa formata solo da cifre e virgola lun = stringa.length; // divide in interi e decimali if (v == -1){ interi = stringa decimali=" "; } else{ interi = stringa.substr(0, v); decimali = stringa.substr(v+1, lun-(v+1)) } // riporta interi nella stringa di output ("numeroFmt") inserendo i punti //secondo parametro parseInt indica base numerica //eliminazione zeri non significativi a sx interiInt=parseInt(interi,10); interi=interiInt.toString(); lun = interi.length - 3; quanti=3; while (lun >= 0){ numeroFmt= interi.substr(lun, quanti) + numeroFmt; if (lun > 0){ numeroFmt = "." + numeroFmt } lun = lun - 3; } if (lun >-3){ quanti= 3 + lun; lun=0; numeroFmt= interi.substr(lun, quanti) + numeroFmt } // se richiesti decimali, inserisce "," if (numdec != 0){ numeroFmt= numeroFmt + "," } // riporta decimali inputati o "0" per il numero di decimali richiesti (numdec) v = 0 while (numdec != 0){ if (decimali.charAt(v) >= "0" && decimali.charAt(v) <= "9"){ numeroFmt = numeroFmt + decimali.charAt(v) } else{ numeroFmt = numeroFmt + "0" } v = v + 1; numdec = numdec - 1 } // eventuale segno "-" if (s != -1){ numeroFmt= "-" + numeroFmt } campo.value= numeroFmt; return true; } else { return false; } } //Funzione checkNumero: testa se la stringa in input e' un numero: restituisce "true" se numero, "false" altrimenti // parametri: parIdCampoNumero: ID del campo numerico da controllare // parInteri // parMsgErrore: messaggio di errore in caso di campo non numerico // parTipoPrimoParametro -"I/C" (Id, Campo -> l'oggetto vero e proprio) //Author: Maurizio Rosso //Version 1.0.0. 15-giu-2005 //********** // si pu? usare per testare i campi numerici che non devono essere formattati infatti: // - trimma il campo che riceve (cos? da togliere i caratteri vuoti davanti o dietro il numero) // - se riceve una stringa vuota, imposta il valore ZERO //Author: Marco Damilano //Version 1.1.0. 26-ott-2005 function checkNumero(parIdCampoNumero,parInteri,parMsgErrore,parTipoPrimoParametro ){ var campo=null; if (parTipoPrimoParametro==null || parTipoPrimoParametro!="C"){ campo=document.getElementById(parIdCampoNumero); } else { campo=parIdCampoNumero; } // se campo readOnly (non editabile), allora non faccio il controllo if (campo.readOnly==true){ return true; } // imposto il numero senza spazi var tmpStringa=campo.value; tmpStringa=trim(tmpStringa); // se il numero ? vuoto, imposto ZERO if (tmpStringa=="") { campo.value="0"; } else { campo.value=tmpStringa; } if (!(ValidateNumber(campo.value,parInteri))){ if (parMsgErrore!=""){ campo.style.backgroundColor=ERROR_COLOR; try{ campo.focus(); campo.select(); } catch(e){ // salta operazione non sicura } campo.title=parMsgErrore; } return false; } else{ if (parMsgErrore!=""){ campo.style.backgroundColor=NORMAL_COLOR; } campo.title=""; return true; } } function ValidateNumber(val,parInteri){ // solo per le percentuali // se XX.XX -> XX,XX // se XX.X -> XX,X0 // se X.XX -> X,XX // se X.X -> X,X0 if (val.length<6 && val.length>2){ var posPunto=val.indexOf("."); if (posPunto!=-1 && (posPunto==(val.length-2) || posPunto==(val.length-3))){ val=val.substring(0,posPunto)+","+val.substring(posPunto+1,val.length); } } var pos; val=val.replace(/\./g, ''); val=val.replace(/\-/g, ''); pos=val.indexOf(","); if (pos==-1){ if (val.length>parInteri || val.length==0){ return false; } if (isNaN(val)) return false; } else { var prima; var dopo; prima=val.substring(0,pos); if (prima.length>parInteri || prima.length==0){ return false; } dopo= val.substring(pos+1,val.length); if (isNaN( prima ) ) return false; if (isNaN( dopo ) ) return false; } return true; } //Funzione checkNoZero: testa se la stringa in input e' un numero <> 0: restituisce "true" se numero, "false" //altrimenti // parametri: parIdCampoNumero: ID del campo numerico da controllare // parMsgErrore: messaggio di errore in caso di numero formalmente errato // parTipoPrimoParametro -"I/C" (Id, Campo -> l'oggetto vero e proprio) //Author: Maurizio Rosso //Version 1.0.0. 15-giu-2005 function checkNoZero(parIdCampoNumero,parMsgErrore,parTipoPrimoParametro){ var campo=null; if (parTipoPrimoParametro==null || parTipoPrimoParametro!="C"){ campo=document.getElementById(parIdCampoNumero); } else { campo=parIdCampoNumero; } if (!ValidateNumber(campo.value) || parseFloat(campo.value)== 0){ campo.style.backgroundColor=ERROR_COLOR; try{ campo.focus(); campo.select(); } catch(e){ // salta operazione non sicura } campo.title=parMsgErrore; return false; } else { campo.style.backgroundColor=NORMAL_COLOR; campo.title=""; return true; } } var altezzaPopUpEleCliCrm = 565; // modifica la dimensione del font su un insieme di elemento (ripristinando i valori di classe se zoom ridotto) //Parametri: // insiemeElementi: l'insieme di elementi su cui applicare la nova dimensione // (ES.: document.getElementsByTagName('FONT') per cambiare dimensione a tutti i tag 'FONT' // formato: piccolo/medio/grande // (in genere si potra' usare la variabile 'formato' della home (parent.formato)) function CambiaFontSize(insiemeElementi, formato){ // calcola la variabile dimensione in base allo stato dello zoom var dimensione = "11px"; if (formato=="medio"){ dimensione="13px"; }else{ if (formato=="grande"){ dimensione="16px"; } } // modifica la dimensione degli elementi for (var i = 0; i < insiemeElementi.length; i++ ) { if ((insiemeElementi[i].className=="") || (formato!="piccolo")){ insiemeElementi[i].style.fontSize=dimensione; //imposta nuova dimensione }else{ insiemeElementi[i].style.fontSize=""; //ripristina valori di classe } } } // Funzione checkAnno: formatta campo contenente anno nella forma AAAA // parametri: parIdCampoAnno: ID del campo anno da formattare function checkAnno(parIdCampoAnno){ var aa=trim(document.getElementById(parIdCampoAnno).value); if (aa.length==2){ aa = '20' + aa; }else if(aa.length==1){ aa = '200' + aa; } document.getElementById(parIdCampoAnno).value=aa; } // trim (sia a sx sia a destra) //Author: Maurizio Rosso //Version 1.0.0. 21/09/05 function trim(parStringa){ return parStringa.replace(/\s+$|^\s+/g,""); } // disabilita la chiamata del FORM quando premo ENTER in un campo di INPUT. // se evento 13 -> ENTER // ritorna evento 0 -> nessun evento //Author: Marco Damilano //Version 1.0.0. 06/10/2005 function disableEnterKey(e){ if(checkTastoInvio(e)) return false; else return true; } // Funzione checkOra: formatta campo orario nella forma HH:mm // parametri: parIdCampoOrario: ID del campo orario da formattare // parMsgErrore: messaggio di errore function checkOra(parIdCampoOrario, parMsgErrore ){ if (document.getElementById(parIdCampoOrario).readOnly==true){ return true; } var HHmm=document.getElementById(parIdCampoOrario).value; var errore = false; HHmm=HHmm.replace(/\ /g, ''); HHmm=HHmm.replace(/\./g, ''); HHmm=HHmm.replace(/\:/g, ''); HHmm=HHmm.replace(/\,/g, ''); var HH; var mm; HHmm = trim(HHmm); if (HHmm==""){ document.getElementById(parIdCampoOrario).value=""; document.getElementById(parIdCampoOrario).style.backgroundColor=NORMAL_COLOR; document.getElementById(parIdCampoOrario).title=""; return true; } if (HHmm.length>4){ errore = true; } else { if (HHmm.length==4){ HH = HHmm.substr(0,2); mm = HHmm.substr(2,2); } if (HHmm.length==3){ HH = HHmm.substr(0,1); mm = HHmm.substr(1,2); } if (HHmm.length==2){ HH = HHmm.substr(0,2); mm = "00"; } if (HHmm.length==1){ HH = HHmm.substr(0,1); mm = "00"; } if (HHmm.length==0){ HH = "00"; mm = "00"; } if (isNaN(HH) || HH>23){ errore = true; } if (isNaN(mm) || mm>59){ errore = true; } if ( !errore ){ //00:00 non lo lascio inserire, perche' in db corrisponde a null errore = (HH==0 && mm==0); } } if (errore){ document.getElementById(parIdCampoOrario).style.backgroundColor=ERROR_COLOR; document.getElementById(parIdCampoOrario).focus(); document.getElementById(parIdCampoOrario).select(); if (parMsgErrore!=null){ document.getElementById(parIdCampoOrario).title=parMsgErrore; } return false; } else { document.getElementById(parIdCampoOrario).style.backgroundColor=NORMAL_COLOR; document.getElementById(parIdCampoOrario).title=""; if (HH.length==2){ HHmm = HH + ":" + mm; } else { HHmm = "0" + HH + ":" + mm; } document.getElementById(parIdCampoOrario).value=HHmm; return true; } } // Imposta data odierna in formato dd/mm/yyyy function now(){ var oggi = new Date(); var giorno = (oggi.getDate()<10)?giorno='0'+oggi.getDate():giorno=oggi.getDate(); var mese = ((oggi.getMonth())<9)?mese='0'+(oggi.getMonth()+1):mese=(oggi.getMonth()+1); return giorno + '/' + mese + '/' +oggi.getFullYear() ; } // Controlla e Imposta formato data Mese Anno // MM/yyyy // Utilizzato per indicare la scadenza della carta di credito // Author: Marco Damilano // Version 1.0.0. 24/10/2005 function checkDataMeseAnno (parIdCampoData, parMsgErrore){ if (document.getElementById(parIdCampoData).readOnly==true){ return true; } var dataString=document.getElementById(parIdCampoData).value; var mese=""; var anno=""; var errore = false; dataString=dataString.replace(/\ /g, ''); dataString=dataString.replace(/\./g, ''); dataString=dataString.replace(/\-/g, ''); dataString = trim(dataString); if (dataString==""){ document.getElementById(parIdCampoData).value=""; document.getElementById(parIdCampoData).style.backgroundColor=NORMAL_COLOR; document.getElementById(parIdCampoData).title=""; return true; } if (dataString.length<2){ errore=true; } if (dataString.length==3){ mese = "0" + dataString.substr(0,1); anno = dataString.substr(1,2); } if (dataString.length==4){ mese = dataString.substr(0,2); anno = dataString.substr(2,2); } if (dataString.length==5){ mese = dataString.substr(0,2); anno = dataString.substr(3,2); } if (dataString.length==6){ mese = dataString.substr(0,2); anno = dataString.substr(2,4); } if (dataString.length==7){ mese = dataString.substr(0,2); anno = dataString.substr(3,4); } if (isNaN(mese)){ errore = true; } if (isNaN(anno)){ errore = true; } if (mese < 1 || mese > 12){ errore = true; } if (anno.length==2){ anno = "20" + anno; } if (errore){ document.getElementById(parIdCampoData).style.backgroundColor=ERROR_COLOR; document.getElementById(parIdCampoData).focus(); document.getElementById(parIdCampoData).select(); return false; } else { document.getElementById(parIdCampoData).style.backgroundColor=NORMAL_COLOR; document.getElementById(parIdCampoData).title=""; var meseAnno = mese + "/" + anno; document.getElementById(parIdCampoData).value=meseAnno; return true; } } // verifica se un campo hidden e' vuoto e imposta errore su un altro campo (la label visibile) // parametri: // parIdCampo - id del campo da valutare // parColore - colore da impostare // parMsgErrore - messaggio di errore // parSetFocus - true/false - dare o no il focus al campo errato // parTipoCampo - "S/N/I" (Stringa, Numero, Importo) - per determinare se il dato ? vuoto // parTipoPrimoParametro -"I/C" (Id, Campo -> l'oggetto vero e proprio) function checkVuotoHidden( parIdCampoHidden, parIdCampo, parColore, parMsgErrore, parSetFocus, parTipoCampo,parTipoPrimoParametro){ var campo=null; var campoHidden = null; var debugStep = -1; if (parTipoPrimoParametro==null || parTipoPrimoParametro!="C"){ campo=document.getElementById(parIdCampo); campoHidden=document.getElementById(parIdCampoHidden); } else { campo=parIdCampo; campoHidden= parIdCampoHidden } var dataString=campoHidden.value; if( debugStep >= 1){ alert( "checkVuotoHidden.campo" + campo +", checkVuotoHidden.campoHidden" + campoHidden ); alert( "checkVuotoHidden.dataString:"+dataString); } dataString = trim(dataString); var datoVuoto=false; if (parTipoCampo!=null){ // Test per tipologia if (parTipoCampo=="S"){ if (dataString==""){ datoVuoto=true; } } else if (parTipoCampo=="N"){ if (dataString=="0"){ datoVuoto=true; } } else if (parTipoCampo=="I"){ if (dataString=="0,00"){ datoVuoto=true; } } } else if (dataString=="" || dataString=="0" || dataString=="0,00"){ // DA METTERE A POSTO datoVuoto=true; } var retval = false; if (datoVuoto){ campo.style.backgroundColor=parColore; campo.title=parMsgErrore; if (parSetFocus==true){ try{ campo.focus(); } catch(e){ // salta operazione non sicura } } } else { retval = true; } if( debugStep >= 1){ alert( "Bye from checkVuotoHidden, retVal:"+retval ); } return retval; } // verifica se un campo e' vuoto // parametri: // parIdCampo - id del campo da valutare // parColore - colore da impostare // parMsgErrore - messaggio di errore // parSetFocus - true/false - dare o no il focus al campo errato // parTipoCampo - "S/N/I" (Stringa, Numero, Importo) - per determinare se il dato ? vuoto // parTipoPrimoParametro -"I/C" (Id, Campo -> l'oggetto vero e proprio) function checkVuoto (parIdCampo, parColore, parMsgErrore, parSetFocus, parTipoCampo,parTipoPrimoParametro){ return checkVuotoHidden( parIdCampo, parIdCampo, parColore, parMsgErrore, parSetFocus, parTipoCampo, parTipoPrimoParametro ); } //lancia interrogazione Piano dei Conti per Cassa, Banca, Pos(modale per IE, normale altri browser) //Parametri: // parIdCampoNatura: ID campo del chiamante in cui verra' restituita la natura // parIdCampoMastro: ID campo del chiamante in cui verra' restituito il mastro // parIdCampoGruppo: ID campo del chiamante in cui verra' restituito il gruppo // parIdCampoConto: ID campo del chiamante in cui verra' restituito il conto // parIdCampoSottoconto: ID campo del chiamante in cui verra' restituito il sottoconto // parIdCampoDesc: ID campo del chiamante in cui verra' restituita la descrizione // (facoltativo: se passato vuoto, non verra' restituita la descrizione) // parVisSviluppo: visualizza conti con ulteriore sviluppo Y/N //Author: Luca Tonello //Version 1.0.0. 15/06/2005 function callCassaBancaPos(tipologia,parIdCampoNatura, parIdCampoMastro, parIdCampoGruppo, parIdCampoConto, parIdCampoSottoconto, parIdCampoDesc, parVisSviluppo){ var url= '../servlet/serCassaBancaPos?' + 'tipologia=' + tipologia + '&natura=' + document.getElementById(parIdCampoNatura).value + '&mastro=' + document.getElementById(parIdCampoMastro).value + '&gruppo=' + document.getElementById(parIdCampoGruppo).value + '&conto=' + document.getElementById(parIdCampoConto).value + '&sottoconto=' + document.getElementById(parIdCampoSottoconto).value + '&idCampoNatura=' + parIdCampoNatura + '&idCampoMastro=' + parIdCampoMastro + '&idCampoGruppo=' + parIdCampoGruppo + '&idCampoConto=' + parIdCampoConto + '&idCampoSottoconto=' + parIdCampoSottoconto + '&idCampoDesc=' +parIdCampoDesc + '&visSviluppo=' +parVisSviluppo var wdwName = "cassaBancaPos"; var larghezza = 510; var altezza =475; interrPopup(url, wdwName, larghezza, altezza); } //cursore con clessidra per popup function curClessidraPopup(){ if (document.all){ for (var i=0;i < document.all.length; i++){ document.all(i).style.cursor = 'wait'; } } } //cursore con puntatore per popup function curPuntatorePopup(){ if (document.all){ for (var i=0;i < document.all.length; i++){ if (document.all(i).tagName=="A" || (document.all(i).tagName=="IMG" && !(document.all(i).name=='imgAllegato') ) ){ document.all(i).style.cursor = 'hand'; } else { document.all(i).style.cursor = 'default'; } } } } // verifica se un campo ? continene lo slash(/) function checkSlash (parIdCampo, parColore, parMsgErrore1, parMsgErrore2, parSetFocus){ var dataString=document.getElementById(parIdCampo).value; dataString = trim(dataString); // controllo che la stringa abbia lo slash (errore 1) if (dataString.indexOf("/")==-1){ document.getElementById(parIdCampo).style.backgroundColor=parColore; document.getElementById(parIdCampo).title=parMsgErrore1; if (parSetFocus==true){ document.getElementById(parIdCampo).select(); document.getElementById(parIdCampo).focus(); } return false; } else { // controllo che la stringa non sia solo con lo/gli slash (errore 2) if (dataString.substring(0,1)=="/") { document.getElementById(parIdCampo).style.backgroundColor=parColore; document.getElementById(parIdCampo).title=parMsgErrore2; if (parSetFocus==true){ document.getElementById(parIdCampo).select(); document.getElementById(parIdCampo).focus(); } return false; } else { return true; } } } // dato "url" e "wdwName", apre una nuova finestra function oW (url, wdwName){ wdwPopup=window.open (url, wdwName); wdwPopup.focus(); } // Arrotonda alla cifra "quanteCifreDec" il "impDaArrotondare" passato // @param impDaArrotondare // @param quanteCifreDec // @author Maurizio Rosso / Marco Damilano - 22-giu-2006 function arrotonda (impDaArrotondare,quanteCifreDec){ var mult = 10^(quanteCifreDec*1.0); var impArrotondato = Math.round((impDaArrotondare*1.0 + Number.EPSILON) * mult) / mult; return impArrotondato; /*var bigD_Appoggio=new BigDecimal(impDaArrotondare.toString()); var impArrotondato=bigD_Appoggio.setScale(quanteCifreDec, BigDecimal.prototype.ROUND_HALF_UP)*1.0;*/ } //paginazione (nelle ricerche) function paginazione(prForm,prIndice,prAzione){ document.forms[prForm].indice.value=prIndice; abilitaWait(); doSubmit(prForm,prAzione); } //assegna focus function assegnaFocus(prIdCampo){ assegnaFocusObj( document.getElementById(prIdCampo) ); } function assegnaFocusObj( obj ){ assegnaFocusOggetto(obj,true); } function assegnaFocusOggetto(obj,faiSelect){ try{ if( obj != null ){ obj.focus(); if (faiSelect==true){ obj.select(); } } } catch(e){ // salta operazione non sicura } } //conferma cancellazione function confermaCancellazione(prServletCall,prMessaggio){ if (confirm(prMessaggio)) { document.location.href=prServletCall; } } //ripulisce campo value function ripulisciCampo(prIdCampo){ document.getElementById(prIdCampo).value=""; } // imposta il colore ed il titolo ricevendo in input l'ID del campo. // Se non vengono passati, imposta: // - colore: NORMAL_COLOR // - titolo: "" function impostaColorTitle(prIdCampo, colore, titolo){ if (colore==null){ document.getElementById(prIdCampo).style.backgroundColor=NORMAL_COLOR; } else { document.getElementById(prIdCampo).style.backgroundColor=colore; } if (titolo==null){ document.getElementById(prIdCampo).title=""; } else { document.getElementById(prIdCampo).title=titolo; } } function impostaColorTitleAlert(prIdCampo, colore, titolo){ impostaColorTitle( prIdCampo, colore, titolo ); alert( titolo ); } // imposta il colore ed il titolo ricevendo in input il campo( l'oggetto vero e proprio). // Se non vengono passati, imposta: // - colore: NORMAL_COLOR // - titolo: "" function impostaColorTitleCampo(campo, colore, titolo){ if (colore==null){ campo.style.backgroundColor=NORMAL_COLOR; } else { campo.style.backgroundColor=colore; } if (titolo==null){ campo.title=""; } else { campo.title=titolo; } } //ripulisci codice e relativa descrizione (per i campi cod+descrizione) function ripulisciCod_and_Desc(prIdCampoCod, prIdCampoDes){ impostaColorTitle(prIdCampoCod); ripulisciCampo(prIdCampoDes); } //cambia stato function cambiaStato(prIdImage,prIdStato){ if (document.getElementById(prIdStato).value==""){ imageChange(prIdImage,'../image/icoSospesoB.png'); document.images[prIdImage].title="Sospeso"; document.getElementById(prIdStato).value = "S"; } else if (document.getElementById(prIdStato).value=="S"){ imageChange(prIdImage,'../image/icoAnnullatoB.png'); document.images[prIdImage].title="Annullato"; document.getElementById(prIdStato).value = "A"; } else if (document.getElementById(prIdStato).value=="A"){ imageChange(prIdImage,'../image/icoAttivoB.png'); document.images[prIdImage].title="Attivo"; document.getElementById(prIdStato).value = ""; } } // // allinea stringa a destra //@param stringa da allineare //@param lunghezza massima stringa //@return stringa allineata a destra //@author Rosso Maurizio // function allineaDx(parStringa, parLung, parSoloStringaCarica) { var stringaDx =""; var lunghezza=0; var i=0; if(parStringa!="" || (parSoloStringaCarica!=null && !parSoloStringaCarica)){ parStringa=trim(parStringa); lunghezza=parStringa.length; if (lunghezza == parLung){ stringaDx=parStringa; } else { for (i=lunghezza; iMAX_LEN){ document.getElementById(parIdRagSocBreve).value = document.getElementById(parIdRagSoc).value.substr(0,MAX_LEN); } else { document.getElementById(parIdRagSocBreve).value = document.getElementById(parIdRagSoc).value; } } } /*====================================================================================* Verifica se un campo contiente almeno n caratteri @param parIdCampo: ID del campo su cui effettuare la verifica @param parNumChar: numero caratteri minimo @param parSetFocus: se true e test negativo, ritorna il Fosus sul campo testato @return true, se contiene almeno n caratteri; false, altrimenti. *====================================================================================*/ function checkMinCharacters (parIdCampo, parNumChar, parMsgError, parSetFocus){ var dataString = document.getElementById(parIdCampo).value; dataString = trim(dataString); if (dataString.length > 0 && dataString.length < parNumChar){ document.getElementById(parIdCampo).style.backgroundColor = ERROR_COLOR; document.getElementById(parIdCampo).title = parMsgError; if (parSetFocus==true){ document.getElementById(parIdCampo).focus(); } return false; } else { return true; } } /*=====================================================================================* * divInt: Divisione intera * * @param parDividendo: dividendo * * @param parDivisore: divisore * * @return Quoziente intero divisione * *=====================================================================================*/ function divInt (parDividendo, parDivisore) { var quoziente = 0; var temp = parDividendo; while (temp >= parDivisore) { temp = temp - parDivisore; quoziente++; } return quoziente; } /*=====================================================================================* checkPartitaIva: Verifica la validita' della Partita IVA (solo ITALIA) @param parIdCampo: ID del campo contenente la PARTITA IVA @param parColore: colore per la segnalazione dell'errore @param parMsgErrore: messaggio per la segnalazione dell'errore @param parSetFocus: true --> focus su campo se errato @return true: se la partita IVA ? valida , false in caso contrario @author Marco Rosa - 09.01.2006 NOTA: necessaria function javascript divInt (v. sopra) *=====================================================================================*/ function checkPartitaIva(parIdCampo, parColore, parMsgErrore, parSetFocus){ var ret = true; var tot = 0; var indice = 0; var numTemp = 0 var partitaIva = document.getElementById(parIdCampo).value; // Prerequisito: // PartitaIva --> NUMERICO (11) if ((partitaIva.length != 11) || (isNaN(partitaIva))){ ret = false; } else { // Somma le 5 posizioni dispari (eccetto la 11 che e' un // carattere di controllo) while (indice < 10) { tot = tot + parseInt(partitaIva.substr(indice, 1)); indice = indice + 2; } /* posizioni pari */ indice = 1; while (indice < 10) { // raddoppia ogni singola posizione pari... numTemp = parseInt(partitaIva.substr(indice, 1)) * 2; // ...aggiunge numTemp alla somma delle dispari // Se numTemp e' maggiore di 10, viene ridotta // alla somma della parte delle decine e delle // unita' (es: 15 diventa 1+5) tot = tot + divInt(numTemp,10) + (numTemp % 10); indice = indice + 2; } numTemp = tot; if (((numTemp % 10 == 0) && (parseInt(partitaIva.substr(10, 1)) == 0)) || (10 - (numTemp % 10) == parseInt(partitaIva.substr(10, 1)))) { ret = true; } else { ret = false; } } if(!ret){ document.getElementById(parIdCampo).style.backgroundColor=parColore; document.getElementById(parIdCampo).title=parMsgErrore; if (parSetFocus==true){ document.getElementById(parIdCampo).focus(); } } return ret; } /**=====================================================================================* checkCodiceFiscale: Verifica la validita' del Codice Fiscale @param parIdCampo: ID del campo contenente il CODICE FISCALE @param parColore: colore per la segnalazione dell'errore @param parMsgErrore: messaggio per la segnalazione dell'errore @param parSetFocus: true --> focus su campo se errato @return true: se il Codice Fiscale ? valido, false in caso contrario @author Marco Rosa - 09.01.2006 Osservazioni: E' composto da 16 caratteri alfanumerici. L'ultimo carattere ? il codice di controllo che vogliamo verificare. *=====================================================================================*/ function checkCodiceFiscale(parIdCampo, parColore, parMsgErrore, parSetFocus) { var ret = true; var charValidi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; var indice = 0; var var_temp = 0; var set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ"; var setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; var setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX"; var debugStep = -1; var codFiscale = document.getElementById(parIdCampo).value; codFiscale = codFiscale.toUpperCase(); // Prerequisito: // CodFiscale --> ALFANUMERICO (16) if (codFiscale.length != 16){ if( debugStep>=1 ){ alert( "codFiscale.length != 16" ); } ret = false; } else { for( indice = 0; indice < 16; indice++ ){ if( charValidi.indexOf( codFiscale.charAt(indice) ) == -1 ){ if( debugStep>=1 ){ if( debugStep>=1 ){ alert( "charValidi.indexOf( codFiscale.charAt(indice) ) == -1 " ); } } ret = false; } } var_temp = 0; for( indice = 1; indice <= 13; indice += 2 ){ var_temp += setpari.indexOf( set2.charAt( set1.indexOf( codFiscale.charAt(indice) ))); } for( indice = 0; indice <= 14; indice += 2 ){ var_temp += setdisp.indexOf( set2.charAt( set1.indexOf( codFiscale.charAt(indice) ))); } if( var_temp%26 != codFiscale.charCodeAt(15)-'A'.charCodeAt(0) ){ //ultimo carattere e' di parita' non mettere a' if( debugStep>=1 ){ alert( "var_temp%26="+(var_temp%26)+" != codFiscale.charCodeAt(15)-'A'.charCodeAt(0)="+(codFiscale.charCodeAt(15)-'A'.charCodeAt(0)) ); } ret = false; } } if(!ret){ document.getElementById(parIdCampo).style.backgroundColor=parColore; document.getElementById(parIdCampo).title=parMsgErrore; if (parSetFocus==true){ document.getElementById(parIdCampo).focus(); } } return ret; } /*====================================================================================* * Aggiorna, se vuoto, parIdCampo2 con il valore di parIdCampo1 troncandolo alla * * lunghezza specificata (parIdLength) * *====================================================================================*/ function cpyCampo1ToCampo2 (parIdCampo1,parIdCampo2,parIdLength){ impostaColorTitle(parIdCampo2,NORMAL_COLOR); if(document.getElementById(parIdCampo2).value==''){ if (document.getElementById(parIdCampo1).value.length>parIdLength){ document.getElementById(parIdCampo2).value = document.getElementById(parIdCampo1).value.substr(0,parIdLength); } else { document.getElementById(parIdCampo2).value = document.getElementById(parIdCampo1).value; } } } // Date due Stringhe(alfanumeriche) determina quale delle due ? la maggiore // Logica: LETTERA < NUMERO // Le LETTERE sono minori dei NUMERI in base a esigenze di DB // Restituisce TRUE se str1 <= str2 function cmpStr(str1,str2){ var lenStr = str1.length; var isOk = true; var indice = 0; var char1 = ''; var char2 = ''; for (indice=0;indice char2){ isOk = false; } if (char1 < char2){ break; } } } else { if (isNaN(char2)){ isOk = false; } else { if(char1 > char2){ isOk = false; } if (char1 < char2){ break; } } } } return isOk; } //Funzione checkIntero: testa se la stringa in input e' un intero: restituisce "true" se intero, "false" altrimenti // parametri: parIdCampoNumero: ID del campo da controllare // parMsgErrore: messaggio di errore in caso di campo non intero // parTipoPrimoParametro -"I/C" (Id, Campo -> l'oggetto vero e proprio) //Author: Alessandro Rossi //Version 1.0.0. 23-apr-2007 //********** // si pu? usare per testare i campi numerici che non devono essere formattati infatti: // - trimma il campo che riceve (cos? da togliere i caratteri vuoti davanti o dietro il numero) // - se riceve una stringa vuota, imposta il valore ZERO function checkIntero(parIdCampoNumero,parMsgErrore,parTipoPrimoParametro ){ var campo=null; if (parTipoPrimoParametro==null || parTipoPrimoParametro!="C"){ campo=document.getElementById(parIdCampoNumero); } else { campo=parIdCampoNumero; } // se campo readOnly (non editabile), allora non faccio il controllo if (campo.readOnly==true){ return true; } // imposto il numero senza spazi var tmpStringa=campo.value; tmpStringa=trim(tmpStringa); // se il numero ? vuoto, imposto ZERO if (tmpStringa=="") { campo.value="0"; } else { campo.value=tmpStringa; } flIntero = true; validi = "0123456789"; for( i = 0; i < campo.value.length; i++ ){ if( validi.indexOf( campo.value.charAt(i) ) == -1 ) flIntero = false; } if (flIntero){ campo.style.backgroundColor=NORMAL_COLOR; campo.title=""; return true; } else { campo.style.backgroundColor=ERROR_COLOR; campo.focus(); campo.select(); campo.title=parMsgErrore; return false; } } //Funzione strReplaceAll: //Sostituisce, all'interno di un testo, tutte le occorrenze di un certa stringa con un' altra. //parametri: // parStringa: stringa da controllare per la sostituzione; // parStrOld: occorrenza attuale che verr? sostituita; // parStrNew: occorrenza da sostituire; //********************************************************************* // parFlags: 'g' for a global match; // 'i' to ignore case; // 'gi' for a case-insensitive global match. //********************************************************************* //Author: Alessandro Rossi //Version 1.0.0. 24-apr-2007 //********** function strReplaceAll(parStringa, parStrOld, parStrNew, parFlags){ if (parStringa!=""){ RE = new RegExp(parStrOld, parFlags); //RE -> espressione regolare; parStringa = parStringa.replace(RE, parStrNew); return parStringa; } } //Selezione deseleziona check su form //Nome form //Nome checkbox //Azione: 0 seleziona - 1 deseleziona //Tonello Luca function selDesAll(prForm,prNome,prOperazione){ var modulo = document.getElementById(prForm).elements; for (i=0; i millisecondi){ sleeping = false; } } } //lancia popUp per la gestione elenco clienti con Fido || MODIFICA X VENTURA //(modale per IE, normale altri browser) //Author: Alessandro Rossi //Version 1.0.1. 22/05/2007 function callEleClientiFido(){ var url= '../servlet/serEleClientiFido'; var larghezza = 900 var altezza =763; interrPopup(url, "eleClientiFido", larghezza, altezza); } function getKeyCode( e ){ var debugStep = -1; var retVal = false; e = (e) ? e : window.event; var keyCode; if (e!=null){ keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode; //alert( keyCode ); if( debugStep >= 1 ){ alert( keyCode ); } } else { keyCode=""; } return keyCode; } //controlla che il carattere inserito sia uguale al parametro specificato function checkTastoKeyCode( e, key ) { retVal = getKeyCode( e ) == key; return retVal; } //controlla che il carattere inserito sia uguale ad un carattere di cancellazione (canc o del) function checkTastoCancOrDel( e ){ return checkTastoKeyCode( e, 8 ) || checkTastoKeyCode( e, 46 ); } function checkTastoSpostamento( e ){ return checkTastoKeyCode( e, 33 ) //pag giu' || checkTastoKeyCode( e, 34 ) //pag giu' || checkTastoKeyCode( e, 35 ) //fine || checkTastoKeyCode( e, 37 ) //home || checkTastoKeyCode( e, 37 ) //freccia sx || checkTastoKeyCode( e, 38 ) //freccia su || checkTastoKeyCode( e, 39 ) //freccia dx || checkTastoKeyCode( e, 40 ) //freccia dx ; } function checkTastoFunzione( e ){ var tastoFunzione = false; var keyCode = getKeyCode( e ); if( keyCode >= 112 && keyCode<=123 ){//da F1 a F12 return true; } return false; } function checkTastoModificatore( e ){ return checkTastoKeyCode( e, 19 ) //BREAK || checkTastoKeyCode( e, 20 ) //CAPS LOCK || checkTastoKeyCode( e, 27 ) //ESCAPE || checkTastoKeyCode( e, 45 ) //ins || checkTastoKeyCode( e, 144 ) //NUM LOCK || checkTastoKeyCode( e, 145 ) //SCROLL LOCK ; } function checkTastoStampabile( e ){ return !checkTastoModificatore( e ) && !checkTastoFunzione( e ) && !checkTastoSpostamento( e ) && !checkTastoCancOrDel( e ); } //controlla che il carattere inserito sia corrisponde all' INVIO function checkTastoInvio( e ) { return checkTastoKeyCode( e, 13 ); } // Interrogazione tabella CRM Tipi Reclami (modale per IE, normale altri browser) // // Parametri: // parIdCampoCod: ID campo del chiamante in cui verra' restituito il codice // parIdCampoDesc: ID campo del chiamante in cui verra' restituita la descrizione // (facoltativo: se passato vuoto, non verra' restituita la descrizione) // parTitolo: titolo della finestra popup // function callIntTipiReclami(parIdCampoCod, parIdCampoDesc, parTitolo){ var url= '../servlet/serIntTipiReclami' + '?codice=' + document.getElementById(parIdCampoCod).value + '&idCampoCod=' + parIdCampoCod + '&idCampoDesc=' + parIdCampoDesc + '&titolo=' + parTitolo var wdwName = parTitolo.replace(/ /g, ''); var larghezza = 410 var altezza =440; interrPopup(url, wdwName, larghezza, altezza); } function getSelectedValFromCombo( combo ){ var i=0; var selectedVal=""; for (i=0; i= 20030210); } function isNetscape7() { return (navigator.userAgent.toLowerCase().indexOf("netscape") != -1 && navigator.userAgent.toLowerCase().indexOf("7.") != -1); } function isSafari() { return (navigator.userAgent.toLowerCase().indexOf("khtml") != -1); } function isOpera() { return (navigator.userAgent.toLowerCase().indexOf("opera") != -1); } //gestione options in un select function removeAllOptions( sel ){ //alert( "removeAllOptions" ); sel.options.length=0; } function removeAllOptionsId( idSelect ){ var sel = document.getElementById( idSelect ); //alert( "removeAllOptionsId:" + idSelect+","+sel ); removeAllOptions( sel ); } function removeAllOptionsFromVal( sel, val ){ if( sel != null ){ var i=0; for( i=0; i< sel.options.length; i++ ){ if( sel.options[i].value == val ){ sel.options.length= i; break; } } } } function addOption( sel, value, text, newSelected ){ //creo nuova opzione che aggiunge alla lista: //alert( "addOption" ); if( sel != null ){ var nOp = new Option(text,value); sel.options[sel.length]=nOp; sel.options[sel.length-1].selected= newSelected; } } function addOptionId( idSelect, value, text, newSelected ){ //e aggiunta alla lista: //alert( "addOptionId" ); var sel = document.getElementById( idSelect ); addOption( sel, value, text, newSelected ); } /* Returns the value of the input element of id given in the current document. Multiple values (check-box, select-multi) are comma separated (to match the value in db) */ function getValueOfId( id, text ){ return getValueOfIdInDocument( document, id, text ); } /* Returns the value of the input element of id given in given document. Multiple values (check-box, select-multi) are comma separated (to match the value in db) */ function getValueOfIdInDocument( which_document, id, text ){ if( id == null || id== '' ){ return ''; } var debugStep = -1; if( debugStep >= 1 ){ alert( "getValueOfIdInDocument( "+ which_document + "," + id +")" ); } var inputEl = which_document.getElementById( id ); var type = inputEl.type; var val =''; if( debugStep >= 1 ){ alert( "inputEl.type:"+type ); } if( type == 'text' || type == 'hidden' || type == 'textarea' ){ val = inputEl.value; }else if( type == 'select-one' || type == 'select-multiple' ){ var i=0; for (i=0; i < inputEl.options.length; i++) { if ( inputEl.options[i].selected ){ if( val != '' ){ val+=','; } if( text == true ){//to get the visible label instead of the invisible value! val += inputEl.options[i].text; }else{ val += inputEl.options[i].value; } if( type == 'select-one' ){ break; } } } }else if( type == 'radio' || type == 'checkbox' ){ if( debugStep > 1 ){ alert( "Radio" ); } //devo recuperare tra tutti gli input id dato e restituire il valore di quello impostato. //perche' con getElementById dalle prove fatte individuo solo un radio button var lista_input = which_document.forms[0].elements; var i=0; for(i=0; i < lista_input.length; i++){ if( lista_input.item(i).id == id){ if( debugStep > 1 ){ alert( id +"["+ i+"]"+ lista_input.item(i).value ); alert( id +"["+ i+"]"+ lista_input.item(i).checked ); } if(lista_input.item(i).checked ){ //alert( lista_input.item(i).getAttribute("id") + "checked" + i ); if( val != '' ){ val += ','; } val += lista_input.item(i).value; if( type == 'radio' ){ break; } } } } /* in questo modo dovrei avere il nome del radio button, l'id mi indiviuda solo il primo della lista var radioLength = inputEl.length; if( debugStep == 1 ){ alert( "radioLength:"+radioLength ); } if(radioLength == undefined){ if(inputEl.checked){ if( debugStep >= 1 ){ alert( "Checked:" + inputEl.value ); } val = inputEl.value; }else{ val = ""; } }else{ var i; for(i = 0; i < radioLength; i++) { alert( 'Checked['+i+']:' + inputEl[i].checked ); if(inputEl[i].checked) { val= inputEl[i].value; } } }*/ } if( debugStep >= 1 ){ alert( "getValueOfId("+id+") val:"+val ); } return val; } /* Sets the value of the input element of id given in the current document. Multiple values (check-box, select-multi) are comma separated (to match the value in db) */ function setValueOfId( id, newVal ){ setValueOfIdInDocument( document, id, newVal ); } /* Sets the value of the input element of id given in the given document. Multiple values (check-box, select-multi) are comma separated (to match the value in db) */ function setValueOfIdInDocument( which_document, id, newVal ){ var debugStep = -1; if( debugStep >= 1 ){ alert( "setValueOfId( " + id +","+newVal +")" ); } var inputEl = which_document.getElementById( id ); var type = inputEl.type; var vals = new Array(); vals = newVal.split(","); if( debugStep >= 1 ){ alert( "inputEl.type:"+type ); } if( type == 'text' || type == 'hidden' || type == 'textarea' ){ inputEl.value = newVal ; }else if( type == 'select-one' || type == 'select-multiple' ){ var i,j; for (i=0; i < inputEl.options.length; i++) { var newOptionIndex=-1; for(j=0; j< vals.length; j++ ){ if ( inputEl.options[i].value == vals[j] ){ inputEl.options[i].selected = true; newOptionIndex=i; }else{ inputEl.options[i].selected = false; } } // imposto il nuovo index if (newOptionIndex!=-1){ inputEl.options.selectedIndex=newOptionIndex; } } }else if( type == 'radio' || type == 'checkbox' ){ if( debugStep > 1 ){ alert( "Radio" ); } //devo recuperare tra tutti gli input id dato e restituire il valore di quello impostato. //perche' con getElementById dalle prove fatte individuo solo un radio button var lista_input = which_document.forms[0].elements; var i,j; for(i=0; i < lista_input.length; i++){ if( lista_input.item(i).id == id){ if( debugStep > 1 ){ alert( id +"["+ i+"]"+ lista_input.item(i).value ); alert( id +"["+ i+"]"+ lista_input.item(i).checked ); } for(j=0; j< vals.length; j++ ){ if ( lista_input.item(i).value == vals[j] ){ lista_input.item(i).checked = true; }else{ lista_input.item(i).checked = false; } } } } } } /** true if the old and current value are different */ function chkModificato( idTxt, idOld ){ var debugStep = -1; var valTxt = getValueOfId( idTxt ); var valOld = getValueOfId( idOld ); return valTxt != valOld ; } /* true if there are uncommitted changes that would be lost */ function tralasciaModificheCampiDin( numCampi, nomeBase ){ var i, id; var debugStep = -1; var modificato = 0; var rows = new Array(); if( debugStep == 1 ){ alert( "controllo se ci sono modifiche!"); } for( i=0; i< numCampi ; i ++ ){ fieldNameRefId = nomeBase + "_"+ i; id = document.getElementById( fieldNameRefId ).value; if( chkModificato( id, "old_" + id ) ){ rows[modificato] = "label_" + id; if( debugStep == 1 ){ alert("Modificato " + rows[modificato] ); } modificato ++; } } continua = true; if( modificato > 0 ){ impostaErroreIdV( rows, '' ); continua = confirm( 'Ci sono modifiche non salvate continuare?' ); pulisciErrore(); } if( debugStep == 1 ){ alert( "Continua:"+continua ); } return continua; } function getEventField( e ){ var debugStep = -1; var field=null; if(e) { if( debugStep >= 1 ){ alert( "e:" + e ); alert( "e.target:" + e.target ); } if( e.target ){ field= e.target; } } if( field === null ){ if( debugStep >= 1 ){ alert( "window.event:" + window.event ); alert( "window.event.srcElement:" + window.event.srcElement ); } field = window.event.srcElement; } return field; } function maxLength(e,maxChars, msg) { var field = getEventField( e ); //se voglio inserire (non canc e delete): if( checkTastoStampabile( e ) ){ //field.value.length is the number of characters WITHOUT the one to be added right now if(field.value.length >= parseInt(maxChars) ) { alert(msg); e.returnValue=false; return false; } } } function maxLengthPaste(e,maxChars, msg ) { e.returnValue=false; var field= getEventField( e ); if( checkTastoStampabile( e ) ){ if((field.value.length + window.clipboardData.getData("Text").length) > parseInt(maxChars)) { alert(msg); return false; } } e.returnValue=true; } // Rende selezionato l'importo, quando si fa click sul campo // per permettere un'immediata modifica. // RICHIEDE: l'elemento cliccato deve avere l'id // autore: Marco Damilano - 21 giu 2007 function focusSuCampo(evt) { // l'evento su Firefox o su IE evt = (evt) ? evt : ((window.event) ? window.event : "") if (evt) { // l'elemento su Firefox o su IE var elem = (evt.target) ? evt.target : evt.srcElement assegnaFocus(elem.id); } } function getCurDate(){ var now = new Date(); var day = ''+ now.getDate(); if( day.length ==1 ){ day = '0'+day; } var month = ''+now.getMonth(); if( month.length == 1 ){ month = '0'+month; } return day+"/"+ month +"/"+ now.getFullYear(); } function callIntAzioni( tipRefFisso, idRef, operatore, statoEx ){ var debugStep=-1; var url = '../servlet/serAzioneCrm?azione=Mostra' if( tipRefFisso!= '' ){ url+= '&txtTipRifFisso='+tipRefFisso; } if( idRef != '' ){ url+= '&txtIdRifFisso='+idRef; } if( operatore!='' ){ url+= '&txtSearchOpExe='+operatore; } if( statoEx!='' ){ url+= '&txtSearchStatoEx='+statoEx; } url +='&displayMode=NO&vismod=M&callDa=POPUP'; if( debugStep >= 1 ){ alert(url); } var wdwName; wdwName = "popUpCliCrm"; larghezza = 640; altezza =510; var barreScorr='N'; interrPopup(url, wdwName, larghezza, altezza, barreScorr); } function getCurTime(){ var now = new Date(); var hh = ''+now.getHours(); if( hh.length== 1 ){ hh = '0'+hh; } var mm = ''+now.getMinutes(); if( mm.length == 1 ){ mm = 0+mm; } return oraEnd = hh +":"+ mm; } //Imposta il focus sul primo campo non hidden e con onfocus ed onload null nel documento //per la gestione del tasto invio su conferma e ricerca //Parametri: // parDocumentoAttuale: documento //Author: Alessandro Servetti //Version 1.0.0. 11/10/2007 function focusSuPrimoCampoInput(prDocumentoAttuale){ var elencoInput = prDocumentoAttuale.getElementsByTagName('INPUT'); var primoElemento=null; if(elencoInput!=null && elencoInput.length>0){ for(indE=0;indE v1==v2 elemento per elemento (null e vettori vuoti comresi conpresi) */ function confrontaArray(v1,v2 ){ var debugStep = -1; var differenza=0; if( v1 == null && v2 == null ){ return differenza;/// opinabile! }else{ if( v1!= null && v2!= null ){ if( v1.length != v2.length ){ differenza = v1.length - v2.length ; }else{ if( debugStep >= 2){ alert( "v1.length:"+ v1.length ); } for(i=0; i < v1.length; i++){ var v1esaminando = v1[i]; var v2esaminando = v2[i]; if( debugStep>=2 ){ alert( "v1["+i+"]:'" +v1[i] +"'\nv2["+i+"]:'" + v2[i]+"'" ); } if( v1esaminando != v2esaminando ){ differenza++; } } } }else{ if( v1 == null ){ differenza = -v2.length; }else{ //v2 == null differeza = v1.length; } } } if( debugStep>=1 ){ alert( "differenza:"+differenza ); } return differenza; } function datiModificati( which_document, vToBeExcluded, vIniziali ){ var vAttuali = salvaDatiInDocument( which_document, vToBeExcluded ); modificati = false; if( confrontaArray( vAttuali, vIniziali ) != 0 ){ modificati = true; } return modificati; } //this function opens a pop-up to insert the field of the table of the table form row //Parametri: // parIdCampoTabellaOrigine: ID campo del chiamante in cui c'e' la tabella di interesse // parIdCampoCampoOrigine: ID campo del chiamante in cui verra' restituito il campo // parIdLabelCampoCampoOrigine: ID campo del chiamante in cui verra' restituito la descrizione del campo // parIdCampoValoriOrigine: ID campo del chiamante contenente i Valori che verra' spianato // parIdLabelCampoValoriOrigine: ID campo del chiamante contenente le descrizioni dei Valori che verra' spianato //Author: Bartolomeo Nicolotti //Version 1.0.0. 13/04/2007 function callIntInsField( parIdCampoTabellaOrigine, parIdCampoCampoOrigine, parIdLabelCampoCampoOrigine, parIdCampoValoriOrigine, parIdLabelCampoValoriOrigine ) { var debugStep = -1; if( debugStep == 0 ){ alert( "callIntInsField : Hullo!\n" ); } //prendo la tabella di cui elencare i campi in pop-up: var tabellaOrigine = document.getElementById(parIdCampoTabellaOrigine).value; var campoOrigine = document.getElementById(parIdCampoCampoOrigine).value; //spiano campo e valori: //document.getElementById(parIdCampoCampoOrigine).value = ''; //document.getElementById(parIdLabelCampoCampoOrigine).value = ''; //document.getElementById(parIdCampoValoriOrigine).value = ''; //document.getElementById(parIdLabelCampoValoriOrigine).value = ''; if( debugStep == 0 ){ alert( "Spianato!\n" ); } var url= '../servlet/serSelCriCamCrm?' + 'tabellaOrigine=' + tabellaOrigine + '&idTabellaOrigine=' + parIdCampoTabellaOrigine + '&campoOrigine=' + campoOrigine + '&idCampoOrigine=' + parIdCampoCampoOrigine + '&idLabelCampoOrigine=' + parIdLabelCampoCampoOrigine + '&idValoriOrigine=' + parIdCampoValoriOrigine + '&idLabelValoriOrigine=' + parIdLabelCampoValoriOrigine; if( debugStep == 0 ){ alert( "callIntInsField : \n" + url ); } var wdwName; wdwName = "popUpCliCrm"; var larghezza = ""; var altezza = ""; larghezza = 400; altezza =200; var barreScorr='N'; interrPopup(url, wdwName, larghezza, altezza, barreScorr); } //this function opens a pop-up to insert the field of the table of the table form row //Parametri: // parIdCampoTabellaOrigine: ID campo del chiamante in cui c'e' la tabella di interesse // parIdCampoCampoOrigine: ID campo del chiamante in cui verra' restituito il campo // parIdLabelCampoCampoOrigine: ID campo del chiamante in cui verra' restituito la descrizione del campo // parIdCampoValoriOrigine: ID campo del chiamante contenente i Valori che verra' spianato // parIdLabelCampoValoriOrigine: ID campo del chiamante contenente le descrizioni dei Valori che verra' spianato //Author: Bartolomeo Nicolotti //Version 1.0.0. 13/04/2007 function callIntInsVals( parIdCampoTabellaOrigine, parIdCampoCampoOrigine, parIdLabelCampoCampoOrigine, parIdCampoOperatoreOrigine, parIdCampoValoriOrigine, parIdLabelCampoValoriOrigine ) { var debugStep = -1; if( debugStep == 1 ){ alert( "callIntInsVals : Hullo!\n" ); } //prendo la tabella e il campo di cui elencare i valori in pop-up: var tabellaOrigine = document.getElementById( parIdCampoTabellaOrigine ).value; var campoOrigine = document.getElementById( parIdCampoCampoOrigine ).value; var operatoreOrigine = document.getElementById( parIdCampoOperatoreOrigine ).value; var valoriOrigine = document.getElementById( parIdCampoValoriOrigine ).value; if( debugStep == 1 ){ alert( 'Op:'+ operatoreOrigine ); } if( campoOrigine == '' || campoOrigine == null ){ impostaColorTitle( parIdLabelCampoCampoOrigine, ERROR_COLOR, "Impostare prima campo" ); return; } //spiano valori: //dal popup: document.getElementById(parIdCampoValoriOrigine).value = ''; //dal popup: document.getElementById(parIdLabelCampoValoriOrigine).value = ''; if( debugStep == 1 ){ alert( "Spianato!\n" ); } var url= '../servlet/serSelCriValCrm?' + 'tabellaOrigine=' + tabellaOrigine + '&campoOrigine=' + campoOrigine + '&operatoreOrigine=' + operatoreOrigine + '&valoriOrigine=' + encodeURIComponent(valoriOrigine) //occhio che puo' esserci & + '&idTabellaOrigine=' + parIdCampoTabellaOrigine + '&idCampoOrigine=' + parIdCampoCampoOrigine + '&idLabelCampoOrigine=' + parIdLabelCampoCampoOrigine + '&idValoriOrigine=' + parIdCampoValoriOrigine + '&idLabelValoriOrigine=' + parIdLabelCampoValoriOrigine; if( debugStep == 1 ){ alert( "callIntInsField : \n" + url ); } var wdwName; wdwName = "popUpCliCrm"; var larghezza = ""; var altezza = ""; larghezza = 400; altezza =200; var barreScorr='N'; interrPopup(url, wdwName, larghezza, altezza, barreScorr); } function warningBLANK( idOp, idVal ){ var debugStep = -1; if( debugStep == 1 ){ alert( "idOp:"+idOp ); alert( "idVal:"+idVal ); } var val = document.getElementById( idVal ).value; var op = document.getElementById( idOp ).value; if( debugStep == 1 ){ alert( "op:"+op ); } var retVal = true; if( val=='*BLANK' ){ if( op == '<%=SelCriTree.containOpStr%>' || op == '<%=SelCriTree.nlikeOpStr%>' || op == '<%=SelCriTree.startOpStr%>' || op == '<%=SelCriTree.endOpStr%>' ){ impostaColorTitle( idVal, ERROR_COLOR, '<%= labelXML.getLabel("*BLANK NON CONSENTITO SE OP.CONFRONTO Contiene, Non contiene, Inizia per e Finisce per")%>' ); retVal = false; }else{ impostaColorTitle( idVal, WARNING_COLOR, '<%= labelXML.getLabel("Attenzione, si potrebbero avere molti risultati!")%>' ); } }else{ impostaNormaleId( idVal ); } return retVal; } /** * cancella una riga del criterio di selezione CRM (selcriCrm.jsp) e del filtro risultati (selresCrm.jsp). Chiamata generata da EleSelCriCrm.java */ function spianaRiga( parIdCampoCampoOrigine, parIdLabelCampoCampoOrigine, parIdCampoValoriOrigine, parIdLabelCampoValoriOrigine, parIdCampoConfrontoOrigine ){ document.getElementById(parIdCampoCampoOrigine).value = ''; document.getElementById(parIdLabelCampoCampoOrigine).value = ''; document.getElementById(parIdCampoValoriOrigine).value = ''; document.getElementById(parIdLabelCampoValoriOrigine).value = ''; setValueOfId( parIdCampoConfrontoOrigine, '' ); } function dataInIntervalloValido( idParData, shiftDay, valid_date, message ){ //data inizio 3gg da oggi var shiftDay = shiftDay; var today = new Date(); var dataInizio = new Date(); var dataPossibile = new Date(); //shiftDay in ms var shiftTime = shiftDay * 24 * 60 * 60 * 1000; dataInizio.setTime( today.getTime() + shiftTime );//shitfDaty==1 => dataInizio is tomorrow var addTime = 0; if( shiftDay > 0 ){ //shiftDay == 1 => dataPossibile is the day after tomorrow: addTime is 2 days addTime = shiftDay * 24 * 60 * 60 * 1000; }else{ //shiftDay == 0 => dataPossibile is today: addTime:0 } dataPossibile.setTime( today.getTime() + addTime ); //data fine 31/10/2009 var dataFine = parseDataDDMMYYYY(valid_date); var parDataDate = parseDataDDMMYYYY( getValueOfId( idParData ) ); var debugStep =-1; if( debugStep>= 1 ){ alert( "dataInIntervalloValido.dataInizio:" + dataInizio.toDateString() ); alert( "dataInIntervalloValido.dataFine:" + dataFine.toDateString() ); alert( "dataInIntervalloValido.parDataDate:" + parDataDate.toDateString() ); } var retVal = false; if(message === undefined || message === null || message == ''){ var message = 'Per Prenotazioni Online la data deve essere compresa tra \n ' + dataPossibile.toDateString() + ' e ' + dataFine.toDateString() + '\n\nContattateci telefonicamente'; }else{ message = message.replace("%beginPeriod%", dataPossibile.toDateString()); message = message.replace("%endPeriod%", dataFine.toDateString()); } /* Quando si vuol prenotare anche per il giorno stesso, è possibile che si prenoti il mattino per l'immediato pomeriggio per cui il test deve essere fatto per <= LIVIO 25-07-11 per kenobi*/ dataInizio.setHours(0); dataInizio.setMinutes(0); dataInizio.setSeconds(0); dataInizio.setMilliseconds(0); if( dataInizio <= parDataDate && parDataDate <= dataFine ){ retVal = true; }else{ impostaColorTitleAlert( idParData, ERROR_COLOR, message); } if( debugStep>= 1 ){ alert( "dataInIntervalloValido.retVal:" + retVal ); } return retVal; } function parseDataDDMMYYYY( parData ){ var parDataSplit = parData.split(/-|\//); var dd = parDataSplit[0]; var mm = parDataSplit[1]; var yyyy = parDataSplit[2]; var mesi = new Array(); var i=0; mesi[i++]= 'Jan'; mesi[i++]= 'Feb'; mesi[i++]= 'Mar'; mesi[i++]= 'Apr'; mesi[i++]= 'May'; mesi[i++]= 'Jun'; mesi[i++]= 'Jul'; mesi[i++]= 'Aug'; mesi[i++]= 'Sep'; mesi[i++]= 'Oct'; mesi[i++]= 'Nov'; mesi[i++]= 'Dec'; var parDataOk = mesi[ mm-1 ]+ " "+ dd + ", " +yyyy; //alert( "parseData.parDataOk:" + parDataOk ); var d = new Date(); d.setTime( Date.parse( parDataOk ) ); //alert( "parseData.d:" + d.toDateString() ); return d; } function data1PrimaData2( idData1, idData2, msg ){ var data1Date = parseDataDDMMYYYY( getValueOfId( idData1 ) ) ; var data2Date = parseDataDDMMYYYY( getValueOfId( idData2 ) ) ; //alert( 'data1PrimaData2.data1Date:' + data1Date ); //alert( 'data1PrimaData2.data2Date:' + data2Date ); if( data1Date <= data2Date ){ return true; }else{ var ids = new Array(); ids[0] = idData1; ids[1] = idData2; impostaErroreAlertIdV( ids, msg ); } return false; } function dataPartenzaEArrivoOK( idParDataDA, idParDataA, controllaIntervallo, shiftDay, datafine, message ){ var retVal = true; retVal = data1PrimaData2( idParDataDA, idParDataA, 'Errore: Arrivo precedente Partenza' ); if( retVal && controllaIntervallo ){ retVal = dataInIntervalloValido(idParDataDA, shiftDay, datafine, message); if( retVal ){ retVal = dataInIntervalloValido(idParDataA, shiftDay, datafine, message); } } return retVal; } function ControllaVideata_date(date1, date2) { x = document.getElementById(date1).value; y = document.getElementById(date2).value; var one_day=1000*60*60*24; //1 sec = 1000 ms ; 1m = 60 sec; 1 hour = 60 m; 1day = 24 h; var tmp_1 = new Array(); tmp_1 = x.split("-"); // we split the date in array with delimiter - tmp_2 = y.split("-"); var d1=new Date(tmp_1[2],(tmp_1[1]-1),tmp_1[0]); // we create a new date var d2=new Date(tmp_2[2],(tmp_2[1]-1),tmp_2[0]); diff = Math.ceil((d2.getTime()-d1.getTime())/(one_day)); if(diff >= 90) /// spostato a 90 il 12/08 Livio e Franco { return 0; }else{ if(diff >= 30){ if(confirm( "La ricerca e\' per "+diff+" giorni, vuoi procedere?")){ return 1; }else{ return 2; } }else{ return 1; } } } function return_day(date1, date2) { x = document.getElementById(date1).value; y = document.getElementById(date2).value; var one_day=1000*60*60*24; //1 sec = 1000 ms ; 1m = 60 sec; 1 hour = 60 m; 1day = 24 h; var tmp_1 = new Array(); tmp_1 = x.split("-"); // we split the date in array with delimiter - tmp_2 = y.split("-"); var d1=new Date(tmp_1[2],(tmp_1[1]-1),tmp_1[0]); // we create a new date var d2=new Date(tmp_2[2],(tmp_2[1]-1),tmp_2[0]); diff = Math.ceil((d2.getTime()-d1.getTime())/(one_day)); return diff; } function CheckDate(date1, date2) { x = document.getElementById(date1).value; y = document.getElementById(date2).value; var one_day=1000*60*60*24; //1 sec = 1000 ms ; 1m = 60 sec; 1 hour = 60 m; 1day = 24 h; var tmp_1 = new Array(); tmp_1 = x.split("-"); // we split the date in array with delimiter - tmp_2 = y.split("-"); var d1=new Date(tmp_1[2],(tmp_1[1]-1),tmp_1[0]); // we create a new date var d2=new Date(tmp_2[2],(tmp_2[1]-1),tmp_2[0]); diff = Math.ceil((d2.getTime()-d1.getTime())/(one_day)); if(diff<0) { return 0; }else { return 1; } } function CheckDate_before(date1) { x = document.getElementById(date1).value; var currentTime = new Date(); var month = currentTime.getMonth()+1; var day = currentTime.getDate(); var year = currentTime.getFullYear(); y = day+"-"+month+"-"+year; var one_day=1000*60*60*24; //1 sec = 1000 ms ; 1m = 60 sec; 1 hour = 60 m; 1day = 24 h; var tmp_1 = new Array(); tmp_1 = x.split("-"); // we split the date in array with delimiter - tmp_2 = y.split("-"); var d1=new Date(tmp_1[2],(tmp_1[1]-1),tmp_1[0]); // we create a new date var d2=new Date(tmp_2[2],(tmp_2[1]-1),tmp_2[0]); diff = Math.ceil((d2.getTime()-d1.getTime())/(one_day)); if (d1 browserWidth) ? pageWidth : browserWidth); popupBackDivHeight = ((pageHeight > browserHeight) ? pageHeight : browserHeight); // Set the dimension of the transparent div $('#' + divBackground).width(popupBackDivWidth); $('#' + divBackground).height(popupBackDivHeight); if(browserWidth < initBrowserWidth) { if(browserWidth < minBrowserWidth) { $('#' + divPopUp).css('width', minBrowserWidth + 'px'); var browserWidthDiff = initBrowserWidth - minBrowserWidth; } else { $('#' + divPopUp).css('width', browserWidth + 'px'); var browserWidthDiff = initBrowserWidth - browserWidth; } winWidth = initWinWidth - browserWidthDiff; $('#' + divPopUp + ' .window_middle, #' + divPopUp + ' .window_top_middle, #' + divPopUp + ' .window_bottom_middle').css('width', winWidth + 'px'); if($("#" + divPopUpContent).length != 0) { $('#' + divPopUpContent).css('width', winWidth + 'px'); } var winTitleWidth = initWinTitle - browserWidthDiff; $('#' + divPopUp + ' #move_div').css('width', winTitleWidth + 'px'); } else { $('#' + divPopUp).css('width', initBrowserWidth + 'px'); $('#' + divPopUp + ' .window_middle, #' + divPopUp + ' .window_top_middle, #' + divPopUp + ' .window_bottom_middle').css('width', initWinWidth + 'px'); if($("#" + divPopUpContent).length != 0) { $('#' + divPopUpContent).css('width', initWinWidth + 'px'); } $('#' + divPopUp + ' #move_div').css('width', initWinTitle + 'px'); } if(browserHeight < initBrowserHeight) { if(browserHeight < minBrowserHeight) { $('#' + divPopUp).css('height', minBrowserHeight + 'px'); var browserHeightDiff = initBrowserHeight - minBrowserHeight; } else { $('#' + divPopUp).css('height', browserHeight + 'px'); var browserHeightDiff = initBrowserHeight - browserHeight; } winHeight = initWinHeight - browserHeightDiff; // $('#scroll_description').css('height', winHeight - 110 + 'px'); $('#' + divPopUp + ' .window_middle, #' + divPopUp + ' .window_middle_left, #' + divPopUp + ' .window_middle_right').css('height', winHeight + 'px'); if($("#" + divPopUpContent).length != 0) { $('#' + divPopUpContent).css('height', (winHeight - $('#' + divPopUp + ' #move_div').height() - heightBetweenTitleAndContent) + 'px'); } } else { $('#' + divPopUp).css('height', initBrowserHeight + 'px'); $('#' + divPopUp + ' .window_middle, #' + divPopUp + ' .window_middle_left, #' + divPopUp + ' .window_middle_right').css('height', initWinHeight + 'px'); if($("#" + divPopUpContent).length != 0) { $('#' + divPopUpContent).css('height', (initWinHeight - $('#' + divPopUp + ' #move_div').height() - heightBetweenTitleAndContent) + 'px'); } //$('#scroll_description').css('height', initWinHeight - 110 + 'px'); } //Find out what is the position from the left in order to put the div into the center of the page //var centerHeight = browserHeight/2 - divHeight/2; //var centerWidth = browserWidth/2 - divWidth/2; var centerHeight = 20; var centerWidth = browserWidth/4; if(centerHeight < 0) centerHeight = 0; if(centerWidth < 0) centerWidth = 0; // Put the div that contain all the description into the center of the page. $('#' + divPopUp).css('top',centerHeight); $('#' + divPopUp).css('left',centerWidth); } /* * Daniel added this here because it is use in many parts and i added this instead to added into each file * END * */ /* * @ Avasiloaei Catalin > Start * * # Logarithmic Slider * Used when you need a slider that must have different values between units * Ex : 1, 2, 3, 5, 10, 20, 30 * * OBJECT CALL : * var Slider = new LogarithmicSlider(); * Slider.open({ * target : "test", // the DOM node where the slider will be appended * sections : 2, // a section is a region on the slider with equal unit values * widths : "300,300", // width of each section separated by ',' * gradations : [ "1,2,3,4,5,6,7,8,9,10", "20,40,60,80,100" ], // units values for each section passed as an array * selected : "5", // the unit selected by default when the slider is initiated * unit : "Km", // the unit of measurement - used just for user friendliness * snap : "strict", // strict / kind - how the slider controller will move across sections * change : function() { console.log(Slider.$get); }, // executed when the slider controller is moving across sections * release : function() { console.log(Slider.$get); } // executed when the slide action is ended and a gradation is picked * }); * * Note that 'Slider' in Slider.$get comes from the variable that instantiated the object ( var Slider = new LogarithmicSlider(); ) * */ var LogarithmicSlider = function() { this.target = null; this.body = ""; this.gradmarks = ""; this.Sections = 1; this.Widths = new Array(); this.Gradations = new Array(); this.gSizes = new Array(); this.gPositions = new Array(); this.Selected = false; this.Unit = false; this.Hover = false; this.Snap = "kind"; this.ChangeAction = false; this.ReleaseAction = false; this.$get = false; var Object = this; this.Controller = false; this.Myself = false; this.active = false; this.open = function(options) { // Check if target exists. If not, return if(typeof options.target !== 'undefined' && options.target !== false) this.target = document.getElementById(options.target); if(this.target === null) return; // Check if a unit has been defined for user display if(typeof options.unit !== 'undefined' && options.unit !== false) this.Unit = options.unit; // Get sections, widths & gradations // Check if numbers match, or else return if(typeof options.sections !== 'undefined' && options.sections !== false) this.Sections = options.sections; if(typeof options.widths !== 'undefined' && options.widths !== false) { if(options.widths.indexOf(",") > -1) { var splitWidths = options.widths.replace(" ","").replace("px", "").split(","); for(var swInc = 0; swInc < splitWidths.length; swInc++) { this.Widths[swInc+1] = splitWidths[swInc]; } } else this.Widths[1] = parseInt(options.widths.replace(" ","").replace("px", ""), 10); } else return; if((this.Widths.length-1) != this.Sections) return; if(typeof options.gradations.length !== 'undefined' && options.gradations.length == this.Sections) { for(var gInc = 0; gInc < options.gradations.length; gInc++) { if(options.gradations[gInc].indexOf(",") > -1) { this.Gradations[gInc+1] = new Array(); var splitGradations = options.gradations[gInc].replace(" ","").replace("px", "").split(","); for(var sgInc = 0; sgInc < splitGradations.length; sgInc++) { this.Gradations[gInc+1].push(splitGradations[sgInc]); } } else this.Gradations[gInc+1] = [options.gradations[gInc]]; } } else return; this.Myself = "sld_"+this.target.id+"_object"; this.Controller = "sld_"+this.target.id+"_ctrl"; // Build the html body of the slider & gradations labels // Append the code to the target this.body += "
"; this.body += "
 
"; this.body += "
 
"; if(this.Unit !== false) this.body += "
"+this.Unit+"
"; this.gradmarks += "
"; for(var sInc = 1; sInc <= this.Sections; sInc++) { this.body += "
 "; this.gSizes[sInc] = Math.floor(this.Widths[sInc] / this.Gradations[sInc].length); for(var gInc = 0; gInc < this.Gradations[sInc].length; gInc++) { this.body += "
"; this.body += "
 
"; this.body += "
"; this.gradmarks += "
"+ ""+this.Gradations[sInc][gInc]+""+ "
"; } this.body += "
"; } //this.body += "
"; this.gradmarks += "
"; //$(this.target).html(this.body+"
"+this.gradmarks); $(this.target).html(this.body+this.gradmarks+""); // Display slider unit ( if defined ) if(this.Unit !== false) $("#sld_"+this.target.id+"_unit").css("left", "100%"); // Make the begining of the slider equal to the end var firstMarker = this.Gradations[1][0]; var lastMarker = this.Gradations[this.Gradations.length-1][this.Gradations[this.Gradations.length-1].length-1]; var finishDiff = Math.floor( ( $("[id='sld_"+this.target.id+"_grd_"+lastMarker+"']").width() - $("[id='sld_"+this.target.id+"_grd_"+firstMarker+"']").width() ) / 2 ); if(finishDiff != 0) { if(finishDiff > 0) { $("#sld_"+this.target.id+"_beginer").css("width", finishDiff+"px").css("left", "-"+finishDiff+"px"); $("#"+this.Myself).css("margin-left",finishDiff+"px"); } else { finishDiff = -finishDiff; $("#sld_"+this.target.id+"_beginer").css("width", finishDiff+"px").css("right", "-"+finishDiff+"px"); if(this.Unit !== false) $("#sld_"+this.target.id+"_unit").css("left", ($("#"+this.Myself).outerWidth() + finishDiff)+"px"); } } // Make a map of the locations of all markers var elementOffset = $("#"+this.Myself).offset().left; var halfController = $("#"+Object.Controller).outerWidth() / 2; $("[id^='sld_"+this.target.id+"_mrk_']").each(function() { var markerNumber = this.id.split("_mrk_")[1]; Object.gPositions[markerNumber] = $(this).offset().left - elementOffset + ($(this).outerWidth() / 2) - halfController; }); // Define snap type if(typeof options.snap === 'undefined' || (typeof options.snap !== 'undefined' && options.snap.replace(" ","") === "strict")) this.Snap = "strict"; // Select one of the gradations // Move the controller on top of the active marker if(typeof options.selected !== 'undefined' && options.selected !== false) this.Selected = options.selected.replace(" ","").replace("px",""); else this.Selected = this.Gradations[1][0]; Object.mark(this.Selected, true); // Add events on slider bar var mouseMoveBlocker_L = $("[id='sld_"+this.target.id+"_mrk_"+firstMarker+"']"); mouseMoveBlocker_L = mouseMoveBlocker_L.offset().left - elementOffset; var mouseMoveBlocker_R = $("[id='sld_"+this.target.id+"_mrk_"+lastMarker+"']"); mouseMoveBlocker_R = mouseMoveBlocker_R.offset().left - elementOffset; $("#"+this.Controller).on("mousedown", function() { Object.active = true; }); var hoverSection = 1; this.Widths[0] = 0; $(document).on("mousemove", function(event) { // Define the behaviour during the slide action if(Object.active === true) { var mousePosition = event.clientX - elementOffset; // Find out on top of which section the controller is var tempSum = 0; for(var csInc = 1; csInc <= Object.Sections; csInc++) { if( mousePosition < (tempSum + Object.Widths[csInc]) ) { hoverSection = csInc; break; } else tempSum += parseInt(Object.Widths[csInc], 10); } // The marker that was hovered before mouse move var captureHover = Object.Hover; // Find out marker that is hovered at the present mouse position var hoverGradation = Math.ceil( (mousePosition-tempSum) / Object.gSizes[hoverSection] ); if(hoverGradation == 0) hoverGradation = 1; hoverGradation = Object.Gradations[hoverSection][hoverGradation-1]; if(Object.Snap == "strict") { // Strict snap mode if( mousePosition < ( mouseMoveBlocker_L + halfController ) ) hoverGradation = firstMarker; else if( mousePosition > ( mouseMoveBlocker_R - halfController ) ) hoverGradation = lastMarker; Object.mark(hoverGradation); if(hoverGradation != captureHover) { $("[id='sld_"+Object.target.id+"_lbl_"+captureHover+"']").attr("class", "lSlider-label"); Object.change(hoverGradation); } return; } else { // Kind snap mode if( mousePosition > ( mouseMoveBlocker_L + halfController ) && mousePosition < ( mouseMoveBlocker_R - halfController ) ) { var realMP = mousePosition - halfController; var snapDifference = Object.gSizes[hoverSection] / 3; var markerHotInterval = { left : Object.gPositions[hoverGradation] - snapDifference, right : Object.gPositions[hoverGradation] + snapDifference } if(realMP > markerHotInterval.left && realMP < markerHotInterval.right) { Object.mark(hoverGradation); if(hoverGradation != captureHover) { $("[id='sld_"+Object.target.id+"_lbl_"+captureHover+"']").attr("class", "lSlider-label"); Object.change(hoverGradation); } return; } else $("#"+Object.Controller).css("left", ( mousePosition - halfController )+"px"); } else if( mousePosition < ( mouseMoveBlocker_L + halfController ) ) { Object.mark(firstMarker); if(hoverGradation != captureHover) { $("[id='sld_"+Object.target.id+"_lbl_"+captureHover+"']").attr("class", "lSlider-label"); Object.change(hoverGradation); } } else if( mousePosition > ( mouseMoveBlocker_R - halfController ) ) { Object.mark(lastMarker); if(hoverGradation != captureHover) { $("[id='sld_"+Object.target.id+"_lbl_"+captureHover+"']").attr("class", "lSlider-label"); Object.change(hoverGradation); } } } } }); $(document).on("mouseup", function() { Object.mark(Object.Hover); Object.release(this); Object.active = false; }); // Add events on the gradation labels $("[id^='sld_"+this.target.id+"_lbl']").each(function() { $(this).on("click", function() { var targetMarker = $(this).attr("id").split("_"); targetMarker = targetMarker[targetMarker.length - 1]; if(targetMarker != Object.Selected) { $("[id='sld_"+Object.target.id+"_lbl_"+Object.Selected+"']").attr("class", "lSlider-label"); Object.mark(targetMarker); Object.change(true); Object.release(true); } }); $(this).on("mouseover", function() { var targetMarker = $(this).attr("id").split("_"); targetMarker = targetMarker[targetMarker.length - 1]; if(targetMarker != Object.Selected) $(this).attr("class", "lSlider-label-over"); }); $(this).on("mouseout", function() { var targetMarker = $(this).attr("id").split("_"); targetMarker = targetMarker[targetMarker.length - 1]; if(targetMarker != Object.Selected) $(this).attr("class", "lSlider-label"); }); }); // Disable mouse select on the gradations labels $("#sld_"+this.target.id+"_gradations, #"+Object.Myself).attr('unselectable','on') .css({'-moz-user-select':'-moz-none', '-moz-user-select':'none', '-o-user-select':'none', '-khtml-user-select':'none', '-webkit-user-select':'none', '-ms-user-select':'none', 'user-select':'none' }).bind('selectstart', function(){ return false; }); // Prepare release / change actions if(typeof options.change !== 'undefined' && options.change !== false) this.ChangeAction = options.change; if(typeof options.release !== 'undefined' && options.release !== false) this.ReleaseAction = options.release; } this.mark = function(marker, first) { // Set one of the marker as the active one // Move the controller on top of the active marker $("#"+Object.Controller).css("left", Object.gPositions[marker]+"px"); $("[id='sld_"+Object.target.id+"_lbl_"+marker+"']").attr("class", "lSlider-label-selected"); if(typeof first !== 'undefined' && first === true) $("#"+Object.Controller).html(marker); Object.Selected = marker; Object.Hover = marker; Object.$get = marker; } this.change = function(force) { // Executed while navigating the slider when the controller reaches a new marker // This uses Object.Hover $("#"+Object.Controller).html(Object.Hover); if(typeof force !== 'undefined' && force !== true && force != Object.Selected) $("[id='sld_"+Object.target.id+"_lbl_"+force+"']").attr("class", "lSlider-label-over"); if((Object.ChangeAction !== false && Object.active === true) || (typeof force !== 'undefined' && force === true)) { Object.ChangeAction(); return; } } this.release = function(force) { // Executed when the controller is released // This uses Object.Selected if((Object.ReleaseAction !== false && Object.active === true) || (typeof force !== 'undefined' && force === true)) { Object.ReleaseAction(); return; } } } /* * @ Avasiloaei Catalin > Finish */