/[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 584 by vpihour, Fri Nov 2 17:15:30 2012 UTC revision 939 by vpihour, Fri Nov 30 13:53:11 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 30  class dossier extends dossier_gen { Line 31  class dossier extends dossier_gen {
31      } // fin constructeur      } // fin constructeur
32            
33      function setValFAjout($val = array()) {      function setValFAjout($val = array()) {
34          // 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;  
35      }      }
36    
37      function setvalF($val){      function setvalF($val){
# Line 276  class dossier extends dossier_gen { Line 265  class dossier extends dossier_gen {
265              $form->setType('temp3',$temp3_type);              $form->setType('temp3',$temp3_type);
266              $form->setType('temp4',$temp4_type);              $form->setType('temp4',$temp4_type);
267              $form->setType('temp5',$temp5_type);              $form->setType('temp5',$temp5_type);
268                $form->setType('a_qualifier', 'checkbox');
269            }
270            if ($maj == 1) {
271                //
272                if ($this->f->isAccredited("dossier_modifier_instructeur")) {
273                    $form->setType('instructeur', 'select');
274                } else {
275                    $form->setType('instructeur', 'selecthiddenstatic');
276                }
277                //
278                if($this->f->getParameter('afficher_division') === 'true') {
279                    //
280                    if ($this->f->isAccredited("dossier_modifier_division")) {
281                        $form->setType('division', 'select');
282                    } else {
283                        $form->setType('division', 'selecthiddenstatic');
284                    }
285                } else {
286                    $form->setType('division', 'hidden');
287                }
288          }          }
289          if($maj == 3) {          if($maj == 3) {
290              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
# Line 289  class dossier extends dossier_gen { Line 298  class dossier extends dossier_gen {
298              $form->setType('parcelle_lot_archive','hidden');              $form->setType('parcelle_lot_archive','hidden');
299              $form->setType('geom1','hidden');              $form->setType('geom1','hidden');
300              $form->setType('geom','hidden');              $form->setType('geom','hidden');
301                $form->setType('a_qualifier', 'checkboxstatic');
302          }          }
303          if($this->f->getParameter('afficher_division')==='true') {          //
304              $form->setType('division','hiddenstatic');          if(!$this->f->getParameter('afficher_division') === 'true') {
305          } else {              $form->setType('division', 'hidden');
306              $form->setType('division','hidden');          }
307            $form->setType('dossier_autorisation', 'hiddenstatic');
308            //
309            if ($maj == 0) {
310                $form->setType('dossier_autorisation', 'select');
311          }          }
           
         /* Gestion des droits pour l'ajout forcé d'un instructeur, si le profil est 5, c'est un administrateur */  
         if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] != 5 )  
             $form->setType('instructeur', 'hidden');  
