/[openfoncier]/trunk/obj/instruction.class.php
ViewVC logotype

Diff of /trunk/obj/instruction.class.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 265 by fraynaud, Tue Dec 6 08:49:57 2011 UTC revision 1439 by nhaye, Fri Mar 15 14:45:21 2013 UTC
# Line 18  specific : Line 18  specific :
18  - voir script_lang.js : bible ...  - voir script_lang.js : bible ...
19  */  */
20  require_once ("../gen/obj/instruction.class.php");  require_once ("../gen/obj/instruction.class.php");
21    require_once("../services/outgoing/messageenqueuer.php");
22    
23  class instruction extends instruction_gen {  class instruction extends instruction_gen {
24    
# Line 29  class instruction extends instruction_ge Line 30  class instruction extends instruction_ge
30          $this->constructeur($id,$db,$debug);          $this->constructeur($id,$db,$debug);
31      }// fin constructeur      }// fin constructeur
32    
33      function setvalF($val){      // {{{ Gestion de la confidentialité des données spécifiques
34          $this->valF['instruction'] = $val['instruction'];  
35          $this->valF['destinataire'] = $val['destinataire'];      /**
36          $this->valF['lettretype'] = $val['lettretype'];       * Surcharge pour gérer les actions disponibles dans le portlet
37          $this->valF['dossier'] = $val['dossier'];       */
38          if($val['datecourrier']!="")      function checkAccessibility() {
39              $this->valF['datecourrier'] = $this->dateDB($val['datecourrier']);          //
40          $this->valF['complement'] = $val['complement'];          parent::checkAccessibility();
41          $this->valF['complement2'] = $val['complement2'];          // Si l'utilisateur est un intructeur qui en correspond pas à la
42          $this->valF['evenement'] = $val['evenement'];          // division du dossier
43          $this->valF['delai'] = $val['delai']; // necessaire pour maj datecourrier          if ($this->f->isUserInstructeur()
44                && isset($this->f->om_utilisateur["division"])
45                && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) {
46                //
47                $this->actions_sup = array();
48                $this->setParameter("actions", array());
49            }
50            // Si une action 'lu' est présente et que le champ lu est à true
51            // on supprime l'action
52            if (isset($this->actions_sup["lu"])
53                && isset($this->val[array_search("lu", $this->champs)])
54                && $this->val[array_search("lu", $this->champs)]== "t") {
55                unset($this->actions_sup["lu"]);
56            }
57        }
58    
59        /**
60         * Cette methode est à surcharger elle permet de tester dans chaque classe
61         * des droits des droits spécifiques en fonction des données
62         */
63        function canAccess() {
64            // Si l'utilisateur est un intructeur qui ne correspond pas à la
65            // division du dossier
66            if ($this->f->isUserInstructeur()
67                && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()
68                && $this->getParameter("maj") != 3) {
69                //
70                return false;
71            }
72            //
73            return true;
74        }
75    
76        /**
77         * Cette méthode permet de récupérer la division d'un dossier
78         */
79        function getDivisionFromDossier() {
80            //
81            if (!isset($this->val[array_search("dossier", $this->champs)])) {
82                return NULL;
83            }
84            //
85            $sql = "select division from ".DB_PREFIXE."dossier ";
86            $sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'";
87            //
88            $division = $this->db->getOne($sql);
89            $this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE);
90            database::isError($division);
91            //
92            return $division;
93      }      }
94    
95        // }}}
96    
97      function cleSecondaire($id,&$db,$val,$DEBUG) {      function cleSecondaire($id,&$db,$val,$DEBUG) {
98          parent::cleSecondaire($id,$db,$val,$DEBUG);          parent::cleSecondaire($id,$db,$val,$DEBUG);
# Line 55  class instruction extends instruction_ge Line 106  class instruction extends instruction_ge
106          $dernierevenement = $db->getOne($sql);          $dernierevenement = $db->getOne($sql);
107           if($dernierevenement==$id){           if($dernierevenement==$id){
108               $this->correct=true;               $this->correct=true;
109               $this->msg="<br>"._('destruction_chronologique')." ok <br>";               $this->addToMessage(_('Destruction_chronologique'));
110            }else{            }else{
111               $this->msg="<br>"._('destruction_evenement')." : ".$dernierevenement.               $this->addToMessage(_('Destruction_evenement')." : ".$dernierevenement);
112               "<br>"._('destruction_chronologique');               $this->addToMessage(_('Destruction_chronologique'));
113               $this->correct=false;               $this->correct=false;
114            }            }
115      }      }
116    
117      function verifier($val,&$db,$DEBUG){      // Sélectionne le signataire_arrete par défaut
118          $this->correct=True;      function setVal(&$form,$maj,$validation){
119          $imgv="";          
120          $f="&nbsp!&nbsp;&nbsp;&nbsp;&nbsp;";          // Ajout
121          $imgv="<img src='../app/img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>";          if($maj == 0) {
122          // obligatoire              
123          if ($this->valF['destinataire']==""){              // Création de la requête
124             $this->correct=false;              $sql = "SELECT signataire_arrete
125             $this->msg= $this->msg.$imgv." "._('instruction')." ".                      FROM ".DB_PREFIXE."signataire_arrete
126             _('obligatoire').$f;                      WHERE defaut IS TRUE";
127          }              
128          if ($val['datecourrier']==""){              // Exécution de la requête
129             $this->correct=false;              $this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE);
130             $this->msg= $this->msg.$imgv." "._('datecourrier')." ".              $res = $this->f->db->query($sql);
131             _('obligatoire').$f;              $this->f->isDatabaseError();
132          }          
133          if ($val['evenement']==""){              $row = $res->fetchrow(DB_FETCHMODE_ASSOC);
134             $this->correct=false;              
135             $this->msg= $this->msg.$imgv." "._('evenement')." ".              if ( isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){
136             _('obligatoire').$f;                  
137                    $form->setVal("signataire_arrete",$row['signataire_arrete']);
138                }
139          }          }
140      }//verifier      }
141    
142        /*Met des valeurs par défaut dans certains des sous-formulaire*/
143      function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){      function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){
144          if ($validation==0) {          if ($validation==0 and $maj<2) {
145              if ($maj == 0){              if ($maj == 0){
146                  $form->setVal("destinataire", $idxformulaire);                  $form->setVal("destinataire", $idxformulaire);
147                  $form->setVal("dossier", $idxformulaire);                  $form->setVal("dossier", $idxformulaire);
148                  $form->setVal("datecourrier", date('Y-m-d'));                  $form->setVal("date_evenement", date('Y-m-d'));
149              }              }
150              $form->setVal("bible_auto","bible_auto()");              $form->setVal("bible_auto","bible_auto()");
151              $form->setVal("bible","bible()");              $form->setVal("bible","bible()");
# Line 101  class instruction extends instruction_ge Line 155  class instruction extends instruction_ge
155          $this->idxformulaire=$idxformulaire;          $this->idxformulaire=$idxformulaire;
156      }      }
157    
158        /*Affecte un type à certains champs*/
159      function setType(&$form,$maj) {      function setType(&$form,$maj) {
160      if ($maj < 2) { //ajouter et modifier          parent::setType($form,$maj);
161          $form->setType('destinataire', 'hidden');          if ($maj < 2) { //ajouter et modifier
162          $form->setType('lettretype', 'hiddenstatic');              $form->setType('destinataire', 'hidden');
163          $form->setType('complement', 'textarea');              $form->setType('lettretype', 'hiddenstatic');
164          $form->setType('complement2', 'textarea');              $form->setType('complement', 'textarea');
165                $form->setType('complement2', 'textarea');
166                $form->setType('bible_auto', 'httpclick');
167                $form->setType('bible', 'httpclick');
168                $form->setType('bible2', 'httpclick');
169                $form->setType('dossier', 'hidden');  
170                $form->setType('libelle', 'hiddenstatic');
171                $form->setType('signataire_arrete','select');
172                if($maj==0){ // add
173                    $form->setType('instruction', 'hiddenstatic');
174                    $form->setType('evenement', 'select');
175                    $form->setType('date_evenement', 'date2');
176                }else{ // modify
177                    $form->setType('instruction', 'hiddenstatic');
178                    $form->setType('evenement', 'hiddenstatic');
179                    //$form->setType('date_evenement', 'hiddenstaticdate');
180                    $form->setType('date_evenement', 'date2');
181                    // necessaire pour calcul de date en modification
182                    $form->setType('delai', 'hiddenstatic');
183                }
184            } elseif($maj==2){
185                $form->setType('dossier', 'hidden');
186                $form->setType('bible_auto', 'hidden');
187                $form->setType('bible', 'hidden');
188                $form->setType('bible2', 'hidden');
189            }else {
190                $form->setType('destinataire', 'hidden');
191                $form->setType('dossier', 'hidden');
192                $form->setType('bible_auto', 'hidden');
193                $form->setType('bible', 'hidden');
194                $form->setType('bible2', 'hidden');
195            }
196          $form->setType('complement3', 'hidden');          $form->setType('complement3', 'hidden');
197          $form->setType('bible3', 'hidden');          $form->setType('bible3', 'hidden');
198          $form->setType('complement4', 'hidden');          $form->setType('complement4', 'hidden');
# Line 133  class instruction extends instruction_ge Line 219  class instruction extends instruction_ge
219          $form->setType('bible14', 'hidden');          $form->setType('bible14', 'hidden');
220          $form->setType('complement15', 'hidden');          $form->setType('complement15', 'hidden');
221          $form->setType('bible15', 'hidden');          $form->setType('bible15', 'hidden');
         $form->setType('bible_auto', 'httpclick');  
         $form->setType('bible', 'httpclick');  
         $form->setType('bible2', 'httpclick');  
         $form->setType('dossier', 'hiddenstatic');  
222          $form->setType('delai', 'hidden');          $form->setType('delai', 'hidden');
223          $form->setType('etat', 'hidden');          $form->setType('etat', 'hidden');
224          $form->setType('accord_tacite', 'hidden');          $form->setType('accord_tacite', 'hidden');
225          $form->setType('action', 'hidden');          $form->setType('action', 'hidden');
226          $form->setType('delai_notification', 'hidden');          $form->setType('delai_notification', 'hidden');
227          $form->setType('avis', 'hidden');          $form->setType('avis_decision', 'hidden');
228          $form->setType('archive_delai', 'hidden');          $form->setType('archive_delai', 'hidden');
229          $form->setType('archive_etat', 'hidden');          $form->setType('archive_etat', 'hidden');
230          $form->setType('archive_accord_tacite', 'hidden');          $form->setType('archive_accord_tacite', 'hidden');
# Line 155  class instruction extends instruction_ge Line 237  class instruction extends instruction_ge
237          $form->setType('archive_date_validite', 'hidden');          $form->setType('archive_date_validite', 'hidden');
238          $form->setType('archive_date_achevement', 'hidden');          $form->setType('archive_date_achevement', 'hidden');
239          $form->setType('archive_date_conformite', 'hidden');          $form->setType('archive_date_conformite', 'hidden');
240          $form->setType('archive_date_chantier', 'hidden');              $form->setType('archive_date_chantier', 'hidden');  
241          $form->setType('libelle', 'hiddenstatic');          $form->setType('numero_arrete', 'hidden');
         if($maj==0){ // add  
             $form->setType('instruction', 'hiddenstatic');  
             $form->setType('evenement', 'select');  
             $form->setType('datecourrier', 'date2');  
         }else{ // modify  
             $form->setType('instruction', 'hiddenstatic');  
             $form->setType('evenement', 'hiddenstatic');  
             //$form->setType('datecourrier', 'hiddenstaticdate');  
             $form->setType('datecourrier', 'date2');  
             // necessaire pour calcul de date en modification  
             $form->setType('delai', 'hiddenstatic');  
         }  
     }else{ // supprimer  [delete]  
         $form->setType('instruction', 'hiddenstatic');  
         $form->setType('dossier', 'hiddenstatic');  
         $form->setType('archive_delai', 'hiddenstatic');  
         $form->setType('archive_etat', 'hiddenstatic');  
         $form->setType('archive_accord_tacite', 'hiddenstatic');  
         $form->setType('archive_avis', 'hiddenstatic');  
         $form->setType('archive_date_complet', 'hiddenstatic');  
         $form->setType('archive_date_rejet', 'hiddenstatic');  
         $form->setType('archive_date_limite', 'hiddenstatic');  
         $form->setType('archive_date_notification_delai', 'hiddenstatic');  
         $form->setType('archive_date_decision', 'hiddenstatic');  
         $form->setType('archive_date_validite', 'hiddenstatic');  
         $form->setType('archive_date_achevement', 'hiddenstatic');  
     }  
     }  
   
     function setTaille(&$form,$maj){  
         $form->setTaille('complement', 120);  
         $form->setTaille('complement2', 120);  
         $form->setTaille('datecourrier', 12);  
     }  
   
     function setMax(&$form,$maj){  
         $form->setMax('complement',12 );  
         $form->setMax('complement2',12 );  
242      }      }
   
243            
244        /*Met des valeurs choisies dans certains select du formulaire*/
245      function setSelect(&$form, $maj,&$db,$DEBUG) {      function setSelect(&$form, $maj,&$db,$DEBUG) {
246          if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))          if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
247              include ("../sql/".$db->phptype."/".$this->table.".form.inc");              include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
248          if($maj<2){  
249              // *** evenement ***          parent::setSelect($form, $maj, $db, $DEBUG);
250              $contenu=array();  
251              // etat du dossier          // *** evenement ***
252              $sql="select etat from ".DB_PREFIXE."dossier where dossier ='".          $contenu=array();
253                    $this->idxformulaire."'";          // etat du dossier
254              $etat_dossier = $db->getOne($sql);          $sql="select etat from ".DB_PREFIXE."dossier where dossier ='".
255              $nature_dossier= substr($this->idxformulaire,0,2);                $this->idxformulaire."'";
256              // recherche des evenement de transition          $etat_dossier = $db->getOne($sql);
257              $sql= $sql_transition." where transition.etat ='".$etat_dossier."' and (evenement.nature ='".          // nature du dossier d'autorisation
258                    $nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action";          $sql="select code from ".DB_PREFIXE."dossier
259                            INNER JOIN ".DB_PREFIXE."dossier_autorisation ON
260              // *** attention en dur le CU                  dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
261                            INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON
262                    dossier_autorisation.dossier_autorisation_type_detaille =
263              $res = $db->query($sql);                  dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
264              if (database::isError($res))              WHERE dossier ='".
265                  die($res->getMessage());                $this->idxformulaire."'";
266              $contenu[0][0]="";          $nature_dossier = $db->getOne($sql);
267              $contenu[1][0]=_('choisir')." "._('evenement');  
268              $k=1;          // recherche des evenement de transition
269              while ($row=& $res->fetchRow()){          // XXX modifier la requète après la modification de structure du workflow
270                  if($maj==0){ // ajouter          $sql= $sql_transition." where transition.etat ='".$etat_dossier."' and dossier='".
271                      $contenu[0][$k]=$row[0];                $this->idxformulaire."' order by evenement.action";
272                      $contenu[1][$k]=$row[1];          
273                      $k++;          // *** attention en dur le CU
274                  }else{          $this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE);
275                      // select hiddenstatic  
276                      $contenu[0][$k]=$row[0];          $res = $db->query($sql);
277                      $contenu[1][$k]=$row[1];          if (database::isError($res))
278                      $k++;              die($res->getMessage());
279                  }          $contenu[0][0]="";
280              }          $contenu[1][0]=_('choisir')." "._('evenement');
281              $form->setSelect("evenement",$contenu);          $k=1;
282              // lien bible_auto  [link]          while ($row=& $res->fetchRow()){
283              $contenu=array();              if($maj==0){ // ajouter
284              $contenu[0]=" automatique ";                  $contenu[0][$k]=$row[0];
285              $form->setSelect("bible_auto",$contenu);                  $contenu[1][$k]=$row[1];
286              // lien bible1                  $k++;
287              $contenu=array();              }else{
288              $contenu[0]=" Bible ";                  // select hiddenstatic
289              $form->setSelect("bible",$contenu);                  $contenu[0][$k]=$row[0];
290              // lien bible2                  $contenu[1][$k]=$row[1];
291              $contenu=array();                  $k++;
292              $contenu[0]=" Bible ";              }
             $form->setSelect("bible2",$contenu);  
293          }          }
294            $form->setSelect("evenement",$contenu);
295            // lien bible_auto  [link]
296            $contenu=array();
297            $contenu[0]=" automatique ";
298            $form->setSelect("bible_auto",$contenu);
299            // lien bible1
300            $contenu=array();
301            $contenu[0]=" Bible ";
302            $form->setSelect("bible",$contenu);
303            // lien bible2
304            $contenu=array();
305            $contenu[0]=" Bible ";
306            $form->setSelect("bible2",$contenu);
307      } // function select      } // function select
308    
309      function setGroupe(&$form,$maj){      function setLayout(&$form, $maj){
310          $form->setGroupe('evenement','D');          if ( $maj < 2 OR $maj == 3 ) {
311          $form->setGroupe('libelle','G');                          /*Champ sur lequel s'ouvre le bloc 1 */
312          $form->setGroupe('datecourrier','G');              $form->setBloc('evenement','D',"","col_12");
313          $form->setGroupe('lettretype','F');  
314      }                  $form->setFieldset('evenement','D',_('Evenement'));
315                        $form->setBloc('evenement','D',"","group col_12");
316      function setRegroupe(&$form,$maj){                            $form->setBloc('date_evenement','F');
317          $form->setRegroupe('evenement','D',_('evenement'), "collapsible");                  $form->setFieldset('lettretype','F','');
318          $form->setRegroupe('libelle','G','');              
319          $form->setRegroupe('datecourrier','G','');              $form->setBloc('lettretype','F');
320          $form->setRegroupe('lettretype','F','');  
321          $form->setRegroupe('complement','D',_('complement'), "collapsible");              $form->setBloc('date_finalisation_courrier','D',"","col_12");
322          $form->setRegroupe('bible_auto','G','');  
323          $form->setRegroupe('bible','F','');                  $form->setFieldset('date_finalisation_courrier','D',_('Dates'));
324          $form->setRegroupe('complement2','D',_('complement2'), "startClosed");                      $form->setBloc('date_finalisation_courrier','D',"","col_6");
325          $form->setRegroupe('bible2','F','');                      $form->setBloc('date_envoi_controle_legalite','F');
326    
327                        $form->setBloc('signataire_arrete','D',"","col_6");
328                        $form->setBloc('date_retour_controle_legalite','F');
329                    $form->setFieldset('date_retour_controle_legalite','F','');
330                
331                $form->setBloc('date_retour_controle_legalite','F');
332    
333                $form->setBloc('complement','D',"","col_12");
334                    $form->setFieldset('complement','D',_('Complement'));
335                    $form->setFieldset('bible','F','');
336                $form->setBloc('bible','F');
337    
338                $form->setBloc('complement2','D',"","col_12");
339                    $form->setFieldset('complement2','D',_('Complement 2'));
340                    $form->setFieldset('bible2','F','');
341                $form->setBloc('bible2','F');
342            }
343      }      }
344            
345        /*Change le libellé de certains champs*/
346      function setLib(&$form,$maj) {      function setLib(&$form,$maj) {
347          parent :: setLib($form,$maj);          parent :: setLib($form,$maj);
348          $form->setLib('libelle',' ');          $form->setLib('libelle',' ');
349          $form->setLib('bible_auto',"");          $form->setLib('bible_auto',"");
350          $form->setLib('bible',"");          $form->setLib('bible',"");
351          $form->setLib('bible2',"");          $form->setLib('bible2',"");
         $form->setLib('lettretype',"->"._(" courrier "));  
         $form->setLib('datecourrier',_(" du "));  
     }  
   
     function setOnchange(&$form,$maj){  
         $form->setOnchange("datecourrier","fdate(this)");  
352      }      }
353    
354      // ==================================================================      // ==================================================================
355      // trigger avant modification données    [trigger before modify data]      // trigger avant modification des données    [trigger before modify data]
356      // ==================================================================      // ==================================================================
357      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
358          // mise a jour instruction avec evenement          // mise a jour instruction avec evenement
359          // [modify instruction with evenement]          // [modify instruction with evenement]
360          $sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement'];          $sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement'];
361            
362          $res = $db->query($sql);          $res = $db->query($sql);
363          if (database::isError($res)) die($res->getMessage());          if (database::isError($res)) die($res->getMessage());
364            
365          if ($DEBUG == 1)          if ($DEBUG == 1)
366              echo " la requete ".$sql." est exécutée<br>";              echo " la requete ".$sql." est exécutée<br>";
367            
368          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
369              $this->valF['action']=$row['action'];              
370                if(isset($row['action']) and !empty($row['action'])) {
371                    $this->valF['action']=$row['action'];
372                } else {
373                    $this->valF['action']=NULL;
374                }
375              $this->valF['delai']=$row['delai'];              $this->valF['delai']=$row['delai'];
376              $this->valF['etat']=$row['etat'];              if(isset($row['etat']) and !empty($row['etat'])) {
377                    $this->valF['etat']=$row['etat'];
378                } else {
379                    $this->valF['etat']=NULL;
380                }
381              $this->valF['accord_tacite']=$row['accord_tacite'];              $this->valF['accord_tacite']=$row['accord_tacite'];
382              $this->valF['delai_notification']=$row['delai_notification'];              $this->valF['delai_notification']=$row['delai_notification'];
383              $this->valF['avis']=$row['avis'];              if(isset($row['avis_decision']) and !empty($row['avis_decision'])) {
384                    $this->valF['avis_decision']=$row['avis_decision'];
385                } else {
386                    $this->valF['avis_decision']=NULL;
387                }
388              if($row['lettretype']!="")              if($row['lettretype']!="")
389                  $this->valF['lettretype']=$row['lettretype'];                  $this->valF['lettretype']=$row['lettretype'];
390              else              else
391                  $this->valF['lettretype']="standard";                  $this->valF['lettretype']="standard";
392                
393          }          }
394          $sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'";          $sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'";
395          $res = $db->query($sql);          $res = $db->query($sql);
# Line 319  class instruction extends instruction_ge Line 404  class instruction extends instruction_ge
404              $this->valF['archive_delai']=$row['delai'];              $this->valF['archive_delai']=$row['delai'];
405              $this->valF['archive_accord_tacite']=$row['accord_tacite'];              $this->valF['archive_accord_tacite']=$row['accord_tacite'];
406              $this->valF['archive_etat']=$row['etat'];              $this->valF['archive_etat']=$row['etat'];
407              $this->valF['archive_avis']=$row['avis'];              $this->valF['archive_avis']=$row['avis_decision'];
408              // compatibilite pgsql              // compatibilite pgsql
409              if($row['date_complet']!='')              if($row['date_complet']!='')
410                 $this->valF['archive_date_complet']=$row['date_complet'];                 $this->valF['archive_date_complet']=$row['date_complet'];
# Line 342  class instruction extends instruction_ge Line 427  class instruction extends instruction_ge
427          }          }
428      }      }
429            
430        // Test si une restriction est valide
431        // return boolean
432        function restrictionIsValid($restriction){
433            
434            /* Met des espace avant et après les opérateurs puis transforme la chaine en
435             * un tableau */
436            $tabRestriction = str_replace(">="," >= ",
437                              str_replace("<="," <= ",
438                              str_replace("-"," - ",
439                              str_replace("+"," + ",$restriction))));
440            $tabRestriction = explode( " ", $tabRestriction);
441            
442            //Variables de résultat
443            $res = array();
444            $i = 0;
445            $comp = "";
446            
447            
448            //Test que le tableau n'est pas vide
449            if ( count($tabRestriction) > 0 ){
450                
451                $res[0] = $this->getRestrictionValue($tabRestriction[0]);
452                
453                //Calcul des variables
454                for ( $j = 1 ; $j < count($tabRestriction) ; $j += 2 ) {
455                    
456                    //Variable de comparaison
457                    if ( strcmp( ">=", $tabRestriction[$j] ) == 0 ||
458                         strcmp( "<=", $tabRestriction[$j]) ==0 ){
459                        
460                        $comp = $tabRestriction[$j];
461                        $res[++$i] = $this->getRestrictionValue($tabRestriction[$j+1]);
462                    }
463                    // Fait l'addition
464                    elseif ( strcmp( "+", $tabRestriction[$j]) == 0 ){
465                        
466                       $res[$i] =  $this->moisdate( $res[$i], $this->getRestrictionValue($tabRestriction[$j+1]) );
467                    }
468                }
469            }
470                    
471            // Effectue le test
472            if ( strcmp($comp, ">=") == 0 ){
473                
474                if ( $res[0] >= $res[1] || $res[0] == "" ){
475                    
476                    return true;
477                }
478                else {
479                    
480                    return false;
481                }
482            }
483            elseif ( strcmp($comp, "<=") == 0 ){
484    
485                if ( $res[0] <= $res[1] || $res[1] == "" ){
486    
487                    return true;
488                }
489                else {
490    
491                    return false;
492                }
493            }
494            
495            return true;
496        }
497        
498        //Retourne la valeur de valF si $restrictionValue n'est pas un chiffre, le chiffre sinon
499        function getRestrictionValue($restrictionValue){
500            
501            return ( is_numeric($restrictionValue) ) ?
502                $restrictionValue :
503                $this->valF[$restrictionValue];
504        }
505        
506      function regle($regle){      function regle($regle){
507          $temp = explode ("+",$regle);          $temp = explode ("+",$regle);
508          //echo '|'.$regle;          //echo '|'.$regle;
# Line 391  class instruction extends instruction_ge Line 552  class instruction extends instruction_ge
552          // voir parametrage des actions en dur          // voir parametrage des actions en dur
553          $param=1;          $param=1;
554          if($param==1){          if($param==1){
555          $sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'";              $sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'";
556          $res = $db->query($sql);              $res = $db->query($sql);
557          if (database::isError($res))              if (database::isError($res))
558              die($res->getMessage());                  die($res->getMessage());
559          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
560              if($row['regle_etat']!=''){                  if($row['regle_etat']!=''){
561                  $valF['etat']= $this->regle($row['regle_etat']);                      $valF['etat']= $this->regle($row['regle_etat']);
562              }                  }
563              if($row['regle_delai']!=''){                  if($row['regle_delai']!=''){
564                  $valF['delai']= $this->regle($row['regle_delai']);                      $valF['delai']= $this->regle($row['regle_delai']);
565              }                  }
566              if($row['regle_accord_tacite']!=''){                  if($row['regle_accord_tacite']!=''){
567                  $valF['accord_tacite']= $this->regle($row['regle_accord_tacite']);                      $valF['accord_tacite']= $this->regle($row['regle_accord_tacite']);
568              }                  }
569              if($row['regle_avis']!=''){                  if($row['regle_avis']!=''){
570                  $valF['avis']= $this->regle($row['regle_avis']);                      $valF['avis_decision']= $this->regle($row['regle_avis']);
571              }                  }
572              if($row['regle_date_limite']!=''){                  if($row['regle_date_limite']!=''){
573                  $valF['date_limite']= $this->regle($row['regle_date_limite']);                      $valF['date_limite']= $this->regle($row['regle_date_limite']);
574              }                  }
575              if($row['regle_date_complet']!=''){                  if($row['regle_date_complet']!=''){
576                  $valF['date_complet']= $this->regle($row['regle_date_complet']);                      $valF['date_complet']= $this->regle($row['regle_date_complet']);
577              }                  }
578              if($row['regle_date_notification_delai']!=''){                  if($row['regle_date_notification_delai']!=''){
579                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);                      $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);
580              }                  }
581              if($row['regle_date_decision']!=''){                  if($row['regle_date_decision']!=''){
582                  $valF['date_decision']= $this->regle($row['regle_date_decision']);                      $valF['date_decision']= $this->regle($row['regle_date_decision']);
583              }                  }
584              if($row['regle_date_rejet']!=''){                  if($row['regle_date_rejet']!=''){
585                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);                      $valF['date_rejet']= $this->regle($row['regle_date_rejet']);
586              }                  }
587             if($row['regle_date_validite']!=''){                 if($row['regle_date_validite']!=''){
588                  $valF['date_validite']= $this->regle($row['regle_date_validite']);                      $valF['date_validite']= $this->regle($row['regle_date_validite']);
589              }                  }
590             if($row['regle_date_chantier']!=''){                 if($row['regle_date_chantier']!=''){
591                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);                      $valF['date_chantier']= $this->regle($row['regle_date_chantier']);
592              }                  }
593             if($row['regle_date_achevement']!=''){                 if($row['regle_date_achevement']!=''){
594                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);                      $valF['date_achevement']= $this->regle($row['regle_date_achevement']);
595              }                  }
596             if($row['regle_date_conformite']!=''){                 if($row['regle_date_conformite']!=''){
597                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                      $valF['date_conformite']= $this->regle($row['regle_date_conformite']);
598                    }
599                  
600                   // Appel des méthode stockées dans le champ methode_trigger
601                   if($row['methode_trigger'] != "") {
602                       foreach (explode(";", $row['methode_trigger']) as $methode) {
603                           if(method_exists($this, $methode)) {
604                               $this->$methode();
605                           }
606                          
607                       }
608                   }
609              }              }
         }  
