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 |
} |
} |
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){ |
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 |
* */ |
* */ |
699 |
function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) { |
function getQuartierArrondissement($parcelle, &$quartier, &$arrondissement, &$db) { |
700 |
|
|
701 |
$parcelle = trim($parcelle); |
$parcelle = trim($parcelle); |
702 |
|
$quartier = ''; |
703 |
|
|
704 |
/*Code impots*/ |
/*Code impots*/ |
705 |
for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ) |
for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ) |
722 |
if (database :: isError($res)) |
if (database :: isError($res)) |
723 |
die($res->getMessage()."erreur ".$sql); |
die($res->getMessage()."erreur ".$sql); |
724 |
|
|
725 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
if ( $res->numRows() > 0 ){ |
726 |
|
|
727 |
$quartier = $row['quartier']; |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
728 |
$arrondissement = $row['arrondissement']; |
|
729 |
|
$quartier = $row['quartier']; |
730 |
|
$arrondissement = $row['arrondissement']; |
731 |
|
} |
732 |
} |
} |
733 |
} |
} |
734 |
} |
} |
739 |
function getSection($parcelle){ |
function getSection($parcelle){ |
740 |
|
|
741 |
$parcelle = trim($parcelle); |
$parcelle = trim($parcelle); |
742 |
$section = ''; |
$section = NULL; |
743 |
|
|
744 |
for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ) |
for ( $i = 0 ; $i < strlen($parcelle) ; $i++ ) |
745 |
if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' ) |
if ( !is_numeric($parcelle[$i]) && is_string($parcelle[$i]) && $parcelle[$i] !== ' ' ) |
747 |
|
|
748 |
return $section; |
return $section; |
749 |
} |
} |
750 |
|
|
751 |
/* ============================================================= |
/* |
752 |
* fonction trigger relative a la connexion SIG |
* Retourne l'intructeur correspondant le mieux à la parcelle |
753 |
* $sig = 1 dans dyn/var.inc |
* */ |
754 |
* =============================================================== |
function getInstructeur( $quartier, $arrondissement, $section, $nature, &$db) { |
755 |
*/ |
|
756 |
|
$sql = " |
757 |
function triggerajouterapres($id,&$db,$val,$DEBUG) { |
SELECT |
758 |
$this->sig_parametre($db); |
instructeur, section, quartier, arrondissement, nature |
759 |
$id=$this->valF['dossier']; // id n est pas valorise en ajout |
FROM |
760 |
if($this->sig==1 and $val['sig']!='Oui'){ |
lien_localisation_nature l |
761 |
if($val['parcelle']!=''or $val['parcelle_lot']!=''){ |
WHERE |
762 |
|
( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR |
763 |
$this->sig_interne($id,$db,$val,$DEBUG); |
( nature IS NULL AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR |
764 |
} |
( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR |
765 |
else |
( nature IS NULL AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR |
766 |
$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 |
767 |
|
( nature IS NULL AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR |
768 |
|
( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR |
769 |
|
( nature IS NULL AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) OR |
770 |
|
( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section IS NULL ) OR |
771 |
|
( nature = '$nature' AND arrondissement IS NULL AND quartier IS NULL AND section = '$section' ) OR |
772 |
|
( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section IS NULL ) OR |
773 |
|
( nature = '$nature' AND arrondissement IS NULL AND quartier = $quartier AND section = '$section' ) OR |
774 |
|
( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section IS NULL ) OR |
775 |
|
( nature = '$nature' AND arrondissement = $arrondissement AND quartier IS NULL AND section = '$section' ) OR |
776 |
|
( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section IS NULL ) OR |
777 |
|
( nature = '$nature' AND arrondissement = $arrondissement AND quartier = $quartier AND section = '$section' ) |
778 |
|
ORDER BY section, quartier, arrondissement, nature |
779 |
|
LIMIT 1 |
780 |
|
"; |
781 |
|
|
782 |
|
$res = $db->query($sql); |
783 |
|
if (database :: isError($res)) |
784 |
|
die($res->getMessage()."erreur ".$sql); |
785 |
|
|
786 |
|
if ( $res->numRows() > 0 ){ |
787 |
|
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
788 |
|
return $row['instructeur']; |
789 |
} |
} |
790 |
} |
|
791 |
|
return NULL; |
792 |
|
} |
793 |
|
|
794 |
/* ============================================================= |
/* ============================================================= |
795 |
* fonction trigger relative a la connexion SIG |
* fonction trigger relative a la connexion SIG |
798 |
*/ |
*/ |
799 |
|
|
800 |
function triggerajouter($id,&$db,$val,$DEBUG) { |
function triggerajouter($id,&$db,$val,$DEBUG) { |
801 |
|
|
802 |
|
|
803 |
|
/*Localisation*/ |
804 |
|
$quartier = 'NULL'; |
805 |
|
$arrondissement = 'NULL'; |
806 |
|
$section = 'NULL' ; |
807 |
|
|
808 |
if($val['parcelle']!=''){ |
if($val['parcelle']!=''){ |
809 |
|
|
|
/*Localisation*/ |
|
|
$quartier=''; |
|
|
$arrondissement = ''; |
|
810 |
$this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db); |
$this->getQuartierArrondissement($val['parcelle'], $quartier, $arrondissement, $db); |
811 |
|
|
812 |
|
if ( strcmp($arrondissement,'NULL') == 0 ) |
813 |
|
$quartier = 'NULL'; |
814 |
|
|
815 |
$section = $this->getSection($val['parcelle']); |
$section = $this->getSection($val['parcelle']); |
816 |
|
|
817 |
//$this->addToMessage("<br> $quartier , $arrondissement , $section , ".$val['nature']."<br>"); |
|
818 |
} |
} |
819 |
|
|
820 |
|
/*Instructeur*/ |
821 |
|
if ( ( empty($this->valF['instructeur']) || $this->valF['instructeur'] == '' ) && $val['nature'] != '' ){ |
822 |
|
|
823 |
|
$instructeur = $this->getInstructeur($quartier, $arrondissement, $section, $val['nature'], $db); |
824 |
|
|
825 |
|
if ( $instructeur != NULL ) |
826 |
|
$this->valF['instructeur'] = $instructeur; |
827 |
|
else { |
828 |
|
if ( is_numeric($_SESSION['profil']) && $_SESSION['profil'] == 5 ) |
829 |
|
$this->addToMessage("<br/> "._("Pensez a assigner un instructeur a ce dossier.")." <br/>"); |
830 |
|
else |
831 |
|
$this->addToMessage("<br/> "._("Aucun instructeur compatible avec ce dossier trouve, contactez votre administrateur afin d'en assigner un a ce dossier.")." <br/>"); |
832 |
|
} |
833 |
|
} |
834 |
|
|
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 |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
function triggermodifierapres($id,&$db,$val,$DEBUG) { |
944 |
if (database :: isError($res)) |
if (database :: isError($res)) |
945 |
die($res->getMessage()."erreur ".$sql); |
die($res->getMessage()."erreur ".$sql); |
946 |
} |
} |
947 |
$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id.""); |
//$this->addToMessage("<br> parcelle ".$parcelle." "._("inexistante")." ".$id.""); |
948 |
} |
} |
949 |
} |
} |
950 |
|
|