1 |
<?php |
2 |
/** |
3 |
* DBFORM - 'demandeur' - Surcharge gen. |
4 |
* |
5 |
* Ce script définit la classe 'demandeur'. |
6 |
* |
7 |
* @package openads |
8 |
* @version SVN : $Id: demandeur.class.php 5056 2015-08-19 10:25:20Z nhaye $ |
9 |
*/ |
10 |
|
11 |
require_once ("../gen/obj/demandeur.class.php"); |
12 |
|
13 |
class demandeur extends demandeur_gen { |
14 |
|
15 |
var $required_tag = array("particulier_nom", |
16 |
"personne_morale_denomination", |
17 |
"personne_morale_raison_sociale" |
18 |
); |
19 |
|
20 |
function init_class_actions() { |
21 |
parent::init_class_actions(); |
22 |
|
23 |
// |
24 |
// |
25 |
$this->class_actions[998] = array( |
26 |
"identifier" => "json_data", |
27 |
"view" => "view_json_data", |
28 |
"permission_suffix" => "consulter", |
29 |
); |
30 |
} |
31 |
|
32 |
/** |
33 |
* Clause select pour la requête de sélection des données de l'enregistrement. |
34 |
* |
35 |
* @return array |
36 |
*/ |
37 |
function get_var_sql_forminc__champs() { |
38 |
return array( |
39 |
'demandeur', |
40 |
'type_demandeur', |
41 |
'qualite', |
42 |
'om_collectivite', |
43 |
'particulier_civilite', 'particulier_nom', 'particulier_prenom', |
44 |
'particulier_date_naissance', 'particulier_commune_naissance', |
45 |
'particulier_departement_naissance', 'particulier_pays_naissance', |
46 |
'personne_morale_denomination', |
47 |
'personne_morale_raison_sociale', 'personne_morale_siret', |
48 |
'personne_morale_categorie_juridique', |
49 |
'personne_morale_civilite', 'personne_morale_nom', 'personne_morale_prenom', |
50 |
'numero', |
51 |
'voie', |
52 |
'complement', |
53 |
'lieu_dit', |
54 |
'localite', |
55 |
'code_postal', |
56 |
'bp', |
57 |
'cedex', |
58 |
'pays', |
59 |
'division_territoriale', |
60 |
'telephone_fixe', |
61 |
'telephone_mobile', |
62 |
'indicatif', |
63 |
'fax', |
64 |
'courriel', |
65 |
'notification', |
66 |
'frequent', |
67 |
'num_inscription', |
68 |
'nom_cabinet', |
69 |
'conseil_regional', |
70 |
); |
71 |
} |
72 |
|
73 |
/** |
74 |
* Mise en page. |
75 |
* |
76 |
* @param formulaire $form Instance de la classe om_formulaire. |
77 |
* @param integer $maj Identifiant de l'action. |
78 |
*/ |
79 |
function setLayout(&$form, $maj){ |
80 |
// Affichage multi |
81 |
$col_coll = 'nolabel col_12'; |
82 |
if ($_SESSION["niveau"] == 2) { |
83 |
$col_coll = 'nolabel col_6'; |
84 |
} |
85 |
|
86 |
// Gestion recherche pétitionnaire fréquent |
87 |
$search_fields = ''; |
88 |
if ($maj == 0 || $maj == 1) { |
89 |
if ($form->val['type_demandeur'] === 'petitionnaire' || |
90 |
$form->val['type_demandeur'] === 'avocat' || |
91 |
$form->val['type_demandeur'] === 'bailleur') { |
92 |
$search_fields = ' search_fields'; |
93 |
} |
94 |
} |
95 |
|
96 |
// Qualité |
97 |
$form->setBloc( |
98 |
'qualite', |
99 |
'D', |
100 |
'', |
101 |
$col_coll |
102 |
); |
103 |
|
104 |
$form->setFieldset( |
105 |
'qualite', |
106 |
'D', |
107 |
_("Qualité") |
108 |
); |
109 |
$form->setFieldset( |
110 |
'qualite', |
111 |
'F' |
112 |
); |
113 |
|
114 |
$form->setBloc('qualite', 'F'); |
115 |
|
116 |
// Collectivité |
117 |
$form->setBloc( |
118 |
'om_collectivite', |
119 |
'D', |
120 |
'', |
121 |
$col_coll.$search_fields |
122 |
); |
123 |
// Renomme "collectivité" en "service" si l'option est activée |
124 |
$om_collectivite_libelle = __("Collectivité"); |
125 |
if ($this->f->is_option_renommer_collectivite_enabled() === true) { |
126 |
$om_collectivite_libelle = __("service"); |
127 |
} |
128 |
$form->setFieldset( |
129 |
'om_collectivite', |
130 |
'DF', |
131 |
$om_collectivite_libelle |
132 |
); |
133 |
|
134 |
$form->setBloc('om_collectivite', 'F'); |
135 |
|
136 |
// Etat civil |
137 |
$form->setBloc( |
138 |
'particulier_civilite', |
139 |
'D', |
140 |
"", |
141 |
"particulier_fields" |
142 |
); |
143 |
|
144 |
$form->setFieldset( |
145 |
'particulier_civilite', |
146 |
'D', |
147 |
_("Etat civil"), |
148 |
"group" |
149 |
); |
150 |
$form->setBloc( |
151 |
'particulier_nom', |
152 |
'D', |
153 |
"", |
154 |
"group".$search_fields |
155 |
); |
156 |
$form->setBloc('particulier_prenom', 'F'); |
157 |
$form->setBloc( |
158 |
'particulier_date_naissance', |
159 |
'D', |
160 |
"", |
161 |
"group" |
162 |
); |
163 |
$form->setBloc('particulier_commune_naissance', 'F'); |
164 |
$form->setFieldset( |
165 |
'particulier_pays_naissance', |
166 |
'F' |
167 |
); |
168 |
|
169 |
$form->setBloc('particulier_pays_naissance', 'F'); |
170 |
|
171 |
$form->setBloc( |
172 |
'personne_morale_denomination', |
173 |
'D', |
174 |
"", |
175 |
"personne_morale_fields" |
176 |
); |
177 |
|
178 |
$form->setFieldset( |
179 |
'personne_morale_denomination', |
180 |
'D', |
181 |
_("Personne morale"), |
182 |
$search_fields |
183 |
); |
184 |
|
185 |
$form->setBloc( |
186 |
'personne_morale_denomination', |
187 |
'D', |
188 |
"", |
189 |
"group" |
190 |
); |
191 |
$form->setBloc('personne_morale_raison_sociale', 'F'); |
192 |
|
193 |
$form->setBloc( |
194 |
'personne_morale_siret', |
195 |
'D', |
196 |
"", |
197 |
"group" |
198 |
); |
199 |
$form->setBloc( |
200 |
'personne_morale_categorie_juridique', |
201 |
'F' |
202 |
); |
203 |
|
204 |
$form->setBloc('personne_morale_civilite', 'D', ""); |
205 |
$form->setBloc('personne_morale_civilite', 'F'); |
206 |
|
207 |
$form->setBloc('personne_morale_nom', 'D', "", "group"); |
208 |
$form->setBloc('personne_morale_prenom', 'F'); |
209 |
|
210 |
$form->setFieldset('personne_morale_prenom', 'F'); |
211 |
|
212 |
$form->setBloc('personne_morale_prenom', 'F'); |
213 |
|
214 |
// Adresse |
215 |
$form->setFieldset('numero', 'D', _("Adresse"), ""); |
216 |
|
217 |
$form->setBloc('numero', 'D', "", "group"); |
218 |
$form->setBloc('voie', 'F'); |
219 |
|
220 |
$form->setBloc('complement', 'D', ""); |
221 |
$form->setBloc('complement', 'F'); |
222 |
|
223 |
$form->setBloc('lieu_dit', 'D', "", "group"); |
224 |
$form->setBloc('localite', 'F'); |
225 |
|
226 |
$form->setBloc('code_postal', 'D', "", "group"); |
227 |
$form->setBloc('cedex', 'F'); |
228 |
|
229 |
$form->setBloc('pays', 'D', "", "", "group"); |
230 |
$form->setBloc('division_territoriale', 'F'); |
231 |
$form->setFieldset('division_territoriale', 'F'); |
232 |
|
233 |
// Coordonnées |
234 |
$form->setFieldset('telephone_fixe', 'D', _("Coordonnees"), ""); |
235 |
$form->setBloc('telephone_fixe', 'D', "", "group"); |
236 |
$form->setBloc('indicatif', 'F'); |
237 |
|
238 |
$form->setBloc('courriel', 'D', "", "group"); |
239 |
$form->setBloc('notification', 'F'); |
240 |
|
241 |
$form->setFieldset('notification', 'F'); |
242 |
|
243 |
// Architecte |
244 |
$form->setFieldset('num_inscription', 'D', __("Architecte législation connexe"), ""); |
245 |
$form->setBloc('num_inscription', 'D', "", "group"); |
246 |
$form->setBloc('num_inscription', 'F'); |
247 |
$form->setBloc('nom_cabinet', 'D', "", "group"); |
248 |
$form->setBloc('nom_cabinet', 'F'); |
249 |
$form->setBloc('conseil_regional', 'D', "", "group"); |
250 |
$form->setBloc('conseil_regional', 'F'); |
251 |
$form->setFieldset('conseil_regional', 'F'); |
252 |
} |
253 |
|
254 |
/** |
255 |
* SETTER_FORM - setVal (setVal). |
256 |
* |
257 |
* @return void |
258 |
*/ |
259 |
function setVal(&$form, $maj, $validation, &$dnu1 = null, $dnu2 = null) { |
260 |
parent::setVal($form, $maj, $validation); |
261 |
// |
262 |
if ($maj == 0) { |
263 |
$form->setVal("pays", "France"); |
264 |
} |
265 |
} |
266 |
|
267 |
/** |
268 |
* Lbellé des champs |
269 |
*/ |
270 |
function setLib(&$form,$maj) { |
271 |
parent::setLib($form,$maj); |
272 |
$form->setLib('qualite', ''); |
273 |
$form->setLib('om_collectivite', ''); |
274 |
} |
275 |
|
276 |
/** |
277 |
* SETTER_FORM - setValsousformulaire (setVal). |
278 |
* |
279 |
* @return void |
280 |
*/ |
281 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
282 |
parent::setValsousformulaire($form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire); |
283 |
// |
284 |
if ($maj == 0) { |
285 |
$form->setVal("pays", "France"); |
286 |
} |
287 |
// XXX L'objectif de cette portion de code n'est pas de faire un setVal |
288 |
// Message d'information concernant la modification des demandeurs |
289 |
// fréquents |
290 |
if ($maj == 1 && $this->getVal("frequent") == "t") { |
291 |
switch ($this->getVal("type_demandeur")) { |
292 |
case "petitionnaire": |
293 |
$type_demandeur = _("Pétitionnaire"); |
294 |
break; |
295 |
|
296 |
case "avocat": |
297 |
$type_demandeur = _("Avocat"); |
298 |
break; |
299 |
|
300 |
case "bailleur": |
301 |
$type_demandeur = _("Bailleur"); |
302 |
break; |
303 |
} |
304 |
$message = sprintf(_("%s fréquent non modifiable"), $type_demandeur); |
305 |
$this->f->displayMessage("info", $message); |
306 |
} |
307 |
} |
308 |
|
309 |
/** |
310 |
* @return void |
311 |
*/ |
312 |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
313 |
parent::verifier($val); |
314 |
// le nom du particulier est obligatoire |
315 |
if($this->valF['qualite'] == "particulier" AND $this->valF['particulier_nom'] == "") { |
316 |
$this->correct = false; |
317 |
$this->addToMessage(_("Le champ")." <span class=\"bold\">". |
318 |
_("particulier_nom")."</span> "._("est obligatoire.")); |
319 |
} |
320 |
|
321 |
// la dénomination ou la raison sociale est obligatoire pour une personne morale |
322 |
if($this->valF['qualite'] == "personne_morale" |
323 |
AND $this->valF['personne_morale_denomination'] == "" |
324 |
AND $this->valF['personne_morale_raison_sociale'] == "") { |
325 |
$this->correct = false; |
326 |
$this->addToMessage(_("Un des champs")." <span class=\"bold\">". |
327 |
_("personne_morale_denomination")."</span> ou <span class=\"bold\">". |
328 |
_("personne_morale_raison_sociale")."</span> "._("doit etre rempli.")); |
329 |
} |
330 |
|
331 |
} |
332 |
|
333 |
/* |
334 |
* Select pour les champs qualite et type_demandeur |
335 |
*/ |
336 |
function setType(&$form,$maj) { |
337 |
parent::setType($form,$maj); |
338 |
|
339 |
$form->setType('num_inscription', 'hidden'); |
340 |
$form->setType('nom_cabinet', 'hidden'); |
341 |
$form->setType('conseil_regional', 'hidden'); |
342 |
|
343 |
if ($maj < 2) { //ajouter et modifier |
344 |
|
345 |
$form->setType('type_demandeur', 'select'); |
346 |
$form->setType('qualite', 'select'); |
347 |
if ($this->f->is_option_mode_service_consulte_enabled() === false) { |
348 |
if ($maj == 1){ |
349 |
if ($this->get_dossier_from_link() !== false && $this->get_dossier_from_link() !== null) { |
350 |
$id_dossier = null; |
351 |
if (empty($this->get_dossier_from_link())) { |
352 |
if ($this->f->get_submitted_get_value('idx_dossier') != null) { |
353 |
$id_dossier = $this->f->get_submitted_get_value('idx_dossier'); |
354 |
} |
355 |
} else { |
356 |
$id_dossier=$this->get_dossier_from_link()[0]['dossier']; |
357 |
} |
358 |
|
359 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
360 |
"obj" => "dossier", |
361 |
"idx" => $id_dossier, |
362 |
)); |
363 |
if ($this->f->is_type_dossier_platau($inst_dossier->getVal('dossier_autorisation')) === true |
364 |
&& $inst_dossier->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
365 |
// |
366 |
$required_fields_platau = $inst_dossier->list_platau_required_fields_dossier; |
367 |
foreach ($required_fields_platau as $required_field_platau) { |
368 |
$champ = explode('.', $required_field_platau)[1]; |
369 |
if (in_array($champ, $this->champs)) { |
370 |
$form->setType($champ ,$form->type[$champ].'_demat_color'); |
371 |
} |
372 |
} |
373 |
} |
374 |
} |
375 |
} |
376 |
if ($maj == 0) { |
377 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
378 |
"obj" => "dossier", |
379 |
"idx" => $this->f->get_submitted_get_value('idx_dossier'), |
380 |
)); |
381 |
if ($this->f->is_type_dossier_platau($inst_dossier->getVal('dossier_autorisation')) === true |
382 |
&& $inst_dossier->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
383 |
// |
384 |
$required_fields_platau = $inst_dossier->list_platau_required_fields_dossier; |
385 |
foreach ($required_fields_platau as $required_field_platau) { |
386 |
$champ = explode('.', $required_field_platau)[1]; |
387 |
if (in_array($champ, $this->champs)) { |
388 |
$form->setType($champ ,$form->type[$champ].'_demat_color'); |
389 |
} |
390 |
} |
391 |
} |
392 |
} |
393 |
} |
394 |
if($maj == 0 AND $this->getParameter("idx_demandeur") != "") { |
395 |
$form->setType('frequent','hidden'); |
396 |
$form->setType('qualite','selectdisabled'); |
397 |
$form->setType('particulier_nom','textdisabled'); |
398 |
$form->setType('particulier_prenom','textdisabled'); |
399 |
$form->setType('particulier_date_naissance','datedisabled'); |
400 |
$form->setType('particulier_commune_naissance','textdisabled'); |
401 |
$form->setType('particulier_departement_naissance','textdisabled'); |
402 |
$form->setType('particulier_pays_naissance','textdisabled'); |
403 |
$form->setType('personne_morale_denomination','textdisabled'); |
404 |
$form->setType('personne_morale_raison_sociale','textdisabled'); |
405 |
$form->setType('personne_morale_siret','textdisabled'); |
406 |
$form->setType('personne_morale_categorie_juridique','textdisabled'); |
407 |
$form->setType('personne_morale_nom','textdisabled'); |
408 |
$form->setType('personne_morale_prenom','textdisabled'); |
409 |
$form->setType('particulier_civilite','selectdisabled'); |
410 |
$form->setType('personne_morale_civilite','selectdisabled'); |
411 |
$form->setType('telephone_fixe','textdisabled'); |
412 |
$form->setType('telephone_mobile','textdisabled'); |
413 |
$form->setType('fax','textdisabled'); |
414 |
$form->setType('indicatif','textdisabled'); |
415 |
$form->setType('courriel','textdisabled'); |
416 |
|
417 |
} |
418 |
} |
419 |
|
420 |
$form->setType('demandeur', 'hidden'); |
421 |
|
422 |
} |
423 |
|
424 |
/** |
425 |
* SETTER_FORM - setSelect. |
426 |
* |
427 |
* @return void |
428 |
*/ |
429 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
430 |
parent::setSelect($form, $maj); |
431 |
|
432 |
// Type du demandeur |
433 |
$contenu=array(); |
434 |
|
435 |
$contenu[0][0]=""; |
436 |
$contenu[1][0]=_('choisir')." "._('type_demandeur'); |
437 |
$contenu[0][2]="petitionnaire"; |
438 |
$contenu[1][2]=_('petitionnaire'); |
439 |
$contenu[0][1]="delegataire"; |
440 |
$contenu[1][1]=_('autre correspondant'); |
441 |
$contenu[0][3]="plaignant"; |
442 |
$contenu[1][3]=_('Plaignant'); |
443 |
$contenu[0][4]="contrevenant"; |
444 |
$contenu[1][4]=_('Contrevenant'); |
445 |
$contenu[0][5]="requerant"; |
446 |
$contenu[1][5]=_('Requérant'); |
447 |
$contenu[0][6]="avocat"; |
448 |
$contenu[1][6]=_('Avocat'); |
449 |
$contenu[0][7]="bailleur"; |
450 |
$contenu[1][7]=_('Bailleur'); |
451 |
$contenu[0][8] = "proprietaire"; |
452 |
$contenu[1][8] = __('Propriétaire'); |
453 |
$contenu[0][9] = "architecte_lc"; |
454 |
$contenu[1][9] = __('Architecte législation connexe'); |
455 |
$contenu[0][10] = "paysagiste"; |
456 |
$contenu[1][10] = __('Concepteur-Paysagiste'); |
457 |
|
458 |
$form->setSelect("type_demandeur", $contenu); |
459 |
|
460 |
// Qualité du demandeur |
461 |
$contenu=array(); |
462 |
|
463 |
$contenu[0][0]="particulier"; |
464 |
$contenu[1][0]=_('particulier'); |
465 |
$contenu[0][1]="personne_morale"; |
466 |
$contenu[1][1]=_('personne morale'); |
467 |
|
468 |
$form->setSelect("qualite", $contenu); |
469 |
} |
470 |
|
471 |
/* |
472 |
* Ajoute l'action javascript sur le select de la qualité |
473 |
*/ |
474 |
function setOnchange(&$form,$maj){ |
475 |
parent::setOnchange($form,$maj); |
476 |
|
477 |
$form->setOnchange("qualite","changeDemandeurType('qualite');"); |
478 |
} |
479 |
|
480 |
/** |
481 |
* Ajout d'un champs caché permettant de linker l'id du demandeur |
482 |
* recement ajouté |
483 |
**/ |
484 |
function sousFormSpecificContent($maj) { |
485 |
$id_demandeur = $this->getVal("demandeur"); |
486 |
if(isset($this->valF["demandeur"]) AND !empty($this->valF["demandeur"])) { |
487 |
echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"". |
488 |
$this->valF["demandeur"]."\" />"; |
489 |
} elseif (isset($id_demandeur) AND !empty($id_demandeur) AND $maj == 110) { |
490 |
echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"". |
491 |
$this->getVal("demandeur")."\" />"; |
492 |
} |
493 |
} |
494 |
/** |
495 |
* Surcharge du lien de retour permettant de linker l'id du demandeur |
496 |
* recement ajouté |
497 |
**/ |
498 |
function retoursousformulaire($idxformulaire = NULL, $retourformulaire = NULL, $val = NULL, |
499 |
$objsf = NULL, $premiersf = NULL, $tricolsf = NULL, $validation = NULL, |
500 |
$idx = NULL, $maj = NULL, $retour = NULL) { |
501 |
if($retourformulaire === "demande") { |
502 |
echo "\n<a class=\"retour\" "; |
503 |
echo "href=\"#\">"; |
504 |
// |
505 |
echo _("Retour"); |
506 |
// |
507 |
echo "</a>\n"; |
508 |
} else { |
509 |
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
510 |
$objsf, $premiersf, $tricolsf, $validation, |
511 |
$idx, $maj, $retour); |
512 |
} |
513 |
} |
514 |
|
515 |
/** |
516 |
* Ajout du paramètre principal |
517 |
*/ |
518 |
function getDataSubmitSousForm() { |
519 |
/*Création du lien de validation du sous-formulaire*/ |
520 |
$datasubmit = ""; |
521 |
$datasubmit .= OM_ROUTE_SOUSFORM; |
522 |
$datasubmit .= "&obj=".$this->get_absolute_class_name(); |
523 |
$datasubmit .= "&validation=".$this->getParameter("validation"); |
524 |
if ($this->getParameter("idx") != "]") { |
525 |
// |
526 |
if ($this->getParameter("maj") == 1) { // modifier |
527 |
$datasubmit .= "&action=1"; |
528 |
$datasubmit .= "&idx=".$this->getParameter("idx"); |
529 |
} else { // supprimer |
530 |
$datasubmit .= "&action=2"; |
531 |
$datasubmit .= "&idx=".$this->getParameter("idx"); |
532 |
} |
533 |
} |
534 |
$datasubmit .= "&premiersf=".$this->getParameter("premiersf"); |
535 |
$datasubmit .= "&retourformulaire=".$this->getParameter("retourformulaire"); |
536 |
$datasubmit .= "&trisf=".$this->getParameter("tricolsf"); |
537 |
$datasubmit .= "&idxformulaire=".$this->getParameter("idxformulaire"); |
538 |
$datasubmit .= "&principal=".$this->getParameter("principal"); |
539 |
// |
540 |
return $datasubmit; |
541 |
} |
542 |
|
543 |
/** |
544 |
* Synthèse des demandeurs pour le formulaire de la demande. |
545 |
* |
546 |
* @param string $type Type de demandeur. |
547 |
* @param boolean $linkable Affiche le lien d'édition. |
548 |
*/ |
549 |
function afficherSynthese($type, $linkable) { |
550 |
// Récupération du type de demandeur pour l'affichage |
551 |
switch ($type) { |
552 |
case 'petitionnaire_principal': |
553 |
$legend = _("Petitionnaire principal"); |
554 |
break; |
555 |
|
556 |
case 'delegataire': |
557 |
$legend = _("Autre correspondant"); |
558 |
break; |
559 |
|
560 |
case 'petitionnaire': |
561 |
$legend = _("Petitionnaire"); |
562 |
break; |
563 |
|
564 |
case 'contrevenant_principal': |
565 |
$legend = _("Contrevenant principal"); |
566 |
break; |
567 |
|
568 |
case 'contrevenant': |
569 |
$legend = _("Contrevenant"); |
570 |
break; |
571 |
|
572 |
case 'plaignant_principal': |
573 |
$legend = _("Plaignant principal"); |
574 |
break; |
575 |
|
576 |
case 'plaignant': |
577 |
$legend = _("Plaignant"); |
578 |
break; |
579 |
|
580 |
case 'requerant_principal': |
581 |
$legend = _("Requérant principal"); |
582 |
break; |
583 |
|
584 |
case 'requerant': |
585 |
$legend = _("Requérant"); |
586 |
break; |
587 |
|
588 |
case 'avocat_principal': |
589 |
$legend = _("Avocat principal"); |
590 |
break; |
591 |
|
592 |
case 'avocat': |
593 |
$legend = _("Avocat"); |
594 |
break; |
595 |
|
596 |
case 'bailleur_principal': |
597 |
$legend = _("Bailleur principal"); |
598 |
break; |
599 |
|
600 |
case 'bailleur': |
601 |
$legend = _("Bailleur"); |
602 |
break; |
603 |
|
604 |
case 'proprietaire': |
605 |
$legend = __('Propriétaire'); |
606 |
break; |
607 |
|
608 |
case 'architecte_lc': |
609 |
$legend = __('Architecte législation connexe'); |
610 |
break; |
611 |
|
612 |
case 'paysagiste': |
613 |
$legend = __('Concepteur-Paysagiste'); |
614 |
break; |
615 |
} |
616 |
|
617 |
// Initialisation de tous les éléments à afficher |
618 |
foreach ($this->champs as $champs) { |
619 |
${$champs} = $this->val[array_search($champs, $this->champs)] != "" ? |
620 |
$this->val[array_search($champs, $this->champs)] : |
621 |
''; |
622 |
if ($champs == 'notification') { |
623 |
$notification = $this->val[array_search($champs, $this->champs)] == "t" ? |
624 |
'(Accepte les couriels)' : |
625 |
''; |
626 |
} |
627 |
} |
628 |
|
629 |
// Templates utilisés pour réaliser l'affichage |
630 |
$templateConteneurDemandeur = |
631 |
'<div class="%1$s col_6" id="%1$s_%2$s"> |
632 |
<div class="legend_synthese_demandeur"> |
633 |
%3$s |
634 |
</div> |
635 |
<div class="synthese_demandeur">'; |
636 |
|
637 |
$templateLienDemandeur = |
638 |
'<a href="#" onclick="removeDemandeur(\'%1$s_%2$s\'); return false;"> |
639 |
<span class="demandeur_del om-icon om-icon-16 om-icon-fix delete-16" title="%3$s"> |
640 |
%3$s |
641 |
</span> |
642 |
</a>'; |
643 |
|
644 |
$templateLienModifDemandeur = |
645 |
'<a class="edit_demandeur" href="#" onclick="editDemandeur(\'%1$s\',%2$s,\'%3$s\',%3$s_%2$s); return false;">'; |
646 |
|
647 |
$sql_civilite = |
648 |
'SELECT |
649 |
libelle |
650 |
FROM |
651 |
%1$scivilite |
652 |
WHERE |
653 |
civilite=%2$s |
654 |
'; |
655 |
|
656 |
// Conteneur du demandeur |
657 |
printf( |
658 |
$templateConteneurDemandeur, |
659 |
$type, |
660 |
$demandeur, |
661 |
$legend |
662 |
); |
663 |
// Si le paramètre linkable est défini à true on ajoute les balises |
664 |
// de lien |
665 |
if ($linkable === true) { |
666 |
printf( |
667 |
$templateLienDemandeur, |
668 |
$type, |
669 |
$demandeur, |
670 |
_("Supprimer le demandeur") |
671 |
); |
672 |
} |
673 |
$input_name = $type.'[]'; |
674 |
|
675 |
// Valeur de formulaire à retourner |
676 |
printf( |
677 |
"<input type=\"hidden\" class=\"demandeur_id\" name=\"%s\" value=\"%s\" />\n", |
678 |
$input_name, |
679 |
$this->val[array_search('demandeur', $this->champs)] |
680 |
); |
681 |
|
682 |
// Lien de modification du demandeur |
683 |
if ($linkable === true) { |
684 |
printf( |
685 |
$templateLienModifDemandeur, |
686 |
$type_demandeur, |
687 |
$demandeur, |
688 |
$type |
689 |
); |
690 |
} |
691 |
|
692 |
// Préparation des infos du demandeur qui seront affichées en les stockant dans un tableau |
693 |
// Chaque élement du tableau correspond a une ligne dans l'affichage |
694 |
$infosAffichage = array(); |
695 |
if ($qualite == 'particulier') { |
696 |
$infosAffichage['particulier'] = $particulier_nom." ".$particulier_prenom; |
697 |
// S'il existe une civilité elle est ajoutée devant le nom du particulier |
698 |
if ( ! empty($particulier_civilite)) { |
699 |
$sql = sprintf($sql_civilite, DB_PREFIXE, $particulier_civilite); |
700 |
$civilite = $this->f->db->getone($sql); |
701 |
$this->f->addToLog("afficherSynthese() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
702 |
if ( database::isError($civilite)) { |
703 |
die(); |
704 |
} |
705 |
$infosAffichage['particulier'] = $civilite." ".$particulier_nom." ".$particulier_prenom; |
706 |
} |
707 |
} else { |
708 |
$infosAffichage['personne_morale'] = $personne_morale_raison_sociale." ".$personne_morale_denomination; |
709 |
$infosAffichage['personne_morale_jur'] = $personne_morale_siret." ".$personne_morale_categorie_juridique; |
710 |
$infosAffichage['personne_morale_nom'] = $personne_morale_nom." ".$personne_morale_prenom; |
711 |
// S'il existe une civilité elle est ajoutée devant le nom de la personne morale |
712 |
if (! empty($personne_morale_civilite)) { |
713 |
$sql = sprintf($sql_civilite, DB_PREFIXE, $personne_morale_civilite); |
714 |
$civilite = $this->f->db->getone($sql); |
715 |
$this->f->addToLog("afficherSynthese() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
716 |
if ( database::isError($civilite)) { |
717 |
die(); |
718 |
} |
719 |
$infosAffichage['personne_morale_nom'] = $civilite." ".$personne_morale_nom." ".$personne_morale_prenom; |
720 |
} |
721 |
} |
722 |
$infosAffichage['adresse_1'] = $numero." ".$voie." ".$complement; |
723 |
$infosAffichage['adresse_2'] = $lieu_dit; |
724 |
$infosAffichage['adresse_3'] = $code_postal." ".$localite." ".$bp." ".$cedex; |
725 |
$infosAffichage['adresse_4'] = $division_territoriale." ".$pays; |
726 |
$infosAffichage['telephones'] = $telephone_fixe." ".$telephone_mobile; |
727 |
$infosAffichage['courriel'] = $courriel." ".$notification; |
728 |
|
729 |
// Affichage de la date et du lieu de naissance sous la forme : |
730 |
// - s'il existe une date et un lieu de naissance : né le XX/XX/XX à XXXX |
731 |
// - s'il existe une date de naissance : né le XX/XX/XX |
732 |
// - s'il existe juste un lieu de naissance : né à XXXX |
733 |
// Converti la date du format YYYY-MM-DD au format DD/MM/YYYY |
734 |
$particulier_date_naissance = $this->dateDBToForm($particulier_date_naissance); |
735 |
if ($qualite == 'particulier') { |
736 |
$lieuNaissance = trim($particulier_commune_naissance.' '.$particulier_departement_naissance.' '.$particulier_pays_naissance); |
737 |
if ($particulier_date_naissance != '' && $lieuNaissance != '') { |
738 |
$infosAffichage['naissance'] = sprintf( |
739 |
'Né le %s à %s', |
740 |
$particulier_date_naissance, |
741 |
$lieuNaissance |
742 |
); |
743 |
} elseif ($particulier_date_naissance != '') { |
744 |
$infosAffichage['naissance'] = sprintf( |
745 |
'Né le %s', |
746 |
$particulier_date_naissance |
747 |
); |
748 |
} elseif ($lieuNaissance != '') { |
749 |
$infosAffichage['naissance'] = sprintf( |
750 |
'Né à %s', |
751 |
$lieuNaissance |
752 |
); |
753 |
} |
754 |
} |
755 |
|
756 |
// Permet de n'avoir de retour à la ligne que si des informations ont été affichées |
757 |
foreach ($infosAffichage as $info) { |
758 |
$info = trim($info); |
759 |
if ($info != '') { |
760 |
printf( |
761 |
'%s<br/>', |
762 |
$info |
763 |
); |
764 |
} |
765 |
} |
766 |
|
767 |
if ($linkable === true) { |
768 |
echo "</a>\n"; |
769 |
} |
770 |
echo "</div>\n"; |
771 |
echo "</div>\n"; |
772 |
} |
773 |
|
774 |
/** |
775 |
* |
776 |
*/ |
777 |
function get_inst_civilite($civilite) { |
778 |
return $this->get_inst_common("civilite", $civilite); |
779 |
} |
780 |
|
781 |
/** |
782 |
* Retourne un tableau avec les données principales du demandeur. |
783 |
* |
784 |
* L'objectif est de mettre à disposition via un WS Reste un ensemble |
785 |
* de données exploitable par une autre application. |
786 |
*/ |
787 |
function get_datas() { |
788 |
|
789 |
/** |
790 |
* |
791 |
*/ |
792 |
$particulier_civilite = ""; |
793 |
$personne_morale_civilite = ""; |
794 |
if ($this->getVal('qualite') == 'particulier' |
795 |
&& $this->getVal('particulier_civilite') !== '') { |
796 |
// |
797 |
$inst_civilite = $this->get_inst_civilite($this->getVal('particulier_civilite')); |
798 |
$particulier_civilite = $inst_civilite->getVal("libelle"); |
799 |
} elseif ($this->getVal('qualite') == 'personne_morale' |
800 |
&& $this->getVal('personne_morale_civilite') !== '') { |
801 |
// |
802 |
$inst_civilite = $this->get_inst_civilite($this->getVal('personne_morale_civilite')); |
803 |
$personne_morale_civilite = $inst_civilite->getVal("libelle"); |
804 |
} |
805 |
|
806 |
/** |
807 |
* |
808 |
*/ |
809 |
// |
810 |
$datas = array( |
811 |
"demandeur" => $this->getVal($this->clePrimaire), |
812 |
"qualite" => $this->getVal("qualite"), |
813 |
); |
814 |
|
815 |
if ($this->getVal('qualite') == 'particulier') { |
816 |
$datas["particulier_civilite"] = $particulier_civilite; |
817 |
$datas["particulier_nom"] = $this->getVal("particulier_nom"); |
818 |
$datas["particulier_prenom"] = $this->getVal("particulier_prenom"); |
819 |
$datas["particulier_date_naissance"] = $this->getVal("particulier_date_naissance"); |
820 |
$datas["particulier_commune_naissance"] = $this->getVal("particulier_commune_naissance"); |
821 |
$datas["particulier_departement_naissance"] = $this->getVal("particulier_departement_naissance"); |
822 |
$datas["particulier_pays_naissance"] = $this->getVal("particulier_pays_naissance"); |
823 |
} |
824 |
if ($this->getVal('qualite') == 'personne_morale') { |
825 |
$datas["personne_morale_civilite"] = $personne_morale_civilite; |
826 |
$datas["personne_morale_denomination"] = $this->getVal("personne_morale_denomination"); |
827 |
$datas["personne_morale_raison_sociale"] = $this->getVal("personne_morale_raison_sociale"); |
828 |
$datas["personne_morale_siret"] = $this->getVal("personne_morale_siret"); |
829 |
$datas["personne_morale_categorie_juridique"] = $this->getVal("personne_morale_categorie_juridique"); |
830 |
$datas["personne_morale_nom"] = $this->getVal("personne_morale_nom"); |
831 |
$datas["personne_morale_prenom"] = $this->getVal("personne_morale_prenom"); |
832 |
} |
833 |
// |
834 |
$datas["numero"] = $this->getVal("numero"); |
835 |
$datas["voie"] = $this->getVal("voie"); |
836 |
$datas["complement"] = $this->getVal("complement"); |
837 |
$datas["lieu_dit"] = $this->getVal("lieu_dit"); |
838 |
$datas["localite"] = $this->getVal("localite"); |
839 |
$datas["code_postal"] = $this->getVal("code_postal"); |
840 |
$datas["bp"] = $this->getVal("bp"); |
841 |
$datas["cedex"] = $this->getVal("cedex"); |
842 |
$datas["pays"] = $this->getVal("pays"); |
843 |
$datas["division_territoriale"] = $this->getVal("division_territoriale"); |
844 |
$datas["telephone_fixe"] = $this->getVal("telephone_fixe"); |
845 |
$datas["telephone_mobile"] = $this->getVal("telephone_mobile"); |
846 |
$datas["indicatif"] = $this->getVal("indicatif"); |
847 |
$datas["courriel"] = $this->getVal("courriel"); |
848 |
$datas["fax"] = $this->getVal("fax"); |
849 |
|
850 |
/** |
851 |
* |
852 |
*/ |
853 |
return $datas; |
854 |
} |
855 |
|
856 |
|
857 |
/** |
858 |
* Indique si la redirection vers le lien de retour est activée ou non. |
859 |
* |
860 |
* L'objectif de cette méthode est de permettre d'activer ou de désactiver |
861 |
* la redirection dans certains contextes. |
862 |
* |
863 |
* @return boolean |
864 |
*/ |
865 |
function is_back_link_redirect_activated() { |
866 |
// |
867 |
if ($this->getParameter("retourformulaire") === 'demande') { |
868 |
// |
869 |
return false; |
870 |
} |
871 |
|
872 |
// |
873 |
return true; |
874 |
} |
875 |
|
876 |
public function get_dossier_from_link() { |
877 |
$query = sprintf(' |
878 |
SELECT lien_dossier_demandeur.dossier |
879 |
FROM %1$slien_dossier_demandeur |
880 |
WHERE lien_dossier_demandeur.demandeur = \'%2$s\' |
881 |
', |
882 |
DB_PREFIXE, |
883 |
$this->getVal($this->clePrimaire) |
884 |
); |
885 |
$res = $this->f->get_all_results_from_db_query($query, true); |
886 |
if ($res['code'] === 'KO') { |
887 |
return false; |
888 |
} |
889 |
return $res['result']; |
890 |
} |
891 |
|
892 |
public function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
893 |
parent::triggermodifierapres($id, $dnu1, $val, $dnu2); |
894 |
if (count(array_diff_assoc($this->valF, array_combine($this->champs, $this->val))) > 0) { |
895 |
/** |
896 |
* Gestion des tâches pour la dématérialisation |
897 |
*/ |
898 |
$dossiers = $this->get_dossier_from_link(); |
899 |
foreach ($dossiers as $dossier) { |
900 |
// |
901 |
$inst_dossier = $this->f->get_inst__om_dbform(array( |
902 |
"obj" => "dossier", |
903 |
"idx" => $dossier['dossier'], |
904 |
)); |
905 |
|
906 |
if ($this->f->is_option_mode_service_consulte_enabled() === false |
907 |
&& $this->f->is_type_dossier_platau($inst_dossier->getVal('dossier_autorisation')) === true |
908 |
&& $inst_dossier->getVal('etat_transmission_platau') !== 'jamais_transmissible') { |
909 |
// |
910 |
$trigger_platau_required_fields = $inst_dossier->trigger_platau_required_fields($dossier['dossier'], 'update'); |
911 |
} |
912 |
|
913 |
if ($this->f->is_type_dossier_platau($inst_dossier->getVal('dossier_autorisation')) |
914 |
&& $inst_dossier->getVal('etat_transmission_platau') !== 'jamais_transmissible' |
915 |
&& ($this->f->is_option_mode_service_consulte_enabled() !== true |
916 |
|| ($this->f->is_option_mode_service_consulte_enabled() === true |
917 |
&& ($inst_dossier->get_source_depot_from_demande() === 'platau' |
918 |
|| $inst_dossier->get_source_depot_from_demande() === 'portal')))) { |
919 |
// |
920 |
$inst_task = $this->f->get_inst__om_dbform(array( |
921 |
"obj" => "task", |
922 |
"idx" => 0, |
923 |
)); |
924 |
$task_val = array( |
925 |
'type' => 'modification_DI', |
926 |
'object_id' => $dossier['dossier'], |
927 |
'dossier' => $dossier['dossier'], |
928 |
); |
929 |
// Change l'état de la tâche de notification en fonction de l'état de |
930 |
// transmission du dossier d'instruction |
931 |
if ($this->f->is_option_mode_service_consulte_enabled() === false |
932 |
&& ($this->getVal('etat_transmission_platau') == 'non_transmissible' |
933 |
|| $this->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
934 |
// |
935 |
$task_val['state'] = $inst_task::STATUS_DRAFT; |
936 |
} |
937 |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
938 |
if ($add_task === false) { |
939 |
$this->addToMessage(sprintf('%s %s', |
940 |
__("Une erreur s'est produite lors de la création tâche."), |
941 |
__("Veuillez contacter votre administrateur.") |
942 |
)); |
943 |
$this->correct = false; |
944 |
return false; |
945 |
} |
946 |
// XXX Les données du DA sont mises à jour seulement lors de l'ajout ou modification |
947 |
// d'une instruction du DI initial et lors de la décision sur le DI non initial. |
948 |
// Sachant ce comportement, voir si cette tâche modification_DA est bien située. |
949 |
$inst_task = $this->f->get_inst__om_dbform(array( |
950 |
"obj" => "task", |
951 |
"idx" => 0, |
952 |
)); |
953 |
$task_val = array( |
954 |
'type' => 'modification_DA', |
955 |
'object_id' => $inst_dossier->getVal('dossier_autorisation'), |
956 |
'dossier' => $inst_dossier->getVal('dossier_autorisation'), |
957 |
); |
958 |
// Change l'état de la tâche de notification en fonction de l'état de |
959 |
// transmission du dossier d'instruction |
960 |
if ($this->f->is_option_mode_service_consulte_enabled() === false |
961 |
&& ($this->getVal('etat_transmission_platau') == 'non_transmissible' |
962 |
|| $this->getVal('etat_transmission_platau') == 'transmis_mais_non_transmissible')) { |
963 |
// |
964 |
$task_val['state'] = $inst_task::STATUS_DRAFT; |
965 |
} |
966 |
$add_task = $inst_task->add_task(array('val' => $task_val)); |
967 |
if ($add_task === false) { |
968 |
$this->addToMessage(sprintf('%s %s', |
969 |
__("Une erreur s'est produite lors de la création tâche."), |
970 |
__("Veuillez contacter votre administrateur.") |
971 |
)); |
972 |
$this->correct = false; |
973 |
return false; |
974 |
} |
975 |
} |
976 |
} |
977 |
} |
978 |
// |
979 |
return true; |
980 |
} |
981 |
|
982 |
public function view_json_data() { |
983 |
$this->checkAccessibility(); |
984 |
$this->f->disableLog(); |
985 |
$view = $this->get_json_data(); |
986 |
printf(json_encode($view)); |
987 |
} |
988 |
|
989 |
public function get_json_data() { |
990 |
$val = array_combine($this->champs, $this->val); |
991 |
foreach ($val as $key => $value) { |
992 |
$val[$key] = strip_tags($value); |
993 |
} |
994 |
return $val; |
995 |
} |
996 |
|
997 |
}// fin classe |
998 |
|