/[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 943 by fmichon, Fri Nov 30 15:25: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 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          }          }
           
         /* 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');  
369      }      }
370    
371      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 446  class dossier extends dossier_gen { Line 513  class dossier extends dossier_gen {
513      }          }    
514    
515      function setGroupe(&$form,$maj){      function setGroupe(&$form,$maj){
516          If ($maj==0){          //If ($maj==0){
517              $form->setGroupe('date_demande','D');          //    $form->setGroupe('date_demande','D');
518              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
519              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
520          }else{          //}else{
521              $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
522              $form->setGroupe('nature','G');          //    $form->setGroupe('nature','G');
523              $form->setGroupe('annee','G');          //    $form->setGroupe('annee','G');
524              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_demande','G');
525              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
526              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
527          }          //}
528          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
529          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
530          $form->setGroupe('demandeur_nom','F');          $form->setGroupe('demandeur_nom','F');
# Line 573  class dossier extends dossier_gen { Line 640  class dossier extends dossier_gen {
640          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
641      }      }
642    
643      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
644          // depot          //
645          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
646              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
647          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
648          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
649              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
650              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
651          }          $form->setFieldset('date_demande', 'D', _("Depot"));
652          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
653          $form->setRegroupe('division','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
654            $form->setFieldset('enjeu_erp', 'F');
655            $form->setBloc('enjeu_erp', 'F');
656            $form->setBloc('enjeu_erp', 'F');
657            //
658            $form->setBloc('objet_dossier', 'D', '', 'col_12');
659            //
660            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
661            $form->setRegroupe('date_conformite','F','');
662            //
663            $form->setBloc('terrain_superficie', 'F');
664                    
665        }
666        
667        function setRegroupe(&$form,$maj) {
668            //// depot
669            //If ($maj==0){
670            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
671            //}
672            //If ($maj==1){
673            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
674            //    $form->setRegroupe('date_demande','G','');
675            //}
676            //$form->setRegroupe('date_depot','G','');
677            //$form->setRegroupe('division','F','');
678    
679          // travaux          // travaux
680          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
681          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
682          $form->setRegroupe('travaux','G','');          $form->setRegroupe('travaux','G','');
683          $form->setRegroupe('travaux_complement','F','');          $form->setRegroupe('travaux_complement','F','');
684                    
685          // instruction          //// instruction
686          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
687          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
688          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
689          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
690          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
691          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
692          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
693          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
694          $form->setRegroupe('avis_decision','G','');          //$form->setRegroupe('avis_decision','G','');
695          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
696          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
697          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
698          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
699          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
700                    
701          // demandeur          // demandeur
702          $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 760  class dossier extends dossier_gen {
760          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
761          $form->setRegroupe('parcelle_lot','G','');          $form->setRegroupe('parcelle_lot','G','');
762          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
763            
764      }      }
765    
       
   
766      /* =============================================================      /* =============================================================
767      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
768      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
769        * utilisé aussi pour envoyer une message au service REST d'ERP
770      * ===============================================================      * ===============================================================
771      */      */
772    
# Line 691  class dossier extends dossier_gen { Line 782  class dossier extends dossier_gen {
782                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
783                            
784          }          }
785                    
786            // envoi du message a ERP en cas d'un depot du dossier dat
787            if ($this->valF['nature'] ==
788                    $this->f->getParameter('erp_depot_dossier_dat')) {
789                $msgenque = new MessageEnqueuer();
790                $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
791                $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
792            }
793            
794            // envoi du message a ERP en cas d'une demande d'ouverture DAT
795            if ($this->valF['nature'] ==
796                    $this->f->getParameter('erp_demande_ouverture_dat')) {
797                $msgenque = new MessageEnqueuer();
798                $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
799                $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
800            }
801            
802            if ($this->valF['erp'] === true) {
803                // envoi du message a ERP en cas d'annulation d'une demande
804                if ($this->valF['nature'] ==
805                        $this->f->getParameter('erp_annulation_demande')) {
806                    $msgenque = new MessageEnqueuer();
807                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
808                    $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
809                }
810                
811                // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
812                // au dossier DAACT
813                if ($this->valF['nature'] ==
814                        $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
815                    $msgenque = new MessageEnqueuer();
816                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
817                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
818                }
819            }
820            
821      }      }
822            
823      /*      /*
824       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
825       * */       * */
826       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {       function getQuartierArrondissement($parcelle) {
827                            
828           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
829           $quartier = '';           $quartier = '';
830                    
831           /*Code impots*/           /*Récupère le code impot du quartier dans la parcelle*/
832           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
833              if (is_numeric($parcelle[$i]) )                  
834                if (is_numeric($parcelle[$i]) ){
835                        
836                  $quartier .= $parcelle[$i];                  $quartier .= $parcelle[$i];
837              else              }
838                else{
839                        
840                  break;                  break;
841                }
842             }
843                    
844          if ( $quartier !== '' ){          if ( $quartier !== '' ){
845                            
# Line 714  class dossier extends dossier_gen { Line 847  class dossier extends dossier_gen {
847              $sql = "SELECT              $sql = "SELECT
848                          quartier, arrondissement                          quartier, arrondissement
849                      FROM                      FROM
850                          quartier                          ".DB_PREFIXE."quartier
851                      WHERE                      WHERE
852                          code_impots='$quartier'";                          code_impots='$quartier'";
853                            
854              $res = $db->query($sql);              $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
855                $res = $this->db->query($sql);
856              if (database :: isError($res))              if (database :: isError($res))
857                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
858                            
859              if ( $res->numRows() > 0 ){              if ( $res->numRows() > 0 ){
860                                            
861                  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){                  return $res->fetchRow(DB_FETCHMODE_ASSOC);
                   
                     $quartier = $row['quartier'];  
                     $arrondissement = $row['arrondissement'];  
                 }  
862              }              }
863          }          }
864            
865            return NULL;
866       }       }
867            
868       /*       /*
# Line 751  class dossier extends dossier_gen { Line 883  class dossier extends dossier_gen {
883      /*      /*
884       * Retourne l'intructeur correspondant le mieux à la parcelle       * Retourne l'intructeur correspondant le mieux à la parcelle
885       * */       * */
886       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
887                    
888            $quartier = ( $quartier == NULL ) ? -1 : $quartier;
889            $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
890                    
891            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
892          $sql = "          $sql = "
893             SELECT             SELECT
894                 instructeur, section, quartier, arrondissement, nature                 dossier_autorisation_type_detaille
895             FROM             FROM
896                 lien_localisation_nature l                 ".DB_PREFIXE."dossier_autorisation
897             WHERE             WHERE
898                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR                 dossier_autorisation = '$dossier_autorisation'";    
899                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR          
900                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR          $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
901                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR          $resDATD = $this->db->query($sql);
902                 ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR          if (database :: isError($resDATD))
903                 ( 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'];  
         }  
