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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1063 - (show annotations)
Fri Dec 14 10:18:55 2012 UTC (12 years, 1 month ago) by vpihour
File size: 35571 byte(s)
Code xHTML valide

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26