/[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 925 by fmichon, Thu Nov 29 23:28:01 2012 UTC revision 1299 by nhaye, Fri Mar 1 10:18:14 2013 UTC
# Line 30  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        // {{{ Gestion de la confidentialité des données spécifiques
34    
35        /**
36         * Surcharge pour gérer les actions disponibles dans le portlet
37         */
38        function checkAccessibility() {
39            //
40            parent::checkAccessibility();
41            // Si l'utilisateur est un intructeur qui en correspond pas à la
42            // division du dossier
43            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);
99          // controle suppression cle secondaire [secondary key delete control]          // controle suppression cle secondaire [secondary key delete control]
# Line 50  class instruction extends instruction_ge Line 114  class instruction extends instruction_ge
114            }            }
115      }      }
116    
117        // Sélectionne le signataire_arrete par défaut
118        function setVal(&$form,$maj,$validation){
119            
120            // Ajout
121            if($maj == 0) {
122                
123                // Création de la requête
124                $sql = "SELECT signataire_arrete
125                        FROM ".DB_PREFIXE."signataire_arrete
126                        WHERE defaut IS TRUE";
127                
128                // Exécution de la requête
129                $this->f->addToLog("deleteAllLienDossierInstructionTypeEvenementEvenement(): db->query(\"".$sql."\");", VERBOSE_MODE);
130                $res = $this->f->db->query($sql);
131                $this->f->isDatabaseError();
132            
133                $row = $res->fetchrow(DB_FETCHMODE_ASSOC);
134                
135                if ( isset($row['signataire_arrete']) && is_numeric($row['signataire_arrete'])){
136                    
137                    $form->setVal("signataire_arrete",$row['signataire_arrete']);
138                }
139            }
140        }
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 and $maj<2) {          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 65  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          parent::setType($form,$maj);          parent::setType($form,$maj);
161          if ($maj < 2) { //ajouter et modifier          if ($maj < 2) { //ajouter et modifier
# Line 77  class instruction extends instruction_ge Line 168  class instruction extends instruction_ge
168              $form->setType('bible2', 'httpclick');              $form->setType('bible2', 'httpclick');
169              $form->setType('dossier', 'hiddenstatic');                $form->setType('dossier', 'hiddenstatic');  
170              $form->setType('libelle', 'hiddenstatic');              $form->setType('libelle', 'hiddenstatic');
171                $form->setType('signataire_arrete','select');
172              if($maj==0){ // add              if($maj==0){ // add
173                  $form->setType('instruction', 'hiddenstatic');                  $form->setType('instruction', 'hiddenstatic');
174                  $form->setType('evenement', 'select');                  $form->setType('evenement', 'select');
175                  $form->setType('datecourrier', 'date2');                  $form->setType('date_evenement', 'date2');
176              }else{ // modify              }else{ // modify
177                  $form->setType('instruction', 'hiddenstatic');                  $form->setType('instruction', 'hiddenstatic');
178                  $form->setType('evenement', 'hiddenstatic');                  $form->setType('evenement', 'hiddenstatic');
179                  //$form->setType('datecourrier', 'hiddenstaticdate');                  //$form->setType('date_evenement', 'hiddenstaticdate');
180                  $form->setType('datecourrier', 'date2');                  $form->setType('date_evenement', 'date2');
181                  // necessaire pour calcul de date en modification                  // necessaire pour calcul de date en modification
182                  $form->setType('delai', 'hiddenstatic');                  $form->setType('delai', 'hiddenstatic');
183              }              }
184          } elseif($maj==2){          } elseif($maj==2){
185              $form->setType('dossier', 'hiddenstatic');              $form->setType('dossier', 'hiddenstatic');
186                $form->setType('bible_auto', 'hidden');
187                $form->setType('bible', 'hidden');
188                $form->setType('bible2', 'hidden');
189          }else {          }else {
190              $form->setType('destinataire', 'hidden');              $form->setType('destinataire', 'hidden');
191              $form->setType('dossier', 'static');              $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');
         $form->setType('bible_auto', 'hidden');  
         $form->setType('bible', 'hidden');  
         $form->setType('bible2', 'hidden');  
197          $form->setType('bible3', 'hidden');          $form->setType('bible3', 'hidden');
198          $form->setType('complement4', 'hidden');          $form->setType('complement4', 'hidden');
199          $form->setType('bible4', 'hidden');          $form->setType('bible4', 'hidden');
# Line 145  class instruction extends instruction_ge Line 240  class instruction extends instruction_ge
240          $form->setType('archive_date_chantier', 'hidden');            $form->setType('archive_date_chantier', 'hidden');  
241      }      }
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.php"))          if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
246              include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");              include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
247    
248            parent::setSelect($form, $maj, $db, $DEBUG);
249    
250          // *** evenement ***          // *** evenement ***
251          $contenu=array();          $contenu=array();
252          // etat du dossier          // etat du dossier
253          $sql="select etat from ".DB_PREFIXE."dossier where dossier ='".          $sql="select etat from ".DB_PREFIXE."dossier where dossier ='".
254                $this->idxformulaire."'";                $this->idxformulaire."'";
255          $etat_dossier = $db->getOne($sql);          $etat_dossier = $db->getOne($sql);
256          $nature_dossier= substr($this->idxformulaire,0,2);          // nature du dossier d'autorisation
257            $sql="select code from ".DB_PREFIXE."dossier
258                INNER JOIN ".DB_PREFIXE."dossier_autorisation ON
259                    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                    dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
263                WHERE dossier ='".
264                  $this->idxformulaire."'";
265            $nature_dossier = $db->getOne($sql);
266    
267          // recherche des evenement de transition          // recherche des evenement de transition
268          $sql= $sql_transition." where transition.etat ='".$etat_dossier."' and (evenement.nature ='".          // XXX modifier la requète après la modification de structure du workflow
269                $nature_dossier."' or (nature ='T' and nature !='CU')) order by evenement.action";          $sql= $sql_transition." where transition.etat ='".$etat_dossier."' and dossier='".
270                  $this->idxformulaire."' order by evenement.action";
271                    
272          // *** attention en dur le CU          // *** attention en dur le CU
273                    $this->addToLog("setSelect(): db->query(\"".$sql."\");", VERBOSE_MODE);
274    
275          $res = $db->query($sql);          $res = $db->query($sql);
276          if (database::isError($res))          if (database::isError($res))
# Line 199  class instruction extends instruction_ge Line 308  class instruction extends instruction_ge
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 215  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 222  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 "));
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                
354              if(isset($row['action']) and !empty($row['action'])) {              if(isset($row['action']) and !empty($row['action'])) {
355                  $this->valF['action']=$row['action'];                  $this->valF['action']=$row['action'];
356              } else {              } else {
# Line 259  class instruction extends instruction_ge Line 373  class instruction extends instruction_ge
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 296  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 345  class instruction extends instruction_ge Line 536  class instruction extends instruction_ge
536          // voir parametrage des actions en dur          // voir parametrage des actions en dur
537          $param=1;          $param=1;
538          if($param==1){          if($param==1){
539          $sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'";              $sql="select * from ".DB_PREFIXE."action where action = '".$this->valF['action']."'";
540          $res = $db->query($sql);              $res = $db->query($sql);
541          if (database::isError($res))              if (database::isError($res))
542              die($res->getMessage());                  die($res->getMessage());
543          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
544              if($row['regle_etat']!=''){                  if($row['regle_etat']!=''){
545                  $valF['etat']= $this->regle($row['regle_etat']);                      $valF['etat']= $this->regle($row['regle_etat']);
546              }                  }
547              if($row['regle_delai']!=''){                  if($row['regle_delai']!=''){
548                  $valF['delai']= $this->regle($row['regle_delai']);                      $valF['delai']= $this->regle($row['regle_delai']);
549              }                  }
550              if($row['regle_accord_tacite']!=''){                  if($row['regle_accord_tacite']!=''){
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_decision']= $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']);
558              }                  }
559              if($row['regle_date_complet']!=''){                  if($row['regle_date_complet']!=''){
560                  $valF['date_complet']= $this->regle($row['regle_date_complet']);                      $valF['date_complet']= $this->regle($row['regle_date_complet']);
561              }                  }
562              if($row['regle_date_notification_delai']!=''){                  if($row['regle_date_notification_delai']!=''){
563                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);                      $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);
564              }                  }
565              if($row['regle_date_decision']!=''){                  if($row['regle_date_decision']!=''){
566                  $valF['date_decision']= $this->regle($row['regle_date_decision']);                      $valF['date_decision']= $this->regle($row['regle_date_decision']);
567              }                  }
568              if($row['regle_date_rejet']!=''){                  if($row['regle_date_rejet']!=''){
569                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);                      $valF['date_rejet']= $this->regle($row['regle_date_rejet']);
570              }                  }
571             if($row['regle_date_validite']!=''){                 if($row['regle_date_validite']!=''){
572                  $valF['date_validite']= $this->regle($row['regle_date_validite']);                      $valF['date_validite']= $this->regle($row['regle_date_validite']);
573              }                  }
574             if($row['regle_date_chantier']!=''){                 if($row['regle_date_chantier']!=''){
575                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);                      $valF['date_chantier']= $this->regle($row['regle_date_chantier']);
576              }                  }
577             if($row['regle_date_achevement']!=''){                 if($row['regle_date_achevement']!=''){
578                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);                      $valF['date_achevement']= $this->regle($row['regle_date_achevement']);
579              }                  }
580             if($row['regle_date_conformite']!=''){                 if($row['regle_date_conformite']!=''){
581                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                      $valF['date_conformite']= $this->regle($row['regle_date_conformite']);
582                    }
583                  
584                   // Appel des méthode stockées dans le champ methode_trigger
585                   if($row['methode_trigger'] != "") {
586                       foreach (explode(";", $row['methode_trigger']) as $methode) {
587                           if(method_exists($this, $methode)) {
588                               $this->$methode();
589                           }
590                          
591                       }
592                   }
593              }              }
         }  
