1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 08/11/2012 14:00 |
4 |
|
5 |
require_once ("../gen/obj/demande.class.php"); |
6 |
|
7 |
class demande extends demande_gen { |
8 |
|
9 |
var $valIdDemandeur = array("petitionnaire_principal" => "", |
10 |
"delegataire" => "", |
11 |
"petitionnaire" => array()); |
12 |
var $postedIdDemandeur = array("petitionnaire_principal" => "", |
13 |
"delegataire" => "", |
14 |
"petitionnaire" => array()); |
15 |
|
16 |
function demande($id,&$db,$debug) { |
17 |
$this->constructeur($id,$db,$debug); |
18 |
}// fin constructeur |
19 |
|
20 |
/* |
21 |
* La date du jour par défaut dans le champs date_demande |
22 |
* Put the date of the day by default into the field date_demande |
23 |
*/ |
24 |
function setVal(&$form, $maj, $validation, &$db) { |
25 |
if($maj == 0) { |
26 |
$form->setVal("date_demande",date('d/m/Y')); |
27 |
} |
28 |
} |
29 |
|
30 |
/** |
31 |
* Méthode de verification du contenu |
32 |
*/ |
33 |
function verifier($val, &$db, $DEBUG) { |
34 |
parent::verifier($val, $db, $DEBUG); |
35 |
$this->getPostedValues(); |
36 |
if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR |
37 |
empty($this->postedIdDemandeur["petitionnaire_principal"])) { |
38 |
$this->correct = false; |
39 |
$this->addToMessage("La saisie d'un petitionnaire principal est obligatoire."); |
40 |
$this->valIdDemandeur=$this->postedIdDemandeur; |
41 |
} |
42 |
} |
43 |
/* |
44 |
* Ajout du fielset |
45 |
* Add fieldset |
46 |
*/ |
47 |
function setLayout(&$form, $maj){ |
48 |
if ( $maj < 2 OR $maj == 3 ) { |
49 |
|
50 |
//Champs sur lequel s'ouvre le fieldset |
51 |
$form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8"); |
52 |
|
53 |
$form->setFieldset('dossier_autorisation_type_detaille','D' |
54 |
,_('Type de dossier/demande')); |
55 |
$form->setFieldset('demande_type','F',''); |
56 |
|
57 |
$form->setBloc('demande_type','F'); |
58 |
|
59 |
$form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc"); |
60 |
$form->setFieldset('date_demande','D',_('Date de la demande')); |
61 |
$form->setFieldset('date_demande','F',''); |
62 |
$form->setBloc('date_demande','F'); |
63 |
|
64 |
$form->setBloc('terrain_references_cadastrales','D',"", |
65 |
"localisation col_12 demande_hidden_bloc"); |
66 |
$form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain')); |
67 |
$form->setFieldset('terrain_superficie','F',''); |
68 |
$form->setBloc('terrain_superficie','F'); |
69 |
|
70 |
$form->setBloc('nombre_lots','D',"","lots col_12 demande_hidden_bloc"); |
71 |
$form->setFieldset('nombre_lots','D',_('Nombre de lots')); |
72 |
$form->setFieldset('nombre_lots','F',''); |
73 |
$form->setBloc('nombre_lots','F'); |
74 |
} |
75 |
} |
76 |
|
77 |
/* |
78 |
* Ajoute des actions sur les deux premiers select |
79 |
* Add actions on the two first select |
80 |
*/ |
81 |
function setOnchange(&$form,$maj){ |
82 |
parent::setOnchange($form,$maj); |
83 |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
84 |
$form->setOnchange("demande_type","showFormsDemande();"); |
85 |
} |
86 |
|
87 |
/* |
88 |
* Cache le champ terrain_references_cadastrales |
89 |
* Hide the fiels terrain_references_cadastrales |
90 |
*/ |
91 |
function setType(&$form,$maj) { |
92 |
parent::setType($form,$maj); |
93 |
|
94 |
$form->setType('dossier_instruction', 'hidden'); |
95 |
$form->setType('dossier_autorisation', 'hidden'); |
96 |
} |
97 |
|
98 |
/** |
99 |
* Méthode permettant d'ajouter un dossier d'autorisation |
100 |
*/ |
101 |
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){ |
102 |
require_once '../obj/dossier_autorisation.class.php'; |
103 |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
104 |
// Création du dossier |
105 |
foreach($dossier_autorisation->champs as $value) { |
106 |
$valAuto[$value] = NULL; |
107 |
} |
108 |
$valAuto['dossier_autorisation']=NULL; |
109 |
$valAuto['nature']=NULL; |
110 |
$valAuto['exercice']=NULL; |
111 |
$valAuto['insee']=NULL; |
112 |
$valAuto['arrondissement']=NULL; |
113 |
$valAuto['etat']=NULL; |
114 |
$valAuto['erp_numero_batiment']=NULL; |
115 |
$valAuto['erp_ouvert']=NULL; |
116 |
$valAuto['erp_arrete_decision']=NULL; |
117 |
$valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille']; |
118 |
$valAuto['depot_initial']=$this->valF['date_demande']; |
119 |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
120 |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
121 |
$valAuto['complement']=$this->valF['complement']; |
122 |
$valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
123 |
$valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
124 |
$valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
125 |
$valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
126 |
$valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
127 |
$valAuto['terrain_superficie']=$this->valF['terrain_superficie']; |
128 |
// Ajout du dossier dans la base |
129 |
$dossier_autorisation->ajouter($valAuto, $db, $DEBUG); |
130 |
// Liaison du dossier ajouter à la demande |
131 |
$this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation']; |
132 |
} |
133 |
|
134 |
/** |
135 |
* Méthode permettant d'ajouter un dossier d'instruction |
136 |
*/ |
137 |
function ajoutDossierInstruction($id, &$db, $val, $DEBUG){ |
138 |
require_once '../obj/dossier.class.php'; |
139 |
$dossier = new dossier("]",$db,$DEBUG); |
140 |
foreach($dossier->champs as $value) { |
141 |
$valInstr[$value] = NULL; |
142 |
} |
143 |
require_once '../obj/dossier_autorisation_type_detaille.class.php'; |
144 |
$datd = new dossier_autorisation_type_detaille( |
145 |
$this->valF['dossier_autorisation_type_detaille'],$db,$DEBUG); |
146 |
// Définition des valeurs à entrée dans la table |
147 |
$valInstr['nature']=$datd->val[array_search("code", $datd->champs)]; |
148 |
$valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille']; |
149 |
$valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']); |
150 |
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
151 |
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
152 |
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
153 |
$valInstr['complement']=$this->valF['complement']; |
154 |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
155 |
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
156 |
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
157 |
$valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
158 |
$valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
159 |
$valInstr['terrain_superficie']=$this->valF['terrain_superficie']; |
160 |
$valInstr['description']=""; |
161 |
$valInstr['dossier_autorisation']=$this->valF['dossier_autorisation']; |
162 |
$dossier->ajouter($valInstr, $db, $DEBUG); |
163 |
$this->f->isDatabaseError(); |
164 |
// Liaison du dossier ajouter à la demande |
165 |
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
166 |
} |
167 |
|
168 |
/** |
169 |
* Ajout des liens demandeurs / dossier d'autorisation |
170 |
**/ |
171 |
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
172 |
// Création des liens entre le dossier autorisation et les demandeurs |
173 |
include '../sql/pgsql/demande.form.inc.php'; |
174 |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
175 |
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
176 |
// Recupération des demandeurs liés à la demande |
177 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
178 |
$res = $db->query($sql); |
179 |
$this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
180 |
$this->f->isDatabaseError(); |
181 |
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
182 |
$row['lien_dossier_autorisation_demandeur'] = NULL; |
183 |
$row['dossier_autorisation'] = $this->valF['dossier_autorisation']; |
184 |
$ldad->ajouter($row, $db, $DEBUG); |
185 |
} |
186 |
} |
187 |
|
188 |
/** |
189 |
* Ajout des liens demandeurs / dossier d'autorisation |
190 |
**/ |
191 |
function ajoutLiensDossierInstruction($id, &$db, $val, $DEBUG) { |
192 |
// Création des liens entre le dossier instruction et les demandeurs |
193 |
include '../sql/pgsql/demande.form.inc.php'; |
194 |
require_once '../obj/lien_dossier_demandeur.class.php'; |
195 |
$ldd = new lien_dossier_demandeur("]",$db,$DEBUG); |
196 |
// Recupération des demandeurs liés à la demande |
197 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
198 |
$res = $db->query($sql); |
199 |
$this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE); |
200 |
$this->f->isDatabaseError(); |
201 |
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
202 |
$row['lien_dossier_demandeur'] = NULL; |
203 |
$row['dossier'] = $this->valF['dossier_instruction']; |
204 |
$ldd->ajouter($row, $db, $DEBUG); |
205 |
} |
206 |
} |
207 |
|
208 |
/** |
209 |
* Ajout des dossiers |
210 |
**/ |
211 |
function triggerAjouter($id, &$db, $val, $DEBUG){ |
212 |
include '../sql/pgsql/demande.form.inc.php'; |
213 |
if($this->valF["demande_type"] != NULL) { |
214 |
$res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)); |
215 |
$this->f->isDatabaseError(); |
216 |
$dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC); |
217 |
// Création du dossier_autorisation |
218 |
if($dossier_type['dossier_autorisation_type_detaille'] != NULL) { |
219 |
$this->ajoutDossierAutorisation($id, $db, $val, $DEBUG); |
220 |
$this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']); |
221 |
} |
222 |
// Création du dossier d'instruction |
223 |
if($dossier_type['dossier_instruction_type'] != NULL) { |
224 |
$this->ajoutDossierInstruction($id, $db, $val, $DEBUG); |
225 |
$this -> addToMessage(_("Creation du dossier d'instruction no".$this->valF['dossier_instruction'])); |
226 |
} |
227 |
|
228 |
/*Création du lien de téléchargement de récépissé de demande*/ |
229 |
if ( $this->valF['demande_type'] != "" && is_numeric($this->valF['demande_type']) |
230 |
&& isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ){ |
231 |
|
232 |
/*Récupérer l'événement lié à ce type de demande*/ |
233 |
$sql = |
234 |
"SELECT |
235 |
evenement |
236 |
FROM |
237 |
".DB_PREFIXE."demande_type |
238 |
WHERE |
239 |
demande_type = ".$this->valF['demande_type']." |
240 |
"; |
241 |
|
242 |
$res = $this->db->query($sql); |
243 |
$this->f->isDatabaseError($res); |
244 |
|
245 |
/*Le champ evenement est not null dans la table demande_type*/ |
246 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
247 |
|
248 |
/*Récupération de la lettre type de l'événement*/ |
249 |
$sql = |
250 |
"SELECT |
251 |
lettretype |
252 |
FROM |
253 |
".DB_PREFIXE."evenement |
254 |
WHERE |
255 |
evenement = ".$row['evenement']; |
256 |
|
257 |
$resLT = $this->db->query($sql); |
258 |
$this->f->isDatabaseError($resLT); |
259 |
|
260 |
$rowLT=& $resLT->fetchRow(DB_FETCHMODE_ASSOC); |
261 |
|
262 |
/*Création d'une nouvelle instruction avec cet événement*/ |
263 |
/*Données*/ |
264 |
$valInstr['instruction']=NULL; |
265 |
|
266 |
$valInstr['destinataire']=$this->valF['dossier_instruction']; |
267 |
$valInstr['dossier']=$this->valF['dossier_instruction']; |
268 |
|
269 |
$valInstr['datecourrier']=date("d/m/Y"); |
270 |
$valInstr['evenement']=$row['evenement']; |
271 |
$valInstr['lettretype']=$rowLT['lettretype']; |
272 |
$valInstr['complement']=""; |
273 |
$valInstr['complement2']=""; |
274 |
|
275 |
$valInstr['action']="initialisation"; |
276 |
$valInstr['delai']="2"; |
277 |
$valInstr['etat']="notifier"; |
278 |
$valInstr['accord_tacite']="Oui"; |
279 |
$valInstr['delai_notification']="1"; |
280 |
$valInstr['archive_delai']="0"; |
281 |
$valInstr['archive_date_complet']=NULL; |
282 |
$valInstr['archive_date_rejet']=NULL; |
283 |
$valInstr['archive_date_limite']=NULL; |
284 |
$valInstr['archive_date_notification_delai']=NULL; |
285 |
$valInstr['archive_accord_tacite']="Non"; |
286 |
$valInstr['archive_etat']="initialiser"; |
287 |
$valInstr['archive_date_decision']=NULL; |
288 |
$valInstr['archive_avis']=""; |
289 |
$valInstr['archive_date_validite']=NULL; |
290 |
$valInstr['archive_date_achevement']=NULL; |
291 |
$valInstr['archive_date_chantier']=NULL; |
292 |
$valInstr['archive_date_conformite']=NULL; |
293 |
$valInstr['complement3']=""; |
294 |
$valInstr['complement4']=""; |
295 |
$valInstr['complement5']=""; |
296 |
$valInstr['complement6']=""; |
297 |
$valInstr['complement7']=""; |
298 |
$valInstr['complement8']=""; |
299 |
$valInstr['complement9']=""; |
300 |
$valInstr['complement10']=""; |
301 |
$valInstr['complement11']=""; |
302 |
$valInstr['complement12']=""; |
303 |
$valInstr['complement13']=""; |
304 |
$valInstr['complement14']=""; |
305 |
$valInstr['complement15']=""; |
306 |
$valInstr['avis_decision']=NULL; |
307 |
|
308 |
/*Fichier requis*/ |
309 |
require_once '../obj/instruction.class.php'; |
310 |
|
311 |
/*Création d'un nouveau dossier*/ |
312 |
$instruction = new instruction("]",$db,$DEBUG); |
313 |
$instruction->valF = ""; |
314 |
$instruction->ajouter($valInstr, $db, $DEBUG); |
315 |
if ( $instruction->valF['instruction'] != "" ){ |
316 |
|
317 |
$this -> addToMessage("<br/><a |
318 |
class='lien' |
319 |
href='../pdf/pdflettretype.php?obj=".$rowLT['lettretype']."&idx=".$this->valF['dossier_instruction']."'> |
320 |
<span |
321 |
class=\"om-icon om-icon-16 om-icon-fix pdf-16\" |
322 |
title=\""._("Telecharger le recepisse de la demande")."\">". |
323 |
_("Telecharger le recepisse de la demande"). |
324 |
"</span> |
325 |
". |
326 |
_("Telecharger le recepisse de la demande")." |
327 |
</a></br>"); |
328 |
} |
329 |
else { |
330 |
|
331 |
$this -> addToMessage(_("Une erreur s'est produite lors de la création du recepisse")); |
332 |
} |
333 |
} |
334 |
} |
335 |
} |
336 |
|
337 |
/** |
338 |
* Ajout des délégataires et pétitionnaires |
339 |
**/ |
340 |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
341 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
342 |
$this->valIdDemandeur=$this->postedIdDemandeur; |
343 |
// Ajout des lliens entre dossier_autorisation et demandeur |
344 |
if(!empty($this->valF['dossier_autorisation'])) { |
345 |
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
346 |
} |
347 |
// Ajout des lliens entre dossier et demandeur |
348 |
if(!empty($this->valF['dossier_instruction'])) { |
349 |
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
350 |
} |
351 |
} |
352 |
function triggerModifierApres($id, &$db, $val, $DEBUG){ |
353 |
$this->listeDemandeur(); |
354 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
355 |
$this->valIdDemandeur=$this->postedIdDemandeur; |
356 |
|
357 |
} |
358 |
|
359 |
/** |
360 |
* Gestion des liens entre la demande et les demendeurs recement ajoutés |
361 |
**/ |
362 |
function insertLinkDemandeDemandeur($db, $DEBUG) { |
363 |
// |
364 |
require_once "../obj/lien_demande_demandeur.class.php"; |
365 |
|
366 |
// Comparaison de l'id petitionnaire principal |
367 |
if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND |
368 |
!empty($this->postedIdDemandeur['petitionnaire_principal']) AND |
369 |
$this->valIdDemandeur['petitionnaire_principal'] != |
370 |
$this->postedIdDemandeur['petitionnaire_principal']) { |
371 |
// Ajout du nouveau lien |
372 |
$this->addLinkDemandeDemandeur($this->postedIdDemandeur['petitionnaire_principal'], true, $db, $DEBUG); |
373 |
if(!empty($this->valIdDemandeur['petitionnaire_principal'])) { |
374 |
$this->deleteLinkDemandeDemandeur($this->valIdDemandeur['petitionnaire_principal'], $db, $DEBUG); |
375 |
} |
376 |
} |
377 |
|
378 |
// Comparaison du delegataire |
379 |
if(isset($this->postedIdDemandeur['delegataire']) AND |
380 |
!empty($this->postedIdDemandeur['delegataire']) AND |
381 |
$this->valIdDemandeur['delegataire'] != |
382 |
$this->postedIdDemandeur['delegataire']) { |
383 |
// Ajout du nouveau lien |
384 |
$this->addLinkDemandeDemandeur($this->postedIdDemandeur['delegataire'], false, $db, $DEBUG); |
385 |
if(!empty($this->valIdDemandeur['delegataire'])) { |
386 |
$this->deleteLinkDemandeDemandeur($this->valIdDemandeur['delegataire'], $db, $DEBUG); |
387 |
} |
388 |
} |
389 |
|
390 |
// Comparaison des different petitionnaires |
391 |
if(isset($this->postedIdDemandeur['petitionnaire'])) { |
392 |
// Suppression des liens non valides |
393 |
foreach ($this->valIdDemandeur['petitionnaire'] as $petitionnaire) { |
394 |
if(!in_array($petitionnaire, $this->postedIdDemandeur['petitionnaire'])) { |
395 |
$this->deleteLinkDemandeDemandeur($petitionnaire, $db, $DEBUG); |
396 |
} |
397 |
} |
398 |
// Ajout des nouveaux liens |
399 |
foreach ($this->postedIdDemandeur['petitionnaire'] as $petitionnaire) { |
400 |
if(!in_array($petitionnaire, $this->valIdDemandeur['petitionnaire'])) { |
401 |
$this->addLinkDemandeDemandeur($petitionnaire, false, $db, $DEBUG); |
402 |
} |
403 |
} |
404 |
} |
405 |
} |
406 |
|
407 |
|
408 |
/** |
409 |
* Fonction permettant d'ajouter un lien |
410 |
* entre la table demande et demandeur |
411 |
**/ |
412 |
function addLinkDemandeDemandeur($id, $principal, $db, $DEBUG) { |
413 |
$lienAjout = new lien_demande_demandeur( |
414 |
"]", |
415 |
$db, |
416 |
$DEBUG); |
417 |
$lien = array('lien_demande_demandeur' => "", |
418 |
'petitionnaire_principal' => (($principal)?"t":"f"), |
419 |
'demande' => $this->valF['demande'], |
420 |
'demandeur' => $id); |
421 |
$lienAjout->ajouter($lien, $db, $DEBUG); |
422 |
$lienAjout->__destruct(); |
423 |
} |
424 |
|
425 |
/** |
426 |
* Fonction permettant de supprimer un lien |
427 |
* entre la table demande et demandeur |
428 |
**/ |
429 |
function deleteLinkDemandeDemandeur($id, $db, $DEBUG) { |
430 |
// Suppression |
431 |
$sql = "DELETE FROM ".DB_PREFIXE."lien_demande_demandeur ". |
432 |
"WHERE demande=".$this->valF['demande']. |
433 |
" AND demandeur=".$id; |
434 |
// Execution de la requete de suppression de l'objet |
435 |
$res = $db->query($sql); |
436 |
// Logger |
437 |
$this->f->addToLog("supprimer(): db->query(\"".$sql."\");", VERBOSE_MODE); |
438 |
$this->f->isDatabaseError(); |
439 |
|
440 |
} |
441 |
|
442 |
function isLinkDemandeDemandeurExist($idDemandeur) { |
443 |
$sql = "SELECT count(*) |
444 |
FROM ".DB_PREFIXE."lien_demande_demandeur |
445 |
WHERE demande = ".$this->valF['demande']. |
446 |
"AND demandeur = ".$idDemandeur; |
447 |
$count = $this->f->db->getOne($sql); |
448 |
$this->f->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE); |
449 |
$this->f->isDatabaseError($count); |
450 |
if ($count === 0) { |
451 |
return false; |
452 |
} else { |
453 |
return true; |
454 |
} |
455 |
|
456 |
} |
457 |
|
458 |
/** |
459 |
* Methode de recupération des valeurs postées |
460 |
**/ |
461 |
function getPostedValues() { |
462 |
// Récupération des demandeurs dans POST |
463 |
if (isset($_POST['petitionnaire_principal']) OR |
464 |
isset($_POST['delegataire']) OR |
465 |
isset($_POST['petitionnaire'])) { |
466 |
if( isset($_POST['petitionnaire_principal']) AND |
467 |
!empty($_POST['petitionnaire_principal'])) { |
468 |
$this->postedIdDemandeur['petitionnaire_principal'] = $_POST['petitionnaire_principal']; |
469 |
} |
470 |
if( isset($_POST['delegataire']) AND |
471 |
!empty($_POST['delegataire'])) { |
472 |
$this->postedIdDemandeur['delegataire'] = $_POST['delegataire']; |
473 |
} |
474 |
if( isset($_POST['petitionnaire']) AND |
475 |
!empty($_POST['petitionnaire'])) { |
476 |
$this->postedIdDemandeur['petitionnaire'] = $_POST['petitionnaire']; |
477 |
} |
478 |
} |
479 |
} |
480 |
/** |
481 |
* Méthode permettant de récupérer les id des demandeur lié à la demande |
482 |
**/ |
483 |
function listeDemandeur() { |
484 |
// Récupération des demandeurs de la base |
485 |
$sql = "SELECT demandeur.demandeur, |
486 |
demandeur.type_demandeur, |
487 |
lien_demande_demandeur.petitionnaire_principal |
488 |
FROM ".DB_PREFIXE."lien_demande_demandeur |
489 |
INNER JOIN ".DB_PREFIXE."demandeur |
490 |
ON demandeur.demandeur=lien_demande_demandeur.demandeur |
491 |
WHERE demande = ".$this->val[array_search('demande', $this->champs)]; |
492 |
$res = $this->f->db->query($sql); |
493 |
$this->f->addToLog("listeDemandeur() : ".$sql); |
494 |
$this->f->isDatabaseError($res); |
495 |
// Stoquage du résultat dans un tableau |
496 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
497 |
if ($row['petitionnaire_principal'] == 't' AND |
498 |
$row['type_demandeur']=="petitionnaire") { |
499 |
$this->valIdDemandeur['petitionnaire_principal']=$row['demandeur']; |
500 |
} elseif ($row['petitionnaire_principal'] == 'f' AND |
501 |
$row['type_demandeur']=="petitionnaire"){ |
502 |
$this->valIdDemandeur['petitionnaire'][]=$row['demandeur']; |
503 |
} elseif ($row['type_demandeur']=="delegataire"){ |
504 |
$this->valIdDemandeur['delegataire']=$row['demandeur']; |
505 |
} |
506 |
} |
507 |
} |
508 |
|
509 |
/** |
510 |
* Ajout de la liste des demandeurs |
511 |
*/ |
512 |
function formSpecificContent($maj) { |
513 |
if(!$this->correct AND $maj != 0) { |
514 |
$this->listeDemandeur(); |
515 |
} |
516 |
if($maj < 2 AND !$this->correct) { |
517 |
$linkable = true; |
518 |
} else { |
519 |
$linkable = false; |
520 |
} |
521 |
// Conteneur de la listes des demandeurs |
522 |
echo "<div class=\"demande_hidden_bloc col_12\">"; |
523 |
echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">"; |
524 |
echo " <legend class=\"ui-corner-all ui-widget-content ui-state-active\">" |
525 |
._("Petitionnaire")."</legend>"; |
526 |
// Si des demandeurs sont liés à la demande |
527 |
require_once "../obj/petitionnaire.class.php"; |
528 |
require_once "../obj/delegataire.class.php"; |
529 |
|
530 |
// Affichage du bloc pétitionnaire principal / délégataire |
531 |
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
532 |
echo "<div id=\"petitionnaire_principal_delegataire\">"; |
533 |
// Affichage de la synthèse |
534 |
if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND |
535 |
!empty($this->valIdDemandeur["petitionnaire_principal"])) { |
536 |
$demandeur = new petitionnaire( |
537 |
$this->valIdDemandeur["petitionnaire_principal"], |
538 |
$this->f->db,false); |
539 |
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
540 |
$demandeur -> __destruct(); |
541 |
} |
542 |
// Si en édition de formulaire |
543 |
if($maj < 2 AND $this->correct != true) { |
544 |
// Bouton d'ajout du pétitionnaire principal |
545 |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
546 |
echo "<input id=\"add_petitionnaire_principal\" |
547 |
class=\"ui-button ui-widget ui-state-default ui-corner-all\" |
548 |
type=\"button\" value=\""._("Saisir le petitionnaire principal")."\"/>"; |
549 |
echo " <span class=\"om-icon om-icon-16 om-icon-fix arrow-right-16\">></span> "; |
550 |
// Bouton d'ajout du delegataire |
551 |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
552 |
echo "<input id=\"add_delegataire\" |
553 |
class=\"ui-button ui-widget ui-state-default ui-corner-all\" |
554 |
type=\"button\" value=\""._("Saisir le delegataire")."\"/>"; |
555 |
} |
556 |
// Affichage de la synthèse |
557 |
if (isset ($this->valIdDemandeur["delegataire"]) AND |
558 |
!empty($this->valIdDemandeur["delegataire"])) { |
559 |
$demandeur = new delegataire($this->valIdDemandeur["delegataire"], |
560 |
$this->f->db,false); |
561 |
$demandeur -> afficherSynthese("delegataire", $linkable); |
562 |
$demandeur -> __destruct(); |
563 |
} |
564 |
|
565 |
echo "</div>"; |
566 |
|
567 |
// Bloc des pétitionnaires secondaires |
568 |
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
569 |
echo "<div id=\"listePetitionnaires\">"; |
570 |
|
571 |
// Affichage de la synthèse |
572 |
if (isset ($this->valIdDemandeur["petitionnaire"]) AND |
573 |
!empty($this->valIdDemandeur["petitionnaire"])) { |
574 |
|
575 |
foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) { |
576 |
$demandeur = new petitionnaire($petitionnaire, |
577 |
$this->f->db,false); |
578 |
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
579 |
$demandeur -> __destruct(); |
580 |
} |
581 |
|
582 |
} |
583 |
if ($maj < 2 AND !$this->correct) { |
584 |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
585 |
echo "<input id=\"add_petitionnaire\" |
586 |
class=\"ui-button ui-widget ui-state-default ui-corner-all\" |
587 |
type=\"button\" value=\""._("Ajouter un petitionnaire")."\"/>"; |
588 |
} |
589 |
echo "</div>"; |
590 |
echo "</fieldset>"; |
591 |
echo "</div>"; |
592 |
} |
593 |
|
594 |
}// fin classe |
595 |
?> |