904                    
905            if ( $resDATD->numRows() > 0 ){
906                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
907                
908                $sql = "
909                   SELECT
910                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
911                   FROM
912                       ".DB_PREFIXE."affectation_automatique l
913                   WHERE
914                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
915                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
916                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
917                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
918                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
919                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
920                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
921                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
922                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
923                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
924                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
925                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
926                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
927                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
928                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
929                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
930                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
931                   LIMIT 1
932                ";
933                
934                $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
935                $res = $this->db->query($sql);
936                if (database :: isError($res))
937                    die($res->getMessage()."erreur ".$sql);
938                
939                if ( $res->numRows() > 0 ){
940                    
941                    $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
942                    
943                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
944                    $res = $this->db->query($sql);
945                    if (database :: isError($res))
946                        die($res->getMessage()."erreur ".$sql);
947                        
948                    if ( $res->numRows() > 0 ){
949                        
950                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
951                        $row['division'] = $rowT['division'];
952                    }
953                    
954                    return $row;
955                }
956            }
957    
958          return NULL;          return NULL;
959       }       }
960            
# Line 798  class dossier extends dossier_gen { Line 965  class dossier extends dossier_gen {
965      */      */
966    
967      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
968            //
969            $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
970                    
971            // Initialisation des variables nécessaires à l'affectation automatique
972            $quartier = NULL;
973            $arrondissement = NULL;
974            $section = NULL;
975            $instructeur = NULL;
976            
977            // Si la parcelle n'est pas vide alors on récupère la section, le
978            // quartier et l'arrondissement
979            if ($val['parcelle'] != '') {
980                // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
981                $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
982                if ( $quartierArrondissement!= NULL ){
983                                    
984          /*Localisation*/                  $quartier = $quartierArrondissement['quartier'];
985          $quartier = 'NULL';                  $arrondissement = $quartierArrondissement['arrondissement'];
986          $arrondissement = 'NULL';              }
987          $section = 'NULL' ;              // Si il n'y a pas d'arrondissement alors on vide le quartier
988                        if ( strcmp($arrondissement,'') == 0 )  {
989          if($val['parcelle']!=''){                  
990                                $arrondissement = NULL;
991              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);                  $quartier = NULL;
992                            }
993              if ( strcmp($arrondissement,'NULL') == 0 )              // On récupère la section
                 $quartier = 'NULL';  
               
994              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
               
               
995          }          }
996                    
997          /*Instructeur*/          // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
998          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){          // alors on récupère l'instructeur et la division depuis l'affectation
999                          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
             $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);  
