/[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 583 by vpihour, Wed Oct 31 17:04:12 2012 UTC revision 584 by vpihour, Fri Nov 2 17:15:30 2012 UTC
# Line 76  class dossier extends dossier_gen { Line 76  class dossier extends dossier_gen {
76      function verifier($val,&$db,$DEBUG){      function verifier($val,&$db,$DEBUG){
77          parent::verifier($val,$db,$DEBUG);          parent::verifier($val,$db,$DEBUG);
78          if($val['parcelle']!="" and $val['sig']!='Oui'){          if($val['parcelle']!="" and $val['sig']!='Oui'){
79              if  (!preg_match('/^[0-9]{3} [A-Z]{1,3} [0-9]{1,5}$/', $val['parcelle'])){                if  (!preg_match('/^[0-9]{3} [A-Z]{1,3} [0-9]{1,5}$/', $val['parcelle']) && !preg_match('/^[0-9]{3}[A-Z]{1,3}[0-9]{1,5}$/', $val['parcelle'])){    
80                  $this->correct=false;                  $this->correct=false;
81                  $this->addToMessage("<br>format parcelle incorrect");                  $this->addToMessage("<br>format parcelle incorrect");
82              }              }
# Line 295  class dossier extends dossier_gen { Line 295  class dossier extends dossier_gen {
295          } else {          } else {
296              $form->setType('division','hidden');              $form->setType('division','hidden');
297          }          }
298          $form->setType('instructeur', 'hidden');          
299            /* Gestion des droits pour l'ajout forcé d'un instructeur, si le profil est 5, c'est un administrateur */
300            if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] != 5 )
301                $form->setType('instructeur', 'hidden');
302      }      }
303    
304      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 668  class dossier extends dossier_gen { Line 671  class dossier extends dossier_gen {
671          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
672      }      }
673    
674        
675    
676        /* =============================================================
677        * fonction trigger relative a la connexion SIG
678        * $sig = 1 dans dyn/var.inc
679        * ===============================================================
680        */
681    
682        function triggerajouterapres($id,&$db,$val,$DEBUG) {
683            $this->sig_parametre($db);
684            $id=$this->valF['dossier']; // id n est pas valorise en ajout
685            if($this->sig==1 and $val['sig']!='Oui'){
686                if($val['parcelle']!=''or $val['parcelle_lot']!=''){
687                        
688                    $this->sig_interne($id,$db,$val,$DEBUG);
689                }
690                else
691                    $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
692                
693            }
694        }
695        
696      /*      /*
697       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
698       * */       * */
# Line 710  class dossier extends dossier_gen { Line 735  class dossier extends dossier_gen {
735       function getSection($parcelle){       function getSection($parcelle){
736                    
737           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
738           $section = '';           $section = NULL;
739                    
740           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
741              if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )              if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
# Line 718  class dossier extends dossier_gen { Line 743  class dossier extends dossier_gen {
743                    
744           return $section;           return $section;
745       }       }
746        
747      /* =============================================================      /*
748      * fonction trigger relative a la connexion SIG       * Retourne l'intructeur correspondant le mieux à la parcelle
749      * $sig = 1 dans dyn/var.inc       * */
750      * ===============================================================       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {
751      */          
752            $sql = "
753      function triggerajouterapres($id,&$db,$val,$DEBUG) {             SELECT
754          $this->sig_parametre($db);                 instructeur, section, quartier, arrondissement, nature
755          $id=$this->valF['dossier']; // id n est pas valorise en ajout             FROM
756          if($this->sig==1 and $val['sig']!='Oui'){                 lien_localisation_nature l
757              if($val['parcelle']!=''or $val['parcelle_lot']!=''){             WHERE
758                                       ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
759                  $this->sig_interne($id,$db,$val,$DEBUG);                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
760              }                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
761              else                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
762                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                 ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
763                               ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
764                   ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
765                   ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
766                   ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
767                   ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
768                   ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
769                   ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
770                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
771                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
772                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
773                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
774               ORDER BY section, quartier, arrondissement, nature
775               LIMIT 1
776            ";
777            
778            $res = $db->query($sql);
779            if (database :: isError($res))
780                die($res->getMessage()."erreur ".$sql);
781            
782            if ( $res->numRows() > 0 ){
783                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
784                return $row['instructeur'];
785          }          }
786      }          
787            return NULL;
788         }
789            
790      /* =============================================================      /* =============================================================
791      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
# Line 749  class dossier extends dossier_gen { Line 797  class dossier extends dossier_gen {
797          if($val['parcelle']!=''){          if($val['parcelle']!=''){
798                                            
799              /*Localisation*/              /*Localisation*/
800              $quartier='';              $quartier = NULL;
801              $arrondissement = '';              $arrondissement = NULL;
802                
803              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);
804              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
805                                        /*Instructeur*/
806              //$this->addToMessage("<br> $quartier , $arrondissement , $section , ".$val['nature']."<br>");              if ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' && $val['nature'] != '' ){
807          }                        
808                    $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);
809                    
810                    if ( $instructeur != NULL )
811                        $this->valF['instructeur'] = $instructeur;
812                    else {
813                        if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )
814                            $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
815                        else
816                            $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
817                    }
818                }
819            }
820            
821            else {
822                if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )
823                    $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
824                else
825                    $this->addToMessage("<br/> "._("Parcelle non saisie, contactez votre administrateur afin d'assigner un instructeur a ce dossier.")." <br/>");
826            }
827      }      }
828    
829      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26