/[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 920 by nhaye, Thu Nov 29 19:19:09 2012 UTC revision 959 by fmichon, Mon Dec 3 02:19:43 2012 UTC
# Line 26  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          /*          $this->valF['dossier'] = $val['dossier_autorisation'].str_pad(rand(1, 99),2, "0", STR_PAD_LEFT);
         // Cle primaire  
         $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;  
         */  
         $this->valF['dossier'] = time();  
92      }      }
93    
94      function setvalF($val){      function setvalF($val){
# Line 319  class dossier extends dossier_gen { Line 361  class dossier extends dossier_gen {
361          if(!$this->f->getParameter('afficher_division') === 'true') {          if(!$this->f->getParameter('afficher_division') === 'true') {
362              $form->setType('division', 'hidden');              $form->setType('division', 'hidden');
363          }          }
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('option_ERP') != 'true') {
371                $form->setType('erp', 'hidden');
372                $form->setType('enjeu_erp', 'hidden');
373            }
374      }      }
375    
376      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 716  class dossier extends dossier_gen { Line 768  class dossier extends dossier_gen {
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
# Line 743  class dossier extends dossier_gen { Line 793  class dossier extends dossier_gen {
793                  $this->f->getParameter('erp_depot_dossier_dat')) {                  $this->f->getParameter('erp_depot_dossier_dat')) {
794              $msgenque = new MessageEnqueuer();              $msgenque = new MessageEnqueuer();
795              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
796              $msgenque->enqueueMessage($msgenque->ERP_DEPOT_DOSSIER_DAT);              $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
797          }          }
798                    
799          // envoi du message a ERP en cas d'une demande d'ouverture DAT          // envoi du message a ERP en cas d'une demande d'ouverture DAT
# Line 751  class dossier extends dossier_gen { Line 801  class dossier extends dossier_gen {
801                  $this->f->getParameter('erp_demande_ouverture_dat')) {                  $this->f->getParameter('erp_demande_ouverture_dat')) {
802              $msgenque = new MessageEnqueuer();              $msgenque = new MessageEnqueuer();
803              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
804              $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_OUVERTURE_DAT);              $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
805          }          }
806                    
807          if ($this->valF['erp'] === true) {          if ($this->valF['erp'] === true) {
# Line 760  class dossier extends dossier_gen { Line 810  class dossier extends dossier_gen {
810                      $this->f->getParameter('erp_annulation_demande')) {                      $this->f->getParameter('erp_annulation_demande')) {
811                  $msgenque = new MessageEnqueuer();                  $msgenque = new MessageEnqueuer();
812                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
813                  $msgenque->enqueueMessage($msgenque->ERP_ANNULATION_DEMANDE);                  $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
814              }              }
815                            
816              // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"              // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
# Line 769  class dossier extends dossier_gen { Line 819  class dossier extends dossier_gen {
819                      $this->f->getParameter('erp_demande_ouverture_pc_daact')) {                      $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
820                  $msgenque = new MessageEnqueuer();                  $msgenque = new MessageEnqueuer();
821                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
822                  $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_OUVERTURE_PC);                  $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
823              }              }
824          }          }
825                    
# Line 802  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                            
# Line 838  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 getInstructeurDivision( $quartier, $arrondissement, $section, $nature) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
892                                    
893          $quartier = ( $quartier == NULL ) ? -1 : $quartier;          $quartier = ( $quartier == NULL ) ? -1 : $quartier;
894          $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;          $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'";    
                ( 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  
         ";  
           
         $this->addToLog("getInstructeurDivision( quartier, arrondissement, section, nature) : db->query(\"$sql\")", VERBOSE_MODE);  
         $res = $this->db->query($sql);  
         if (database :: isError($res))  
             die($res->getMessage()."erreur ".$sql);  
904                    
905          if ( $res->numRows() > 0 ){          $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
906            $resDATD = $this->db->query($sql);
907            if (database :: isError($resDATD))
908                die($resDATD->getMessage()."erreur ".$sql);
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              $row = $res->fetchRow(DB_FETCHMODE_ASSOC);              $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
               
             $sql = "SELECT division FROM instructeur WHERE instructeur = ".$row['instructeur'];  
940              $res = $this->db->query($sql);              $res = $this->db->query($sql);
941              if (database :: isError($res))              if (database :: isError($res))
942                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
943                                
944              if ( $res->numRows() > 0 ){              if ( $res->numRows() > 0 ){
945                                    
946                  $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);                  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
947                  $row['division'] = $rowT['division'];                  
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              }              }
               
             return $row;  
961          }          }
962            
963          return NULL;          return NULL;
964       }       }
965            
# Line 931  class dossier extends dossier_gen { Line 999  class dossier extends dossier_gen {
999              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
1000          }          }
1001                    
1002          // Si aucun instructeur n'est saisi et que la nature n'est pas vide          // Si aucun instructeur n'est saisi et que la dossier_autorisation_type_detaille n'est pas vide
1003          // alors on récupère l'instructeur et la division depuis l'affectation          // alors on récupère l'instructeur et la division depuis l'affectation
1004          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ) {          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
1005                            
1006              //              //
1007              $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['nature']);              $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
1008              if ( $instructeurDivision != NULL ){              if ( $instructeurDivision != NULL ){
1009                                    
1010                  $instructeur = $instructeurDivision['instructeur'];                  $instructeur = $instructeurDivision['instructeur'];
# Line 999  class dossier extends dossier_gen { Line 1067  class dossier extends dossier_gen {
1067                  $msgenque->setContraintePlu($this->valF['servitude']);                  $msgenque->setContraintePlu($this->valF['servitude']);
1068                  $msgenque->setReferenceCadastrale(                  $msgenque->setReferenceCadastrale(
1069                          $this->getReferenceCadastrale($this->valF['dossier']));                          $this->getReferenceCadastrale($this->valF['dossier']));
1070                  $msgenque->enqueueMessage($msgenque->ERP_QUALIFIE);                                              $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1071              }              }
1072                            
1073              // envoi des messages a ERP en cas du dossier PC traite par URBA, et              // envoi des messages a ERP en cas du dossier PC traite par URBA, et
# Line 1007  class dossier extends dossier_gen { Line 1075  class dossier extends dossier_gen {
1075              if ($this->valF['nature'] == 'PC' && $this->valF['erp'] == true) {              if ($this->valF['nature'] == 'PC' && $this->valF['erp'] == true) {
1076                  $msgenque = new MessageEnqueuer();                  $msgenque = new MessageEnqueuer();
1077                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1078                  $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_COMPLETUDE_PC);                  $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1079                  $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_QUALIFICATION_PC);                  $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1080              }              }
1081                            
1082          }              }    
# Line 1024  class dossier extends dossier_gen { Line 1092  class dossier extends dossier_gen {
1092       * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.       * sinon NULL. En cas d'erreur de la BD, l'execution s'arrete.
1093       */       */
1094      function getReferenceCadastrale($dossier) {      function getReferenceCadastrale($dossier) {
1095          $sql = "SELECT terrain_references_cadastrales FROM demande WHERE dossier_instruction = '" . $dossier . "'";          $sql = "SELECT terrain_references_cadastrales FROM ".DB_PREFIXE."demande WHERE dossier_instruction = '" . $dossier . "'";
1096          $res = $this->db->limitquery($sql, 0, 1);          $res = $this->db->limitquery($sql, 0, 1);
1097          $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".          $this->addToLog("getReferenceCadastrale(): db->limitquery(\"".
1098                          str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);                          str_replace(",",", ",$sql)."\", 0, 1);", VERBOSE_MODE);

Legend:
Removed from v.920  
changed lines
  Added in v.959

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26