/[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 1268 - (show annotations)
Tue Feb 19 15:39:55 2013 UTC (11 years, 11 months ago) by nhaye
File size: 17270 byte(s)
Ajout des champs de calculs d'imposition present dans les cerfa,
mise en page de ces champs,
configuration des tableaux de champs
insertion des formulaires de cerfa dans les formulaires de lots

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26