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

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26