1 |
fraynaud |
3 |
<?php |
2 |
|
|
//$Id$ |
3 |
|
|
//gen openMairie le 10/02/2011 20:36 |
4 |
|
|
require_once ("../gen/obj/terrain.class.php"); |
5 |
|
|
|
6 |
|
|
class terrain extends terrain_gen { |
7 |
|
|
|
8 |
fraynaud |
10 |
function terrain($id,&$db,$debug) { |
9 |
|
|
$this->constructeur($id,$db,$debug); |
10 |
|
|
}// fin constructeur |
11 |
fraynaud |
3 |
|
12 |
fraynaud |
10 |
function setType(&$form,$maj) { |
13 |
|
|
parent::setType($form,$maj); |
14 |
|
|
if ($maj < 2) { //ajouter et modifier |
15 |
|
|
$form->setType('parcelle','comboD2'); |
16 |
|
|
$form->setType('nom','comboG2'); |
17 |
fraynaud |
20 |
$form->setType('dossier','hiddenstatic'); |
18 |
fraynaud |
10 |
} |
19 |
|
|
} |
20 |
|
|
|
21 |
|
|
function setSelect(&$form, $maj,$db,$debug) { |
22 |
fraynaud |
44 |
// parent:: setSelect($form, $maj,$db,$debug); |
23 |
|
|
// pb d optimisation et de chargement de 41.000 parcelles -> eliminer les select |
24 |
fraynaud |
10 |
// parcelle |
25 |
|
|
$contenu=""; |
26 |
|
|
$contenu[0][0]="parcelle";// table |
27 |
|
|
$contenu[0][1]="parcelle"; // zone origine |
28 |
|
|
$contenu[1][0]="proprietaire"; |
29 |
|
|
$contenu[1][1]="nom"; |
30 |
|
|
$form->setSelect("parcelle",$contenu); |
31 |
|
|
$contenu=""; |
32 |
|
|
$contenu[0][0]="parcelle";// table |
33 |
|
|
$contenu[0][1]="proprietaire"; // zone origine |
34 |
|
|
$contenu[1][0]="parcelle"; |
35 |
|
|
$contenu[1][1]="parcelle"; |
36 |
|
|
$form->setSelect("nom",$contenu); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
function setGroupe(&$form,$maj){ |
40 |
|
|
$form->setGroupe('parcelle','D'); |
41 |
|
|
$form->setGroupe('nom','F'); |
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
function setTaille(&$form,$maj){ |
45 |
|
|
$form->setTaille('terrain', 8); |
46 |
|
|
$form->setTaille('dossier', 12); |
47 |
|
|
$form->setTaille('parcelle', 6); |
48 |
|
|
$form->setTaille('nom', 60); |
49 |
|
|
} |
50 |
|
|
|
51 |
|
|
function setMax(&$form,$maj){ |
52 |
|
|
$form->setMax('terrain', 8); |
53 |
|
|
$form->setMax('dossier', 12); |
54 |
|
|
$form->setMax('parcelle', 6); |
55 |
|
|
$form->setMax('nom', 60); |
56 |
|
|
} |
57 |
fraynaud |
20 |
|
58 |
|
|
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire){ |
59 |
|
|
if ($validation==0) { |
60 |
|
|
if ($maj == 0){ |
61 |
|
|
$form->setVal("dossier", $idxformulaire); |
62 |
|
|
} |
63 |
|
|
} |
64 |
|
|
} |
65 |
fraynaud |
10 |
|
66 |
|
|
function triggerajouterapres($id,&$db,$val,$DEBUG){ |
67 |
|
|
// calcul terrain surface dossier |
68 |
fraynaud |
244 |
$sql ="select sum(surface) as surface from ".DB_PREFIXE."terrain inner join ".DB_PREFIXE."parcelle on terrain.parcelle =parcelle.parcelle where dossier ='" |
69 |
fraynaud |
10 |
.$val['dossier']."'" ; |
70 |
|
|
$res=$db->query($sql); |
71 |
fraynaud |
38 |
if (database::isError($res)) |
72 |
fraynaud |
20 |
die($res->getMessage()); |
73 |
fraynaud |
38 |
while ($row=& $res->fetchRow( DB_FETCHMODE_ASSOC)){ |
74 |
fraynaud |
20 |
$cle= " dossier = '".$val['dossier']."'"; |
75 |
fraynaud |
38 |
if(!is_numeric($row['surface'])) |
76 |
|
|
$surface=0; |
77 |
|
|
else |
78 |
|
|
$surface = $row['surface']; |
79 |
|
|
$valF['terrain_surface_calcul']= $surface; |
80 |
fraynaud |
244 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
81 |
fraynaud |
20 |
if (database::isError($res1)) |
82 |
|
|
die($res1->getMessage()); |
83 |
|
|
if ($DEBUG == 1) |
84 |
fraynaud |
38 |
echo _("requête_de_maj_effectuee")."<br>"; |
85 |
fraynaud |
45 |
$this->msg=$this->msg."<br>"._('enregistrement')." ".$val['dossier']." \"dossier\"" |
86 |
|
|
." [ ".$db->affectedRows()." "._('enregistrement')." "._('mis a jour')." ]" ; |
87 |
fraynaud |
20 |
} |
88 |
fraynaud |
10 |
} |
89 |
|
|
|
90 |
|
|
function triggermodifierapres($id,&$db,$val,$DEBUG){ |
91 |
|
|
// calcul terrain surface dossier |
92 |
fraynaud |
244 |
$sql ="select sum(surface) as surface from ".DB_PREFIXE."terrain inner join ".DB_PREFIXE."parcelle on terrain.parcelle =parcelle.parcelle where dossier ='" |
93 |
fraynaud |
20 |
.$val['dossier']."'" ; |
94 |
|
|
$res=$db->query($sql); |
95 |
fraynaud |
38 |
if (database::isError($res1)) |
96 |
fraynaud |
20 |
die($res->getMessage()."erreur ".$sql); |
97 |
|
|
while ($row=& $res->fetchRow( DB_FETCHMODE_ASSOC)){ |
98 |
|
|
$cle= " dossier = '".$val['dossier']."'"; |
99 |
fraynaud |
38 |
if(!is_numeric($row['surface'])) |
100 |
|
|
$surface=0; |
101 |
|
|
else |
102 |
|
|
$surface = $row['surface']; |
103 |
|
|
$valF['terrain_surface_calcul']= $surface; |
104 |
fraynaud |
244 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
105 |
fraynaud |
20 |
if (database::isError($res)) |
106 |
|
|
die($res->getMessage()); |
107 |
|
|
if ($DEBUG == 1) |
108 |
fraynaud |
38 |
echo _("requête_de_maj_effectuee")."<br>"; |
109 |
fraynaud |
45 |
$this->msg=$this->msg."<br>"._('enregistrement')." ".$val['dossier']." \"dossier\"" |
110 |
|
|
." [ ".$db->affectedRows()." "._('enregistrement')." "._('mis a jour')." ]" ; |
111 |
fraynaud |
20 |
} |
112 |
fraynaud |
10 |
} |
113 |
|
|
|
114 |
fraynaud |
20 |
|
115 |
fraynaud |
10 |
function triggersupprimerapres($id,&$db,$val,$DEBUG){ |
116 |
|
|
// calcul terrain surface dossier |
117 |
fraynaud |
244 |
$sql ="select sum(surface) as surface from ".DB_PREFIXE."terrain inner join ".DB_PREFIXE."parcelle on terrain.parcelle =parcelle.parcelle where dossier ='" |
118 |
fraynaud |
20 |
.$val['dossier']."'" ; |
119 |
|
|
$res=$db->query($sql); |
120 |
fraynaud |
38 |
if (database::isError($res1)) |
121 |
fraynaud |
20 |
die($res->getMessage()."erreur ".$sql); |
122 |
|
|
while ($row=& $res->fetchRow( DB_FETCHMODE_ASSOC)){ |
123 |
fraynaud |
10 |
$cle= " dossier = '".$val['dossier']."'"; |
124 |
fraynaud |
38 |
if(!is_numeric($row['surface'])) |
125 |
|
|
$surface=0; |
126 |
|
|
else |
127 |
|
|
$surface = $row['surface']; |
128 |
|
|
$valF['terrain_surface_calcul']= $surface; |
129 |
fraynaud |
244 |
$res1= $db->autoExecute(DB_PREFIXE.'dossier',$valF,DB_AUTOQUERY_UPDATE,$cle); |
130 |
fraynaud |
20 |
if (database::isError($res)) |
131 |
|
|
die($res->getMessage()); |
132 |
|
|
if ($DEBUG == 1) |
133 |
fraynaud |
38 |
echo _("requête_de_maj_effectuee")."<br>"; |
134 |
fraynaud |
45 |
$this->msg=$this->msg."<br>"._('enregistrement')." ".$val['dossier']." \"dossier\"" |
135 |
|
|
." [ ".$db->affectedRows()." "._('enregistrement')." "._('mis a jour')." ]" ; |
136 |
fraynaud |
20 |
} |
137 |
fraynaud |
10 |
} |
138 |
|
|
|
139 |
fraynaud |
3 |
}// fin classe |
140 |
|
|
?> |