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

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

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

revision 44 by fraynaud, Mon Jul 25 16:06:39 2011 UTC revision 1187 by nhaye, Wed Jan 9 11:58:51 2013 UTC
# Line 1  Line 1 
1  <?php  <?php
2  //$Id$  //$Id$
3  //gen openMairie le 10/02/2011 20:39  //gen openMairie le 10/02/2011 20:39
4    
5  require_once ("../gen/obj/dossier.class.php");  require_once ("../gen/obj/dossier.class.php");
6  //require_once ("../sig/strategyDynmap.class.php"); //specific  require_once("../services/outgoing/messageenqueuer.php");
7    
8  class dossier extends dossier_gen {  class dossier extends dossier_gen {
9    
10      var $maj;      var $maj;
11        var $sig;
12        var $servitude="";
13        var $auto_pos;
14        var $auto_servitude_surfacique;
15        var $auto_servitude_ligne;
16        var $auto_servitude_point;
17        var $auto_parcelle;
18        var $auto_parcelle_lot;
19        var $aff_depot = "collapsible";
20        var $aff_travaux = "collapsible";
21        var $aff_instruction = "collapsible";
22        var $aff_demandeur = "startClosed";
23        var $aff_delegataire = "startClosed";
24        var $aff_terrain = "startClosed";
25        var $aff_localisation = "collapsible";
26        var $aff_description = "startClosed";
27        var $aff_amenagement = "startClosed";
28        var $dossier_instruction_type;
29    
30        function dossier($id,&$db,$DEBUG) {
31            $this->constructeur($id,$db,$DEBUG);
32        } // fin constructeur
33        
34        /*Mutateur pour ma variable dossier_instruction_type*/
35        public function getDossierInstructionType(){
36            return $this->dossier_instruction_type;
37        }
38        public function setDossierInstructionType($dossier_instruction_type){
39            $this->dossier_instruction_type = $dossier_instruction_type;
40        }
41        
42        // {{{ Gestion de la confidentialité des données spécifiques
43    
44      function setvalF($val){      /**
45          parent::setvalF($val);       * Surcharge pour gérer les actions disponibles dans le portlet
46         */
47        function checkAccessibility() {
48            //
49            parent::checkAccessibility();
50            // Si l'utilisateur est un intructeur qui en correspond pas à la
51            // division du dossier
52            if ($this->f->isUserInstructeur()
53                && isset($this->f->om_utilisateur["division"])
54                && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) {
55                //
56                $this->actions_sup = array();
57                $this->setParameter("actions", array());
58            }
59                    
60          // cles secondaires numerique (contrainte integrite  pgsql)          /*
61          if(!is_numeric($val['instructeur'])) $this->valF['instructeur']= null;           * Si une action 'rapport_instruction' est présente et
62          if(!is_numeric($val['architecte'])) $this->valF['architecte']= null;           * que le le rapport d'instruction existe déjà, lien vers l'objet en modification
63          if(!is_numeric($val['travaux'])) $this->valF['travaux']= null;           * sinon, lien vers un script qui va créer le nouvel objet et
64          if(!is_numeric($val['demandeur_categorie'])) $this->valF['demandeur_categorie']= null;           * rediriger l'utilisateur vers l'objet en modification.
65                     */
66          // cle secondaire alpha vide (contrainte integrite pgsql)          
67          if($val['demandeur_civilite']=='') $this->valF['demandeur_civilite']= null;          // Vérifie si  un rapport d'instruction existe déjà
68          if($val['delegataire_civilite']=='') $this->valF['delegataire_civilite']= null;          if ( isset($this->actions_sup["rapport_instruction"]) ) {
69                        
70          // zone numerique non valorisée a 0              // Requête de vérification
71          if(!is_numeric($val['delai'])) unset ($this->valF['delai']);              $sql = "SELECT
72          if(!is_numeric($val['terrain_surface'])) unset ($this->valF['terrain_surface']);                      rapport_instruction
73          if(!is_numeric($val['batiment_nombre'])) unset ($this->valF['batiment_nombre']);                  FROM
74          if(!is_numeric($val['logement_nombre'])) unset ($this->valF['logement_nombre']);                      ".DB_PREFIXE."rapport_instruction
75          if(!is_numeric($val['shon'])) unset ($this->valF['shon']);                  WHERE
76          if(!is_numeric($val['shob'])) unset ($this->valF['shob']);                      dossier_instruction = '".$this->getParameter('idx')."'";
77          if(!is_numeric($val['lot'])) unset ($this->valF['lot']);              
78          if(!is_numeric($val['hauteur'])) unset ($this->valF['hauteur']);              // Ajout au log
79          if(!is_numeric($val['piece_nombre'])) unset ($this->valF['piece_nombre']);              $this->f->addToLog("checkAccessibility(): db->query(\"".$sql."\");", VERBOSE_MODE);
80                
81                // Exécution de la requête  
82                $res=$this->f->db->query($sql);
83                $this->f->isDatabaseError($res);
84    
85                /*
86                 * S'il n'y a pas de rapport d'instruction, redirection vers un script
87                 * de création, puis vers l'objet.
88                 * */
89                if ( $res->numrows() == 0 ){
90                    
91                    $this->actions_sup["rapport_instruction"]["lien"] =
92                        '../app/rapport_instruction.php?idx=';
93                }
94                // S'il a déjà été créé, lien vers l'objet en modification
95                elseif ( $res->numrows() > 0 ){
96                    
97                    $row = & $res->fetchRow(DB_FETCHMODE_ASSOC);
98                    $this->actions_sup["rapport_instruction"]["lien"] =
99                        '../scr/form.php?obj=rapport_instruction&amp;action=1&amp;idx='.
100                        $row['rapport_instruction'].'&amp;idD=';
101                }
102                
103            }
104        }
105    
106        /**
107         * Cette methode est à surcharger elle permet de tester dans chaque classe
108         * des droits des droits spécifiques en fonction des données
109         */
110        function canAccess() {
111            // Si l'utilisateur est un intructeur qui ne correspond pas à la
112            // division du dossier
113            if ($this->f->isUserInstructeur()
114                && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()
115                && $this->getParameter("maj") != 3) {
116                //
117                return false;
118            }
119            //
120            return true;
121        }
122    
123         // enlever les valeurs a ne pas saisir -> recherche en trigger ajouter et modifier      /**
124         // $sig = 1       * Cette méthode permet de récupérer la division d'un dossier
125          unset ($this->valF['geom']);       */
126        function getDivisionFromDossier() {
127            //
128            if (!isset($this->val[array_search("dossier", $this->champs)])) {
129                return NULL;
130            }
131            //
132            $sql = "select division from ".DB_PREFIXE."dossier ";
133            $sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'";
134            //
135            $division = $this->db->getOne($sql);
136            $this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE);
137            database::isError($division);
138            //
139            return $division;
140        }
141    
142        // }}}
143        /*
144         * Ajoute un numéro au dossier
145         *
146         */
147        function setValFAjout($val = array()) {
148            
149            /*Récupération de la lettre associé au type de dossier d'instruction*/
150            $code = $this->getCode($this->getDossierInstructionType());
151            
152            /* Récupération de la valeur du suffixe ce dossier_instruction_type */
153            $suffixe = $this->getSuffixe($this->getDossierInstructionType());
154            
155            /*S'il est à TRUE, on récupère le numéro de version du dossier d'autorisation*/
156            $numeroVersion = "";
157            if ( $suffixe == 't' ){
158                
159                $numeroVersion = $this->getNumeroVersion($val['dossier_autorisation']);
160                
161                /* Incrémentation du numéro de version */
162                if ( is_numeric($numeroVersion) or $numeroVersion == -1 ){
163                    
164                    $this->incrementNumeroVersion($val['dossier_autorisation'], ++$numeroVersion);
165                }
166            }
167            
168            /*Création du numéro de dossier*/
169            $this->valF['dossier'] = $val['dossier_autorisation']."$code$numeroVersion";
170        }
171    
172        /*Récupère la valeur du suffixe d'un dossier_instruction_type*/
173        function getSuffixe($dossierInstructionType){
174            
175            $suffixe = "";
176            
177            $sql = "SELECT
178                        suffixe
179                    FROM
180                        ".DB_PREFIXE."dossier_instruction_type
181                    WHERE
182                        dossier_instruction_type = $dossierInstructionType";
183                        
184            $this->addToLog("getSuffixe(): db->query(\"".$sql."\")", VERBOSE_MODE);
185            $res = $this->db->query($sql);
186            if (database :: isError($res))
187                die($res->getMessage()."erreur ".$sql);
188                
189            if ( $res->numRows() > 0 ){
190                
191                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
192                $suffixe =  $row['suffixe'];
193            }
194            
195            return $suffixe;
196        }
197        
198        /*Récupère dans la table de paramètrage la lettre correspondant
199         * au dossier_instruction_type
200         */
201        function getCode($dossierInstructionType){
202            
203            $code = "";
204            
205            $sql = "SELECT
206                        code
207                    FROM
208                        ".DB_PREFIXE."dossier_instruction_type
209                    WHERE
210                        dossier_instruction_type = $dossierInstructionType";
211                        
212            $this->addToLog("getCode(): db->query(\"".$sql."\")", VERBOSE_MODE);
213            $res = $this->db->query($sql);
214            if (database :: isError($res))
215                die($res->getMessage()."erreur ".$sql);
216                
217            if ( $res->numRows() > 0 ){
218                
219                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
220                $code =  $row['code'];
221            }
222                    
223            return $code;
224        }
225        
226        /*Récupère le numéro de version d'un dossier_autorisation*/
227        function getNumeroVersion($dossierAutorisation){
228            
229            $numeroVersion = "";
230            
231            $sql = "SELECT
232                        numero_version
233                    FROM
234                        ".DB_PREFIXE."dossier_autorisation
235                    WHERE
236                        dossier_autorisation = '$dossierAutorisation'";
237                        
238            $this->addToLog("getNumeroVersion(): db->query(\"".$sql."\")", VERBOSE_MODE);
239            $res = $this->db->query($sql);
240            if (database :: isError($res))
241                die($res->getMessage()."erreur ".$sql);
242                
243            if ( $res->numRows() > 0 ){
244                
245                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
246                $numeroVersion =  $row['numero_version'];
247            }
248            
249            return $numeroVersion;
250        }
251        
252        /*Incrémente le numéro de version du dossier*/
253        function incrementNumeroVersion($dossierAutorisation, $nouveauNumeroVersion) {
254            
255            $valF = array (
256                        "numero_version" => $nouveauNumeroVersion
257                    );
258            
259            $res = $this->db->autoExecute(DB_PREFIXE."dossier_autorisation",
260                                        $valF,
261                                        DB_AUTOQUERY_UPDATE,
262                                        "dossier_autorisation = '$dossierAutorisation'");
263                                        
264            if (database :: isError($res))
265                die($res->getMessage()."erreur ".$sql);
266                
267        }
268        
269        function setvalF($val){
270            parent::setvalF($val);
271            // enlever les valeurs a ne pas saisir -> recherche en trigger ajouter et modifier
272            // $sig = 1
273            unset ($this->valF['geom']);
274            unset ($this->valF['geom1']);
275          // valeurs hiddenstatic (calcule)          // valeurs hiddenstatic (calcule)
276          if($this->maj==1){          if($this->maj==1){
277              // par defaut              // par defaut
# Line 45  class dossier extends dossier_gen { Line 280  class dossier extends dossier_gen {
280              unset ($this->valF['accord_tacite']);              unset ($this->valF['accord_tacite']);
281              unset ($this->valF['types']);              unset ($this->valF['types']);
282          }          }
283          unset ($this->valF['avis']); // avis + libelle avis          unset ($this->valF['avis_decision']); // avis + libelle avis
284          unset ($this->valF['terrain_surface_calcul']);          unset ($this->valF['terrain_surface_calcul']);
285          unset ($this->valF['shon_calcul']);          unset ($this->valF['shon_calcul']);
286          unset ($this->valF['parcelle_archive']);          unset ($this->valF['parcelle_archive']);
287            unset ($this->valF['parcelle_lot_archive']);
288          unset ($this->valF['date_notification_delai']);          unset ($this->valF['date_notification_delai']);
289          unset ($this->valF['date_decision']);          unset ($this->valF['date_decision']);
290          unset ($this->valF['date_limite']);          unset ($this->valF['date_limite']);
291          unset ($this->valF['date_validite']);          unset ($this->valF['date_validite']);
292          unset ($this->valF['date_chantier']);          unset ($this->valF['date_chantier']);
293          unset ($this->valF['date_achevement']);          unset ($this->valF['date_achevement']);
294          unset ($this->valF['date_conformite']);            unset ($this->valF['date_conformite']);
     }  
   
     // specifique  
     function setId($db){  
         // id automatique nextid  
         // departement      13  
         // ville            004  
         // nature           2 caracteres  
         // lettre           R arles F vitrolles  
         // numero sur       6 caracteres  
         if (file_exists ("../dyn/var.inc"))  
             include ("../dyn/var.inc");  
         if($numero_unique==1){  
         // numero unique (voir dyn/var.inc)  
         $temp=$db->nextId($this->table);  
         }else{  
         // numero suivant nature  
         $temp=$db->nextId("dossier_".$this->nature);  
         }  
         $temp=str_pad($temp,4,"0", STR_PAD_LEFT);  
         $this->valF['dossier'] = $this->valF['nature'].$this->valF['annee'].  
                                  $lettre.$temp;  
     }  
   
     // fonction a surcharger car utilisation d un nextID alpha  
     function verifierAjout(){  
295      }      }
296    
297        /*Vérification des données saisies*/
298      function verifier($val,&$db,$DEBUG){      function verifier($val,&$db,$DEBUG){
299          $this->correct=True;          parent::verifier($val,$db,$DEBUG);
         // obligatoire  
         if($val['date_depot']!=""){  
             $this->valF['date_depot'] = $this->dateDB($val['date_depot']);  
         }else{  
             $this->correct=false;  
             $this->msg= $this->msg."<br>date_depot obligatoire";  
         }  
300          if($val['parcelle']!="" and $val['sig']!='Oui'){          if($val['parcelle']!="" and $val['sig']!='Oui'){
301            if  (!preg_match('/^[A-Z]{2}[0-9]{4}$/', $val['parcelle'])){              if  (!preg_match('/^[0-9]{3} [A-Z]{1,3} [0-9]{1,5}$/', $val['parcelle']) && !preg_match('/^[0-9]{3}[A-Z]{1,3}[0-9]{1,5}$/', $val['parcelle'])){    
302                $this->correct=false;                  $this->correct=false;
303                $this->msg= $this->msg."<br>format parcelle AANNNN";                  $this->addToMessage("<br>format parcelle incorrect");
304            }              }
305          }          }
306          // regles travaux verification          // regles travaux verification
307          if ($this->valF['travaux']!=""){          if ($this->valF['travaux']!=""){
308              $sql= "select * from regle where id = '".$this->valF['travaux'].              $sql= "select * from ".DB_PREFIXE."regle where id = '".$this->valF['travaux'].
309              "' and controle = 'travaux' order by ordre";              "' and controle = 'travaux' order by ordre";
310              $res = $db->query($sql);              $res = $db->query($sql);
311              if (DB :: isError($res))               if (database :: isError($res)) die($res->getMessage().$sql);
312                   die($res->getMessage().$sql);              $this->addToLog("requete ".$sql." execute <br>", EXTRA_VERBOSE_MODE);
313              else{              $regle=0;
314              if ($DEBUG == 1)              $msg="";
315                  echo " la requete ".$sql." est executee<br>";              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
316                  $regle=0;                  if(isset($this->valF[$row['champ']]))
317                  $msg="";                      $champvaleur=$this->valF[$row['champ']];
318                  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){                  else
319                      switch ($row['operateur']) {                      $champvaleur=0;
320                      case ">" :                  switch ($row['operateur']) {
321                          if($row['sens']=="plus"){                  case ">" :
322                              if($this->valF[$row['champ']] > $row['valeur'])                      if($row['sens']=="plus"){
323                                  $condition = 1;                          if($champvaleur > $row['valeur'])
324                              else                              $condition = 1;
325                                  $condition = 0;                          else
326                              if($regle==1 or $condition == 1)                              $condition = 0;
327                                  $regle=1;                          if($regle==1 or $condition == 1)
328                              else                              $regle=1;
329                                  $regle=0;                          else
330                              $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".                              $regle=0;
331                              $this->valF[$row['champ']]."]";                                  $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
332                            $champvaleur."]";        
333                        }else{
334                            if($champvaleur > $row['valeur']){
335                                $condition = 0;
336                          }else{                          }else{
337                              if($this->valF[$row['champ']] > $row['valeur']){                              $condition = 1;
338                                  $condition = 0;                              $regle=0;
                             }else{  
                                 $condition = 1;  
                                 $regle=0;  
                             }  
                             $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".  
                             $this->valF[$row['champ']]."]";  
339                          }                          }
340                          break;                          $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
341                      case ">=":                          $champvaleur."]";
342                         if($row['sens']=="plus"){                      }
                             if($this->valF[$row['champ']] >= $row['valeur'])  
                                 $condition = 1;  
                             else  
                                 $condition = 0;  
                             if($regle==1 or $condition == 1)  
                                 $regle=1;  
                             else  
                                 $regle=0;  
                             $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".  
                             $this->valF[$row['champ']]."]";  
                         }else{  
                             if($this->valF[$row['champ']] >= $row['valeur']){  
                                 $condition = 0;  
                 
                             }else{  
                                 $condition = 1;  
                                 $regle=0;  
                             }  
                             $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".  
                             $this->valF[$row['champ']]."]";  
                          }  
343                      break;                      break;
344                      case "<" :                  case ">=":
345                          if($row['sens']=="plus"){                      if($row['sens']=="plus"){
346                              if($this->valF[$row['champ']] < $row['valeur'])                          if($champvaleur >= $row['valeur'])
347                                  $condition = 1;                              $condition = 1;
348                              else                          else
349                                  $condition = 0;                              $condition = 0;
350                              if($regle==1 or $condition == 1)                          if($regle==1 or $condition == 1)
351                                  $regle=1;                              $regle=1;
352                              else                          else
353                                  $regle=0;                              $regle=0;
354                              $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".                          $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
355                              $this->valF[$row['champ']]."]";                          $champvaleur."]";
356                        }else{
357                            if($champvaleur >= $row['valeur']){
358                                $condition = 0;
359              
360                          }else{                          }else{
361                              if($this->valF[$row['champ']] < $row['valeur']){                              $condition = 1;
362                                  $condition = 0;                              $regle=0;
                             }else{  
                                 $condition = 1;  
                                 $regle=0;  
                             }  
                             $msg=$msg."<br> et ".$row['message']." [".$row['champ']." = ".  
                                 $this->valF[$row['champ']]."]";  
363                          }                          }
364                      break;                          $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
365                            $champvaleur."]";
366                        }
367                    break;
368                    case "<" :
369                        if($row['sens']=="plus"){
370                            if($champvaleur < $row['valeur'])
371                                $condition = 1;
372                            else
373                                $condition = 0;
374                            if($regle==1 or $condition == 1)
375                                $regle=1;
376                            else
377                                $regle=0;
378                            $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
379                            $champvaleur."]";
380                        }else{
381                            if($champvaleur < $row['valeur']){
382                                $condition = 0;
383                            }else{
384                                $condition = 1;
385                                $regle=0;
386                            }
387                            $msg=$msg."<br> et ".$row['message']." [".$row['champ']." = ".
388                                $champvaleur."]";
389                        }
390                    break;
391                  case "==":                  case "==":
392                      if($row['sens']=="plus"){                      if($row['sens']=="plus"){
393                          if($this->valF[$row['champ']] == $row['valeur'])                          if($champvaleur == $row['valeur'])
394                              $condition = 1;                              $condition = 1;
395                          else                          else
396                              $condition = 0;                              $condition = 0;
# Line 194  class dossier extends dossier_gen { Line 399  class dossier extends dossier_gen {
399                          else                          else
400                              $regle=0;                              $regle=0;
401                          $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".                          $msg=$msg."<br> + ".$row['message']." [".$row['champ']." = ".
402                          $this->valF[$row['champ']]."]";                          $champvaleur."]";
403                     }else{                      }else{
404                          if($this->valF[$row['champ']] == $row['valeur']){                          if($champvaleur == $row['valeur']){
405                              $condition = 0;                              $condition = 0;
406                        
407                          }else{                          }else{
# Line 204  class dossier extends dossier_gen { Line 409  class dossier extends dossier_gen {
409                              $regle=0;                              $regle=0;
410                          }                          }
411                          $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".                          $msg=$msg."<br> ou ".$row['message']." [".$row['champ']." = ".
412                          $this->valF[$row['champ']]."]";                          $champvaleur."]";
413                      }                      }
                   break;  
414                  break;                  break;
415                    //break;
416                  } // switch                  } // switch
417              }                  if($regle==0)
418              if($regle==0)                      $this->addToMessage($msg." <br>");
419                  $this->msg= $this->msg.$msg." <br><br>";              } // while
420              }          } // travaux
         }  
421      }//verifier      }//verifier
422    
423    
424      function setType(&$form,$maj) {      function setType(&$form,$maj) {
425          //parent::setType($form,$maj);          parent::setType($form,$maj);
426          if ($maj < 2) { //ajouter et modifier          if ($maj < 2) { //ajouter et modifier
427              // cache              // cache
428              if($maj==0) $form->setType('dossier', 'hidden');              if($maj==0) $form->setType('dossier', 'hidden');
429              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
430              $form->setType('nature', 'hidden');              $form->setType('parcelle_archive','hidden');
431              $form->setType('parcelle_archive','hidden');              $form->setType('parcelle_lot_archive','hidden');
432              $form->setType('objet_dossier','hidden'); // PC              $form->setType('objet_dossier','hidden'); // PC
433              $form->setType('amenagement','hidden'); // PC              $form->setType('amenagement','hidden'); // PC
434                                        $form->setType('parcelle_lot','hidden'); // PC
435              // a voir a quoi cela peut servir              $form->setType('parcelle_lot_lotissement','hidden'); // PC
             $form->setType('sig','hidden'); // PC  
             $form->setType('siglien','hidden'); // PC  
               
             // date  
             $form->setType('date_depot','date');  
             $form->setType('date_demande','date');  
436                            
437                $form->setType('geom1', 'hidden');
438                $form->setType('geom', 'geom');
439                $form->setType('servitude', 'hiddenstatic');
440    
441              //select              //select
442              $form->setType('travaux','select');              $form->setType('terrain_numero_complement','select');            
             $form->setType('instructeur','select');  
             $form->setType('terrain_numero_complement','select');  
             $form->setType('delegataire_civilite','select');  
             $form->setType('demandeur_civilite','select');  
             $form->setType('demandeur_categorie','select');  
443    
444              // combo              // combo
445              $form->setType('rivoli','comboD');              $form->setType('rivoli','comboD');
446              $form->setType('terrain_adresse','comboG');              $form->setType('terrain_adresse','comboG');
             //$form->setType('architecte','comboD');  
             //$form->setType('architecte','textdisabled'); // ne valorise pas  
447              $form->setType('architecte_nom','comboG');              $form->setType('architecte_nom','comboG');
448                $form->setType('architecte','comboD');
449    
450    
451              // hiddenstatic              // hiddenstatic
452              if($maj==1) $form->setType('dossier', 'hiddenstatic');              if($maj==1) $form->setType('dossier', 'hiddenstatic');
453              $form->setType('etat','hiddenstatic');              $form->setType('etat','hiddenstatic');
454              $form->setType('avis','hiddenstatic');              $form->setType('avis_decision','hiddenstatic');
455              $form->setType('delai','hiddenstatic');              $form->setType('delai','hiddenstatic');
456              $form->setType('terrain_surface_calcul','hiddenstatic');              $form->setType('terrain_surface_calcul','hiddenstatic');
457              $form->setType('shon_calcul','hiddenstatic');              $form->setType('shon_calcul','hiddenstatic');
# Line 276  class dossier extends dossier_gen { Line 473  class dossier extends dossier_gen {
473              $form->setType('date_conformite','hiddenstaticdate');              $form->setType('date_conformite','hiddenstaticdate');
474                        
475              // checkbox                  // checkbox    
476              //$form->setType('sig','checkbox');              $form->setType('sig','checkbox');
477              $form->setType('delegataire','checkbox');              $form->setType('delegataire','checkbox');
478                                      
             // http  
             //$form->setType('siglien','http');  
             $form->setType('saisie_architecte', 'httpclick');  
               
479              // mail              // mail
480              $form->setType('delegataire_email','mail');              $form->setType('delegataire_email','mail');
481              $form->setType('demandeur_email','mail');                        $form->setType('demandeur_email','mail');          
482                            
483              // zones temp et strategysig              // zones temp et strategysig
484              include ("../dyn/var.inc");              
485              if(!isset($sauvegardeDossier)) $sauvegardeDossier='';  
486              if($sauvegardeDossier != '') // strategie sig              // temp
487                  $form->setType('pos','hiddenstatic');              if (file_exists ("../dyn/var.inc"))
488                    include ("../dyn/var.inc");
489                if(!isset($auto_pos))
490                    $auto_pos=0;              
491                if($auto_pos==1)
492                   $form->setType('pos','hiddenstatic');
493              else              else
494                  $form->setType('pos','select');                  $form->setType('pos','select');
             // temp              
495              $form->setType('temp1',$temp1_type);              $form->setType('temp1',$temp1_type);
496              $form->setType('temp2',$temp2_type);              $form->setType('temp2',$temp2_type);
497              $form->setType('temp3',$temp3_type);              $form->setType('temp3',$temp3_type);
498              $form->setType('temp4',$temp4_type);              $form->setType('temp4',$temp4_type);
499              $form->setType('temp5',$temp5_type);              $form->setType('temp5',$temp5_type);
500          }else{ // supprimer              $form->setType('a_qualifier', 'checkbox');
501               $form->setType('dossier', 'hiddenstatic');          }
502               $form->setType('sig', 'hiddenstatic');          if ($maj == 1) {
503                //
504                if ($this->f->isAccredited("dossier_modifier_instructeur")) {
505                    $form->setType('instructeur', 'select');
506                } else {
507                    $form->setType('instructeur', 'selecthiddenstatic');
508                }
509                //
510                if($this->f->getParameter('afficher_division') === 'true') {
511                    //
512                    if ($this->f->isAccredited("dossier_modifier_division")) {
513                        $form->setType('division', 'select');
514                    } else {
515                        $form->setType('division', 'selecthiddenstatic');
516                    }
517                } else {
518                    $form->setType('division', 'hidden');
519                }
520            }
521            if($maj == 3) {
522                $form->setType('annee', 'hidden');
523                $form->setType('temp1','hidden');
524                $form->setType('temp2','hidden');
525                $form->setType('temp3','hidden');
526                $form->setType('temp4','hidden');
527                $form->setType('temp5','hidden');
528                $form->setType('parcelle_archive','hidden');
529                $form->setType('parcelle_lot_archive','hidden');
530                $form->setType('geom1','hidden');
531                $form->setType('geom','hidden');
532                $form->setType('a_qualifier', 'checkboxstatic');
533          }          }
     }  
   
   
     function setMax(&$form,$maj){  
         $form->setMax('architecte_nom', 30);  
   
         $form->setMax('demandeur_nom', 80);  
         $form->setMax('demandeur_societe', 80);  
         $form->setMax('demandeur_adresse', 40);  
         $form->setMax('demandeur_cp', 5);  
         $form->setMax('demandeur_ville', 30);  
         $form->setMax('demandeur_pays', 40);  
         $form->setMax('demandeur_telephone', 14);  
         $form->setMax('demandeur_email', 40);  
           
         $form->setMax('delegataire_societe', 80);  
         $form->setMax('delegataire_nom', 80);  
         $form->setMax('delegataire_adresse', 80);  
         $form->setMax('delegataire_pays', 40);  
         $form->setMax('delegataire_cp', 5);  
         $form->setMax('delegataire_ville', 30);  
         $form->setMax('delegataire_telephone', 14);  
         $form->setMax('delegataire_email', 40);  
           
         $form->setMax('terrain_adresse', 80);  
         $form->setMax('terrain_numero', 4);  
         $form->setMax('terrain_adresse_complement', 80);  
         $form->setMax('rivoli', 4);  
         $form->setMax('terrain_cp', 5);  
         $form->setMax('terrain_ville', 30);  
           
         $form->setMax('parcelle', 20);  
           
         $form->setMax('temp1', 100);  
         $form->setMax('temp2', 100);  
         $form->setMax('temp3', 100);  
         $form->setMax('temp4', 100);  
         $form->setMax('temp5', 100);  
     }  
   
     function setTaille(&$form,$maj){  
         // date  
         $form->setTaille('date_demande', 12);  
         $form->setTaille('date_notification_delai', 12);  
         $form->setTaille('date_decision', 12);  
         $form->setTaille('date_limite', 12);  
         $form->setTaille('date_depot', 12);  
         // demandeur  
         $form->setTaille('demandeur_nom', 20);  
         $form->setTaille('demandeur_societe', 20);  
         $form->setTaille('demandeur_adresse', 30);  
         $form->setTaille('demandeur_cp', 5);  
         $form->setTaille('demandeur_ville', 20);  
         $form->setTaille('demandeur_pays', 20);  
         $form->setTaille('demandeur_telephone', 14);  
         $form->setTaille('demandeur_email', 20);  
         // delegataire  
         $form->setTaille('delegataire_societe', 20);  
         $form->setTaille('delegataire_nom', 20);  
         $form->setTaille('delegataire_adresse', 30);  
         $form->setTaille('delegataire_pays', 20);  
         $form->setTaille('delegataire_cp', 5);  
         $form->setTaille('delegataire_ville', 20);  
         $form->setTaille('delegataire_telephone', 14);  
         $form->setTaille('delegataire_email', 20);  
         // terrain  
         $form->setTaille('terrain_surface', 6);  
         $form->setTaille('terrain_surface_calcul', 6);  
         $form->setTaille('terrain_adresse', 20);  
         $form->setTaille('terrain_adresse_complement', 20);  
         $form->setTaille('terrain_numero', 4);  
         $form->setTaille('terrain_cp', 5);  
         $form->setTaille('terrain_ville', 20);  
         $form->setTaille('rivoli', 4);  
         $form->setTaille('parcelle', 20);  
534          //          //
535          $form->setTaille('architecte_nom', 30);          if(!$this->f->getParameter('afficher_division') === 'true') {
536          $form->setTaille('architecte', 3);              $form->setType('division', 'hidden');
537          // description          }
538          $form->setTaille('hauteur','3');          $form->setType('dossier_autorisation', 'hiddenstatic');
539                    $form->setType('dossier_instruction_type', 'selectstatic');
540          $form->setTaille('temp1', 100);          //
541          $form->setTaille('temp2', 100);          if ($maj == 0) {
542          $form->setTaille('temp3', 100);              $form->setType('dossier_autorisation', 'select');
543          $form->setTaille('temp4', 100);          }
544          $form->setTaille('temp5', 100);          // On cache enjeu_ERP si l'option n'est pas activée
545            if($this->f->getParameter('option_ERP') != 'true') {
546                $form->setType('erp', 'hidden');
547                $form->setType('enjeu_erp', 'hidden');
548            }
549      }      }
550    
551      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
552          $this->maj=$maj;          $this->maj=$maj;
553          if ($validation==0) {          if ($validation==0) {
554              if ($maj == 0){              if ($maj == 0){
555                  include ("../dyn/var.inc");                  //$dossier_cp = $this->f->collectivite["cp"];
556                  $form->setVal('nature', $this->nature);                  //$dossier_ville = $this->f->collectivite["ville"];
557                                
558                  $form->setVal('annee', date('y'));                  $form->setVal('annee', date('y'));
559                  $form->setVal('date_demande', date('Y-m-d'));                  $form->setVal('date_demande', date('Y-m-d'));
560                  $form->setVal('date_depot', date('Y-m-d'));                  $form->setVal('date_depot', date('Y-m-d'));
561                                
562                  $form->setVal('demandeur_cp', $dossier_cp);                  //$form->setVal('demandeur_cp', $dossier_cp);
563                  $form->setVal('demandeur_ville', $dossier_ville);                  //$form->setVal('demandeur_ville', $dossier_ville);
564                                
565                  $form->setVal('delegataire_cp', $dossier_cp);                  //$form->setVal('delegataire_cp', $dossier_cp);
566                  $form->setVal('delegataire_ville', $dossier_ville);                  //$form->setVal('delegataire_ville', $dossier_ville);
567                                
568                  $form->setVal('terrain_cp', $dossier_cp);                  //$form->setVal('terrain_cp', $dossier_cp);
569                  $form->setVal('terrain_ville', $dossier_ville);                  //$form->setVal('terrain_ville', $dossier_ville);
570                                
571                  $form->setVal('accord_tacite', 'Non');                  $form->setVal('accord_tacite', 'Non');
572                  $form->setVal('etat', 'initialiser');                  $form->setVal('etat', 'initialiser');
573                  $form->setVal('types', 'Initial');                  $form->setVal('types', 'Initial');
574                  $form->setVal("saisie_architecte","saisie3()");              }
             }else{  
                 $form->setVal("saisie_architecte","saisie3()");  
            }  
575          }          }
576      }      }
577    
578      function setSelect(&$form, $maj,&$db,$debug) {      function setSelect(&$form, $maj,&$db,$debug) {
579            parent::setSelect($form, $maj,$db,$debug);
580          //optimisation sur table importante parcelle -> pas d appel methode parent          //optimisation sur table importante parcelle -> pas d appel methode parent
581                  if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))          if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
582                          include ("../sql/".$db->phptype."/".$this->table.".form.inc");                  include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
583          if($maj<2){          if($maj<2){
584              // travaux              // travaux
585              $contenu=array();              $contenu=array();
# Line 437  class dossier extends dossier_gen { Line 591  class dossier extends dossier_gen {
591                  $sql_travaux = $sql_travaux.                  $sql_travaux = $sql_travaux.
592                  " order by libelle";                                  " order by libelle";                
593              $res = $db->query($sql_travaux);              $res = $db->query($sql_travaux);
594              if (database::isError($res))              if (database::isError($res)) die($res->getMessage()).$sql_travaux;
595                  die($res->getMessage());              $this->addToLog(" la requete ".$sql_travaux." est executee", VERBOSE_MODE);
596              else{              $contenu[0][0]="";
597                  if ($debug == 1)              $contenu[1][0]=_('choisir')." "._('travaux');
598                      echo " la requete ".$sql_travaux." est executee<br>";              $k=1;
599                  $contenu[0][0]="";              while ($row=& $res->fetchRow()){
                 $contenu[1][0]=_('choisir')." "._('travaux');  
                 $k=1;  
                 while ($row=& $res->fetchRow()){  
                     $contenu[0][$k]=$row[0];  
                     $contenu[1][$k]=$row[1];  
                     $k++;  
                 }  
             $form->setSelect("travaux",$contenu);  
             }  
   
             // instructeur  
             $contenu=array();  
             $res = $db->query($sql_instructeur);  
             if (DB :: isError($res))  
                  die($res->getMessage().$sql_instructeur);  
             else{  
              if ($debug == 1)  
                echo " la requete ".$sql_instructeur." est executee<br>";  
                $contenu[0][0]="";  
                $contenu[1][0]=$this->lang('choisir')." ".$this->lang('instructeur');  
                $k=1;  
                while ($row=& $res->fetchRow()){  
                 $contenu[0][$k]=$row[0];  
                 $contenu[1][$k]=$row[1];  
                 $k++;  
                }  
             $form->setSelect("instructeur",$contenu);  
             }  
             // demandeur et delegataire civilite  
             $contenu=array();  
             $res = $db->query($sql_civilite);  
                         if (database::isError($res))  
                                 die($res->getMessage().$sql_travaux);  
             else{  
              if ($debug == 1)  
                echo " la requete ".$sql_civilite." est execute<br>";  
                $contenu[0][0]="";  
                $contenu[1][0]=_('choisir')." "._('civilite');  
                $k=1;  
                while ($row=& $res->fetchRow()){  
600                  $contenu[0][$k]=$row[0];                  $contenu[0][$k]=$row[0];
601                  $contenu[1][$k]=$row[1];                  $contenu[1][$k]=$row[1];
602                  $k++;                  $k++;
                }  
             $form->setSelect("demandeur_civilite",$contenu);  
             $form->setSelect("delegataire_civilite",$contenu);  
603              }              }
604              // demandeur categorie              $form->setSelect("travaux",$contenu);
605              $contenu=array();  
             $res = $db->query($sql_categorie_demandeur);  
                         if (database::isError($res))  
                                 die($res->getMessage().$sql_categorie_demandeur);  
             else{  
              if ($debug == 1)  
                echo " la requete ".$sql_categorie_demandeur." est execute<br>";  
                $contenu[0][0]="";  
                $contenu[1][0]=_('choisir')." "._('categorie');  
                $k=1;  
                while ($row=& $res->fetchRow()){  
                 $contenu[0][$k]=$row[0];  
                 $contenu[1][$k]=$row[1];  
                 $k++;  
                }  
             $form->setSelect("demandeur_categorie",$contenu);  
             }  
             // pos  
             $contenu=array();  
             $res = $db->query($sql_pos);  
                         if (database::isError($res))  
                                 die($res->getMessage().$sql_pos);  
             else{  
              if ($debug == 1)  
                echo " la requete ".$sql_architecte." est execute<br>";  
                $contenu[0][0]="";  
                $contenu[1][0]=$this->lang('choisir')." ".$this->lang('pos');  
                $k=1;  
                while ($row=& $res->fetchRow()){  
                 $contenu[0][$k]=$row[0];  
                 $contenu[1][$k]=$row[1];  
                 $k++;  
                }  
             $form->setSelect("pos",$contenu);  
             }  
             // lien sig  
             include ("../dyn/var.inc");  
             $contenu=array();  
             $contenu[0]="<img src='".$image_sig."'>";  
             $form->setSelect("siglien",$contenu);  
606              // code et libelle voie              // code et libelle voie
607              $contenu="";              $contenu="";
608              $contenu[0][0]="rivoli";// table              $contenu[0][0]="rivoli";// table
# Line 538  class dossier extends dossier_gen { Line 610  class dossier extends dossier_gen {
610              $contenu[1][0]="libelle";              $contenu[1][0]="libelle";
611              $contenu[1][1]="terrain_adresse";              $contenu[1][1]="terrain_adresse";
612              $form->setSelect("rivoli",$contenu);              $form->setSelect("rivoli",$contenu);
613                //terrain_adresse
614              $contenu="";              $contenu="";
615              $contenu[0][0]="rivoli";// table              $contenu[0][0]="rivoli";// table
616              $contenu[0][1]="libelle"; // zone origine              $contenu[0][1]="libelle"; // zone origine
# Line 557  class dossier extends dossier_gen { Line 630  class dossier extends dossier_gen {
630              $contenu[1][0]="architecte";              $contenu[1][0]="architecte";
631              $contenu[1][1]="architecte";              $contenu[1][1]="architecte";
632              $form->setSelect("architecte_nom",$contenu);              $form->setSelect("architecte_nom",$contenu);
633                // parcelle_lot
634                $contenu="";
635                $contenu[0][0]="parcelle_lot";// table
636                $contenu[0][1]="parcelle_lot"; // zone origine
637                $contenu[1][0]="lotissement";
638                $contenu[1][1]="parcelle_lot_lotissement";
639                $form->setSelect("parcelle_lot",$contenu);
640                $contenu="";
641                $contenu[0][0]="parcelle_lot";// table
642                $contenu[0][1]="lotissement"; // zone origine
643                $contenu[1][0]="parcelle_lot";
644                $contenu[1][1]="parcelle_lot";
645                $form->setSelect("parcelle_lot_lotissement",$contenu);
646              // accord tacite              // accord tacite
647              $contenu=array();              $contenu=array();
648              $contenu[0]=array('Non','Oui');              $contenu[0]=array('Non','Oui');
649              $contenu[1]=array('Non','Oui');              $contenu[1]=array('Non','Oui');
             $form->setSelect("etat",$contenu);  
650              $form->setSelect("accord_tacite",$contenu);              $form->setSelect("accord_tacite",$contenu);
651              // terrain_numero_complement              // terrain_numero_complement
652              $contenu=array();              $contenu=array();
653              $contenu[0]=array('','bis','ter','quater');              $contenu[0]=array('','bis','ter','quater');
654              $contenu[1]=array('','bis','ter','quater');              $contenu[1]=array('','bis','ter','quater');
655              $form->setSelect("terrain_numero_complement",$contenu);              $form->setSelect("terrain_numero_complement",$contenu);
656              // lien demandeur              // geom *** a voir
657              $contenu=array();              if($maj==1){ //modification
658              $contenu[0]=" <img src='../img/modifier.gif' border ='0'> ";                  $contenu=array();
659              $form->setSelect("saisie_demandeur",$contenu);                  $contenu[0]=array("dossier",$this->getParameter("idx"));
660              // lien demandeur                  $form->setSelect('geom',$contenu);
661              $contenu=array();              }
662              $contenu[0]=" <img src='../img/modifier.gif' border ='0'> ";              // arrondissement recherche anvancée
663              $form->setSelect("saisie_delegataire",$contenu);              $this->init_select($form, $db, $maj, $debug, "arrondissement",
664              // lien architecte                             $sql_arrondissement, $sql_arrondissement_by_id, false);
665                // dossier_autorisation_type_detaille recherche anvancée
666                $this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille",
667                               $sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false);
668                /*
669                 * Affichage de données dans le select de la parcelle
670                 * */
671              $contenu=array();              $contenu=array();
672              $contenu[0]=" <img src='../img/ajouter.gif' border ='0'> ";              $sql="select parcelle from ".DB_PREFIXE."parcelle ";
673              $form->setSelect("saisie_architecte",$contenu);              $res = $db->query($sql);
674                if (database::isError($res))
675                    die($res->getMessage());
676                $contenu[0][0]="";
677                $contenu[1][0]=_("choisir parcelle");
678                $k=1;
679                while ($row=& $res->fetchRow()){
680                    $contenu[0][$k]=$row[0];
681                    $contenu[1][$k]=$row[0];
682                    $k++;
683                }
684                $form->setSelect("parcelle",$contenu);
685                
686            }
687            if($this->f->getParameter('afficher_division')==='true') {
688                // instructeur
689                $this->init_select($form, $db, $maj, $debug, "instructeur",
690                $sql_instructeur_div, $sql_instructeur_div_by_id, false);
691          }          }
692      }      }
693    
694        function setLib(&$form,$maj) {
695            parent::setLib($form,$maj);
696            $form->setLib('geom','');
697        }    
698    
699      function setGroupe(&$form,$maj){      function setGroupe(&$form,$maj){
700          If ($maj==0){          //If ($maj==0){
701              $form->setGroupe('date_demande','D');          //    $form->setGroupe('date_demande','D');
702              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
703              $form->setGroupe('instructeur','F');          //    $form->setGroupe('division','F');
704          }else{          //}else{
705              $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
706              $form->setGroupe('nature','G');          //    $form->setGroupe('annee','G');
707              $form->setGroupe('annee','G');          //    $form->setGroupe('date_demande','G');
708              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_depot','G');
709              $form->setGroupe('date_depot','G');          //    $form->setGroupe('division','F');
710              $form->setGroupe('instructeur','F');          //}
         }  
711          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
712          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
713          $form->setGroupe('demandeur_nom','G');          $form->setGroupe('demandeur_nom','F');
714          $form->setGroupe('demandeur_societe','F');          
715                  $form->setGroupe('demandeur_societe','D');
716          $form->setGroupe('demandeur_adresse','D');          $form->setGroupe('demandeur_adresse','G');
717          $form->setGroupe('demandeur_cp','G');          $form->setGroupe('demandeur_adresse_complement','F');
718    
719            $form->setGroupe('demandeur_cp','D');
720          $form->setGroupe('demandeur_ville','G');          $form->setGroupe('demandeur_ville','G');
721          $form->setGroupe('demandeur_pays','F');          $form->setGroupe('demandeur_pays','F');
722                
# Line 611  class dossier extends dossier_gen { Line 725  class dossier extends dossier_gen {
725                    
726          $form->setGroupe('delegataire','D');          $form->setGroupe('delegataire','D');
727          $form->setGroupe('delegataire_civilite','G');          $form->setGroupe('delegataire_civilite','G');
728          $form->setGroupe('delegataire_nom','G');          $form->setGroupe('delegataire_nom','F');
729          $form->setGroupe('delegataire_societe','F');  
730                  $form->setGroupe('delegataire_societe','D');
731          $form->setGroupe('delegataire_adresse','D');          $form->setGroupe('delegataire_adresse','G');
732          $form->setGroupe('delegataire_cp','G');          $form->setGroupe('delegataire_adresse_complement','F');
733            $form->setGroupe('delegataire_cp','D');
734          $form->setGroupe('delegataire_ville','G');          $form->setGroupe('delegataire_ville','G');
735          $form->setGroupe('delegataire_pays','F');          $form->setGroupe('delegataire_pays','F');
736                
# Line 623  class dossier extends dossier_gen { Line 738  class dossier extends dossier_gen {
738          $form->setGroupe('delegataire_telephone','F');          $form->setGroupe('delegataire_telephone','F');
739                                
740          $form->setGroupe('architecte','D');          $form->setGroupe('architecte','D');
741          $form->setGroupe('architecte_nom','G');          $form->setGroupe('architecte_nom','F');
742          $form->setGroupe('saisie_architecte','G');          //$form->setGroupe('saisie_architecte','F');
743          $form->setGroupe('travaux','F');            
744            $form->setGroupe('travaux','D');  
745            $form->setGroupe('travaux_complement','F');
746                    
747          // terrain          // terrain
748          $form->setGroupe('terrain_numero','D');          $form->setGroupe('terrain_numero','D');
749          $form->setGroupe('terrain_numero_complement','G');          $form->setGroupe('terrain_numero_complement','G');
750          $form->setGroupe('rivoli','G');          $form->setGroupe('rivoli','F');
751          $form->setGroupe('terrain_adresse','G');          $form->setGroupe('terrain_adresse','D');
752          $form->setGroupe('terrain_adresse_complement','F');          $form->setGroupe('terrain_adresse_complement','F');
753    
754          $form->setGroupe('terrain_cp','D');          $form->setGroupe('terrain_cp','D');
# Line 653  class dossier extends dossier_gen { Line 770  class dossier extends dossier_gen {
770          $form->setGroupe('etat','F');          $form->setGroupe('etat','F');
771                    
772          $form->setGroupe('date_decision','D');          $form->setGroupe('date_decision','D');
773          $form->setGroupe('avis','G');          $form->setGroupe('avis_decision','G');
774          $form->setGroupe('date_validite','G');          $form->setGroupe('date_validite','G');
775          $form->setGroupe('types','F');          $form->setGroupe('types','F');
776                    
777          $form->setGroupe('date_chantier','D');          $form->setGroupe('date_chantier','D');
778          $form->setGroupe('date_achevement','G');          $form->setGroupe('date_achevement','G');
779          $form->setGroupe('date_conformite','F');          $form->setGroupe('date_conformite','F');
780            
781          // localisation          // localisation
782          $form->setGroupe('parcelle','D');          $form->setGroupe('parcelle','D');
783          $form->setGroupe('pos','F');          $form->setGroupe('pos','G');
784          //$form->setGroupe('sig','G');          if($maj==1){
785          //$form->setGroupe('siglien','F');              $form->setGroupe('sig','G');
786                    $form->setGroupe('geom','F');
787            }else {
788                $form->setGroupe('sig','F');
789            }
790            if($maj==1){
791                $form->setGroupe('sig','G');
792                $form->setGroupe('geom','F');
793            }
794            
795          // description          // description
796          $form->setGroupe('batiment_nombre','D');          $form->setGroupe('batiment_nombre','D');
797          $form->setGroupe('logement_nombre','G');          $form->setGroupe('logement_nombre','G');
# Line 676  class dossier extends dossier_gen { Line 802  class dossier extends dossier_gen {
802          $form->setGroupe('shon_calcul','G');          $form->setGroupe('shon_calcul','G');
803          $form->setGroupe('shob','G');          $form->setGroupe('shob','G');
804          $form->setGroupe('lot','F');          $form->setGroupe('lot','F');
     }  
   
   
   
     function setLib(&$form,$maj) {  
         $col = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";  
         $form->setLib('dossier','');  
         $form->setLib('date_demande',$col._('demande le').' : ');  
         $form->setLib('date_depot',$col._('depose le ')." : ");  
         $form->setLib('instructeur',$col._('instructeur')."  ");        
         $form->setLib('date_complet',_('complet le').' : ');  
         $form->setLib('date_rejet',_('rejette le').' : ');  
         $form->setLib('date_notification_delai',$col._('date notification').' : ');  
         $form->setLib('delai',$col._('delai (mois)').' : ');  
         $form->setLib('siglien','  ');  
   
         $form->setLib('demandeur_categorie','');  
         $form->setLib('demandeur_civilite','');  
         $form->setLib('demandeur_nom','');  
         $form->setLib('demandeur_societe',_('societe').' ');  
         $form->setLib('demandeur_adresse','');  
         $form->setLib('demandeur_cp',_('cp'));  
         $form->setLib('demandeur_ville',_('ville'));  
         $form->setLib('demandeur_pays',' '._('pays').' ');  
         $form->setLib('demandeur_telephone',' '._('tel').' ');  
         $form->setLib('demandeur_email','');  
               
         $form->setLib('delegataire','');  
         $form->setLib('delegataire_civilite','');  
         $form->setLib('delegataire_nom','');  
         $form->setLib('delegataire_societe',_('societe').': ');  
         $form->setLib('delegataire_adresse','');  
         $form->setLib('delegataire_cp',_('cp'));  
         $form->setLib('delegataire_ville',_('ville'));  
         $form->setLib('delegataire_pays',' '._('pays').': ');  
         $form->setLib('delegataire_telephone',' '._('tel').': ');  
         $form->setLib('delegataire_email','');  
               
         $form->setLib('types','');  
               
         $form->setLib('terrain_numero',_('adresse'));  
         $form->setLib('terrain_numero_complement','');  
         $form->setLib('terrain_adresse','');  
         $form->setLib('terrain_adresse_complement','');  
         $form->setLib('rivoli','');  
         $form->setLib('terrain_cp','cp');  
         $form->setLib('terrain_ville','ville');  
           
         $form->setLib('terrain_surface',' '._('surface').' : ');  
         $form->setLib('terrain_surface_calcul',' '._('calcul').' : ');  
         $form->setLib('parcelle',' '._('parcelle').' : ');  
           
         $form->setLib('date_decision',' '._('decide le').' : ');  
         $form->setLib('date_validite',$col._('valide jusqu au').' : ');  
         $form->setLib('date_achevement',$col._('acheve le').' : ');  
         $form->setLib('avis',$col._('avec avis').' : ');  
         $form->setLib('date_limite',''._('limite le').' : ');  
         $form->setLib('date_chantier',''._('chantier le').' : ');  
         $form->setLib('date_conformite',$col._('conforme le').' : ');  
         $form->setLib('etat',$col._('etat').' : ');  
         $form->setLib('accord_tacite',$col._('accord tacite').' : ');  
         $form->setLib('date_rejet',$col._("DPC")." : ");  
805                    
806                    $form->setGroupe('amenagement','D');
807          // travaux          $form->setGroupe('parcelle_lot','G');
808          $form->setLib('objet_dossier','');          $form->setGroupe('parcelle_lot_lotissement','F');
         $form->setLib('travaux','');  
         $form->setLib('saisie_architecte',""); // ***  
         $form->setLib('architecte_nom',"");  
         $form->setLib('architecte','');  
           
         // description  
         $form->setLib('batiment_nombre',' '._('nombre de batiment').' : ');  
         $form->setLib('logement_nombre',' '._('nombre de logement').' : ');  
         $form->setLib('hauteur',' '._('hauteur').' : ');  
         $form->setLib('piece_nombre',' '._('nombre de piece(s)').' : ');  
         $form->setLib('shon',' '._('shon').' : ');  
         $form->setLib('shon_calcul',' '._('calcul shon').' : ');  
         $form->setLib('shob',' '._('shob').' : ');  
         $form->setLib('amenagement',' '._('amenagement').' : ');  
           
         // zones temp  
         include ("../dyn/var.inc");  
         $form->setLib('temp1',$temp1_lib);  
         $form->setLib('temp2',$temp2_lib);  
         $form->setLib('temp3',$temp3_lib);  
         $form->setLib('temp4',$temp4_lib);  
         $form->setLib('temp5',$temp5_lib);  
809      }      }
810    
811      function setOnchange(&$form,$maj){      function setOnchange(&$form,$maj){
# Line 774  class dossier extends dossier_gen { Line 816  class dossier extends dossier_gen {
816          $form->setOnchange("delegataire_nom","this.value=this.value.toUpperCase()");          $form->setOnchange("delegataire_nom","this.value=this.value.toUpperCase()");
817          $form->setOnchange("delegataire_societe","this.value=this.value.toUpperCase()");          $form->setOnchange("delegataire_societe","this.value=this.value.toUpperCase()");
818          $form->setOnchange("architecte_nom","this.value=this.value.toUpperCase()");          $form->setOnchange("architecte_nom","this.value=this.value.toUpperCase()");
819            $form->setOnchange("terrain_adresse","this.value=this.value.toUpperCase()");
820            $form->setOnchange('shon','VerifNumdec(this)');
821            $form->setOnchange('shob','VerifNumdec(this)');
822            $form->setOnchange('hauteur','VerifNumdec(this)');
823            $form->setOnchange('terrain_surface','VerifNumdec(this)');
824      }      }
825    
826      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
827          // depot          //
828          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
829              $form->setRegroupe('date_demande','D',_(Depot),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
830          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
831          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
832              $form->setRegroupe('dossier','D',_(Depot), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
833              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
834          }          $form->setFieldset('date_demande', 'D', _("Depot"));
835          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
836          $form->setRegroupe('instructeur','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
837            $form->setFieldset('enjeu_erp', 'F');
838            $form->setBloc('enjeu_erp', 'F');
839            $form->setBloc('enjeu_erp', 'F');
840            //
841            $form->setBloc('objet_dossier', 'D', '', 'col_12');
842            //
843            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
844            $form->setRegroupe('date_conformite','F','');
845            //
846            $form->setBloc('terrain_superficie', 'F');
847                    
848        }
849        
850        function setRegroupe(&$form,$maj) {
851            //// depot
852            //If ($maj==0){
853            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
854            //}
855            //If ($maj==1){
856            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
857            //    $form->setRegroupe('date_demande','G','');
858            //}
859            //$form->setRegroupe('date_depot','G','');
860            //$form->setRegroupe('division','F','');
861    
862          // travaux          // travaux
863          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
864          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
865          $form->setRegroupe('saisie_architecte','G','');          $form->setRegroupe('travaux','G','');
866          $form->setRegroupe('travaux','F','');          $form->setRegroupe('travaux_complement','F','');
867                    
868          // instruction          //// instruction
869          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
870          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
871          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
872          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
873          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
874          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
875          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
876          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
877          $form->setRegroupe('avis','G','');          //$form->setRegroupe('avis_decision','G','');
878          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
879          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
880          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
881          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
882          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
883                    
884          // demandeur          // demandeur
885          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
# Line 849  class dossier extends dossier_gen { Line 919  class dossier extends dossier_gen {
919                    
920          // localisation          // localisation
921          $form->setRegroupe('parcelle','D',_('localisation'), $this->aff_localisation);          $form->setRegroupe('parcelle','D',_('localisation'), $this->aff_localisation);
922          $form->setRegroupe('pos','F','');          $form->setRegroupe('pos','G','');
923          //$form->setRegroupe('sig','G','');          $form->setRegroupe('sig','F','');
924          //$form->setRegroupe('siglien','F','');          if($maj==1){
925                $form->setRegroupe('sig','G','');
926                $form->setRegroupe('geom','F','');
927            }
928                    
929          // description          // description
930          $form->setRegroupe('batiment_nombre','D',_('description'), $this->aff_description);          $form->setRegroupe('batiment_nombre','D',_('statistique'), $this->aff_description);
931          $form->setRegroupe('logement_nombre','G','');          $form->setRegroupe('logement_nombre','G','');
932          $form->setRegroupe('hauteur','G','');          $form->setRegroupe('hauteur','G','');
933          $form->setRegroupe('piece_nombre','G','');                  $form->setRegroupe('piece_nombre','G','');        
# Line 862  class dossier extends dossier_gen { Line 935  class dossier extends dossier_gen {
935          $form->setRegroupe('shon_calcul','G','');          $form->setRegroupe('shon_calcul','G','');
936          $form->setRegroupe('shob','G','');          $form->setRegroupe('shob','G','');
937          $form->setRegroupe('lot','F','');          $form->setRegroupe('lot','F','');
938          // temp          
939            $form->setRegroupe('description','D',_('description').' '._('servitude'), $this->aff_amenagement);
940            $form->setRegroupe('servitude','F','');
941            
942            // amenagement
943            $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
944            $form->setRegroupe('parcelle_lot','G','');
945            $form->setRegroupe('parcelle_lot_lotissement','F','');
946            
947      }      }
948    
   
   
949      /* =============================================================      /* =============================================================
950      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
951      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
952        * utilisé aussi pour envoyer une message au service REST d'ERP
953      * ===============================================================      * ===============================================================
954      */      */
955    
   
