//// Base Var var ie = /MSIE/.test(navigator.userAgent); var Chrome = /Chrome/.test(navigator.userAgent); var cls = ie ? "className" : "class"; var Toolbar_NoAction = false; var Toolbar_NoList = false; var Toolbar_NoDetails = false; var Toolbar_NoModif = false; var Toolbar_NoAdd = false; var O2Get_Users; var O2Get_Clients; var ActiveBasket = -1; var CurrentDocument = null; var StartTime = null; var HeaderIcon = ""; var LsvSelectable = true; var SaveMsg = true; //// UI /////////////////// function SwitchVisible(el, State) { var SwicthObj = $(el); if (SwicthObj) { if (State) { if (State=='hidden') { if ($(el+"IMG")) { document.getElementById(el+"IMG").src = "./images/down.png"; } SwicthObj.style.visibility = 'hidden'; SwicthObj.style.left = 0; SwicthObj.style.top = 0; SwicthObj.style.zindex = -100; SwicthObj.style.position = 'absolute'; } else { if ($(el+"IMG")) { document.getElementById(el+"IMG").src = "./images/up.png"; } SwicthObj.style.position = ''; SwicthObj.style.zindex = 0; //SwicthObj.style.visibility = 'visible'; SwicthObj.style.visibility = ''; } } else { if (document.getElementById(el+"IMG").src.toString().indexOf("up.png")>0) { document.getElementById(el+"IMG").src = "./images/down.png"; } else { document.getElementById(el+"IMG").src = "./images/up.png"; } if (SwicthObj.style.visibility) { if (SwicthObj.style.visibility=='hidden') { SwicthObj.style.position = ''; SwicthObj.style.zindex = 0; SwicthObj.style.visibility = 'visible'; } else { SwicthObj.style.visibility = 'hidden'; SwicthObj.style.left = 0; SwicthObj.style.top = 0; SwicthObj.style.zindex = -100; SwicthObj.style.position = 'absolute'; } } else { SwicthObj.style.visibility = 'hidden'; SwicthObj.style.left = 0; SwicthObj.style.top = 0; SwicthObj.style.zindex = -100; SwicthObj.style.position = 'absolute'; } } } } //// Toolbar function Toolbar() { //var ToolbarUrl='./docs/home/toolbar.php?Title=' + window.document.title; //new Ajax.Request(ToolbarUrl, {onSuccess:ToolbarOk, onFailure:AjaxErr}); var HeaderText = ""; HeaderText = HeaderText + ""; HeaderText = HeaderText + ""; HeaderText = HeaderText + ""; if (!Toolbar_NoAction || Toolbar_NoAction == false) { var AddText = "Ajouter une fiche"; var SaveText = "Enregistrer la fiche"; var DeleteText = "Supprimer la fiche"; var GetText = "Recherche"; var txtText = "Utilisez < % > comme caractère générique & < _ > comme substitut."; if ($("LanguageTag").innerHTML == "2" || $("LanguageTag").innerHTML == 2) { AddText = "Add a record"; SaveText = "Save the record"; DeleteText = "Delete the record"; GetText = "Search"; txtText = "Use < % > as a wildcard & < _ > as a substitute."; } if (!Toolbar_NoModif || Toolbar_NoModif == false) { if (!Toolbar_NoAdd || Toolbar_NoAdd == false) { HeaderText = HeaderText + ""; } HeaderText = HeaderText + ""; HeaderText = HeaderText + ""; } HeaderText = HeaderText + ""; } HeaderText = HeaderText + ""; HeaderText = HeaderText + "
"; if (HeaderIcon != "") { HeaderText = HeaderText + "

"; HeaderIcon = "" } else { HeaderText = HeaderText + "

"; } HeaderText = HeaderText + document.title + "

