1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 03/10/2012 16:52 |
4 |
|
5 |
require_once ("../obj/om_dbform.class.php"); |
6 |
|
7 |
class parcelle_gen extends om_dbform { |
8 |
var $table="parcelle"; |
9 |
var $clePrimaire="parcelle"; |
10 |
var $typeCle="A"; |
11 |
var $required_field=array( |
12 |
"parcelle" |
13 |
); |
14 |
var $retourformulaire; |
15 |
|
16 |
function setvalF($val) { |
17 |
//affectation valeur formulaire |
18 |
$this->valF['parcelle'] = $val['parcelle']; |
19 |
if ($val['debut'] == "") { |
20 |
$this->valF['debut'] = ""; // -> default |
21 |
} else { |
22 |
$this->valF['debut'] = $val['debut']; |
23 |
} |
24 |
if ($val['rivoli'] == "") { |
25 |
$this->valF['rivoli'] = NULL; |
26 |
} else { |
27 |
$this->valF['rivoli'] = $val['rivoli']; |
28 |
} |
29 |
if ($val['proprietaire'] == "") { |
30 |
$this->valF['proprietaire'] = NULL; |
31 |
} else { |
32 |
$this->valF['proprietaire'] = $val['proprietaire']; |
33 |
} |
34 |
if ($val['pos'] == "") { |
35 |
$this->valF['pos'] = NULL; |
36 |
} else { |
37 |
$this->valF['pos'] = $val['pos']; |
38 |
} |
39 |
if (!is_numeric($val['surface'])) { |
40 |
$this->valF['surface'] = NULL; |
41 |
} else { |
42 |
$this->valF['surface'] = $val['surface']; |
43 |
} |
44 |
if ($val['section'] == "") { |
45 |
$this->valF['section'] = NULL; |
46 |
} else { |
47 |
$this->valF['section'] = $val['section']; |
48 |
} |
49 |
if ($val['commune'] == "") { |
50 |
$this->valF['commune'] = NULL; |
51 |
} else { |
52 |
$this->valF['commune'] = $val['commune']; |
53 |
} |
54 |
if ($val['geom'] == "") { |
55 |
unset($this->valF['geom']); |
56 |
} |
57 |
} |
58 |
|
59 |
//========================== |
60 |
// Formulaire [form] |
61 |
//========================== |
62 |
|
63 |
function setType(&$form,$maj) { |
64 |
//type |
65 |
if ($maj==0){ //ajout |
66 |
$form->setType('parcelle','text'); |
67 |
$form->setType('debut','text'); |
68 |
|
69 |
if($this->retourformulaire=='rivoli' |
70 |
and $form->val['rivoli'] == $this->getParameter('idxformulaire')) { |
71 |
$form->setType('rivoli','selecthiddenstatic'); |
72 |
} else { |
73 |
$form->setType('rivoli','select'); |
74 |
} |
75 |
|
76 |
if($this->retourformulaire=='proprietaire' |
77 |
and $form->val['proprietaire'] == $this->getParameter('idxformulaire')) { |
78 |
$form->setType('proprietaire','selecthiddenstatic'); |
79 |
} else { |
80 |
$form->setType('proprietaire','select'); |
81 |
} |
82 |
|
83 |
if($this->retourformulaire=='pos' |
84 |
and $form->val['pos'] == $this->getParameter('idxformulaire')) { |
85 |
$form->setType('pos','selecthiddenstatic'); |
86 |
} else { |
87 |
$form->setType('pos','select'); |
88 |
} |
89 |
$form->setType('surface','text'); |
90 |
$form->setType('section','text'); |
91 |
$form->setType('commune','text'); |
92 |
$form->setType('geom','geom'); |
93 |
}// fin ajout |
94 |
if ($maj==1){ //modifier |
95 |
$form->setType('parcelle','hiddenstatic'); |
96 |
$form->setType('debut','text'); |
97 |
|
98 |
if($this->retourformulaire=='rivoli' |
99 |
and $form->val['rivoli'] == $this->getParameter('idxformulaire')) { |
100 |
$form->setType('rivoli','selecthiddenstatic'); |
101 |
} else { |
102 |
$form->setType('rivoli','select'); |
103 |
} |
104 |
|
105 |
if($this->retourformulaire=='proprietaire' |
106 |
and $form->val['proprietaire'] == $this->getParameter('idxformulaire')) { |
107 |
$form->setType('proprietaire','selecthiddenstatic'); |
108 |
} else { |
109 |
$form->setType('proprietaire','select'); |
110 |
} |
111 |
|
112 |
if($this->retourformulaire=='pos' |
113 |
and $form->val['pos'] == $this->getParameter('idxformulaire')) { |
114 |
$form->setType('pos','selecthiddenstatic'); |
115 |
} else { |
116 |
$form->setType('pos','select'); |
117 |
} |
118 |
$form->setType('surface','text'); |
119 |
$form->setType('section','text'); |
120 |
$form->setType('commune','text'); |
121 |
$form->setType('geom','geom'); |
122 |
}// fin modifier |
123 |
if ($maj==2){ //supprimer |
124 |
$form->setType('parcelle','hiddenstatic'); |
125 |
$form->setType('debut','hiddenstatic'); |
126 |
$form->setType('rivoli','selectstatic'); |
127 |
$form->setType('proprietaire','selectstatic'); |
128 |
$form->setType('pos','selectstatic'); |
129 |
$form->setType('surface','hiddenstatic'); |
130 |
$form->setType('section','hiddenstatic'); |
131 |
$form->setType('commune','hiddenstatic'); |
132 |
$form->setType('geom','hiddenstatic'); |
133 |
}//fin supprimer |
134 |
if ($maj==3){ //consulter |
135 |
$form->setType('parcelle','static'); |
136 |
$form->setType('debut','static'); |
137 |
$form->setType('rivoli','selectstatic'); |
138 |
$form->setType('proprietaire','selectstatic'); |
139 |
$form->setType('pos','selectstatic'); |
140 |
$form->setType('surface','static'); |
141 |
$form->setType('section','static'); |
142 |
$form->setType('commune','static'); |
143 |
$form->setType('geom','geom'); |
144 |
}//fin consulter |
145 |
} |
146 |
|
147 |
function setOnchange(&$form,$maj) { |
148 |
//javascript controle client |
149 |
$form->setOnchange('surface','VerifNum(this)'); |
150 |
} |
151 |
/** |
152 |
* Methode setTaille |
153 |
*/ |
154 |
function setTaille(&$form, $maj) { |
155 |
$form->setTaille("parcelle", 10); |
156 |
$form->setTaille("debut", 10); |
157 |
$form->setTaille("rivoli", 10); |
158 |
$form->setTaille("proprietaire", 10); |
159 |
$form->setTaille("pos", 10); |
160 |
$form->setTaille("surface", 20); |
161 |
$form->setTaille("section", 10); |
162 |
$form->setTaille("commune", 10); |
163 |
$form->setTaille("geom", 10); |
164 |
} |
165 |
|
166 |
/** |
167 |
* Methode setMax |
168 |
*/ |
169 |
function setMax(&$form, $maj) { |
170 |
$form->setMax("parcelle", 6); |
171 |
$form->setMax("debut", 4); |
172 |
$form->setMax("rivoli", 4); |
173 |
$form->setMax("proprietaire", 6); |
174 |
$form->setMax("pos", 6); |
175 |
$form->setMax("surface", 20); |
176 |
$form->setMax("section", 7); |
177 |
$form->setMax("commune", 5); |
178 |
$form->setMax("geom", -5); |
179 |
} |
180 |
|
181 |
|
182 |
function setLib(&$form,$maj) { |
183 |
//libelle des champs |
184 |
$form->setLib('parcelle',_('parcelle')); |
185 |
$form->setLib('debut',_('debut')); |
186 |
$form->setLib('rivoli',_('rivoli')); |
187 |
$form->setLib('proprietaire',_('proprietaire')); |
188 |
$form->setLib('pos',_('pos')); |
189 |
$form->setLib('surface',_('surface')); |
190 |
$form->setLib('section',_('section')); |
191 |
$form->setLib('commune',_('commune')); |
192 |
$form->setLib('geom',_('geom')); |
193 |
} |
194 |
|
195 |
function setSelect(&$form, $maj,&$db,$debug) { |
196 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
197 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
198 |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
199 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
200 |
|
201 |
// pos |
202 |
$this->init_select($form, $db, $maj, $debug, "pos", |
203 |
$sql_pos, $sql_pos_by_id, false); |
204 |
|
205 |
// proprietaire |
206 |
$this->init_select($form, $db, $maj, $debug, "proprietaire", |
207 |
$sql_proprietaire, $sql_proprietaire_by_id, false); |
208 |
|
209 |
// rivoli |
210 |
$this->init_select($form, $db, $maj, $debug, "rivoli", |
211 |
$sql_rivoli, $sql_rivoli_by_id, false); |
212 |
// geom |
213 |
if($maj==1 || $maj==3){ //modification ou visualisation |
214 |
$contenu=array(); |
215 |
$contenu[0]=array("parcelle",$this->getParameter("idx"),"0"); |
216 |
$form->setSelect('geom',$contenu); |
217 |
} |
218 |
}// fin select |
219 |
|
220 |
//================================== |
221 |
// sous Formulaire [subform] |
222 |
//================================== |
223 |
|
224 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){ |
225 |
$this->retourformulaire = $retourformulaire; |
226 |
if($validation == 0) { |
227 |
if($retourformulaire =='pos') |
228 |
$form->setVal('pos', $idxformulaire); |
229 |
if($retourformulaire =='proprietaire') |
230 |
$form->setVal('proprietaire', $idxformulaire); |
231 |
if($retourformulaire =='rivoli') |
232 |
$form->setVal('rivoli', $idxformulaire); |
233 |
}// fin validation |
234 |
}// fin setValsousformulaire |
235 |
|
236 |
//================================== |
237 |
// cle secondaire [secondary key] |
238 |
//================================== |
239 |
/** |
240 |
* Methode clesecondaire |
241 |
*/ |
242 |
function cleSecondaire($id, &$db = NULL, $val = array(), $DEBUG = false) { |
243 |
// On appelle la methode de la classe parent |
244 |
parent::cleSecondaire($id, $db, $val, $DEBUG); |
245 |
// Verification de la cle secondaire : dossier |
246 |
$this->rechercheTable($db, "dossier", "parcelle", $id); |
247 |
// Verification de la cle secondaire : terrain |
248 |
$this->rechercheTable($db, "terrain", "parcelle", $id); |
249 |
} |
250 |
|
251 |
|
252 |
}// fin classe |
253 |
?> |