/[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 626 by vpihour, Wed Nov 7 16:54:25 2012 UTC revision 948 by nhaye, Fri Nov 30 16:29:37 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 25  class dossier extends dossier_gen { Line 26  class dossier extends dossier_gen {
26      var $aff_description = "startClosed";      var $aff_description = "startClosed";
27      var $aff_amenagement = "startClosed";      var $aff_amenagement = "startClosed";
28    
29          function dossier($id,&$db,$DEBUG) {      function dossier($id,&$db,$DEBUG) {
30          $this->constructeur($id,$db,$DEBUG);          $this->constructeur($id,$db,$DEBUG);
31      } // fin constructeur      } // fin constructeur
32        
33        // {{{ Gestion de la confidentialité des données spécifiques
34    
35        /**
36         * Surcharge pour gérer les actions disponibles dans le portlet
37         */
38        function checkAccessibility() {
39            //
40            parent::checkAccessibility();
41            // Si l'utilisateur est un intructeur qui en correspond pas à la
42            // division du dossier
43            if ($this->f->isUserInstructeur()
44                && isset($this->f->om_utilisateur["division"])
45                && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) {
46                //
47                $this->actions_sup = array();
48                $this->setParameter("actions", array());
49            }
50        }
51    
52        /**
53         * Cette methode est à surcharger elle permet de tester dans chaque classe
54         * des droits des droits spécifiques en fonction des données
55         */
56        function canAccess() {
57            // Si l'utilisateur est un intructeur qui ne correspond pas à la
58            // division du dossier
59            if ($this->f->isUserInstructeur()
60                && $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()
61                && $this->getParameter("maj") != 3) {
62                //
63                return false;
64            }
65            //
66            return true;
67        }
68    
69        /**
70         * Cette méthode permet de récupérer la division d'un dossier
71         */
72        function getDivisionFromDossier() {
73            //
74            if (!isset($this->val[array_search("dossier", $this->champs)])) {
75                return NULL;
76            }
77            //
78            $sql = "select division from ".DB_PREFIXE."dossier ";
79            $sql .= " where dossier='".$this->val[array_search("dossier", $this->champs)]."'";
80            //
81            $division = $this->db->getOne($sql);
82            $this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE);
83            database::isError($division);
84            //
85            return $division;
86        }
87    
88        // }}}
89    
90      function setValFAjout($val = array()) {      function setValFAjout($val = array()) {
91          // Cle primaire          $this->valF['dossier'] = $val['dossier_autorisation'].str_pad(rand(1, 99),2, "0", STR_PAD_LEFT);
         $lettre=$this->f->collectivite["lettre"];  
         $numero_unique = $this->f->collectivite["numero_unique"];  
         if($numero_unique==1){  
         // numero unique (voir dyn/var.inc)  
         $temp=$this->$db->nextId(DB_PREFIXE.$this->table);  
         }else{  
         // numero suivant nature  
         $temp=$this->db->nextId(DB_PREFIXE."dossier_".$val['nature']);  
         }  
         $temp=str_pad($temp,4,"0", STR_PAD_LEFT);  
         $this->valF['dossier'] = $this->valF['nature'].$this->valF['annee'].  
                                  $lettre.$temp;  
92      }      }
93    
94      function setvalF($val){      function setvalF($val){
# Line 276  class dossier extends dossier_gen { Line 322  class dossier extends dossier_gen {
322              $form->setType('temp3',$temp3_type);              $form->setType('temp3',$temp3_type);
323              $form->setType('temp4',$temp4_type);              $form->setType('temp4',$temp4_type);
324              $form->setType('temp5',$temp5_type);              $form->setType('temp5',$temp5_type);
325                $form->setType('a_qualifier', 'checkbox');
326            }
327            if ($maj == 1) {
328                //
329                if ($this->f->isAccredited("dossier_modifier_instructeur")) {
330                    $form->setType('instructeur', 'select');
331                } else {
332                    $form->setType('instructeur', 'selecthiddenstatic');
333                }
334                //
335                if($this->f->getParameter('afficher_division') === 'true') {
336                    //
337                    if ($this->f->isAccredited("dossier_modifier_division")) {
338                        $form->setType('division', 'select');
339                    } else {
340                        $form->setType('division', 'selecthiddenstatic');
341                    }
342                } else {
343                    $form->setType('division', 'hidden');
344                }
345          }          }
346          if($maj == 3) {          if($maj == 3) {
347              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
# Line 289  class dossier extends dossier_gen { Line 355  class dossier extends dossier_gen {
355              $form->setType('parcelle_lot_archive','hidden');              $form->setType('parcelle_lot_archive','hidden');
356              $form->setType('geom1','hidden');              $form->setType('geom1','hidden');
357              $form->setType('geom','hidden');              $form->setType('geom','hidden');
358                $form->setType('a_qualifier', 'checkboxstatic');
359          }          }
360          if($this->f->getParameter('afficher_division')==='true') {          //
361              $form->setType('division','hiddenstatic');          if(!$this->f->getParameter('afficher_division') === 'true') {
362          } else {              $form->setType('division', 'hidden');
363              $form->setType('division','hidden');          }
364            $form->setType('dossier_autorisation', 'hiddenstatic');
365            //
366            if ($maj == 0) {
367                $form->setType('dossier_autorisation', 'select');
368            }
369            // On cache enjeu_ERP si l'option n'est pas activée
370            if($this->f->getParameter('enjeu_ERP') != 'true') {
371                $form->setType('erp', 'hidden');
372                $form->setType('enjeu_erp', 'hidden');
373          }          }
           
         /* 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');  
374      }      }
375    
376      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 446  class dossier extends dossier_gen { Line 518  class dossier extends dossier_gen {
518      }          }    
519    
520      function setGroupe(&$form,$maj){      function setGroupe(&$form,$maj){
521          If ($maj==0){          //If ($maj==0){
522              $form->setGroupe('date_demande','D');          //    $form->setGroupe('date_demande','D');
523              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
524              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
525          }else{          //}else{
526              $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
527              $form->setGroupe('nature','G');          //    $form->setGroupe('nature','G');
528              $form->setGroupe('annee','G');          //    $form->setGroupe('annee','G');
529              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_demande','G');
530              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
531              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
532          }          //}
533          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
534          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
535          $form->setGroupe('demandeur_nom','F');          $form->setGroupe('demandeur_nom','F');
# Line 488  class dossier extends dossier_gen { Line 560  class dossier extends dossier_gen {
560          $form->setGroupe('delegataire_telephone','F');          $form->setGroupe('delegataire_telephone','F');
561                                
562          $form->setGroupe('architecte','D');          $form->setGroupe('architecte','D');
563          $form->setGroupe('architecte_nom','G');          $form->setGroupe('architecte_nom','F');
564          $form->setGroupe('saisie_architecte','F');          //$form->setGroupe('saisie_architecte','F');
565                    
566          $form->setGroupe('travaux','D');            $form->setGroupe('travaux','D');  
567          $form->setGroupe('travaux_complement','F');          $form->setGroupe('travaux_complement','F');
# Line 573  class dossier extends dossier_gen { Line 645  class dossier extends dossier_gen {
645          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
646      }      }
647    
648      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
649          // depot          //
650          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
651              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
652          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
653          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
654              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
655              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
656          }          $form->setFieldset('date_demande', 'D', _("Depot"));
657          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
658          $form->setRegroupe('division','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
659            $form->setFieldset('enjeu_erp', 'F');
660            $form->setBloc('enjeu_erp', 'F');
661            $form->setBloc('enjeu_erp', 'F');
662            //
663            $form->setBloc('objet_dossier', 'D', '', 'col_12');
664            //
665            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
666            $form->setRegroupe('date_conformite','F','');
667            //
668            $form->setBloc('terrain_superficie', 'F');
669                    
670        }
671        
672        function setRegroupe(&$form,$maj) {
673            //// depot
674            //If ($maj==0){
675            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
676            //}
677            //If ($maj==1){
678            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
679            //    $form->setRegroupe('date_demande','G','');
680            //}
681            //$form->setRegroupe('date_depot','G','');
682            //$form->setRegroupe('division','F','');
683    
684          // travaux          // travaux
685          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
686          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
687          $form->setRegroupe('travaux','G','');          $form->setRegroupe('travaux','G','');
688          $form->setRegroupe('travaux_complement','F','');          $form->setRegroupe('travaux_complement','F','');
689                    
690          // instruction          //// instruction
691          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
692          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
693          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
694          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
695          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
696          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
697          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
698          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
699          $form->setRegroupe('avis_decision','G','');          //$form->setRegroupe('avis_decision','G','');
700          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
701          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
702          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
703          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
704          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
705                    
706          // demandeur          // demandeur
707          $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 765  class dossier extends dossier_gen {
765          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
766          $form->setRegroupe('parcelle_lot','G','');          $form->setRegroupe('parcelle_lot','G','');
767          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
768            
769      }      }
770    
       
   
771      /* =============================================================      /* =============================================================
772      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
773      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
774        * utilisé aussi pour envoyer une message au service REST d'ERP
775      * ===============================================================      * ===============================================================
776      */      */
777    
# Line 691  class dossier extends dossier_gen { Line 787  class dossier extends dossier_gen {
787                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
788                            
789          }          }
790                    
791            // envoi du message a ERP en cas d'un depot du dossier dat
792            if ($this->valF['nature'] ==
793                    $this->f->getParameter('erp_depot_dossier_dat')) {
794                $msgenque = new MessageEnqueuer();
795                $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
796                $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
797            }
798            
799            // envoi du message a ERP en cas d'une demande d'ouverture DAT
800            if ($this->valF['nature'] ==
801                    $this->f->getParameter('erp_demande_ouverture_dat')) {
802                $msgenque = new MessageEnqueuer();
803                $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
804                $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
805            }
806            
807            if ($this->valF['erp'] === true) {
808                // envoi du message a ERP en cas d'annulation d'une demande
809                if ($this->valF['nature'] ==
810                        $this->f->getParameter('erp_annulation_demande')) {
811                    $msgenque = new MessageEnqueuer();
812                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
813                    $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
814                }
815                
816                // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
817                // au dossier DAACT
818                if ($this->valF['nature'] ==
819                        $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
820                    $msgenque = new MessageEnqueuer();
821                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
822                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
823                }
824            }
825            
826      }      }
827            
828      /*      /*
829       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
830       * */       * */
831       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {       function getQuartierArrondissement($parcelle) {
832                            
833           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
834           $quartier = '';           $quartier = '';
835                    
836           /*Code impots*/           /*Récupère le code impot du quartier dans la parcelle*/
837           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
838              if (is_numeric($parcelle[$i]) )                  
839                if (is_numeric($parcelle[$i]) ){
840                        
841                  $quartier .= $parcelle[$i];                  $quartier .= $parcelle[$i];
842              else              }
843                else{
844                        
845                  break;                  break;
846                }
847             }
848                    
849          if ( $quartier !== '' ){          if ( $quartier !== '' ){
850                            
# Line 714  class dossier extends dossier_gen { Line 852  class dossier extends dossier_gen {
852              $sql = "SELECT              $sql = "SELECT
853                          quartier, arrondissement                          quartier, arrondissement
854                      FROM                      FROM
855                          quartier                          ".DB_PREFIXE."quartier
856                      WHERE                      WHERE
857                          code_impots='$quartier'";                          code_impots='$quartier'";
858                            
859              $res = $db->query($sql);              $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
860                $res = $this->db->query($sql);
861              if (database :: isError($res))              if (database :: isError($res))
862                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
863                            
864              if ( $res->numRows() > 0 ){              if ( $res->numRows() > 0 ){
865                                            
866                  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){                  return $res->fetchRow(DB_FETCHMODE_ASSOC);
                   
                     $quartier = $row['quartier'];  
                     $arrondissement = $row['arrondissement'];  
                 }  
867              }              }
868          }          }
869            
870            return NULL;
871       }       }
872            
873       /*       /*
# Line 751  class dossier extends dossier_gen { Line 888  class dossier extends dossier_gen {
888      /*      /*
889       * Retourne l'intructeur correspondant le mieux à la parcelle       * Retourne l'intructeur correspondant le mieux à la parcelle
890       * */       * */
891       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
892                    
893            $quartier = ( $quartier == NULL ) ? -1 : $quartier;
894            $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
895                    
896            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
897          $sql = "          $sql = "
898             SELECT             SELECT
899                 instructeur, section, quartier, arrondissement, nature                 dossier_autorisation_type_detaille
900             FROM             FROM
901                 lien_localisation_nature l                 ".DB_PREFIXE."dossier_autorisation
902             WHERE             WHERE
903                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR                 dossier_autorisation = '$dossier_autorisation'";    
904                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR          
905                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR          $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
906                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR          $resDATD = $this->db->query($sql);
907                 ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR          if (database :: isError($resDATD))
908                 ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR              die($resDATD->getMessage()."erreur ".$sql);
                ( 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);  
           
         if ( $res->numRows() > 0 ){  
             $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);  
             return $row['instructeur'];  
         }  