"; HeaderText = HeaderText + "
"; HeaderText = HeaderText + "\"""; HeaderText = HeaderText + ""; HeaderText = HeaderText + "\"""; HeaderText = HeaderText + ""; HeaderText = HeaderText + "\"""; HeaderText = HeaderText + ""; HeaderText = HeaderText + "" + GetText + ""; HeaderText = HeaderText + ""; HeaderText = HeaderText + "\"""; HeaderText = HeaderText + "
"; if (!Toolbar_NoList || Toolbar_NoList == false) { HeaderText = HeaderText + "
"; HeaderText = HeaderText + "
"; HeaderText = HeaderText + ""; // HeaderText = HeaderText + ""; HeaderText = HeaderText + "
"; HeaderText = HeaderText + ""; HeaderText = HeaderText + "

"; if ($("LanguageTag").innerHTML == "2" || $("LanguageTag").innerHTML == 2) { HeaderText = HeaderText + "\"+\"0 item(s) found.

"; } else { HeaderText = HeaderText + "\"+\"0 item(s) trouvé(s)."; } HeaderText = HeaderText + "
"; // if ($("LanguageTag").innerHTML == "2" || $("LanguageTag").innerHTML == 2) // { // HeaderText = HeaderText + "\"First\""; // HeaderText = HeaderText + "\"Previous\""; // HeaderText = HeaderText + "\"Next\""; // HeaderText = HeaderText + "\"Last\""; // } // else // { // HeaderText = HeaderText + "\"Première\""; // HeaderText = HeaderText + "\"Précedente\""; // HeaderText = HeaderText + "\"Suivante\""; // HeaderText = HeaderText + "\"Dernière\""; // } // HeaderText = HeaderText + "
"; HeaderText = HeaderText + ""; HeaderText = HeaderText + ""; HeaderText = HeaderText + "
"; HeaderText = HeaderText + "
"; } if (!Toolbar_NoDetails || Toolbar_NoDetails == false) { //HeaderText = HeaderText + ""; //HeaderText = HeaderText + "

"; HeaderText = HeaderText + "
"; HeaderText = HeaderText + ""; //if ($("LanguageTag").innerHTML == "2" || $("LanguageTag").innerHTML == 2) //{ //HeaderText = HeaderText + "\"+\"Selected Item

"; //HeaderText = HeaderText + "Selected Item"; //HeaderText = HeaderText + ""; //} //else //{ //HeaderText = HeaderText + "\"+\"Item sélectionné"; //HeaderText = HeaderText + "Item sélectionné"; //HeaderText = HeaderText + ""; //} } if ($("Toolbar")) { $("Toolbar").innerHTML = HeaderText; $("Toolbar").style.visibility = "visible"; } setTimeout('SetTxtFocus();', 100) Toolbar_NoAction = false; Toolbar_NoList = false; Toolbar_NoDetails = false; Toolbar_NoModif = false; } function checkEnter(e) { var characterCode ; if(e && e.which) { //e = e; characterCode = e.which ; } else { //e = event; characterCode = e.keyCode ; } if(characterCode == 13) { Search($('frm').txtGet.value); return false; } else { return true; } } function checkKey(e) { var characterCode ; if(e && e.which) { //e = e; characterCode = e.which ; } else { //e = event; characterCode = e.keyCode ; } if(characterCode == 13) { alert("Enter KeyCode"); return false; } else { alert(characterCode); return true; } } // Data to UI function BindData() { SetErrorMsg(true); if($("SearchImage")) { $("SearchImage").src="./images/p16Search.png"; } if (DataSet.Tables[0].Name.indexOf("_List")>0) { BindDataList(); } else { //window.location="#TopLogo"; window.scrollTo(0,0); if (DataSet.Tables[0].Name.indexOf("_Custom")>0) { BindDataCustom(); } else { Ds[DataSet.Tables[0].Name].MoveFirst(); if (DataSet.Tables[0].Name.toUpperCase() != "LANGUE") { Ds.binddata_UI("frm"); } } } if (StartTime && $("aRec")) { var myTime = new Date(); var timeNow = myTime.getTime(); var timeDiff = (timeNow - StartTime)/1000; document.getElementById("aRec").title = timeDiff.toString() + " secondes"; } if(document.body) { document.body.style.cursor = "auto"; } } function BindDataList() { $("content_active").innerHTML=""; if (Ds[DataSet.Tables[0].Name].RecordCount>0) { Ds[DataSet.Tables[0].Name].MoveFirst(); tmp=$("content_tmp").innerHTML; t=tmp.replace("table-1_tmp","table-1").replace("mytable_body_tmp","mytable_body"); $("content_active").innerHTML=t; document.getElementById("table-1").setAttribute(cls, "sortable"); trh =document.createElement("thead"); tru =document.createElement("tr"); for(c=0;c 0) { document.getElementById("lblCount").innerHTML = Ds[DataSet.Tables[0].Name].RecordCount.toString(); } else { document.getElementById("lblCount").innerHTML = ""; } var myTime = new Date(); var timeNow = myTime.getTime(); var timeDiff = (timeNow - StartTime)/1000; document.getElementById("lblCount").title = timeDiff.toString() + " secondes"; //document.getElementById("lblCount").title = "999 secondes"; document.getElementById("content_active").style.visibility="visible"; document.getElementById("content_active").style.display="inline"; if (Searching && Searching == true) { if ($("frm")) { $("frm").style.visibility = "visible"; $('frm').txtGet.focus(); } if ($("Data")) { $("Data").style.visibility = ""; } } Searching = false; if ($('frm')) { $('frm').txtGet.focus(); } if(document.body) { document.body.style.cursor = "auto"; } } //GET function Get(sDocId) { if (sDocId) { SwitchVisible('table-1', 'hidden'); SwitchVisible('DataDoc', 'visible'); StartDay = new Date(); StartTime = StartDay.getTime(); CurrentDocument = sDocId; var target=DataUrl+'?action=get&DocId='+sDocId+'&lsid='+LocalSession; new Ajax.Request(target, {onSuccess:make_rs, onFailure:AjaxErr}); } } //Search function Search(sDoc) { while (sDoc.indexOf(";") > -1 || sDoc.indexOf("'") > -1) { sDoc = sDoc.replace(";", "").replace("'", ""); } StartDay = new Date(); StartTime = StartDay.getTime(); SwitchVisible('DataDoc', 'hidden'); $("SearchImage").src="./images/Searching.gif"; var target=DataUrl+'?action=search&DocText='+sDoc+'&lsid='+LocalSession; new Ajax.Request(target, {onSuccess:make_rs, onFailure:AjaxErr}); if(document.body) { document.body.style.cursor = "wait"; } } //NEW function New() { if ($("table-1")) { SwitchVisible('table-1', 'hidden'); } if ($("DataDoc")) { SwitchVisible('DataDoc', 'visible'); } var target=DataUrl+'?action=new'+'&lsid='+LocalSession; new Ajax.Request(target, {onSuccess:make_rs, onFailure:AjaxErr}); } /// SAVE function save(xmlData) { if ($("SaveButton")) { $("SaveButton").style.visibility = "hidden"; } if (Valid()) { var save_dataset = new Ajax.Request(DataUrl, { method:'post', parameters:'action=save&doc='+escape(xmlData), onSuccess:SaveOk, onFailure:AjaxErr}); Ds.binddata_UI("frm"); } else { if ($("SaveButton")) { $("SaveButton").style.visibility = "visible"; } } } function SaveOk(t) { var newStr ; var pos ; if (SaveMsg) { if (t.responseText == 1 || t.responseText == "Driver={IBM INFORMIX ODBC DRIVER};Host=192.168.20.20;Server=odbc_se;Service=sqlexec;Protocol=sesoctcp;Database= /u2/ogcplus/sys1/gest/;Uid=ogc_odbc;Pwd=tc7873403;Langue=1;o2uid=3;1" ) { //Ds[Ds.Rs[0]].Update(Ds[Ds.Rs[0]].Fields('datarowstate').Name, "modified"); if ($("LanguageTag").innerHTML == "2" || $("LanguageTag").innerHTML == 2) { alert("Save succesful."); } else { alert("Enregistrement effectué avec succès."); } } else { if ($("LanguageTag").innerHTML == "2" || $("LanguageTag").innerHTML == 2) { alert("Impossible to Save the record."); } else { alert("Impossible d'effectuer wdrf l'enregistrement."); } } } //if add Ds[Ds.Rs[0]].Update(Ds[Ds.Rs[0]].Fields('datarowstate').Name, "modified"); //if del //se cache SaveMsg = true; if (SaveAfterUrl != null && SaveAfterUrl != "") { var NavUrl = SaveAfterUrl; SaveAfterUrl = ""; Nav(NavUrl); } else { if ($("SaveButton")) { $("SaveButton").style.visibility = "visible"; } } } /// DELETE function Delete() { var ConfirmText = "Êtes-vous certains de vouloir supprimer la fiche ?"; if ($("LanguageTag").innerHTML == "2" || $("LanguageTag").innerHTML == 2) { ConfirmText = "Are you sure that you want to delete this record ?"; } if (confirm(ConfirmText)) { Ds[Ds.Rs[0]].Update(Ds[Ds.Rs[0]].Fields('datarowstate').Name, "deleted"); SaveMsg = false; SaveData(); SwitchVisible('DataDoc', 'hidden'); //SwitchVisible('table-1', 'hidden'); $("content_active").style.display = "none"; } } /// PRINT function PrintDocument(Page) { FixUI(false); window.print(); setTimeout('FixUI(true);', 2000) } /// EMAIL function EmailDocument(Page) { FixUI(false); //window.print(); setTimeout('FixUI(true);', 1000) // while ($("LinesBody").firstChild) // { // //The list is LIVE so it will re-index each call // $("LinesBody").removeChild($("LinesBody").firstChild); // }; if($("ActionBar") != null) { var tmpData = $("ActionBar").innerHTML; while ($("ActionBar").firstChild) { $("ActionBar").removeChild($("ActionBar").firstChild); }; } if($("MenuBar") != null) { var tmpDataMenu = $("MenuBar").innerHTML; while ($("MenuBar").firstChild) { $("MenuBar").removeChild($("MenuBar").firstChild); }; } var save_dataset = new Ajax.Request(DataUrl, { method:'post', parameters:'action=email&doc='+escape($("DataDoc").innerHTML)+'&lsid='+LocalSession, onSuccess:EmailDocumentOk, onFailure:AjaxErr}); HtmlToPdf($("DataDoc").innerHTML, "document.pdf"); if($("ActionBar") != null) { $("ActionBar").innerHTML = tmpData; } if($("MenuBar") != null) { $("MenuBar").innerHTML = tmpDataMenu; } } function EmailDocumentOk(Response) { alert("Email envoyé."); } function FixUI(Style) { if (Style) { document.body.style.padding = ""; document.body.style.margin = ""; document.body.style.backgroundColor = ""; $("ShellMainHeader_Row").style.display = ""; $("ShellMainTopNav_Row").style.display = ""; $("ShellMainFooter_Row").style.display = ""; $("Toolbar").style.display = ""; if ($("ActionBar")) { $("ActionBar").style.display = ""; } if ($("MenuBar")) { $("MenuBar").style.display = ""; } if ($("ShellZoneSideMenu")) { $("ShellZoneSideMenu").style.display = ""; } $("ShellMain").style.borderWidth = ""; } else { document.body.style.padding = "0px"; document.body.style.margin = "0px"; document.body.style.backgroundColor = "White"; $("ShellMainHeader_Row").style.display = "none"; $("ShellMainTopNav_Row").style.display = "none"; $("ShellMainFooter_Row").style.display = "none"; $("Toolbar").style.display = "none"; if ($("ActionBar")) { $("ActionBar").style.display = "none"; } if ($("MenuBar")) { $("MenuBar").style.display = "none"; } if ($("ShellZoneSideMenu")) { $("ShellZoneSideMenu").style.display = "none"; } $("ShellMain").style.borderWidth = "0px"; } } function PrintOk(t) { //alert(t.responseText); window.open(window.location); } //Lsv Select function choice(e) { var sDocId = ""; //var SaveAfterUrl = ""; e=(window.event)? event.srcElement: e.currentTarget; if (!ie && !Chrome) { sDocId=e.firstChild.firstChild.nodeValue; } else { sDocId=e.parentNode.childNodes[0].childNodes[0].nodeValue; } SwitchVisible('table-1', 'hidden'); SwitchVisible('DataDoc', 'visible'); //alert(sDocId); StartDay = new Date(); StartTime = StartDay.getTime(); //Get(sDocId); var target=DataUrl+'?action=get&DocId='+sDocId+'&lsid='+LocalSession; CurrentDocument = sDocId; new Ajax.Request(target, {onSuccess:make_rs, onFailure:AjaxErr}); } function Valid() { var isValid = true; var els = document.getElementsByTagName("*"); for (i=0;i