312      }      }
313    
314      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 446  class dossier extends dossier_gen { Line 456  class dossier extends dossier_gen {
456      }          }    
457    
458      function setGroupe(&$form,$maj){      function setGroupe(&$form,$maj){
459          If ($maj==0){          //If ($maj==0){
460              $form->setGroupe('date_demande','D');          //    $form->setGroupe('date_demande','D');
461              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
462              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
463          }else{          //}else{
464              $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
465              $form->setGroupe('nature','G');          //    $form->setGroupe('nature','G');
466              $form->setGroupe('annee','G');          //    $form->setGroupe('annee','G');
467              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_demande','G');
468              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
469              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
470          }          //}
471          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
472          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
473          $form->setGroupe('demandeur_nom','F');          $form->setGroupe('demandeur_nom','F');
# Line 488  class dossier extends dossier_gen { Line 498  class dossier extends dossier_gen {
498          $form->setGroupe('delegataire_telephone','F');          $form->setGroupe('delegataire_telephone','F');
499                                
500          $form->setGroupe('architecte','D');          $form->setGroupe('architecte','D');
501          $form->setGroupe('architecte_nom','G');          $form->setGroupe('architecte_nom','F');
502          $form->setGroupe('saisie_architecte','F');          //$form->setGroupe('saisie_architecte','F');
503                    
504          $form->setGroupe('travaux','D');            $form->setGroupe('travaux','D');  
505          $form->setGroupe('travaux_complement','F');          $form->setGroupe('travaux_complement','F');
# Line 573  class dossier extends dossier_gen { Line 583  class dossier extends dossier_gen {
583          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
584      }      }
585    
586      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
587          // depot          //
588          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
589              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
590          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
591          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
592              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
593              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
594          }          $form->setFieldset('date_demande', 'D', _("Depot"));
595          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
596          $form->setRegroupe('division','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
597            $form->setFieldset('enjeu_erp', 'F');
598            $form->setBloc('enjeu_erp', 'F');
599            $form->setBloc('enjeu_erp', 'F');
600            //
601            $form->setBloc('objet_dossier', 'D', '', 'col_12');
602            //
603            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
604            $form->setRegroupe('date_conformite','F','');
605            //
606            $form->setBloc('terrain_superficie', 'F');
607                    
608        }
609        
610        function setRegroupe(&$form,$maj) {
611            //// depot
612            //If ($maj==0){
613            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
614            //}
615            //If ($maj==1){
616            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
617            //    $form->setRegroupe('date_demande','G','');
618            //}
619            //$form->setRegroupe('date_depot','G','');
620            //$form->setRegroupe('division','F','');
621    
622          // travaux          // travaux
623          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
624          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
625          $form->setRegroupe('travaux','G','');          $form->setRegroupe('travaux','G','');
626          $form->setRegroupe('travaux_complement','F','');          $form->setRegroupe('travaux_complement','F','');
627                    
628          // instruction          //// instruction
629          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
630          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
631          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
632          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
633          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
634          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
635          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
636          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
637          $form->setRegroupe('avis_decision','G','');          //$form->setRegroupe('avis_decision','G','');
638          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
639          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
640          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
641          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
642          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
643                    
644          // demandeur          // demandeur
645          $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 703  class dossier extends dossier_gen {
703          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);          $form->setRegroupe('amenagement','D',_('Amenagement'), $this->aff_amenagement);
704          $form->setRegroupe('parcelle_lot','G','');          $form->setRegroupe('parcelle_lot','G','');
705          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
706            
707      }      }
708    
709            
# Line 676  class dossier extends dossier_gen { Line 711  class dossier extends dossier_gen {
711      /* =============================================================      /* =============================================================
712      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
713      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
714        * utilisé aussi pour envoyer une message au service REST d'ERP
715      * ===============================================================      * ===============================================================
716      */      */
717    
# Line 691  class dossier extends dossier_gen { Line 727  class dossier extends dossier_gen {
727                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
728                            
729          }          }
730                    
731            // envoi du message a ERP en cas d'un depot du dossier dat
732            if ($this->valF['nature'] ==
733                    $this->f->getParameter('erp_depot_dossier_dat')) {
734                $msgenque = new MessageEnqueuer();
735                $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
736                $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
737            }
738            
739            // envoi du message a ERP en cas d'une demande d'ouverture DAT
740            if ($this->valF['nature'] ==
741                    $this->f->getParameter('erp_demande_ouverture_dat')) {
742                $msgenque = new MessageEnqueuer();
743                $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
744                $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
745            }
746            
747            if ($this->valF['erp'] === true) {
748                // envoi du message a ERP en cas d'annulation d'une demande
749                if ($this->valF['nature'] ==
750                        $this->f->getParameter('erp_annulation_demande')) {
751                    $msgenque = new MessageEnqueuer();
752                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
753                    $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
754                }
755                
756                // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
757                // au dossier DAACT
758                if ($this->valF['nature'] ==
759                        $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
760                    $msgenque = new MessageEnqueuer();
761                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
762                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
763                }
764            }
765            
766      }      }
767            
768      /*      /*
769       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
770       * */       * */
771       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {       function getQuartierArrondissement($parcelle) {
772                            
773           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
774             $quartier = '';
775                    
776           /*Code impots*/           /*Récupère le code impot du quartier dans la parcelle*/
777           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ){
778              if (is_numeric($parcelle[$i]) )                  
779                if (is_numeric($parcelle[$i]) ){
780                        
781                  $quartier .= $parcelle[$i];                  $quartier .= $parcelle[$i];
782              else              }
783                else{
784                        
785                  break;                  break;
786                }
787             }
788                    
789          if ( $quartier !== '' ){          if ( $quartier !== '' ){
790                            
# Line 713  class dossier extends dossier_gen { Line 792  class dossier extends dossier_gen {
792              $sql = "SELECT              $sql = "SELECT
793                          quartier, arrondissement                          quartier, arrondissement
794                      FROM                      FROM
795                          quartier                          ".DB_PREFIXE."quartier
796                      WHERE                      WHERE
797                          code_impots='$quartier'";                          code_impots='$quartier'";
798                            
799              $res = $db->query($sql);              $this->addToLog("getQuartierArrondissement(parcelle) : db->query(\"$sql\")", VERBOSE_MODE);
800                $res = $this->db->query($sql);
801              if (database :: isError($res))              if (database :: isError($res))
802                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
803                            
804              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              if ( $res->numRows() > 0 ){
805                                        
806                  $quartier = $row['quartier'];                  return $res->fetchRow(DB_FETCHMODE_ASSOC);
                 $arrondissement = $row['arrondissement'];  
807              }              }
808          }          }
809            
810            return NULL;
811       }       }
812            
813       /*       /*
# Line 747  class dossier extends dossier_gen { Line 828  class dossier extends dossier_gen {
828      /*      /*
829       * Retourne l'intructeur correspondant le mieux à la parcelle       * Retourne l'intructeur correspondant le mieux à la parcelle
830       * */       * */
831       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
832                    
833            $quartier = ( $quartier == NULL ) ? -1 : $quartier;
834            $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;
835                    
836            /*Récupération du dossier_autorisation_type_detaille concerné par le $dossier_autorisation*/
837          $sql = "          $sql = "
838             SELECT             SELECT
839                 instructeur, section, quartier, arrondissement, nature                 dossier_autorisation_type_detaille
840             FROM             FROM
841                 lien_localisation_nature l                 ".DB_PREFIXE."dossier_autorisation
842             WHERE             WHERE
843                 ( 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);  
           
         if ( $res->numRows() > 0 ){  
             $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);  
             return $row['instructeur'];  
         }  
