/[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 575 by vpihour, Wed Oct 31 17:04:12 2012 UTC revision 681 by fmichon, Wed Nov 14 07:09:49 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 290  class dossier extends dossier_gen { Line 290  class dossier extends dossier_gen {
290              $form->setType('geom1','hidden');              $form->setType('geom1','hidden');
291              $form->setType('geom','hidden');              $form->setType('geom','hidden');
292          }          }
293          if($this->f->getParameter('afficher_division')==='true') {          //if($this->f->getParameter('afficher_division')==='true') {
294              $form->setType('division','hiddenstatic');          //    $form->setType('division','hiddenstatic');
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 ( !$this->f->isAccredited("dossier_modifier_instructeur") )
301                $form->setType('instructeur', 'hidden');
302      }      }
303    
304      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 485  class dossier extends dossier_gen { Line 488  class dossier extends dossier_gen {
488          $form->setGroupe('delegataire_telephone','F');          $form->setGroupe('delegataire_telephone','F');
489                                
490          $form->setGroupe('architecte','D');          $form->setGroupe('architecte','D');
491          $form->setGroupe('architecte_nom','G');          $form->setGroupe('architecte_nom','F');
492          $form->setGroupe('saisie_architecte','F');          //$form->setGroupe('saisie_architecte','F');
493                    
494          $form->setGroupe('travaux','D');            $form->setGroupe('travaux','D');  
495          $form->setGroupe('travaux_complement','F');          $form->setGroupe('travaux_complement','F');
# Line 570  class dossier extends dossier_gen { Line 573  class dossier extends dossier_gen {
573          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
574      }      }
575    
576      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
577          // depot          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
578          If ($maj==0){          $form->setFieldset('division', 'F');
579              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );      }
580          }      
581          If ($maj==1){      function setRegroupe(&$form,$maj) {
582              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          //// depot
583              $form->setRegroupe('date_demande','G','');          //If ($maj==0){
584          }          //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
585          $form->setRegroupe('date_depot','G','');          //}
586          $form->setRegroupe('division','F','');          //If ($maj==1){
587                    //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
588            //    $form->setRegroupe('date_demande','G','');
589            //}
590            //$form->setRegroupe('date_depot','G','');
591            //$form->setRegroupe('division','F','');
592    
593          // travaux          // travaux
594          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
595          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
# Line 668  class dossier extends dossier_gen { Line 676  class dossier extends dossier_gen {
676          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
677      }      }
678    
679        
680    
681        /* =============================================================
682        * fonction trigger relative a la connexion SIG
683        * $sig = 1 dans dyn/var.inc
684        * ===============================================================
685        */
686    
687        function triggerajouterapres($id,&$db,$val,$DEBUG) {
688            $this->sig_parametre($db);
689            $id=$this->valF['dossier']; // id n est pas valorise en ajout
690            if($this->sig==1 and $val['sig']!='Oui'){
691                if($val['parcelle']!=''or $val['parcelle_lot']!=''){
692                        
693                    $this->sig_interne($id,$db,$val,$DEBUG);
694                }
695                else
696                    $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
697                
698            }
699        }
700        
701      /*      /*
702       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
703       * */       * */
704       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {
705                            
706           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
707             $quartier = '';
708                    
709           /*Code impots*/           /*Code impots*/
710           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
# Line 696  class dossier extends dossier_gen { Line 727  class dossier extends dossier_gen {
727              if (database :: isError($res))              if (database :: isError($res))
728                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
729                            
730              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              if ( $res->numRows() > 0 ){
731                                        
732                  $quartier = $row['quartier'];                  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
733                  $arrondissement = $row['arrondissement'];                  
734                        $quartier = $row['quartier'];
735                        $arrondissement = $row['arrondissement'];
736                    }
737              }              }
738          }          }
739       }       }
# Line 710  class dossier extends dossier_gen { Line 744  class dossier extends dossier_gen {
744       function getSection($parcelle){       function getSection($parcelle){
745                    
746           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
747           $section = '';           $section = NULL;
748                    
749           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
750              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 752  class dossier extends dossier_gen {
752                    
753           return $section;           return $section;
754       }       }
755        
756      /* =============================================================      /*
757      * fonction trigger relative a la connexion SIG       * Retourne l'intructeur correspondant le mieux à la parcelle
758      * $sig = 1 dans dyn/var.inc       * */
759      * ===============================================================       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {
760      */          
761            $sql = "
762      function triggerajouterapres($id,&$db,$val,$DEBUG) {             SELECT
763          $this->sig_parametre($db);                 instructeur, section, quartier, arrondissement, nature
764          $id=$this->valF['dossier']; // id n est pas valorise en ajout             FROM
765          if($this->sig==1 and $val['sig']!='Oui'){                 lien_localisation_nature l
766              if($val['parcelle']!=''or $val['parcelle_lot']!=''){             WHERE
767                                       ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
768                  $this->sig_interne($id,$db,$val,$DEBUG);                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
769              }                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
770              else                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
771                  $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
772                               ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
773                   ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
774                   ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
775                   ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
776                   ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
777                   ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
778                   ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
779                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
780                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
781                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
782                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
783               ORDER BY section, quartier, arrondissement, nature
784               LIMIT 1
785            ";
786            
787            $res = $db->query($sql);
788            if (database :: isError($res))
789                die($res->getMessage()."erreur ".$sql);
790            
791            if ( $res->numRows() > 0 ){
792                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
793                return $row['instructeur'];
794          }          }
795      }          
796            return NULL;
797         }
798            
799      /* =============================================================      /* =============================================================
800      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
# Line 746  class dossier extends dossier_gen { Line 803  class dossier extends dossier_gen {
803      */      */
804    
805      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
806            
807                    
808            /*Localisation*/
809            $quartier = 'NULL';
810            $arrondissement = 'NULL';
811            $section = 'NULL' ;
812            
813          if($val['parcelle']!=''){          if($val['parcelle']!=''){
814                                    
             /*Localisation*/  
             $quartier='';  
             $arrondissement = '';  
815              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);
816                
817                if ( strcmp($arrondissement,'NULL') == 0 )
818                    $quartier = 'NULL';
819                
820              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
821                                        
822              //$this->addToMessage("<br> $quartier , $arrondissement , $section , ".$val['nature']."<br>");              
823          }            }
824            
825            /*Instructeur*/
826            if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){
827                  
828                $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);
829                
830                if ( $instructeur != NULL )
831                    $this->valF['instructeur'] = $instructeur;
832                else {
833                    if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )
834                        $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
835                    else
836                        $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
837                }
838            }
839            
840            else
841                        $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
842      }      }
843    
844      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 866  class dossier extends dossier_gen { Line 949  class dossier extends dossier_gen {
949                  if (database :: isError($res))                  if (database :: isError($res))
950                      die($res->getMessage()."erreur ".$sql);                      die($res->getMessage()."erreur ".$sql);
951              }              }
952              $this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");              //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
953          }          }
954      }      }
955    

Legend:
Removed from v.575  
changed lines
  Added in v.681

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26