// Funzioni Javascript for CREAtiv.net ( rel. 2.12 ) // Developed by Davide Gullo -->>> gullo@m4ss.net /////////////////////////////////////////////////////////////// ///////////////////////// FUNZIONI GENERALI /////////////////// /////////////////////////////////////////////////////////////// // Apre una nuova finestra function ApriFinestra( urlpagina, w, h ){ window.open( urlpagina, 'Finestra', 'left=50,top=50,width=' + w + ',height=' + h + ', menubar=no, scrollbars=yes, toolbar=no, screenX=0, screenY=0, status=1'); } // Cambia il submit di una form in base ai parametri passati function ChangeSubmit(myform, myact, myaction, mytarget) { myform.act.value = myact; myform.action = myaction; myform.target = mytarget; myform.submit(); } // Conferma messaggio delle Finestre Javascript function MsgConferma(txt, conferma) { // Exp Reg per cercare . o ? var regX = /\.|\?|!/gi ; var _ret=""; var counter = 0; var _item = txt.split(" "); for(var i=0;i<_item.length;i++) { counter++; if( _item[i].match(regX) ) { _item[i]=_item[i] + '\n'; _ret+=_item[i]; counter = 0; } else { if( counter == 6 ) { _item[i]=_item[i] + '\n'; _ret+=_item[i]; counter = 0; } else { _ret+=_item[i] + ' '; } } } if(conferma == 1) { return confirm(_ret); } else { alert(_ret); return true; } } // Funzione per il calcolo del TOTALE su tariffa, durata, iva function CalcolaOrario(tariffa, durata, iva) { var totale; totale = ((tariffa * durata) + ( (tariffa * durata) * iva / 100)); return totale; } // Formatta un numero con i decimali passati a decimals function FormatNumero(total,decimals) { var num = parseFloat(total); // First section sets non-number value to zero if (!(num = parseFloat(num))) num = "0.00"; // Second section sets two decimal place format var Pad = ""; num = "" + Math.floor(num * Math.pow(10,decimals + 1) + 5); // Pad if less than 0.10 if(num.length < decimals+1) { for(Count = num.length; Count <= decimals; Count++) Pad += "0"; } num = Pad + num; // Parse into final string num = num.substring(0,num.length - decimals - 1) + "." + num.substring(num.length - decimals -1, num.length -1); // If less than 1 then add 0 to the left of the decimal if((num == "") || (parseFloat(num) < 1)) num = "0" + num; // Final section returns formatted number return num; } // Riempie una combo in base all'oggetto passato function populate(cacheobj, x, selezionato) { for (m=cacheobj.options.length-1;m>0;m--) { cacheobj.options[m]=null } selectedarray=eval(x) for (i=0;i 0){ my_nfatt.readOnly = false; if(my_nfatt.value < 2) { alert("La Fatturazione Multipla\ndeve avere un numero di fatture maggiore di 1 !"); my_nfatt.value = 2; } } else { alert("La Fatturazione Come convenuto\nč possibile solo nei Servizi Orari."); my_tipofatt.value = 0; my_nfatt.readOnly = true; my_nfatt.value = 1; } break; case 'H': my_fatt_oraria.disabled = false; if( my_tipofatt.value == 0) { my_nfatt.value = 1; my_nfatt.readOnly = true; my_fatt_oraria.disabled = true; if( my_fatt_oraria.checked == true ) { my_fatt_oraria.checked = false; my_fatt_oraria.disabled = true; my_tipofatt.value = 0; } } else if( my_tipofatt.value > 0){ my_nfatt.readOnly = false; my_fatt_oraria.disabled = false; if( my_fatt_oraria.checked == true ) { my_nfatt.value = 0; my_nfatt.readOnly = true; } else { if( my_nfatt.value < 2 ) { alert("La Fatturazione Multipla deve avere\nun numero di fatture maggiore di 1 !"); my_nfatt.value = 2; } } } else { my_fatt_oraria.checked = false; my_fatt_oraria.disabled = true; my_nfatt.readOnly = true; my_nfatt.value = ''; } break; } } // Funzione per impostazione etichette in fase di preventivo function ImpostaEtichetta(field) { var my_label; switch(field.value) { case 'F': my_label = 'Quantitā'; break; case 'H': my_label = 'Durata (h)'; break; } var my_field = document.newprev.field_label_tipo; my_field.value = my_label; ControlloFatt(); } // Funzione per aggiornamento combo per gli estremi bancari di pagamento function ComboBanche(selezionato) { // Variabili e funzioni per la combo selezione Banca var banche = new Array(); banche[0] = new Option("Solo per Bonifico Bancario","0"); var banche_C = new Array(); banche_C[0] = new Option("BIPOP - UNICREDIT Ag.S.Polo d'Enza (RE)","1"); banche_C[1] = new Option("B.Pop.Emilia Romagna Ag.S.Polo d'Enza (RE)","2"); banche_C[2] = new Option("Credito Emiliano Ag.S.Polo d'Enza (RE)","3"); banche_C[3] = new Option("Banca di Cavola e Sassuolo","4"); banche_C[4] = new Option("Banca Reggiana Agenzia di Bibbiano","5"); banche_C[5] = new Option("Banca Monte Paschi Siena","6"); banche_C[6] = new Option("B.S.G.S.P - AGENZIA DI SAN POLO D'ENZA","7"); var banche_S = new Array(); banche_S[0] = new Option("BIPOP - UNICREDIT Ag.S.Polo d'Enza (RE)","1"); banche_S[1] = new Option("BANCA POPOLARE EMILIA ROMAGNA AG. S.POLO D'ENZA, RE","2"); banche_S[2] = new Option("BPV-BSGSP Ag. Castelnovo nč Monti","3"); banche_S[3] = new Option("Banca di Cavola e Sassuolo","4"); banche_S[4] = new Option("BCC di Leverano","5"); banche_S[5] = new Option("Banca Reggiana Agenzia di Bibbiano","6"); banche_S[6] = new Option("Banca Monte Paschi Siena","7"); var sel_idcoop; var sel_paga_m; var my_field; sel_coop = document.newprev['field_prev[idcoop]']; sel_paga_m = document.newprev['field_prev[paga_m]']; if(sel_paga_m.value == 'B') { my_field = eval('banche_' + sel_coop.value); // Devo sottrarre 1 per riportare il valore coerente con quello degli array banche if(selezionato > 0) { selezionato = (selezionato - 1); } else { selezionato = 0; } populate(document.newprev['field_prev[paga_b]'], my_field, selezionato); } else { populate(document.newprev['field_prev[paga_b]'], banche, 0); } } // Verifica che sia selezionato almeno un settore function VerificaOperatore() { var flag = 0; var theElements = document.userform.elements['CHKsett_id[]'].length; for (var i = 0; i < theElements; i++) { if (eval("document.userform.elements['CHKsett_id[]'][" + i + "].checked") == true) { flag = 1; } } if (flag == 0){ alert("Un operatore deve essere autorizzato\na lavorare per almeno un Settore !"); return false; } else { return true; } } // Verifica che sia selezionato almeno un checkbox tra quelli passati con array -> array_field function VerifyOneCheckbox(form, array_field, avviso) { var flag = 0; var theElements = array_field.length; if(theElements > 0){ for (var i = 0; i < theElements; i++) { if (eval(form + ".elements['" + array_field[i] + "'].checked") == true) { flag = 1; } } } else { flag = 0; } if (flag == 0){ alert(avviso); return false; } else { return true; } } // Seleziona tutti i checkbox di array (array_field) del form (form) o viceversa: a seconda del valore passato da (controllo) function CheckAll(form, array_field, controllo) { var n_Elements = array_field.length; if(controllo.checked == true) { checked_bool= true; } else { checked_bool = false; } for (var i = 0; i < n_Elements; i++) { eval(form + ".elements['" + array_field[i] + "'].checked = " + checked_bool); } } // Funzione per il controllo della visualizzazione dei campi in Ricerca Incassi function Field_CercaIncassi(tipoincasso, id_field) { if( tipoincasso == "R") { this.document.getElementById(id_field).style.display='inline'; this.document.getElementById("tipo_data3").checked = true; } else { this.document.getElementById(id_field).style.display='none'; this.document.getElementById("tipo_data1").checked = true; } } // Expandable content script function toggleDisplay(id){ if(this.document.getElementById(id).style.display=='none'){ this.document.getElementById(id).style.display='inline'; this.document.getElementById(id+"link").style.display='none'; }else{ this.document.getElementById(id).style.display='none'; this.document.getElementById(id+"link").style.display='inline'; } } function DisplayContent(section, id){ var tabobj=document.getElementById("tablist"); tabobjlinks=tabobj.getElementsByTagName("A"); for (i=1; i