/[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 467 by nhaye, Wed Oct 3 09:42:47 2012 UTC revision 584 by vpihour, Fri Nov 2 17:15:30 2012 UTC
# Line 59  class dossier extends dossier_gen { Line 59  class dossier extends dossier_gen {
59              unset ($this->valF['accord_tacite']);              unset ($this->valF['accord_tacite']);
60              unset ($this->valF['types']);              unset ($this->valF['types']);
61          }          }
62          unset ($this->valF['avis']); // avis + libelle avis          unset ($this->valF['avis_decision']); // avis + libelle avis
63          unset ($this->valF['terrain_surface_calcul']);          unset ($this->valF['terrain_surface_calcul']);
64          unset ($this->valF['shon_calcul']);          unset ($this->valF['shon_calcul']);
65          unset ($this->valF['parcelle_archive']);          unset ($this->valF['parcelle_archive']);
# 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('/^[A-Z0-9]{1}[A-Z]{1}[0-9]{4}$/', $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 AANNNN");                  $this->addToMessage("<br>format parcelle incorrect");
82              }              }
83          }          }
84          // regles travaux verification          // regles travaux verification
# Line 230  class dossier extends dossier_gen { Line 230  class dossier extends dossier_gen {
230              // hiddenstatic              // hiddenstatic
231              if($maj==1) $form->setType('dossier', 'hiddenstatic');              if($maj==1) $form->setType('dossier', 'hiddenstatic');
232              $form->setType('etat','hiddenstatic');              $form->setType('etat','hiddenstatic');
233              $form->setType('avis','hiddenstatic');              $form->setType('avis_decision','hiddenstatic');
234              $form->setType('delai','hiddenstatic');              $form->setType('delai','hiddenstatic');
235              $form->setType('terrain_surface_calcul','hiddenstatic');              $form->setType('terrain_surface_calcul','hiddenstatic');
236              $form->setType('shon_calcul','hiddenstatic');              $form->setType('shon_calcul','hiddenstatic');
# 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') {
294                $form->setType('division','hiddenstatic');
295            } else {
296                $form->setType('division','hidden');
297            }
298            
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 392  class dossier extends dossier_gen { Line 401  class dossier extends dossier_gen {
401              $contenu=array();              $contenu=array();
402              $contenu[0]=array('Non','Oui');              $contenu[0]=array('Non','Oui');
403              $contenu[1]=array('Non','Oui');              $contenu[1]=array('Non','Oui');
             $form->setSelect("etat",$contenu);  
404              $form->setSelect("accord_tacite",$contenu);              $form->setSelect("accord_tacite",$contenu);
405              // terrain_numero_complement              // terrain_numero_complement
406              $contenu=array();              $contenu=array();
# Line 406  class dossier extends dossier_gen { Line 414  class dossier extends dossier_gen {
414                  $form->setSelect('geom',$contenu);                  $form->setSelect('geom',$contenu);
415              }              }
416                            
417                /*
418                 * Affichage de données dans le select de la parcelle
419                 * */
420                $contenu=array();
421                $sql="select parcelle from ".DB_PREFIXE."parcelle ";
422                $res = $db->query($sql);
423                if (database::isError($res))
424                    die($res->getMessage());
425                $contenu[0][0]="";
426                $contenu[1][0]=_("choisir parcelle");
427                $k=1;
428                while ($row=& $res->fetchRow()){
429                    $contenu[0][$k]=$row[0];
430                    $contenu[1][$k]=$row[0];
431                    $k++;
432                }
433                $form->setSelect("parcelle",$contenu);
434                
435            }
436            if($this->f->getParameter('afficher_division')==='true') {
437                // instructeur
438                $this->init_select($form, $db, $maj, $debug, "instructeur",
439                $sql_instructeur_div, $sql_instructeur_div_by_id, false);
440          }          }
441      }      }
442    
# Line 418  class dossier extends dossier_gen { Line 449  class dossier extends dossier_gen {
449          If ($maj==0){          If ($maj==0){
450              $form->setGroupe('date_demande','D');              $form->setGroupe('date_demande','D');
451              $form->setGroupe('date_depot','G');              $form->setGroupe('date_depot','G');
452              $form->setGroupe('instructeur','F');              $form->setGroupe('division','F');
453          }else{          }else{
454              $form->setGroupe('dossier','D');              $form->setGroupe('dossier','D');
455              $form->setGroupe('nature','G');              $form->setGroupe('nature','G');
456              $form->setGroupe('annee','G');              $form->setGroupe('annee','G');
457              $form->setGroupe('date_demande','G');              $form->setGroupe('date_demande','G');
458              $form->setGroupe('date_depot','G');              $form->setGroupe('date_depot','G');
459              $form->setGroupe('instructeur','F');              $form->setGroupe('division','F');
460          }          }
461          $form->setGroupe('demandeur_categorie','D');          $form->setGroupe('demandeur_categorie','D');
462          $form->setGroupe('demandeur_civilite','G');          $form->setGroupe('demandeur_civilite','G');
# Line 489  class dossier extends dossier_gen { Line 520  class dossier extends dossier_gen {
520          $form->setGroupe('etat','F');          $form->setGroupe('etat','F');
521                    
522          $form->setGroupe('date_decision','D');          $form->setGroupe('date_decision','D');
523          $form->setGroupe('avis','G');          $form->setGroupe('avis_decision','G');
524          $form->setGroupe('date_validite','G');          $form->setGroupe('date_validite','G');
525          $form->setGroupe('types','F');          $form->setGroupe('types','F');
526                    
# Line 552  class dossier extends dossier_gen { Line 583  class dossier extends dossier_gen {
583              $form->setRegroupe('date_demande','G','');              $form->setRegroupe('date_demande','G','');
584          }          }
585          $form->setRegroupe('date_depot','G','');          $form->setRegroupe('date_depot','G','');
586          $form->setRegroupe('instructeur','F','');          $form->setRegroupe('division','F','');
587                    
588          // travaux          // travaux
589          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);          $form->setRegroupe('architecte','D',_('Architecte')." / "._("Travaux"), $this->aff_travaux);
# Line 569  class dossier extends dossier_gen { Line 600  class dossier extends dossier_gen {
600          $form->setRegroupe('accord_tacite','G','');          $form->setRegroupe('accord_tacite','G','');
601          $form->setRegroupe('etat','G','');          $form->setRegroupe('etat','G','');
602          $form->setRegroupe('date_decision','G','');          $form->setRegroupe('date_decision','G','');
603          $form->setRegroupe('avis','G','');          $form->setRegroupe('avis_decision','G','');
604          $form->setRegroupe('date_validite','G','');          $form->setRegroupe('date_validite','G','');
605          $form->setRegroupe('types','G','');          $form->setRegroupe('types','G','');
606          $form->setRegroupe('date_chantier','G','');          $form->setRegroupe('date_chantier','G','');
# Line 640  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      * fonction trigger relative a la connexion SIG
678      * $sig = 1 dans dyn/var.inc      * $sig = 1 dans dyn/var.inc
# Line 650  class dossier extends dossier_gen { Line 683  class dossier extends dossier_gen {
683          $this->sig_parametre($db);          $this->sig_parametre($db);
684          $id=$this->valF['dossier']; // id n est pas valorise en ajout          $id=$this->valF['dossier']; // id n est pas valorise en ajout
685          if($this->sig==1 and $val['sig']!='Oui'){          if($this->sig==1 and $val['sig']!='Oui'){
686              if($val['parcelle']!=''or $val['parcelle_lot']!='')              if($val['parcelle']!=''or $val['parcelle_lot']!=''){
687                        
688                  $this->sig_interne($id,$db,$val,$DEBUG);                  $this->sig_interne($id,$db,$val,$DEBUG);
689                }
690              else              else
691                  $this->addToMessage("<br>"._("Parcelle non renseignee dans dossier")." ".$id." <br>");                      $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
698         * */
699         function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) {
700                
701             $parcelle = trim($parcelle);
702            
703             /*Code impots*/
704             for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
705                if (is_numeric($parcelle[$i]) )
706                    $quartier .= $parcelle[$i];
707                else
708                    break;
709            
710            if ( $quartier !== '' ){
711                
712                /*identifiant*/
713                $sql = "SELECT
714                            quartier, arrondissement
715                        FROM
716                            quartier
717                        WHERE
718                            code_impots='$quartier'";
719                
720                $res = $db->query($sql);
721                if (database :: isError($res))
722                    die($res->getMessage()."erreur ".$sql);
723                
724                while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
725                    
726                    $quartier = $row['quartier'];
727                    $arrondissement = $row['arrondissement'];
728                }
729            }
730         }
731        
732         /*
733         * Retourne la section d'une parcelle
734         * */
735         function getSection($parcelle){
736            
737             $parcelle = trim($parcelle);
738             $section = NULL;
739            
740             for ( $i = 0 ; $i < strlen($parcelle) ; $i++ )
741                if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' )
742                    $section .= $parcelle[$i];
743            
744             return $section;
745         }
746        
747        /*
748         * Retourne l'intructeur correspondant le mieux à la parcelle
749         * */
750         function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) {
751            
752            $sql = "
753               SELECT
754                   instructeur, section, quartier, arrondissement, nature
755               FROM
756                   lien_localisation_nature l
757               WHERE
758                   ( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR
759                   ( 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                   ( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR
762                   ( 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
792        * $sig = 1 dans dyn/var.inc
793        * ===============================================================
794        */
795    
796        function triggerajouter($id,&$db,$val,$DEBUG) {
797            if($val['parcelle']!=''){
798                        
799                /*Localisation*/
800                $quartier = NULL;
801                $arrondissement = NULL;
802                
803                $this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db);
804                $section = $this->getSection($val['parcelle']);
805                /*Instructeur*/
806                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    
# Line 821  class dossier extends dossier_gen { Line 990  class dossier extends dossier_gen {
990              $this->servitude.="  [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";              $this->servitude.="  [".$row['libelle']."] ".$row['observation']." a ".round($row['distance'],2)." m - ";
991         }         }
992      }      }
   
   
993  }// fin classe  }// fin classe
994  ?>  ?>

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26