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 scripts for the gestion
30 * remove an attached document of an action
32 *@param dt_id id of the document (pk document:d_id)
34function remove_document(p_dossier,p_id)
42 var action=new Ajax.Request (
46 parameters:queryString,
47 onFailure:errorRemoveDoc,
48 onSuccess:successRemoveDoc
57 * remove the concerned operation of an action
59 *@param p_id id pk action_comment_operation
61function remove_operation(p_dossier,p_id)
69 var action=new Ajax.Request (
73 parameters:queryString,
74 onFailure:errorRemoveDoc,
75 onSuccess:successRemoveOp
81function successRemoveOp(request,json)
84 var answer=request.responseText.evalJSON(true);
85 if ( answer.ago_id == -1 ) { alert_box (content[59]);return;}
87 var action="acop"+answer.ago_id;
88 $(action).innerHTML="";
89 var doc="op"+answer.ago_id;
90 $(doc).style.color="red";
91 $(doc).href="javascript:alert_box(content[60])";
92 $(doc).style.textDecoration="line-through";
98 * remove the concerned operation of an action
100 *@param p_id id pk action_comment_operation
102function remove_action(p_dossier,p_id,ag_id)
105 "gDossier":p_dossier,
111 var action=new Ajax.Request (
115 parameters:queryString,
116 onFailure:ajax_misc_failure,
117 onSuccess:function(request,json) {
119 var answer=request.responseText.evalJSON(true);
120 if ( answer.act_id == -1 ) { alert_box (content[59]);return;}
121 var action="acact"+answer.act_id;
122 $(action).innerHTML="";
123 var doc="act"+answer.act_id;
124 $(doc).style.color="red";
125 $(doc).href="javascript:alert_box(content[60])";
126 $(doc).style.textDecoration="line-through";
127 } catch (e){ alert_box(e.message);}
135 * remove comment of an action
137 *@param p_id pk action_gestion_comment
139function remove_comment(p_dossier,p_id)
142 "gDossier":p_dossier,
147 var action=new Ajax.Request (
151 parameters:queryString,
152 onFailure:errorRemoveDoc,
153 onSuccess:successRemoveComment
159function successRemoveComment(request,json)
161 var answer=request.responseText.evalJSON(true);
162 if ( answer.agc_id == -1 ) { alert_box (content[59]);return;}
163 var action="accom"+answer.agc_id;
164 $(action).innerHTML="";
165 var doc="com"+answer.agc_id;
166 $(doc).style.color="red";
167 $(doc).href="javascript:alert_box(content[60])";
168 $(doc).style.textDecoration="line-through";
172 * error if a document if removed
174function errorRemoveDoc()
176 alert_box('Impossible d\'effacer ce document');
179 * success when removing a document
181function successRemoveDoc(request,json)
183 var answer=request.responseText.evalJSON(true);
184 if ( answer.d_id == -1 ) { alert_box ('Effacement non autorisé');return;}
185 var action="ac"+answer.d_id;
186 $(action).innerHTML="";
187 var doc="doc"+answer.d_id;
188 $(doc).style.color="red";
189 $(doc).href="javascript:alert_box(content[60])";
190 $(doc).style.textDecoration="line-through";
191 $('desc'+answer.d_id).innerHTML="";
195* check the format of the hour
196* @param p_ctl is the control where the hour is encoded
198function check_hour(p_ctl)
202 var h=document.getElementById(p_ctl);
203 var re = /^\d{1,2}:\d{2}$/;
204 if ( trim(h.value) !='' && ! h.value.match(re))
209 alert_box('fct : check_hour '+erreur);
214 * remove an attached document of an action
216 *@param dt_id id of the document (pk document:d_id)
219function removeStock(s_id,p_dossier)
221 smoke.confirm(content[50],
225 queryString="gDossier="+p_dossier+"&op=rm_stock&s_id="+s_id;
226 var action=new Ajax.Request (
230 parameters:queryString,
231 onFailure:errorRemoveStock,
232 onSuccess:successRemoveStock
243 * error if a document if removed
245function errorRemoveStock()
247 alert_box(content[60]);
250 * success when removing a document
252function successRemoveStock(request,json)
256 var answer=request.responseText.evalJSON(true);
257 var doc="stock"+answer.d_id;
258 var href="href"+answer.d_id;
259 $(href).innerHTML='';
261 $(doc).style.color="red";
262 // $(doc).href="javascript:alert_box('Stock Effacé')";
263 $(doc).style.textDecoration="line-through";
266 alert_box("success_box"+e.message);
270 * display details of the last actions in management
271 * called from dashboard
272 * @param p_dossier : dossier id
274function action_show(p_dossier)
278 var action = new Ajax.Request('ajax_misc.php',
281 parameters : {gDossier:p_dossier,'op':'action_show'},
282 onSuccess : function(p_xml, p_text) {
283 remove_waiting_box();
284 add_div({id: 'action_list_div', style:"top:1%;width:90%;left:5%" , cssclass: 'inner_box'});
285 $('action_list_div').innerHTML=p_xml.responseText;
286 var table_followup=document.getElementById('event_followup');
287 if ( table_followup) { sorttable.makeSortable(table_followup); }
292 alert_box('action_show '+e.message);
296 * Display a box for adding a new event
297 * @param {type} p_dossier
298 * @returns {undefined}
300function action_add(p_dossier) {
302 if ( $('action_add_div')) {
303 alert_box(content[61]);
307 var action = new Ajax.Request('ajax_misc.php',
310 parameters : {gDossier:p_dossier,'op':'action_add'},
311 onSuccess : function(p_xml, p_text) {
312 if (p_xml.responseText === 'NOCONX') { reconnect();return;}
313 remove_waiting_box();
314 add_div({id: 'action_add_div',style:'top:25px',
315 cssclass: 'inner_box'});
316 $('action_add_div').innerHTML=p_xml.responseText;
317 p_xml.responseText.evalScripts();
322 alert_box('action_add '+e.message);
326 * The new event is entered into the div action_add_div, we try
327 * to save and receive as answer a XML file with a code of success and possibly
329 * If the message is OK then the div is fading out, otherwise the reason of
330 * failure is shown and the div remains
332function action_save_short()
335 $('action_add_frm_info').innerHTML="";
336 $('action_add_frm')['date_event_action_short'].parentNode.className="";
337 $('action_add_frm')['title_event'].parentNode.className="";
338 $('action_add_frm')['type_event'].parentNode.className="";
339 $('action_add_frm')['hour_event'].parentNode.className="";
341 if ( $('action_add_frm')['date_event_action_short'].value.trim() == '') {
342 $('action_add_frm')['date_event_action_short'].parentNode.className="notice";
346 if ( $('action_add_frm')['title_event'].value.trim()=="") {
347 $('action_add_frm')['title_event'].parentNode.className="notice";
350 var str_hour=new String($('action_add_frm')['hour_event'].value);
351 str_hour=str_hour.trim();
353 if ( str_hour.trim() != ""
354 && str_hour.search(/^[0-9]{2}:[0-9]{2}$/) == -1 &&
355 str_hour.search(/^[0-9]{2}.[0-9]{2}$/) == -1)
357 $('action_add_frm')['hour_event'].parentNode.className="notice";
358 alert_box('HH:MM or HH.MM');
362 if ( $('action_add_frm')['type_event'].options[$('action_add_frm')['type_event'].selectedIndex].value == -1 )
364 $('action_add_frm')['type_event'].parentNode.className="notice";
367 var form=$('action_add_frm').serialize();
369 var action = new Ajax.Request('ajax_misc.php',
373 onSuccess: function (p_xml, p_text) {
374 remove_waiting_box();
375 var answer=p_xml.responseXML;
376 var code_tags=answer.getElementsByTagName('status');
377 var code=getNodeText(code_tags[0]);
378 var message_tags=answer.getElementsByTagName('content');
379 var message=getNodeText(message_tags[0]);
382 // Successfully saved
383 $('action_add_frm_info').innerHTML=message;
384 $('action_add_div').remove();
387 else if (code == 'NOK') {
388 // issue while saving
389 $('action_add_frm_info').innerHTML=message;
398 alert_box('action_add ' + e.message);
404 * list of filter for follow up
405 * @param p_dossier int dossier id
406 * @param access_code string access_code
408function list_filter_followup(p_dossier,access_code)
411 "gDossier":p_dossier,
412 "op":"list_filter_followup",
413 "ctl":"filter_followup_id",
416 var action=new Ajax.Request (
420 parameters:queryString,
421 onSuccess:function(responseHtml)
424 var div = create_div({"id":"filter_followup_id",
425 'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:'+posy+"px"});
426 div.update(responseHtml.responseText);
435 * @brief delete a filter of follow-up
436 * @param p_dossier int dossier id
437 * @param filter_id int table: action_gestion_comment.af_id
439function delete_filter_followup(p_dossier,filter_id)
441 smoke.confirm(content[47], function (e) {
445 "gDossier": p_dossier,
446 "op": "delete_filter_followup",
447 "ctl": "filter_followup_id",
448 "filter_id": filter_id
450 var action = new Ajax.Request(
454 parameters: queryString,
455 onSuccess: function (responseHtml) {
456 $('item_fu' + filter_id).remove();