/[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 923 by fmichon, Thu Nov 29 22:51:42 2012 UTC revision 939 by vpihour, Fri Nov 30 13:53:11 2012 UTC
# Line 31  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          /*          $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();  
35      }      }
36    
37      function setvalF($val){      function setvalF($val){
# Line 319  class dossier extends dossier_gen { Line 304  class dossier extends dossier_gen {
304          if(!$this->f->getParameter('afficher_division') === 'true') {          if(!$this->f->getParameter('afficher_division') === 'true') {
305              $form->setType('division', 'hidden');              $form->setType('division', 'hidden');
306          }          }
307            $form->setType('dossier_autorisation', 'hiddenstatic');
308            //
309            if ($maj == 0) {
310                $form->setType('dossier_autorisation', 'select');
311            }
312      }      }
313    
314      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 743  class dossier extends dossier_gen { Line 733  class dossier extends dossier_gen {
733                  $this->f->getParameter('erp_depot_dossier_dat')) {                  $this->f->getParameter('erp_depot_dossier_dat')) {
734              $msgenque = new MessageEnqueuer();              $msgenque = new MessageEnqueuer();
735              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
736              $msgenque->enqueueMessage($msgenque->ERP_DEPOT_DOSSIER_DAT);              $msgenque->enqueueMessage($msgenque::$ERP_DEPOT_DOSSIER_DAT);
737          }          }
738                    
739          // 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 741  class dossier extends dossier_gen {
741                  $this->f->getParameter('erp_demande_ouverture_dat')) {                  $this->f->getParameter('erp_demande_ouverture_dat')) {
742              $msgenque = new MessageEnqueuer();              $msgenque = new MessageEnqueuer();
743              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);              $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
744              $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_OUVERTURE_DAT);              $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_DAT);
745          }          }
746                    
747          if ($this->valF['erp'] === true) {          if ($this->valF['erp'] === true) {
# Line 760  class dossier extends dossier_gen { Line 750  class dossier extends dossier_gen {
750                      $this->f->getParameter('erp_annulation_demande')) {                      $this->f->getParameter('erp_annulation_demande')) {
751                  $msgenque = new MessageEnqueuer();                  $msgenque = new MessageEnqueuer();
752                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
753                  $msgenque->enqueueMessage($msgenque->ERP_ANNULATION_DEMANDE);                  $msgenque->enqueueMessage($msgenque::$ERP_ANNULATION_DEMANDE);
754              }              }
755                            
756              // 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 759  class dossier extends dossier_gen {
759                      $this->f->getParameter('erp_demande_ouverture_pc_daact')) {                      $this->f->getParameter('erp_demande_ouverture_pc_daact')) {
760                  $msgenque = new MessageEnqueuer();                  $msgenque = new MessageEnqueuer();
761                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
762                  $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_OUVERTURE_PC);                  $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_OUVERTURE_PC);
763              }              }
764          }          }
765                    
# Line 838  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 getInstructeurDivision( $quartier, $arrondissement, $section, $nature) {       function getInstructeurDivision( $quartier, $arrondissement, $section, $dossier_autorisation) {
832                                    
833          $quartier = ( $quartier == NULL ) ? -1 : $quartier;          $quartier = ( $quartier == NULL ) ? -1 : $quartier;
834          $arrondissement = ( $arrondissement == NULL ) ? -1 : $arrondissement;          $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                 ".DB_PREFIXE."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  
         ";  
           
         $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);  
844                    
845          if ( $res->numRows() > 0 ){          $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              $row = $res->fetchRow(DB_FETCHMODE_ASSOC);              $this->addToLog("getInstructeurDivision : db->query(\"$sql\")", VERBOSE_MODE);
               
             $sql = "SELECT division FROM ".DB_PREFIXE."instructeur WHERE instructeur = ".$row['instructeur'];  
880              $res = $this->db->query($sql);              $res = $this->db->query($sql);
881              if (database :: isError($res))              if (database :: isError($res))
882                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
883                                
884              if ( $res->numRows() > 0 ){              if ( $res->numRows() > 0 ){
885                                    
886                  $rowT=& $res->fetchRow(DB_FETCHMODE_ASSOC);                  $row = $res->fetchRow(DB_FETCHMODE_ASSOC);
887                  $row['division'] = $rowT['division'];                  
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              }              }
               
             return $row;  
901          }          }
902            
903          return NULL;          return NULL;
904       }       }
905            
# Line 931  class dossier extends dossier_gen { Line 939  class dossier extends dossier_gen {
939              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
940          }          }
941                    
942          // 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
943          // 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
944          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ) {          if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['dossier_autorisation'] != '' ) {
945                            
946              //              //
947              $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['nature']);              $instructeurDivision = $this->getInstructeurDivision($quartier, $arrondissement, $section, $val['dossier_autorisation']);
948              if ( $instructeurDivision != NULL ){              if ( $instructeurDivision != NULL ){
949                                    
950                  $instructeur = $instructeurDivision['instructeur'];                  $instructeur = $instructeurDivision['instructeur'];
# Line 999  class dossier extends dossier_gen { Line 1007  class dossier extends dossier_gen {
1007                  $msgenque->setContraintePlu($this->valF['servitude']);                  $msgenque->setContraintePlu($this->valF['servitude']);
1008                  $msgenque->setReferenceCadastrale(                  $msgenque->setReferenceCadastrale(
1009                          $this->getReferenceCadastrale($this->valF['dossier']));                          $this->getReferenceCadastrale($this->valF['dossier']));
1010                  $msgenque->enqueueMessage($msgenque->ERP_QUALIFIE);                                              $msgenque->enqueueMessage($msgenque::$ERP_QUALIFIE);                            
1011              }              }
1012                            
1013              // 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 1015  class dossier extends dossier_gen {
1015              if ($this->valF['nature'] == 'PC' && $this->valF['erp'] == true) {              if ($this->valF['nature'] == 'PC' && $this->valF['erp'] == true) {
1016                  $msgenque = new MessageEnqueuer();                  $msgenque = new MessageEnqueuer();
1017                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);                  $msgenque->setDossierInstructionIdentifier($this->valF['dossier']);
1018                  $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_COMPLETUDE_PC);                  $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_COMPLETUDE_PC);
1019                  $msgenque->enqueueMessage($msgenque->ERP_DEMANDE_QUALIFICATION_PC);                  $msgenque->enqueueMessage($msgenque::$ERP_DEMANDE_QUALIFICATION_PC);
1020              }              }
1021                            
1022          }              }    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26