956      function triggerajouterapres($id,&$db,$val,$DEBUG) {      function triggerajouterapres($id,&$db,$val,$DEBUG) {
957          if (file_exists ("../dyn/var.inc"))          $this->sig_parametre($db);
             include ("../dyn/var.inc");  
         if(!isset($sig)) $sig=0;  
         if(!isset($auto_pos)) $auto_pos=0;  
958          $id=$this->valF['dossier']; // id n est pas valorise en ajout          $id=$this->valF['dossier']; // id n est pas valorise en ajout
959          if($sig==1 ){          if($this->sig==1 and $val['sig']!='Oui'){
960              if($val['parcelle']!='')              if($val['parcelle']!=''or $val['parcelle_lot']!=''){
961                  $this->sig_interne($id,&$db,$val,$DEBUG,$auto_pos);                      
962                    $this->sig_interne($id,$db,$val,$DEBUG);
963                }
964              else              else
965                  $this->msg = $this->msg."<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>";                      $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
966                
967            }
968            
969            
970            if ($this->f->getParameter('option_erp') != "") {
971                // envoi du message a ERP en cas d'un depot du dossier dat
972                if ($this->getDATDCode($this->valF['dossier']) ==
973                        $this->f->getParameter('erp_depot_dossier_dat')) {
974                    $msgenque = new MessageEnqueuer();
975                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
976                    $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
977                }
978                
979                // envoi du message a ERP en cas d'une demande d'ouverture DAT
980                if ($this->getDATDCode($this->valF['dossier']) ==
981                        $this->f->getParameter('erp_demande_ouverture_dat')) {
982                    $msgenque = new MessageEnqueuer();
983                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
984                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
985                }
986                
987                if ($this->valF['erp'] === true) {
988                    // envoi du message a ERP en cas d'annulation d'une demande
989                    if ($this->getDATDCode($this->valF['dossier']) ==
990                            $this->f->getParameter('erp_annulation_demande')) {
991                        $msgenque = new MessageEnqueuer();
992                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
993                        $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
994                    }
995                    
996                    // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
997                    // au dossier DAACT
998                    if ($this->getDATDCode($this->valF['dossier']) ==
999                            $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
1000                        $msgenque = new MessageEnqueuer();
1001                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1002                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
1003                    }
1004                }
1005            } // fin de if ($this->f->getParameter('option_erp') != "")        
1006        }
1007        
1008        /*
1009         * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
1010         * */
1011         function getQuartierArrondissement($parcelle) {
1012                
1013             $parcelle = trim($parcelle);
1014             $quartier = '';
1015            
1016             /*Récupère le code impot du quartier dans la parcelle*/
1017             for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
1018                    
1019                if (is_numeric($parcelle[$i]) ){
1020                        
1021                    $quartier .= $parcelle[$i];
1022                }
1023                else{
1024                        
1025                    break;
1026                }
1027             }
1028            
1029            if ( $quartier !== '' ){
1030                
1031                /*identifiant*/
1032                $sql = "SELECT
1033                            quartier, arrondissement
1034                        FROM
1035                            ".DB_PREFIXE."quartier
1036                        WHERE
1037                            code_impots='$quartier'";
1038                
1039                $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
1040                $res = $this->db->query($sql);
1041                if (database :: isError($res))
1042                    die($res->getMessage()."erreur ".$sql);
1043                
1044                if ( $res->numRows() > 0 ){
1045                        
1046                    return $res->fetchRow(DB_FETCHMODE_ASSOC);
1047                }
1048            }
1049            
1050            return NULL;
1051         }
1052        
1053         /*
1054         * Retourne la section d'une parcelle
1055         * */
1056         function getSection($parcelle){
1057            
1058             $parcelle = trim($parcelle);
1059             $section = NULL;
1060            
1061             for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
1062                if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
1063                    $section .= $parcelle[$i];
1064            
1065             return $section;
1066         }
1067        
1068        /*
1069         * Retourne l'intructeur correspondant le mieux à la parcelle
1070         * */
1071         function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
1072                    
1073            $quartier = ( $quartier == NULL ) ? -1 : $quartier;
1074            $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
1075            
1076            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
1077            $sql = "
1078               SELECT
1079                   dossier_autorisation_type_detaille
1080               FROM
1081                   ".DB_PREFIXE."dossier_autorisation
1082               WHERE
1083                   dossier_autorisation = '$dossier_autorisation'";    
1084            
1085            $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1086            $resDATD = $this->db->query($sql);
1087            if (database :: isError($resDATD))
1088                die($resDATD->getMessage()."erreur ".$sql);
1089            
1090            if ( $resDATD->numRows() > 0 ){
1091                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
1092                
1093                $sql = "
1094                   SELECT
1095                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
1096                   FROM
1097                       ".DB_PREFIXE."affectation_automatique l
1098                   WHERE
1099                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1100                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1101                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1102                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1103                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1104                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1105                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1106                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
1107                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1108                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1109                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1110                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1111                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1112                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1113                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1114                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
1115                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
1116                   LIMIT 1
1117                ";
1118                
1119                $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1120                $res = $this->db->query($sql);
1121                if (database :: isError($res))
1122                    die($res->getMessage()."erreur ".$sql);
1123                
1124                if ( $res->numRows() > 0 ){
1125                    
1126                    $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1127                    
1128                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
1129                    $res = $this->db->query($sql);
1130                    if (database :: isError($res))
1131                        die($res->getMessage()."erreur ".$sql);
1132                        
1133                    if ( $res->numRows() > 0 ){
1134                        
1135                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1136                        $row['division'] = $rowT['division'];
1137                    }
1138                    
1139                    return $row;
1140                }
1141            }
1142    
1143            return NULL;
1144         }
1145        
1146        /* =============================================================
1147        * fonction trigger relative a la connexion SIG
1148        * $sig = 1 dans dyn/var.inc
1149        * ===============================================================
1150        */
1151    
1152        function triggerajouter($id,&$db,$val,$DEBUG) {
1153            //
1154            $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
1155            
1156            // Initialisation des variables nécessaires à l'affectation automatique
1157            $quartier = NULL;
1158            $arrondissement = NULL;
1159            $section = NULL;
1160            $instructeur = NULL;
1161            
1162            // Si la parcelle n'est pas vide alors on récupère la section, le
1163            // quartier et l'arrondissement
1164            if ($val['parcelle'] != '') {
1165                // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
1166                $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
1167                if ( $quartierArrondissement!= NULL ){
1168                    
1169                    $quartier = $quartierArrondissement['quartier'];
1170                    $arrondissement = $quartierArrondissement['arrondissement'];
1171                }
1172                // Si il n'y a pas d'arrondissement alors on vide le quartier
1173                if ( strcmp($arrondissement,'') == 0 )  {
1174                    
1175                    $arrondissement = NULL;
1176                    $quartier = NULL;
1177                }
1178                // On récupère la section
1179                $section = $this->getSection($val['parcelle']);
1180          }          }
1181            
1182            // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1183            // alors on récupère l'instructeur et la division depuis l'affectation
1184            if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
1185                
1186                //
1187                $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1188                if ( $instructeurDivision != NULL ){
1189                    
1190                    $instructeur = $instructeurDivision['instructeur'];
1191                    $division = $instructeurDivision['division'];
1192                }
1193                
1194                if ( $instructeur != NULL ){
1195                    
1196                    $this->valF['instructeur'] = $instructeur;
1197                    $this->valF['division'] = $division;
1198                } else {
1199                    if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1200                        $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1201                    } else {
1202                        $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1203                    }
1204                }
1205            } else {
1206                $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1207            }
1208            //
1209            $this->addToLog("triggerajouter() : end", EXTRA_VERBOSE_MODE);
1210      }      }
1211    
1212      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
1213          if (file_exists ("../dyn/var.inc"))          $this->sig_parametre($db);
                 include ("../dyn/var.inc");  
         if(!isset($sig)) $sig=0;  
         if(!isset($auto_pos)) $auto_pos=0;  
