/[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 446 by nhaye, Tue Sep 25 16:45:31 2012 UTC revision 1358 by vpihour, Mon Mar 11 14:48:17 2013 UTC
# Line 3  Line 3 
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("../services/outgoing/messageenqueuer.php");
7    
8  class dossier extends dossier_gen {  class dossier extends dossier_gen {
9    
# Line 15  class dossier extends dossier_gen { Line 16  class dossier extends dossier_gen {
16      var $auto_servitude_point;      var $auto_servitude_point;
17      var $auto_parcelle;      var $auto_parcelle;
18      var $auto_parcelle_lot;      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        /**
45         * Surcharge pour gérer les actions disponibles dans le portlet
46         */
47        function checkAccessibility() {
48            //
49            parent::checkAccessibility();
50            // Si l'utilisateur est un intructeur qui en correspond pas à la
51            // division du dossier
52            if ($this->f->isUserInstructeur()
53                && isset($this->f->om_utilisateur["division"])
54                && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) {
55                //
56                $this->actions_sup = array();
57                $this->setParameter("actions", array());
58            }
59        }
60    
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        /**
79         * Cette méthode permet de récupérer la division d'un dossier
80         */
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()) {      function setValFAjout($val = array()) {
103          // Cle primaire          
104          $lettre=$this->f->collectivite["lettre"];          /*Récupération de la lettre associé au type de dossier d'instruction*/
105          $numero_unique = $this->f->collectivite["numero_unique"];          $code = $this->getCode($this->getDossierInstructionType());
106          if($numero_unique==1){          
107          // numero unique (voir dyn/var.inc)          /* Récupération de la valeur du suffixe ce dossier_instruction_type */
108          $temp=$this->$db->nextId(DB_PREFIXE.$this->table);          $suffixe = $this->getSuffixe($this->getDossierInstructionType());
109          }else{          
110          // numero suivant nature          /*S'il est à TRUE, on récupère le numéro de version du dossier d'autorisation*/
111          $temp=$this->db->nextId(DB_PREFIXE."dossier_".$this->nature);          $numeroVersion = "";
112            if ( $suffixe == 't' ){
113                
114                $numeroVersion = $this->getNumeroVersion($val['dossier_autorisation']);
115                
116                /* Incrémentation du numéro de version */
117                if ( is_numeric($numeroVersion) or $numeroVersion == -1 ){
118                    
119                    $this->incrementNumeroVersion($val['dossier_autorisation'], ++$numeroVersion);
120                }
121          }          }
122          $temp=str_pad($temp,4,"0", STR_PAD_LEFT);          
123          $this->valF['dossier'] = $this->valF['nature'].$this->valF['annee'].          /*Création du numéro de dossier*/
124                                   $lettre.$temp;          $this->valF['dossier'] = $val['dossier_autorisation']."$code$numeroVersion";
125      }      }
126    
127        /*Récupère la valeur du suffixe d'un dossier_instruction_type*/
128        function getSuffixe($dossierInstructionType){
129            
130            $suffixe = "";
131            
132            $sql = "SELECT
133                        suffixe
134                    FROM
135                        ".DB_PREFIXE."dossier_instruction_type
136                    WHERE
137                        dossier_instruction_type = $dossierInstructionType";
138                        
139            $this->addToLog("getSuffixe(): db->query(\"".$sql."\")", VERBOSE_MODE);
140            $res = $this->db->query($sql);
141            if (database :: isError($res))
142                die($res->getMessage()."erreur ".$sql);
143                
144            if ( $res->numRows() > 0 ){
145                
146                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
147                $suffixe =  $row['suffixe'];
148            }
149            
150            return $suffixe;
151        }
152        
153        /*Récupère dans la table de paramètrage la lettre correspondant
154         * au dossier_instruction_type
155         */
156        function getCode($dossierInstructionType){
157            
158            $code = "";
159            
160            $sql = "SELECT
161                        code
162                    FROM
163                        ".DB_PREFIXE."dossier_instruction_type
164                    WHERE
165                        dossier_instruction_type = $dossierInstructionType";
166                        
167            $this->addToLog("getCode(): db->query(\"".$sql."\")", VERBOSE_MODE);
168            $res = $this->db->query($sql);
169            if (database :: isError($res))
170                die($res->getMessage()."erreur ".$sql);
171                
172            if ( $res->numRows() > 0 ){
173                
174                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
175                $code =  $row['code'];
176            }
177            
178            return $code;
179        }
180        
181        /*Récupère le numéro de version d'un dossier_autorisation*/
182        function getNumeroVersion($dossierAutorisation){
183            
184            $numeroVersion = "";
185            
186            $sql = "SELECT
187                        numero_version
188                    FROM
189                        ".DB_PREFIXE."dossier_autorisation
190                    WHERE
191                        dossier_autorisation = '$dossierAutorisation'";
192                        
193            $this->addToLog("getNumeroVersion(): db->query(\"".$sql."\")", VERBOSE_MODE);
194            $res = $this->db->query($sql);
195            if (database :: isError($res))
196                die($res->getMessage()."erreur ".$sql);
197                
198            if ( $res->numRows() > 0 ){
199                
200                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
201                $numeroVersion =  $row['numero_version'];
202            }
203            
204            return $numeroVersion;
205        }
206        
207        /*Incrémente le numéro de version du dossier*/
208        function incrementNumeroVersion($dossierAutorisation, $nouveauNumeroVersion) {
209            
210            $valF = array (
211                        "numero_version" => $nouveauNumeroVersion
212                    );
213            
214            $res = $this->db->autoExecute(DB_PREFIXE."dossier_autorisation",
215                                        $valF,
216                                        DB_AUTOQUERY_UPDATE,
217                                        "dossier_autorisation = '$dossierAutorisation'");
218                                        
219            if (database :: isError($res))
220                die($res->getMessage()."erreur ".$sql);
221                
222        }
223        
224      function setvalF($val){      function setvalF($val){
225          parent::setvalF($val);          parent::setvalF($val);
226          // enlever les valeurs a ne pas saisir -> recherche en trigger ajouter et modifier          // enlever les valeurs a ne pas saisir -> recherche en trigger ajouter et modifier
# Line 46  class dossier extends dossier_gen { Line 235  class dossier extends dossier_gen {
235              unset ($this->valF['accord_tacite']);              unset ($this->valF['accord_tacite']);
236              unset ($this->valF['types']);              unset ($this->valF['types']);
237          }          }
238          unset ($this->valF['avis']); // avis + libelle avis          unset ($this->valF['avis_decision']); // avis + libelle avis
239          unset ($this->valF['terrain_surface_calcul']);          unset ($this->valF['terrain_surface_calcul']);
240          unset ($this->valF['shon_calcul']);          unset ($this->valF['shon_calcul']);
241          unset ($this->valF['parcelle_archive']);          unset ($this->valF['parcelle_archive']);
# Line 60  class dossier extends dossier_gen { Line 249  class dossier extends dossier_gen {
249          unset ($this->valF['date_conformite']);          unset ($this->valF['date_conformite']);
250      }      }
251    
252        /*Vérification des données saisies*/
253      function verifier($val,&$db,$DEBUG){      function verifier($val,&$db,$DEBUG){
254          parent::verifier($val,$db,$DEBUG);          parent::verifier($val,$db,$DEBUG);
255          if($val['parcelle']!="" and $val['sig']!='Oui'){          if($val['parcelle']!="" and $val['sig']!='Oui'){
256              if  (!preg_match('/^[A-Z0-9]{1}[A-Z]{1}[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'])){    
257                  $this->correct=false;                  $this->correct=false;
258                  $this->addToMessage("<br>format parcelle AANNNN");                  $this->addToMessage("<br>format parcelle incorrect");
259              }              }
260          }          }
261          // regles travaux verification          // regles travaux verification
# Line 192  class dossier extends dossier_gen { Line 382  class dossier extends dossier_gen {
382              // cache              // cache
383              if($maj==0) $form->setType('dossier', 'hidden');              if($maj==0) $form->setType('dossier', 'hidden');
384              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
             $form->setType('nature', 'hidden');  
