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
24 * javascript scripts for the gestion
31 * remove an attached document of an action
33 *@param {int} dt_id id of the document (pk document:d_id)
35function remove_document(p_dossier,p_id)
43 var action=new Ajax.Request (
47 parameters:queryString,
48 onFailure:errorRemoveDoc,
49 onSuccess:successRemoveDoc
58 * remove the concerned operation of an action
60 *@param p_id id pk action_comment_operation
62function remove_operation(p_dossier,p_id)
70 var action=new Ajax.Request (
74 parameters:queryString,
75 onFailure:errorRemoveDoc,
76 onSuccess:successRemoveOp
82function successRemoveOp(request,json)
85 var answer=request.responseText.evalJSON(true);
86 if ( answer.ago_id == -1 ) { alert_box (content[59]);return;}
88 var action="acop"+answer.ago_id;
89 $(action).innerHTML="";
90 var doc="op"+answer.ago_id;
91 $(doc).style.color="red";
92 $(doc).href="javascript:alert_box(content[60])";
93 $(doc).style.textDecoration="line-through";
99 * remove the concerned operation of an action
101 *@param p_id id pk action_comment_operation
103function remove_action(p_dossier,p_id,ag_id)
106 "gDossier":p_dossier,
112 var action=new Ajax.Request (
116 parameters:queryString,
117 onFailure:ajax_misc_failure,
118 onSuccess:function(request,json) {
120 var answer=request.responseText.evalJSON(true);
121 if ( answer.act_id == -1 ) { alert_box (content[59]);return;}
122 var action="acact"+answer.act_id;
123 $(action).innerHTML="";
124 var doc="act"+answer.act_id;
125 $(doc).style.color="red";
126 $(doc).href="javascript:alert_box(content[60])";
127 $(doc).style.textDecoration="line-through";
128 } catch (e){ alert_box(e.message);}
136 * remove comment of an action
138 *@param p_id pk action_gestion_comment
140function remove_comment(p_dossier,p_id)
143 "gDossier":p_dossier,
148 var action=new Ajax.Request (
152 parameters:queryString,
153 onFailure:errorRemoveDoc,
154 onSuccess:successRemoveComment
160function successRemoveComment(request,json)
162 var answer=request.responseText.evalJSON(true);
163 if ( answer.agc_id == -1 ) { alert_box (content[59]);return;}
164 var action="accom"+answer.agc_id;
165 $(action).innerHTML="";
166 var doc="com"+answer.agc_id;
167 $(doc).style.color="red";
168 $(doc).href="javascript:alert_box(content[60])";
169 $(doc).style.textDecoration="line-through";
173 * error if a document if removed
175function errorRemoveDoc()
177 alert_box('Impossible d\'effacer ce document');
180 * success when removing a document
182function successRemoveDoc(request,json)
184 var answer=request.responseText.evalJSON(true);
185 if ( answer.d_id == -1 ) { alert_box ('Effacement non autorisé');return;}
186 var action="ac"+answer.d_id;
187 $(action).innerHTML="";
188 var doc="doc"+answer.d_id;
189 $(doc).style.color="red";
190 $(doc).href="javascript:alert_box(content[60])";
191 $(doc).style.textDecoration="line-through";
192 $('desc'+answer.d_id).innerHTML="";
196* check the format of the hour
197* @param p_ctl is the control where the hour is encoded
199function check_hour(p_ctl)
203 var h=document.getElementById(p_ctl);
204 var re = /^\d{1,2}:\d{2}$/;
205 if ( trim(h.value) !='' && ! h.value.match(re))
210 alert_box('fct : check_hour '+erreur);
215 * remove an attached document of an action
217 *@param dt_id id of the document (pk document:d_id)
220function removeStock(s_id,p_dossier)
222 smoke.confirm(content[50],
226 queryString="gDossier="+p_dossier+"&op=rm_stock&s_id="+s_id;
227 var action=new Ajax.Request (
231 parameters:queryString,
232 onFailure:errorRemoveStock,
233 onSuccess:successRemoveStock
244 * error if a document if removed
246function errorRemoveStock()
248 alert_box(content[60]);
251 * success when removing a document
253function successRemoveStock(request,json)
257 var answer=request.responseText.evalJSON(true);
258 var doc="stock"+answer.d_id;
259 var href="href"+answer.d_id;
260 $(href).innerHTML='';
262 $(doc).style.color="red";
263 // $(doc).href="javascript:alert_box('Stock Effacé')";
264 $(doc).style.textDecoration="line-through";
267 alert_box("success_box"+e.message);
271 * display details of the last actions in management
272 * called from dashboard
273 * @param p_dossier : dossier id
275function action_show(p_dossier)
279 var action = new Ajax.Request('ajax_misc.php',
282 parameters : {gDossier:p_dossier,'op':'action_show'},
283 onSuccess : function(p_xml, p_text) {
284 remove_waiting_box();
285 add_div({id: 'action_list_div', style:"position:fixed;top:1%;width:90%;left:5%" , cssclass: 'inner_box'});
286 $('action_list_div').innerHTML=p_xml.responseText;
287 var table_followup=document.getElementById('event_followup');
288 if ( table_followup) { sorttable.makeSortable(table_followup); }
293 alert_box('action_show '+e.message);
297 * Display a box for adding a new event
298 * @param {type} p_dossier
299 * @returns {undefined}
301function action_add(p_dossier) {
303 if ( $('action_add_div')) {
304 alert_box(content[61]);
308 var action = new Ajax.Request('ajax_misc.php',
311 parameters : {gDossier:p_dossier,'op':'action_add'},
312 onSuccess : function(p_xml, p_text) {
313 if (p_xml.responseText === 'NOCONX') { reconnect();return;}
314 remove_waiting_box();
315 add_div({id: 'action_add_div',style:'top:25px',
316 cssclass: 'inner_box'});
317 $('action_add_div').innerHTML=p_xml.responseText;
318 p_xml.responseText.evalScripts();
323 alert_box('action_add '+e.message);
327 * The new event is entered into the div action_add_div, we try
328 * to save and receive as answer a XML file with a code of success and possibly
330 * If the message is OK then the div is fading out, otherwise the reason of
331 * failure is shown and the div remains
333function action_save_short()
336 $('action_add_frm_info').innerHTML="";
337 $('action_add_frm')['date_event_action_short'].parentNode.className="";
338 $('action_add_frm')['title_event'].parentNode.className="";
339 $('action_add_frm')['type_event'].parentNode.className="";
340 $('action_add_frm')['hour_event'].parentNode.className="";
342 if ( $('action_add_frm')['date_event_action_short'].value.trim() == '') {
343 $('action_add_frm')['date_event_action_short'].parentNode.className="notice";
347 if ( $('action_add_frm')['title_event'].value.trim()=="") {
348 $('action_add_frm')['title_event'].parentNode.className="notice";
351 var str_hour=new String($('action_add_frm')['hour_event'].value);
352 str_hour=str_hour.trim();
354 if ( str_hour.trim() != ""
355 && str_hour.search(/^[0-9]{2}:[0-9]{2}$/) == -1 &&
356 str_hour.search(/^[0-9]{2}.[0-9]{2}$/) == -1)
358 $('action_add_frm')['hour_event'].parentNode.className="notice";
359 alert_box('HH:MM or HH.MM');
363 if ( $('action_add_frm')['type_event'].options[$('action_add_frm')['type_event'].selectedIndex].value == -1 )
365 $('action_add_frm')['type_event'].parentNode.className="notice";
368 var form=$('action_add_frm').serialize();
370 var action = new Ajax.Request('ajax_misc.php',
374 onSuccess: function (p_xml, p_text) {
375 remove_waiting_box();
376 var answer=p_xml.responseXML;
377 var code_tags=answer.getElementsByTagName('status');
378 var code=getNodeText(code_tags[0]);
379 var message_tags=answer.getElementsByTagName('content');
380 var message=getNodeText(message_tags[0]);
383 // Successfully saved
384 $('action_add_frm_info').innerHTML=message;
385 $('action_add_div').remove();
388 else if (code == 'NOK') {
389 // issue while saving
390 $('action_add_frm_info').innerHTML=message;
399 alert_box('action_add ' + e.message);
405 * list of filter for follow up
406 * @param p_dossier int dossier id
407 * @param access_code string access_code
409function list_filter_followup(p_dossier,access_code)
412 "gDossier":p_dossier,
413 "op":"list_filter_followup",
414 "ctl":"filter_followup_id",
417 var action=new Ajax.Request (
421 parameters:queryString,
422 onSuccess:function(responseHtml)
425 var div = create_div({"id":"filter_followup_id",
426 'cssclass': "inner_box2", 'style': 'top:'+posy+"px"});
427 div.update(responseHtml.responseText);
436 * @brief delete a filter of follow-up
437 * @param p_dossier int dossier id
438 * @param filter_id int table: action_gestion_comment.af_id
440function delete_filter_followup(p_dossier,filter_id)
442 smoke.confirm(content[47], function (e) {
446 "gDossier": p_dossier,
447 "op": "delete_filter_followup",
448 "ctl": "filter_followup_id",
449 "filter_id": filter_id
451 var action = new Ajax.Request(
455 parameters: queryString,
456 onSuccess: function (responseHtml) {
457 $('item_fu' + filter_id).remove();