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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1560 - (hide annotations)
Tue Mar 26 11:50:49 2013 UTC (11 years, 10 months ago) by nhaye
File size: 21352 byte(s)
Correction de l'affichage des tableaux dans les formulaires des données techniques

1 vpihour 1249 <?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 nhaye 1262 var $cerfa; // Instance de la classe cerfa
10    
11 vpihour 1249 function donnees_techniques($id,&$db,$debug) {
12     $this->constructeur($id,$db,$debug);
13     }// fin constructeur
14    
15 nhaye 1262 /**
16     * Méthode permettant de récupérer l'id du cerfa lié au dossier
17     **/
18     function getCerfa(){
19 nhaye 1270 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 nhaye 1263
26 nhaye 1268 } else {
27 nhaye 1270 $sql = "SELECT cerfa FROM ".DB_PREFIXE."dossier_instruction_type
28 nhaye 1263 JOIN ".DB_PREFIXE."dossier ON dossier.dossier_instruction_type=
29     dossier_instruction_type.dossier_instruction_type
30 nhaye 1270 WHERE dossier = '";
31     $sql .= $this->getParameter("idxformulaire")."'";
32     }
33 nhaye 1268
34 nhaye 1262 $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 nhaye 1263 } else {
43 fmichon 1316 $this->f->displayMessage("error", _("Aucun cerfa lie a ce type de dossier"));
44 nhaye 1263 die();
45 nhaye 1262 }
46     }
47    
48 nhaye 1268 /**
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 nhaye 1262 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 nhaye 1268 $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 nhaye 1269 $this->setTabSelect($tab_tax_su_tot, "tab_tax_su_non_habit_surf");
87 nhaye 1268 $this->setTabSelect($tab_tax_am, "tab_tax_am");
88 nhaye 1262
89 nhaye 1268
90 nhaye 1262 }
91    
92    
93     // XXX Créer une nouvelle méthode au même endroit que l'appel a checkAccessibility()
94     function checkAccessibility() {
95 nhaye 1268 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 nhaye 1262
103 nhaye 1397 $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 nhaye 1268 //Suppression des champs de tableaux
112 nhaye 1397 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 nhaye 1268 }
117 nhaye 1397 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 nhaye 1394 }
122 nhaye 1397 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 nhaye 1394 }
127 nhaye 1397 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 nhaye 1394 }
132 nhaye 1397 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 nhaye 1394 }
137 nhaye 1397 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 nhaye 1394 }
142 nhaye 1397 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 nhaye 1394 }
147 nhaye 1262 // Renumérotation
148     $this->champs = array_values($this->champs);
149     }
150    
151 nhaye 1269 /**
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 nhaye 1394 /**
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 nhaye 1262 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 nhaye 1269 $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 vpihour 1266 //Cache les champs des clés étrangères, elles sont renseignées automatiquement
220 nhaye 1262 $form->setType('dossier_instruction', 'hidden');
221 vpihour 1266 $form->setType('lot', 'hidden');
222    
223 nhaye 1262 // Boucler sur les champs du cerfa pour cacher les données qui ne doivent
224     // pas être saisies
225    
226 nhaye 1268 foreach ($this->champs as $champ) {
227     if(array_search($champ, $this->cerfa->champs) !== false) {
228 nhaye 1262 if($this->cerfa->getVal($champ) == 'f') {
229     $form->setType($champ,'hidden');
230     }
231 nhaye 1268 } else {
232 nhaye 1397 $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 nhaye 1560 $hidden = true;
240 nhaye 1394
241 nhaye 1560 // On cache tous les champs
242     $form->setType($champ,'hidden');
243    
244     // On défini l'affichage des champs des tableaux de configuration
245     // Si les tableau sont définis dans le cerfa on test si les champs des données
246     // techniques sont définis dans les tableaux de configuration des tableaux
247     // pour chaque cerfa alors on les affiche en type "text"
248 nhaye 1397 if(!empty($id_tab_surface)) {
249 nhaye 1560 if(in_array($champ, $tab_surface[$this->cerfa->getVal("tab_surface")]['values'])) {
250     $hidden = false;
251 nhaye 1397 }
252     }
253     if(!empty($id_tab_tax_su_princ)) {
254 nhaye 1560 if(in_array($champ, $tab_tax_su_princ[$this->cerfa->getVal("tab_tax_su_princ")]['values'])) {
255     $hidden = false;
256 nhaye 1397 }
257     }
258     if(!empty($id_tab_tax_su_heber)) {
259 nhaye 1560 if(in_array($champ, $tab_tax_su_heber[$this->cerfa->getVal("tab_tax_su_heber")]['values'])) {
260     $hidden = false;
261 nhaye 1397 }
262     }
263     if(!empty($id_tab_tax_su_secon)) {
264 nhaye 1560 if(in_array($champ, $tab_tax_su_secon[$this->cerfa->getVal("tab_tax_su_secon")]['values'])) {
265     $hidden = false;
266 nhaye 1397 }
267     }
268     if(!empty($id_tab_tax_su_tot)) {
269 nhaye 1560 if(in_array($champ, $tab_tax_su_tot[$this->cerfa->getVal("tab_tax_su_tot")]['values'])) {
270     $hidden = false;
271 nhaye 1397 }
272     }
273     if(!empty($id_tab_tax_su_non_habit_surf)) {
274 nhaye 1560 if(in_array($champ, $tab_tax_su_non_habit_surf[$this->cerfa->getVal("tab_tax_su_non_habit_surf")]['values'])) {
275     $hidden = false;
276 nhaye 1397 }
277     }
278     if(!empty($id_tab_tax_am)) {
279 nhaye 1560 if(in_array($champ, $tab_tax_am[$this->cerfa->getVal("tab_tax_am")]['values'])) {
280     $hidden = false;
281 nhaye 1397 }
282     }
283 nhaye 1560
284     if(!$hidden){
285     $form->setType($champ,'text');
286 nhaye 1268 }
287 nhaye 1262 }
288     }
289     }
290    
291 vpihour 1266 // Ajout des clés étrangères
292 nhaye 1263 function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){
293     $this->retourformulaire = $retourformulaire;
294     if($validation == 0) {
295 vpihour 1266
296     //Si on est dans le dossier
297     if($retourformulaire =='dossier' || $retourformulaire =='dossier_instruction' ) {
298    
299 nhaye 1263 $form->setVal('dossier_instruction', $idxformulaire);
300 vpihour 1266 $form->setVal('lot', "");
301     }
302    
303     //Si on est dans le lot
304     if($retourformulaire =='lot') {
305    
306     $form->setVal('dossier_instruction', "");
307 nhaye 1263 $form->setVal('lot', $idxformulaire);
308 vpihour 1266 }
309 nhaye 1263 }// fin validation
310     }// fin setValsousformulaire
311    
312 nhaye 1264 function setLayout(&$form, $maj) {
313 nhaye 1268 /*Fieldset Parametrage du cerfa */
314     $form->setBloc('cerfa','D',"","col_12");
315     $form->setFieldset('cerfa','D'
316 nhaye 1264 ,_("Parametrage du cerfa"));
317    
318    
319     $form->setFieldset('om_validite_fin','F','');
320     $form->setBloc('om_validite_fin','F');
321    
322 nhaye 1268 $form->setBloc('avap_co_elt_pro','D',"","col_12");
323     $form->setFieldset('avap_co_elt_pro','D'
324     ,_("Projet"));
325    
326    
327     $form->setFieldset('avap_aut_auv_elec','F','');
328     $form->setBloc('avap_aut_auv_elec','F');
329    
330    
331     $form->setBloc('tr_total','D',"","col_12");
332     $form->setFieldset('tr_total','D'
333     ,_("Projet"));
334    
335    
336     $form->setFieldset('tr_desc','F','');
337     $form->setBloc('tr_desc','F');
338    
339    
340    
341 nhaye 1264 /*Fieldset n°4 Projet d'aménagement */
342     $form->setBloc('am_lotiss','D',"","col_12");
343     $form->setFieldset('am_lotiss','D'
344     ,_("Projet d'amenagement"));
345     // bloc 4.1
346     $form->setBloc('am_lotiss','D',_("Nature des travaux, instalations
347 fmichon 1316 ou amenagements envisages"),"col_12");
348 nhaye 1264
349     $form->setBloc('am_tranche_desc','F');
350    
351     // bloc 4.2
352     $form->setBloc('am_lot_max_nb','D',_("Demande concernant un lotissement"),"col_12");
353    
354     $form->setBloc('am_lot_vente_ant','F');
355    
356     // bloc 4.3
357     $form->setBloc('am_empl_nb','D',_("Amenagement d'un camping ou
358 fmichon 1316 d'un terrain amenage en vue de l'hebergement
359 nhaye 1264 touristique"),"col_12");
360    
361     $form->setBloc('am_exist_agrand','F');
362    
363     $form->setFieldset('am_coupe_autr','F','');
364    
365     $form->setBloc('am_coupe_autr','F');
366    
367     /*Fieldset n°5 Projet de construction */
368     $form->setBloc('co_archi_recours','D',"","col_12");
369     $form->setFieldset('co_archi_recours','D'
370     ,_("Projet de construction"));
371     // bloc 5.1
372     $form->setBloc('co_archi_recours','D',_("Architecte"),"col_12");
373    
374     $form->setBloc('co_archi_recours','F');
375    
376     // bloc 5.2
377     $form->setBloc('co_cstr_nouv','D',_("Nature du projet"),"col_12");
378    
379     $form->setBloc('co_elec_tension','F');
380    
381     // bloc 5.3
382     $form->setBloc('co_tot_log_nb','D',_("Informations complementaires"),"col_12");
383    
384     $form->setBloc('co_trx_nivsup','F');
385    
386     // bloc 5.4
387     $form->setBloc('co_demont_period','D',_("Construction periodiquement
388 fmichon 1316 demontee et re-installee"),"col_12");
389 nhaye 1264
390     $form->setBloc('co_demont_period','F');
391    
392     // bloc 5.5
393     $form->setBloc('tab_surface','D',_("Destination des constructions
394     et tableau des surfaces"),"col_12");
395    
396     $form->setBloc('tab_surface','F');
397    
398     // bloc 5.6
399     $form->setBloc('co_sp_transport','D',_("Destination des constructions
400     futures en cas de realisation au benefice d'un
401     service public ou d'interet collectif"),"col_12");
402    
403     $form->setBloc('co_sp_culture','F');
404    
405     // bloc 5.7
406     $form->setBloc('co_statio_avt_nb','D',_("Stationnement"),"col_12");
407    
408     $form->setBloc('co_statio_comm_cin_surf','F');
409    
410     $form->setFieldset('co_statio_apr_surf','F','');
411    
412     $form->setBloc('co_statio_apr_surf','F');
413    
414    
415     /*Fieldset n°6 Projet necessitant demolitions */
416     $form->setBloc('dm_constr_dates','D',"","col_12");
417     $form->setFieldset('dm_constr_dates','D'
418     ,_("Projet necessitant demolitions"));
419    
420     $form->setBloc('dm_constr_dates','D',"","col_12");
421    
422     $form->setBloc('dm_tot_log_nb','F');
423    
424     $form->setFieldset('dm_tot_log_nb','F','');
425    
426     $form->setBloc('dm_tot_log_nb','F');
427 nhaye 1268
428     $form->setBloc('tax_surf_tot','D',_("Declaration des elements necessaires au calcul des impositions"),"col_12");
429     $form->setBloc('tax_surf_tot','D',"","col_12");
430     $form->setFieldset('tax_surf_tot','D'
431     ,_("Renseignement"));
432    
433     $form->setBloc('tax_surf_tot','D',"","col_12");
434    
435     $form->setBloc('tax_dest_loc_tr','F');
436    
437     $form->setBloc('tab_tax_su_princ','D',_("Locaux a usage d'habitation principale"),"col_12");
438     $form->setBloc('tab_tax_su_princ','F');
439    
440     $form->setBloc('tab_tax_su_heber','D',_("Locaux a usage d'hebergement"),"col_12");
441     $form->setBloc('tab_tax_su_heber','F');
442    
443     $form->setBloc('tab_tax_su_secon','D',_("Locaux a usage d'habitation secondaire"),"col_12");
444     $form->setBloc('tab_tax_su_secon','F');
445    
446     $form->setBloc('tab_tax_su_tot','D',_("Total de logement"),"col_12");
447     $form->setBloc('tab_tax_su_tot','F');
448    
449     $form->setBloc('tax_ext_pret','D',"","col_12");
450     $form->setBloc('tax_log_exist_nb','F');
451    
452     $form->setBloc('tax_comm_nb','D',_("Creation ou extension de locaux non destines a l'habitation"),"col_12");
453     $form->setBloc('tab_tax_su_non_habit_surf','F');
454    
455     $form->setBloc('tab_tax_am','D',_("Autres elements soumis a la taxe d'amenagement"),"col_12");
456     $form->setBloc('tab_tax_am','F');
457    
458     $form->setBloc('tax_trx_presc_ppr','D',_("Cas particuliers"),"col_12");
459     $form->setBloc('tax_monu_hist','F');
460    
461     $form->setFieldset('tax_monu_hist','F','');
462    
463     $form->setBloc('tax_monu_hist','F');
464    
465     $form->setBloc('vsd_surf_planch_smd','D',"","col_12");
466     $form->setFieldset('vsd_surf_planch_smd','D'
467     ,_("Autres renseignements"));
468    
469     $form->setBloc('vsd_surf_planch_smd','D',_("Versement pour sous-densite (VSD)"),"col_12");
470     $form->setBloc('vsd_rescr_fisc','F');
471    
472     $form->setBloc('pld_val_terr','D',_("Plafond legal de densite (PLD)"),"col_12");
473     $form->setBloc('pld_const_exist_dem_surf','F');
474    
475     $form->setFieldset('pld_const_exist_dem_surf','F','');
476    
477     $form->setBloc('pld_const_exist_dem_surf','F');
478    
479     $form->setBloc('pld_const_exist_dem_surf','F');
480 nhaye 1264 }
481 nhaye 1268
482    
483 vpihour 1266
484     /**
485     * Surcharge du bouton retour afin de retourner sur le dossier d'instruction selon de cas
486     */
487     function retoursousformulaire($idxformulaire, $retourformulaire, $val,
488     $objsf, $premiersf, $tricolsf, $validation,
489     $idx, $maj, $retour) {
490    
491 vpihour 1301 $visualisation = $this->getParameter('visualisation');
492    
493     if ( $visualisation == "" ){
494 vpihour 1266
495 vpihour 1301 // Ajout et consultation, retour dossier
496     if ( ( $maj == 0 && $validation == 0 ) ||
497     ( $maj == 3 && $validation == 0 ) ||
498     ( $maj == 0 && $validation == 1 ) && $retourformulaire == "dossier_instruction" ){
499    
500     echo "\n<a class=\"retour\" ";
501     echo "href=\"#\" ";
502     echo "onclick=\"redirectPortletAction(1,'main');\" ";
503     echo ">";
504     echo _("Retour");
505     echo "</a>\n";
506     }
507     //Sinon affiche un retour normal
508     else{
509    
510     parent::retoursousformulaire($idxformulaire, $retourformulaire, $val,
511     $objsf, $premiersf, $tricolsf, $validation,
512     $idx, $maj, $retour);
513     }
514 vpihour 1266 }
515     }
516 vpihour 1249 }// fin classe
517 nhaye 1268 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26