2 * This file is part of NOALYSS.
4 * NOALYSS is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * NOALYSS is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with NOALYSS; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20// Copyright Author Dany De Bontridder danydb@aevalys.eu
23 * \brief javascript script, always added to every page
27// tag_choose Element which contains all the selected tags
29var aDraggableElement = new Array();
31// document.viewport depends of prototype.js
32var viewport = document.viewport.getDimensions(); // Gets the viewport as an object literal
33var width = viewport.width; // Usable window width
34var height = viewport.height;
36 * return undefined if nothing is found , otherwise return the DOM elemnt
37 * @param {type} p_name_dom
38 * @param {type} name_child
39 * @returns {undefined}
41function in_child(p_element,name_child) {
43 if ( typeof p_element !== "object" ) {
44 element=document.getElementById(p_element);
47 if ( ! element ) return undefined;
48 for ( var e=0; e < element.childElementCount;e++) {
49 if ( element.childNodes[e].id == name_child) {
50 return element.childNodes[e];
55 * callback function when we just need to update a hidden div with an info
58function infodiv(req, json)
63 var answer = req.responseXML;
64 var a = answer.getElementsByTagName('ctl');
65 var html = answer.getElementsByTagName('code');
68 var rec = req.responseText;
69 alert_box('erreur :' + rec);
71 var name_ctl = a[0].firstChild.nodeValue;
72 var code_html = getNodeText(html[0]);
74 code_html = unescape_xml(code_html);
75 g(name_ctl + "info").innerHTML = code_html;
78 alert_box("success_box" + e.message);
82 code_html.evalScripts();
85 alert_box(content[53] + "\n" + e.message);
90 * delete a row from a table (tb) the input button send the this
93function deleteRow(tb, obj)
95 smoke.confirm(content[50], function (e)
98 var td = obj.parentNode;
99 var tr = td.parentNode;
100 var lidx = tr.rowIndex;
101 g(tb).deleteRow(lidx);
108function deleteRowRec(tb, obj)
111 var lidx = tr.rowIndex;
112 g(tb).deleteRow(lidx);
114/*!\brief remove trailing and heading space
115 * \param the string to modify
116 * \return string without heading and trailing space
120 return s.replace(/^\s+/, '').replace(/\s+$/, '');
124 * retrieve an element thanks its ID
125 * @param ID is a string
126 * @return the found object of undefined if not found
130 if (document.getElementById)
132 return this.document.getElementById(ID);
133 } else if (document.all)
135 return document.all[ID];
142 * enable the type of periode
144function enable_type_periode()
146 if ($("type_periode").options[$("type_periode").selectedIndex].value == 0)
148 $('from_periode').enable();
149 $('to_periode').enable();
150 $('from_date').disable();
151 $('to_date').disable();
152 $('p_step').enable();
155 $('from_periode').disable();
156 $('to_periode').disable();
157 $('from_date').enable();
158 $('to_date').enable();
159 $('p_step').disable();
164 * will reload the window but it is dangerous if we have submitted
167function refresh_window()
169 window.location.reload();
174 * we receive a json object as parameter and the function returns the string
175 * with the format variable=value&var2=val2...
177function encodeJSON(obj)
179 if (typeof obj != 'object')
181 alert_box('encodeParameter obj n\'est pas un objet');
197 str += '=' + encodeURI(obj[i]);
202 alert_box('encodeParameter ' + e.message);
206function hide(p_param)
208 g(p_param).style.display = 'none';
210function show(p_param)
212 g(p_param).style.display = 'block';
216 * set the focus on the selected field
217 *@param Field id of the control
218 *@param selectIt : the value selected in case of Field is a object select, numeric
220function SetFocus(Field, SelectIt)
230 * set a DOM id with a value in the parent window (the caller),
231 @param p_ctl is the name of the control
232 @param p_value is the value to set in
233 @param p_add if we don't replace the current value but we add something
235function set_inparent(p_ctl, p_value, p_add)
237 self.opener.set_value(p_ctl, p_value, p_add);
241 * set a DOM id with a value, it will consider if it the attribute
242 value or innerHTML has be used
243 @param p_ctl is the name of the control
244 @param p_value is the value to set in
245 @param p_add if we don't replace the current value but we add something
247function set_value(p_ctl, p_value, p_add)
251 var g_ctrl = g(p_ctl);
252 if (p_add != undefined && p_add === 1)
256 p_value = g_ctrl.value + ',' + p_value;
259 if (g_ctrl.tagName === 'INPUT')
261 g(p_ctl).value = p_value;
263 if (g_ctrl.tagName === 'SPAN')
265 g(p_ctl).innerHTML = p_value;
267 if (g_ctrl.tagName === 'SELECT')
269 g(p_ctl).value = p_value;
274 * compute small math in numeric cells
275 * @param string value
278function compute_number(value)
282 var exp = new RegExp("^[0-9/*+-.()]+$", "g");
283 /*pour éviter un eval() mal intentionné*/
284 var res = exp.test(value);
287 /*pour gérer un nombre non valide comme 5..36 ou 5.3.6
288 parce qu'il est possible d'entrer plusieurs
289 points dans le nombre et eval() lève une exception*/
292 retval = eval(value);
295 return parseFloat(value);
297 /*pour gérer les divisions par 0*/
298 if (retval == Infinity)
310 * format the number change comma to point
313function format_number(obj, p_prec)
316 if (p_prec === undefined)
322 var value = obj.value;
323 value = value.replace(/ /g, '');
324 value = value.replace(/,/g, '.');
327 value=compute_number(value);
329 value = parseFloat(value);
334 var arrondi = Math.pow(10, precision);
336 value = Math.round(value * arrondi) / arrondi;
338 $(obj).value = value;
342 * Replace slash , space and minus by dot
343 * @param p_object DOM Element date to check
345function format_date(p_object)
347 p_object.value=p_object.value.replace(/\//g,'.');
348 p_object.value=p_object.value.replace(/-/g,'.');
349 p_object.value=p_object.value.replace(/ /g,'.');
350 p_object.value=p_object.value.replace(/\.\./g,'.');
351 var tmp_value = p_object.value;
352 a_split=tmp_value.split('.');
353 if (a_split[2] && a_split[2].match(/[0-9]{2}/) && a_split[2].length==2) {
354 a_split[2]="20"+a_split[2];
355 p_object.value=a_split[0]+"."+a_split[1]+"."+a_split[2];
357 var nMonth=parseFloat(a_split[1])-1;
358 var ma_date = new Date(a_split[2], nMonth, a_split[0]);
359 if(ma_date.getFullYear()==a_split[2] && ma_date.getMonth()==nMonth && ma_date.getDate() == a_split[0]){
362 new Effect.Highlight(p_object.id,{startcolor:"#ff0000"});
369 * check if the object is hidden or show and perform the opposite,
370 * show the hidden obj or hide the shown one. With display : flex,
371 *@param name of the object
372 * @param button id of the button
373 * @param rotate : if true with rotate the object of p_button otherwise
375function toggleHideShow(p_obj, p_button,rotate)
377 var div_obj=g(p_obj);
378 var stat = div_obj.style.display;
380 var str = ( g(p_button))?g(p_button).value:"";
384 // specific for the DIV id search_form
385 if( div_obj.id=='search_form') { show(p_obj); } else { $(p_obj).show()}
386 str = str.replace(/Afficher/, content[62]);
387 g(p_button).value = str;
390 // specific for the DIV di search_form
391 if(!div_obj.id=='search_form') { hide(p_obj); } else { $(p_obj).hide()}
392 str = str.replace(/Cacher/, content[63]);
393 g(p_button).value = str;
395 if ( ! rotate ) return;
396 if ( stat == "none") {
397 g(p_button).addClassName ("icon-up-open-1")
398 g(p_button).removeClassName(" icon-down-open-2")
400 g(p_button).removeClassName("icon-up-open-1")
401 g(p_button).addClassName(" icon-down-open-2")
407 * open popup with the search windows
408 *@param p_dossier the dossier where to search
409 *@param p_style style of the detail value are E for expert or S for simple
411function popup_recherche(p_dossier)
413 var w = window.open("recherche.php?gDossier=" + p_dossier + "&ac=SEARCH", '', 'statusbar=no,scrollbars=yes,toolbar=no');
417 * replace the special characters (><'") by their HTML representation
418 *@return a string without the offending char.
420function unescape_xml(code_html)
422 code_html = code_html.replace(/\</, '<');
423 code_html = code_html.replace(/\>/, '>');
424 code_html = code_html.replace(/\"/, '"');
425 code_html = code_html.replace(/\'/, "'");
426 code_html = code_html.replace(/\&/, '&');
430 * Firefox splits the XML into 4K chunk, so to retrieve everything we need
431 * to get the different parts thanks textContent
432 *@param xmlNode a node (result of var data = =answer.getElementsByTagName('code'))
433 *@return all the content of the XML node
435function getNodeText(xmlNode)
439 if (typeof (xmlNode.textContent) != "undefined")
441 return xmlNode.textContent;
443 if (xmlNode.firstChild && xmlNode.firstChild.nodeValue)
444 return xmlNode.firstChild.nodeValue;
448 * change the periode in the calendar of the dashboard
449 *@param object select
451function change_month(obj)
453 var action = new Ajax.Request(
457 parameters: {gDossier: obj.gDossier, op: 'cal', "per": obj.value, t: obj.type_display, notitle: obj.notitle},
458 onFailure: ajax_misc_failure,
459 onSuccess: success_misc
465 * basic answer to ajax on success, it will fill the DOMID code with
466 * the code. In that case, you need to create the object before the Ajax.Request
467 *The difference with success box is that
468 *@see add_div removeDiv success_box is that the width and height are not changed ajax_misc.php
469 *@param code is the ID of the object containing the html (div, button...)
470 *@param value is the html code, with it you fill the ctl element
473function success_misc(req)
477 var answer = req.responseXML;
478 var html = answer.getElementsByTagName('code');
479 if (html.length === 0)
481 var rec = req.responseText;
482 alert_box('erreur :' + rec);
484 var nodeXml = html[0];
485 var code_html = getNodeText(nodeXml);
486 code_html = unescape_xml(code_html);
487 $("user_cal").innerHTML = code_html;
490 alert_box(e.message);
494 code_html.evalScripts();
497 alert_box(content[53] + "\n" + e.message);
504 var str='<div class="loading_msg"></div>';
505 str+='<div class="loading_msg"></div>';
506 str+='<div class="loading_msg"></div>';
507 str+='<div class="loading_msg"></div>';
508 str+='<div class="loading_msg"></div>';
513function ajax_misc_failure()
515 alert_box(content[53]);
518 * remove a document_modele
520function cat_doc_remove(p_dt_id, p_dossier)
522 var queryString = "gDossier=" + p_dossier + "&op=rem_cat_doc" + "&dt_id=" + p_dt_id;
523 var action = new Ajax.Request(
524 "ajax_misc.php", {method: 'get',
525 parameters: queryString,
526 onFailure: ajax_misc_failure,
527 onSuccess: function (req)
531 var answer = req.responseXML;
532 var html = answer.getElementsByTagName('dtid');
533 if (html.length === 0)
535 var rec = req.responseText;
536 alert_box('erreur <br>' + rec);
539 var nodeXML = html[0];
540 var row_id = getNodeText(nodeXML);
541 if (row_id === 'nok')
543 var message_node = answer.getElementsByTagName('message');
544 var message_text = getNodeText(message_node[0]);
545 alert_box('erreur <br>' + message_text);
548 $('row' + row_id).style.textDecoration = "line-through";
549 $('X' + row_id).style.display = 'none';
550 $('M' + row_id).style.display = 'none';
553 alert_box(e.message);
560 * change a document_modele
562function cat_doc_change(p_dt_id, p_dossier)
564 var queryString = "gDossier=" + p_dossier + "&op=mod_cat_doc" + "&dt_id=" + p_dt_id;
565 var nTop = calcy(posY);
567 var str_style = "top:" + nTop + "px;left:" + nLeft + ";width:50em;height:auto";
569 removeDiv('change_doc_div');
571 var action = new Ajax.Request(
574 method: 'get', parameters: queryString,
575 onFailure: ajax_misc_failure,
576 onSuccess: function (req) {
577 remove_waiting_box();
578 add_div({id: 'change_doc_div', style: str_style, cssclass: 'inner_box', drag: "1"});
579 $('change_doc_div').innerHTML = req.responseText;
587 * display the popup with vat and explanation
588 *@param obj with 4 attributes gdossier, ctl,popup
589 *@param p_function_callback callback function to be called after,
591function popup_select_tva(obj,p_function_callback)
595 if ($('tva_select')) {
596 removeDiv('tva_select');
599 var queryString = "gDossier=" + obj.gDossier + "&op=dsp_tva" + "&ctl=" + obj.ctl + '&popup=' + 'tva_select';
601 queryString += '&code=' + obj.jcode;
603 queryString += '&compute=' + obj.compute;
605 queryString += '&filter=' + obj.filter;
607 var action = new Ajax.Request(
610 parameters: queryString,
611 onFailure: ajax_misc_failure,
612 onSuccess: function (req)
616 var answer = req.responseXML;
617 var popup = answer.getElementsByTagName('popup');
618 if (popup.length === 0)
620 var rec = req.responseText;
621 alert_box('erreur :' + rec);
623 var html = answer.getElementsByTagName('code');
625 var name_ctl = popup[0].firstChild.nodeValue;
626 var nodeXml = html[0];
627 var code_html = getNodeText(nodeXml);
628 code_html = unescape_xml(code_html);
630 var nTop = posY - 200;
632 var str_style = "top:" + nTop + "px;left:" + nLeft + ";right:" + nLeft + ";width:55em;height:auto";
634 var popup = {'id': 'tva_select', 'cssclass': 'inner_box', 'style': str_style, 'html': code_html, 'drag': false};
636 $('lk_tva_select_table').focus();
637 sorttable.makeSortable($('tva_select_table'));
638 if ( p_function_callback) {
639 p_function_callback.call(null);
643 alert_box("success_popup_select_tva " + e.message);
650 alert_box("popup_select_tva " + e.message);
656 * display the popup with vat and explanation
657 *@param obj with 4 attributes gdossier, ctl,popup
659function set_tva_label(obj)
663 var queryString = "gDossier=" + obj.gDossier + "&op=label_tva" + "&id=" + obj.value;
665 queryString += '&code=' + obj.jcode;
666 var action = new Ajax.Request(
669 parameters: queryString,
670 onFailure: ajax_misc_failure,
671 onSuccess: success_set_tva_label
676 alert_box("set_tva_label " + e.message);
680 * display the popup with vat and explanations
681 *@param string req answer from ajax
683function success_set_tva_label(req)
687 var answer = req.responseXML;
688 var code = answer.getElementsByTagName('code');
689 var value = answer.getElementsByTagName('value');
691 if (code.length === 0)
693 var rec = req.responseText;
694 alert_box('erreur :' + rec);
697 var label_code = code[0].firstChild.nodeValue;
698 var label_value = value[0].firstChild.nodeValue;
699 set_value(label_code, label_value);
702 alert_box("success_set_tva_label " + e.message);
708 * Create a div without showing it
711 * - style to add style
713 * - cssclass to add a class
714 * - html is the content
715 * - drag is the div can be moved
716 * @returns html dom element
719function create_div(obj)
726 elt = top.createElement('div');
732 elt.setAttribute('id', obj.id);
736 if (elt.style.setAttribute)
738 elt.style.setAttribute('cssText', obj.style);
741 elt.setAttribute('style', obj.style);
746 elt.setAttribute('class', obj.cssclass); /* FF */
747 elt.setAttribute('className', obj.cssclass); /* IE */
751 elt.innerHTML = obj.html;
754 var bottom_div = document.body;
756 bottom_div.appendChild(elt);
758 /* if ( obj.effect && obj.effect != 'none' ) { Effect.Grow(obj.id,{direction:'top-right',duration:0.1}); }
759 else if ( ! obj.effect ){ Effect.Grow(obj.id,{direction:'top-right',duration:0.1}); }*/
762 aDraggableElement[obj.id] = new Draggable(obj.id, {starteffect: function ()
764 new Effect.Highlight(obj.id, {scroll: window, queue: 'end'});
773 error_message("create_div " + e.message);
777 * add dynamically a object for AJAX
780 * - style to add style
782 * - cssclass to add a class
783 * - html is the content
784 * - drag is the div can be moved
789 var elt = create_div(obj);
790 /* elt.setStyle({visibility:'visible'}); */
791 elt.style.visibility = 'visible';
796 alert_box("add_div " + e.message);
800 * remove a object created with add_div
801 * @param elt id of the elt
803function removeDiv(elt)
807 document.body.removeChild(g(elt));
809 // if reloaded if asked the window will be reloaded when
811 if (ask_reload === 1)
813 // avoid POST window.location = window.location.href;
814 window.location.reload();
817function waiting_node()
819 $('info_div').innerHTML = 'Un instant';
820 $('info_div').style.display = "block";
823 *show a box while loading
824 *must be remove when ajax is successfull
827function waiting_box()
830 id: 'wait_box', html: loading()+'<p>' + content[65] + '</p>'
832 var y = fixed_position(10, 250)
833 obj.style = y + ";width:20%;margin-left:40%;";
835 removeDiv('wait_box');
843 * call add_div to add a DIV and after call the ajax
844 * the queryString, the callback for function for success and error management
845 * the method is always GET
846 *@param obj, the mandatory attributes are
847 * - obj.qs querystring
848 * - obj.js_success callback function in javascript for handling the xml answer
849 * - obj.js_error callback function for error
850 * - obj.callback the php file to call
851 * - obj.fixed optional let you determine the position, otherwise works like IPopup
854function show_box(obj)
859 g(obj.id).style.top = calcy(40) + "px";
866 var action = new Ajax.Request(
871 onFailure: eval(obj.js_error),
872 onSuccess: eval(obj.js_success)
876 * receive answer from ajax and just display it into the IBox
877 * XML must contains at least 2 fields : ctl is the ID of the IBOX and
878 * code is the HTML to put in it
881function success_box(req, json)
885 var answer = req.responseXML;
886 var a = answer.getElementsByTagName('ctl');
887 var html = answer.getElementsByTagName('code');
890 var rec = req.responseText;
891 alert_box(content[48] + rec);
893 var name_ctl = a[0].firstChild.nodeValue;
894 var code_html = getNodeText(html[0]);
896 code_html = unescape_xml(code_html);
897 g(name_ctl).innerHTML = code_html;
898 g(name_ctl).style.height = 'auto';
900 if (name_ctl == 'popup')
901 g(name_ctl).style.width = 'auto';
904 alert_box("success_box" + e.message);
908 code_html.evalScripts();
911 alert_box(content[53] + "\n" + e.message);
917 alert_box(content[53]);
920 * show the ledger choice
922function show_ledger_choice(json_obj)
928 var query = "gDossier=" + json_obj.dossier + '&type=' + json_obj.type + '&div=' + json_obj.div + '&op=ledger_show';
929 query = query + '&nbjrn=' + $(json_obj.div + 'nb_jrn').value;
930 query = query + '&all_type=' + json_obj.all_type;
931 for (i = 0; i < $(json_obj.div + 'nb_jrn').value; i++) {
932 query = query + "&r_jrn[]=" + $(json_obj.div + 'r_jrn[' + i + ']').value;
934 query = encodeURI(query);
935 var action = new Ajax.Request(
939 onFailure: ajax_misc_failure,
940 onSuccess: function (req, json) {
942 if ( req.responseText === 'NOCONX') { reconnect();return;}
944 id: json_obj.div + 'jrn_search',
945 cssclass: 'inner_box',
946 style: ';position:absolute;width:auto;z-index:20;margin-left:20%',
952 obj.style = "top:" + y + 'px;' + obj.style;
953 /* if ( json_obj.class )
955 obj.cssclass=json_obj.class;
960 var answer = req.responseXML;
961 var a = answer.getElementsByTagName('ctl');
962 var html = answer.getElementsByTagName('code');
963 if (a.length === 0) {
964 var rec = req.responseText;
965 alert_box('erreur :' + rec);
967 var name_ctl = a[0].firstChild.nodeValue;
968 var code_html = getNodeText(html[0]);
970 code_html = unescape_xml(code_html);
971 remove_waiting_box();
972 g(obj.id).innerHTML = code_html;
975 alert_box("show_ledger_callback" + e.message);
978 code_html.evalScripts();
980 alert_box(content[53] + "\n" + e.message);
988 alert_box('show_ledger_choice' + e.message);
992 * hide the ledger choice
994function hide_ledger_choice(p_frm_search)
998 var nb = $(p_frm_search).nb_jrn.value;
1000 if ($(p_frm_search).div) {
1001 div = $(p_frm_search).div.value;
1008 for (i = 0; i < nb; i++) {
1009 n_name = div + "r_jrn[" + sel + "]";
1010 name = div + "r_jrn" + i;
1011 if ($(name).checked) {
1012 str += '<input type="hidden" id="' + n_name + '" name="' + n_name + '" value="' + $(name).value + '">';
1016 str += '<input type="hidden" name="' + div + 'nb_jrn" id="' + div + 'nb_jrn" value="' + sel + '">';
1017 $('ledger_id' + div).innerHTML = str;
1018 removeDiv(div + 'jrn_search');
1021 alert_box('hide_ledger_choice' + e.message);
1027 * show the cat of ledger choice
1029function show_cat_choice()
1031 g('div_cat').style.visibility = 'visible';
1034 * hide the cat of ledger choice
1036function hide_cat_choice()
1038 g('div_cat').style.visibility = 'hidden';
1041 * add a row for the forecast item
1043function for_add_row(tableid)
1045 style = 'class="input_text"';
1046 var mytable = g(tableid).tBodies[0];
1047 var nNumberRow = mytable.rows.length;
1048 var oRow = mytable.insertRow(nNumberRow);
1049 var rowToCopy = mytable.rows[1];
1050 var nNumberCell = rowToCopy.cells.length;
1051 var nb = g("nbrow");
1052 var oNewRow = mytable.insertRow(nNumberRow);
1053 for (var e = 0; e < nNumberCell; e++)
1055 var newCell = oRow.insertCell(e);
1056 var tt = rowToCopy.cells[e].innerHTML;
1057 new_tt = tt.replace(/an_cat0/g, "an_cat" + nb.value);
1058 new_tt = new_tt.replace(/an_cat_acc0/g, "an_cat_acc" + nb.value);
1059 new_tt = new_tt.replace(/an_qc0/g, "an_qc" + nb.value);
1060 new_tt = new_tt.replace(/an_label0/g, "an_label" + nb.value);
1061 new_tt = new_tt.replace(/month0/g, "month" + nb.value);
1062 new_tt = new_tt.replace(/an_cat_amount0/g, "an_cat_amount" + nb.value);
1063 new_tt = new_tt.replace(/an_deb0/g, "an_deb" + nb.value);
1064 newCell.innerHTML = new_tt;
1065 new_tt.evalScripts();
1067 $("an_cat_acc" + nb.value).value = "";
1068 $("an_qc" + nb.value).value = "";
1069 $("an_label" + nb.value).value = "";
1070 $("an_cat_amount" + nb.value).value = "0";
1074 * toggle all the checkbox in a given form
1075 * @param form_id id of the form
1077function toggle_checkbox(form_id)
1079 var form = g(form_id);
1080 for (var i = 0; i < form.length; i++)
1082 var e = form.elements[i];
1083 if (e.type === 'checkbox')
1085 if (e.checked === true)
1096 * select all the checkbox in a given form
1097 * @param form_id id of the form
1099function select_checkbox(form_id)
1101 var form = $(form_id);
1102 for (var i = 0; i < form.length; i++)
1104 var e = form.elements[i];
1105 if (e.type === 'checkbox')
1112 * select all the checkbox in a given form if the specific attribute
1113 * has the given value
1114 * @param form_id id of the form
1115 * @param attribute name
1116 * @param attribute value
1118function select_checkbox_attribute(form_id, p_attribute_name, p_attribute_value)
1120 var form = $(form_id);
1121 for (var i = 0; i < form.length; i++)
1123 var e = form.elements[i];
1124 if (e.type === 'checkbox' && e.getAttribute(p_attribute_name) == p_attribute_value)
1131 * unselect all the checkbox in a given form
1132 * @param form_id id of the form
1134function unselect_checkbox(form_id)
1136 var form = $(form_id);
1137 for (var i = 0; i < form.length; i++)
1139 var e = form.elements[i];
1140 if (e.type === 'checkbox')
1147 * show the calculator
1153 this.document.getElementById('inp').value = "";
1154 this.document.getElementById('inp').focus();
1159 shtml += "<div class=\"bxbutton\">";
1160 shtml += '<a class="icon" onclick="pin(\'calc1\')" id="pin_calc1"></a> <a onclick="removeDiv(\'calc1\');" href="javascript:void(0)" title="" class="icon">⨉</a>';
1162 shtml += ' <h2 class="title">' + content[66] + '</h2>';
1163 shtml += '<form name="calc_line" method="GET" onSubmit="cal();return false;" >' + content[68] + '<input class="input_text" type="text" id="inp" name="calculator"> <input type="button" value="Efface" class="button" onClick="Clean();return false;" > <input type="button" value="Efface historique" class="button" onClick="CleanHistory();return false;" > <input type="button" class="button" value="Fermer" onClick="removeDiv(\'calc1\')" >';
1164 shtml += '</form><span class="highligth" style="display:block" id="sub_total"> ' + content[67] + ' </span><span style="display:block" id="listing"> </span>';
1166 var obj = {id: sid, html: shtml,
1167 drag: false, style: 'z-index:98'
1170 this.document.getElementById('inp').focus();
1172function display_periode(p_dossier, p_id)
1177 var queryString = "gDossier=" + p_dossier + "&op=input_per" + "&p_id=" + p_id;
1178 var popup = {'id': 'mod_periode', 'cssclass': 'inner_box', 'html': loading(), 'style': 'width:30em', 'drag': true};
1179 if (!$('mod_periode')) {
1182 var action = new Ajax.Request(
1185 parameters: queryString,
1186 onFailure: ajax_misc_failure,
1187 onSuccess: success_display_periode
1190 $('mod_periode').style.top = (posY - 70) + "px";
1191 $('mod_periode').style.left = (posX - 70) + "px";
1194 alert_box("display_periode " + e.message);
1198function success_display_periode(req)
1203 var answer = req.responseXML;
1204 var html = answer.getElementsByTagName('data');
1206 if (html.length === 0)
1208 var rec = req.responseText;
1209 alert_box('erreur :' + rec);
1212 var code_html = getNodeText(html[0]);
1213 code_html = unescape_xml(code_html);
1215 $('mod_periode').innerHTML = code_html;
1218 alert_box("success_display_periode".e.message);
1222 code_html.evalScripts();
1225 alert_box(content[53] + "\n" + e.message);
1229function save_periode(obj)
1233 var queryString = $(obj).serialize() + "&op=save_per";
1235 var action = new Ajax.Request(
1238 parameters: queryString,
1239 onFailure: ajax_misc_failure,
1240 onSuccess: success_display_periode
1246 alert_box("display_periode " + e.message);
1252 * basic answer to ajax on success, it will fill the ctl with
1253 * the code. In that case, you need to create the object before the Ajax.Request
1254 *The difference with success box is that
1255 *@see add_div removeDiv success_box is that the width and height are not changed
1256 *@param ctl is the ID of the object containing the html (div, button...)
1257 *@param code is the html code, with it you fill the ctl element
1259function fill_box(req)
1262 if (req.responseText=='NOCONX') { reconnect(); return;}
1263 remove_waiting_box();
1265 var answer = req.responseXML;
1266 var a = answer.getElementsByTagName('ctl');
1267 var html = answer.getElementsByTagName('code');
1268 if (a.length === 0) {
1269 var rec = req.responseText;
1270 alert_box('erreur :' + rec);
1272 var name_ctl = a[0].firstChild.nodeValue;
1273 var code_html = getNodeText(html[0]); // Firefox ne prend que les 4096 car.
1274 code_html = unescape_xml(code_html);
1275 $(name_ctl).innerHTML = code_html;
1277 alert_box(e.message);
1280 console.error("log answer = " + req.responseText);
1284 code_html.evalScripts();
1288 console.error("log answer = " + req.responseText);
1290 alert_box(content[53] + "\n" + e.message);
1296 *display a popin to let you modified a predefined operation
1298 *@param od_id from table op_predef
1300function mod_predf_op(dossier_id, od_id,p_ledger)
1302 var target = "mod_predf_op";
1304 var str_style = "top:10%;left:2%;width:96%";
1306 var div = {id: target, cssclass: 'inner_box', style: str_style, html: loading(), drag: 1};
1310 var qs = "gDossier=" + dossier_id + '&op=mod_predf&id=' + od_id+'&ledger_id='+p_ledger;
1312 var action = new Ajax.Request('ajax_misc.php',
1323function save_predf_op(obj)
1326 var querystring = $(obj).serialize() + '&op=save_predf';
1327 // Create a ajax request to get all the person
1328 var action = new Ajax.Request('ajax_misc.php',
1331 parameters: querystring,
1333 onSuccess: refresh_window
1341 *ctl_concern is the widget to update
1342 *amount_id is either a html obj. or an amount and the field tiers if given
1343 * @param {type} dossier
1344 * @param {type} ctl_concern
1345 * @param {float or string} amount_id Amount or DOM Id of the element containing the amount
1346 * @param {float} ledger
1347 * @param {type} p_id_targetDom Element (div) where to display the search result
1348 * @param p_tiers id of the Tiers
1349 * @returns {undefined}
1351function search_reconcile(dossier, ctl_concern, amount_id, ledger, p_id_target, p_tiers)
1353 if (amount_id === undefined)
1356 } else if ($(amount_id))
1358 if ($(amount_id).value)
1360 amount_id = $(amount_id).value;
1362 ($(amount_id).innerHTML) {
1363 amount_id = $(amount_id).innerHTML;
1370 if (p_id_target != "") {
1371 target = p_id_target;
1373 target = "search" + layer;
1376 var str_style = fixed_position(77, 99);
1377 str_style += ";width:92%;overflow:auto;";
1379 var hide_operation = $(ctl_concern).getAttribute("hide_operation");
1380 var single_operation = $(ctl_concern).getAttribute("single_operation");
1382 var param_send = {gDossier: dossier,
1386 amount_id: amount_id,
1390 hide_operation: hide_operation,
1391 single_operation:single_operation
1394 var qs = encodeJSON(param_send);
1396 var action = new Ajax.Request('ajax_misc.php',
1401 onSuccess: function (req) {
1402 remove_waiting_box();
1403 var div = {id: target, cssclass: 'inner_box', style: str_style, drag: 0};
1405 $(target).innerHTML = req.responseText;
1406 req.responseText.evalScripts();
1412 * search in a popin obj if the object form
1414function search_operation(obj)
1417 var dossier = g('gDossier').value;
1419 var target = "search" + layer;
1420 if ($(obj)["target"]) {
1421 target = $(obj)["target"].value;
1423 var qs = Form.serialize('search_form_ajx') + "&op=search_op";
1424 var action = new Ajax.Request('ajax_misc.php',
1429 onSuccess: function (req) {
1430 remove_waiting_box();
1431 $(target).innerHTML = req.responseText;
1432 req.responseText.evalScripts();
1438 remove_waiting_box();
1439 alert_box(e.message);
1443 * Update the field e_concerned, from class_iconcerned
1444 * Value is the field where to put the quick-code but only if one checkbox has been
1447 * @returns {undefined}
1449function set_reconcile(obj)
1454 var ctlc = obj.elements['ctlc'];
1455 var tiers = obj.elements['tiers'];
1456 if (!obj.elements['target'])
1458 var target = obj.elements['target'].value;
1459 var single_operation = obj.elements['single_operation'].value;
1460 for (var e = 0; e < obj.elements.length; e++)
1463 var elmt = obj.elements[e];
1464 if (elmt.type === "checkbox")
1466 if (elmt.checked === true)
1468 var str_name = elmt.name;
1469 var nValue = str_name.replace("jr_concerned", "");
1470 if ($(ctlc.value).value != '') {
1471 $(ctlc.value).value += ',';
1475 if (tiers && tiers.value != "") {
1476 $(tiers.value).value = elmt.value;
1478 new Ajax.Request("fid.php",{
1480 parameters:{gDossier:obj.elements['gDossier'].value,"FID":elmt.value},
1481 onSuccess:function(req){
1482 // find the row number
1483 //tiers.value = e_othern
1484 var tiers_card=new String(tiers.value);
1485 var num=tiers_card.replace("e_other","");
1486 var tiers_name_id="e_other"+"_name"+num;
1487 var answer = req.responseText.evalJSON();
1488 $(tiers_name_id).value=answer["name"];
1493 if (single_operation==0) {
1494 $(ctlc.value).value += nValue;
1496 $(ctlc.value).value = nValue;
1502 removeDiv(obj.elements['target'].value);
1505 alert_box(e.message)
1508function remove_waiting_node()
1510 $('info_div').innerHTML = "";
1511 $('info_div').style.display = "none";
1514function remove_waiting_box()
1516 if ($('wait_box')) {
1517 Effect.Fade('wait_box', {duration: 0.6});
1520 remove_waiting_node();
1523 * Show all the detail of a profile : Menu, Management, Repository and
1524 * let the user to modify it
1525 * @param {type} gDossier
1526 * @param {type} profile_id
1527 * @returns {undefined}
1529function get_profile_detail(gDossier, profile_id)
1532 var qs = "op=display_profile&gDossier=" + gDossier + "&p_id=" + profile_id + "&ctl=detail_profile";
1533 var action = new Ajax.Request('ajax_misc.php',
1538 onSuccess: function (req) {
1539 remove_waiting_box();
1540 $('list_profile').hide();
1541 $('detail_profile').innerHTML = req.responseText;
1542 req.responseText.evalScripts();
1543 $('detail_profile').show();
1544 if (profile_id != "-1")
1545 profile_show('profile_gen_div');
1550function get_profile_detail_success_obsolete(xml)
1552 remove_waiting_box();
1556 * compute the string to position a div in a fixed way
1559function fixed_position(p_sx, p_sy)
1562 var sy = calcy(p_sy);
1564 var str_style = "top:" + sy + "px;left:" + sx + "px;position:absolute";
1569 * compute Y even if the windows has scrolled down or up
1570 *@return the correct Y position
1575 if (window.pageYOffset)
1577 sy = window.pageYOffset + p_sy;
1580 sy = document.documentElement.scrollTop + p_sy;
1587 * display a box with the menu option
1588 * @param {type} gdossier
1589 * @param {type} pm_id
1590 * @returns {undefined}
1592function mod_menu(gdossier, pm_id)
1595 removeDiv('divdm' + pm_id);
1596 var qs = "op=det_menu&gDossier=" + gdossier + "&pm_id=" + pm_id + "&ctl=divdm" + pm_id;
1597 var pos = fixed_position(50, 250);
1598 var action = new Ajax.Request('ajax_misc.php',
1603 onSuccess: function (req) {
1605 remove_waiting_box();
1606 add_div({id: "divdm" + pm_id, drag: 1, cssclass: "inner_box", style: pos});
1607 $('divdm' + pm_id).innerHTML = req.responseText;
1609 alert_box(e.message);
1616 * Display the submenu of a menu or a module, used in setting the menu
1618 * @param {type} p_dossier
1619 * @param {type} p_profile
1620 * @param {type} p_dep
1621 * @returns {undefined}
1623function display_sub_menu(p_dossier, p_profile, p_dep, p_level)
1626 new Ajax.Request('ajax_misc.php',
1629 parameters: {op: 'display_submenu',
1630 gDossier: p_dossier,
1632 p_profile: p_profile,
1635 onSuccess: function (req) {
1637 remove_waiting_box();
1638 if ($('menu_table').rows.length > p_level) {
1639 $('menu_table').rows[1].remove();
1641 $('sub' + p_dep).addClassName("selectedmenu");
1642 var new_row = document.createElement('TR');
1643 new_row.innerHTML = req.responseText;
1644 $('menu_table').appendChild(new_row);
1646 alert_box(e.message);
1652 * in CFGPRO, ask to confirm before removing a submenu and its children
1653 * @param {type} p_dossier
1654 * @param {type} profile_menu_id
1655 * @returns {undefined}
1657function remove_sub_menu(p_dossier, profile_menu_id)
1659 confirm_box(null, content[47],
1662 new Ajax.Request('ajax_misc.php',
1665 parameters: {op: 'remove_submenu', gDossier: p_dossier,
1666 p_profile_menu_id: profile_menu_id},
1667 onSuccess: function (req) {
1669 remove_waiting_box();
1670 $('sub' + profile_menu_id).remove();
1671 if ($('menu_table').rows.length > 1) {
1672 $('menu_table').rows[1].remove();
1677 alert_box(e.message);
1686 * add a menu to a profile, propose only the available menu
1687 * @param obj json object
1689 * - p_id : profile id ,
1690 * - type : Type of menu are "pr" for Printing "me" for plain menu
1691 * - p_level : level of menu (0 -> module,1-> top menu, 2->submenu)
1692 * - dep : the parent menu id (pm_id)
1695function add_menu(obj)
1697 var pdossier = obj.dossier;
1698 var p_id = obj.p_id;
1699 var p_type = obj.type;
1702 removeDiv('divdm' + p_id);
1703 var pos = fixed_position(250, 150) + ";width:50%;";
1704 var action = new Ajax.Request('ajax_misc.php',
1707 parameters: {op: 'add_menu',
1708 'gDossier': pdossier,
1710 'ctl': 'divdm' + p_id,
1713 'p_level': obj.p_level},
1715 onSuccess: function (req) {
1717 remove_waiting_box();
1718 add_div({id: "divdm" + p_id, drag: 1, "cssclass": "inner_box", "style": pos});
1719 $('divdm' + p_id).innerHTML = req.responseText;
1721 alert_box(e.message);
1728 * Display a box to enter data for adding a new plugin from
1730 * @param {type} p_dossier
1731 * @returns {undefined}
1733function add_plugin(p_dossier)
1736 removeDiv('divplugin');
1737 var qs = "op=add_plugin&gDossier=" + p_dossier + "&ctl=divplugin";
1739 var action = new Ajax.Request('ajax_misc.php',
1744 onSuccess: function (req) {
1746 remove_waiting_box();
1747 var pos = fixed_position(250, 150) + ";width:30%";
1748 add_div({id: "divplugin", drag: 1, cssclass: "inner_box", style: pos});
1749 $('divplugin').innerHTML = req.responseText;
1751 alert_box(e.message);
1759 * @param {type} p_dossier
1760 * @param {type} me_code
1761 * @returns {undefined}
1763function mod_plugin(p_dossier, me_code)
1766 removeDiv('divplugin');
1767 var qs = "op=mod_plugin&gDossier=" + p_dossier + "&ctl=divplugin&me_code=" + me_code;
1769 var action = new Ajax.Request('ajax_misc.php',
1774 onSuccess: function (req) {
1776 remove_waiting_box();
1777 var pos = fixed_position(250, 150) + ";width:30%";
1778 add_div({id: "divplugin", drag: 1, cssclass: "inner_box", style: pos});
1779 $('divplugin').innerHTML = req.responseText;
1782 alert_box(e.message);
1788function create_menu(p_dossier)
1791 removeDiv('divmenu');
1792 var qs = "op=create_menu&gDossier=" + p_dossier + "&ctl=divmenu";
1794 var action = new Ajax.Request('ajax_misc.php',
1799 onSuccess: function (req) {
1801 remove_waiting_box();
1802 var pos = fixed_position(250, 150) + ";width:30%";
1806 cssclass: "inner_box",
1809 $('divmenu').innerHTML = req.responseText;
1811 alert_box(e.message);
1817function modify_menu(p_dossier, me_code)
1820 removeDiv('divmenu');
1821 var qs = "op=modify_menu&gDossier=" + p_dossier + "&ctl=divmenu&me_code=" + me_code;
1823 var action = new Ajax.Request('ajax_misc.php',
1828 onSuccess: function (req) {
1830 remove_waiting_box();
1831 var pos = fixed_position(250, 150) + ";width:30%";
1835 cssclass: "inner_box",
1838 $('divmenu').innerHTML = req.responseText;
1841 alert_box(e.message);
1847function get_properties(obj)
1850 var s_type = "[" + typeof obj + "]";
1855 alert_box(s_type + a_array.join(","));
1858 * add a line in the form for the report
1859 * @param p_dossier dossier id to connect
1861function rapport_add_row(p_dossier)
1863 style = 'style="border: 1px solid blue;"';
1864 var table = $("rap1");
1865 var line = table.rows.length;
1867 var row = table.insertRow(line);
1869 var cellPos = row.insertCell(0);
1870 cellPos.innerHTML = '<input type="text" ' + style + ' size="3" id="pos' + line + '" name="pos' + line + '" value="' + line + '">';
1873 var cellName = row.insertCell(1);
1874 cellName.innerHTML = '<input type="text" ' + style + ' size="40" id="text' + line + '" name="text' + line + '">';
1877 var cellbutton = row.insertCell(2);
1878 var but_html = table.rows[1].cells[2].innerHTML;
1879 but_html = but_html.replace(/form0/g, "form" + line);
1880 cellbutton.innerHTML = but_html;
1881 but_html.evalScripts();
1883 g('form' + line).value = '';
1886 * Search an action in an inner box
1888function search_action(dossier, ctl_concern)
1893 var dossier = g('gDossier').value;
1895 var target = "search_action_div";
1897 var str_style = fixed_position(77, 99);
1899 var div = {id: target, cssclass: 'inner_box', style: str_style, html: loading(), drag: 1};
1902 var target = {gDossier: dossier,
1904 op: 'search_action',
1908 var qs = encodeJSON(target);
1910 var action = new Ajax.Request('ajax_misc.php',
1915 onSuccess: function (req) {
1917 remove_waiting_box();
1919 $('search_action_div').innerHTML = req.responseText;
1920 req.responseText.evalScripts();
1922 alert_box(e.message);
1928 alert_box(e.message);
1932function result_search_action(obj)
1936 var queryString = $(obj).serialize() + "&op=search_action";
1937 var action = new Ajax.Request(
1940 parameters: queryString,
1941 onFailure: ajax_misc_failure,
1942 onSuccess: function (req) {
1944 remove_waiting_box();
1945 $('search_action_div').innerHTML = req.responseText;
1946 req.responseText.evalScripts();
1948 alert_box(e.message);
1956 alert_box("display_periode " + e.message);
1962function set_action_related(p_obj)
1968 var ctlc = obj.elements['ctlc'];
1970 for (var e = 0; e < obj.elements.length; e++)
1973 var elmt = obj.elements[e];
1974 if (elmt.type === "checkbox")
1976 if (elmt.checked === true)
1978 var str_name = elmt.name;
1979 var nValue = elmt.value;
1980 if ($(ctlc.value).value != '') {
1981 $(ctlc.value).value += ',';
1983 $(ctlc.value).value += nValue;
1987 removeDiv('search_action_div');
1991 alert_box(e.message);
1996 * Show a form to modify or add a new repository
1998 *@param r_id : repository id
2000function stock_repo_change(p_dossier, r_id)
2002 var queryString = "gDossier=" + p_dossier + "&op=mod_stock_repo" + "&r_id=" + r_id;
2003 var nTop = calcy(posY);
2004 var nLeft = "10.1562%";
2005 var str_style = "top:" + nTop + "px;left:" + nLeft + ";height:auto;width:auto";
2007 removeDiv('change_stock_repo_div');
2009 var action = new Ajax.Request(
2012 method: 'get', parameters: queryString,
2013 onFailure: ajax_misc_failure,
2014 onSuccess: function (req) {
2015 remove_waiting_box();
2016 add_div({id: 'change_stock_repo_div', style: str_style, cssclass: 'inner_box', drag: "1"});
2017 $('change_stock_repo_div').innerHTML = req.responseText;
2023function stock_inv_detail(p_dossier, p_id)
2025 var queryString = "gDossier=" + p_dossier + "&op=view_mod_stock" + "&c_id=" + p_id + "&ctl=view_mod_stock_div";
2026 var nTop = calcy(posY);
2028 var str_style = "top:" + nTop + "px;left:" + nLeft + ";width:80%;";
2030 removeDiv('view_mod_stock_div');
2032 var action = new Ajax.Request(
2035 method: 'get', parameters: queryString,
2036 onFailure: ajax_misc_failure,
2037 onSuccess: function (req) {
2038 remove_waiting_box();
2039 add_div({id: 'view_mod_stock_div', style: str_style, cssclass: 'inner_box', drag: "1"});
2040 $('view_mod_stock_div').innerHTML = req.responseText;
2041 req.responseText.evalScripts();
2046function show_fin_chdate(obj_id)
2050 var ch = $(obj_id).options[$(obj_id).selectedIndex].value;
2052 $('chdate_ext').hide();
2056 $('chdate_ext').show();
2059 var nb = $('nb_item').value;
2060 for (i = 0; i < nb; i++) {
2061 if ($('tdchdate' + i)) {
2063 $('tdchdate' + i).show();
2066 $('tdchdate' + i).hide();
2072 alert_box(e.message);
2076 * tab menu for the profile parameter
2078function profile_show(p_div)
2081 var div = ['profile_gen_div', 'profile_menu_div', 'profile_print_div', 'profile_gestion_div', 'profile_repo_div','profile_menu_mobile_div'];
2082 for (var r = 0; r < div.length; r++) {
2088 alert_box(e.message);
2091function detail_category_show(p_div, p_dossier, p_id)
2095 $('detail_category_div').innerHTML = "";
2096 var queryString = "gDossier=" + p_dossier + "&id=" + p_id + "&op=fddetail";
2097 var action = new Ajax.Request(
2100 method: 'get', parameters: queryString,
2101 onFailure: ajax_misc_failure,
2102 onSuccess: function (req) {
2103 remove_waiting_box();
2104 $('list_cat_div').hide();
2105 $('detail_category_div').innerHTML = req.responseText;
2106 $('detail_category_div').show();
2107 req.responseText.evalScripts();
2113 * check if the parameter is a valid a valid date or not, returns true if it is valid otherwise
2115 * @param p_str_date the string of the date (format DD.MM.YYYY)
2117function check_date(p_str_date)
2119 var format = /^\d{2}\.\d{2}\.\d{4}$/;
2120 if (!format.test(p_str_date)) {
2123 var date_temp = p_str_date.split('.');
2124 var nMonth = parseFloat(date_temp[1]) - 1;
2125 var ma_date = new Date(date_temp[2], nMonth, date_temp[0]);
2126 if (ma_date.getFullYear() == date_temp[2] && ma_date.getMonth() == nMonth && ma_date.getDate() == date_temp[0]) {
2135 * get the string in the id and check if the date is valid
2136 * @param p_id_date is the id of the element to check
2137 * @return true if the date is valid
2140function check_date_id(p_id_date)
2142 var str_date = $(p_id_date).value;
2143 return check_date(str_date);
2147 * @param ag_id to view
2148 * @param dossier is the folder
2149 * @param modify : show the modify button values : 0 for no 1 for yes
2151function view_action(ag_id, dossier, modify)
2155 id = 'action' + layer;
2157 querystring = 'gDossier=' + dossier + '&op=vw_action&ag_id=' + ag_id + '&div=' + id + '&mod=' + modify;
2158 var action = new Ajax.Request(
2162 parameters: querystring,
2163 onFailure: error_box,
2164 onSuccess: function (req) {
2166 if (req.responseText === 'NOCONX') { reconnect();return;}
2167 remove_waiting_box();
2168 var answer = req.responseXML;
2169 var ctl = answer.getElementsByTagName('ctl');
2170 if (ctl.length == 0) {
2171 throw 'ajax failed ctl view_action';
2173 var ctl_txt = getNodeText(ctl[0]);
2174 var html = answer.getElementsByTagName('code');
2175 if (html.length === 0)
2177 var rec = req.responseText;
2178 throw 'ajax failed html view_action';
2180 var code_html = getNodeText(html[0]);
2181 code_html = unescape_xml(code_html);
2182 var pos = fixed_position(0, 50) + ";width:90%;left:5%;";
2185 cssclass: "inner_box",
2188 $(id).innerHTML = code_html;
2189 if (ctl_txt == 'ok') {
2191 var detail=in_child(id,"follow_up_detail");
2193 compute_all_ledger();
2198 code_html.evalScripts();
2200 alert_box('view_action' + e.message);
2207 * filter quickly a table
2208 * @param phrase : phrase to seach
2209 * @param _id : id of the table
2210 * @param colnr : string containing the column number where you're searching separated by a comma
2211 * @param start_row : first row (1 if you have table header)
2213 * @see HtmlInput::filter_table
2215function filter_table(phrase, _id, colnr, start_row) {
2216 $('info_div').innerHTML = content[65];
2217 $('info_div').style.display = "block";
2218 var words = $(phrase).value.toLowerCase();
2219 var table = document.getElementById(_id);
2221 // if colnr contains a comma then check several columns
2222 var aCol = new Array();
2223 if (colnr.indexOf(',') >= 0) {
2224 aCol = colnr.split(',');
2231 for (var r = start_row; r < table.rows.length; r++) {
2233 for (var col = 0; col < aCol.length; col++)
2235 var idx = aCol[col];
2236 if (table.rows[r].cells[idx])
2238 ele = table.rows[r].cells[idx].innerHTML.replace(/<[^>]+>/g, "");
2239 //var displayStyle = 'none';
2240 if (ele.toLowerCase().indexOf(words) >= 0) {
2248 table.rows[r].style.display = '';
2250 table.rows[r].style.display = 'none';
2252 $('info_div').style.display = "none";
2253 $('info_div').innerHTML = "";
2255 if (tot_found == 0) {
2256 if ($('info_' + _id)) {
2257 $('info_' + _id).innerHTML = content[69];
2260 if ($('info_' + _id)) {
2261 $('info_' + _id).innerHTML = " ";
2264 $('info_div').style.display = "none";
2265 $('info_div').innerHTML = "";
2268 * filter quickly a list
2269 * @param phrase : DOM id of the input text where we find the word to seach, the searchable content use the className searchContent
2270 * @param _id : id of the list
2272 * @see HtmlInput::filter_list
2274function filter_list(phrase, _id) {
2275 $('info_div').innerHTML = content[65];
2276 $('info_div').style.display = "block";
2277 var words = $(phrase).value.toLowerCase();
2278 var l_list = document.getElementById(_id);
2283 for (var r = 0; r < l_list.childNodes.length; r++) {
2286 if (l_list.childNodes[r].nodeType != 1) {
2290 let la_content = l_list.childNodes[r].getElementsByClassName("search-content");
2293 for (e = 0; e < la_content.length; e++) {
2294 ele += la_content[e].innerText;
2297 console.debug (`ele = ${ele}`);
2298 if (ele.toLowerCase().indexOf(words) >= 0) {
2300 l_list.childNodes[r].style.display = 'block';
2302 l_list.childNodes[r].style.display = 'none';
2306 if (tot_found == 0) {
2307 if ($('info_' + _id)) {
2308 $('info_' + _id).innerHTML = content[69];
2311 if ($('info_' + _id)) {
2312 $('info_' + _id).innerHTML = " ";
2315 $('info_div').style.display = "none";
2316 $('info_div').innerHTML = "";
2320 * filter quickly a select
2321 * @param phrase : DOM id of the input text where we find the word to seach
2322 * @param _id : id of the list
2324 * @see HtmlInput::filter_list
2326function filter_multiselect(phrase, _id) {
2327 $('info_div').innerHTML = content[65];
2328 $('info_div').style.display = "block";
2329 var words = $(phrase).value.toLowerCase();
2330 var l_list = document.getElementById(_id);
2334 for (var r = 0; r < l_list.options.length; r++) {
2336 var ele = l_list.options[r].text;
2338 if (ele.toLowerCase().indexOf(words) >= 0) {
2340 l_list.options[r].style.display = 'block';
2342 l_list.options[r].style.display = 'none';
2344 $('info_div').style.display = "none";
2345 $('info_div').innerHTML = "";
2347 if (tot_found == 0) {
2348 if ($('info_' + _id)) {
2349 $('info_' + _id).innerHTML = content[69];
2352 if ($('info_' + _id)) {
2353 $('info_' + _id).innerHTML = " ";
2359 * Display the task late or for today in dashboard
2361function display_task(p_id)
2364 $(p_id).style.top = posY + 'px';
2365 $(p_id).style.left = "10%";
2366 $(p_id).style.width = "80%";
2367 $(p_id).style.display = 'block';
2372 * Set a message in the info
2374function info_message(p_message)
2376 $('info_div').innerHTML = p_message;
2377 $('info_div').style.display = "block";
2384 $('info_div').style.display = "none";
2387 * Show the navigator in a internal window
2388 * @returns {undefined}
2390function ask_navigator(p_dossier) {
2393 removeDiv('navi_div')
2394 var queryString = "gDossier=" + p_dossier + "&op=navigator";
2395 var action = new Ajax.Request(
2398 method: 'get', parameters: queryString,
2399 onFailure: ajax_misc_failure,
2400 onSuccess: function (req) {
2401 remove_waiting_box();
2402 add_div({id: 'navi_div', style: 'top:2em;', cssclass: 'inner_box'});
2403 $('navi_div').innerHTML = req.responseText;
2406 req.responseText.evalScripts();
2407 sorttable.makeSortable($("navi_tb"));
2410 alert_box("answer_box Impossible executer script de la reponse\n" + e.message);
2417 info_message(e.message);
2422 * Display an internal windows to set the user's preference
2425function set_preference(p_dossier) {
2428 removeDiv('preference_div')
2429 var queryString = "gDossier=" + p_dossier + "&op=preference";
2430 var action = new Ajax.Request(
2433 method: 'get', parameters: queryString,
2434 onFailure: ajax_misc_failure,
2435 onSuccess: function (req) {
2436 remove_waiting_box();
2437 if (req.responseText === 'NOCONX') { reconnect();return;}
2438 add_div({id: 'preference_div', drag: 1});
2439 $('preference_div').innerHTML = req.responseText;
2442 req.responseText.evalScripts();
2445 alert_box("answer_box Impossible executer script de la reponse\n" + e.message);
2452 info_message(e.message);
2457 * Display user's bookmark
2460function show_bookmark(p_dossier) {
2463 removeDiv('bookmark_div');
2464 var param = window.location.search;
2465 param = param.gsub('?', '');
2466 var queryString = "gDossier=" + p_dossier + "&op=bookmark&" + param;
2467 var action = new Ajax.Request(
2470 method: 'get', parameters: queryString,
2471 onFailure: ajax_misc_failure,
2472 onSuccess: function (req) {
2473 remove_waiting_box();
2474 add_div({id: 'bookmark_div', cssclass: 'inner_box', drag: 1});
2475 $('bookmark_div').innerHTML = req.responseText;
2478 req.responseText.evalScripts();
2481 alert_box(content[53] + "\n" + e.message);
2488 info_message(e.message);
2495function save_bookmark() {
2498 var queryString = "op=bookmark&" + $("bookmark_frm").serialize();
2499 var action = new Ajax.Request(
2502 method: 'get', parameters: queryString,
2503 onFailure: ajax_misc_failure,
2504 onSuccess: function (req) {
2505 remove_waiting_box();
2506 // removeDiv('bookmark_div');
2508 $('bookmark_div').innerHTML = req.responseText;
2511 req.responseText.evalScripts();
2514 alert_box(content[53] + "\n" + e.message);
2521 info_message(e.message);
2526 * remove selected bookmark
2528function remove_bookmark() {
2531 var queryString = "op=bookmark&" + $("bookmark_del_frm").serialize();
2532 var action = new Ajax.Request(
2535 method: 'get', parameters: queryString,
2536 onFailure: ajax_misc_failure,
2537 onSuccess: function (req) {
2538 remove_waiting_box();
2539 $('bookmark_div').innerHTML = req.responseText;
2542 req.responseText.evalScripts();
2545 alert_box(content[53] + "\n" + e.message);
2552 error_message(e.message);
2557 * display the error message into the div error_content_div (included into error_div)
2558 *@param message message to display
2559 *@note there is no protection
2561function error_message(message)
2563 $('error_content_div').innerHTML = message;
2564 $('error_div').style.visibility = 'visible';
2567 * show the detail of a tag and propose to save it
2569function show_tag(p_dossier, p_ac, p_tag_id, p_post)
2573 var queryString = "op=tag_detail&tag=" + p_tag_id + "&gDossier=" + p_dossier + "&ac=" + p_ac + '&form=' + p_post;
2574 var action = new Ajax.Request(
2577 method: 'get', parameters: queryString,
2578 onFailure: ajax_misc_failure,
2579 onSuccess: function (req) {
2580 var answer = req.responseXML;
2581 var html = answer.getElementsByTagName('code');
2582 if (html.length === 0)
2584 var rec = req.responseText;
2585 alert_box('erreur :' + rec);
2587 var code_html = getNodeText(html[0]);
2588 code_html = unescape_xml(code_html);
2589 remove_waiting_box();
2590 var posy = calcy(250);
2591 add_div({id: 'tag_div', cssclass: 'inner_box', drag: 0, style: "position:fixed;top:15%;"});
2592 $('tag_div').innerHTML = code_html;
2595 code_html.evalScripts();
2598 alert_box(content[53] + "\n" + e.message);
2605 error_message(e.message);
2610 * save the modified tag
2616 var queryString = "op=tag_save&" + $("tag_detail_frm").serialize();
2617 var action = new Ajax.Request(
2621 parameters: queryString,
2622 onFailure: ajax_misc_failure,
2623 onSuccess: function (req, j) {
2624 remove_waiting_box();
2625 removeDiv('tag_div');
2630 error_message(e.message);
2637 * Show a list of tag which can be added to the current followup document
2638 * @param {type} p_dossier
2639 * @param {type} ag_id
2640 * @returns {undefined}
2642function action_tag_select(p_dossier, ag_id)
2646 var queryString = "ag_id=" + ag_id + "&op=tag_list&gDossier=" + p_dossier;
2647 var action = new Ajax.Request(
2650 method: 'get', parameters: queryString,
2651 onFailure: ajax_misc_failure,
2652 onSuccess: function (req, j) {
2653 var answer = req.responseXML;
2654 var html = answer.getElementsByTagName('code');
2655 if (html.length === 0)
2657 var rec = unescape_xml(req.responseText);
2658 error_message('erreur :' + rec);
2660 var code_html = getNodeText(html[0]);
2661 code_html = unescape_xml(code_html);
2662 var pos = fixed_position(35, 229);
2663 add_div({id: 'tag_div', style: pos, cssclass: 'inner_box tag', drag: 0});
2665 remove_waiting_box();
2666 $('tag_div').innerHTML = code_html;
2671 error_message(e.message);
2675 * Add the current tag to the current ag_id
2676 * @param {type} p_dossier
2677 * @param {type} ag_id
2678 * @param p_isgroup g it is a group , t is a single tag
2679 * @returns {undefined}
2681function action_tag_add(p_dossier, ag_id, t_id,p_isgroup)
2685 var queryString = "t_id=" + t_id + "&ag_id=" + ag_id + "&op=tag_add&gDossier=" + p_dossier+"&isgroup="+p_isgroup;
2686 var action = new Ajax.Request(
2689 method: 'get', parameters: queryString,
2690 onFailure: ajax_misc_failure,
2691 onSuccess: function (req, j) {
2692 var answer = req.responseXML;
2693 var html = answer.getElementsByTagName('code');
2694 if (html.length === 0)
2696 var rec = unescape_xml(req.responseText);
2697 error_message('erreur :' + rec);
2699 var code_html = getNodeText(html[0]);
2700 code_html = unescape_xml(code_html);
2701 remove_waiting_box();
2702 $('action_tag_td').innerHTML = code_html;
2703 removeDiv('tag_div');
2708 error_message(e.message);
2712 * remove the current tag to the current ag_id
2713 * @param {type} p_dossier
2714 * @param {type} ag_id
2715 * @returns {undefined}
2717function action_tag_remove(p_dossier, ag_id, t_id)
2719 confirm_box(null, content[50], function () {
2722 var queryString = "t_id=" + t_id + "&ag_id=" + ag_id + "&op=tag_remove&gDossier=" + p_dossier;
2723 var action = new Ajax.Request(
2726 method: 'get', parameters: queryString,
2727 onFailure: ajax_misc_failure,
2728 onSuccess: function (req) {
2729 var answer = req.responseXML;
2730 var html = answer.getElementsByTagName('code');
2731 if (html.length === 0)
2733 var rec = unescape_xml(req.responseText);
2734 error_message('erreur :' + rec);
2736 var code_html = getNodeText(html[0]);
2737 code_html = unescape_xml(code_html);
2738 remove_waiting_box();
2739 $('action_tag_td').innerHTML = code_html;
2745 error_message(e.message);
2752 * @param int p_dossier
2753 * @param int p_tag_id
2755function activate_tag(p_dossier, p_tag_id) {
2757 new Ajax.Request("ajax_misc.php",
2760 parameters: {gDossier: p_dossier, op: 'tag_activate', t_id: p_tag_id},
2761 onSuccess: function (req) {
2762 remove_waiting_box();
2763 var answer = req.responseText.evalJSON();
2764 var tagId = "tag_onoff" + p_tag_id;
2765 $(tagId).update(answer.code);
2766 $(tagId).setStyle(answer.style);
2767 remove_waiting_box();
2772 * Display a div with available tags, this div can update the cell
2774 * @param {type} p_dossier
2775 * @param {string} p_prefix is the prefix of the div
2776 * @param {string} Calling object either Tag_Operation or Tag_Action
2777 * @returns {undefined}
2780function search_display_tag(p_dossier, p_prefix,p_object)
2784 var queryString = { op : "search_display_tag",gDossier:p_dossier,pref:p_prefix,caller_obj:p_object};
2785 var action = new Ajax.Request(
2788 method: 'get', parameters: queryString,
2789 onFailure: ajax_misc_failure,
2790 onSuccess: function (req, j) {
2791 var answer = req.responseXML;
2792 var html = answer.getElementsByTagName('code');
2793 if (html.length === 0)
2795 var rec = unescape_xml(req.responseText);
2796 error_message('erreur :' + rec);
2798 var code_html = getNodeText(html[0]);
2799 code_html = unescape_xml(code_html);
2800 remove_waiting_box();
2801 add_div({id: p_prefix + 'tag_div', style: 'left:10%;width:70%', cssclass: 'inner_box', drag: 1});
2802 $(p_prefix + 'tag_div').style.top = calcy(200)+"px"
2803 $(p_prefix + 'tag_div').style.left = 20+ "%";
2804 remove_waiting_box();
2805 $(p_prefix + 'tag_div').innerHTML = code_html;
2806 code_html.evalScripts();
2811 error_message(e.message);
2815 * Add the selected tag (p_tag_id) to the cell of tag_choose_td in the search screen
2816 * in the search screen
2817 * @param {type} p_dossier
2818 * @param {type} p_tag_id
2819 * @param p_prefix is the prefix of the widget
2820 * @param p_obj is either g for group of tag or t for a single tag
2822function search_add_tag(p_dossier, p_tag_id, p_prefix,p_obj)
2825 var clear_button = 0;
2826 if (tag_choose === '' && p_prefix === 'search') {
2827 tag_choose = $(p_prefix + 'tag_choose_td').innerHTML;
2831 var queryString = "op=search_add_tag&gDossier=" + p_dossier + "&id=" + p_tag_id + "&clear=" + clear_button + '&pref=' + p_prefix+"&obj="+p_obj;
2832 var action = new Ajax.Request(
2835 method: 'get', parameters: queryString,
2836 onFailure: ajax_misc_failure,
2837 onSuccess: function (req, j) {
2838 var answer = req.responseXML;
2839 var html = answer.getElementsByTagName('html');
2840 if (html.length === 0)
2842 var rec = unescape_xml(req.responseText);
2843 error_message('erreur :' + rec);
2845 var code_html = getNodeText(html[0]);
2846 code_html = unescape_xml(code_html);
2847 remove_waiting_box();
2848 $(p_prefix + 'tag_choose_td').innerHTML = $(p_prefix + 'tag_choose_td').innerHTML + code_html;
2849 removeDiv(p_prefix + 'tag_div');
2854 error_message(e.message);
2858 * Clear the tags in the cell tag_choose_td of the search screen
2859 * @returns {undefined}
2861function search_clear_tag(p_dossier, p_prefix)
2863 if (p_prefix != 'search') {
2864 $(p_prefix + 'tag_choose_td').innerHTML = "";
2868 var queryString = "op=search_clear_tag&gDossier=" + p_dossier + "&pref=" + p_prefix;
2869 var action = new Ajax.Request(
2872 method: 'get', parameters: queryString,
2873 onFailure: ajax_misc_failure,
2874 onSuccess: function (req, j) {
2875 var answer = req.responseXML;
2876 var html = answer.getElementsByTagName('html');
2877 if (html.length === 0)
2879 var rec = unescape_xml(req.responseText);
2880 error_message('erreur :' + rec);
2882 var code_html = getNodeText(html[0]);
2883 code_html = unescape_xml(code_html);
2884 $(p_prefix + 'tag_choose_td').innerHTML = code_html;
2890 error_message(e.message);
2893function action_show_checkbox()
2895 var a = document.getElementsByName('ag_id_td');
2896 for (var i = 0; i < a.length; i++) {
2897 a[i].style.display = 'block';
2900function action_hide_checkbox()
2902 var a = document.getElementsByName('ag_id_td');
2903 for (var i = 0; i < a.length; i++) {
2904 a[i].style.display = 'none';
2910 * object attribute : g
2911 * - Dossier dossier_id,
2912 * - invalue DOM Element where you can find the periode to zoom
2913 * - outdiv ID of the target (DIV)
2916function calendar_zoom(obj)
2920 var per_periode = null;
2923 if ($(obj.invalue)) {
2924 per_periode = $(obj.invalue).value;
2926 if (obj.notitle && obj.notitle == 1) {
2929 var action = new Ajax.Request(
2933 parameters: {"notitle": notitle, "op": 'calendar_zoom', 'from': from, 'gDossier': obj.gDossier, 'in': per_periode, 'out': obj.outdiv, 'distype': obj.distype},
2934 onFailure: ajax_misc_failure,
2935 onSuccess: function (req, j) {
2936 if (req.responseText === 'NOCONX') { reconnect();return;}
2937 var answer = req.responseXML;
2938 var html = answer.getElementsByTagName('html');
2939 if (html.length === 0)
2941 var rec = unescape_xml(req.responseText);
2942 error_message('erreur :' + rec);
2944 var code_html = getNodeText(html[0]);
2945 code_html = unescape_xml(code_html);
2947 // if the target doesn't exist
2949 if (obj.outdiv === undefined) {
2950 obj.outdiv = 'calendar_zoom_div';
2952 if ($(obj.outdiv) == undefined) {
2953 var str_style = 'top:10%;margin-left:2%;';
2954// var str_style = fixed_position(0, 120);
2955 add_div({id: obj.outdiv, style: 'margin-left:3%;width:94%;' + str_style, cssclass: "inner_box", drag: 0});
2957 remove_waiting_box();
2958 $(obj.outdiv).innerHTML = code_html;
2959 $(obj.outdiv).show();
2964 error_message('calendar_zoom ' + e.message);
2970 * add a line in the form for the stock
2972function stock_add_row()
2975 style = 'class="input_text"';
2976 var mytable = g("stock_tb").tBodies[0];
2977 var ofirstRow = mytable.rows[1];
2978 var line = mytable.rows.length;
2979 var nCell = mytable.rows[1].cells.length;
2980 var row = mytable.insertRow(line);
2982 for (var e = 0; e < nCell; e++)
2984 var newCell = row.insertCell(e);
2985 if (mytable.rows[1].cells[e].hasClassName('num')) {
2986 newCell.addClassName("num");
2989 var tt = ofirstRow.cells[e].innerHTML;
2990 var new_tt = tt.replace(/sg_code0/g, "sg_code" + nb.value);
2991 new_tt = new_tt.replace(/sg_quantity0/g, "sg_quantity" + nb.value);
2992 new_tt = new_tt.replace(/label0/g, "label" + nb.value);
2993 newCell.innerHTML = new_tt;
2994 new_tt.evalScripts();
2997 g("sg_code" + nb.value).innerHTML = ' ';
2998 g("sg_code" + nb.value).value = '';
2999 g("label" + nb.value).innerHTML = '';
3000 g("sg_quantity" + nb.value).value = '0';
3004 new_tt.evalScripts();
3006 alert_box(e.message);
3010function show_description(p_id)
3012 $('print_desc' + p_id).hide();
3013 $('input_desc' + p_id).show();
3017 * Display an empty card to fill , with the right card category
3018 * @param pn_fiche_card_id : fiche_def.fd_id
3019 * @param pn_dossier_id
3021function select_cat(pn_fiche_card_id, pn_dossier_id, ps_element_id)
3023 dis_blank_card({"ctl": "div_new_card", "fd_id": pn_fiche_card_id, "op2": "bc", "op": "card", gDossier: pn_dossier_id, "elementId": ps_element_id});
3024 removeDiv('select_card_div');
3027 * Show the DIV and hide the other, the array of possible DIV are
3029 * @param {array} a_tabs name of possible tabs
3030 * @param {strng} p_display_tab tab to display
3032function show_tabs(a_tabs, p_display_tab)
3036 if (a_tabs.length == 0) {
3037 console.error('a_tabs in empty');
3038 throw ("a_tabs empty");
3042 for (i = 0; i < a_tabs.length; i++) {
3043 $(a_tabs[i]).hide();
3045 $(p_display_tab).show();
3047 alert_box(e.message);
3052 * Change the class of all the "LI" element of a UL or OL
3053 * @param node of ul (this)
3055function unselect_other_tab(p_tab)
3058 var other = p_tab.getElementsByTagName("li");
3061 for (i = 0; i < other.length; i++) {
3063 tab.className = "tabs";
3067 console.error(e.message);
3068 alert_box('unselect_other_tab ' + e.message);
3072 * logout function call from ajax
3073 * @see ajax_disconnected
3074 * @returns {undefined}
3078 var tmp_place = window.location.href
3079 var tmp_b = tmp_place.split('/')
3080 var tmp_last = tmp_b.length - 1
3081 var place_logout = tmp_place.replace(tmp_b[tmp_last], 'logout.php');
3082 window.location.href = place_logout;
3085 * Create a div which can be used in a anchor
3086 * @returns {undefined}
3088function create_anchor_up()
3090 if (document.getElementById('up_top'))
3093 var newElt = document.createElement('div');
3094 newElt.setAttribute('id', 'up_top');
3095 newElt.innerHTML = '<a id="up_top"></a>';
3097 var parent = $('info_div').parentNode;
3098 parent.insertBefore(newElt, $('info_div'));
3102 * Initialize the window to show the button "UP" if the window is scrolled
3104 * @returns {undefined}
3106function init_scroll()
3108 var up = new Element('div', {"class": "",
3109 "style": "padding:5px;left:auto;width:auto;height: auto;display:none;position:fixed;bottom:30%;right:50px;text-align:center;font-size:20px",
3112 up.innerHTML = '<a class="icon" onclick="document.getElementById(\'go_up\').hide()" style="float:right;font-size:70%"></a> <a class="icon" href="#up_top" ></a><a href="javascript:show_calc()" class="icon"></a>';
3113 document.body.appendChild(up);
3114 window.onscroll = function () {
3115 if ( document.getElementById("select_box_content") )
3116 { document.getElementById("select_box_content").setStyle({display:"none"})};
3117 if (document.viewport.getScrollOffsets().top > 0) {
3118 if ($('go_up').visible() == false) {
3119 $('go_up').setOpacity(0.65);
3121 $('go_up').style.zIndex = 99;
3130 * Confirm a form thanks a modal dialog Box, it returns true if we agree otherwise
3133 <form onsubmit="return confirm_box(this,'message')">
3136 * @param p_obj form element (object) or element id (string)
3137 * @param p_message message to display
3138 * @param p_callback_true callback function or null
3139 * @param p_waiting if true display a waiting box
3140 * @returns true or false
3142function confirm_box(p_obj, p_message, p_callback_true,p_waiting)
3146 // Find id of the end
3150 if (typeof (p_obj) === "object") {
3157 // execute the callback function or submit the form
3158 if ( ! p_callback_true )
3161 smoke.confirm(p_message, function (e) {
3163 if (p_waiting){waiting_box();}
3168 smoke.confirm(p_message, function (e)
3171 p_callback_true.apply();
3176 alert_box(e.message);
3178 remove_waiting_box();
3182 * Alert box in CSS and HTML to replace the common javascript alert
3183 * @param p_message message to display
3186function alert_box(p_message)
3188 smoke.alert(p_message, undefined, {ok: 'ok', classname: "inner_box"});
3193 * Colorize the rows of the table
3194 * @param string p_table id of the table
3196function alternate_row_color(p_table)
3198 var table_colored=$(p_table);
3199 if (! table_colored.tBodies[0] ) return;
3201 var len = table_colored.tBodies[0].rows.length;
3203 var localClass = "";
3204 for (i = 1; i < len; i++) {
3205 localClass = (i % 2 == 0) ? "even" : "odd";
3206 if ( table_colored.tBodies[0].rows[i].hasClassName("odd"))
3208 table_colored.tBodies[0].rows[i].removeClassName("odd");
3210 if (table_colored.tBodies[0].rows[i].hasClassName("even"))
3212 table_colored.tBodies[0].rows[i].removeClassName("even");
3214 table_colored.tBodies[0].rows[i].addClassName(localClass);
3219 * Make an DOM element draggable or not
3220 * @param object_id DOM id
3222function pin(object_id) {
3223 if (aDraggableElement[object_id]) {
3224 aDraggableElement[object_id].destroy();
3225 aDraggableElement[object_id] = undefined;
3226 $('pin_' + object_id).innerHTML = "";
3228 aDraggableElement[object_id] = new Draggable(object_id, {starteffect: function ()
3230 new Effect.Highlight(object_id, {scroll: window, queue: 'end'});
3233 $('pin_' + object_id).innerHTML = "";
3237 * Show only the rows into the table (p_table_id) with the attribute (p_attribute_name) and if this attribute
3238 * has the value of (attribut_value)
3239 * @param p_table_id table id
3240 * @param p_attribute_name the name of the attribute
3241 * @param p_attribute_value the value of the attribute we want to show
3243function show_only_row(p_table_id, p_attribute_name, p_attribute_value)
3245 if (!$(p_table_id)) {
3246 throw "Invalide table id"
3248 var mTable = $(p_table_id);
3249 var ncount = mTable.rows.length
3250 for (var i = 0; i < ncount; i++) {
3251 var mRow = mTable.rows[i];
3252 if (mRow.getAttribute(p_attribute_name) != undefined && mRow.getAttribute(p_attribute_name) != p_attribute_value) {
3260 * Show all the rows into the table (p_table_id)
3261 * @param p_table_id table id
3263function show_all_row(p_table_id)
3265 if (!$(p_table_id)) {
3266 throw "Invalide table id"
3268 var mTable = $(p_table_id);
3269 var ncount = mTable.rows.length
3270 for (var i = 0; i < ncount; i++) {
3271 var mRow = mTable.rows[i];
3280 * - id of the row of the periode row_per_(p_periode_id) , attribute exercice =per_exercice,periode_id=p_id
3282 * - id of the table with the rows : periode_tbl
3285 * - periode_id the concerned Periode , 0 none
3286 * - p_ledger : the id of ledger (jrn_def.jrn_def_id), 0 for global
3287 * - pcallback : default ajax_misc.php (this.callback) with the parameter { op:'periode',gDossier,[action:display,remove,save],p_id:p_periode_id}
3289 * - js_obj_name : name of the js object (this.js_obj_name)
3290 * - ajax_test : file to include for debugging
3291 * - dialog : id of the dialog box (update / add ) periode_box
3294var Periode = function (p_ledger) {
3295 this.periode_id = 0;
3296 this.p_ledger = p_ledger;
3297 this.dialog = 'periode_box';
3298 this.pcallback = 'ajax_misc.php';
3300 this.js_obj_name = "";
3301 this.ajax_test = "";
3302 this.set_callback = function (p_phpfile) {
3303 this.pcallback = p_phpfile;
3305 this.set_dossier = function (p_dosid) {
3306 this.dossier = p_dosid;
3309 * set_js_obj_name (p_js_obj_name)
3310 * We need to know the javascript variable name , to pass it to ajax and
3311 * create a HTML containing the right variable
3312 * @param p_js_obj_name name of the variable js we use on caller side
3314 this.set_js_obj_name = function (p_js_obj_name) {
3315 this.js_obj_name = p_js_obj_name;
3319 * Remove the periode , so call new Ajax and hide the row if successful
3320 * otherwise show dialog box.
3321 * @parameter p_periode_id is the id of periode
3323 this.remove = function (p_periode_id) {
3325 var js_param = {"gDossier": this.dossier,
3328 "p_id": p_periode_id,
3330 "js_var": this.js_obj_name};
3331 if (this.ajax_test != "") {
3332 js_param["TestAjaxFile"] = this.ajax_test;
3335 smoke.confirm("Confirmer ?", function (e) {
3338 new Ajax.Request(here.pcallback,
3341 parameters: js_param,
3342 onSuccess: function (req) {
3343 var answer = req.responseText.evalJSON();
3344 remove_waiting_box();
3345 if (answer.status == "OK")
3347 $("row_per_" + p_periode_id).remove();
3348 alternate_row_color("periode_tbl");
3350 smoke.alert(answer.content);
3359 * display a dialog box to update a periode, call save either display
3360 * an error box or update the row.
3361 * the name of variable is requested
3362 * to build the right button , javascript in the html of answer
3363 * @parameter p_periode_id is the id of periode
3365 this.box_display = function (p_periode_id) {
3366 if (this.js_obj_name == "") {
3367 smoke.alert("ERROR BOX_ADD")
3370 var js_param = {"gDossier": this.dossier,
3373 "p_id": p_periode_id,
3374 "ledger_id": this.p_ledger,
3375 "js_var": this.js_obj_name};
3376 if (this.ajax_test != "") {
3377 js_param["TestAjaxFile"] = this.ajax_test;
3380 new Ajax.Request(here.pcallback,
3383 parameters: js_param,
3384 onSuccess: function (req) {
3385 remove_waiting_box();
3386 var json = req.responseText.evalJSON();
3388 add_div({"id": "mod_periode", "style": "position:fixed;top:" + y + "px;width:50%", "cssclass": "inner_box", 'html': "wait"});
3389 $('mod_periode').update(json.content);
3394 * close the periode, call ajax and receive a json object with the attribute
3396 * @parameter p_periode_id is the id of periode
3398 this.close_periode = function (p_periode_id) {
3399 if (this.js_obj_name == "") {
3400 smoke.alert("ERROR BOX_ADD")
3403 if (this.ajax_test != "") {
3404 js_param["TestAjaxFile"] = this.ajax_test;
3407 smoke.confirm("Confirmer ?", function (e) {
3409 here._close(p_periode_id);
3414 * Internal function to close without confirming
3415 * @param {type} p_periode_id
3416 * @returns {undefined}
3418 this._close = function (p_periode_id) {
3419 if (this.js_obj_name == "") {
3420 smoke.alert("ERROR BOX_ADD")
3422 var js_param = {"gDossier": this.dossier,
3425 "ledger_id": this.p_ledger,
3426 "p_id": p_periode_id,
3427 "js_var": this.js_obj_name
3429 if (this.ajax_test != "") {
3430 js_param["TestAjaxFile"] = this.ajax_test;
3434 new Ajax.Request(here.pcallback,
3437 parameters: js_param,
3438 onSuccess: function (req) {
3439 remove_waiting_box();
3440 var json = req.responseText.evalJSON();
3441 if (json.status == 'OK')
3443 $('row_per_' + p_periode_id).update(json.content);
3444 new Effect.Highlight('row_per_' + p_periode_id, {startcolor: '#FAD4D4', endcolor: '#F78082'});
3446 smoke.alert(json.content);
3452 * reopen the periode
3453 * @parameter p_periode_id is the SQL id of parm_periode or the id of
3456 this.open_periode = function (p_periode_id) {
3457 if (this.js_obj_name == "") {
3458 smoke.alert("ERROR BOX_ADD")
3460 var js_param = {"gDossier": this.dossier,
3463 "ledger_id": this.p_ledger,
3464 "p_id": p_periode_id,
3465 "js_var": this.js_obj_name
3467 if (this.ajax_test != "") {
3468 js_param["TestAjaxFile"] = this.ajax_test;
3471 smoke.confirm("Confirmer ?", function (e) {
3474 new Ajax.Request(here.pcallback,
3477 parameters: js_param,
3478 onSuccess: function (req) {
3479 remove_waiting_box();
3480 var json = req.responseText.evalJSON();
3481 if (json.status == 'OK')
3483 $('row_per_' + p_periode_id).update(json.content);
3484 new Effect.Highlight('row_per_' + p_periode_id, {startcolor: '#FAD4D4', endcolor: '#F78082'});
3486 smoke.alert(json.content);
3494 * This DOMID of the DIV containing the form is mod_periode
3495 * @param {type} p_frm
3496 * @returns {Boolean}
3498 this.save = function (p_frm) {
3499 var js_param = $(p_frm).serialize(true);
3501 js_param["js_var"] = this.js_obj_name;
3502 js_param["act"] = "save";
3503 js_param["op"] = "periode";
3505 new Ajax.Request(this.pcallback, {
3507 parameters: js_param,
3508 onSuccess: function (req) {
3510 var answer = req.responseText.evalJSON();
3511 remove_waiting_box();
3512 if (answer.status == "OK") {
3513 $('row_per_' + js_param['periode_id']).update(answer.content);
3514 removeDiv('mod_periode');
3515 new Effect.Highlight('row_per_' + js_param['periode_id'], {startcolor: '#FAD4D4', endcolor: '#F78082'});
3517 smoke.alert(answer.content);
3524 * Thanks the object DOMID sel_per_closed[] the selected periodes are
3526 * @see Periode._close
3528 this.close_selected = function () {
3530 var a_selected = document.getElementsByName('sel_per_close[]');
3533 for (i = 0; i < a_selected.length; i++) {
3534 if (a_selected[i].checked == true) {
3535 // Close the selected periode
3540 smoke.signal("Sélectionner au moins une période", function () {}, {duration: 1500});
3543 smoke.confirm("Confirmer fermeture de " + count + " periode", function (e) {
3545 var a_selected = document.getElementsByName('sel_per_close[]');
3547 for (i = 0; i < a_selected.length; i++) {
3548 if (a_selected[i].checked == true) {
3549 // Close the selected periode
3550 here._close(a_selected[i].value);
3558 * Insert a periode into the list, always at the bottom !
3560 * # FORM id :insert_periode_frm
3561 * # DIV id = periode_add
3562 * # table id = periode_tbl
3564 this.insert_periode = function () {
3565 var p_frm = 'insert_periode_frm';
3566 var js_param = $(p_frm).serialize(true);
3568 js_param["js_var"] = this.js_obj_name;
3569 js_param["act"] = "insert_periode";
3570 js_param["op"] = "periode";
3571 js_param["p_id"] = "-1";
3572 js_param["ledger_id"] = "0";
3574 new Ajax.Request(this.pcallback, {
3576 parameters: js_param,
3577 onSuccess: function (req) {
3578 var answer = req.responseText.evalJSON();
3579 remove_waiting_box();
3580 if (answer.status == "OK") {
3581 var new_row = document.createElement("tr");
3582 $('periode_tbl').append(new_row);
3583 new_row.replace(answer.content);
3586 $('periode_add').hide();
3587 new Effect.Highlight('row_per_' + answer.p_id, {startcolor: '#FAD4D4', endcolor: '#F78082'});
3588 alternate_row_color('periode_tbl');
3590 smoke.alert(answer.content);
3599 * Show the periodes from the exercice contained into the id (p_exercice_sel)
3600 * @param p_table_id DOM ID of the table
3602Periode.filter_exercice = function (p_table_id) {
3603 var rows = $(p_table_id).rows;
3604 var selected_value = $('p_exercice_sel').value;
3605 for (var i = 1; i < rows.length; i++) {
3606 var exercice = rows[i].getAttribute("per_exercice");
3607 if (selected_value == -1) {
3609 } else if (selected_value == exercice) {
3618// keep track of progress bar
3619var progressBar = [];
3620// idx of progress bar
3624 * Start the progress bar
3625 * @param {string} p_taskid id to monitor
3626 * @param {int} p_message
3628function progress_bar_start(p_taskid, p_message)
3634 var message = '<p>' + content[70] + '</p>';
3636 message = p_message;
3639 add_div({id: "blocking" + progressIdx, cssclass: "smoke-base smoke-visible "});
3641 add_div({id: "message" + progressIdx, cssclass: "inner_box", style: "z-index:1000;position:fixed;top:30%;width:40%;left:30%"});
3642 $("message" + progressIdx).update('<h3>' + content[65] + '</h3>' + message);
3644 add_div({id: "progressDiv" + progressIdx, cssclass: "progressbar", html: '<span id="progressValue">0</span>'});
3645 // Check status every sec.
3646 progressBar[progressIdx] = setInterval(progress_bar_check.bind(null, progressIdx, p_taskid), 1000);
3648 console.error(e.message);
3653 * Check every second the status
3654 * @param {integer} p_idx idx of progressbar
3655 * @param {string} p_taskid id to monitor
3657function progress_bar_check(p_idx, p_taskid)
3661 new Ajax.Request("ajax_misc.php", {
3662 parameters: {gDossier: 0, task_id: p_taskid, op: "progressBar"},
3664 onSuccess: function (req) {
3667 var answer = req.responseText.evalJSON();
3668 var progress_div = $("progressDiv" + progressIdx);
3669 var a_child = progress_div.childNodes;
3671 for (i = 0; i < a_child.length; i++) {
3672 if (a_child[i].id = "progressValue") {
3673 var progressValue = a_child[i];
3676 var progress = parseFloat(progressValue.innerHTML);
3677 if (answer.value <= progress) {
3681 progressValue.innerHTML = answer.value;
3682 progressValue.setStyle("width:" + answer.value + "%");
3683 if (answer.value == 100) {
3684 clearInterval(progressBar[p_idx]);
3685 progressValue.innerHTML = "Success";
3686 Effect.BlindUp("progressDiv" + p_idx, {duration: 1.0, scaleContent: false})
3687 $("message" + p_idx).remove();
3688 $("blocking" + p_idx).remove();
3689 setTimeout(function () {
3690 $("progressDiv" + progressIdx).remove
3694 clearInterval(progressBar[p_idx]);
3695 document.getElementById("progressValue").innerHTML = req.responseText;
3696 console.error(e.message);
3701 clearInterval(progressBar[p_idx]);
3702 console.error(e.message);
3707 * In the user's setting box, update the period list with the choosen exercice
3708 * @param {int} p_dossier
3710function updatePeriodePreference(p_dossier)
3713 var exercice = $('exercice_setting').value;
3714 new Ajax.Updater('setting_period', "ajax_misc.php", {method: "get", parameters: {"op": "pref_exercice", "gDossier": p_dossier, "exercice": exercice}});
3715 remove_waiting_box();
3718 * Update the from and to periode list when changing the exercice
3719 * @param {int} p_dossier
3720 * @param {string} p_exercice dom id of the exercice (SELECT)
3721 * @param {type} p_periode_from id of the starting periode
3722 * @param {type} p_periode_to id of the ending periode
3723 * @param {type} p_last possible value = 1 to show last date or 0 the first
3725function updatePeriode(p_dossier, p_exercice, p_periode_from, p_periode_to, p_last)
3728 var exercice = $(p_exercice).value;
3729 new Ajax.Updater(p_periode_from, "ajax_misc.php",
3731 parameters: {op: "periode_change", "gDossier": p_dossier, "exercice": exercice,
3732 field: p_periode_from, "type": "from", "last": p_last}});
3733 if ( p_periode_to && p_last ) {
3734 new Ajax.Updater(p_periode_to, "ajax_misc.php",
3736 parameters: {op: "periode_change", "gDossier": p_dossier, "exercice": exercice,
3737 field: p_periode_to, "type": "to", "last": p_last}});
3739 remove_waiting_box();
3743 * @param {string} p_domid DOM id of the span containing the padlock icon
3746function toggle_lock(p_domid)
3748 var padlock = document.getElementById(p_domid);
3749 if (padlock == null) {
3750 console.error("domid invalid");
3752 var status = padlock.getAttribute("is_locked");
3754 padlock.innerHTML = "";
3755 padlock.setAttribute("is_locked", 0);
3756 } else if (status == 0) {
3757 padlock.innerHTML = "";
3758 padlock.setAttribute("is_locked", 1);
3760 throw "toggle_lock failed";
3767 * @returns {undefined}
3769function show_ledger_fin_currency()
3771 var ledger=$('p_jrn').value;
3772 var dossier=$('gDossier').value;
3773 // $('ledger_currency').
3774 var a=new Ajax.Updater("ledger_currency",
3777 parameters: {"op":"currencyCode","gDossier":dossier,"ledger":ledger}
3782 * Update Preference, applied the new CSS
3784function updatePreference()
3788 var param = $('preference_frm').serialize() + "&op=preference&action=save";
3790 new Ajax.Request("ajax_misc.php", {
3793 onSuccess: function (req) {
3794 var answer = req.responseText.evalJSON();
3795 // $('pagestyle').setAttribute('href', style.style);
3796 if ( answer['psw']=='NOK') {
3797 smoke.alert(answer['msg']);
3799 removeDiv('preference_div');
3805 smoke.alert(content[48] + e.message);
3807 remove_waiting_box();
3812 * turn on or off , set an domElement to 1 or 0 and change the icon
3813 * @param string icon_domid : id of the domElement which must be changed
3814 * @param string p_value_domid : id of domElement containing 1 or 0
3815 * @see param_jrn.php
3817function toggle_onoff(icon_domid, p_value_domid)
3819 if ($(p_value_domid).value == 0) {
3820 $(p_value_domid).value = 1;
3821 $(icon_domid).innerHTML = '';
3822 $(icon_domid).style = 'color:green';
3824 $(p_value_domid).value = 0;
3825 $(icon_domid).innerHTML = '';
3826 $(icon_domid).style = 'color:red';
3830 * turn on or off , set an domElement to 1 or 0 and change the icon
3831 * @param string icon_domid : id of the domElement which must be changed
3832 * @param string p_value_domid : id of domElement containing 1 or 0
3833 * @see param_jrn.php
3835function toggle_checkbox_onoff(icon_domid, p_value_domid)
3838 if ($(p_value_domid).value == 0) {
3839 $(p_value_domid).value = 1;
3840 $(icon_domid).innerHTML = '';
3842 $(p_value_domid).value = 0;
3843 $(icon_domid).innerHTML = '';
3847 * in CFGLED show or hide the row depending if the warning is enable or not
3849 * @param {type} p_enable
3850 * @param {type} p_row
3851 * @returns {undefined}
3853function toggle_row_warning_enable(p_enable, p_row)
3855 if ($(p_enable).value == 1) {
3863 * return a json object which is the merge of the 2 json objects
3864 * from 2015 : Object.assign(obj1, obj2);
3865 * @param p_json1 object 1 to merge
3866 * @param p_json2 object 2 to merge
3867 * @returns new json object
3869function json_concat(p_json1,p_json2)
3873 for (var key in p_json1) {
3874 result[key] = p_json1[key];
3876 for (var key in p_json2) {
3877 result[key] = p_json2[key];
3885 * this function unchecks other checkbox , it mimics the way a radio behaves
3886 * @param string p_click is the DOM id of the checkbox you clicked
3887 * @param string p_name is the name of all the checkbox to uncheck
3889function uncheck_other(p_click,p_name)
3891 var aCheckbox=document.getElementsByName(p_name);
3892 if (aCheckbox.length == 0) return;
3894 for (i=0;i<aCheckbox.length;i++) {
3895 aCheckbox[i].checked=false;
3897 p_click.checked=true;
3900 * @class operation Tag Manage the tag with operations
3901 * @returns {undefined}
3903var operation_tag = function (p_div)
3907 * Show a list of tag which can be added to the current followup document
3908 * @param {type} p_dossier
3909 * @param {type} jrn_id
3910 * @returns {undefined}
3912 this.select = function (p_dossier, p_jrn_id)
3916 var queryString = {jrn_id:p_jrn_id,op:"operation_tag_select",gDossier:p_dossier,ctl:this.ctl};
3917 var action = new Ajax.Request(
3921 parameters: queryString,
3922 onFailure: ajax_misc_failure,
3923 onSuccess: function (req, j) {
3924 remove_waiting_box();
3926 var answer = req.responseXML;
3927 var html = answer.getElementsByTagName('code');
3928 if (html.length === 0)
3930 var rec = unescape_xml(req.responseText);
3931 error_message('erreur :' + rec);
3933 var code_html = getNodeText(html[0]);
3934 code_html = unescape_xml(code_html);
3935 var pos = fixed_position(35, 229);
3936 add_div({id: 'tag_div', style: pos, cssclass: 'inner_box tag', drag: 0});
3938 remove_waiting_box();
3939 $('tag_div').innerHTML = code_html;
3944 error_message(e.message);
3949 * Add the current tag to the current ag_id
3950 * @param {int} p_dossier
3952 * @param p_isgroup g it is a group , t is a single tag
3955 this.add = function (p_dossier, p_jrn_id, t_id, p_isgroup)
3959 var queryString = {t_id:t_id,jrn_id:p_jrn_id,op:"operation_tag_add",
3960 gDossier:p_dossier,ctl:this.ctl,isgroup:p_isgroup};
3962 var action = new Ajax.Request(
3965 method: 'get', parameters: queryString,
3966 onFailure: ajax_misc_failure,
3967 onSuccess: function (req, j) {
3968 var answer = req.responseXML;
3969 var html = answer.getElementsByTagName('code');
3970 if (html.length === 0)
3972 var rec = unescape_xml(req.responseText);
3973 error_message('erreur :' + rec);
3975 var code_html = getNodeText(html[0]);
3976 code_html = unescape_xml(code_html);
3977 remove_waiting_box();
3978 $('operation_tag_td'+ctl).innerHTML = code_html;
3979 removeDiv('tag_div');
3984 error_message(e.message);
3988 * remove the current tag to the current ag_id
3989 * @param {int} p_dossier
3990 * @param {int} ag_id
3993 this.remove = function (p_dossier, p_jrn_id, t_id)
3996 confirm_box(null, content[50], function () {
3999 var queryString = {t_id:t_id,jrn_id:p_jrn_id,op:"operation_tag_remove",gDossier:p_dossier,ctl:ctl};
4000 var action = new Ajax.Request(
4004 parameters: queryString,
4005 onFailure: ajax_misc_failure,
4006 onSuccess: function (req, j) {
4007 var answer = req.responseXML;
4008 var html = answer.getElementsByTagName('code');
4009 if (html.length === 0)
4011 var rec = unescape_xml(req.responseText);
4012 error_message('erreur :' + rec);
4014 var code_html = getNodeText(html[0]);
4015 code_html = unescape_xml(code_html);
4016 remove_waiting_box();
4017 $('operation_tag_td'+ctl).innerHTML = code_html;
4023 error_message(e.message);
4030 * Check the sum of size of all the FILES to upload
4031 * @param p_object the form DOM object,
4032 * @param p_max_size MAX_FILE_SIZE constant (see config.inc.php or constant.php)
4033 * @returns true if the sum of filesize is greater than the limit
4035function check_file_size(p_object,p_max_size)
4038 for(var i=0;i<p_object.elements.length;i++) {
4039 var a=p_object.elements[i];
4041 if ( p_object.elements[i].getAttribute('type')=="file" )
4043 for (let x = 0; x < p_object.elements[i].files.length ; x++) {
4044 if( p_object.elements[i].files[x]){
4046 sum_file+=p_object.elements[i].files[x].size;
4051 if ( sum_file > p_max_size) {alert_box(content[78]);return false;}
4056 * Check that the receipt file is not too big
4057 * @see ajax_ledger.php , ledger_detail_file
4058 * @param int p_max_size maximum size
4059 * @param p_info name of the waiting box
4060 * @returns true if file size is less than the maximum
4062function check_receipt_size(p_max_size,p_info)
4064 document.getElementById(p_info).style.display="inline";
4066 var f=document.getElementById("receipt_id");
4067 if ( f && f.files[0] && f.files[0].size > parseFloat(p_max_size)) {
4068 document.getElementById("receipt_info_id").innerHTML=content[78];
4069 document.getElementById(p_info).style.display="none";
4072 document.getElementById("receipt_info_id").innerHTML="";
4073 document.getElementById("form_file").submit();
4077 * toggle size of a div : fullsize or normal
4080function full_size(p_div) {
4081 div_dom=document.getElementById(p_div);
4082 if ( ! div_dom ) return;
4083 if ( div_dom.hasClassName('fullsize')) {
4084 div_dom.removeClassName('fullsize');$('size_'+p_div).innerHTML='';
4086 div_dom.addClassName('fullsize');$('size_'+p_div).innerHTML='';
4092 * download a document from an url
4094function download_document(p_url)
4097 document.location=p_url;
4098 remove_waiting_box();
4101 * download a document from a form
4103function download_document_form(p_form_id)
4106 var url="export.php?"+$(p_form_id).serialize();
4107 document.location=url;
4108 remove_waiting_box();
4112 * Pause a javascript
4114function pausecomp(millis)
4116 var date = new Date();
4118 do { curDate = new Date(); }
4119 while(curDate-date < millis);
4122 * propose to reconnect
4123 * @returns {undefined}
4125function reconnect(){
4126 remove_waiting_box();
4127 new Ajax.Request('ajax_misc.php',{
4129 parameters:{op:"disconnect"},
4130 onSuccess:function (req) {
4131 var pos="position:fixed;top:0px;width:95%;height:95%";
4133 'id':"reconnect_bx",
4134 cssclass:"inner_box",
4137 div.innerHTML=req.responseText;
4143 * enlarge an INPUT TEXT
4146function enlarge_text(p_domid,p_size) {
4148 var element= document.getElementById(p_domid);
4149 if ( !element) {console.error (`enlarge text doesn't exist [${p_domid}]`)}
4150 var current_size=parseInt(element.getAttribute('size'));
4151 element.setAttribute('size',current_size+parseInt(p_size));
4153 console.error(`enlarge text fails with ${p_domid} ${p_size} `);
4154 console.error(e.message);
4161 * @brief display a box with the customer , supplier or event for today or late
4162 * @param p_detail , what to do
4164function event_display_detail(p_dossier,p_detail) {
4168 // create div if not exists
4169 var dgbox="situation_detail_div";
4172 var queryString={gDossier:p_dossier,op:'event_display_detail','what':p_detail};
4173 // call ajax and update content of the div
4174 var action = new Ajax.Request(
4178 parameters:queryString,
4179 onFailure:ajax_misc_failure,
4180 onSuccess:function(req){
4181 remove_waiting_box();
4182 if (req.responseText == 'NOCONX') {
4186 if ( ! document.getElementById(dgbox)) {
4187 var div_style="position:fixed;"+";top:30%";
4188 add_div({id:dgbox,cssclass:'inner_box',html:loading(),style:div_style,drag:true});
4192 $(dgbox).update(req.responseText)
4197 event_display_main(p_dossier);
4200 alert_box(e.message);
4205 * @brief refresh the main display in the dashboard to reflect possible changes
4208function event_display_main(p_dossier) {
4212 var dgbox="situation_div";
4213 var queryString={gDossier:p_dossier,op:'event_display_detail','what':"main_display"};
4214 var action = new Ajax.Request(
4218 parameters:queryString,
4219 onFailure:ajax_misc_failure,
4220 onSuccess:function(req){
4221 remove_waiting_box();
4222 if (req.responseText == 'NOCONX') {
4227 $(dgbox).update(req.responseText)
4234 alert_box(e.message);
4239 * @brief check if password is strong or not, update a DIV element
4240 * @param p_pass_domid DOM ID of the INPUT element with the password
4241 * @param p_result_domid DOM ID of the element to update
4243function check_password_strength(p_pass_domid,p_result_domid,details)
4247 if ( $(p_pass_domid).value=="") { $(p_result_domid).update("");return;}
4250 ,pass:$(p_pass_domid).value
4252 var action = new Ajax.Request(
4256 parameters:queryString,
4257 onFailure:ajax_misc_failure,
4258 onSuccess:function(req){
4259 remove_waiting_box();
4260 if (req.responseText == 'NOCONX') {
4263 var answer=req.responseJSON;
4264 console.debug(answer);
4265 if (answer['password']=='nok') {
4267 $(p_pass_domid).setStyle("background-color:red");
4269 $(p_result_domid).update(answer['msg'])
4273 $(p_pass_domid).setStyle("background-color: lightgreen");
4274 $(p_result_domid).update("")
4280 alert_box(e.message);