610          }else{          }else{
611              switch ($this->valF['action']) {              switch ($this->valF['action']) {
612              case "initialisation" :              case "initialisation" :
# Line 457  class instruction extends instruction_ge Line 628  class instruction extends instruction_ge
628                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
629                  // la date du courrier ne doit pas etre depasse par rapport au delai de                  // la date du courrier ne doit pas etre depasse par rapport au delai de
630                  // notification    [verify notification date]                  // notification    [verify notification date]
631                  if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier'])                  if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement'])
632                      $this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ".                      $this->msg=$this->msg."<br><img src='../img/erreur.gif'> "._("date_notification_delai")." ".
633                      $this->valF['archive_date_notification_delai']." < "._('datecourrier');                      $this->valF['archive_date_notification_delai']." < "._('date_evenement');
634                  //                  //
635                  break;                  break;
636              case "retour" :              case "retour" :
# Line 467  class instruction extends instruction_ge Line 638  class instruction extends instruction_ge
638                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
639                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
640                  // la date_complet est celle de l evenement                  // la date_complet est celle de l evenement
641                  $valF['date_complet']= $this->valF['datecourrier'];                  $valF['date_complet']= $this->valF['date_evenement'];
642                  $valF['date_limite'] =  $this->moisdate($valF['date_complet'],$valF['delai']);                  $valF['date_limite'] =  $this->moisdate($valF['date_complet'],$valF['delai']);
643                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
644                  break;                  break;
# Line 476  class instruction extends instruction_ge Line 647  class instruction extends instruction_ge
647                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
648                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
649                  // la date rejet est initialisee                  // la date rejet est initialisee
650                  $valF['date_rejet']= $this->valF['datecourrier'];                  $valF['date_rejet']= $this->valF['date_evenement'];
651                  // les dates de depart et fin d instruction sont annulées                  // les dates de depart et fin d instruction sont annulées
652                  $valF['date_limite'] =null;                  $valF['date_limite'] =null;
653                  $valF['date_notification_delai'] =null;                  $valF['date_notification_delai'] =null;
# Line 492  class instruction extends instruction_ge Line 663  class instruction extends instruction_ge
663                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
664                  // la date du courrier ne doit pas etre depasse par rapport au delai de                  // la date du courrier ne doit pas etre depasse par rapport au delai de
665                  // notification                  // notification
666                  if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier'])                  if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement'])
667                      $this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai").                      $this->msg=$this->msg."<br><img src='../img/erreur.gif'>"._("date_notification_delai").
668                  $this->valF['archive_date_notification_delai']." < "._('datecourrier');                  $this->valF['archive_date_notification_delai']." < "._('date_evenement');
669                  break;                  break;
670              case "acceptation" :              case "acceptation" :
671                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
672                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
673                  $valF['avis']= $this->valF['avis'];                  $valF['avis_decision']= $this->valF['avis_decision'];
674                  // date de validite = date de l evenement + delai                  // date de validite = date de l evenement + delai
675                  $valF['date_validite'] =  $this->moisdate($this->valF['datecourrier'],$this->valF['delai']);                  $valF['date_validite'] =  $this->moisdate($this->valF['date_evenement'],$this->valF['delai']);
676                     break;                     break;
677              case "refus" :              case "refus" :
678                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
679                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
680                  $valF['avis']= $this->valF['avis'];                  $valF['avis_decision']= $this->valF['avis_decision'];
681                  break;                  break;
682              case "prolongation" :              case "prolongation" :
683                  $valF['date_validite'] =  $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']);                  $valF['date_validite'] =  $this->moisdate($this->valF['archive_date_validite'],$this->valF['delai']);
684                  break;                  break;
685              case "sursis" :              case "sursis" :
686                  $valF['date_limite'] =  $this->moisdate($this->valF['datecourrier'],$this->valF['delai']);                  $valF['date_limite'] =  $this->moisdate($this->valF['date_evenement'],$this->valF['delai']);
687                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
688                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
689                  $valF['avis']= $this->valF['avis'];                  $valF['avis_decision']= $this->valF['avis_decision'];
690                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
691                  $temp = $valF['date_limite'];                  $temp = $valF['date_limite'];
692                  $valF['date_validite']= $this->moisdate($temp,2);                  $valF['date_validite']= $this->moisdate($temp,2);
693                  break;                  break;
694              case "execution" :              case "execution" :
695                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
696                  $valF['date_chantier'] =  $this->valF['datecourrier'];                  $valF['date_chantier'] =  $this->valF['date_evenement'];
697                  //echo $this->msg=$this->msg.$valF['date_chantier']."";                  //echo $this->msg=$this->msg.$valF['date_chantier']."";
698                  break;                  break;
699              case "achevement" :              case "achevement" :
700                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
701                  $valF['date_achevement'] = $this->valF['datecourrier'];                  $valF['date_achevement'] = $this->valF['date_evenement'];
702                  break;                  break;
703              case "archivage" :              case "archivage" :
704                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
705                  $valF['date_conformite'] = $this->valF['datecourrier'];                  $valF['date_conformite'] = $this->valF['date_evenement'];
706                  break;                  break;
707            
708              default:              default:
# Line 551  class instruction extends instruction_ge Line 722  class instruction extends instruction_ge
722              $db->affectedRows()." "._('enregistrement').              $db->affectedRows()." "._('enregistrement').
723              " "._('mis_a_jour')."]" ;              " "._('mis_a_jour')."]" ;
724          }          }
725            // verification si envoi vers ERP est active
726            if ($this->f->getParameter('option_erp') != "") {
727                // la nature du dossier
728                $nature_dossier = substr($this->idxformulaire,0,2);
729                $dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" .
730                                            $this->valF['dossier'] . "'");
731                $evenement_libelle = $this->getFromDB(
732                        "SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" .
733                        $this->valF['evenement'] . "'");
734                if ($dossier_erp == 't') {
735                    // envoi du message en cas d'un PC qui est ERP et sur lequel un evenement
736                    // d'acceptation etait fait
737                    if ($nature_dossier ==
738                            $this->f->getParameter('erp_evenement_accepter_dossier_PC')
739                        && $this->valF['evenement'] ==
740                            $this->f->getParameter('erp_evenement_accepter_sans_reserve')) {
741                        $msgenque = new MessageEnqueuer();
742                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
743                        $msgenque->setDecision($evenement_libelle);
744                        $msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE);
745                    }
746                    if ($this->valF['evenement'] ==
747                            $this->f->getParameter('erp_evenement_refuser_dossier')) {
748                        $msgenque = new MessageEnqueuer();
749                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
750                        $msgenque->enqueueMessage($msgenque::$ERP_DECISION_CONFORMITE_EFFECTUE);                
751                    }
752                }
753            } // fin de if ($this->f->getParameter('option_erp') != "")
754        }
755        
756        
757        /**
758         * Fait une requette sql pour extraire la valeur d'un champ, et retourne
759         * cette valeur
760         * @param string $sql La requete sql a executer
761         * @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD
762         * l'execution s'arrete.
763         */
764        function getFromDB($sql) {
765            //$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'";
766            $res = $this->db->limitquery($sql, 0, 1);
767            $this->addToLog("getDossierERPSpecification(): db->limitquery(\"".
768                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
769            // Si une erreur survient on die
770            if (database::isError($res, true)) {
771                // Appel de la methode de recuperation des erreurs
772                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction');
773            }
774            // retourne la nature du dossier
775            while ($row =& $res->fetchRow()) {
776                return $row[0];
777            }
778            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
779            return NULL;
780    
781      }      }
782        
783    
784      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
785          /*          /*
786           * cette fonction apour objet de permettre de modifier la date courrier           * cette fonction a pour objet de permettre de modifier la date courrier
787          */          */
788          $valF=array();          $valF=array();
789          $sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement'];          $sql= "select action from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement'];
# Line 566  class instruction extends instruction_ge Line 794  class instruction extends instruction_ge
794          if (database::isError($res)) die($res->getMessage().$sql);          if (database::isError($res)) die($res->getMessage().$sql);
795          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
796              // application des regles sur le courrier + delai              // application des regles sur le courrier + delai
797              if(preg_match("/datecourrier/",$row['regle_date_limite'])){              if(preg_match("/date_evenement/",$row['regle_date_limite'])){
798                  $valF['date_limite']= $this->regle($row['regle_date_limite']);                  $valF['date_limite']= $this->regle($row['regle_date_limite']);
799              }              }
800              if(preg_match("/datecourrier/",$row['regle_date_complet'])){              if(preg_match("/date_evenement/",$row['regle_date_complet'])){
801                  $valF['date_complet']= $this->regle($row['regle_date_complet']);                  $valF['date_complet']= $this->regle($row['regle_date_complet']);
802              }              }
803              if(preg_match("/datecourrier/",$row['regle_date_notification_delai'])){              if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){
804                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);
805              }              }
806              if(preg_match("/datecourrier/",$row['regle_date_decision'])){              if(preg_match("/date_evenement/",$row['regle_date_decision'])){
807                  $valF['date_decision']= $this->regle($row['regle_date_decision']);                  $valF['date_decision']= $this->regle($row['regle_date_decision']);
808              }              }
809              if(preg_match("/datecourrier/",$row['regle_date_rejet'])){              if(preg_match("/date_evenement/",$row['regle_date_rejet'])){
810                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);
811              }              }
812              if(preg_match("/datecourrier/",$row['regle_date_validite'])){              if(preg_match("/date_evenement/",$row['regle_date_validite'])){
813                  $valF['date_validite']= $this->regle($row['regle_date_validite']);                  $valF['date_validite']= $this->regle($row['regle_date_validite']);
814              }              }
815              if(preg_match("/datecourrier/",$row['regle_date_chantier'])){              if(preg_match("/date_evenement/",$row['regle_date_chantier'])){
816                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);
817              }              }
818              if(preg_match("/datecourrier/",$row['regle_date_achevement'])){              if(preg_match("/date_evenement/",$row['regle_date_achevement'])){
819                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);
820              }              }
821              if(preg_match("/datecourrier/",$row['regle_date_conformite'])){              if(preg_match("/date_evenement/",$row['regle_date_conformite'])){
822                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);
823              }              }
824          } // while          } // while
# Line 606  class instruction extends instruction_ge Line 834  class instruction extends instruction_ge
834              $db->affectedRows()." "._('enregistrement').              $db->affectedRows()." "._('enregistrement').
835              " "._('mis_a_jour')."]" ;              " "._('mis_a_jour')."]" ;
836          }          }
837    
838            // Envoi des infos au
839            if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) {
840                $msgenque = new MessageEnqueuer();
841                $sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\",
842                                    signataire_arrete.nom as \"ws_DA_In_Sign_Nom\",
843                                    signataire_arrete.prenom as \"ws_DA_In_Sign_Prenom\",
844                                    signataire_arrete.qualite as \"ws_DA_In_Sign_Qualite\",
845                                    instruction.date_evenement as \"ws_DA_In_Dte_Redac\",
846                                    '' as \"ws_DA_In_lieu_Redac\",
847                                    instruction.dossier as \"ws_DA_In_N_Doss_DAS\",
848                                    '' as \"ws_DA_In_Sigle\",
849                                    instruction.etat as \"ws_DA_In_Decision\",
850                                    dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\",
851                                    dossier.terrain_numero as \"ws_DA_In_N_Voie\",
852                                    '' as \"ws_DA_In_Type_Voie\",
853                                    dossier.complement as \"ws_DA_In_Adresse1\",
854                                    dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\",
855                                    dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\",
856                                    dossier.terrain_adresse_localite as \"ws_DA_In_Ville\",
857                                    dossier.terrain_references_cadastrales as \"ws_DA_In_Nb_Parcelle\",
858                                    '' as \"ws_DA_In_Detail_Parcelle\",
859                                    CONCAT(donnees_techniques.am_projet_desc,' ',donnees_techniques.co_projet_desc) as \"ws_DA_In_Nature_Trvx\",
860                                    '' as \"ws_DA_In_Destination_Trvx\",
861                                    dossier_autorisation_type_detaille.code as \"ws_DA_In_Type_Dos_Autoris\",
862                                    COALESCE(particulier_nom,personne_morale_raison_sociale) as \"ws_DA_In_Nom_Petition\",
863                                    COALESCE(particulier_prenom, personne_morale_denomination) as \"ws_DA_In_Prenom_Petition\",
864                                    '' as \"ws_DA_In_Piece_GED\",
865                                    instruction.date_retour_signature as \"ws_DA_In_Dte_Signature\"
866                            FROM ".DB_PREFIXE."instruction
867                            LEFT JOIN ".DB_PREFIXE."signataire_arrete ON
868                                instruction.signataire_arrete = signataire_arrete.signataire_arrete
869                            LEFT JOIN ".DB_PREFIXE."dossier ON
870                                instruction.dossier = dossier.dossier
871                            LEFT JOIN ".DB_PREFIXE."lien_dossier_demandeur ON
872                                lien_dossier_demandeur.dossier = dossier.dossier
873                            LEFT JOIN ".DB_PREFIXE."demandeur ON
874                                lien_dossier_demandeur.demandeur = demandeur.demandeur
875                            LEFT JOIN ".DB_PREFIXE."dossier_instruction_type ON
876                                dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type
877                            LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON
878                                dossier_instruction_type.dossier_autorisation_type_detaille =
879                                    dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
880                            LEFT JOIN ".DB_PREFIXE."donnees_techniques ON
881                                    donnees_techniques.dossier_instruction = dossier.dossier
882                            WHERE instruction.instruction = ".$this->valF['instruction'];
883                $resArrete = $this->db->query($sqlArrete);
884                $this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE);
885                $this->f->isDatabaseError();
886    
887                $rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC);
888                $msgenque->setArreteInfo($rowArrete);
889                $msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI);                
890            }
891      }      }
892    
893    
# Line 617  class instruction extends instruction_ge Line 899  class instruction extends instruction_ge
899          $valF['accord_tacite']=$val['archive_accord_tacite'];          $valF['accord_tacite']=$val['archive_accord_tacite'];
900          $valF['etat']=$val['archive_etat'];          $valF['etat']=$val['archive_etat'];
901          if($val['archive_avis']=='')          if($val['archive_avis']=='')
902              $valF['avis']= null;              $valF['avis_decision']= null;
903          else          else
904              $valF['avis']=$val['archive_avis'];              $valF['avis_decision']=$val['archive_avis'];
905          // if= compatibilite pgsql          // if= compatibilite pgsql
906          if($val['archive_date_complet']!='')          if($val['archive_date_complet']!='')
907              $valF['date_complet']=$val['archive_date_complet'];              $valF['date_complet']=$val['archive_date_complet'];
# Line 700  class instruction extends instruction_ge Line 982  class instruction extends instruction_ge
982      return $annee."-".$mois."-".$jour ;      return $annee."-".$mois."-".$jour ;
983      }      }
984    
985        // Vérifie la restriction sur l'événement
986        function verifier($val = array(), &$db, $DEBUG){
987            parent::verifier($val, $db, $DEBUG);
988            //Récupère la restriction
989            $sql= "SELECT
990                      restriction
991                  FROM
992                      ".DB_PREFIXE."evenement
993                  WHERE
994                      evenement =".$this->valF['evenement'];
995    
996            $res = $db->query($sql);
997            $this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE);
998            $this->f->isDatabaseError();
999            
1000            $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1001    
1002            //Test qu'une restriction est présente
1003            if ( isset($row['restriction']) && $row['restriction'] != "" ){
1004                
1005                //Test si la restriction est valide
1006                if ( !$this->restrictionIsValid($row['restriction']) ){
1007                    
1008                    $this->correct=false;
1009                    $this->addToMessage(_("Restriction non valide"));
1010                }
1011                else {
1012                    
1013                    $this->correct = true;
1014                }
1015            }
1016        }
1017        
1018        /**
1019         * Méthode permettant de mettre à jour l'état d'un DA
1020         */
1021        function majEtatDA() {
1022            if($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 8) {
1023                $val['etat_dossier_autorisation']=5;
1024            } elseif($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 15) {
1025                $val['etat_dossier_autorisation']=3;
1026            } elseif($this->valF['action'] == 'accepter') {
1027                $val['etat_dossier_autorisation']=2;
1028            } elseif($this->valF['action'] == 'rejeter') {
1029                $val['etat_dossier_autorisation']=4;
1030            } elseif($this->valF['action'] == 'terminer') {
1031                $val['etat_dossier_autorisation']=8;
1032            } elseif($this->valF['action'] == 'majorer') {
1033                $val['etat_dossier_autorisation']=6;
1034            } else {
1035                $val['etat_dossier_autorisation']=7;
1036            }
1037            
1038            //Récupération du numéro de dossier d'autorisation lié au dossier d'instruction
1039            $IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']);
1040          
1041            // Mis à jour de l'état du dossier d'autorisation
1042            require_once '../obj/dossier_autorisation.class.php';
1043            $dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG);
1044            
1045            $dossier_autorisation->val[array_search("etat_dossier_autorisation", $dossier_autorisation->champs)] = $val['etat_dossier_autorisation'];
1046            
1047            //Récupération des données
1048            $valDossierAutorisation = array();
1049            for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){
1050                
1051                $valDossierAutorisation[$dossier_autorisation->champs[$i]]=
1052                    $dossier_autorisation->val[$i];
1053            }
1054    
1055            $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);
1056        }
1057        
1058       /**
1059        * Méthode permettant de mettre à jour les données d'un DA
1060        */
1061        function majDataDA() {
1062            
1063            //Récupération du numéro de dossier d'autorisation lié au dossier d'instruction
1064            $IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']);
1065            require_once '../obj/dossier_autorisation.class.php';
1066            $dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG);
1067            
1068            require_once '../obj/dossier.class.php';
1069            $dossier = new dossier($this->valF['dossier'],$this->db,DEBUG);
1070            
1071            //Récupération des données
1072            $valDossierAutorisation = array();
1073            for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){
1074                
1075                if ( array_search($dossier_autorisation->champs[$i], $dossier->champs) ){
1076                    
1077                    $valDossierAutorisation[$dossier_autorisation->champs[$i]]=$dossier->getVal($dossier_autorisation->champs[$i]);
1078                }
1079                else {
1080                    $valDossierAutorisation[$dossier_autorisation->champs[$i]]=
1081                    $dossier_autorisation->val[$i];
1082                }
1083            }
1084    
1085            $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);
1086            
1087            // Suppression du liens entre les lots et le DA
1088            $valLot['dossier_autorisation'] = NULL;
1089            $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "dossier_autorisation='".$IDdossier_autorisation."'");
1090            
1091            // Liaison des lots du DI avec le DA
1092            $sqlLot = "SELECT lot FROM ".DB_PREFIXE."lien_dossier_lot WHERE dossier='".$this->valF['dossier']."'";
1093            $res = $this->db->query($sqlLot);
1094            $this->addToLog($sqlLot);
1095            $this->f->isDatabaseError();
1096            while($rowLot = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
1097                $valLot['dossier_autorisation'] = $IDdossier_autorisation;
1098                $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "lot=".$rowLot['lot']);
1099            }
1100        }
1101        
1102        // Récupération de l'identifiant du dossier d'autorisation lié au dossier d'instruction
1103        function getDossierAutorisation($dossier_instruction){
1104            
1105            $sql = "SELECT
1106                        dossier_autorisation.dossier_autorisation
1107                    FROM
1108                        ".DB_PREFIXE."dossier_autorisation
1109                    LEFT JOIN
1110                        ".DB_PREFIXE."dossier
1111                        ON
1112                            dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation
1113                    WHERE
1114                        dossier.dossier = '".$dossier_instruction."'";
1115          
1116            $IDdossier_autorisation = $this->db->getOne($sql);
1117            $this->addToLog("getDossierAutorisation(): db->getone(\"".$sql."\")", VERBOSE_MODE);
1118            database::isError($IDdossier_autorisation);
1119            
1120            return $IDdossier_autorisation;
1121        }
1122  }// fin classe  }// fin classe
1123  ?>  ?>

Legend:
Removed from v.265  
changed lines
  Added in v.1439

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26