/[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 656 by fmichon, Sun Nov 11 22:14:37 2012 UTC revision 1058 by vpihour, Thu Dec 13 15:00:27 2012 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 24  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 73  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 276  class dossier extends dossier_gen { Line 453  class dossier extends dossier_gen {
453              $form->setType('temp3',$temp3_type);              $form->setType('temp3',$temp3_type);
454              $form->setType('temp4',$temp4_type);              $form->setType('temp4',$temp4_type);
455              $form->setType('temp5',$temp5_type);              $form->setType('temp5',$temp5_type);
456                $form->setType('a_qualifier', 'checkbox');
457            }
458            if ($maj == 1) {
459                //
460                if ($this->f->isAccredited("dossier_modifier_instructeur")) {
461                    $form->setType('instructeur', 'select');
462                } else {
463                    $form->setType('instructeur', 'selecthiddenstatic');
464                }
465                //
466                if($this->f->getParameter('afficher_division') === 'true') {
467                    //
468                    if ($this->f->isAccredited("dossier_modifier_division")) {
469                        $form->setType('division', 'select');
470                    } else {
471                        $form->setType('division', 'selecthiddenstatic');
472                    }
473                } else {
474                    $form->setType('division', 'hidden');
475                }
476          }          }
477          if($maj == 3) {          if($maj == 3) {
478              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
# Line 289  class dossier extends dossier_gen { Line 486  class dossier extends dossier_gen {
486              $form->setType('parcelle_lot_archive','hidden');              $form->setType('parcelle_lot_archive','hidden');
487              $form->setType('geom1','hidden');              $form->setType('geom1','hidden');
488              $form->setType('geom','hidden');              $form->setType('geom','hidden');
489                $form->setType('a_qualifier', 'checkboxstatic');
490          }          }
491          if($this->f->getParameter('afficher_division')==='true') {          //
492              $form->setType('division','hiddenstatic');          if(!$this->f->getParameter('afficher_division') === 'true') {
493          } else {              $form->setType('division', 'hidden');
494              $form->setType('division','hidden');          }
495            $form->setType('dossier_autorisation', 'hiddenstatic');
496            //
497            if ($maj == 0) {
498                $form->setType('dossier_autorisation', 'select');
499            }
500            // On cache enjeu_ERP si l'option n'est pas activée
501            if($this->f->getParameter('option_ERP') != 'true') {
502                $form->setType('erp', 'hidden');
503                $form->setType('enjeu_erp', 'hidden');
504          }          }
           
         /* Gestion des droits pour l'ajout forcé d'un instructeur, si le profil est 5, c'est un administrateur */  
         if ( !$this->f->isAccredited("dossier_modifier_instructeur") )  
             $form->setType('instructeur', 'hidden');  
505      }      }
506    
507      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 413  class dossier extends dossier_gen { Line 616  class dossier extends dossier_gen {
616                  $contenu[0]=array("dossier",$this->getParameter("idx"));                  $contenu[0]=array("dossier",$this->getParameter("idx"));
617                  $form->setSelect('geom',$contenu);                  $form->setSelect('geom',$contenu);
618              }              }
619                            // arrondissement recherche anvancée
620                $this->init_select($form, $db, $maj, $debug, "arrondissement",
621                               $sql_arrondissement, $sql_arrondissement_by_id, false);
622                // dossier_autorisation_type_detaille recherche anvancée
623                $this->init_select($form, $db, $maj, $debug, "dossier_autorisation_type_detaille",
624                               $sql_dossier_autorisation_type_detaille, $sql_dossier_autorisation_type_detaille_by_id, false);
625              /*              /*
626               * Affichage de données dans le select de la parcelle               * Affichage de données dans le select de la parcelle
627               * */               * */
# Line 446  class dossier extends dossier_gen { Line 654  class dossier extends dossier_gen {
654      }          }    
655    
656      function setGroupe(&$form,$maj){      function setGroupe(&$form,$maj){
657          If ($maj==0){          //If ($maj==0){
658              $form->setGroupe('date_demande','D');          //    $form->setGroupe('date_demande','D');
659              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
660              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
661          }else{          //}else{
662              $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
663              $form->setGroupe('nature','G');          //    $form->setGroupe('nature','G');
664              $form->setGroupe('annee','G');          //    $form->setGroupe('annee','G');
665              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_demande','G');
666              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
667              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
668          }          //}
669          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
670          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
671          $form->setGroupe('demandeur_nom','F');          $form->setGroupe('demandeur_nom','F');
# Line 573  class dossier extends dossier_gen { Line 781  class dossier extends dossier_gen {
781          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
782      }      }
783    
784      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
785          // depot          //
786          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
787              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
788          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
789          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
790              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
791              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
792          }          $form->setFieldset('date_demande', 'D', _("Depot"));
793          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
794          $form->setRegroupe('division','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
795            $form->setFieldset('enjeu_erp', 'F');
796            $form->setBloc('enjeu_erp', 'F');
797            $form->setBloc('enjeu_erp', 'F');
798            //
799            $form->setBloc('objet_dossier', 'D', '', 'col_12');
800            //
801            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
802            $form->setRegroupe('date_conformite','F','');
803            //
804            $form->setBloc('terrain_superficie', 'F');
805                    
806        }
807        
808        function setRegroupe(&$form,$maj) {
809            //// depot
810            //If ($maj==0){
811            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
812            //}
813            //If ($maj==1){
814            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
815            //    $form->setRegroupe('date_demande','G','');
816            //}
817            //$form->setRegroupe('date_depot','G','');
818            //$form->setRegroupe('division','F','');
819    
820          // travaux          // travaux
821          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
822          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
823          $form->setRegroupe('travaux','G','');          $form->setRegroupe('travaux','G','');
824          $form->setRegroupe('travaux_complement','F','');          $form->setRegroupe('travaux_complement','F','');
825                    
826          // instruction          //// instruction
827          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
828          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
829          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
830          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
831          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
832          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
833          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
834          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
835          $form->setRegroupe('avis_decision','G','');          //$form->setRegroupe('avis_decision','G','');
836          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
837          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
838          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
839          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
840          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
841                    
842          // demandeur          // demandeur
843          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
# Line 669  class dossier extends dossier_gen { Line 901  class dossier extends dossier_gen {
901          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
902          $form->setRegroupe('parcelle_lot','G','');          $form->setRegroupe('parcelle_lot','G','');
903          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
904            
905      }      }
906    
       
   
907      /* =============================================================      /* =============================================================
908      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
909      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
910        * utilisé aussi pour envoyer une message au service REST d'ERP
911      * ===============================================================      * ===============================================================
912      */      */
913    
# Line 691  class dossier extends dossier_gen { Line 923  class dossier extends dossier_gen {
923                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
924                            
925          }          }
926            
927            
928            if ($this->f->getParameter('option_erp') != "") {
929                // envoi du message a ERP en cas d'un depot du dossier dat
930                if ($this->valF['nature'] ==
931                        $this->f->getParameter('erp_depot_dossier_dat')) {
932                    $msgenque = new MessageEnqueuer();
933                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
934                    $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
935                }
936                
937                // envoi du message a ERP en cas d'une demande d'ouverture DAT
938                if ($this->valF['nature'] ==
939                        $this->f->getParameter('erp_demande_ouverture_dat')) {
940                    $msgenque = new MessageEnqueuer();
941                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
942                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
943                }
944                
945                if ($this->valF['erp'] === true) {
946                    // envoi du message a ERP en cas d'annulation d'une demande
947                    if ($this->valF['nature'] ==
948                            $this->f->getParameter('erp_annulation_demande')) {
949                        $msgenque = new MessageEnqueuer();
950                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
951                        $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
952                    }
953                    
954                    // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
955                    // au dossier DAACT
956                    if ($this->valF['nature'] ==
957                            $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
958                        $msgenque = new MessageEnqueuer();
959                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
960                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
961                    }
962                }
963            } // fin de if ($this->f->getParameter('option_erp') != "")        
964      }      }
965            
966      /*      /*
967       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
968       * */       * */
969       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {       function getQuartierArrondissement($parcelle) {
970                            
971           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
972           $quartier = '';           $quartier = '';
973                    
974           /*Code impots*/           /*Récupère le code impot du quartier dans la parcelle*/
975           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
976              if (is_numeric($parcelle[$i]) )                  
977                if (is_numeric($parcelle[$i]) ){
978                        
979                  $quartier .= $parcelle[$i];                  $quartier .= $parcelle[$i];
980              else              }
981                else{
982                        
983                  break;                  break;
984                }
985             }
986                    
987          if ( $quartier !== '' ){          if ( $quartier !== '' ){
988                            
# Line 714  class dossier extends dossier_gen { Line 990  class dossier extends dossier_gen {
990              $sql = "SELECT              $sql = "SELECT
991                          quartier, arrondissement                          quartier, arrondissement
992                      FROM                      FROM
993                          quartier                          ".DB_PREFIXE."quartier
994                      WHERE                      WHERE
995                          code_impots='$quartier'";                          code_impots='$quartier'";
996                            
997              $res = $db->query($sql);              $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
998                $res = $this->db->query($sql);
999              if (database :: isError($res))              if (database :: isError($res))
1000                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
1001                            
1002              if ( $res->numRows() > 0 ){              if ( $res->numRows() > 0 ){
1003                                            
1004                  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){                  return $res->fetchRow(DB_FETCHMODE_ASSOC);
                   
                     $quartier = $row['quartier'];  
                     $arrondissement = $row['arrondissement'];  
                 }  
1005              }              }
1006          }          }
1007            
1008            return NULL;
1009       }       }
1010            
1011       /*       /*
# Line 751  class dossier extends dossier_gen { Line 1026  class dossier extends dossier_gen {
1026      /*      /*
1027       * Retourne l'intructeur correspondant le mieux à la parcelle       * Retourne l'intructeur correspondant le mieux à la parcelle
1028       * */       * */
1029       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
1030                    
1031            $quartier = ( $quartier == NULL ) ? -1 : $quartier;
1032            $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
1033                    
1034            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
1035          $sql = "          $sql = "
1036             SELECT             SELECT
1037                 instructeur, section, quartier, arrondissement, nature                 dossier_autorisation_type_detaille
1038             FROM             FROM
1039                 lien_localisation_nature l                 ".DB_PREFIXE."dossier_autorisation
1040             WHERE             WHERE
1041                 ( 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  
         ";  
           
         $res = $db->query($sql);  
         if (database :: isError($res))  
             die($res->getMessage()."erreur ".$sql);  
1042                    
1043          if ( $res->numRows() > 0 ){          $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1044              $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);          $resDATD = $this->db->query($sql);
1045              return $row['instructeur'];          if (database :: isError($resDATD))
1046          }              die($resDATD->getMessage()."erreur ".$sql);
1047                    
1048            if ( $resDATD->numRows() > 0 ){
1049                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
1050                
1051                $sql = "
1052                   SELECT
1053                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
1054                   FROM
1055                       ".DB_PREFIXE."affectation_automatique l
1056                   WHERE
1057                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1058                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1059                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1060                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1061                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1062                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1063                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1064                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
1065                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1066                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1067                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1068                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1069                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1070                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1071                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1072                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
1073                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
1074                   LIMIT 1
1075                ";
1076                
1077                $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1078                $res = $this->db->query($sql);
1079                if (database :: isError($res))
1080                    die($res->getMessage()."erreur ".$sql);
1081                
1082                if ( $res->numRows() > 0 ){
1083                    
1084                    $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1085                    
1086                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
1087                    $res = $this->db->query($sql);
1088                    if (database :: isError($res))
1089                        die($res->getMessage()."erreur ".$sql);
1090                        
1091                    if ( $res->numRows() > 0 ){
1092                        
1093                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1094                        $row['division'] = $rowT['division'];
1095                    }
1096                    
1097                    return $row;
1098                }
1099            }
1100    
1101          return NULL;          return NULL;
1102       }       }
1103            
# Line 798  class dossier extends dossier_gen { Line 1108  class dossier extends dossier_gen {
1108      */      */
1109    
1110      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
1111            //
1112            $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
1113                    
1114            // Initialisation des variables nécessaires à l'affectation automatique
1115            $quartier = NULL;
1116            $arrondissement = NULL;
1117            $section = NULL;
1118            $instructeur = NULL;
1119            
1120            // Si la parcelle n'est pas vide alors on récupère la section, le
1121            // quartier et l'arrondissement
1122            if ($val['parcelle'] != '') {
1123                // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
1124                $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
1125                if ( $quartierArrondissement!= NULL ){
1126                                    
1127          /*Localisation*/                  $quartier = $quartierArrondissement['quartier'];
1128          $quartier = 'NULL';                  $arrondissement = $quartierArrondissement['arrondissement'];
1129          $arrondissement = 'NULL';              }
1130          $section = 'NULL' ;              // Si il n'y a pas d'arrondissement alors on vide le quartier
1131                        if ( strcmp($arrondissement,'') == 0 )  {
1132          if($val['parcelle']!=''){                  
1133                                $arrondissement = NULL;
1134              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);                  $quartier = NULL;
1135                            }
1136              if ( strcmp($arrondissement,'NULL') == 0 )              // On récupère la section
                 $quartier = 'NULL';  
               
1137              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
               
               
1138          }          }
1139                    
1140          /*Instructeur*/          // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1141          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){          // alors on récupère l'instructeur et la division depuis l'affectation
1142                          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
             $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);  