1214          // si la parcelle est changée          // si la parcelle est changée
1215          if($sig==1 and $val['parcelle']!=$val['parcelle_archive']){          if(($this->sig==1 and $val['sig']!='Oui' and ($val['parcelle']!=$val['parcelle_archive'])
1216              if($val['parcelle']!='')             or $val['parcelle_lot']!=$val['parcelle_lot_archive'])){ // parcelle_lot_archive
1217                  $this->sig_interne($this->valF['dossier'],&$db,$val,$DEBUG,$auto_pos);              if($val['parcelle']!='' or $val['parcelle_lot']!='')
1218                    $this->sig_interne($this->valF['dossier'],$db,$val,$DEBUG);
1219                else{
1220                    if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
1221                    $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
1222                    $res = $db -> query($sql);
1223                    $this->addToLog("requete trigger modifier parcelle vide -> maj pos et servitude :".$sql, VERBOSE_MODE);
1224                    if (database :: isError($res))
1225                        die($res->getMessage()."erreur ".$sql);
1226                }
1227                    $this->addToMessage("<br>"._("Parcelle ou parcelle_lot non renseignee dans dossier")." ".$id." <br>");    
1228                }
1229            }
1230                    
1231            // verification si envoi vers ERP est active
1232            if ($this->f->getParameter('option_erp') != "") {
1233                if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1234                    && $this->valF['a_qualifier'] === false) {
1235                                    
1236                    // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1237                    // de la qualification URBA
1238                    if ($this->getDATDCode($this->valF['dossier']) ==
1239                                 $this->f->getParameter('erp_nature_dat')) {
1240                        $msgenque = new MessageEnqueuer();
1241                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1242                        $msgenque->setCompetence($this->valF['autorite_competente']);
1243                        $msgenque->setContraintePlu($this->valF['servitude']);
1244                        $msgenque->setReferenceCadastrale(
1245                                $this->getReferenceCadastrale($this->valF['dossier']));
1246                        $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1247                    }
1248                    
1249                    // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1250                    // qui etait classifie come ERP
1251                    if ($this->getDATDCode($this->valF['dossier']) ==
1252                            $this->f->getParameter('erp_dossier_nature_pc')
1253                        && $this->valF['erp'] == true) {
1254                        $msgenque = new MessageEnqueuer();
1255                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1256                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1257                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1258                    }
1259                }
1260            } // fin de if($this->f->getParameter('option_erp'))
1261        }
1262    
1263        /**
1264         * Retourne le type de dossier d'autorisation du dossier courant :
1265         *  - dossier_autorisation_type_detaille.code
1266         **/
1267        function getDATDCode($idxDossier) {
1268            $sql = "SELECT dossier_autorisation_type_detaille.code
1269                    FROM ".DB_PREFIXE."dossier_autorisation_type_detaille
1270                    INNER JOIN ".DB_PREFIXE."dossier_autorisation
1271                        ON dossier_autorisation_type_detaille.dossier_autorisation_type_detaille =
1272                           dossier_autorisation.dossier_autorisation_type_detaille
1273                    INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier_autorisation = dossier_autorisaiton.dossier_autorisation
1274                    WHERE dossier.dossier = ".$idxDossier;
1275            $res = $db -> getOne($sql);
1276            $this->f->isDatabaseError();
1277            return $res;
1278        }
1279        
1280        
1281        /**
1282         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1283         * specifique
1284         * @param string $dossier L'identifiant du dossier
1285         * @return string|null La reference cadastrale si elle est trouve,
1286         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1287         */
1288        function getReferenceCadastrale($dossier) {
1289            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1290            $res = $this->db->limitquery($sql, 0, 1);
1291            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1292                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1293            // Si une erreur survient on die
1294            if (database::isError($res, true)) {
1295                // Appel de la methode de recuperation des erreurs
1296                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1297            }
1298            // retourne la nature du dossier
1299            while ($row =& $res->fetchRow()) {
1300                return $row[0];
1301          }          }
1302            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1303            return NULL;
1304        }
1305        
1306    
1307        function sig_parametre(&$db){
1308            if (file_exists ("../dyn/var.inc"))
1309                include ("../dyn/var.inc");
1310            if(!isset($sig))
1311                $this->sig=0;
1312            else
1313                $this->sig=1;
1314            if(!isset($auto_pos))
1315                $this->auto_pos=0;
1316            else
1317                $this->auto_pos=$auto_pos;
1318            if(!isset($auto_servitude_surfacique))
1319                $this->auto_servitude_surfacique=0;
1320            else
1321                $this->auto_servitude_surfacique=$auto_servitude_surfacique;
1322            if(!isset($auto_servitude_ligne))
1323                $this->auto_servitude_ligne=0;
1324            else
1325                $this->auto_servitude_ligne=$auto_servitude_ligne;
1326            if(!isset($auto_servitude_point))
1327                $this->auto_servitude_point=0;
1328            else
1329                $this->auto_servitude_point=$auto_servitude_point;
1330            if(!isset($auto_parcelle))
1331                $this->auto_parcelle=0;
1332            else
1333                $this->auto_parcelle=$auto_parcelle;
1334            if(!isset($auto_parcelle_lot))
1335                $this->auto_parcelle_lot=0;
1336            else
1337                $this->auto_parcelle_lot=$auto_parcelle_lot;
1338            $this->addToLog("trigger valeur sig :".$this->sig, VERBOSE_MODE);
1339            $this->addToLog("trigger valeur auto_pos :". $this->auto_pos, VERBOSE_MODE);
1340            $this->addToLog("trigger valeur auto_servitude_surfacique :".$this->auto_servitude_surfacique, VERBOSE_MODE);
1341            $this->addToLog("trigger valeur auto_servitude_ligne :". $this->auto_servitude_ligne, VERBOSE_MODE);
1342            $this->addToLog("trigger valeur auto_servitude_point :".$this->auto_servitude_point, VERBOSE_MODE);
1343            $this->addToLog("trigger valeur auto_parcelle :". $this->auto_parcelle, VERBOSE_MODE);
1344            $this->addToLog("trigger valeur auto_parcelle_lot :".$this->auto_parcelle_lot, VERBOSE_MODE);
1345      }      }
1346    
1347      function sig_interne($id,&$db,$val,$DEBUG,$auto_pos){  
1348        function sig_interne($id,&$db,$val,$DEBUG){
1349          // Strategy interne dans var.inc          // Strategy interne dans var.inc
1350          // si la parcelle existe, il est cree un point au milieu de la parcelle          // si la parcelle existe, il est cree un point au milieu de la parcelle
1351          // de maniere automatique          // de maniere automatique
1352            $geom='';
1353            $parcelle=$val["parcelle"];
1354          $projection = $db -> getOne("select srid from geometry_columns where f_table_name='dossier'");          $projection = $db -> getOne("select srid from geometry_columns where f_table_name='dossier'");
1355          $sql= "select astext(centroid(geom)) from parcelle where parcelle ='".$val["parcelle"]."'";          if($this->auto_parcelle==1  and $val["parcelle"]!=''){
1356          $geom = $db -> getOne($sql);              $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle where parcelle ='".$val["parcelle"]."'";
1357          if($geom!=''){ // la parcelle est exitante dans la table / vue parcelle              $this->addToLog("recherche centroid parcelle :".$sql, VERBOSE_MODE);
1358              $sql ="update dossier set geom =geometryfromtext('".$geom."', ".$projection." ) where dossier ='".$id."'";              $geom = $db -> getOne($sql);
1359                if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1360            }
1361            if($geom=='' and $this->auto_parcelle_lot==1 and $val["parcelle_lot"]!=''){ // lot
1362                $sql= "select astext(centroid(geom)) from ".DB_PREFIXE."parcelle_lot where parcelle_lot ='".$val["parcelle_lot"]."'";
1363                $this->addToLog("recherche centroid parcelle lot :".$sql, VERBOSE_MODE);
1364                $geom = $db -> getOne($sql);
1365                if (database :: isError($geom))die($res->getMessage()."erreur ".$sql);
1366                $parcelle=$val["parcelle_lot"]." ".$val["parcelle_lot_lotissement"];
1367            }
1368            if($geom!=''){ // la parcelle est exitante dans la table ou vue parcelle
1369                $sql ="update ".DB_PREFIXE."dossier set geom =geometryfromtext('".$geom."', ".$projection." ) where dossier ='".$id."'";
1370                $this->addToLog("sig_interne maj geom  :".$sql, VERBOSE_MODE);    
1371              $res = $db -> query($sql);              $res = $db -> query($sql);
1372              if (database :: isError($res)){              if (database :: isError($res)) die($res->getMessage()."erreur ".$sql);
1373                  die($res->getMessage()."erreur ".$sql);              $this->addToMessage(""._("centroid de parcelle calcule")." ".$parcelle." ");
1374              }else{              if($this->auto_pos==1) // recherche du pos
1375                  $this->msg = $this->msg."<br>"._("centroid de parcelle calculé")." ".$val["parcelle"].                  $this->calcul_auto_pos($id,$db,$geom,$projection);
1376                      " "._("dossier")." ".$id."<br>";              if($this->auto_servitude_surfacique==1) // recherche de servitude surfacique
1377              }                  $this->calcul_auto_servitude_surfacique($id,$db,$geom,$projection);
1378              if($auto_pos==1) // recherche du pos              if($this->auto_servitude_ligne==1) // recherche de servitude ligne
1379                  $this->auto_pos($id,$db,$geom,$projection);                  $this->calcul_auto_servitude_ligne($id,$db,$geom,$projection);
1380          }else{ // parcelle inexistante              if($this->auto_servitude_point==1) // recherche de servitude point
1381                    $this->calcul_auto_servitude_point($id,$db,$geom,$projection);
1382                $temp=strtr($this->servitude,"'"," "); // enleve le '
1383                $sql1 ="update ".DB_PREFIXE."dossier set servitude = '".$temp."' where dossier = '".$id."'";
1384                $res1 = $db -> query($sql1);
1385                $this->addToLog("maj servitudes :".$sql1, VERBOSE_MODE);
1386                if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1387            }else{ // parcelle inexistante //***
1388              if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante              if($this->maj ==1){ // en maj mettre a null la geometrie si parcelle changée inexistante
1389                  $sql ="update dossier set geom = null where dossier ='".$id."'";                  $sql ="update ".DB_PREFIXE."dossier set geom = null, servitude = '', pos= '' where dossier ='".$id."'";
1390                  $res = $db -> query($sql);                  $res = $db -> query($sql);
1391                    $this->addToLog("requete sig_interne maj parcelle inexistante :".$sql, VERBOSE_MODE);
1392                  if (database :: isError($res))                  if (database :: isError($res))
1393                      die($res->getMessage()."erreur ".$sql);                      die($res->getMessage()."erreur ".$sql);
1394              }              }
1395              $this->msg = $this->msg."<br> parcelle ".$val["parcelle"]." "._("inexistante")." ".$id."<br>";              //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
1396          }          }
1397      }      }
1398    
1399      function auto_pos($id,&$db,$geom,$projection){      function calcul_auto_pos($id,&$db,$geom,$projection){
1400          // recherche du pos automatique dans le geom de la table / vue pos          // recherche du pos automatique
1401          $sql="select pos from pos  WHERE ST_contains(geom,  geometryfromtext('".$geom."', ".$projection."))";          $sql="select pos from ".DB_PREFIXE."pos  WHERE ST_contains(geom,  geometryfromtext('".$geom."', ".$projection."))";
1402          $pos = $db -> getOne($sql);          $pos = $db -> getOne($sql);
1403            $this->addToLog("recherche auto_pos :".$sql, VERBOSE_MODE);
1404          if($pos!=''){          if($pos!=''){
1405              $sql1 ="update dossier set pos = '".$pos."' where dossier = '".$id."'";              $sql1 ="update ".DB_PREFIXE."dossier set pos = '".$pos."' where dossier = '".$id."'";
1406              $res1 = $db -> query($sql1);              $res1 = $db -> query($sql1);
1407              if (database:: isError($res1)){ // ok              $this->addToLog("maj auto_pos :".$sql1, VERBOSE_MODE);
1408                  die($res1->getMessage()."erreur ".$sql1);              if (database:: isError($res1)) die($res1->getMessage()."erreur ".$sql1);
1409              }else{              $this->addToMessage("<br>"._("POS/PLU")." : ".$pos."");
                     $this->msg = $this->msg."<br>"._("POS/PLU renseignee automatiquement dans dossier")." ".$id." -> ".$pos."<br>";  
             }  
1410          }else{          }else{
1411              $this->msg = $this->msg."<br>"._("POS/PLU non trouvé pour dossier")." ".$id."<br>";              $this->addToMessage("<br>"._("POS/PLU non trouve")." ".$id."");
1412          }          }
1413      }      }
1414    
1415        function calcul_auto_servitude_surfacique($id,&$db,$geom,$projection){
1416            // recherche servitude surfacique
1417            $sql="select * from ".DB_PREFIXE."servitude_surfacique WHERE ST_contains(geom,  geometryfromtext('".$geom."', ".$projection."))";
1418            $res=$db->query($sql);
1419            if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1420            $this->addToLog("requete  :".$sql." executee ", VERBOSE_MODE);
1421            while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1422                $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1423                $this->servitude.="  [".$row['libelle']."] ".$row['observation']." - ";
1424           }
1425        }
1426    
1427        function calcul_auto_servitude_ligne($id,&$db,$geom,$projection){
1428            // recherche servitude ligne
1429            $sql="select * from ".DB_PREFIXE."servitude_ligne WHERE ST_contains(ST_buffer(geom, perimetre),  geometryfromtext('".$geom."', ".$projection."))";
1430            $res=$db->query($sql);
1431            if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1432            $this->addToLog("requete  :".$sql." executee ", VERBOSE_MODE);
1433            while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1434                $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']);
1435                $this->servitude.="  [".$row['libelle']."] ".$row['observation']." - ";
1436           }
1437        }
1438    
1439        function calcul_auto_servitude_point($id,&$db,$geom,$projection){
1440            // recherche servitude point
1441            $sql="select libelle,observation, perimetre, distance(geom, geometryfromtext('".$geom."', ".$projection.")) as distance from ".
1442                DB_PREFIXE."servitude_point WHERE distance(geom,  geometryfromtext('".$geom."', ".$projection."))<perimetre";
1443            $res=$db->query($sql);
1444            if (database:: isError($res)) die($res1->getMessage()."erreur ".$sql);
1445            $this->addToLog("requete  :".$sql." executee ", VERBOSE_MODE);
1446            while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
1447                $this->addToMessage("<br>"._("servitude")." : ".$row['libelle']." - ".$row['observation']." a ".round($row['distance'],2)." m ");
1448                $this->servitude.="  [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";
1449           }
1450        }
1451  }// fin classe  }// fin classe
1452  ?>  ?>

Legend:
Removed from v.44  
changed lines
  Added in v.1187

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26