594          }else{          }else{
595              switch ($this->valF['action']) {              switch ($this->valF['action']) {
596              case "initialisation" :              case "initialisation" :
# Line 411  class instruction extends instruction_ge Line 612  class instruction extends instruction_ge
612                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
613                  // 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
614                  // notification    [verify notification date]                  // notification    [verify notification date]
615                  if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier'])                  if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement'])
616                      $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")." ".
617                      $this->valF['archive_date_notification_delai']." < "._('datecourrier');                      $this->valF['archive_date_notification_delai']." < "._('date_evenement');
618                  //                  //
619                  break;                  break;
620              case "retour" :              case "retour" :
# Line 421  class instruction extends instruction_ge Line 622  class instruction extends instruction_ge
622                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
623                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
624                  // la date_complet est celle de l evenement                  // la date_complet est celle de l evenement
625                  $valF['date_complet']= $this->valF['datecourrier'];                  $valF['date_complet']= $this->valF['date_evenement'];
626                  $valF['date_limite'] =  $this->moisdate($valF['date_complet'],$valF['delai']);                  $valF['date_limite'] =  $this->moisdate($valF['date_complet'],$valF['delai']);
627                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
628                  break;                  break;
# Line 430  class instruction extends instruction_ge Line 631  class instruction extends instruction_ge
631                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
632                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
633                  // la date rejet est initialisee                  // la date rejet est initialisee
634                  $valF['date_rejet']= $this->valF['datecourrier'];                  $valF['date_rejet']= $this->valF['date_evenement'];
635                  // les dates de depart et fin d instruction sont annulées                  // les dates de depart et fin d instruction sont annulées
636                  $valF['date_limite'] =null;                  $valF['date_limite'] =null;
637                  $valF['date_notification_delai'] =null;                  $valF['date_notification_delai'] =null;
# Line 446  class instruction extends instruction_ge Line 647  class instruction extends instruction_ge
647                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);                  $valF['date_notification_delai'] =  $this->moisdate($valF['date_complet'],1);
648                  // 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
649                  // notification                  // notification
650                  if($this->valF['archive_date_notification_delai']<$this->valF['datecourrier'])                  if($this->valF['archive_date_notification_delai']<$this->valF['date_evenement'])
651                      $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").
652                  $this->valF['archive_date_notification_delai']." < "._('datecourrier');                  $this->valF['archive_date_notification_delai']." < "._('date_evenement');
653                  break;                  break;
654              case "acceptation" :              case "acceptation" :
655                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
656                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
657                  $valF['avis_decision']= $this->valF['avis_decision'];                  $valF['avis_decision']= $this->valF['avis_decision'];
658                  // date de validite = date de l evenement + delai                  // date de validite = date de l evenement + delai
659                  $valF['date_validite'] =  $this->moisdate($this->valF['datecourrier'],$this->valF['delai']);                  $valF['date_validite'] =  $this->moisdate($this->valF['date_evenement'],$this->valF['delai']);
660                     break;                     break;
661              case "refus" :              case "refus" :
662                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
663                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
664                  $valF['avis_decision']= $this->valF['avis_decision'];                  $valF['avis_decision']= $this->valF['avis_decision'];
665                  break;                  break;
666              case "prolongation" :              case "prolongation" :
667                  $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']);
668                  break;                  break;
669              case "sursis" :              case "sursis" :
670                  $valF['date_limite'] =  $this->moisdate($this->valF['datecourrier'],$this->valF['delai']);                  $valF['date_limite'] =  $this->moisdate($this->valF['date_evenement'],$this->valF['delai']);
671                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
672                  $valF['accord_tacite']= $this->valF['accord_tacite'];                  $valF['accord_tacite']= $this->valF['accord_tacite'];
673                  $valF['avis_decision']= $this->valF['avis_decision'];                  $valF['avis_decision']= $this->valF['avis_decision'];
674                  $valF['date_decision']= $this->valF['datecourrier'];                  $valF['date_decision']= $this->valF['date_evenement'];
675                  $temp = $valF['date_limite'];                  $temp = $valF['date_limite'];
676                  $valF['date_validite']= $this->moisdate($temp,2);                  $valF['date_validite']= $this->moisdate($temp,2);
677                  break;                  break;
678              case "execution" :              case "execution" :
679                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
680                  $valF['date_chantier'] =  $this->valF['datecourrier'];                  $valF['date_chantier'] =  $this->valF['date_evenement'];
681                  //echo $this->msg=$this->msg.$valF['date_chantier']."";                  //echo $this->msg=$this->msg.$valF['date_chantier']."";
682                  break;                  break;
683              case "achevement" :              case "achevement" :
684                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
685                  $valF['date_achevement'] = $this->valF['datecourrier'];                  $valF['date_achevement'] = $this->valF['date_evenement'];
686                  break;                  break;
687              case "archivage" :              case "archivage" :
688                  $valF['etat']= $this->valF['etat'];                  $valF['etat']= $this->valF['etat'];
689                  $valF['date_conformite'] = $this->valF['datecourrier'];                  $valF['date_conformite'] = $this->valF['date_evenement'];
690                  break;                  break;
691            
692              default:              default:
# Line 505  class instruction extends instruction_ge Line 706  class instruction extends instruction_ge
706              $db->affectedRows()." "._('enregistrement').              $db->affectedRows()." "._('enregistrement').
707              " "._('mis_a_jour')."]" ;              " "._('mis_a_jour')."]" ;
708          }          }
709          // la nature du dossier          // verification si envoi vers ERP est active
710          $nature_dossier = substr($this->idxformulaire,0,2);          if ($this->f->getParameter('option_erp') != "") {
711          $dossier_erp = $this->getFromDB("SELECT erp FROM dossier WHERE dossier = '" .              // la nature du dossier
712                                      $this->valF['dossier'] . "'");              $nature_dossier = substr($this->idxformulaire,0,2);
713          $evenement_libelle = $this->getFromDB(              $dossier_erp = $this->getFromDB("SELECT erp FROM ".DB_PREFIXE."dossier WHERE dossier = '" .
714                  "SELECT libelle FROM evenement WHERE evenement = '" .                                          $this->valF['dossier'] . "'");
715                  $this->valF['evenement'] . "'");              $evenement_libelle = $this->getFromDB(
716          // envoi du message en cas d'un PC qui est ERP et sur lequel un evenement                      "SELECT libelle FROM ".DB_PREFIXE."evenement WHERE evenement = '" .
717          // d'acceptation etait fait                      $this->valF['evenement'] . "'");
718          if ($dossier_erp == 't' && $nature_dossier ==              if ($dossier_erp == 't') {
719                  $this->f->getParameter('erp_evenement_accepter_dossier_PC')                  // envoi du message en cas d'un PC qui est ERP et sur lequel un evenement
720              && $this->valF['evenement'] ==                  // d'acceptation etait fait
721                  $this->f->getParameter('erp_evenement_accepter_sans_reserve')) {                  if ($nature_dossier ==
722              $msgenque = new MessageEnqueuer();                          $this->f->getParameter('erp_evenement_accepter_dossier_PC')
723              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                      && $this->valF['evenement'] ==
724              $msgenque->setDecision($evenement_libelle);                          $this->f->getParameter('erp_evenement_accepter_sans_reserve')) {
725              $msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE);                      $msgenque = new MessageEnqueuer();
726          }                              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
727                        $msgenque->setDecision($evenement_libelle);
728                        $msgenque->enqueueMessage($msgenque::$ERP_ARRETE_PC_EFFECTUE);
729                    }
730                    if ($this->valF['evenement'] ==
731                            $this->f->getParameter('erp_evenement_refuser_dossier')) {
732                        $msgenque = new MessageEnqueuer();
733                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
734                        $msgenque->enqueueMessage($msgenque::$ERP_DECISION_CONFORMITE_EFFECTUE);                
735                    }
736                }
737            } // fin de if ($this->f->getParameter('option_erp') != "")
738      }      }
739            
740            
# Line 534  class instruction extends instruction_ge Line 746  class instruction extends instruction_ge
746       * l'execution s'arrete.       * l'execution s'arrete.
747       */       */
748      function getFromDB($sql) {      function getFromDB($sql) {
749          //$sql = "SELECT libelle FROM dossier WHERE dossier = '" . $dossier . "'";          //$sql = "SELECT libelle FROM ".DB_PREFIXE."dossier WHERE dossier = '" . $dossier . "'";
750          $res = $this->db->limitquery($sql, 0, 1);          $res = $this->db->limitquery($sql, 0, 1);
751          $this->addToLog("getDossierERPSpecification(): db->limitquery(\"".          $this->addToLog("getDossierERPSpecification(): db->limitquery(\"".
752                          str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);                          str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
# Line 555  class instruction extends instruction_ge Line 767  class instruction extends instruction_ge
767    
768      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
769          /*          /*
770           * cette fonction apour objet de permettre de modifier la date courrier           * cette fonction a pour objet de permettre de modifier la date courrier
771          */          */
772          $valF=array();          $valF=array();
773          $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 778  class instruction extends instruction_ge
778          if (database::isError($res)) die($res->getMessage().$sql);          if (database::isError($res)) die($res->getMessage().$sql);
779          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){          while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
780              // application des regles sur le courrier + delai              // application des regles sur le courrier + delai
781              if(preg_match("/datecourrier/",$row['regle_date_limite'])){              if(preg_match("/date_evenement/",$row['regle_date_limite'])){
782                  $valF['date_limite']= $this->regle($row['regle_date_limite']);                  $valF['date_limite']= $this->regle($row['regle_date_limite']);
783              }              }
784              if(preg_match("/datecourrier/",$row['regle_date_complet'])){              if(preg_match("/date_evenement/",$row['regle_date_complet'])){
785                  $valF['date_complet']= $this->regle($row['regle_date_complet']);                  $valF['date_complet']= $this->regle($row['regle_date_complet']);
786              }              }
787              if(preg_match("/datecourrier/",$row['regle_date_notification_delai'])){              if(preg_match("/date_evenement/",$row['regle_date_notification_delai'])){
788                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);                  $valF['date_notification_delai']= $this->regle($row['regle_date_notification_delai']);
789              }              }
790              if(preg_match("/datecourrier/",$row['regle_date_decision'])){              if(preg_match("/date_evenement/",$row['regle_date_decision'])){
791                  $valF['date_decision']= $this->regle($row['regle_date_decision']);                  $valF['date_decision']= $this->regle($row['regle_date_decision']);
792              }              }
793              if(preg_match("/datecourrier/",$row['regle_date_rejet'])){              if(preg_match("/date_evenement/",$row['regle_date_rejet'])){
794                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);                  $valF['date_rejet']= $this->regle($row['regle_date_rejet']);
795              }              }
796              if(preg_match("/datecourrier/",$row['regle_date_validite'])){              if(preg_match("/date_evenement/",$row['regle_date_validite'])){
797                  $valF['date_validite']= $this->regle($row['regle_date_validite']);                  $valF['date_validite']= $this->regle($row['regle_date_validite']);
798              }              }
799              if(preg_match("/datecourrier/",$row['regle_date_chantier'])){              if(preg_match("/date_evenement/",$row['regle_date_chantier'])){
800                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);                  $valF['date_chantier']= $this->regle($row['regle_date_chantier']);
801              }              }
802              if(preg_match("/datecourrier/",$row['regle_date_achevement'])){              if(preg_match("/date_evenement/",$row['regle_date_achevement'])){
803                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);                  $valF['date_achevement']= $this->regle($row['regle_date_achevement']);
804              }              }
805              if(preg_match("/datecourrier/",$row['regle_date_conformite'])){              if(preg_match("/date_evenement/",$row['regle_date_conformite'])){
806                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);                  $valF['date_conformite']= $this->regle($row['regle_date_conformite']);
807              }              }
808          } // while          } // while
# Line 606  class instruction extends instruction_ge Line 818  class instruction extends instruction_ge
818              $db->affectedRows()." "._('enregistrement').              $db->affectedRows()." "._('enregistrement').
819              " "._('mis_a_jour')."]" ;              " "._('mis_a_jour')."]" ;
820          }          }
821    
822            // Envoi des infos au
823            if ($this->valF['date_retour_signature'] != $this->getVal('date_retour_signature')) {
824                $msgenque = new MessageEnqueuer();
825                $sqlArrete = "SELECT instruction.signataire_arrete as \"ws_DA_In_Signataire\",
826                                    signataire_arrete.nom as \"ws_DA_In_Sign_Nom\",
827                                    signataire_arrete.prenom as \"ws_DA_In_Sign_Prenom\",
828                                    signataire_arrete.qualite as \"ws_DA_In_Sign_Qualite\",
829                                    instruction.date_evenement as \"ws_DA_In_Dte_Redac\",
830                                    '' as \"ws_DA_In_lieu_Redac\",
831                                    instruction.dossier as \"ws_DA_In_N_Doss_DAS\",
832                                    '' as \"ws_DA_In_Sigle\",
833                                    instruction.etat as \"ws_DA_In_Decision\",
834                                    dossier.date_depot as \"ws_DA_In_Dte_Depot_Dem\",
835                                    dossier.terrain_numero as \"ws_DA_In_N_Voie\",
836                                    '' as \"ws_DA_In_Type_Voie\",
837                                    dossier.complement as \"ws_DA_In_Adresse1\",
838                                    dossier.terrain_adresse_lieu_dit as \"ws_DA_In_Adresse2\",
839                                    dossier.terrain_adresse_code_postal as \"ws_DA_In_CP\",
840                                    dossier.terrain_adresse_localite as \"ws_DA_In_Ville\",
841                                    dossier.terrain_references_cadastrales as \"ws_DA_In_Nb_Parcelle\",
842                                    '' as \"ws_DA_In_Detail_Parcelle\",
843                                    travaux.libelle as \"ws_DA_In_Nature_Trvx\",
844                                    '' as \"ws_DA_In_Destination_Trvx\",
845                                    dossier_autorisation_type_detaille.code as \"ws_DA_In_Type_Dos_Autoris\",
846                                    COALESCE(particulier_nom,personne_morale_raison_sociale) as \"ws_DA_In_Nom_Petition\",
847                                    COALESCE(particulier_prenom, personne_morale_denomination) as \"ws_DA_In_Prenom_Petition\",
848                                    '' as \"ws_DA_In_Piece_GED\",
849                                    instruction.date_retour_signature as \"ws_DA_In_Dte_Signature\"
850                            FROM ".DB_PREFIXE."instruction
851                            JOIN ".DB_PREFIXE."signataire_arrete ON
852                                instruction.signataire_arrete = signataire_arrete.signataire_arrete
853                            JOIN ".DB_PREFIXE."dossier ON
854                                instruction.dossier = dossier.dossier
855                            JOIN ".DB_PREFIXE."lien_dossier_demandeur ON
856                                lien_dossier_demandeur.dossier = dossier.dossier
857                            JOIN ".DB_PREFIXE."demandeur ON
858                                lien_dossier_demandeur.demandeur = demandeur.demandeur
859                            JOIN ".DB_PREFIXE."dossier_instruction_type ON
860                                dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type
861                            JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille ON
862                                dossier_instruction_type.dossier_autorisation_type_detaille =
863                                    dossier_autorisation_type_detaille.dossier_autorisation_type_detaille
864                            LEFT JOIN ".DB_PREFIXE."travaux ON
865                                dossier.travaux = travaux.travaux
866                            WHERE instruction.instruction = ".$this->valF['instruction'];
867                $resArrete = $this->db->query($sqlArrete);
868                $this->f->addToLog("triggerModifierApres(): db->query(\"".$sqlArrete."\");", VERBOSE_MODE);
869                $this->f->isDatabaseError();
870    
871                $rowArrete = $resArrete->fetchRow(DB_FETCHMODE_ASSOC);
872                $msgenque->setArreteInfo($rowArrete);
873                $msgenque->enqueueMessage($msgenque::$ARRETE_ENVOI);                
874            }
875      }      }
876    
877    
# Line 700  class instruction extends instruction_ge Line 966  class instruction extends instruction_ge
966      return $annee."-".$mois."-".$jour ;      return $annee."-".$mois."-".$jour ;
967      }      }
968    
969        // Vérifie la restriction sur l'événement
970        function verifier($val = array(), &$db, $DEBUG){
971            parent::verifier($val, $db, $DEBUG);
972            //Récupère la restriction
973            $sql= "SELECT
974                      restriction
975                  FROM
976                      ".DB_PREFIXE."evenement
977                  WHERE
978                      evenement =".$this->valF['evenement'];
979    
980            $res = $db->query($sql);
981            $this->f->addToLog("verifier(): db->query(\"".$sql."\");", VERBOSE_MODE);
982            $this->f->isDatabaseError();
983            
984            $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
985    
986            //Test qu'une restriction est présente
987            if ( isset($row['restriction']) && $row['restriction'] != "" ){
988                
989                //Test si la restriction est valide
990                if ( !$this->restrictionIsValid($row['restriction']) ){
991                    
992                    $this->correct=false;
993                    $this->addToMessage(_("Restriction non valide"));
994                }
995                else {
996                    
997                    $this->correct = true;
998                }
999            }
1000        }
1001        
1002        /**
1003         * Méthode permettant de mettre à jour l'état d'un DA
1004         */
1005        function majEtatDA() {
1006            if($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 8) {
1007                $val['etat_dossier_autorisation']=5;
1008            } elseif($this->valF['action'] == 'accepter' AND $this->valF['avis_decision'] == 15) {
1009                $val['etat_dossier_autorisation']=3;
1010            } elseif($this->valF['action'] == 'accepter') {
1011                $val['etat_dossier_autorisation']=2;
1012            } elseif($this->valF['action'] == 'rejeter') {
1013                $val['etat_dossier_autorisation']=4;
1014            } elseif($this->valF['action'] == 'terminer') {
1015                $val['etat_dossier_autorisation']=8;
1016            } elseif($this->valF['action'] == 'majorer') {
1017                $val['etat_dossier_autorisation']=6;
1018            } else {
1019                $val['etat_dossier_autorisation']=7;
1020            }
1021            
1022            //Récupération du numéro de dossier d'autorisation lié au dossier d'instruction
1023            $IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']);
1024          
1025            // Mis à jour de l'état du dossier d'autorisation
1026            require_once '../obj/dossier_autorisation.class.php';
1027            $dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG);
1028            
1029            $dossier_autorisation->val[array_search("etat_dossier_autorisation", $dossier_autorisation->champs)] = $val['etat_dossier_autorisation'];
1030            
1031            //Récupération des données
1032            $valDossierAutorisation = array();
1033            for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){
1034                
1035                $valDossierAutorisation[$dossier_autorisation->champs[$i]]=
1036                    $dossier_autorisation->val[$i];
1037            }
1038    
1039            $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);
1040        }
1041        
1042       /**
1043        * Méthode permettant de mettre à jour les données d'un DA
1044        */
1045        function majDataDA() {
1046            
1047            //Récupération du numéro de dossier d'autorisation lié au dossier d'instruction
1048            $IDdossier_autorisation = $this->getDossierAutorisation($this->valF['dossier']);
1049            require_once '../obj/dossier_autorisation.class.php';
1050            $dossier_autorisation = new dossier_autorisation($IDdossier_autorisation,$this->db,DEBUG);
1051            
1052            require_once '../obj/dossier.class.php';
1053            $dossier = new dossier($this->valF['dossier'],$this->db,DEBUG);
1054            
1055            //Récupération des données
1056            $valDossierAutorisation = array();
1057            for ( $i=0 ; $i<count($dossier_autorisation->champs); $i++){
1058                
1059                if ( array_search($dossier_autorisation->champs[$i], $dossier->champs) ){
1060                    
1061                    $valDossierAutorisation[$dossier_autorisation->champs[$i]]=$dossier->getVal($dossier_autorisation->champs[$i]);
1062                }
1063                else {
1064                    $valDossierAutorisation[$dossier_autorisation->champs[$i]]=
1065                    $dossier_autorisation->val[$i];
1066                }
1067            }
1068    
1069            $dossier_autorisation->modifier($valDossierAutorisation, $this->db, DEBUG);
1070            
1071            // Suppression du liens entre les lots et le DA
1072            $valLot['dossier_autorisation'] = NULL;
1073            $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "dossier_autorisation='".$IDdossier_autorisation."'");
1074            
1075            // Liaison des lots du DI avec le DA
1076            $sqlLot = "SELECT lot FROM ".DB_PREFIXE."lien_dossier_lot WHERE dossier='".$this->valF['dossier']."'";
1077            $res = $this->db->query($sqlLot);
1078            $this->addToLog($sqlLot);
1079            $this->f->isDatabaseError();
1080            while($rowLot = $res->fetchRow(DB_FETCHMODE_ASSOC)) {
1081                $valLot['dossier_autorisation'] = $IDdossier_autorisation;
1082                $this->db->autoExecute(DB_PREFIXE."lot", $valLot, DB_AUTOQUERY_UPDATE, "lot=".$rowLot['lot']);
1083            }
1084        }
1085        
1086        // Récupération de l'identifiant du dossier d'autorisation lié au dossier d'instruction
1087        function getDossierAutorisation($dossier_instruction){
1088            
1089            $sql = "SELECT
1090                        dossier_autorisation.dossier_autorisation
1091                    FROM
1092                        ".DB_PREFIXE."dossier_autorisation
1093                    LEFT JOIN
1094                        ".DB_PREFIXE."dossier
1095                        ON
1096                            dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation
1097                    WHERE
1098                        dossier.dossier = '".$dossier_instruction."'";
1099          
1100            $IDdossier_autorisation = $this->db->getOne($sql);
1101            $this->addToLog("getDossierAutorisation(): db->getone(\"".$sql."\")", VERBOSE_MODE);
1102            database::isError($IDdossier_autorisation);
1103            
1104            return $IDdossier_autorisation;
1105        }
1106  }// fin classe  }// fin classe
1107  ?>  ?>

Legend:
Removed from v.925  
changed lines
  Added in v.1299

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26