909                    
910            if ( $resDATD->numRows() > 0 ){
911                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
912                
913                $sql = "
914                   SELECT
915                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
916                   FROM
917                       ".DB_PREFIXE."affectation_automatique l
918                   WHERE
919                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
920                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
921                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
922                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
923                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
924                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
925                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
926                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
927                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
928                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
929                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
930                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
931                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
932                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
933                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
934                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
935                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
936                   LIMIT 1
937                ";
938                
939                $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
940                $res = $this->db->query($sql);
941                if (database :: isError($res))
942                    die($res->getMessage()."erreur ".$sql);
943                
944                if ( $res->numRows() > 0 ){
945                    
946                    $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
947                    
948                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
949                    $res = $this->db->query($sql);
950                    if (database :: isError($res))
951                        die($res->getMessage()."erreur ".$sql);
952                        
953                    if ( $res->numRows() > 0 ){
954                        
955                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
956                        $row['division'] = $rowT['division'];
957                    }
958                    
959                    return $row;
960                }
961            }
962    
963          return NULL;          return NULL;
964       }       }
965            
# Line 798  class dossier extends dossier_gen { Line 970  class dossier extends dossier_gen {
970      */      */
971    
972      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
973            //
974            $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
975                    
976            // Initialisation des variables nécessaires à l'affectation automatique
977            $quartier = NULL;
978            $arrondissement = NULL;
979            $section = NULL;
980            $instructeur = NULL;
981            
982            // Si la parcelle n'est pas vide alors on récupère la section, le
983            // quartier et l'arrondissement
984            if ($val['parcelle'] != '') {
985                // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
986                $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
987                if ( $quartierArrondissement!= NULL ){
988                                    
989          /*Localisation*/                  $quartier = $quartierArrondissement['quartier'];
990          $quartier = 'NULL';                  $arrondissement = $quartierArrondissement['arrondissement'];
991          $arrondissement = 'NULL';              }
992          $section = 'NULL' ;              // Si il n'y a pas d'arrondissement alors on vide le quartier
993                        if ( strcmp($arrondissement,'') == 0 )  {
994          if($val['parcelle']!=''){                  
995                                $arrondissement = NULL;
996              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);                  $quartier = NULL;
997                            }
998              if ( strcmp($arrondissement,'NULL') == 0 )              // On récupère la section
                 $quartier = 'NULL';  
               
999              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
               
               
1000          }          }
1001                    
1002          /*Instructeur*/          // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1003          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){          // alors on récupère l'instructeur et la division depuis l'affectation
1004                          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
             $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);  
