noalyss  Version-6.7.2
 All Data Structures Namespaces Files Functions Variables Enumerations
gestion.js
Go to the documentation of this file.
00001 /*
00002  *   This file is part of NOALYSS.
00003  *
00004  *   NOALYSS is free software; you can redistribute it and/or modify
00005  *   it under the terms of the GNU General Public License as published by
00006  *   the Free Software Foundation; either version 2 of the License, or
00007  *   (at your option) any later version.
00008  *
00009  *   NOALYSS is distributed in the hope that it will be useful,
00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *   GNU General Public License for more details.
00013  *
00014  *   You should have received a copy of the GNU General Public License
00015  *   along with NOALYSS; if not, write to the Free Software
00016  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00017 */
00018 /* $Revision$ */
00019 
00020 // Copyright Author Dany De Bontridder danydb@aevalys.eu
00021 
00022 /*!\file
00023  * \brief javascript scripts for the gestion
00024  *
00025  */
00026 
00027 
00028 
00029 /**
00030  *@brief remove an attached document of an action
00031  *@param dossier
00032  *@param dt_id id of the document (pk document:d_id)
00033 */
00034 function remove_document(p_dossier,p_id)
00035 {
00036         var queryString="gDossier="+p_dossier+"&a=rm&d_id="+p_id;
00037         var action=new Ajax.Request (
00038                 "show_document.php",
00039                 {
00040                         method:'get',
00041                         parameters:queryString,
00042                         onFailure:errorRemoveDoc,
00043                         onSuccess:successRemoveDoc
00044                 }
00045 
00046                 );
00047 
00048 }
00049 /**
00050  *@brief update the description of an attached document of an action
00051  *@param dossier
00052  *@param dt_id id of the document (pk document:d_id)
00053 */
00054 function update_document(p_dossier,p_id)
00055 {
00056         var queryString="gDossier="+p_dossier+"&a=upd_doc&d_id="+p_id;
00057         queryString+="&value="+$('input_desc_txt'+p_id).value;
00058         var action=new Ajax.Request (
00059                 "show_document.php",
00060                 {
00061                         method:'get',
00062                         parameters:queryString,
00063                         onFailure:errorRemoveDoc,
00064                         onSuccess:function(req){
00065                                 $('input_desc'+p_id).hide();
00066                                 $('print_desc'+p_id).innerHTML=$('input_desc_txt'+p_id).value+'<a class="line" id="desc'+p_id+'" onclick="javascript:show_description('+p_id+')">Modifier</a>';
00067                                 $('print_desc'+p_id).show();
00068                         }
00069                 }
00070 
00071                 );
00072     return false;
00073 }
00074 
00075 /**
00076  *@brief remove the concerned operation of an action
00077  *@param dossier
00078  *@param p_id id pk action_comment_operation
00079 */
00080 function remove_operation(p_dossier,p_id)
00081 {
00082         queryString="gDossier="+p_dossier+"&a=rmop&id="+p_id;
00083         var action=new Ajax.Request (
00084                 "show_document.php",
00085                 {
00086                         method:'get',
00087                         parameters:queryString,
00088                         onFailure:errorRemoveDoc,
00089                         onSuccess:successRemoveOp
00090                 }
00091 
00092                 );
00093 
00094 }
00095 function successRemoveOp(request,json)
00096 {
00097         try{
00098                 var answer=request.responseText.evalJSON(true);
00099                 if ( answer.ago_id == -1 ) { alert ('Effacement non autorisé');return;}
00100 
00101                 var action="acop"+answer.ago_id;
00102                 $(action).innerHTML="";
00103                 var doc="op"+answer.ago_id;
00104                 $(doc).style.color="red";
00105                 $(doc).href="javascript:alert('Commentaire Effacé')";
00106                 $(doc).style.textDecoration="line-through";
00107         }catch(e){
00108                 alert(e.message);
00109         }
00110 }
00111 /**
00112  *@brief remove the concerned operation of an action
00113  *@param dossier
00114  *@param p_id id pk action_comment_operation
00115 */
00116 function remove_action(p_dossier,p_id,ag_id)
00117 {
00118         queryString="gDossier="+p_dossier+"&a=rmaction&id="+p_id+"&ag_id="+ag_id;
00119         var action=new Ajax.Request (
00120                 "show_document.php",
00121                 {
00122                         method:'get',
00123                         parameters:queryString,
00124                         onFailure:ajax_misc_failure,
00125                         onSuccess:function(request,json) {
00126                                 try{
00127                                 var answer=request.responseText.evalJSON(true);
00128                                 if ( answer.act_id == -1 ) { alert ('Effacement non autorisé');return;}
00129                                 var action="acact"+answer.act_id;
00130                                 $(action).innerHTML="";
00131                                 var doc="act"+answer.act_id;
00132                                 $(doc).style.color="red";
00133                                 $(doc).href="javascript:alert('Action Effacée')";
00134                                 $(doc).style.textDecoration="line-through";
00135                                 } catch (e){ alert(e.message);}
00136                         }
00137                 }
00138 
00139                 );
00140 
00141 }
00142 /**
00143  *@brief remove comment of an action
00144  *@param dossier
00145  *@param p_id pk action_gestion_comment
00146 */
00147 function remove_comment(p_dossier,p_id)
00148 {
00149         queryString="gDossier="+p_dossier+"&a=rmcomment&id="+p_id;
00150         var action=new Ajax.Request (
00151                 "show_document.php",
00152                 {
00153                         method:'get',
00154                         parameters:queryString,
00155                         onFailure:errorRemoveDoc,
00156                         onSuccess:successRemoveComment
00157                 }
00158 
00159                 );
00160 
00161 }
00162 function successRemoveComment(request,json)
00163 {
00164         var answer=request.responseText.evalJSON(true);
00165         if ( answer.agc_id == -1 ) { alert ('Effacement non autorisé');return;}
00166         var action="accom"+answer.agc_id;
00167         $(action).innerHTML="";
00168         var doc="com"+answer.agc_id;
00169         $(doc).style.color="red";
00170         $(doc).href="javascript:alert('Commentaire Effacé')";
00171         $(doc).style.textDecoration="line-through";
00172 
00173 }
00174 /**
00175  *@brief error if a document if removed
00176  */
00177 function errorRemoveDoc()
00178 {
00179         alert('Impossible d\'effacer ce document');
00180 }
00181 /**
00182  *@brief success when removing a document
00183  */
00184 function successRemoveDoc(request,json)
00185 {
00186         var answer=request.responseText.evalJSON(true);
00187         if ( answer.d_id == -1 ) { alert ('Effacement non autorisé');return;}
00188         var action="ac"+answer.d_id;
00189         $(action).innerHTML="";
00190         var doc="doc"+answer.d_id;
00191         $(doc).style.color="red";
00192         $(doc).href="javascript:alert('Document Effacé')";
00193         $(doc).style.textDecoration="line-through";
00194         $('desc'+answer.d_id).innerHTML="";
00195 
00196 }
00197 /**
00198 * @brief check the format of the hour
00199 * @param p_ctl is the control where the hour is encoded
00200 */
00201 function check_hour(p_ctl)
00202 {
00203         try
00204         {
00205                 var h=document.getElementById(p_ctl);
00206                 var re = /^\d{1,2}:\d{2}$/;
00207                 if ( trim(h.value) !='' && ! h.value.match(re))
00208                         alert("Format de l'heure est HH:MM ")
00209         }
00210         catch (erreur)
00211         {
00212                 alert('fct : check_hour '+erreur);
00213         }
00214 
00215 }
00216 /**
00217  *@brief remove an attached document of an action
00218  *@param dossier
00219  *@param dt_id id of the document (pk document:d_id)
00220 */
00221 
00222 function removeStock(s_id,p_dossier)
00223 {
00224         if ( ! confirm("Confirmez-vous l'effacement de cette entrée dans le stock?") )
00225         {
00226                 return;
00227         }
00228         queryString="gDossier="+p_dossier+"&op=rm_stock&s_id="+s_id;
00229         var action=new Ajax.Request (
00230                 "ajax_misc.php",
00231                 {
00232                         method:'get',
00233                         parameters:queryString,
00234                         onFailure:errorRemoveStock,
00235                         onSuccess:successRemoveStock
00236                 }
00237 
00238                 );
00239 
00240 }
00241 /**
00242  *@brief error if a document if removed
00243  */
00244 function errorRemoveStock()
00245 {
00246         alert('Impossible d\'effacer ');
00247 }
00248 /**
00249  *@brief success when removing a document
00250  */
00251 function successRemoveStock(request,json)
00252 {
00253         try
00254         {
00255                 var answer=request.responseText.evalJSON(true);
00256                 var doc="stock"+answer.d_id;
00257                 var href="href"+answer.d_id;
00258                 $(href).innerHTML='';
00259 
00260                 $(doc).style.color="red";
00261                 //    $(doc).href="javascript:alert('Stock Effacé')";
00262                 $(doc).style.textDecoration="line-through";
00263         } catch (e)
00264 {
00265                 alert("success_box"+e.message);
00266         }
00267 }
 All Data Structures Namespaces Files Functions Variables Enumerations