// Main function to obtain an OBJECT from it's ID function getElem(elemID) { var elem = document.all ? document.all[elemID] : document.getElementById(elemID); return elem; } function CheckQte(Qte,id) { if(document.getElementById(id).value>Qte) { alert('Nombre de Client doit être <= '+Qte); document.getElementById(id).value=Qte; } } function aff_positions() { for ( prop in window.datazone ) { if ( document.getElementById(prop)) { document.getElementById(prop).value=window.datazone[prop]; } } } // Afficher les depots function AfficherDepot(Id_pqr,nb) { if(Id_pqr < 10)Id_pqr = '0'+Id_pqr; for(var i = 1; i < nb+1 ;i++) { if(document.getElementById(Id_pqr+'_'+i)!=null) { var obj = document.getElementById(Id_pqr+'_'+i); var img = document.getElementById(Id_pqr); if(obj.style.display == "none") { obj.style.display = ""; img.src ="skin/jade/images/button_minus.png"; } else { img.src ="skin/jade/images/button_plus.png"; obj.style.display = "none"; } } } } // Affciher les Commmune function AfficherCommune(Id_pqr,nb) { for(var i = 0; i < nb; i++) { var obj = document.getElementById(Id_pqr+'_' +i); var img = document.getElementById('img_' + Id_pqr); if(obj.style.display == "none") { obj.style.display = ""; img.src ="skin/jade/images/button_minus.png"; } else { img.src ="skin/jade/images/button_plus.png"; obj.style.display = "none"; } } } // Affciher les Depots et commune function AfficherDepotCommune(Id_pqr,nb) { for(var i = 1; i < nb+1 ;i++) { var obj = document.getElementById(Id_pqr+'_'+i); var img = document.getElementById(Id_pqr); if(obj.style.display == "none") { obj.style.display = ""; img.src ="skin/jade/images/button_minus.png"; } else { img.src ="skin/jade/images/button_plus.png"; obj.style.display = "none"; } for(var j = 1; j < 80 ;j++) { var obj1 = document.getElementById(Id_pqr+'_'+i+'_'+j); if(obj1!=null) { if(obj1.style.display == "none"){ obj1.style.display = ""; } else{ obj1.style.display = "none"; } } } } } // Afficher la quantité pour un depot function AfficherQt() { for (var i = 0; i mlength) { obj.value=obj.value.substring(0,mlength) } } // verifier les valeurs saisies function checkIsNumeric(variable,champ) { var isEntier=function(x){return new RegExp("^[0-9]+$","g").test(x)}; if(!isEntier(variable)) { var obj = document.getElementById(champ); obj.value = variable.substr(0,variable.length-1); } } // Barre de progression function ProgressBar(Index, NbLines) { var PContainer = getElem('ProgressBarContainer'); var PText = getElem('ProgressBarText'); var PBarre = getElem('ProgressBarZone'); var PBaseTxt = "Progression en cours... "; if(PContainer && PText && PBarre) { PText.innerHTML = PBaseTxt + "0%"; if(Index < (NbLines - 1) && Index > 0) { PContainer.className = "display"; PText.innerHTML = PBaseTxt + Math.round(Index / NbLines * 100) + "%"; PBarre.style.width = Math.round(Index / NbLines * 100) + "%"; } else if(Index >= (NbLines - 1)) { PContainer.className = ""; PBarre.style.width = "0%"; } } } // Selectionne toutes les options d'un select multiples function SelectAllOptions(SAObj, SARadix) { for(var i = 0; i < SAObj.length; i++) { if(SARadix) { if(SAObj[i].name.indexOf(SARadix) >= 0){condition = true;} else{condition = false;} } else{condition = true;} if(SAObj[i].type == 'select-multiple' && condition) { for (j = 0; j < SAObj[i].length; j++) { if(SAObj[i].options[j].selected == false){SAObj[i].options[j].selected = true;} } } } } // Supprime une option function DeleteSelectItem(MSIselect, MSIDtoDel) { for (var j = 0; j < MSIselect.options.length; j++) { if (MSIselect.options[j].value == MSIselected[MSIDtoDel]){MSIselect.options[j] = null;} } } // Move one (or several) option from a selectbox to another function MoveselectItem(MSIMove, MSIselect1, MSIselect2, MSIError1, MSIError2, MSILimit, MSISave, MSISaveNb) { MSIselected = new Array(); MSelect1 = getElem(MSIselect1); MCount1 = 0; M1hasAll = false; MSelect2 = getElem(MSIselect2); MCount2 = 0; M2hasAll = false; // Messages d'erreur if(!MSIError1){MSIError1 = "Il faut supprimer les autres valeurs avant de pouvoir ajouter \"Tous\" !";} if(!MSIError2){MSIError2 = "Impossible d'ajouter une autre valeur car \"tous\" est séléctionné !";} if(MSIMove == 'right'){FormSel1 = MSelect1; FormSel2 = MSelect2;} else{FormSel1 = MSelect2; FormSel2 = MSelect1;} FormSave = getElem(MSISave); FormSaveNb = getElem(MSISaveNb); for (var i = 0; i < FormSel1.options.length; i++) { if (FormSel1.options[i].selected) { MCount1++; if(FormSel1.options[i].value == 0){M1hasAll = true;} } } for (var i = 0; i < FormSel2.options.length; i++) { MCount2++; if(FormSel2.options[i].value == 0){M2hasAll = true;} } if(MSIMove == 'right' && M1hasAll && MCount2 > 0){alert(MSIError1);} else if(MSIMove == 'right' && M2hasAll){alert(MSIError2);} else { if(MSILimit){Limited = true; MSILimit -= MCount2;}else{Limited = false;} CountOptions = 1; for (var i = 0; i < FormSel1.options.length; i++) { if (FormSel1.options[i].selected && (!Limited || (CountOptions <= MSILimit))) { CountOptions++; MSIselected.push(FormSel1.options[i].value); FormSel2.options[FormSel2.length] = new Option(FormSel1.options[i].text, FormSel1.options[i].value); } } for (var m = 0; m < MSIselected.length; m++) { DeleteSelectItem(FormSel1, m); } // Save values in an input hidden if(FormSave) { var j = 0; var TempValues = ""; for(var i = 0; i < MSelect2.options.length; i++) { TempValues += MSelect2.options[i].value + ";"; j = j + 1; } FormSave.value = TempValues.substr(0, (TempValues.length) - 1); FormSaveNb.value = j; } } } // Direction for moving item(s) of a selectbox (Top, Bottom, Up, Down) function MoveItemSetTab(MSTab, MSItem, MSAction, MSConsec, TArray) { if(MSAction == "down") { for (var j = (MSTab.length - 1); j >= 0; j--) { var MSTemp = MSTab[j]; if(MSTab[j][0] == MSItem && j + MSConsec < (MSTab.length - 1)) { MSTab[j] = MSTab[j + 1]; MSTab[j + 1] = MSTemp; } } } else { for (var j = 0; j < MSTab.length; j++) { var MSTemp = MSTab[j]; if(MSTab[j][0] == MSItem) { if(MSAction == "up" && j > 0 && (j - MSConsec > 0)) { MSTab[j] = MSTab[j - 1]; MSTab[j - 1] = MSTemp; } else if(MSAction == "top" || MSAction == "bottom") { TArray[TempArrayIndex++] = MSTab[j]; MSTab.splice(j, 1); if(MSAction == "top" && TArray.length == MVSelectedTab.length) MVTab = TArray.concat(MSTab); else if(MSAction == "bottom" && TArray.length == MVSelectedTab.length) MVTab = MSTab.concat(TArray); } } } } } // Move up or down Item(s) from a selectbox function MoveUpDownItem(MVselect, MVaction, MSIHidden) { MVTab = new Array(); MVSelectedTab = new Array(); TempArray = new Array(); TempArrayIndex = 0; p = 0; MVConsec = 0; MForm = getElem(MVselect); for (var i = 0; i < MForm.options.length; i++) { MVTab[MForm.options[i].index] = new Array(MForm.options[i].value, MForm.options[i].text, MForm.options[i].selected); if(MForm.options[i].selected){MVSelectedTab[p++] = new Array(i, MForm.options[i].value);} } if(MVaction == "down") { for (var i = MVSelectedTab.length - 1; i >= 0; i--) { if(i < MVSelectedTab.length - 1 && MVSelectedTab[i + 1][0] == (MVSelectedTab[i][0]) + 1){MVConsec++;}else{MVConsec = 0;} MoveItemSetTab(MVTab, MVSelectedTab[i][1], MVaction, MVConsec, TempArray); } } else { for (var i = 0; i < MVSelectedTab.length; i++) { if(i > 0 && MVSelectedTab[i-1][0] == (MVSelectedTab[i][0]) - 1){MVConsec++;}else{MVConsec = 0;} MoveItemSetTab(MVTab, MVSelectedTab[i][1], MVaction, MVConsec, TempArray); } } MForm.length = 0; for (var o = 0; o < MVTab.length; o++){MForm.options[o] = new Option(MVTab[o][1], MVTab[o][0], MVTab[o][2], MVTab[o][2]);} if(MSIHidden) { FormHid = getElem(MSIHidden); FormHid.value = ''; for(i = 0;i < MForm.length; i++) { FormHid.value += MForm[i].value; if(i < MForm.length - 1) FormHid.value += ','; } } } // Change la couleur des options function ChangeSelectStyle(SelectObj) { SelectObj.className = SelectObj.options[SelectObj.selectedIndex].className; } //Cocher tous les checkbox d'une page function checkbox(checkbox) { var result = "" ; for (var i=0; i 23 || heure < 00 || isNaN(heure) || document.getElementById(id).value.length > 2) { alert('Format heure incorrect'); document.getElementById(id).value="00"; } if(document.getElementById(id).value.length==1)document.getElementById(id).value="0"+heure; if(document.getElementById(id).value.length==0)document.getElementById(id).value="00"; } function checkMinute(minute,id) { if(minute > 59 || minute < 00 || isNaN(minute) || document.getElementById(id).value.length > 2) { alert('Format minutes incorrect'); document.getElementById(id).value="00"; } if(document.getElementById(id).value.length==1)document.getElementById(id).value="0"+minute; if(document.getElementById(id).value.length==0)document.getElementById(id).value="00"; } /** * Même résultat que 'in_array' en PHP. * Expl: * var t=new Array("coucou","test","plop"); * alert(t.in_array("test")); //affichera 1 * alert( t.in_array("bobo") ); //affichera -1 */ Array.prototype.in_array = function(valeur) { for (var i in this) { if (this[i] == valeur) return i;} return -1; } /** Même résultat que 'trim' en PHP * var myString = " hello my name is "; * alert("*"+myString.trim()+"*"); * @return String */ String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } /** * Même résultat que 'ltrim' en PHP * var myString = " hello my name is "; * alert("*"+myString.ltrim()+"*"); * @return String */ String.prototype.ltrim = function() { return this.replace(/^\s+/,""); } /** * Même résultat que 'rtrim' en PHP * var myString = " hello my name is "; * alert("*"+myString.rtrim()+"*"); * @return String */ String.prototype.rtrim = function() { return this.replace(/\s+$/,""); } /* Même résultat que 'str_replace' en PHP*/ function str_replace(search, replace, subject) { var reg=new RegExp("("+search+")", "g"); return subject.replace(reg,replace); } //Transforme les dates de format JJ/MM/AAAA en AAAAMMJJ function dated_m_YToYmd (sDate) { var sSeparator = (arguments[1]) ? arguments[1] : '/'; var array = sDate.split(sSeparator); var date_tmp = array[2] + array[1] + array[0]; return date_tmp; } /* Cette fonction permet de récupérer la valeur de l'attribut _attribut des éléments de tag défini par _tagName et dont les conditions par rapport aux valeurs des autres attributs (_attributesCondition) Cette fonction retourne un tableau ou un FALSE Expl : getValueAttributeByTagname ("input", "name", "type=checkbox;name=^Etat.*28$"); -> Récupère tous les 'name' des 'input' dont le 'type' est 'checkbox' et le 'name' commence par Etat et se termine par '28' -> Si _attributesCondition contient plusieurs conditions, les séparer par un ';' */ function getValueAttributeByTagname (_tagName, _attribut, _attributesCondition) { if (arguments.length != 3) { alert (' 3 paramètres obligatoires pour la fonction getValueAttributeByTagname (_tagName, _attribut, _attributesCondition)'); return false; } var obj = document.getElementsByTagName(_tagName); var reg1 = new RegExp("[;]+", "g"); var reg2 = new RegExp("[=]+", "g"); var aAttrTmp1 = _attributesCondition.split(reg1); var aAttributes = new Object (); for ( var i=0; i 0) { return aOut; } return false; } /* page cpte recep validation */ // envoie le formulaire aprés clic sur le bouton valider function envoyer_formulaire() { // document.getElementById("code_soc").value=document.getElementById("code_societe").value; document.getElementById("id_date").value=document.getElementById("sDate").value; document.getElementById("form_cpte_recep_val").submit(); } /* MESSAGES GENERAUX*/ //faire apparaître la zone de texte pour le message généraux function derouler_MG() { document.getElementById('message_global').style.display=''; if(document.getElementById('message_global').style.display=='none') { document.getElementById('MG_derouler').style.display=''; } else { document.getElementById('MG_derouler').style.display='none'; } } //appliquer le message global à tous les depots function MG_tous() { for(var i=0;i 0; i-=start){ control += ' !"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~ˆ?‚?„…†‡?‰S‹??Z??‘’“”•–—?™s›??zY ???¤?¦§?©?«¬­®?°±???µ¶·???»????AAAAAA?CEEEEIIII?NOOOOO?OUUUUY??aaaaaa?ceeeeiiii?nooooo?ouuuuy?y'.indexOf(_request.charAt(i));} return control; } /** * Search Cache * * @author crossbrowserajax.com * @param _request url-request */ this._search = function( _request ) { // hash generate var _hash = this._rct( _request, this._length_ct ); // viewing the cache for (i in this._cache) { if (this._cache[i][0] == _hash && this._cache[i][1] == _request) { this._search_buffer = this._data_cache[i]; return true; } } return false; } /** * Add Cache * * @author crossbrowserajax.com * @param _request url-request * @param _data data */ this._add = function( _request, _data ) { // checking the limit of memories if ( this._cache_index >= this._buffer_size ) { this._cache_index = 0; } // hash generate var _hash = this._rct( _request, this._length_ct ); // caching this._cache[this._cache_index] = [_hash, _request]; this._data_cache[this._cache_index] = _data; this._cache_index++; } /** * Initializing * * @author crossbrowserajax.com * @param buffer_size buffer size * @param length_ct length string for analysis (for control total) */ this._init = function( buffer_size, length_ct ) { /** buffer_size */ this._buffer_size = buffer_size; /** length string for analysis (for control total) */ this._length_ct = length_ct; /** cache */ this._cache = new Array(); /** data cache */ this._data_cache = new Array(); /** current index of cache */ this._cache_index = 0; /** search result buffer */ this._search_buffer = null; } /** Init Class */ this._init( buffer_size, length_ct ); } /////////// C.B.A. ( core ) //////////////////////////// /** * C.B.A. * * @class CrossBrowserAjax. Core. * @author crossbrowserajax.com * @version 1.10 * @base cbaDOM */ function cbaRequest() { /** * Initializing the C.B.A. Class * * @author crossbrowserajax.com * @member cbaRequest */ this._init = function() { /** handler error status */ this._handler_error = true; /* enable handler error */ if ( this._handler_error ) { window.onerror = this.cbaJsError; } /** parent element id-name */ this._parent_id_name = '_cba_parent_id'; /** name id in url-request */ this._url_id = '_cba_request_id'; /** prefix for created request */ this._id_prefix = '_cba_pack_'; /** interface for dom */ this.dom = new cbaDOM(); /** parent element */ this._parent_element = this.createParentElement(); /** cache of requests */ this._requests = new Array(); /* cache */ /** caching enabled */ this._caching_enabled = true; if ( this._caching_enabled ) { /** buffer_size */ this._buffer_size = 50; /** length string for analysis (for control total) */ this._length_ct = 300; /** cache */ this.cache = new cbaCache( this._buffer_size, this._length_ct ); } } /** * Handler Errors * @author crossbrowserajax.com * @param _message error description * @param _url url * @param _line error line * @member cbaRequest */ this.cbaJsError = function(_message, _url, _line) { var _file = "File: " + _url + " :: " + _line + "\n"; var _title = "There was an error on this page.\n--------------------------\n"; var _error = _title; _error += "Error: " + _message + "\n"; _error += _file; if ( _message.indexOf('unterminated string literal') + _message.indexOf('missing ;') + _message.indexOf('Syntax error') > -3){ _error += '--------------------------\nRecommendation:\n Check response from the server.\n He may return incorrect JavaScrip.'; } alert(_error); } /** * Making the Container for