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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1039 - (show annotations)
Tue Dec 11 12:38:52 2012 UTC (12 years, 1 month ago) by nhaye
File size: 35073 byte(s)
Renomage d'un script et modification afin qu'il puisse récupérer plusieurs informations sur la demande,
suppression des demandeurs lorsque qu'une demande est créée sur un dossier existant
Correction de nom de fonction et méthode afin qu'ils correspondent à la fonctionnalité

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 function setValF($val) {
21 parent::setValF($val);
22
23 // Récupération des id demandeurs postés
24 $this->getPostedValues();
25 //$this->valIdDemandeur=$this->postedIdDemandeur;
26 }
27
28 /**
29 * Méthode permettant de récupérer les valeurs du dossier d'autorisation
30 * correspondant àla nouvelle demande
31 */
32 function getValFromDossier($dossier_autorisation) {
33 include "../sql/pgsql/demande.form.inc.php";
34 $sql=str_replace("<idx>",$this->getParameter("idx_dossier"),
35 $sql_infos_dossier_autorisation);
36 $res = $this->db->query($sql);
37 $this->addToLog("demande -> getValFromDossier() : ".$sql);
38 $this->f->isDatabaseError();
39 $row = & $res->fetchRow(DB_FETCHMODE_ASSOC);
40 return $row;
41 }
42
43 /*
44 * La date du jour par défaut dans le champs date_demande
45 * Put the date of the day by default into the field date_demande
46 */
47 function setVal(&$form, $maj, $validation, &$db) {
48 if($maj == 0) {
49 $form->setVal("date_demande",date('d/m/Y'));
50
51 // Récupération des valeurs du dossier d'autorisation correspondant
52 if($this->getParameter("idx_dossier") != "") {
53 $val_autorisation = $this->getValFromDossier(
54 $this->getParameter("idx_dossier"));
55 foreach($val_autorisation as $champ => $value) {
56 $form->setVal($champ,$value);
57 }
58 }
59 }
60 }
61
62 /**
63 * Méthode de verification du contenu
64 */
65 function verifier($val, &$db, $DEBUG) {
66 parent::verifier($val, $db, $DEBUG);
67 if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR
68 empty($this->postedIdDemandeur["petitionnaire_principal"])) {
69 $this->correct = false;
70 $this->addToMessage("La saisie d'un petitionnaire principal est obligatoire.");
71 }
72 }
73 /*
74 * Ajout du fielset
75 * Add fieldset
76 */
77 function setLayout(&$form, $maj){
78 if ( $maj < 2 OR $maj == 3 ) {
79
80 //Champs sur lequel s'ouvre le fieldset
81 $form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8");
82
83 $form->setFieldset('dossier_autorisation_type_detaille','D'
84 ,_('Type de dossier/demande'));
85 $form->setFieldset('demande_type','F','');
86
87 $form->setBloc('demande_type','F');
88
89 $form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc");
90 $form->setFieldset('date_demande','D',_('Date de la demande'));
91 $form->setFieldset('date_demande','F','');
92 $form->setBloc('date_demande','F');
93
94 $form->setBloc('terrain_references_cadastrales','D',"",
95 "localisation col_12 demande_hidden_bloc");
96 $form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain'));
97 $form->setFieldset('terrain_superficie','F','');
98 $form->setBloc('terrain_superficie','F');
99
100 $form->setBloc('nombre_lots','D',"","lots col_12 demande_hidden_bloc");
101 $form->setFieldset('nombre_lots','D',_('Nombre de lots'));
102 $form->setFieldset('nombre_lots','F','');
103 $form->setBloc('nombre_lots','F');
104 }
105 }
106
107 /*
108 * Ajoute des actions sur les deux premiers select
109 * Add actions on the two first select
110 */
111 function setOnchange(&$form,$maj){
112 parent::setOnchange($form,$maj);
113 $form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();");
114 $form->setOnchange("demande_type","showFormsDemande();");
115 }
116
117 /*
118 * Cache le champ terrain_references_cadastrales
119 * Hide the fiels terrain_references_cadastrales
120 */
121 function setType(&$form,$maj) {
122 parent::setType($form,$maj);
123
124 $form->setType('dossier_instruction', 'hidden');
125 $form->setType('dossier_autorisation', 'hidden');
126
127 $form->setType('instruction_recepisse', 'hidden');
128 $form->setType('arrondissement', 'hidden');
129
130 // Si il s'agit d'une demande sur dossier existant on desactive tous les champs
131 // sauf demande_type
132 if($maj == 0 AND $this-> getParameter("idx_dossier")) {
133 $form->setType('dossier_autorisation_type_detaille', 'selectdisabled');
134 $form->setType('terrain_references_cadastrales', 'textdisabled');
135 $form->setType('terrain_adresse_voie_numero', 'textdisabled');
136 $form->setType('complement', 'textdisabled');
137 $form->setType('terrain_adresse_lieu_dit', 'textdisabled');
138 $form->setType('terrain_adresse_localite', 'textdisabled');
139 $form->setType('terrain_adresse_code_postal', 'textdisabled');
140 $form->setType('terrain_adresse_bp', 'textdisabled');
141 $form->setType('terrain_adresse_cedex', 'textdisabled');
142 $form->setType('terrain_superficie', 'textdisabled');
143 $form->setType('nombre_lots', 'textdisabled');
144 }
145 }
146
147 /**
148 * Méthode permettant d'ajouter un dossier d'autorisation
149 */
150 function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){
151 require_once '../obj/dossier_autorisation.class.php';
152 $dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG);
153 // Création du dossier
154 foreach($dossier_autorisation->champs as $value) {
155 $valAuto[$value] = NULL;
156 }
157 $valAuto['dossier_autorisation']=NULL;
158 $valAuto['nature']=NULL;
159 $valAuto['exercice']=NULL;
160 $valAuto['insee']=NULL;
161 $valAuto['arrondissement']=NULL;
162 $valAuto['etat']=NULL;
163 $valAuto['erp_numero_batiment']=NULL;
164 $valAuto['erp_ouvert']=NULL;
165 $valAuto['erp_arrete_decision']=NULL;
166 $valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
167 $valAuto['depot_initial']=$this->valF['date_demande'];
168 $valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
169 $valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
170 $valAuto['complement']=$this->valF['complement'];
171 $valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
172 $valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
173 $valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
174 $valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];
175 $valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];
176 $valAuto['terrain_superficie']=$this->valF['terrain_superficie'];
177 $valAuto['numero_version']=-1;
178 // Ajout du dossier dans la base
179 $dossier_autorisation->ajouter($valAuto, $db, $DEBUG);
180 // Liaison du dossier ajouter à la demande
181 $this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation'];
182 }
183
184 /**
185 * Méthode permettant d'ajouter un dossier d'instruction
186 */
187 function ajoutDossierInstruction($id, &$db, $val, $DEBUG, $dossier_instruction_type){
188 require_once '../obj/dossier.class.php';
189 $dossier = new dossier("]",$db,$DEBUG);
190 foreach($dossier->champs as $value) {
191 $valInstr[$value] = NULL;
192 }
193 require_once '../obj/dossier_autorisation_type_detaille.class.php';
194 $datd = new dossier_autorisation_type_detaille(
195 $this->valF['dossier_autorisation_type_detaille'],$db,$DEBUG);
196
197 /*Ajout de la variable dossier_instruction_type à l'objet dossier pour le
198 * versionning
199 */
200 $dossier->setDossierInstructionType($dossier_instruction_type);
201
202 // Définition des valeurs à entrée dans la table
203 $valInstr['nature']=$datd->val[array_search("code", $datd->champs)];
204 $valInstr['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille'];
205 $valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']);
206 $valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']);
207 $valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']);
208 $valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales'];
209 $valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero'];
210 $valInstr['complement']=$this->valF['complement'];
211 $valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit'];
212 $valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite'];
213 $valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal'];
214 $valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp'];
215 $valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex'];
216 $valInstr['terrain_superficie']=$this->valF['terrain_superficie'];
217 $valInstr['description']="";
218 $valInstr['dossier_autorisation']=$this->valF['dossier_autorisation'];
219 $dossier->ajouter($valInstr, $db, $DEBUG);
220 $this->f->isDatabaseError();
221 // Liaison du dossier ajouter à la demande
222 $this->valF['dossier_instruction'] = $dossier->valF['dossier'];
223 }
224
225 /**
226 * Ajout des liens demandeurs / dossier d'autorisation
227 **/
228 function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) {
229 // Création des liens entre le dossier autorisation et les demandeurs
230 include '../sql/pgsql/demande.form.inc.php';
231 require_once '../obj/lien_dossier_autorisation_demandeur.class.php';
232 $ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG);
233 // Recupération des demandeurs liés à la demande
234 $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);
235 $res = $db->query($sql);
236 $this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
237 $this->f->isDatabaseError();
238 while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
239 $row['lien_dossier_autorisation_demandeur'] = NULL;
240 $row['dossier_autorisation'] = $this->valF['dossier_autorisation'];
241 $ldad->ajouter($row, $db, $DEBUG);
242 }
243 }
244
245 /**
246 * Ajout des liens demandeurs / dossier d'autorisation
247 **/
248 function ajoutLiensDossierInstruction($id, &$db, $val, $DEBUG) {
249 // Création des liens entre le dossier instruction et les demandeurs
250 include '../sql/pgsql/demande.form.inc.php';
251 require_once '../obj/lien_dossier_demandeur.class.php';
252 $ldd = new lien_dossier_demandeur("]",$db,$DEBUG);
253 // Recupération des demandeurs liés à la demande
254 $sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur);
255 $res = $db->query($sql);
256 $this->f->addToLog("demande.class.php: db->query(\"".$sql."\");", VERBOSE_MODE);
257 $this->f->isDatabaseError();
258 while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) {
259 $row['lien_dossier_demandeur'] = NULL;
260 $row['dossier'] = $this->valF['dossier_instruction'];
261 $ldd->ajouter($row, $db, $DEBUG);
262 }
263 }
264
265 /*
266 * Récupère l'identifiant d'un arrondissement à partir d'un code postal
267 */
268 function getArrondissement($terrain_adresse_code_postal){
269
270 $arrondissement = NULL;
271
272 $sql = "SELECT
273 arrondissement
274 FROM
275 ".DB_PREFIXE."arrondissement
276 WHERE
277 code_postal = '$terrain_adresse_code_postal' ";
278 $this->addToLog("demande.class.php : ".$sql." execute <br>", EXTRA_VERBOSE_MODE);
279
280 $res = $this->db->query($sql);
281 $this->f->isDatabaseError($res);
282
283 if( $res->numrows() > 0 ) {
284
285 $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
286 $arrondissement = $row['arrondissement'];
287 }
288
289 return $arrondissement;
290 }
291
292 /*
293 * Récupère l'évènement lié à un type de demande
294 */
295 function getEvenement($demande_type){
296
297 $evenement = NULL;
298
299 $sql =
300 "SELECT
301 evenement
302 FROM
303 ".DB_PREFIXE."demande_type
304 WHERE
305 demande_type = $demande_type";
306
307 $res = $this->db->query($sql);
308 $this->f->isDatabaseError($res);
309
310 if ( $res->numrows() > 0 ){
311
312 $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
313 $evenement = $row['evenement'];
314 }
315
316 return $evenement;
317 }
318
319 /*
320 * Récupère la lettre type lié à un événement
321 */
322 function getLettreType($evenement){
323
324 $lettretype = NULL;
325
326 $sql =
327 "SELECT
328 lettretype
329 FROM
330 ".DB_PREFIXE."evenement
331 WHERE
332 evenement = $evenement";
333
334 $res = $this->db->query($sql);
335 $this->f->isDatabaseError($res);
336
337 if ( $res->numrows() > 0 ){
338
339 $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
340 $lettretype = $row['lettretype'];
341 }
342
343 return $lettretype;
344 }
345
346 /**
347 * Ajout des dossiers
348 **/
349 function triggerAjouter($id, &$db, $val, $DEBUG){
350 include '../sql/pgsql/demande.form.inc.php';
351 if($this->valF["demande_type"] != NULL) {
352 $res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id));
353 $this->f->isDatabaseError();
354 $dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC);
355 // Création du dossier_autorisation
356 if($dossier_type['dossier_autorisation_type_detaille'] != NULL) {
357 $this->ajoutDossierAutorisation($id, $db, $val, $DEBUG);
358 $this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']);
359 }
360 // Création du dossier d'instruction
361 if($dossier_type['dossier_instruction_type'] != NULL) {
362 $this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']);
363 $this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']);
364 }
365
366 /*Création du lien de téléchargement de récépissé de demande*/
367 if ( $this->valF['demande_type'] != "" && is_numeric($this->valF['demande_type'])
368 && isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ){
369
370 /*Récupérer l'événement lié à ce type de demande*/
371 $evenement = $this->getEvenement($this->valF['demande_type']);
372
373 /*Récupération de la lettre type de l'événement*/
374 $lettretype = $this->getLettreType($evenement);
375
376 /*Création d'une nouvelle instruction avec cet événement*/
377 /*Données*/
378 $valInstr['instruction']=NULL;
379
380 $valInstr['destinataire']=$this->valF['dossier_instruction'];
381 $valInstr['dossier']=$this->valF['dossier_instruction'];
382
383 $valInstr['datecourrier']=date("d/m/Y");
384 $valInstr['evenement']=$evenement;
385 $valInstr['lettretype']=$lettretype;
386 $valInstr['complement']="";
387 $valInstr['complement2']="";
388
389 $valInstr['action']="initialisation";
390 $valInstr['delai']="2";
391 $valInstr['etat']="notifier";
392 $valInstr['accord_tacite']="Oui";
393 $valInstr['delai_notification']="1";
394 $valInstr['archive_delai']="0";
395 $valInstr['archive_date_complet']=NULL;
396 $valInstr['archive_date_rejet']=NULL;
397 $valInstr['archive_date_limite']=NULL;
398 $valInstr['archive_date_notification_delai']=NULL;
399 $valInstr['archive_accord_tacite']="Non";
400 $valInstr['archive_etat']="initialiser";
401 $valInstr['archive_date_decision']=NULL;
402 $valInstr['archive_avis']="";
403 $valInstr['archive_date_validite']=NULL;
404 $valInstr['archive_date_achevement']=NULL;
405 $valInstr['archive_date_chantier']=NULL;
406 $valInstr['archive_date_conformite']=NULL;
407 $valInstr['complement3']="";
408 $valInstr['complement4']="";
409 $valInstr['complement5']="";
410 $valInstr['complement6']="";
411 $valInstr['complement7']="";
412 $valInstr['complement8']="";
413 $valInstr['complement9']="";
414 $valInstr['complement10']="";
415 $valInstr['complement11']="";
416 $valInstr['complement12']="";
417 $valInstr['complement13']="";
418 $valInstr['complement14']="";
419 $valInstr['complement15']="";
420 $valInstr['avis_decision']=NULL;
421
422 /*Fichier requis*/
423 require_once '../obj/instruction.class.php';
424
425 /*Création d'un nouveau dossier*/
426 $instruction = new instruction("]",$db,$DEBUG);
427 $instruction->valF = "";
428 $instruction->ajouter($valInstr, $db, $DEBUG);
429 if ( $instruction->valF['instruction'] != "" ){
430
431 $this->valF['instruction_recepisse'] = $instruction->valF['instruction'];
432 $this -> addToMessage("<br/><a
433 class='lien'
434 href='../pdf/pdflettretype.php?obj=".$lettretype."&amp;idx=".$this->valF['dossier_instruction']."'>
435 <span
436 class=\"om-icon om-icon-16 om-icon-fix pdf-16\"
437 title=\""._("Telecharger le recepisse de la demande")."\">".
438 _("Telecharger le recepisse de la demande").
439 "</span>
440 &nbsp;&nbsp;&nbsp;&nbsp;".
441 _("Telecharger le recepisse de la demande")."
442 </a></br>");
443 }
444 else {
445
446 $this -> addToMessage(_("Une erreur s'est produite lors de la creation du recepisse"));
447 }
448 }
449
450 /*Ajout de l'arrondissement à partir du code postal*/
451 if ( !is_null($this->valF["terrain_adresse_code_postal"]) && is_numeric($this->valF["terrain_adresse_code_postal"]) ){
452
453 $this->valF["arrondissement"] = $this->getArrondissement($this->valF["terrain_adresse_code_postal"]);
454 }
455 }
456 }
457
458 /**
459 * Ajout des délégataires et pétitionnaires
460 **/
461 function triggerAjouterApres($id, &$db, $val, $DEBUG){
462 $this->insertLinkDemandeDemandeur($db, $DEBUG);
463
464 // Ajout des lliens entre dossier_autorisation et demandeur
465 if(!empty($this->valF['dossier_autorisation'])) {
466 $this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG);
467 }
468 // Ajout des lliens entre dossier et demandeur
469 if(!empty($this->valF['dossier_instruction'])) {
470 $this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG);
471 }
472 }
473 function triggerModifierApres($id, &$db, $val, $DEBUG){
474 $this->listeDemandeur("demande",$this->val[array_search('demande', $this->champs)]);
475 $this->insertLinkDemandeDemandeur($db, $DEBUG);
476 $this->valIdDemandeur=$this->postedIdDemandeur;
477
478 }
479
480 /**
481 * Gestion des liens entre la demande et les demendeurs recement ajoutés
482 **/
483 function insertLinkDemandeDemandeur($db, $DEBUG) {
484 //
485 require_once "../obj/lien_demande_demandeur.class.php";
486 // Comparaison de l'id petitionnaire principal
487 if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND
488 !empty($this->postedIdDemandeur['petitionnaire_principal']) AND
489 $this->valIdDemandeur['petitionnaire_principal'] !=
490 $this->postedIdDemandeur['petitionnaire_principal']) {
491 // Ajout du nouveau lien
492 $this->addLinkDemandeDemandeur($this->postedIdDemandeur['petitionnaire_principal'], true, $db, $DEBUG);
493 if(!empty($this->valIdDemandeur['petitionnaire_principal'])) {
494 $this->deleteLinkDemandeDemandeur($this->valIdDemandeur['petitionnaire_principal'], $db, $DEBUG);
495 }
496 }
497
498 // Comparaison du delegataire
499 if(isset($this->postedIdDemandeur['delegataire']) AND
500 !empty($this->postedIdDemandeur['delegataire']) AND
501 $this->valIdDemandeur['delegataire'] !=
502 $this->postedIdDemandeur['delegataire']) {
503 // Ajout du nouveau lien
504 $this->addLinkDemandeDemandeur($this->postedIdDemandeur['delegataire'], false, $db, $DEBUG);
505 if(!empty($this->valIdDemandeur['delegataire'])) {
506 $this->deleteLinkDemandeDemandeur($this->valIdDemandeur['delegataire'], $db, $DEBUG);
507 }
508 }
509
510 // Comparaison des different petitionnaires
511 if(isset($this->postedIdDemandeur['petitionnaire'])) {
512 // Suppression des liens non valides
513 foreach ($this->valIdDemandeur['petitionnaire'] as $petitionnaire) {
514 if(!in_array($petitionnaire, $this->postedIdDemandeur['petitionnaire'])) {
515 $this->deleteLinkDemandeDemandeur($petitionnaire, $db, $DEBUG);
516 }
517 }
518 // Ajout des nouveaux liens
519 foreach ($this->postedIdDemandeur['petitionnaire'] as $petitionnaire) {
520 if(!in_array($petitionnaire, $this->valIdDemandeur['petitionnaire'])) {
521 $this->addLinkDemandeDemandeur($petitionnaire, false, $db, $DEBUG);
522 }
523 }
524 }
525 }
526
527
528 /**
529 * Fonction permettant d'ajouter un lien
530 * entre la table demande et demandeur
531 **/
532 function addLinkDemandeDemandeur($id, $principal, $db, $DEBUG) {
533 $lienAjout = new lien_demande_demandeur(
534 "]",
535 $db,
536 $DEBUG);
537 $lien = array('lien_demande_demandeur' => "",
538 'petitionnaire_principal' => (($principal)?"t":"f"),
539 'demande' => $this->valF['demande'],
540 'demandeur' => $id);
541 $lienAjout->ajouter($lien, $db, $DEBUG);
542 $lienAjout->__destruct();
543 }
544
545 /**
546 * Fonction permettant de supprimer un lien
547 * entre la table demande et demandeur
548 **/
549 function deleteLinkDemandeDemandeur($id, $db, $DEBUG) {
550 // Suppression
551 $sql = "DELETE FROM ".DB_PREFIXE."lien_demande_demandeur ".
552 "WHERE demande=".$this->valF['demande'].
553 " AND demandeur=".$id;
554 // Execution de la requete de suppression de l'objet
555 $res = $db->query($sql);
556 // Logger
557 $this->f->addToLog("supprimer(): db->query(\"".$sql."\");", VERBOSE_MODE);
558 $this->f->isDatabaseError();
559
560 }
561
562 function isLinkDemandeDemandeurExist($idDemandeur) {
563 $sql = "SELECT count(*)
564 FROM ".DB_PREFIXE."lien_demande_demandeur
565 WHERE demande = ".$this->valF['demande'].
566 "AND demandeur = ".$idDemandeur;
567 $count = $this->f->db->getOne($sql);
568 $this->f->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE);
569 $this->f->isDatabaseError($count);
570 if ($count === 0) {
571 return false;
572 } else {
573 return true;
574 }
575
576 }
577
578 /**
579 * Methode de recupération des valeurs postées
580 **/
581 function getPostedValues() {
582 // Récupération des demandeurs dans POST
583 if (isset($_POST['petitionnaire_principal']) OR
584 isset($_POST['delegataire']) OR
585 isset($_POST['petitionnaire'])) {
586 if( isset($_POST['petitionnaire_principal']) AND
587 !empty($_POST['petitionnaire_principal'])) {
588 $this->postedIdDemandeur['petitionnaire_principal'] = $_POST['petitionnaire_principal'];
589 }
590 if( isset($_POST['delegataire']) AND
591 !empty($_POST['delegataire'])) {
592 $this->postedIdDemandeur['delegataire'] = $_POST['delegataire'];
593 }
594 if( isset($_POST['petitionnaire']) AND
595 !empty($_POST['petitionnaire'])) {
596 $this->postedIdDemandeur['petitionnaire'] = $_POST['petitionnaire'];
597 }
598 }
599 }
600 /**
601 * Méthode permettant de récupérer les id des demandeur liés à la demande ou
602 * liés au dossier d'autorisation
603 **/
604 function listeDemandeur($from, $id) {
605 // Récupération des demandeurs de la base
606 $sql = "SELECT demandeur.demandeur,
607 demandeur.type_demandeur,
608 lien_".$from."_demandeur.petitionnaire_principal
609 FROM ".DB_PREFIXE."lien_".$from."_demandeur
610 INNER JOIN ".DB_PREFIXE."demandeur
611 ON demandeur.demandeur=lien_".$from."_demandeur.demandeur
612 WHERE ".$from." = '".$id."'";
613 $res = $this->f->db->query($sql);
614 $this->f->addToLog("listeDemandeur() : ".$sql);
615 $this->f->isDatabaseError($res);
616 // Stoquage du résultat dans un tableau
617 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
618 if ($row['petitionnaire_principal'] == 't' AND
619 $row['type_demandeur']=="petitionnaire") {
620 $this->valIdDemandeur['petitionnaire_principal']=$row['demandeur'];
621 } elseif ($row['petitionnaire_principal'] == 'f' AND
622 $row['type_demandeur']=="petitionnaire"){
623 $this->valIdDemandeur['petitionnaire'][]=$row['demandeur'];
624 } elseif ($row['type_demandeur']=="delegataire"){
625 $this->valIdDemandeur['delegataire']=$row['demandeur'];
626 }
627 }
628 }
629
630
631 /**
632 * Surcharge du bouton retour afin de retourner sur la recherche de dossiers
633 * d'instruction existant
634 */
635 function retour($premier = 0, $recherche = "", $tricol = "") {
636
637 echo "\n<a class=\"retour\" ";
638 echo "href=\"";
639 //
640 if($this->getParameter("idx_dossier") != "") {
641 echo "tab.php?";
642 echo "obj=recherche_dossier";
643
644 } else {
645 if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) {
646 echo "form.php?";
647 } else {
648 echo "tab.php?";
649 }
650 echo "obj=".get_class($this);
651 if($this->getParameter("retour")=="form") {
652 echo "&amp;idx=".$this->getParameter("idx");
653 echo "&amp;action=3";
654 }
655 }
656 echo "&amp;premier=".$this->getParameter("premier");
657 echo "&amp;tricol=".$this->getParameter("tricol");
658 echo "&amp;recherche=".$this->getParameter("recherche");
659 echo "&amp;selectioncol=".$this->getParameter("selectioncol");
660 echo "&amp;advs_id=".$this->getParameter("advs_id");
661 echo "&amp;valide=".$this->getParameter("valide");
662 //
663 echo "\"";
664 echo ">";
665 //
666 echo _("Retour");
667 //
668 echo "</a>\n";
669
670 }
671
672
673 /**
674 * Ajout de la liste des demandeurs
675 */
676 function formSpecificContent($maj) {
677 if(!$this->correct AND $maj != 0) {
678 $this->listeDemandeur("demande", $this->val[array_search('demande', $this->champs)]);
679 }
680 // Si le paramètre idx_dossier est défini on récupère les demandeurs liés au dossier d'instruction
681 if($this->getParameter("idx_dossier") != "") {
682 $this->listeDemandeur("dossier", $this->getParameter("idx_dossier"));
683 }
684 if($maj < 2 AND !$this->correct) {
685 $linkable = true;
686 } else {
687 $linkable = false;
688 }
689
690 // Conteneur de la listes des demandeurs
691 echo "<div class=\"demande_hidden_bloc col_12\">";
692 echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">";
693 echo " <legend class=\"ui-corner-all ui-widget-content ui-state-active\">"
694 ._("Petitionnaire")."</legend>";
695 // Si des demandeurs sont liés à la demande
696 require_once "../obj/petitionnaire.class.php";
697 require_once "../obj/delegataire.class.php";
698
699 // Affichage du bloc pétitionnaire principal / délégataire
700 // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
701 echo "<div id=\"petitionnaire_principal_delegataire\">";
702 // Affichage de la synthèse
703 if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND
704 !empty($this->valIdDemandeur["petitionnaire_principal"])) {
705 $demandeur = new petitionnaire(
706 $this->valIdDemandeur["petitionnaire_principal"],
707 $this->f->db,false);
708 $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);
709 $demandeur -> __destruct();
710 } elseif ( isset ($this->postedIdDemandeur["petitionnaire_principal"]) AND
711 !empty($this->postedIdDemandeur["petitionnaire_principal"]) ) {
712 $demandeur = new petitionnaire(
713 $this->postedIdDemandeur["petitionnaire_principal"],
714 $this->f->db,false);
715 $demandeur -> afficherSynthese("petitionnaire_principal", $linkable);
716 $demandeur -> __destruct();
717 }
718 // Si en édition de formulaire
719 if($maj < 2 AND $this->correct != true) {
720 // Bouton d'ajout du pétitionnaire principal
721 // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
722 echo "<input id=\"add_petitionnaire_principal\"
723 class=\"ui-button ui-widget ui-state-default ui-corner-all\"
724 type=\"button\" value=\""._("Saisir le petitionnaire principal")."\"/>";
725 // Bouton d'ajout du delegataire
726 // L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
727 echo "<div id=\"delegataire\">";
728 echo " <span class=\"om-icon om-icon-16 om-icon-fix arrow-right-16\">></span> ";
729
730 // Affichage de la synthèse
731 if (isset ($this->valIdDemandeur["delegataire"]) AND
732 !empty($this->valIdDemandeur["delegataire"])) {
733 $demandeur = new delegataire($this->valIdDemandeur["delegataire"],
734 $this->f->db,false);
735 $demandeur -> afficherSynthese("delegataire", $linkable);
736 $demandeur -> __destruct();
737 } elseif ( isset ($this->postedIdDemandeur["delegataire"]) AND
738 !empty($this->postedIdDemandeur["delegataire"]) ) {
739 $demandeur = new delegataire($this->postedIdDemandeur["delegataire"],
740 $this->f->db,false);
741 $demandeur -> afficherSynthese("delegataire", $linkable);
742 $demandeur -> __destruct();
743 }
744 echo "<input id=\"add_delegataire\"
745 class=\"ui-button ui-widget ui-state-default ui-corner-all\"
746 type=\"button\" value=\""._("Saisir le delegataire")."\"/>";
747 echo "</div>";
748 }
749 echo "</div>";
750 // Bloc des pétitionnaires secondaires
751 // L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
752 echo "<div id=\"listePetitionnaires\">";
753
754 // Affichage de la synthèse
755 if (isset ($this->valIdDemandeur["petitionnaire"]) AND
756 !empty($this->valIdDemandeur["petitionnaire"])) {
757
758 foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) {
759 $demandeur = new petitionnaire($petitionnaire,
760 $this->f->db,false);
761 $demandeur -> afficherSynthese("petitionnaire", $linkable);
762 $demandeur -> __destruct();
763 }
764
765 } elseif ( isset ($this->postedIdDemandeur["petitionnaire"]) AND
766 !empty($this->postedIdDemandeur["petitionnaire"]) ) {
767 foreach ($this->postedIdDemandeur["petitionnaire"] as $petitionnaire) {
768 $demandeur = new petitionnaire($petitionnaire,
769 $this->f->db,false);
770 $demandeur -> afficherSynthese("petitionnaire", $linkable);
771 $demandeur -> __destruct();
772 }
773 }
774 if ($maj < 2 AND !$this->correct) {
775 // L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS
776 echo "<input id=\"add_petitionnaire\"
777 class=\"ui-button ui-widget ui-state-default ui-corner-all\"
778 type=\"button\" value=\""._("Ajouter un petitionnaire")."\"/>";
779 }
780 echo "</div>";
781 echo "</fieldset>";
782 echo "</div>";
783 }
784
785 }// fin classe
786 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26