1005                            
1006              if ( $instructeur != NULL )              //
1007                $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1008                if ( $instructeurDivision != NULL ){
1009                    
1010                    $instructeur = $instructeurDivision['instructeur'];
1011                    $division = $instructeurDivision['division'];
1012                }
1013                
1014                if ( $instructeur != NULL ){
1015                    
1016                  $this->valF['instructeur'] = $instructeur;                  $this->valF['instructeur'] = $instructeur;
1017              else {                  $this->valF['division'] = $division;
1018                  if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )              } else {
1019                    if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1020                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1021                  else                  } else {
1022                      $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/>");
1023                    }
1024              }              }
1025            } else {
1026                $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1027          }          }
1028                    //
1029          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/>");  
1030      }      }
1031    
1032      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 853  class dossier extends dossier_gen { Line 1046  class dossier extends dossier_gen {
1046              }              }
1047                  $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>");    
1048              }              }
1049         }          }
1050            
1051            // BOGUE: le test pour la nature doit etre change parce que
1052            // 'erp_depot_dossier_dat' n'a pas la connexion directe avec
1053            // qualification d'un dossier, mais c'est necessaire pour les tests
1054            if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1055                && $this->valF['a_qualifier'] === false) {
1056                
1057                $dossier_nature_dat = array(
1058                        $this->f->getParameter('erp_depot_dossier_dat'),
1059                        $this->f->getParameter('erp_demande_ouverture_dat'));
1060                
1061                // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1062                // de la qualification URBA
1063                if (in_array($this->valF['nature'], $dossier_nature_dat)) {
1064                    $msgenque = new MessageEnqueuer();
1065                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1066                    $msgenque->setCompetence($this->valF['autorite_competente']);
1067                    $msgenque->setContraintePlu($this->valF['servitude']);
1068                    $msgenque->setReferenceCadastrale(
1069                            $this->getReferenceCadastrale($this->valF['dossier']));
1070                    $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1071                }
1072                
1073                // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1074                // qui etait classifie come ERP
1075                if ($this->valF['nature'] == 'PC' && $this->valF['erp'] == true) {
1076                    $msgenque = new MessageEnqueuer();
1077                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1078                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1079                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1080                }
1081                
1082            }    
1083    
1084      }      }
1085        
1086        
1087        /**
1088         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1089         * specifique
1090         * @param string $dossier L'identifiant du dossier
1091         * @return string|null La reference cadastrale si elle est trouve,
1092         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1093         */
1094        function getReferenceCadastrale($dossier) {
1095            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1096            $res = $this->db->limitquery($sql, 0, 1);
1097            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1098                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1099            // Si une erreur survient on die
1100            if (database::isError($res, true)) {
1101                // Appel de la methode de recuperation des erreurs
1102                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1103            }
1104            // retourne la nature du dossier
1105            while ($row =& $res->fetchRow()) {
1106                return $row[0];
1107            }
1108            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1109            return NULL;
1110        }
1111        
1112    
1113      function sig_parametre(&$db){      function sig_parametre(&$db){
1114          if (file_exists ("../dyn/var.inc"))          if (file_exists ("../dyn/var.inc"))

Legend:
Removed from v.626  
changed lines
  Added in v.948

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26