/[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 300 by fraynaud, Mon Feb 6 18:04:05 2012 UTC revision 1227 by vpihour, Wed Jan 16 11:17:06 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', 'hiddenstatic');  
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', 'hiddenstatic');
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', 'static');
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');  
         $form->setType('libelle', 'hiddenstatic');  
         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');  
241      }      }
     }  
   
     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        /*Met des valeurs choisies dans certains select du formulaire*/
244      function setSelect(&$form, $maj,&$db,$DEBUG) {      function setSelect(&$form, $maj,&$db,$DEBUG) {
245          if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))          if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
246              include ("../sql/".$db->phptype."/".$this->table.".form.inc");              include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
247          if($maj<2){  
248              // *** evenement ***          parent::setSelect($form, $maj, $db, $DEBUG);
249              $contenu=array();  
250              // etat du dossier          // *** evenement ***
251              $sql="select etat from ".DB_PREFIXE."dossier where dossier ='".          $contenu=array();
252                    $this->idxformulaire."'";          // etat du dossier
253              $etat_dossier = $db->getOne($sql);          $sql="select etat from ".DB_PREFIXE."dossier where dossier ='".
254              $nature_dossier= substr($this->idxformulaire,0,2);                $this->idxformulaire."'";
255              // recherche des evenement de transition          $etat_dossier = $db->getOne($sql);
256              $sql= $sql_transition." where transition.etat ='".$etat_dossier."' and (evenement.nature ='".          // nature du dossier d'autorisation
257                    $nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action";          $sql="select code from ".DB_PREFIXE."dossier
258                            INNER JOIN ".DB_PREFIXE."dossier_autorisation ON
259              // *** attention en dur le CU                  dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
260                            INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON
261                    dossier_autorisation.dossier_autorisation_type_detaille =
262              $res = $db->query($sql);                  dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
263              if (database::isError($res))              WHERE dossier ='".
264                  die($res->getMessage());                $this->idxformulaire."'";
265              $contenu[0][0]="";          $nature_dossier = $db->getOne($sql);
266              $contenu[1][0]=_('choisir')." "._('evenement');  
267              $k=1;          // recherche des evenement de transition
268              while ($row=& $res->fetchRow()){          // XXX modifier la requète après la modification de structure du workflow
269                  if($maj==0){ // ajouter          $sql= $sql_transition." where transition.etat ='".$etat_dossier."' and dossier='".
270                      $contenu[0][$k]=$row[0];                $this->idxformulaire."' order by evenement.action";
271                      $contenu[1][$k]=$row[1];          
272                      $k++;          // *** attention en dur le CU
273                  }else{          $this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE);
274                      // select hiddenstatic  
275                      $contenu[0][$k]=$row[0];          $res = $db->query($sql);
276                      $contenu[1][$k]=$row[1];          if (database::isError($res))
277                      $k++;              die($res->getMessage());
278                  }          $contenu[0][0]="";
279              }          $contenu[1][0]=_('choisir')." "._('evenement');
280              $form->setSelect("evenement",$contenu);          $k=1;
281              // lien bible_auto  [link]          while ($row=& $res->fetchRow()){
282              $contenu=array();              if($maj==0){ // ajouter
283              $contenu[0]=" automatique ";                  $contenu[0][$k]=$row[0];
284              $form->setSelect("bible_auto",$contenu);                  $contenu[1][$k]=$row[1];
285              // lien bible1                  $k++;
286              $contenu=array();              }else{
287              $contenu[0]=" Bible ";                  // select hiddenstatic
288              $form->setSelect("bible",$contenu);                  $contenu[0][$k]=$row[0];
289              // lien bible2                  $contenu[1][$k]=$row[1];
290              $contenu=array();                  $k++;
291              $contenu[0]=" Bible ";              }
292              $form->setSelect("bible2",$contenu);          }
293          }          $form->setSelect("evenement",$contenu);
294            // lien bible_auto  [link]
295            $contenu=array();
296            $contenu[0]=" automatique ";
297            $form->setSelect("bible_auto",$contenu);
298            // lien bible1
299            $contenu=array();
300            $contenu[0]=" Bible ";
301            $form->setSelect("bible",$contenu);
302            // lien bible2
303            $contenu=array();
304            $contenu[0]=" Bible ";
305            $form->setSelect("bible2",$contenu);
306      } // function select      } // function select
307    
308      function setGroupe(&$form,$maj){      function setGroupe(&$form,$maj){
309          $form->setGroupe('evenement','D');          $form->setGroupe('evenement','D');
310          $form->setGroupe('libelle','G');          $form->setGroupe('libelle','G');
311          $form->setGroupe('datecourrier','G');          $form->setGroupe('date_evenement','G');
312          $form->setGroupe('lettretype','F');          $form->setGroupe('lettretype','F');
313      }      }
314    
315      function setRegroupe(&$form,$maj){            function setRegroupe(&$form,$maj){      
316          $form->setRegroupe('evenement','D',_('evenement'), "collapsible");          $form->setRegroupe('evenement','D',_('evenement'), "collapsible");
317          $form->setRegroupe('libelle','G','');          $form->setRegroupe('libelle','G','');
318          $form->setRegroupe('datecourrier','G','');          $form->setRegroupe('date_evenement','G','');
319          $form->setRegroupe('lettretype','F','');          $form->setRegroupe('lettretype','F','');
320          $form->setRegroupe('complement','D',_('complement'), "collapsible");          $form->setRegroupe('complement','D',_('complement'), "collapsible");
321          $form->setRegroupe('bible_auto','G','');          $form->setRegroupe('bible_auto','G','');
# Line 269  class instruction extends instruction_ge Line 324  class instruction extends instruction_ge
324          $form->setRegroupe('bible2','F','');          $form->setRegroupe('bible2','F','');
325      }      }
326            
327        /*Change le libellé de certains champs*/
328      function setLib(&$form,$maj) {      function setLib(&$form,$maj) {
329          parent :: setLib($form,$maj);          parent :: setLib($form,$maj);
330          $form->setLib('libelle',' ');          $form->setLib('libelle',' ');
# Line 276  class instruction extends instruction_ge Line 332  class instruction extends instruction_ge
332          $form->setLib('bible',"");          $form->setLib('bible',"");
333          $form->setLib('bible2',"");          $form->setLib('bible2',"");
334          $form->setLib('lettretype',"->"._(" courrier "));          $form->setLib('lettretype',"->"._(" courrier "));
335          $form->setLib('datecourrier',_(" du "));          $form->setLib('date_evenement',_(" du "));
     }  
   
     function setOnchange(&$form,$maj){  
         $form->setOnchange("datecourrier","fdate(this)");  
336      }      }
337    
338      // ==================================================================      // ==================================================================
339      // trigger avant modification données    [trigger before modify data]      // trigger avant modification des données    [trigger before modify data]
340      // ==================================================================      // ==================================================================
341      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
342          // mise a jour instruction avec evenement          // mise a jour instruction avec evenement
343          // [modify instruction with evenement]          // [modify instruction with evenement]
344          $sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement'];          $sql= "select * from ".DB_PREFIXE."evenement where evenement =".$this->valF['evenement'];
345            
346          $res = $db->query($sql);          $res = $db->query($sql);
347          if (database::isError($res)) die($res->getMessage());          if (database::isError($res)) die($res->getMessage());
348            
349          if ($DEBUG == 1)          if ($DEBUG == 1)
350              echo " la requete ".$sql." est exécutée<br>";              echo " la requete ".$sql." est exécutée<br>";
351            
352          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
353              $this->valF['action']=$row['action'];              
354                if(isset($row['action']) and !empty($row['action'])) {
355                    $this->valF['action']=$row['action'];
356                } else {
357                    $this->valF['action']=NULL;
358                }
359              $this->valF['delai']=$row['delai'];              $this->valF['delai']=$row['delai'];
360              $this->valF['etat']=$row['etat'];              if(isset($row['etat']) and !empty($row['etat'])) {
361                    $this->valF['etat']=$row['etat'];
362                } else {
363                    $this->valF['etat']=NULL;
364                }
365              $this->valF['accord_tacite']=$row['accord_tacite'];              $this->valF['accord_tacite']=$row['accord_tacite'];
366              $this->valF['delai_notification']=$row['delai_notification'];              $this->valF['delai_notification']=$row['delai_notification'];
367              $this->valF['avis']=$row['avis'];              if(isset($row['avis_decision']) and !empty($row['avis_decision'])) {
368                    $this->valF['avis_decision']=$row['avis_decision'];
369                } else {
370                    $this->valF['avis_decision']=NULL;
371                }
372              if($row['lettretype']!="")              if($row['lettretype']!="")
373                  $this->valF['lettretype']=$row['lettretype'];                  $this->valF['lettretype']=$row['lettretype'];
374              else              else
375                  $this->valF['lettretype']="standard";                  $this->valF['lettretype']="standard";
376                
377          }          }
378          $sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'";          $sql= "select * from ".DB_PREFIXE."dossier where dossier = '".$this->valF['dossier']."'";
379          $res = $db->query($sql);          $res = $db->query($sql);
# Line 319  class instruction extends instruction_ge Line 388  class instruction extends instruction_ge
388              $this->valF['archive_delai']=$row['delai'];              $this->valF['archive_delai']=$row['delai'];
389              $this->valF['archive_accord_tacite']=$row['accord_tacite'];              $this->valF['archive_accord_tacite']=$row['accord_tacite'];
390              $this->valF['archive_etat']=$row['etat'];              $this->valF['archive_etat']=$row['etat'];
391              $this->valF['archive_avis']=$row['avis'];              $this->valF['archive_avis']=$row['avis_decision'];
392              // compatibilite pgsql              // compatibilite pgsql
393              if($row['date_complet']!='')              if($row['date_complet']!='')
394                 $this->valF['archive_date_complet']=$row['date_complet'];                 $this->valF['archive_date_complet']=$row['date_complet'];
# Line 342  class instruction extends instruction_ge Line 411  class instruction extends instruction_ge
411          }          }
412      }      }
413            
414        // Test si une restriction est valide
415        // return boolean
416        function restrictionIsValid($restriction){
417            
418            /* Met des espace avant et après les opérateurs puis transforme la chaine en
419             * un tableau */
420            $tabRestriction = str_replace(">="," >= ",
421                              str_replace("<="," <= ",
422                              str_replace("-"," - ",
423                              str_replace("+"," + ",$restriction))));
424            $tabRestriction = explode( " ", $tabRestriction);
425            
426            //Variables de résultat
427            $res = array();
428            $i = 0;
429            $comp = "";
430            
431            
432            //Test que le tableau n'est pas vide
433            if ( count($tabRestriction) > 0 ){
434                
435                $res[0] = $this->getRestrictionValue($tabRestriction[0]);
436                
437                //Calcul des variables
438                for ( $j = 1 ; $j < count($tabRestriction) ; $j += 2 ) {
439                    
440                    //Variable de comparaison
441                    if ( strcmp( ">=", $tabRestriction[$j] ) == 0 ||
442                         strcmp( "<=", $tabRestriction[$j]) ==0 ){
443                        
444                        $comp = $tabRestriction[$j];
445                        $res[++$i] = $this->getRestrictionValue($tabRestriction[$j+1]);
446                    }
447                    // Fait l'addition
448                    elseif ( strcmp( "+", $tabRestriction[$j]) == 0 ){
449                        
450                       $res[$i] =  $this->moisdate( $res[$i], $this->getRestrictionValue($tabRestriction[$j+1]) );
451                    }
452                }
453            }
454                    
455            // Effectue le test
456            if ( strcmp($comp, ">=") == 0 ){
457                
458                if ( $res[0] >= $res[1] || $res[0] == "" ){
459                    
460                    return true;
461                }
462                else {
463                    
464                    return false;
465                }
466            }
467            elseif ( strcmp($comp, "<=") == 0 ){
468    
469                if ( $res[0] <= $res[1] || $res[1] == "" ){
470    
471                    return true;
472                }
473                else {
474    
475                    return false;
476                }
477            }
478            
479            return true;
480        }
481        
482        //Retourne la valeur de valF si $restrictionValue n'est pas un chiffre, le chiffre sinon
483        function getRestrictionValue($restrictionValue){
484            
485            return ( is_numeric($restrictionValue) ) ?
486                $restrictionValue :
487                $this->valF[$restrictionValue];
488        }
489        
490      function regle($regle){      function regle($regle){
491          $temp = explode ("+",$regle);          $temp = explode ("+",$regle);
492          //echo '|'.$regle;          //echo '|'.$regle;
# Line 406  class instruction extends instruction_ge Line 551  class instruction extends instruction_ge
551                  $valF['accord_tacite']= $this->regle($row['regle_accord_tacite']);                  $valF['accord_tacite']= $this->regle($row['regle_accord_tacite']);
552              }              }
553              if($row['regle_avis']!=''){              if($row['regle_avis']!=''){
554                  $valF['avis']= $this->regle($row['regle_avis']);                  $valF['avis_decision']= $this->regle($row['regle_avis']);
555              }              }
556              if($row['regle_date_limite']!=''){              if($row['regle_date_limite']!=''){
557                  $valF['date_limite']= $this->regle($row['regle_date_limite']);                  $valF['date_limite']= $this->regle($row['regle_date_limite']);
# Line 457  class instruction extends instruction_ge Line 602  class instruction extends instruction_ge
602                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
603                  // 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
604                  // notification    [verify notification date]                  // notification    [verify notification date]
605                  if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier'])                  if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement'])
606                      $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")." ".
607                      $this->valF['archive_date_notification_delai']." < "._('datecourrier');                      $this->valF['archive_date_notification_delai']." < "._('date_evenement');
608                  //                  //
609                  break;                  break;
610              case "retour" :              case "retour" :
# Line 467  class instruction extends instruction_ge Line 612  class instruction extends instruction_ge
612                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
613                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
614                  // la date_complet est celle de l evenement                  // la date_complet est celle de l evenement
615                  $valF['date_complet']= $this->valF['datecourrier'];                  $valF['date_complet']= $this->valF['date_evenement'];
616                  $valF['date_limite'] =  $this->moisdate($valF['date_complet'],$valF['delai']);                  $valF['date_limite'] =  $this->moisdate($valF['date_complet'],$valF['delai']);
617                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
618                  break;                  break;
# Line 476  class instruction extends instruction_ge Line 621  class instruction extends instruction_ge
621                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
622                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
623                  // la date rejet est initialisee                  // la date rejet est initialisee
624                  $valF['date_rejet']= $this->valF['datecourrier'];                  $valF['date_rejet']= $this->valF['date_evenement'];
625                  // les dates de depart et fin d instruction sont annulées                  // les dates de depart et fin d instruction sont annulées
626                  $valF['date_limite'] =null;                  $valF['date_limite'] =null;
627                  $valF['date_notification_delai'] =null;                  $valF['date_notification_delai'] =null;
# Line 492  class instruction extends instruction_ge Line 637  class instruction extends instruction_ge
637                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
638                  // 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
639                  // notification                  // notification
640                  if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier'])                  if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement'])
641                      $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").
642                  $this->valF['archive_date_notification_delai']." < "._('datecourrier');                  $this->valF['archive_date_notification_delai']." < "._('date_evenement');
643                  break;                  break;
644              case "acceptation" :              case "acceptation" :
645                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
646                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
647                  $valF['avis']= $this->valF['avis'];                  $valF['avis_decision']= $this->valF['avis_decision'];
648                  // date de validite = date de l evenement + delai                  // date de validite = date de l evenement + delai
649                  $valF['date_validite'] =  $this->moisdate($this->valF['datecourrier'],$this->valF['delai']);                  $valF['date_validite'] =  $this->moisdate($this->valF['date_evenement'],$this->valF['delai']);
650                     break;                     break;
651              case "refus" :              case "refus" :
652                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
653                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
654                  $valF['avis']= $this->valF['avis'];                  $valF['avis_decision']= $this->valF['avis_decision'];
655                  break;                  break;
656              case "prolongation" :              case "prolongation" :
657                  $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']);
658                  break;                  break;
659              case "sursis" :              case "sursis" :
660                  $valF['date_limite'] =  $this->moisdate($this->valF['datecourrier'],$this->valF['delai']);                  $valF['date_limite'] =  $this->moisdate($this->valF['date_evenement'],$this->valF['delai']);
661                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
662                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
663                  $valF['avis']= $this->valF['avis'];                  $valF['avis_decision']= $this->valF['avis_decision'];
664                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
665                  $temp = $valF['date_limite'];                  $temp = $valF['date_limite'];
666                  $valF['date_validite']= $this->moisdate($temp,2);                  $valF['date_validite']= $this->moisdate($temp,2);
667                  break;                  break;
668              case "execution" :              case "execution" :
669                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
670                  $valF['date_chantier'] =  $this->valF['datecourrier'];                  $valF['date_chantier'] =  $this->valF['date_evenement'];
671                  //echo $this->msg=$this->msg.$valF['date_chantier']."";                  //echo $this->msg=$this->msg.$valF['date_chantier']."";
672                  break;                  break;
673              case "achevement" :              case "achevement" :
674                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
675                  $valF['date_achevement'] = $this->valF['datecourrier'];                  $valF['date_achevement'] = $this->valF['date_evenement'];
676                  break;                  break;
677              case "archivage" :              case "archivage" :
678                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
679                  $valF['date_conformite'] = $this->valF['datecourrier'];                  $valF['date_conformite'] = $this->valF['date_evenement'];
680                  break;                  break;
681            
682              default:              default:
# Line 551  class instruction extends instruction_ge Line 696  class instruction extends instruction_ge
696              $db->affectedRows()." "._('enregistrement').              $db->affectedRows()." "._('enregistrement').
697              " "._('mis_a_jour')."]" ;              " "._('mis_a_jour')."]" ;
698          }          }
699            // verification si envoi vers ERP est active
700            if ($this->f->getParameter('option_erp') != "") {
701                // la nature du dossier
702                $nature_dossier = substr($this->idxformulaire,0,2);
703                $dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" .
704                                            $this->valF['dossier'] . "'");
705                $evenement_libelle = $this->getFromDB(
706                        "SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" .
707                        $this->valF['evenement'] . "'");
708                if ($dossier_erp == 't') {
709                    // envoi du message en cas d'un PC qui est ERP et sur lequel un evenement
710                    // d'acceptation etait fait
711                    if ($nature_dossier ==
712                            $this->f->getParameter('erp_evenement_accepter_dossier_PC')
713                        && $this->valF['evenement'] ==
714                            $this->f->getParameter('erp_evenement_accepter_sans_reserve')) {
715                        $msgenque = new MessageEnqueuer();
716                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
717                        $msgenque->setDecision($evenement_libelle);
718                        $msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE);
719                    }
720                    if ($this->valF['evenement'] ==
721                            $this->f->getParameter('erp_evenement_refuser_dossier')) {
722                        $msgenque = new MessageEnqueuer();
723                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
724                        $msgenque->enqueueMessage($msgenque::$ERP_DECISION_CONFORMITE_EFFECTUE);                
725                    }
726                }
727            } // fin de if ($this->f->getParameter('option_erp') != "")
728        }
729        
730        
731        /**
732         * Fait une requette sql pour extraire la valeur d'un champ, et retourne
733         * cette valeur
734         * @param string $sql La requete sql a executer
735         * @return La valeur du champs cherche, sinon NULL. En cas d'erreur de la BD
736         * l'execution s'arrete.
737         */
738        function getFromDB($sql) {
739            //$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'";
740            $res = $this->db->limitquery($sql, 0, 1);
741            $this->addToLog("getDossierERPSpecification(): db->limitquery(\"".
742                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
743            // Si une erreur survient on die
744            if (database::isError($res, true)) {
745                // Appel de la methode de recuperation des erreurs
746                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'instruction');
747            }
748            // retourne la nature du dossier
749            while ($row =& $res->fetchRow()) {
750                return $row[0];
751            }
752            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
753            return NULL;
754    
755      }      }
756        
757    
758      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
759          /*          /*
760           * cette fonction apour objet de permettre de modifier la date courrier           * cette fonction a pour objet de permettre de modifier la date courrier
761          */          */
762          $valF=array();          $valF=array();
763          $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 768  class instruction extends instruction_ge
768          if (database::isError($res)) die($res->getMessage().$sql);          if (database::isError($res)) die($res->getMessage().$sql);
769          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
770              // application des regles sur le courrier + delai              // application des regles sur le courrier + delai
771              if(preg_match("/datecourrier/",$row['regle_date_limite'])){              if(preg_match("/date_evenement/",$row['regle_date_limite'])){
772                  $valF['date_limite']= $this->regle($row['regle_date_limite']);                  $valF['date_limite']= $this->regle($row['regle_date_limite']);
773              }              }
774              if(preg_match("/datecourrier/",$row['regle_date_complet'])){              if(preg_match("/date_evenement/",$row['regle_date_complet'])){
775                  $valF['date_complet']= $this->regle($row['regle_date_complet']);                  $valF['date_complet']= $this->regle($row['regle_date_complet']);
776              }              }
777              if(preg_match("/datecourrier/",$row['regle_date_notification_delai'])){              if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){
778                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);
779              }              }
780              if(preg_match("/datecourrier/",$row['regle_date_decision'])){              if(preg_match("/date_evenement/",$row['regle_date_decision'])){
781                  $valF['date_decision']= $this->regle($row['regle_date_decision']);                  $valF['date_decision']= $this->regle($row['regle_date_decision']);
782              }              }
783              if(preg_match("/datecourrier/",$row['regle_date_rejet'])){              if(preg_match("/date_evenement/",$row['regle_date_rejet'])){
784                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);
785              }              }
786              if(preg_match("/datecourrier/",$row['regle_date_validite'])){              if(preg_match("/date_evenement/",$row['regle_date_validite'])){
787                  $valF['date_validite']= $this->regle($row['regle_date_validite']);                  $valF['date_validite']= $this->regle($row['regle_date_validite']);
788              }              }
789              if(preg_match("/datecourrier/",$row['regle_date_chantier'])){              if(preg_match("/date_evenement/",$row['regle_date_chantier'])){
790                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);
791              }              }
792              if(preg_match("/datecourrier/",$row['regle_date_achevement'])){              if(preg_match("/date_evenement/",$row['regle_date_achevement'])){
793                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);
794              }              }
795              if(preg_match("/datecourrier/",$row['regle_date_conformite'])){              if(preg_match("/date_evenement/",$row['regle_date_conformite'])){
796                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);
797              }              }
798          } // while          } // while
# Line 617  class instruction extends instruction_ge Line 819  class instruction extends instruction_ge
819          $valF['accord_tacite']=$val['archive_accord_tacite'];          $valF['accord_tacite']=$val['archive_accord_tacite'];
820          $valF['etat']=$val['archive_etat'];          $valF['etat']=$val['archive_etat'];
821          if($val['archive_avis']=='')          if($val['archive_avis']=='')
822              $valF['avis']= null;              $valF['avis_decision']= null;
823          else          else
824              $valF['avis']=$val['archive_avis'];              $valF['avis_decision']=$val['archive_avis'];
825          // if= compatibilite pgsql          // if= compatibilite pgsql
826          if($val['archive_date_complet']!='')          if($val['archive_date_complet']!='')
827              $valF['date_complet']=$val['archive_date_complet'];              $valF['date_complet']=$val['archive_date_complet'];
# Line 700  class instruction extends instruction_ge Line 902  class instruction extends instruction_ge
902      return $annee."-".$mois."-".$jour ;      return $annee."-".$mois."-".$jour ;
903      }      }
904    
905        // Vérifie la restriction sur l'événement
906        function verifier($val = array(), &$db, $DEBUG){
907            parent::verifier($val, $db, $DEBUG);
908            //Récupère la restriction
909            $sql= "SELECT
910                      restriction
911                  FROM
912                      ".DB_PREFIXE."evenement
913                  WHERE
914                      evenement =".$this->valF['evenement'];
915    
916            $res = $db->query($sql);
917            $this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE);
918            $this->f->isDatabaseError();
919            
920            $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
921    
922            //Test qu'une restriction est présente
923            if ( isset($row['restriction']) && $row['restriction'] != "" ){
924                
925                //Test si la restriction est valide
926                if ( !$this->restrictionIsValid($row['restriction']) ){
927                    
928                    $this->correct=false;
929                    $this->addToMessage(_("Restriction non valide"));
930                }
931                else {
932                    
933                    $this->correct = true;
934                }
935            }
936        }
937    
938  }// fin classe  }// fin classe
939  ?>  ?>

Legend:
Removed from v.300  
changed lines
  Added in v.1227

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26