/[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 835 by mlimic, Mon Nov 26 16:46:20 2012 UTC revision 1356 by nhaye, Mon Mar 11 14:13:45 2013 UTC
# Line 25  class dossier extends dossier_gen { Line 25  class dossier extends dossier_gen {
25      var $aff_localisation = "collapsible";      var $aff_localisation = "collapsible";
26      var $aff_description = "startClosed";      var $aff_description = "startClosed";
27      var $aff_amenagement = "startClosed";      var $aff_amenagement = "startClosed";
28        var $dossier_instruction_type;
29    
30          function dossier($id,&$db,$DEBUG) {      function dossier($id,&$db,$DEBUG) {
31          $this->constructeur($id,$db,$DEBUG);          $this->constructeur($id,$db,$DEBUG);
32      } // fin constructeur      } // 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_".$val['nature']);          $numeroVersion = "";
112          }          if ( $suffixe == 't' ){
113          $temp=str_pad($temp,4,"0", STR_PAD_LEFT);              
114          $this->valF['dossier'] = $this->valF['nature'].$this->valF['annee'].              $numeroVersion = $this->getNumeroVersion($val['dossier_autorisation']);
115                                   $lettre.$temp;              
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            
123            /*Création du numéro de dossier*/
124            $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 74  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'){
# Line 206  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', 'select');  
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 277  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) {          if ($maj == 1) {
458              //              //
# Line 299  class dossier extends dossier_gen { Line 475  class dossier extends dossier_gen {
475          }          }
476          if($maj == 3) {          if($maj == 3) {
477              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
             $form->setType('nature', 'selectstatic');  
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 309  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          }          }
         $form->setType('a_qualifier', 'hidden');  
489          //          //
490          if(!$this->f->getParameter('afficher_division') === 'true') {          if(!$this->f->getParameter('afficher_division') === 'true') {
491              $form->setType('division', 'hidden');              $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    
506      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 323  class dossier extends dossier_gen { Line 509  class dossier extends dossier_gen {
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'));
# Line 429  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               * Affichage de données dans le select de la parcelle
625               * */               * */
# Line 468  class dossier extends dossier_gen { Line 658  class dossier extends dossier_gen {
658          //    $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
659          //}else{          //}else{
660          //    $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
         //    $form->setGroupe('nature','G');  
661          //    $form->setGroupe('annee','G');          //    $form->setGroupe('annee','G');
662          //    $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_demande','G');
663          //    $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
# Line 609  class dossier extends dossier_gen { Line 798  class dossier extends dossier_gen {
798          $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');          $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
799          $form->setRegroupe('date_conformite','F','');          $form->setRegroupe('date_conformite','F','');
800          //          //
801          $form->setBloc('geom1', 'F');          $form->setBloc('terrain_superficie', 'F');
802                    
803      }      }
804            
# Line 683  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','');  
         }  
           
875          // description          // description
876          $form->setRegroupe('batiment_nombre','D',_('statistique'), $this->aff_description);          $form->setRegroupe('batiment_nombre','D',_('statistique'), $this->aff_description);
877          $form->setRegroupe('logement_nombre','G','');          $form->setRegroupe('logement_nombre','G','');
# Line 709  class dossier extends dossier_gen { Line 889  class dossier extends dossier_gen {
889          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
890          $form->setRegroupe('parcelle_lot','G','');          $form->setRegroupe('parcelle_lot','G','');
891          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
892            
893      }      }
894    
       
   
895      /* =============================================================      /* =============================================================
896      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
897      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
# Line 733  class dossier extends dossier_gen { Line 912  class dossier extends dossier_gen {
912                            
913          }          }
914                    
915          // envoie d'une message au service REST d'ERP          
916          if ($this->valF['enjeu_erp'] === true) {          if ($this->f->getParameter('option_erp') != "") {
917              $msgenque = new MessageEnqueuer();              // envoi du message a ERP en cas d'un depot du dossier dat
918              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);              if ($this->getDATDCode($this->valF['dossier']) ==
919              $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);                      $this->f->getParameter('erp_depot_dossier_dat')) {
920          }                  $msgenque = new MessageEnqueuer();
921                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
922                    $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
923                }
924                
925                // envoi du message a ERP en cas d'une demande d'ouverture DAT
926                if ($this->getDATDCode($this->valF['dossier']) ==
927                        $this->f->getParameter('erp_demande_ouverture_dat')) {
928                    $msgenque = new MessageEnqueuer();
929                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
930                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
931                }
932                
933                if ($this->valF['erp'] === true) {
934                    // envoi du message a ERP en cas d'annulation d'une demande
935                    if ($this->getDATDCode($this->valF['dossier']) ==
936                            $this->f->getParameter('erp_annulation_demande')) {
937                        $msgenque = new MessageEnqueuer();
938                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
939                        $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
940                    }
941                    
942                    // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
943                    // au dossier DAACT
944                    if ($this->getDATDCode($this->valF['dossier']) ==
945                            $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
946                        $msgenque = new MessageEnqueuer();
947                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
948                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
949                    }
950                }
951            } // fin de if ($this->f->getParameter('option_erp') != "")        
952      }      }
953            
954      /*      /*
# Line 768  class dossier extends dossier_gen { Line 978  class dossier extends dossier_gen {
978              $sql = "SELECT              $sql = "SELECT
979                          quartier, arrondissement                          quartier, arrondissement
980                      FROM                      FROM
981                          quartier                          ".DB_PREFIXE."quartier
982                      WHERE                      WHERE
983                          code_impots='$quartier'";                          code_impots='$quartier'";
984                            
# Line 804  class dossier extends dossier_gen { Line 1014  class dossier extends dossier_gen {
1014      /*      /*
1015       * Retourne l'intructeur correspondant le mieux à la parcelle       * Retourne l'intructeur correspondant le mieux à la parcelle
1016       * */       * */
1017       function getInstructeurDivision( $quartier, $arrondissement, $section, $nature) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
1018                                    
1019          $quartier = ( $quartier == NULL ) ? -1 : $quartier;          $quartier = ( $quartier == NULL ) ? -1 : $quartier;
1020          $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;          $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
1021                    
1022            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
1023          $sql = "          $sql = "
1024             SELECT             SELECT
1025                 instructeur, section, quartier, arrondissement, nature                 dossier_autorisation_type_detaille
1026             FROM             FROM
1027                 lien_localisation_nature l                 ".DB_PREFIXE."dossier_autorisation
1028             WHERE             WHERE
1029                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR                 dossier_autorisation = '$dossier_autorisation'";    
                ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR  
                ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR  
                ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR  
                ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR  
                ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR  
                ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR  
                ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR  
                ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR  
                ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR  
                ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR  
                ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR  
                ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR  
                ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR  
                ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR  
                ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )  
            ORDER BY section, quartier, arrondissement, nature  
            LIMIT 1  
         ";  
