/[openfoncier]/trunk/obj/donnees_techniques.class.php
ViewVC logotype

Contents of /trunk/obj/donnees_techniques.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1397 - (show annotations)
Wed Mar 13 18:23:16 2013 UTC (11 years, 10 months ago) by nhaye
File size: 20903 byte(s)
Correction du test d'existance des tableaux de données techniques

1 <?php
2 //$Id$
3 //gen openMairie le 13/02/2013 14:41
4
5 require_once ("../gen/obj/donnees_techniques.class.php");
6
7 class donnees_techniques extends donnees_techniques_gen {
8
9 var $cerfa; // Instance de la classe cerfa
10
11 function donnees_techniques($id,&$db,$debug) {
12 $this->constructeur($id,$db,$debug);
13 }// fin constructeur
14
15 /**
16 * Méthode permettant de récupérer l'id du cerfa lié au dossier
17 **/
18 function getCerfa(){
19 if($this->getParameter("retourformulaire") == "lot") {
20 $sql = "SELECT cerfa_lot FROM ".DB_PREFIXE."dossier_instruction_type
21 JOIN ".DB_PREFIXE."dossier ON dossier.dossier_instruction_type=
22 dossier_instruction_type.dossier_instruction_type
23 JOIN ".DB_PREFIXE."lien_dossier_lot ON dossier.dossier=lien_dossier_lot.dossier
24 WHERE lien_dossier_lot.lot = ".$this->getParameter("idxformulaire");
25
26 } else {
27 $sql = "SELECT cerfa FROM ".DB_PREFIXE."dossier_instruction_type
28 JOIN ".DB_PREFIXE."dossier ON dossier.dossier_instruction_type=
29 dossier_instruction_type.dossier_instruction_type
30 WHERE dossier = '";
31 $sql .= $this->getParameter("idxformulaire")."'";
32 }
33
34 $cerfa = $this->db->getOne($sql);
35 $this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
36 $this->f->isDatabaseError($cerfa);
37
38 // Si le cerfa est défini dans dossier on instancie le cerfa correspondant
39 if(!empty($cerfa)) {
40 require_once ("../obj/cerfa.class.php");
41 $this->cerfa = new cerfa($cerfa, $this->db, DEBUG);
42 } else {
43 $this->f->displayMessage("error", _("Aucun cerfa lie a ce type de dossier"));
44 die();
45 }
46 }
47
48 /**
49 * Méthode permettant de vérifier si le tableau passé en parametre est défini
50 * dans la table des cerfa
51 */
52
53 function setTabSelect($tab, $idchamp) {
54 // Test si un tableau de surface a été défini
55 if ( $this->cerfa->getVal($idchamp) != "" ){
56
57 // Configuration du tableau des surfaces
58 $contenu['column_header']=$tab[$this->cerfa->getVal($idchamp)]['column_header'];
59 $contenu['row_header']=$tab[$this->cerfa->getVal($idchamp)]['row_header'];
60
61 foreach($tab[$this->cerfa->getVal($idchamp)]['values'] as $champ) {
62 $contenu['values'][$champ] = $this->getVal($champ);
63 }
64
65 $this->form->setSelect($idchamp,$contenu);
66 }
67 }
68
69
70 function setSelect(&$form, $maj,&$db,$debug) {
71 parent::setSelect($form, $maj,$db,$debug);
72 if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php"))
73 include ("../sql/".$db->phptype."/".$this->table.".form.inc.php");
74 elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc"))
75 include ("../sql/".$db->phptype."/".$this->table.".form.inc");
76
77 if(empty($this->cerfa)) {
78 $this->getCerfa();
79 }
80
81 $this->setTabSelect($tab_surface, "tab_surface");
82 $this->setTabSelect($tab_tax_su_princ, "tab_tax_su_princ");
83 $this->setTabSelect($tab_tax_su_heber, "tab_tax_su_heber");
84 $this->setTabSelect($tab_tax_su_secon, "tab_tax_su_secon");
85 $this->setTabSelect($tab_tax_su_tot, "tab_tax_su_tot");
86 $this->setTabSelect($tab_tax_su_tot, "tab_tax_su_non_habit_surf");
87 $this->setTabSelect($tab_tax_am, "tab_tax_am");
88
89
90 }
91
92
93 // XXX Créer une nouvelle méthode au même endroit que l'appel a checkAccessibility()
94 function checkAccessibility() {
95 if(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php"))
96 include ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php");
97 elseif(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc"))
98 include ("../sql/".$this->db->phptype."/".$this->table.".form.inc");
99 if(empty($this->cerfa)) {
100 $this->getCerfa();
101 }
102
103 $id_tab_surface = $this->cerfa->getVal("tab_surface");
104 $id_tab_tax_su_princ = $this->cerfa->getVal("tab_tax_su_princ");
105 $id_tab_tax_su_heber = $this->cerfa->getVal("tab_tax_su_heber");
106 $id_tab_tax_su_secon = $this->cerfa->getVal("tab_tax_su_secon");
107 $id_tab_tax_su_tot = $this->cerfa->getVal("tab_tax_su_tot");
108 $id_tab_tax_su_non_habit_surf = $this->cerfa->getVal("tab_tax_su_non_habit_surf");
109 $id_tab_tax_am = $this->cerfa->getVal("tab_tax_am");
110
111 //Suppression des champs de tableaux
112 if(!empty($id_tab_surface)) {
113 foreach($tab_surface[$this->cerfa->getVal("tab_surface")]['values'] as $champ) {
114 unset($this->champs[array_search($champ,$this->champs)]);
115 }
116 }
117 if(!empty($id_tab_tax_su_princ)) {
118 foreach($tab_tax_su_princ[$this->cerfa->getVal("tab_tax_su_princ")]['values'] as $champ) {
119 unset($this->champs[array_search($champ,$this->champs)]);
120 }
121 }
122 if(!empty($id_tab_tax_su_heber)) {
123 foreach($tab_tax_su_heber[$this->cerfa->getVal("tab_tax_su_heber")]['values'] as $champ) {
124 unset($this->champs[array_search($champ,$this->champs)]);
125 }
126 }
127 if(!empty($id_tab_tax_su_secon)) {
128 foreach($tab_tax_su_secon[$this->cerfa->getVal("tab_tax_su_secon")]['values'] as $champ) {
129 unset($this->champs[array_search($champ,$this->champs)]);
130 }
131 }
132 if(!empty($id_tab_tax_su_tot)) {
133 foreach($tab_tax_su_tot[$this->cerfa->getVal("tab_tax_su_tot")]['values'] as $champ) {
134 unset($this->champs[array_search($champ,$this->champs)]);
135 }
136 }
137 if(!empty($id_tab_tax_su_non_habit_surf)) {
138 foreach($tab_tax_su_non_habit_surf[$this->cerfa->getVal("tab_tax_su_non_habit_surf")]['values'] as $champ) {
139 unset($this->champs[array_search($champ,$this->champs)]);
140 }
141 }
142 if(!empty($id_tab_tax_am)) {
143 foreach($tab_tax_am[$this->cerfa->getVal("tab_tax_am")]['values'] as $champ) {
144 unset($this->champs[array_search($champ,$this->champs)]);
145 }
146 }
147 // Renumérotation
148 $this->champs = array_values($this->champs);
149 }
150
151 /**
152 * Méthode permettant de définir le type des différents tableaux en fonction
153 * des valeurs du cerfa
154 **/
155 function setTabType($tab) {
156 // Définition du type "tableau"
157 if ( $this->cerfa->getVal($tab) != "" ){
158
159 $this->form->setType($tab,'tableau');
160 }
161 //Le chache si non défini
162 else {
163
164 $this->form->setType($tab,'hidden');
165 }
166 }
167
168 /**
169 * Méthode permettant de définir le type des champs des tableaux en fonction
170 * des valeurs du cerfa
171 **/
172 function setTabChampType($tab) {
173 if(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php"))
174 include ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php");
175 elseif(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc"))
176 include ("../sql/".$this->db->phptype."/".$this->table.".form.inc");
177 // Pour chaque champ dans la liste des champs du cerfa
178 $tableau = $$tab;
179 print_r($tableau[$this->cerfa->getVal($tab)]['values']);
180 foreach ($this->champs as $champ) {
181 if(array_search($champ, $this->cerfa->champs) !== false) {
182 // On les cache si décoché dans le formulaire de cerfa
183 if($this->cerfa->getVal($champ) == 'f') {
184 $this->form->setType($champ,'hidden');
185 }
186 } else {
187
188 if(!in_array($champ, $tableau[$this->cerfa->getVal($tab)]['values'])) {
189
190 $this->form->setType($champ,'hidden');
191 }
192 }
193 }
194 }
195
196
197
198 function setType(&$form,$maj) {
199 parent::setType($form,$maj);
200
201 if(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php"))
202 include ("../sql/".$this->db->phptype."/".$this->table.".form.inc.php");
203 elseif(file_exists ("../sql/".$this->db->phptype."/".$this->table.".form.inc"))
204 include ("../sql/".$this->db->phptype."/".$this->table.".form.inc");
205
206 if(empty($this->cerfa)) {
207 $this->getCerfa();
208 }
209
210 $this->setTabType("tab_surface");
211 $this->setTabType("tab_tax_su_princ");
212 $this->setTabType("tab_tax_su_heber");
213 $this->setTabType("tab_tax_su_secon");
214 $this->setTabType("tab_tax_su_tot");
215 $this->setTabType("tab_tax_su_non_habit_surf");
216 $this->setTabType("tab_tax_am");
217
218
219 //Cache les champs des clés étrangères, elles sont renseignées automatiquement
220 $form->setType('dossier_instruction', 'hidden');
221 $form->setType('lot', 'hidden');
222
223 // Boucler sur les champs du cerfa pour cacher les données qui ne doivent
224 // pas être saisies
225
226 foreach ($this->champs as $champ) {
227 if(array_search($champ, $this->cerfa->champs) !== false) {
228 if($this->cerfa->getVal($champ) == 'f') {
229 $form->setType($champ,'hidden');
230 }
231 } else {
232 $id_tab_surface = $this->cerfa->getVal("tab_surface");
233 $id_tab_tax_su_princ = $this->cerfa->getVal("tab_tax_su_princ");
234 $id_tab_tax_su_heber = $this->cerfa->getVal("tab_tax_su_heber");
235 $id_tab_tax_su_secon = $this->cerfa->getVal("tab_tax_su_secon");
236 $id_tab_tax_su_tot = $this->cerfa->getVal("tab_tax_su_tot");
237 $id_tab_tax_su_non_habit_surf = $this->cerfa->getVal("tab_tax_su_non_habit_surf");
238 $id_tab_tax_am = $this->cerfa->getVal("tab_tax_am");
239 $hidden = false;
240
241 if(!empty($id_tab_surface)) {
242 if(!in_array($champ, $tab_surface[$this->cerfa->getVal("tab_surface")]['values'])) {
243 $hidden = true;
244 }
245 }
246 if(!empty($id_tab_tax_su_princ)) {
247 if(!in_array($champ, $tab_tax_su_princ[$this->cerfa->getVal("tab_tax_su_princ")]['values'])) {
248 $hidden = true;
249 }
250 }
251 if(!empty($id_tab_tax_su_heber)) {
252 if(!in_array($champ, $tab_surface[$this->cerfa->getVal("tab_surface")]['values'])) {
253 $hidden = true;
254 }
255 }
256 if(!empty($id_tab_tax_su_secon)) {
257 if(!in_array($champ, $tab_tax_su_secon[$this->cerfa->getVal("tab_tax_su_secon")]['values'])) {
258 $hidden = true;
259 }
260 }
261 if(!empty($id_tab_tax_su_tot)) {
262 if(!in_array($champ, $tab_tax_su_tot[$this->cerfa->getVal("tab_tax_su_tot")]['values'])) {
263 $hidden = true;
264 }
265 }
266 if(!empty($id_tab_tax_su_non_habit_surf)) {
267 if(!in_array($champ, $tab_tax_su_non_habit_surf[$this->cerfa->getVal("tab_tax_su_non_habit_surf")]['values'])) {
268 $hidden = true;
269 }
270 }
271 if(!empty($id_tab_tax_am)) {
272 if(!in_array($champ, $tab_tax_am[$this->cerfa->getVal("tab_tax_am")]['values'])) {
273 $hidden = true;
274 }
275 }
276 if($hidden){
277 $form->setType($champ,'hidden');
278 }
279 }
280 }
281 }
282
283 // Ajout des clés étrangères
284 function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){
285 $this->retourformulaire = $retourformulaire;
286 if($validation == 0) {
287
288 //Si on est dans le dossier
289 if($retourformulaire =='dossier' || $retourformulaire =='dossier_instruction' ) {
290
291 $form->setVal('dossier_instruction', $idxformulaire);
292 $form->setVal('lot', "");
293 }
294
295 //Si on est dans le lot
296 if($retourformulaire =='lot') {
297
298 $form->setVal('dossier_instruction', "");
299 $form->setVal('lot', $idxformulaire);
300 }
301 }// fin validation
302 }// fin setValsousformulaire
303
304 function setLayout(&$form, $maj) {
305 /*Fieldset Parametrage du cerfa */
306 $form->setBloc('cerfa','D',"","col_12");
307 $form->setFieldset('cerfa','D'
308 ,_("Parametrage du cerfa"));
309
310
311 $form->setFieldset('om_validite_fin','F','');
312 $form->setBloc('om_validite_fin','F');
313
314 $form->setBloc('avap_co_elt_pro','D',"","col_12");
315 $form->setFieldset('avap_co_elt_pro','D'
316 ,_("Projet"));
317
318
319 $form->setFieldset('avap_aut_auv_elec','F','');
320 $form->setBloc('avap_aut_auv_elec','F');
321
322
323 $form->setBloc('tr_total','D',"","col_12");
324 $form->setFieldset('tr_total','D'
325 ,_("Projet"));
326
327
328 $form->setFieldset('tr_desc','F','');
329 $form->setBloc('tr_desc','F');
330
331
332
333 /*Fieldset n°4 Projet d'aménagement */
334 $form->setBloc('am_lotiss','D',"","col_12");
335 $form->setFieldset('am_lotiss','D'
336 ,_("Projet d'amenagement"));
337 // bloc 4.1
338 $form->setBloc('am_lotiss','D',_("Nature des travaux, instalations
339 ou amenagements envisages"),"col_12");
340
341 $form->setBloc('am_tranche_desc','F');
342
343 // bloc 4.2
344 $form->setBloc('am_lot_max_nb','D',_("Demande concernant un lotissement"),"col_12");
345
346 $form->setBloc('am_lot_vente_ant','F');
347
348 // bloc 4.3
349 $form->setBloc('am_empl_nb','D',_("Amenagement d'un camping ou
350 d'un terrain amenage en vue de l'hebergement
351 touristique"),"col_12");
352
353 $form->setBloc('am_exist_agrand','F');
354
355 $form->setFieldset('am_coupe_autr','F','');
356
357 $form->setBloc('am_coupe_autr','F');
358
359 /*Fieldset n°5 Projet de construction */
360 $form->setBloc('co_archi_recours','D',"","col_12");
361 $form->setFieldset('co_archi_recours','D'
362 ,_("Projet de construction"));
363 // bloc 5.1
364 $form->setBloc('co_archi_recours','D',_("Architecte"),"col_12");
365
366 $form->setBloc('co_archi_recours','F');
367
368 // bloc 5.2
369 $form->setBloc('co_cstr_nouv','D',_("Nature du projet"),"col_12");
370
371 $form->setBloc('co_elec_tension','F');
372
373 // bloc 5.3
374 $form->setBloc('co_tot_log_nb','D',_("Informations complementaires"),"col_12");
375
376 $form->setBloc('co_trx_nivsup','F');
377
378 // bloc 5.4
379 $form->setBloc('co_demont_period','D',_("Construction periodiquement
380 demontee et re-installee"),"col_12");
381
382 $form->setBloc('co_demont_period','F');
383
384 // bloc 5.5
385 $form->setBloc('tab_surface','D',_("Destination des constructions
386 et tableau des surfaces"),"col_12");
387
388 $form->setBloc('tab_surface','F');
389
390 // bloc 5.6
391 $form->setBloc('co_sp_transport','D',_("Destination des constructions
392 futures en cas de realisation au benefice d'un
393 service public ou d'interet collectif"),"col_12");
394
395 $form->setBloc('co_sp_culture','F');
396
397 // bloc 5.7
398 $form->setBloc('co_statio_avt_nb','D',_("Stationnement"),"col_12");
399
400 $form->setBloc('co_statio_comm_cin_surf','F');
401
402 $form->setFieldset('co_statio_apr_surf','F','');
403
404 $form->setBloc('co_statio_apr_surf','F');
405
406
407 /*Fieldset n°6 Projet necessitant demolitions */
408 $form->setBloc('dm_constr_dates','D',"","col_12");
409 $form->setFieldset('dm_constr_dates','D'
410 ,_("Projet necessitant demolitions"));
411
412 $form->setBloc('dm_constr_dates','D',"","col_12");
413
414 $form->setBloc('dm_tot_log_nb','F');
415
416 $form->setFieldset('dm_tot_log_nb','F','');
417
418 $form->setBloc('dm_tot_log_nb','F');
419
420 $form->setBloc('tax_surf_tot','D',_("Declaration des elements necessaires au calcul des impositions"),"col_12");
421 $form->setBloc('tax_surf_tot','D',"","col_12");
422 $form->setFieldset('tax_surf_tot','D'
423 ,_("Renseignement"));
424
425 $form->setBloc('tax_surf_tot','D',"","col_12");
426
427 $form->setBloc('tax_dest_loc_tr','F');
428
429 $form->setBloc('tab_tax_su_princ','D',_("Locaux a usage d'habitation principale"),"col_12");
430 $form->setBloc('tab_tax_su_princ','F');
431
432 $form->setBloc('tab_tax_su_heber','D',_("Locaux a usage d'hebergement"),"col_12");
433 $form->setBloc('tab_tax_su_heber','F');
434
435 $form->setBloc('tab_tax_su_secon','D',_("Locaux a usage d'habitation secondaire"),"col_12");
436 $form->setBloc('tab_tax_su_secon','F');
437
438 $form->setBloc('tab_tax_su_tot','D',_("Total de logement"),"col_12");
439 $form->setBloc('tab_tax_su_tot','F');
440
441 $form->setBloc('tax_ext_pret','D',"","col_12");
442 $form->setBloc('tax_log_exist_nb','F');
443
444 $form->setBloc('tax_comm_nb','D',_("Creation ou extension de locaux non destines a l'habitation"),"col_12");
445 $form->setBloc('tab_tax_su_non_habit_surf','F');
446
447 $form->setBloc('tab_tax_am','D',_("Autres elements soumis a la taxe d'amenagement"),"col_12");
448 $form->setBloc('tab_tax_am','F');
449
450 $form->setBloc('tax_trx_presc_ppr','D',_("Cas particuliers"),"col_12");
451 $form->setBloc('tax_monu_hist','F');
452
453 $form->setFieldset('tax_monu_hist','F','');
454
455 $form->setBloc('tax_monu_hist','F');
456
457 $form->setBloc('vsd_surf_planch_smd','D',"","col_12");
458 $form->setFieldset('vsd_surf_planch_smd','D'
459 ,_("Autres renseignements"));
460
461 $form->setBloc('vsd_surf_planch_smd','D',_("Versement pour sous-densite (VSD)"),"col_12");
462 $form->setBloc('vsd_rescr_fisc','F');
463
464 $form->setBloc('pld_val_terr','D',_("Plafond legal de densite (PLD)"),"col_12");
465 $form->setBloc('pld_const_exist_dem_surf','F');
466
467 $form->setFieldset('pld_const_exist_dem_surf','F','');
468
469 $form->setBloc('pld_const_exist_dem_surf','F');
470
471 $form->setBloc('pld_const_exist_dem_surf','F');
472 }
473
474
475
476 /**
477 * Surcharge du bouton retour afin de retourner sur le dossier d'instruction selon de cas
478 */
479 function retoursousformulaire($idxformulaire, $retourformulaire, $val,
480 $objsf, $premiersf, $tricolsf, $validation,
481 $idx, $maj, $retour) {
482
483 $visualisation = $this->getParameter('visualisation');
484
485 if ( $visualisation == "" ){
486
487 // Ajout et consultation, retour dossier
488 if ( ( $maj == 0 && $validation == 0 ) ||
489 ( $maj == 3 && $validation == 0 ) ||
490 ( $maj == 0 && $validation == 1 ) && $retourformulaire == "dossier_instruction" ){
491
492 echo "\n<a class=\"retour\" ";
493 echo "href=\"#\" ";
494 echo "onclick=\"redirectPortletAction(1,'main');\" ";
495 echo ">";
496 echo _("Retour");
497 echo "</a>\n";
498 }
499 //Sinon affiche un retour normal
500 else{
501
502 parent::retoursousformulaire($idxformulaire, $retourformulaire, $val,
503 $objsf, $premiersf, $tricolsf, $validation,
504 $idx, $maj, $retour);
505 }
506 }
507 }
508 }// fin classe
509 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26