/[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 1005 by fmichon, Thu Dec 6 15:48:07 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"];          
105          $numero_unique = $this->f->collectivite["numero_unique"];          
106          if($numero_unique==1){          $this->valF['dossier'] = $val['dossier_autorisation'].str_pad(rand(1, 99),2, "0", STR_PAD_LEFT);
107          // numero unique (voir dyn/var.inc)          
108          $temp=$this->$db->nextId(DB_PREFIXE.$this->table);          /*Récupération de la lettre associé au type de dossier d'instruction*/
109          }else{          $code = $this->getCode($this->getDossierInstructionType());
110          // numero suivant nature          
111          $temp=$this->db->nextId(DB_PREFIXE."dossier_".$val['nature']);          /* Récupération de la valeur du suffixe ce dossier_instruction_type */
112          }          $suffixe = $this->getSuffixe($this->getDossierInstructionType());
113          $temp=str_pad($temp,4,"0", STR_PAD_LEFT);          
114          $this->valF['dossier'] = $this->valF['nature'].$this->valF['annee'].          /*S'il est à TRUE, on récupère le numéro de version du dossier d'autorisation*/
115                                   $lettre.$temp;          $numeroVersion = "";
116            if ( $suffixe == 't' ){
117                
118                $numeroVersion = $this->getNumeroVersion($val['dossier_autorisation']);
119                
120                /* Incrémentation du numéro de version */
121                if ( is_numeric($numeroVersion) or $numeroVersion == -1 ){
122                    
123                    $this->incrementNumeroVersion($val['dossier_autorisation'], ++$numeroVersion);
124                }
125            }
126            
127            /*Création du numéro de dossier*/
128            $this->valF['dossier'] = $val['dossier_autorisation'].str_pad(rand(1, 99),2, "0", STR_PAD_LEFT)."/$code$numeroVersion";
129      }      }
130    
131        /*Récupère la valeur du suffixe d'un dossier_instruction_type*/
132        function getSuffixe($dossierInstructionType){
133            
134            $suffixe = "";
135            
136            $sql = "SELECT
137                        suffixe
138                    FROM
139                        ".DB_PREFIXE."dossier_instruction_type
140                    WHERE
141                        dossier_instruction_type = $dossierInstructionType";
142                        
143            $this->addToLog("getSuffixe(): db->query(\"".$sql."\")", VERBOSE_MODE);
144            $res = $this->db->query($sql);
145            if (database :: isError($res))
146                die($res->getMessage()."erreur ".$sql);
147                
148            if ( $res->numRows() > 0 ){
149                
150                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
151                $suffixe =  $row['suffixe'];
152            }
153            
154            return $suffixe;
155        }
156        
157        /*Récupère dans la table de paramètrage la lettre correspondant
158         * au dossier_instruction_type
159         */
160        function getCode($dossierInstructionType){
161            
162            $code = "";
163            
164            $sql = "SELECT
165                        code
166                    FROM
167                        ".DB_PREFIXE."dossier_instruction_type
168                    WHERE
169                        dossier_instruction_type = $dossierInstructionType";
170                        
171            $this->addToLog("getCode(): db->query(\"".$sql."\")", VERBOSE_MODE);
172            $res = $this->db->query($sql);
173            if (database :: isError($res))
174                die($res->getMessage()."erreur ".$sql);
175                
176            if ( $res->numRows() > 0 ){
177                
178                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
179                $code =  $row['code'];
180            }
181            
182            return $code;
183        }
184        
185        /*Récupère le numéro de version d'un dossier_autorisation*/
186        function getNumeroVersion($dossierAutorisation){
187            
188            $numeroVersion = "";
189            
190            $sql = "SELECT
191                        numero_version
192                    FROM
193                        ".DB_PREFIXE."dossier_autorisation
194                    WHERE
195                        dossier_autorisation = '$dossierAutorisation'";
196                        
197            $this->addToLog("getNumeroVersion(): db->query(\"".$sql."\")", VERBOSE_MODE);
198            $res = $this->db->query($sql);
199            if (database :: isError($res))
200                die($res->getMessage()."erreur ".$sql);
201                
202            if ( $res->numRows() > 0 ){
203                
204                $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
205                $numeroVersion =  $row['numero_version'];
206            }
207            
208            return $numeroVersion;
209        }
210        
211        /*Incrémente le numéro de version du dossier*/
212        function incrementNumeroVersion($dossierAutorisation, $nouveauNumeroVersion) {
213            
214            $valF = array (
215                        "numero_version" => $nouveauNumeroVersion
216                    );
217            
218            $res = $this->db->autoExecute(DB_PREFIXE."dossier_autorisation",
219                                        $valF,
220                                        DB_AUTOQUERY_UPDATE,
221                                        "dossier_autorisation = '$dossierAutorisation'");
222                                        
223            if (database :: isError($res))
224                die($res->getMessage()."erreur ".$sql);
225                
226        }
227        
228      function setvalF($val){      function setvalF($val){
229          parent::setvalF($val);          parent::setvalF($val);
230          // 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 276  class dossier extends dossier_gen { Line 456  class dossier extends dossier_gen {
456              $form->setType('temp3',$temp3_type);              $form->setType('temp3',$temp3_type);
457              $form->setType('temp4',$temp4_type);              $form->setType('temp4',$temp4_type);
458              $form->setType('temp5',$temp5_type);              $form->setType('temp5',$temp5_type);
459                $form->setType('a_qualifier', 'checkbox');
460            }
461            if ($maj == 1) {
462                //
463                if ($this->f->isAccredited("dossier_modifier_instructeur")) {
464                    $form->setType('instructeur', 'select');
465                } else {
466                    $form->setType('instructeur', 'selecthiddenstatic');
467                }
468                //
469                if($this->f->getParameter('afficher_division') === 'true') {
470                    //
471                    if ($this->f->isAccredited("dossier_modifier_division")) {
472                        $form->setType('division', 'select');
473                    } else {
474                        $form->setType('division', 'selecthiddenstatic');
475                    }
476                } else {
477                    $form->setType('division', 'hidden');
478                }
479          }          }
480          if($maj == 3) {          if($maj == 3) {
481              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
# Line 289  class dossier extends dossier_gen { Line 489  class dossier extends dossier_gen {
489              $form->setType('parcelle_lot_archive','hidden');              $form->setType('parcelle_lot_archive','hidden');
490              $form->setType('geom1','hidden');              $form->setType('geom1','hidden');
491              $form->setType('geom','hidden');              $form->setType('geom','hidden');
492                $form->setType('a_qualifier', 'checkboxstatic');
493          }          }
494          if($this->f->getParameter('afficher_division')==='true') {          //
495              $form->setType('division','hiddenstatic');          if(!$this->f->getParameter('afficher_division') === 'true') {
496          } else {              $form->setType('division', 'hidden');
497              $form->setType('division','hidden');          }
498            $form->setType('dossier_autorisation', 'hiddenstatic');
499            //
500            if ($maj == 0) {
501                $form->setType('dossier_autorisation', 'select');
502            }
503            // On cache enjeu_ERP si l'option n'est pas activée
504            if($this->f->getParameter('option_ERP') != 'true') {
505                $form->setType('erp', 'hidden');
506                $form->setType('enjeu_erp', 'hidden');
507          }          }
           
         /* 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');  
508      }      }
509    
510      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 446  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('division','F');          //    $form->setGroupe('division','F');
659          }else{          //}else{
660              $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
661              $form->setGroupe('nature','G');          //    $form->setGroupe('nature','G');
662              $form->setGroupe('annee','G');          //    $form->setGroupe('annee','G');
663              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_demande','G');
664              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
665              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
666          }          //}
667          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
668          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
669          $form->setGroupe('demandeur_nom','F');          $form->setGroupe('demandeur_nom','F');
# Line 573  class dossier extends dossier_gen { Line 779  class dossier extends dossier_gen {
779          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
780      }      }
781    
782      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
783          // depot          //
784          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
785              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
786          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
787          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
788              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
789              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
790          }          $form->setFieldset('date_demande', 'D', _("Depot"));
791          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
792          $form->setRegroupe('division','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
793            $form->setFieldset('enjeu_erp', 'F');
794            $form->setBloc('enjeu_erp', 'F');
795            $form->setBloc('enjeu_erp', 'F');
796            //
797            $form->setBloc('objet_dossier', 'D', '', 'col_12');
798            //
799            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
800            $form->setRegroupe('date_conformite','F','');
801            //
802            $form->setBloc('terrain_superficie', 'F');
803                    
804        }
805        
806        function setRegroupe(&$form,$maj) {
807            //// depot
808            //If ($maj==0){
809            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
810            //}
811            //If ($maj==1){
812            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
813            //    $form->setRegroupe('date_demande','G','');
814            //}
815            //$form->setRegroupe('date_depot','G','');
816            //$form->setRegroupe('division','F','');
817    
818          // travaux          // travaux
819          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
820          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
821          $form->setRegroupe('travaux','G','');          $form->setRegroupe('travaux','G','');
822          $form->setRegroupe('travaux_complement','F','');          $form->setRegroupe('travaux_complement','F','');
823                    
824          // instruction          //// instruction
825          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
826          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
827          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
828          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
829          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
830          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
831          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
832          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
833          $form->setRegroupe('avis_decision','G','');          //$form->setRegroupe('avis_decision','G','');
834          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
835          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
836          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
837          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
838          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
839                    
840          // demandeur          // demandeur
841          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
# Line 669  class dossier extends dossier_gen { Line 899  class dossier extends dossier_gen {
899          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
900          $form->setRegroupe('parcelle_lot','G','');          $form->setRegroupe('parcelle_lot','G','');
901          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
902            
903      }      }
904    
       
   
905      /* =============================================================      /* =============================================================
906      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
907      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
908        * utilisé aussi pour envoyer une message au service REST d'ERP
909      * ===============================================================      * ===============================================================
910      */      */
911    
# Line 691  class dossier extends dossier_gen { Line 921  class dossier extends dossier_gen {
921                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
922                            
923          }          }
924            
925            
926            if ($this->f->getParameter('option_erp') != "") {
927                // envoi du message a ERP en cas d'un depot du dossier dat
928                if ($this->valF['nature'] ==
929                        $this->f->getParameter('erp_depot_dossier_dat')) {
930                    $msgenque = new MessageEnqueuer();
931                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
932                    $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
933                }
934                
935                // envoi du message a ERP en cas d'une demande d'ouverture DAT
936                if ($this->valF['nature'] ==
937                        $this->f->getParameter('erp_demande_ouverture_dat')) {
938                    $msgenque = new MessageEnqueuer();
939                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
940                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
941                }
942                
943                if ($this->valF['erp'] === true) {
944                    // envoi du message a ERP en cas d'annulation d'une demande
945                    if ($this->valF['nature'] ==
946                            $this->f->getParameter('erp_annulation_demande')) {
947                        $msgenque = new MessageEnqueuer();
948                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
949                        $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
950                    }
951                    
952                    // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
953                    // au dossier DAACT
954                    if ($this->valF['nature'] ==
955                            $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
956                        $msgenque = new MessageEnqueuer();
957                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
958                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
959                    }
960                }
961            } // fin de if ($this->f->getParameter('option_erp') != "")        
962      }      }
963            
964      /*      /*
965       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
966       * */       * */
967       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {       function getQuartierArrondissement($parcelle) {
968                            
969           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
970           $quartier = '';           $quartier = '';
971                    
972           /*Code impots*/           /*Récupère le code impot du quartier dans la parcelle*/
973           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
974              if (is_numeric($parcelle[$i]) )                  
975                if (is_numeric($parcelle[$i]) ){
976                        
977                  $quartier .= $parcelle[$i];                  $quartier .= $parcelle[$i];
978              else              }
979                else{
980                        
981                  break;                  break;
982                }
983             }
984                    
985          if ( $quartier !== '' ){          if ( $quartier !== '' ){
986                            
# Line 714  class dossier extends dossier_gen { Line 988  class dossier extends dossier_gen {
988              $sql = "SELECT              $sql = "SELECT
989                          quartier, arrondissement                          quartier, arrondissement
990                      FROM                      FROM
991                          quartier                          ".DB_PREFIXE."quartier
992                      WHERE                      WHERE
993                          code_impots='$quartier'";                          code_impots='$quartier'";
994                            
995              $res = $db->query($sql);              $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
996                $res = $this->db->query($sql);
997              if (database :: isError($res))              if (database :: isError($res))
998                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
999                            
1000              if ( $res->numRows() > 0 ){              if ( $res->numRows() > 0 ){
1001                                            
1002                  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){                  return $res->fetchRow(DB_FETCHMODE_ASSOC);
                   
                     $quartier = $row['quartier'];  
                     $arrondissement = $row['arrondissement'];  
                 }  
1003              }              }
1004          }          }
1005            
1006            return NULL;
1007       }       }
1008            
1009       /*       /*
# Line 751  class dossier extends dossier_gen { Line 1024  class dossier extends dossier_gen {
1024      /*      /*
1025       * Retourne l'intructeur correspondant le mieux à la parcelle       * Retourne l'intructeur correspondant le mieux à la parcelle
1026       * */       * */
1027       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
1028                    
1029            $quartier = ( $quartier == NULL ) ? -1 : $quartier;
1030            $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
1031                    
1032            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
1033          $sql = "          $sql = "
1034             SELECT             SELECT
1035                 instructeur, section, quartier, arrondissement, nature                 dossier_autorisation_type_detaille
1036             FROM             FROM
1037                 lien_localisation_nature l                 ".DB_PREFIXE."dossier_autorisation
1038             WHERE             WHERE
1039                 ( 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);  
1040                    
1041          if ( $res->numRows() > 0 ){          $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1042              $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);          $resDATD = $this->db->query($sql);
1043              return $row['instructeur'];          if (database :: isError($resDATD))
1044          }              die($resDATD->getMessage()."erreur ".$sql);
1045                    
1046            if ( $resDATD->numRows() > 0 ){
1047                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
1048                
1049                $sql = "
1050                   SELECT
1051                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
1052                   FROM
1053                       ".DB_PREFIXE."affectation_automatique l
1054                   WHERE
1055                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1056                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1057                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1058                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1059                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1060                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1061                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1062                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
1063                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
1064                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
1065                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
1066                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
1067                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
1068                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
1069                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
1070                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
1071                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
1072                   LIMIT 1
1073                ";
1074                
1075                $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
1076                $res = $this->db->query($sql);
1077                if (database :: isError($res))
1078                    die($res->getMessage()."erreur ".$sql);
1079                
1080                if ( $res->numRows() > 0 ){
1081                    
1082                    $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
1083                    
1084                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
1085                    $res = $this->db->query($sql);
1086                    if (database :: isError($res))
1087                        die($res->getMessage()."erreur ".$sql);
1088                        
1089                    if ( $res->numRows() > 0 ){
1090                        
1091                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
1092                        $row['division'] = $rowT['division'];
1093                    }
1094                    
1095                    return $row;
1096                }
1097            }
1098    
1099          return NULL;          return NULL;
1100       }       }
1101            
# Line 798  class dossier extends dossier_gen { Line 1106  class dossier extends dossier_gen {
1106      */      */
1107    
1108      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
1109            //
1110            $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
1111                    
1112            // Initialisation des variables nécessaires à l'affectation automatique
1113            $quartier = NULL;
1114            $arrondissement = NULL;
1115            $section = NULL;
1116            $instructeur = NULL;
1117            
1118            // Si la parcelle n'est pas vide alors on récupère la section, le
1119            // quartier et l'arrondissement
1120            if ($val['parcelle'] != '') {
1121                // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
1122                $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
1123                if ( $quartierArrondissement!= NULL ){
1124                                    
1125          /*Localisation*/                  $quartier = $quartierArrondissement['quartier'];
1126          $quartier = 'NULL';                  $arrondissement = $quartierArrondissement['arrondissement'];
1127          $arrondissement = 'NULL';              }
1128          $section = 'NULL' ;              // Si il n'y a pas d'arrondissement alors on vide le quartier
1129                        if ( strcmp($arrondissement,'') == 0 )  {
1130          if($val['parcelle']!=''){                  
1131                                $arrondissement = NULL;
1132              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);                  $quartier = NULL;
1133                            }
1134              if ( strcmp($arrondissement,'NULL') == 0 )              // On récupère la section
                 $quartier = 'NULL';  
               
1135              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
               
               
1136          }          }
1137                    
1138          /*Instructeur*/          // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1139          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){          // alors on récupère l'instructeur et la division depuis l'affectation
1140                          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
             $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);  