1030                    
1031          $this->addToLog("getInstructeurDivision( quartier, arrondissement, section, nature) : db->query(\"$sql\")", VERBOSE_MODE);          $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1032          $res = $this->db->query($sql);          $resDATD = $this->db->query($sql);
1033          if (database :: isError($res))          if (database :: isError($resDATD))
1034              die($res->getMessage()."erreur ".$sql);              die($resDATD->getMessage()."erreur ".$sql);
1035                    
1036          if ( $res->numRows() > 0 ){          if ( $resDATD->numRows() > 0 ){
1037                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
1038                            
1039              $row = $res->fetchRow(DB_FETCHMODE_ASSOC);              $sql = "
1040                   SELECT
1041                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
1042                   FROM
1043                       ".DB_PREFIXE."affectation_automatique l
1044                   WHERE
1045                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1046                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1047                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1048                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1049                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1050                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1051                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1052                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
1053                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1054                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1055                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1056                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1057                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1058                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1059                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1060                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
1061                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
1062                   LIMIT 1
1063                ";
1064                            
1065              $sql = "SELECT division FROM instructeur WHERE instructeur = ".$row['instructeur'];              $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1066              $res = $this->db->query($sql);              $res = $this->db->query($sql);
1067              if (database :: isError($res))              if (database :: isError($res))
1068                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
1069                                
1070              if ( $res->numRows() > 0 ){              if ( $res->numRows() > 0 ){
1071                                    
1072                  $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);                  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1073                  $row['division'] = $rowT['division'];                  
1074                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
1075                    $res = $this->db->query($sql);
1076                    if (database :: isError($res))
1077                        die($res->getMessage()."erreur ".$sql);
1078                        
1079                    if ( $res->numRows() > 0 ){
1080                        
1081                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1082                        $row['division'] = $rowT['division'];
1083                    }
1084                    
1085                    return $row;
1086              }              }
               
             return $row;  
1087          }          }
1088            
1089          return NULL;          return NULL;
1090       }       }
1091            
# Line 875  class dossier extends dossier_gen { Line 1103  class dossier extends dossier_gen {
1103          $quartier = NULL;          $quartier = NULL;
1104          $arrondissement = NULL;          $arrondissement = NULL;
1105          $section = NULL;          $section = NULL;
1106            $instructeur = NULL;
1107                    
1108          // Si la parcelle n'est pas vide alors on récupère la section, le          // Si la parcelle n'est pas vide alors on récupère la section, le
1109          // quartier et l'arrondissement          // quartier et l'arrondissement
# Line 896  class dossier extends dossier_gen { Line 1125  class dossier extends dossier_gen {
1125              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
1126          }          }
1127                    
1128          // Si aucun instructeur n'est saisi et que la nature n'est pas vide          // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1129          // alors on récupère l'instructeur et la division depuis l'affectation          // alors on récupère l'instructeur et la division depuis l'affectation
1130          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ) {          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
1131                            
1132              //              //
1133              $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['nature']);              $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1134              if ( $instructeurDivision != NULL ){              if ( $instructeurDivision != NULL ){
1135                                    
1136                  $instructeur = $instructeurDivision['instructeur'];                  $instructeur = $instructeurDivision['instructeur'];
# Line 944  class dossier extends dossier_gen { Line 1173  class dossier extends dossier_gen {
1173                  $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>");    
1174              }              }
1175          }          }
1176          // si la qualification est changée, envoie une message au service ERP                  
1177          if ($this->val[array_search('a_qualifier', $this->champs)] != $this->valF['a_qualifier']          // verification si envoi vers ERP est active
1178              && $this->valF['enjeu_erp'] === true) {          if ($this->f->getParameter('option_erp') != "") {
1179              $msgenque = new MessageEnqueuer();              if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1180              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  && $this->valF['a_qualifier'] === false) {
1181              //$msgenque->competence(xxx); // TODO                                  
1182              //$msgenque->contrainte_plu(xxx); // TODO                  // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1183              $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);                  // de la qualification URBA
1184                    if ($this->getDATDCode($this->valF['dossier']) ==
1185                                 $this->f->getParameter('erp_nature_dat')) {
1186                        $msgenque = new MessageEnqueuer();
1187                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1188                        $msgenque->setCompetence($this->valF['autorite_competente']);
1189                        $msgenque->setContraintePlu($this->valF['servitude']);
1190                        $msgenque->setReferenceCadastrale(
1191                                $this->getReferenceCadastrale($this->valF['dossier']));
1192                        $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1193                    }
1194                    
1195                    // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1196                    // qui etait classifie come ERP
1197                    if ($this->getDATDCode($this->valF['dossier']) ==
1198                            $this->f->getParameter('erp_dossier_nature_pc')
1199                        && $this->valF['erp'] == true) {
1200                        $msgenque = new MessageEnqueuer();
1201                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1202                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1203                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1204                    }
1205                }
1206            } // fin de if($this->f->getParameter('option_erp'))
1207        }
1208    
1209        /**
1210         * Retourne le type de dossier d'autorisation du dossier courant :
1211         *  - dossier_autorisation_type_detaille.code
1212         **/
1213        function getDATDCode($idxDossier) {
1214            $sql = "SELECT dossier_autorisation_type_detaille.code
1215                    FROM ".DB_PREFIXE."dossier_autorisation_type_detaille
1216                    INNER JOIN ".DB_PREFIXE."dossier_autorisation
1217                        ON dossier_autorisation_type_detaille.dossier_autorisation_type_detaille =
1218                           dossier_autorisation.dossier_autorisation_type_detaille
1219                    INNER JOIN ".DB_PREFIXE."dossier ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation
1220                    WHERE dossier.dossier = '".$idxDossier."'";
1221            $res = $this -> db -> getOne($sql);
1222            $this->f->isDatabaseError();
1223            $this->addToLog($sql);
1224            return $res;
1225        }
1226        
1227        
1228        /**
1229         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1230         * specifique
1231         * @param string $dossier L'identifiant du dossier
1232         * @return string|null La reference cadastrale si elle est trouve,
1233         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1234         */
1235        function getReferenceCadastrale($dossier) {
1236            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1237            $res = $this->db->limitquery($sql, 0, 1);
1238            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1239                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1240            // Si une erreur survient on die
1241            if (database::isError($res, true)) {
1242                // Appel de la methode de recuperation des erreurs
1243                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1244            }
1245            // retourne la nature du dossier
1246            while ($row =& $res->fetchRow()) {
1247                return $row[0];
1248          }          }
1249            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1250            return NULL;
1251      }      }
1252        
1253    
1254      function sig_parametre(&$db){      function sig_parametre(&$db){
1255          if (file_exists ("../dyn/var.inc"))          if (file_exists ("../dyn/var.inc"))

Legend:
Removed from v.835  
changed lines
  Added in v.1356

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26