/[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 912 by mlimic, Thu Nov 29 17:39:22 2012 UTC revision 948 by nhaye, Fri Nov 30 16:29:37 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          // 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 316  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('enjeu_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 713  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 751  class dossier extends dossier_gen { Line 804  class dossier extends dossier_gen {
804              $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);              $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
805          }          }
806                    
807          // envoi du message a ERP en cas d'annulation d'une demande          if ($this->valF['erp'] === true) {
808          if ($this->valF['nature'] ==              // envoi du message a ERP en cas d'annulation d'une demande
809                  $this->f->getParameter('erp_annulation_demande')) {              if ($this->valF['nature'] ==
810              $msgenque = new MessageEnqueuer();                      $this->f->getParameter('erp_annulation_demande')) {
811              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  $msgenque = new MessageEnqueuer();
812              $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
813                    $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
814                }
815                
816                // envoi du message a ERP en cas d'ouverture d'un dossier PC "rattache"
817                // au dossier DAACT
818                if ($this->valF['nature'] ==
819                        $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
820                    $msgenque = new MessageEnqueuer();
821                    $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
822                    $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
823                }
824          }          }
825                    
826      }      }
# Line 788  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 824  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              $row = $res->fetchRow(DB_FETCHMODE_ASSOC);              $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              $sql = "SELECT division FROM instructeur WHERE instructeur = ".$row['instructeur'];              $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
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 917  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 1010  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.912  
changed lines
  Added in v.948

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26