1141                            
1142              if ( $instructeur != NULL )              //
1143                $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1144                if ( $instructeurDivision != NULL ){
1145                    
1146                    $instructeur = $instructeurDivision['instructeur'];
1147                    $division = $instructeurDivision['division'];
1148                }
1149                
1150                if ( $instructeur != NULL ){
1151                    
1152                  $this->valF['instructeur'] = $instructeur;                  $this->valF['instructeur'] = $instructeur;
1153              else {                  $this->valF['division'] = $division;
1154                  if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )              } else {
1155                    if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1156                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1157                  else                  } else {
1158                      $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/>");
1159                    }
1160              }              }
1161            } else {
1162                $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1163          }          }
1164                    //
1165          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/>");  
1166      }      }
1167    
1168      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 853  class dossier extends dossier_gen { Line 1182  class dossier extends dossier_gen {
1182              }              }
1183                  $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>");    
1184              }              }
1185         }          }
1186                    
1187            // verification si envoi vers ERP est active
1188            if ($this->f->getParameter('option_erp') != "") {
1189                if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1190                    && $this->valF['a_qualifier'] === false) {
1191                                    
1192                    // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1193                    // de la qualification URBA
1194                    if ($this->valF['nature'] ==
1195                                 $this->f->getParameter('erp_nature_dat')) {
1196                        $msgenque = new MessageEnqueuer();
1197                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1198                        $msgenque->setCompetence($this->valF['autorite_competente']);
1199                        $msgenque->setContraintePlu($this->valF['servitude']);
1200                        $msgenque->setReferenceCadastrale(
1201                                $this->getReferenceCadastrale($this->valF['dossier']));
1202                        $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1203                    }
1204                    
1205                    // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1206                    // qui etait classifie come ERP
1207                    if (substr($this->valF['nature'], 0, 2) ==
1208                            $this->f->getParameter('erp_dossier_nature_pc')
1209                        && $this->valF['erp'] == true) {
1210                        $msgenque = new MessageEnqueuer();
1211                        $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1212                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1213                        $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1214                    }
1215                }
1216            } // fin de if($this->f->getParameter('option_erp'))
1217      }      }
1218        
1219        
1220        /**
1221         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1222         * specifique
1223         * @param string $dossier L'identifiant du dossier
1224         * @return string|null La reference cadastrale si elle est trouve,
1225         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1226         */
1227        function getReferenceCadastrale($dossier) {
1228            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1229            $res = $this->db->limitquery($sql, 0, 1);
1230            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1231                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1232            // Si une erreur survient on die
1233            if (database::isError($res, true)) {
1234                // Appel de la methode de recuperation des erreurs
1235                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1236            }
1237            // retourne la nature du dossier
1238            while ($row =& $res->fetchRow()) {
1239                return $row[0];
1240            }
1241            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1242            return NULL;
1243        }
1244        
1245    
1246      function sig_parametre(&$db){      function sig_parametre(&$db){
1247          if (file_exists ("../dyn/var.inc"))          if (file_exists ("../dyn/var.inc"))

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26