844                    
845            $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
846            $resDATD = $this->db->query($sql);
847            if (database :: isError($resDATD))
848                die($resDATD->getMessage()."erreur ".$sql);
849            
850            if ( $resDATD->numRows() > 0 ){
851                $rowDATD = $resDATD->fetchRow(DB_FETCHMODE_ASSOC);
852                
853                $sql = "
854                   SELECT
855                       instructeur, section, quartier, arrondissement, dossier_autorisation_type_detaille
856                   FROM
857                       ".DB_PREFIXE."affectation_automatique l
858                   WHERE
859                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
860                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
861                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
862                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
863                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
864                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
865                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
866                       ( dossier_autorisation_type_detaille IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
867                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
868                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
869                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
870                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
871                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
872                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
873                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
874                       ( dossier_autorisation_type_detaille = ".$rowDATD['dossier_autorisation_type_detaille']." AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
875                   ORDER BY section, quartier, arrondissement, dossier_autorisation_type_detaille
876                   LIMIT 1
877                ";
878                
879                $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
880                $res = $this->db->query($sql);
881                if (database :: isError($res))
882                    die($res->getMessage()."erreur ".$sql);
883                
884                if ( $res->numRows() > 0 ){
885                    
886                    $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
887                    
888                    $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];
889                    $res = $this->db->query($sql);
890                    if (database :: isError($res))
891                        die($res->getMessage()."erreur ".$sql);
892                        
893                    if ( $res->numRows() > 0 ){
894                        
895                        $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);
896                        $row['division'] = $rowT['division'];
897                    }
898                    
899                    return $row;
900                }
901            }
902    
903          return NULL;          return NULL;
904       }       }
905            
# Line 794  class dossier extends dossier_gen { Line 910  class dossier extends dossier_gen {
910      */      */
911    
912      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
913          if($val['parcelle']!=''){          //
914                                $this->addToLog("triggerajouter() : start", EXTRA_VERBOSE_MODE);
915              /*Localisation*/          
916              $quartier = NULL;          // Initialisation des variables nécessaires à l'affectation automatique
917              $arrondissement = NULL;          $quartier = NULL;
918                        $arrondissement = NULL;
919              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);          $section = NULL;
920              $section = $this->getSection($val['parcelle']);          $instructeur = NULL;
921              /*Instructeur*/          
922              if ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' && $val['nature'] != '' ){          // Si la parcelle n'est pas vide alors on récupère la section, le
923                                // quartier et l'arrondissement
924                  $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);          if ($val['parcelle'] != '') {
925                // Cette méthode récupère l'arrondissement et le quartier associé à une parcelle
926                $quartierArrondissement = $this->getQuartierArrondissement($val['parcelle']);
927                if ( $quartierArrondissement!= NULL ){
928                                    
929                  if ( $instructeur != NULL )                  $quartier = $quartierArrondissement['quartier'];
930                      $this->valF['instructeur'] = $instructeur;                  $arrondissement = $quartierArrondissement['arrondissement'];
                 else {  
                     if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )  
                         $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");  
                     else  
                         $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");  
                 }  
931              }              }
932                // Si il n'y a pas d'arrondissement alors on vide le quartier
933                if ( strcmp($arrondissement,'') == 0 )  {
934                    
935                    $arrondissement = NULL;
936                    $quartier = NULL;
937                }
938                // On récupère la section
939                $section = $this->getSection($val['parcelle']);
940          }          }
941                    
942          else {          // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
943              if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )          // alors on récupère l'instructeur et la division depuis l'affectation
944                  $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
945              else              
946                  $this->addToMessage("<br/> "._("Parcelle non saisie, contactez votre administrateur afin d'assigner un instructeur a ce dossier.")." <br/>");              //
947                $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
948                if ( $instructeurDivision != NULL ){
949                    
950                    $instructeur = $instructeurDivision['instructeur'];
951                    $division = $instructeurDivision['division'];
952                }
953                
954                if ( $instructeur != NULL ){
955                    
956                    $this->valF['instructeur'] = $instructeur;
957                    $this->valF['division'] = $division;
958                } else {
959                    if ($this->f->isAccredited("dossier_modifier_instructeur")) {
960                        $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
961                    } else {
962                        $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
963                    }
964                }
965            } else {
966                $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
967          }          }
968            //
969            $this->addToLog("triggerajouter() : end", EXTRA_VERBOSE_MODE);
970      }      }
971    
972      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 843  class dossier extends dossier_gen { Line 986  class dossier extends dossier_gen {
986              }              }
987                  $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>");    
988              }              }
989         }          }
990            
991            // BOGUE: le test pour la nature doit etre change parce que
992            // 'erp_depot_dossier_dat' n'a pas la connexion directe avec
993            // qualification d'un dossier, mais c'est necessaire pour les tests
994            if ($this->val[array_search('a_qualifier', $this->champs)] == 't'
995                && $this->valF['a_qualifier'] === false) {
996                
997                $dossier_nature_dat = array(
998                        $this->f->getParameter('erp_depot_dossier_dat'),
999                        $this->f->getParameter('erp_demande_ouverture_dat'));
1000                
1001                // envoi du message "ERP Qualifie" pour un dossier DAT qui a besoin
1002                // de la qualification URBA
1003                if (in_array($this->valF['nature'], $dossier_nature_dat)) {
1004                    $msgenque = new MessageEnqueuer();
1005                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1006                    $msgenque->setCompetence($this->valF['autorite_competente']);
1007                    $msgenque->setContraintePlu($this->valF['servitude']);
1008                    $msgenque->setReferenceCadastrale(
1009                            $this->getReferenceCadastrale($this->valF['dossier']));
1010                    $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1011                }
1012                
1013                // envoi des messages a ERP en cas du dossier PC traite par URBA, et
1014                // qui etait classifie come ERP
1015                if ($this->valF['nature'] == 'PC' && $this->valF['erp'] == true) {
1016                    $msgenque = new MessageEnqueuer();
1017                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1018                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1019                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1020                }
1021                
1022            }    
1023    
1024      }      }
1025        
1026        
1027        /**
1028         * Retourne la reference cadastrale de la demande attache a un dossier ERP
1029         * specifique
1030         * @param string $dossier L'identifiant du dossier
1031         * @return string|null La reference cadastrale si elle est trouve,
1032         * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1033         */
1034        function getReferenceCadastrale($dossier) {
1035            $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1036            $res = $this->db->limitquery($sql, 0, 1);
1037            $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1038                            str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);
1039            // Si une erreur survient on die
1040            if (database::isError($res, true)) {
1041                // Appel de la methode de recuperation des erreurs
1042                $this->erreur_db($res->getDebugInfo(), $res->getMessage(), 'demande');
1043            }
1044            // retourne la nature du dossier
1045            while ($row =& $res->fetchRow()) {
1046                return $row[0];
1047            }
1048            // la nature n'etait pas trouve, ce qui ne devrait pas se passer
1049            return NULL;
1050        }
1051        
1052    
1053      function sig_parametre(&$db){      function sig_parametre(&$db){
1054          if (file_exists ("../dyn/var.inc"))          if (file_exists ("../dyn/var.inc"))
# Line 934  class dossier extends dossier_gen { Line 1138  class dossier extends dossier_gen {
1138                  if (database :: isError($res))                  if (database :: isError($res))
1139                      die($res->getMessage()."erreur ".$sql);                      die($res->getMessage()."erreur ".$sql);
1140              }              }
1141              $this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");              //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
1142          }          }
1143      }      }
1144    

Legend:
Removed from v.584  
changed lines
  Added in v.939

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26