1000                            
1001              if ( $instructeur != NULL )              //
1002                $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1003                if ( $instructeurDivision != NULL ){
1004                    
1005                    $instructeur = $instructeurDivision['instructeur'];
1006                    $division = $instructeurDivision['division'];
1007                }
1008                
1009                if ( $instructeur != NULL ){
1010                    
1011                  $this->valF['instructeur'] = $instructeur;                  $this->valF['instructeur'] = $instructeur;
1012              else {                  $this->valF['division'] = $division;
1013                  if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )              } else {
1014                    if ($this->f->isAccredited("dossier_modifier_instructeur")) {
1015                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");                      $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
1016                  else                  } else {
1017                      $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/>");
1018                    }
1019              }              }
1020            } else {
1021                $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
1022          }          }
1023                    //
1024          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/>");  
1025      }      }
1026    
1027      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 853  class dossier extends dossier_gen { Line 1041  class dossier extends dossier_gen {
1041              }              }
1042                  $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>");    
1043              }              }
1044         }          }
1045            
1046            // BOGUE: le test pour la nature doit etre change parce que
1047            // 'erp_depot_dossier_dat' n'a pas la connexion directe avec
1048            // qualification d'un dossier, mais c'est necessaire pour les tests
1049            if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
1050                && $this->valF['a_qualifier'] === false) {
1051                
1052                $dossier_nature_dat = array(
1053                        $this->f->getParameter('erp_depot_dossier_dat'),
1054                        $this->f->getParameter('erp_demande_ouverture_dat'));
1055                
1056                // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1057                // de la qualification URBA
1058                if (in_array($this->valF['nature'], $dossier_nature_dat)) {
1059                    $msgenque = new MessageEnqueuer();
1060                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1061                    $msgenque->setCompetence($this->valF['autorite_competente']);
1062                    $msgenque->setContraintePlu($this->valF['servitude']);
1063                    $msgenque->setReferenceCadastrale(
1064                            $this->getReferenceCadastrale($this->valF['dossier']));
1065                    $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1066                }
1067                
1068                // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1069                // qui etait classifie come ERP
1070                if ($this->valF['nature'] == 'PC' && $this->valF['erp'] == true) {
1071                    $msgenque = new MessageEnqueuer();
1072                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1073                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1074                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1075                }
1076                
1077            }    
1078    
1079      }      }
1080        
1081        
1082        /**
1083         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1084         * specifique
1085         * @param string $dossier L'identifiant du dossier
1086         * @return string|null La reference cadastrale si elle est trouve,
1087         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1088         */
1089        function getReferenceCadastrale($dossier) {
1090            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1091            $res = $this->db->limitquery($sql, 0, 1);
1092            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1093                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1094            // Si une erreur survient on die
1095            if (database::isError($res, true)) {
1096                // Appel de la methode de recuperation des erreurs
1097                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1098            }
1099            // retourne la nature du dossier
1100            while ($row =& $res->fetchRow()) {
1101                return $row[0];
1102            }
1103            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1104            return NULL;
1105        }
1106        
1107    
1108      function sig_parametre(&$db){      function sig_parametre(&$db){
1109          if (file_exists ("../dyn/var.inc"))          if (file_exists ("../dyn/var.inc"))

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26