1143                            
1144              if ( $instructeur != NULL )              //
1145                $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1146                if ( $instructeurDivision != NULL ){
1147                    
1148                    $instructeur = $instructeurDivision['instructeur'];
1149                    $division = $instructeurDivision['division'];
1150                }
1151                
1152                if ( $instructeur != NULL ){
1153                    
1154                  $this->valF['instructeur'] = $instructeur;                  $this->valF['instructeur'] = $instructeur;
1155              else {                  $this->valF['division'] = $division;
1156                  if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )              } else {
1157                    if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1158                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1159                  else                  } else {
1160                      $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");                      $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1161                    }
1162              }              }
1163            } else {
1164                $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1165          }          }
1166                    //
1167          else          $this->addToLog("triggerajouter() : end", EXTRA_VERBOSE_MODE);
                     $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");  
1168      }      }
1169    
1170      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 853  class dossier extends dossier_gen { Line 1184  class dossier extends dossier_gen {
1184              }              }
1185                  $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>");    
1186              }              }
1187         }          }
1188                    
1189            // verification si envoi vers ERP est active
1190            if ($this->f->getParameter('option_erp') != "") {
1191                if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1192                    && $this->valF['a_qualifier'] === false) {
1193                                    
1194                    // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1195                    // de la qualification URBA
1196                    if ($this->valF['nature'] ==
1197                                 $this->f->getParameter('erp_nature_dat')) {
1198                        $msgenque = new MessageEnqueuer();
1199                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1200                        $msgenque->setCompetence($this->valF['autorite_competente']);
1201                        $msgenque->setContraintePlu($this->valF['servitude']);
1202                        $msgenque->setReferenceCadastrale(
1203                                $this->getReferenceCadastrale($this->valF['dossier']));
1204                        $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1205                    }
1206                    
1207                    // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1208                    // qui etait classifie come ERP
1209                    if (substr($this->valF['nature'], 0, 2) ==
1210                            $this->f->getParameter('erp_dossier_nature_pc')
1211                        && $this->valF['erp'] == true) {
1212                        $msgenque = new MessageEnqueuer();
1213                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1214                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1215                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1216                    }
1217                }
1218            } // fin de if($this->f->getParameter('option_erp'))
1219      }      }
1220        
1221        
1222        /**
1223         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1224         * specifique
1225         * @param string $dossier L'identifiant du dossier
1226         * @return string|null La reference cadastrale si elle est trouve,
1227         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1228         */
1229        function getReferenceCadastrale($dossier) {
1230            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1231            $res = $this->db->limitquery($sql, 0, 1);
1232            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1233                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1234            // Si une erreur survient on die
1235            if (database::isError($res, true)) {
1236                // Appel de la methode de recuperation des erreurs
1237                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1238            }
1239            // retourne la nature du dossier
1240            while ($row =& $res->fetchRow()) {
1241                return $row[0];
1242            }
1243            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1244            return NULL;
1245        }
1246        
1247    
1248      function sig_parametre(&$db){      function sig_parametre(&$db){
1249          if (file_exists ("../dyn/var.inc"))          if (file_exists ("../dyn/var.inc"))

Legend:
Removed from v.656  
changed lines
  Added in v.1058

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26