385              $form->setType('parcelle_archive','hidden');              $form->setType('parcelle_archive','hidden');
386              $form->setType('parcelle_lot_archive','hidden');              $form->setType('parcelle_lot_archive','hidden');
387              $form->setType('objet_dossier','hidden'); // PC              $form->setType('objet_dossier','hidden'); // PC
# Line 217  class dossier extends dossier_gen { Line 406  class dossier extends dossier_gen {
406              // hiddenstatic              // hiddenstatic
407              if($maj==1) $form->setType('dossier', 'hiddenstatic');              if($maj==1) $form->setType('dossier', 'hiddenstatic');
408              $form->setType('etat','hiddenstatic');              $form->setType('etat','hiddenstatic');
409              $form->setType('avis','hiddenstatic');              $form->setType('avis_decision','hiddenstatic');
410              $form->setType('delai','hiddenstatic');              $form->setType('delai','hiddenstatic');
411              $form->setType('terrain_surface_calcul','hiddenstatic');              $form->setType('terrain_surface_calcul','hiddenstatic');
412              $form->setType('shon_calcul','hiddenstatic');              $form->setType('shon_calcul','hiddenstatic');
# Line 263  class dossier extends dossier_gen { Line 452  class dossier extends dossier_gen {
452              $form->setType('temp3',$temp3_type);              $form->setType('temp3',$temp3_type);
453              $form->setType('temp4',$temp4_type);              $form->setType('temp4',$temp4_type);
454              $form->setType('temp5',$temp5_type);              $form->setType('temp5',$temp5_type);
455                $form->setType('a_qualifier', 'checkbox');
456            }
457            if ($maj == 1) {
458                //
459                if ($this->f->isAccredited("dossier_modifier_instructeur")) {
460                    $form->setType('instructeur', 'select');
461                } else {
462                    $form->setType('instructeur', 'selecthiddenstatic');
463                }
464                //
465                if($this->f->getParameter('afficher_division') === 'true') {
466                    //
467                    if ($this->f->isAccredited("dossier_modifier_division")) {
468                        $form->setType('division', 'select');
469                    } else {
470                        $form->setType('division', 'selecthiddenstatic');
471                    }
472                } else {
473                    $form->setType('division', 'hidden');
474                }
475          }          }
476          if($maj == 3) {          if($maj == 3) {
477              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
             $form->setType('nature', 'hidden');  
478              $form->setType('temp1','hidden');              $form->setType('temp1','hidden');
479              $form->setType('temp2','hidden');              $form->setType('temp2','hidden');
480              $form->setType('temp3','hidden');              $form->setType('temp3','hidden');
# Line 276  class dossier extends dossier_gen { Line 484  class dossier extends dossier_gen {
484              $form->setType('parcelle_lot_archive','hidden');              $form->setType('parcelle_lot_archive','hidden');
485              $form->setType('geom1','hidden');              $form->setType('geom1','hidden');
486              $form->setType('geom','hidden');              $form->setType('geom','hidden');
487                $form->setType('a_qualifier', 'checkboxstatic');
488            }
489            //
490            if(!$this->f->getParameter('afficher_division') === 'true') {
491                $form->setType('division', 'hidden');
492            }
493            $form->setType('dossier_autorisation', 'hiddenstatic');
494            $form->setType('dossier_instruction_type', 'selecthiddenstatic');
495            //
496            if ($maj == 0) {
497                $form->setType('dossier_autorisation', 'select');
498            }
499            // On cache enjeu_ERP si l'option n'est pas activée
500            if($this->f->getParameter('option_ERP') != 'true') {
501                $form->setType('erp', 'hidden');
502                $form->setType('enjeu_erp', 'hidden');
503          }          }
504      }      }
505    
# Line 283  class dossier extends dossier_gen { Line 507  class dossier extends dossier_gen {
507          $this->maj=$maj;          $this->maj=$maj;
508          if ($validation==0) {          if ($validation==0) {
509              if ($maj == 0){              if ($maj == 0){
510                  $dossier_cp = $this->f->collectivite["cp"];                  //$dossier_cp = $this->f->collectivite["cp"];
511                  $dossier_ville = $this->f->collectivite["ville"];                  //$dossier_ville = $this->f->collectivite["ville"];
                 $form->setVal('nature', $this->nature);  
512                                
513                  $form->setVal('annee', date('y'));                  $form->setVal('annee', date('y'));
514                  $form->setVal('date_demande', date('Y-m-d'));                  $form->setVal('date_demande', date('Y-m-d'));
515                  $form->setVal('date_depot', date('Y-m-d'));                  $form->setVal('date_depot', date('Y-m-d'));
516                                
517                  $form->setVal('demandeur_cp', $dossier_cp);                  //$form->setVal('demandeur_cp', $dossier_cp);
518                  $form->setVal('demandeur_ville', $dossier_ville);                  //$form->setVal('demandeur_ville', $dossier_ville);
519                                
520                  $form->setVal('delegataire_cp', $dossier_cp);                  //$form->setVal('delegataire_cp', $dossier_cp);
521                  $form->setVal('delegataire_ville', $dossier_ville);                  //$form->setVal('delegataire_ville', $dossier_ville);
522                                
523                  $form->setVal('terrain_cp', $dossier_cp);                  //$form->setVal('terrain_cp', $dossier_cp);
524                  $form->setVal('terrain_ville', $dossier_ville);                  //$form->setVal('terrain_ville', $dossier_ville);
525                                
526                  $form->setVal('accord_tacite', 'Non');                  $form->setVal('accord_tacite', 'Non');
527                  $form->setVal('etat', 'initialiser');                  $form->setVal('etat', 'initialiser');
# Line 379  class dossier extends dossier_gen { Line 602  class dossier extends dossier_gen {
602              $contenu=array();              $contenu=array();
603              $contenu[0]=array('Non','Oui');              $contenu[0]=array('Non','Oui');
604              $contenu[1]=array('Non','Oui');              $contenu[1]=array('Non','Oui');
             $form->setSelect("etat",$contenu);  
605              $form->setSelect("accord_tacite",$contenu);              $form->setSelect("accord_tacite",$contenu);
606              // terrain_numero_complement              // terrain_numero_complement
607              $contenu=array();              $contenu=array();
# Line 392  class dossier extends dossier_gen { Line 614  class dossier extends dossier_gen {
614                  $contenu[0]=array("dossier",$this->getParameter("idx"));                  $contenu[0]=array("dossier",$this->getParameter("idx"));
615                  $form->setSelect('geom',$contenu);                  $form->setSelect('geom',$contenu);
616              }              }
617                // arrondissement recherche anvancée
618                $this->init_select($form, $db, $maj, $debug, "arrondissement",
619                               $sql_arrondissement, $sql_arrondissement_by_id, false);
620                // dossier_autorisation_type_detaille recherche anvancée
621                $this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille",
622                               $sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false);
623                /*
624                 * Affichage de données dans le select de la parcelle
625                 * */
626                $contenu=array();
627                $sql="select parcelle from ".DB_PREFIXE."parcelle ";
628                $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) {      function setLib(&$form,$maj) {
# Line 402  class dossier extends dossier_gen { Line 652  class dossier extends dossier_gen {
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('annee','G');
662              $form->setGroupe('annee','G');          //    $form->setGroupe('date_demande','G');
663              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_depot','G');
664              $form->setGroupe('date_depot','G');          //    $form->setGroupe('division','F');
665              $form->setGroupe('instructeur','F');          //}
         }  
666          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
667          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
668          $form->setGroupe('demandeur_nom','F');          $form->setGroupe('demandeur_nom','F');
# Line 444  class dossier extends dossier_gen { Line 693  class dossier extends dossier_gen {
693          $form->setGroupe('delegataire_telephone','F');          $form->setGroupe('delegataire_telephone','F');
694                                
695          $form->setGroupe('architecte','D');          $form->setGroupe('architecte','D');
696          $form->setGroupe('architecte_nom','G');          $form->setGroupe('architecte_nom','F');
697          $form->setGroupe('saisie_architecte','F');          //$form->setGroupe('saisie_architecte','F');
698                    
699          $form->setGroupe('travaux','D');            $form->setGroupe('travaux','D');  
700          $form->setGroupe('travaux_complement','F');          $form->setGroupe('travaux_complement','F');
# Line 476  class dossier extends dossier_gen { Line 725  class dossier extends dossier_gen {
725          $form->setGroupe('etat','F');          $form->setGroupe('etat','F');
726                    
727          $form->setGroupe('date_decision','D');          $form->setGroupe('date_decision','D');
728          $form->setGroupe('avis','G');          $form->setGroupe('avis_decision','G');
729          $form->setGroupe('date_validite','G');          $form->setGroupe('date_validite','G');
730          $form->setGroupe('types','F');          $form->setGroupe('types','F');
731                    
# Line 529  class dossier extends dossier_gen { Line 778  class dossier extends dossier_gen {
778          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
779      }      }
780    
781      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
782          // depot          //
783          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
784              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
785          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
786          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
787              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
788              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
789          }          $form->setFieldset('date_demande', 'D', _("Depot"));
790          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
791          $form->setRegroupe('instructeur','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
792            $form->setFieldset('enjeu_erp', 'F');
793            $form->setBloc('enjeu_erp', 'F');
794            $form->setBloc('enjeu_erp', 'F');
795            //
796            $form->setBloc('objet_dossier', 'D', '', 'col_12');
797            //
798            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
799            $form->setRegroupe('date_conformite','F','');
800            //
801            $form->setBloc('terrain_superficie', 'F');
802                    
803        }
804        
805        function setRegroupe(&$form,$maj) {
806            //// depot
807            //If ($maj==0){
808            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
809            //}
810            //If ($maj==1){
811            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
812            //    $form->setRegroupe('date_demande','G','');
813            //}
814            //$form->setRegroupe('date_depot','G','');
815            //$form->setRegroupe('division','F','');
816    
817          // travaux          // travaux
818          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
819          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
820          $form->setRegroupe('travaux','G','');          $form->setRegroupe('travaux','G','');
821          $form->setRegroupe('travaux_complement','F','');          $form->setRegroupe('travaux_complement','F','');
822                    
823          // instruction          //// instruction
824          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
825          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
826          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
827          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
828          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
829          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
830          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
831          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
832          $form->setRegroupe('avis','G','');          //$form->setRegroupe('avis_decision','G','');
833          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
834          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
835          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
836          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
837          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
838                    
839          // demandeur          // demandeur
840          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
# Line 599  class dossier extends dossier_gen { Line 872  class dossier extends dossier_gen {
872          $form->setRegroupe('terrain_surface','G',_('surface'),'');// $this->aff_surface);          $form->setRegroupe('terrain_surface','G',_('surface'),'');// $this->aff_surface);
873          $form->setRegroupe('terrain_surface_calcul','F','');          $form->setRegroupe('terrain_surface_calcul','F','');
874                    
         // localisation  
         $form->setRegroupe('parcelle','D',_('localisation'), $this->aff_localisation);  
         $form->setRegroupe('pos','G','');  
         $form->setRegroupe('sig','F','');  
         if($maj==1){  
             $form->setRegroupe('sig','G','');  
             $form->setRegroupe('geom','F','');  
         }  
           
         // description  
         $form->setRegroupe('batiment_nombre','D',_('statistique'), $this->aff_description);  
         $form->setRegroupe('logement_nombre','G','');  
         $form->setRegroupe('hauteur','G','');  
         $form->setRegroupe('piece_nombre','G','');          
         $form->setRegroupe('shon','G','');  
         $form->setRegroupe('shon_calcul','G','');  
         $form->setRegroupe('shob','G','');  
         $form->setRegroupe('lot','F','');  
           
875          $form->setRegroupe('description','D',_('description').' '._('servitude'), $this->aff_amenagement);          $form->setRegroupe('description','D',_('description').' '._('servitude'), $this->aff_amenagement);
876          $form->setRegroupe('servitude','F','');          $form->setRegroupe('servitude','F','');
877                    
# Line 625  class dossier extends dossier_gen { Line 879  class dossier extends dossier_gen {
879          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
880          $form->setRegroupe('parcelle_lot','G','');          $form->setRegroupe('parcelle_lot','G','');
881          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
882            
883      }      }
884    
885      /* =============================================================      /* =============================================================
886      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
887      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
888        * utilisé aussi pour envoyer une message au service REST d'ERP
889      * ===============================================================      * ===============================================================
890      */      */
891    
# Line 637  class dossier extends dossier_gen { Line 893  class dossier extends dossier_gen {
893          $this->sig_parametre($db);          $this->sig_parametre($db);
894          $id=$this->valF['dossier']; // id n est pas valorise en ajout          $id=$this->valF['dossier']; // id n est pas valorise en ajout
895          if($this->sig==1 and $val['sig']!='Oui'){          if($this->sig==1 and $val['sig']!='Oui'){
896              if($val['parcelle']!=''or $val['parcelle_lot']!='')              if($val['parcelle']!=''or $val['parcelle_lot']!=''){
897                        
898                  $this->sig_interne($id,$db,$val,$DEBUG);                  $this->sig_interne($id,$db,$val,$DEBUG);
899                }
900              else              else
901                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                      $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
902                
903          }          }
904            
905            
906            if ($this->f->getParameter('option_erp') != "") {
907                // envoi du message a ERP en cas d'un depot du dossier dat
908                if ($this->getDATDCode($this->valF['dossier']) ==
909                        $this->f->getParameter('erp_depot_dossier_dat')) {
910                    $msgenque = new MessageEnqueuer();
911                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
912                    $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
913                }
914                
915                // envoi du message a ERP en cas d'une demande d'ouverture DAT
916                if ($this->getDATDCode($this->valF['dossier']) ==
917                        $this->f->getParameter('erp_demande_ouverture_dat')) {
918                    $msgenque = new MessageEnqueuer();
919                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
920                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
921                }
922                
923                if ($this->valF['erp'] === true) {
924                    // envoi du message a ERP en cas d'annulation d'une demande
925                    if ($this->getDATDCode($this->valF['dossier']) ==
926                            $this->f->getParameter('erp_annulation_demande')) {
927                        $msgenque = new MessageEnqueuer();
928                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
929                        $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
930                    }
931                    
932                    // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
933                    // au dossier DAACT
934                    if ($this->getDATDCode($this->valF['dossier']) ==
935                            $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
936                        $msgenque = new MessageEnqueuer();
937                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
938                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
939                    }
940                }
941            } // fin de if ($this->f->getParameter('option_erp') != "")        
942        }
943        
944        /*
945         * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
946         * */
947         function getQuartierArrondissement($parcelle) {
948                
949             $parcelle = trim($parcelle);
950             $quartier = '';
951            
952             /*Récupère le code impot du quartier dans la parcelle*/
953             for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
954                    
955                if (is_numeric($parcelle[$i]) ){
956                        
957                    $quartier .= $parcelle[$i];
958                }
959                else{
960                        
961                    break;
962                }
963             }
964            
965            if ( $quartier !== '' ){
966                
967                /*identifiant*/
968                $sql = "SELECT
969                            quartier, arrondissement
970                        FROM
971                            ".DB_PREFIXE."quartier
972                        WHERE
973                            code_impots='$quartier'";
974                
975                $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
976                $res = $this->db->query($sql);
977                if (database :: isError($res))
978                    die($res->getMessage()."erreur ".$sql);
979                
980                if ( $res->numRows() > 0 ){
981                        
982                    return $res->fetchRow(DB_FETCHMODE_ASSOC);
983                }
984            }
985            
986            return NULL;
987         }
988        
989         /*
990         * Retourne la section d'une parcelle
991         * */
992         function getSection($parcelle){
993            
994             $parcelle = trim($parcelle);
995             $section = NULL;
996            
997             for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
998                if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
999                    $section .= $parcelle[$i];
1000            
1001             return $section;
1002         }
1003        
1004        /*
1005         * Retourne l'intructeur correspondant le mieux à la parcelle
1006         * */
1007         function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
1008                    
1009            $quartier = ( $quartier == NULL ) ? -1 : $quartier;
1010            $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
1011            
1012            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
1013            $sql = "
1014               SELECT
1015                   dossier_autorisation_type_detaille
1016               FROM
1017                   ".DB_PREFIXE."dossier_autorisation
1018               WHERE
1019                   dossier_autorisation = '$dossier_autorisation'";    
1020            
1021            $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1022            $resDATD = $this->db->query($sql);
1023            if (database :: isError($resDATD))
1024                die($resDATD->getMessage()."erreur ".$sql);
1025            
1026            if ( $resDATD->numRows() > 0 ){
1027                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
1028                
1029                $sql = "
1030                   SELECT
1031                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
1032                   FROM
1033                       ".DB_PREFIXE."affectation_automatique l
1034                   WHERE
1035                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1036                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1037                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1038                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1039                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1040                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1041                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1042                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
1043                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1044                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1045                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1046                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1047                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1048                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1049                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1050                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
1051                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
1052                   LIMIT 1
1053                ";
1054                
1055                $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1056                $res = $this->db->query($sql);
1057                if (database :: isError($res))
1058                    die($res->getMessage()."erreur ".$sql);
1059                
1060                if ( $res->numRows() > 0 ){
1061                    
1062                    $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1063                    
1064                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
1065                    $res = $this->db->query($sql);
1066                    if (database :: isError($res))
1067                        die($res->getMessage()."erreur ".$sql);
1068                        
1069                    if ( $res->numRows() > 0 ){
1070                        
1071                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1072                        $row['division'] = $rowT['division'];
1073                    }
1074                    
1075                    return $row;
1076                }
1077            }
1078    
1079            return NULL;
1080         }
1081        
1082        /* =============================================================
1083        * fonction trigger relative a la connexion SIG
1084        * $sig = 1 dans dyn/var.inc
1085        * ===============================================================
1086        */
1087    
1088        function triggerajouter($id,&$db,$val,$DEBUG) {
1089            //
1090            $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
1091            
1092            // Initialisation des variables nécessaires à l'affectation automatique
1093            $quartier = NULL;
1094            $arrondissement = NULL;
1095            $section = NULL;
1096            $instructeur = NULL;
1097            
1098            // Si la parcelle n'est pas vide alors on récupère la section, le
1099            // quartier et l'arrondissement
1100            if ($val['parcelle'] != '') {
1101                // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
1102                $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
1103                if ( $quartierArrondissement!= NULL ){
1104                    
1105                    $quartier = $quartierArrondissement['quartier'];
1106                    $arrondissement = $quartierArrondissement['arrondissement'];
1107                }
1108                // Si il n'y a pas d'arrondissement alors on vide le quartier
1109                if ( strcmp($arrondissement,'') == 0 )  {
1110                    
1111                    $arrondissement = NULL;
1112                    $quartier = NULL;
1113                }
1114                // On récupère la section
1115                $section = $this->getSection($val['parcelle']);
1116            }
1117            
1118            // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1119            // alors on récupère l'instructeur et la division depuis l'affectation
1120            if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
1121                
1122                //
1123                $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1124                if ( $instructeurDivision != NULL ){
1125                    
1126                    $instructeur = $instructeurDivision['instructeur'];
1127                    $division = $instructeurDivision['division'];
1128                }
1129                
1130                if ( $instructeur != NULL ){
1131                    
1132                    $this->valF['instructeur'] = $instructeur;
1133                    $this->valF['division'] = $division;
1134                } else {
1135                    if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1136                        $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1137                    } else {
1138                        $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1139                    }
1140                }
1141            } else {
1142                $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1143            }
1144            //
1145            $this->addToLog("triggerajouter() : end", EXTRA_VERBOSE_MODE);
1146      }      }
1147    
1148      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 661  class dossier extends dossier_gen { Line 1162  class dossier extends dossier_gen {
1162              }              }
1163                  $this->addToMessage("<br>"._("Parcelle ou parcelle_lot non renseignee dans dossier")." ".$id." <br>");                      $this->addToMessage("<br>"._("Parcelle ou parcelle_lot non renseignee dans dossier")." ".$id." <br>");    
1164              }              }
1165         }          }
1166                    
1167            // verification si envoi vers ERP est active
1168            if ($this->f->getParameter('option_erp') != "") {
1169                if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1170                    && $this->valF['a_qualifier'] === false) {
1171                                    
1172                    // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1173                    // de la qualification URBA
1174                    if ($this->getDATDCode($this->valF['dossier']) ==
1175                                 $this->f->getParameter('erp_nature_dat')) {
1176                        $msgenque = new MessageEnqueuer();
1177                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1178                        $msgenque->setCompetence($this->valF['autorite_competente']);
1179                        $msgenque->setContraintePlu($this->valF['servitude']);
1180                        $msgenque->setReferenceCadastrale(
1181                                $this->getReferenceCadastrale($this->valF['dossier']));
1182                        $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1183                    }
1184                    
1185                    // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1186                    // qui etait classifie come ERP
1187                    if ($this->getDATDCode($this->valF['dossier']) ==
1188                            $this->f->getParameter('erp_dossier_nature_pc')
1189                        && $this->valF['erp'] == true) {
1190                        $msgenque = new MessageEnqueuer();
1191                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1192                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1193                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1194                    }
1195                }
1196            } // fin de if($this->f->getParameter('option_erp'))
1197      }      }
1198    
1199        /**
1200         * Retourne le type de dossier d'autorisation du dossier courant :
1201         *  - dossier_autorisation_type_detaille.code
1202         **/
1203        function getDATDCode($idxDossier) {
1204            $sql = "SELECT dossier_autorisation_type_detaille.code
1205                    FROM ".DB_PREFIXE."dossier_autorisation_type_detaille
1206                    INNER JOIN ".DB_PREFIXE."dossier_autorisation
1207                        ON dossier_autorisation_type_detaille.dossier_autorisation_type_detaille =
1208                           dossier_autorisation.dossier_autorisation_type_detaille
1209                    INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1210                    WHERE dossier.dossier = '".$idxDossier."'";
1211            $res = $this -> db -> getOne($sql);
1212            $this->f->isDatabaseError();
1213            $this->addToLog($sql);
1214            return $res;
1215        }
1216        
1217        
1218        /**
1219         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1220         * specifique
1221         * @param string $dossier L'identifiant du dossier
1222         * @return string|null La reference cadastrale si elle est trouve,
1223         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1224         */
1225        function getReferenceCadastrale($dossier) {
1226            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1227            $res = $this->db->limitquery($sql, 0, 1);
1228            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1229                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1230            // Si une erreur survient on die
1231            if (database::isError($res, true)) {
1232                // Appel de la methode de recuperation des erreurs
1233                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1234            }
1235            // retourne la nature du dossier
1236            while ($row =& $res->fetchRow()) {
1237                return $row[0];
1238            }
1239            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1240            return NULL;
1241        }
1242        
1243    
1244      function sig_parametre(&$db){      function sig_parametre(&$db){
1245          if (file_exists ("../dyn/var.inc"))          if (file_exists ("../dyn/var.inc"))
1246              include ("../dyn/var.inc");              include ("../dyn/var.inc");
# Line 752  class dossier extends dossier_gen { Line 1329  class dossier extends dossier_gen {
1329                  if (database :: isError($res))                  if (database :: isError($res))
1330                      die($res->getMessage()."erreur ".$sql);                      die($res->getMessage()."erreur ".$sql);
1331              }              }
1332              $this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");              //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
1333          }          }
1334      }      }
1335    
# Line 808  class dossier extends dossier_gen { Line 1385  class dossier extends dossier_gen {
1385              $this->servitude.="  [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";              $this->servitude.="  [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";
1386         }         }
1387      }      }
   
   
1388  }// fin classe  }// fin classe
1389  ?>  ?>

Legend:
Removed from v.446  
changed lines
  Added in v.1358

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26