/[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 686 by fmichon, Wed Nov 14 12:50:34 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 277  class dossier extends dossier_gen { Line 277  class dossier extends dossier_gen {
277              $form->setType('temp4',$temp4_type);              $form->setType('temp4',$temp4_type);
278              $form->setType('temp5',$temp5_type);              $form->setType('temp5',$temp5_type);
279          }          }
280            if ($maj == 1) {
281                //
282                if ($this->f->isAccredited("dossier_modifier_instructeur")) {
283                    $form->setType('instructeur', 'select');
284                } else {
285                    $form->setType('instructeur', 'selecthiddenstatic');
286                }
287                //
288                if($this->f->getParameter('afficher_division') === 'true') {
289                    //
290                    if ($this->f->isAccredited("dossier_modifier_division")) {
291                        $form->setType('division', 'select');
292                    } else {
293                        $form->setType('division', 'selecthiddenstatic');
294                    }
295                } else {
296                    $form->setType('division', 'hidden');
297                }
298            }
299          if($maj == 3) {          if($maj == 3) {
300              $form->setType('annee', 'hidden');              $form->setType('annee', 'hidden');
301              $form->setType('nature', 'selectstatic');              $form->setType('nature', 'selectstatic');
# Line 290  class dossier extends dossier_gen { Line 309  class dossier extends dossier_gen {
309              $form->setType('geom1','hidden');              $form->setType('geom1','hidden');
310              $form->setType('geom','hidden');              $form->setType('geom','hidden');
311          }          }
312          if($this->f->getParameter('afficher_division')==='true') {          //
313              $form->setType('division','hiddenstatic');          if(!$this->f->getParameter('afficher_division') === 'true') {
314          } else {              $form->setType('division', 'hidden');
             $form->setType('division','hidden');  
315          }          }
         $form->setType('instructeur', 'hidden');  
316      }      }
317    
318      function setVal(&$form,$maj,$validation){      function setVal(&$form,$maj,$validation){
# Line 443  class dossier extends dossier_gen { Line 460  class dossier extends dossier_gen {
460      }          }    
461    
462      function setGroupe(&$form,$maj){      function setGroupe(&$form,$maj){
463          If ($maj==0){          //If ($maj==0){
464              $form->setGroupe('date_demande','D');          //    $form->setGroupe('date_demande','D');
465              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
466              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
467          }else{          //}else{
468              $form->setGroupe('dossier','D');          //    $form->setGroupe('dossier','D');
469              $form->setGroupe('nature','G');          //    $form->setGroupe('nature','G');
470              $form->setGroupe('annee','G');          //    $form->setGroupe('annee','G');
471              $form->setGroupe('date_demande','G');          //    $form->setGroupe('date_demande','G');
472              $form->setGroupe('date_depot','G');          //    $form->setGroupe('date_depot','G');
473              $form->setGroupe('division','F');          //    $form->setGroupe('division','F');
474          }          //}
475          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
476          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
477          $form->setGroupe('demandeur_nom','F');          $form->setGroupe('demandeur_nom','F');
# Line 485  class dossier extends dossier_gen { Line 502  class dossier extends dossier_gen {
502          $form->setGroupe('delegataire_telephone','F');          $form->setGroupe('delegataire_telephone','F');
503                                
504          $form->setGroupe('architecte','D');          $form->setGroupe('architecte','D');
505          $form->setGroupe('architecte_nom','G');          $form->setGroupe('architecte_nom','F');
506          $form->setGroupe('saisie_architecte','F');          //$form->setGroupe('saisie_architecte','F');
507                    
508          $form->setGroupe('travaux','D');            $form->setGroupe('travaux','D');  
509          $form->setGroupe('travaux_complement','F');          $form->setGroupe('travaux_complement','F');
# Line 570  class dossier extends dossier_gen { Line 587  class dossier extends dossier_gen {
587          $form->setOnchange('terrain_surface','VerifNumdec(this)');          $form->setOnchange('terrain_surface','VerifNumdec(this)');
588      }      }
589    
590      function setRegroupe(&$form,$maj){      function setLayout(&$form, $maj) {
591          // depot          //
592          If ($maj==0){          $form->setBloc('dossier', 'D', '', ($maj == 3 ? 'col_9':'col_12'));
593              $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );          $form->setBloc('dossier', 'D', '', 'col_9');
594          }          $form->setFieldset('dossier', 'D', _("Dossier d'instruction"));
595          If ($maj==1){          $form->setFieldset('autorite_competente', 'F');
596              $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);          $form->setBloc('autorite_competente', 'F');
597              $form->setRegroupe('date_demande','G','');          $form->setBloc('date_demande', 'D', '', 'col_3');
598          }          $form->setFieldset('date_demande', 'D', _("Depot"));
599          $form->setRegroupe('date_depot','G','');          $form->setFieldset('date_depot', 'F');
600          $form->setRegroupe('division','F','');          $form->setFieldset('enjeu_urba', 'D', _("Enjeu"));
601            $form->setFieldset('enjeu_erp', 'F');
602            $form->setBloc('enjeu_erp', 'F');
603            $form->setBloc('enjeu_erp', 'F');
604            //
605            $form->setBloc('objet_dossier', 'D', '', 'col_12');
606            //
607            $form->setFieldset('date_complet', 'D', _('Instruction'), 'col_12');
608            $form->setRegroupe('date_conformite','F','');
609            //
610            $form->setBloc('geom1', 'F');
611                    
612        }
613        
614        function setRegroupe(&$form,$maj) {
615            //// depot
616            //If ($maj==0){
617            //    $form->setRegroupe('date_demande','D',_("Depot"),$this->aff_depot );
618            //}
619            //If ($maj==1){
620            //    $form->setRegroupe('dossier','D',_("Depot"), $this->aff_depot);
621            //    $form->setRegroupe('date_demande','G','');
622            //}
623            //$form->setRegroupe('date_depot','G','');
624            //$form->setRegroupe('division','F','');
625    
626          // travaux          // travaux
627          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
628          $form->setRegroupe('architecte_nom','G','');          $form->setRegroupe('architecte_nom','G','');
629          $form->setRegroupe('travaux','G','');          $form->setRegroupe('travaux','G','');
630          $form->setRegroupe('travaux_complement','F','');          $form->setRegroupe('travaux_complement','F','');
631                    
632          // instruction          //// instruction
633          $form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);          //$form->setRegroupe('date_complet','D',_('Instruction'), $this->aff_instruction);
634          $form->setRegroupe('date_rejet','G','');          //$form->setRegroupe('date_rejet','G','');
635          $form->setRegroupe('date_notification_delai','G','');          //$form->setRegroupe('date_notification_delai','G','');
636          $form->setRegroupe('delai','G','');          //$form->setRegroupe('delai','G','');
637          $form->setRegroupe('date_limite','G','Decision ');          //$form->setRegroupe('date_limite','G','Decision ');
638          $form->setRegroupe('accord_tacite','G','');          //$form->setRegroupe('accord_tacite','G','');
639          $form->setRegroupe('etat','G','');          //$form->setRegroupe('etat','G','');
640          $form->setRegroupe('date_decision','G','');          //$form->setRegroupe('date_decision','G','');
641          $form->setRegroupe('avis_decision','G','');          //$form->setRegroupe('avis_decision','G','');
642          $form->setRegroupe('date_validite','G','');          //$form->setRegroupe('date_validite','G','');
643          $form->setRegroupe('types','G','');          //$form->setRegroupe('types','G','');
644          $form->setRegroupe('date_chantier','G','');          //$form->setRegroupe('date_chantier','G','');
645          $form->setRegroupe('date_achevement','G','');          //$form->setRegroupe('date_achevement','G','');
646          $form->setRegroupe('date_conformite','F','');          //$form->setRegroupe('date_conformite','F','');
647                    
648          // demandeur          // demandeur
649          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);          $form->setRegroupe('demandeur_categorie','D',_('Demandeur'), $this->aff_demandeur);
# Line 668  class dossier extends dossier_gen { Line 709  class dossier extends dossier_gen {
709          $form->setRegroupe('parcelle_lot_lotissement','F','');          $form->setRegroupe('parcelle_lot_lotissement','F','');
710      }      }
711    
712        
713    
714        /* =============================================================
715        * fonction trigger relative a la connexion SIG
716        * $sig = 1 dans dyn/var.inc
717        * ===============================================================
718        */
719    
720        function triggerajouterapres($id,&$db,$val,$DEBUG) {
721            $this->sig_parametre($db);
722            $id=$this->valF['dossier']; // id n est pas valorise en ajout
723            if($this->sig==1 and $val['sig']!='Oui'){
724                if($val['parcelle']!=''or $val['parcelle_lot']!=''){
725                        
726                    $this->sig_interne($id,$db,$val,$DEBUG);
727                }
728                else
729                    $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");
730                
731            }
732        }
733        
734      /*      /*
735       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle       * Calcul l'identifiant du quartier et d'un arrondissement d'une parcelle
736       * */       * */
737       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {       function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {
738                            
739           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
740             $quartier = '';
741                    
742           /*Code impots*/           /*Code impots*/
743           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
# Line 696  class dossier extends dossier_gen { Line 760  class dossier extends dossier_gen {
760              if (database :: isError($res))              if (database :: isError($res))
761                  die($res->getMessage()."erreur ".$sql);                  die($res->getMessage()."erreur ".$sql);
762                            
763              while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){              if ( $res->numRows() > 0 ){
764                                        
765                  $quartier = $row['quartier'];                  while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
766                  $arrondissement = $row['arrondissement'];                  
767                        $quartier = $row['quartier'];
768                        $arrondissement = $row['arrondissement'];
769                    }
770              }              }
771          }          }
772       }       }
# Line 710  class dossier extends dossier_gen { Line 777  class dossier extends dossier_gen {
777       function getSection($parcelle){       function getSection($parcelle){
778                    
779           $parcelle = trim($parcelle);           $parcelle = trim($parcelle);
780           $section = '';           $section = NULL;
781                    
782           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )           for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
783              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 785  class dossier extends dossier_gen {
785                    
786           return $section;           return $section;
787       }       }
788        
789      /* =============================================================      /*
790      * fonction trigger relative a la connexion SIG       * Retourne l'intructeur correspondant le mieux à la parcelle
791      * $sig = 1 dans dyn/var.inc       * */
792      * ===============================================================       function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {
793      */          
794            $sql = "
795      function triggerajouterapres($id,&$db,$val,$DEBUG) {             SELECT
796          $this->sig_parametre($db);                 instructeur, section, quartier, arrondissement, nature
797          $id=$this->valF['dossier']; // id n est pas valorise en ajout             FROM
798          if($this->sig==1 and $val['sig']!='Oui'){                 lien_localisation_nature l
799              if($val['parcelle']!=''or $val['parcelle_lot']!=''){             WHERE
800                                       ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
801                  $this->sig_interne($id,$db,$val,$DEBUG);                 ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
802              }                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
803              else                 ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
804                  $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
805                               ( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
806                   ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
807                   ( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR
808                   ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
809                   ( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR
810                   ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR
811                   ( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
812                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR
813                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR
814                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR
815                   ( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' )
816               ORDER BY section, quartier, arrondissement, nature
817               LIMIT 1
818            ";
819            
820            $res = $db->query($sql);
821            if (database :: isError($res))
822                die($res->getMessage()."erreur ".$sql);
823            
824            if ( $res->numRows() > 0 ){
825                $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
826                return $row['instructeur'];
827          }          }
828      }          
829            return NULL;
830         }
831            
832      /* =============================================================      /* =============================================================
833      * fonction trigger relative a la connexion SIG      * fonction trigger relative a la connexion SIG
# Line 746  class dossier extends dossier_gen { Line 836  class dossier extends dossier_gen {
836      */      */
837    
838      function triggerajouter($id,&$db,$val,$DEBUG) {      function triggerajouter($id,&$db,$val,$DEBUG) {
839            
840                    
841            /*Localisation*/
842            $quartier = 'NULL';
843            $arrondissement = 'NULL';
844            $section = 'NULL' ;
845            
846          if($val['parcelle']!=''){          if($val['parcelle']!=''){
847                                    
             /*Localisation*/  
             $quartier='';  
             $arrondissement = '';  
848              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);              $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);
849                
850                if ( strcmp($arrondissement,'NULL') == 0 )
851                    $quartier = 'NULL';
852                
853              $section = $this->getSection($val['parcelle']);              $section = $this->getSection($val['parcelle']);
854                                        
855              //$this->addToMessage("<br> $quartier , $arrondissement , $section , ".$val['nature']."<br>");              
856          }            }
857            
858            /*Instructeur*/
859            if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){
860                  
861                $instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db);
862                
863                if ( $instructeur != NULL )
864                    $this->valF['instructeur'] = $instructeur;
865                else {
866                    if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 )
867                        $this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>");
868                    else
869                        $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
870                }
871            }
872            
873            else
874                        $this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>");
875      }      }
876    
877      function triggermodifierapres($id,&$db,$val,$DEBUG) {      function triggermodifierapres($id,&$db,$val,$DEBUG) {
# Line 866  class dossier extends dossier_gen { Line 982  class dossier extends dossier_gen {
982                  if (database :: isError($res))                  if (database :: isError($res))
983                      die($res->getMessage()."erreur ".$sql);                      die($res->getMessage()."erreur ".$sql);
984              }              }
985              $this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");              //$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id."");
986          }          }
987      }      }
988    

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26