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 |
var $autreDossierEnCour; |
17 |
|
18 |
function demande($id,&$db,$debug) { |
19 |
$this->constructeur($id,$db,$debug); |
20 |
}// fin constructeur |
21 |
|
22 |
function setValF($val) { |
23 |
parent::setValF($val); |
24 |
// Récupération des id demandeurs postés |
25 |
$this->getPostedValues(); |
26 |
//$this->valIdDemandeur=$this->postedIdDemandeur; |
27 |
} |
28 |
|
29 |
/** |
30 |
* Méthode permettant de récupérer les valeurs du dossier d'autorisation |
31 |
* correspondant à la nouvelle demande |
32 |
*/ |
33 |
function getValFromDossier($dossier_autorisation) { |
34 |
include "../sql/pgsql/demande.form.inc.php"; |
35 |
$sql=str_replace("<idx>",$this->getParameter("idx_dossier"), |
36 |
$sql_infos_dossier); |
37 |
$res = $this->db->query($sql); |
38 |
$this->f->addToLog("getValFromDossier(): db->query(\"".$sql."\")", VERBOSE_MODE); |
39 |
if ( database::isError($res)){ |
40 |
die(); |
41 |
} |
42 |
$row = & $res->fetchRow(DB_FETCHMODE_ASSOC); |
43 |
return $row; |
44 |
} |
45 |
|
46 |
/* |
47 |
* La date du jour par défaut dans le champs date_demande |
48 |
* Put the date of the day by default into the field date_demande |
49 |
*/ |
50 |
function setVal(&$form, $maj, $validation, &$db) { |
51 |
if($maj == 0) { |
52 |
$form->setVal("date_demande",date('d/m/Y')); |
53 |
|
54 |
// Récupération des valeurs du dossier d'autorisation correspondant |
55 |
if($this->getParameter("idx_dossier") != "") { |
56 |
$val_autorisation = $this->getValFromDossier( |
57 |
$this->getParameter("idx_dossier")); |
58 |
foreach($val_autorisation as $champ => $value) { |
59 |
$form->setVal($champ,$value); |
60 |
} |
61 |
} |
62 |
} |
63 |
} |
64 |
function getDataSubmit() { |
65 |
|
66 |
$datasubmit = parent::getDataSubmit(); |
67 |
if($this->getParameter("idx_dossier") != "") { |
68 |
$datasubmit .= "&idx_dossier=".$this->getParameter("idx_dossier"); |
69 |
} |
70 |
return $datasubmit; |
71 |
} |
72 |
|
73 |
/** |
74 |
* Méthode de verification du contenu |
75 |
*/ |
76 |
function verifier($val, &$db, $DEBUG) { |
77 |
parent::verifier($val, $db, $DEBUG); |
78 |
if(!isset($this->postedIdDemandeur["petitionnaire_principal"]) OR |
79 |
empty($this->postedIdDemandeur["petitionnaire_principal"])) { |
80 |
$this->correct = false; |
81 |
$this->addToMessage(_("La saisie d'un petitionnaire principal est obligatoire.")); |
82 |
} |
83 |
} |
84 |
|
85 |
/** |
86 |
* Configuration des select |
87 |
*/ |
88 |
function setSelect(&$form, $maj,&$db,$debug) { |
89 |
parent::setSelect($form, $maj,$db,$debug); |
90 |
|
91 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc.php")) |
92 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc.php"); |
93 |
elseif(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
94 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
95 |
|
96 |
// Si en ajout |
97 |
if ($maj == 0) { |
98 |
//Récupération de paramètre pour le rechargement ajax du select |
99 |
$idx_dossier = $this->getParameter("idx_dossier"); |
100 |
$datd = $this->getParameter("datd"); |
101 |
|
102 |
$contenu = array(); |
103 |
|
104 |
$sql_demande_type = "SELECT demande_type.demande_type, demande_type.libelle FROM ".DB_PREFIXE."demande_type |
105 |
LEFT OUTER JOIN ".DB_PREFIXE."lien_demande_type_etat_dossier_autorisation |
106 |
ON lien_demande_type_etat_dossier_autorisation.demande_type=demande_type.demande_type |
107 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier_autorisation |
108 |
ON lien_demande_type_etat_dossier_autorisation.etat_dossier_autorisation= |
109 |
dossier_autorisation.etat_dossier_autorisation |
110 |
LEFT OUTER JOIN ".DB_PREFIXE."dossier |
111 |
ON dossier.dossier_autorisation=dossier_autorisation.dossier_autorisation"; |
112 |
|
113 |
|
114 |
// Ajout de filtre sur la requête (initial) |
115 |
if(isset($idx_dossier) AND $idx_dossier != "") { |
116 |
$sql_demande_type .= " WHERE demande_type.demande_nature = 2 "; |
117 |
|
118 |
// ajout du numéro de dossier existant pour tester l'état du DA |
119 |
$sql_demande_type .= "AND dossier.dossier = '".$idx_dossier."' "; |
120 |
} else { |
121 |
$sql_demande_type .= " WHERE demande_type.demande_nature = 1 "; |
122 |
} |
123 |
if(isset($_POST["dossier_autorisation_type_detaille"]) AND $_POST["dossier_autorisation_type_detaille"] != "") { |
124 |
$datd = $_POST["dossier_autorisation_type_detaille"]; |
125 |
} |
126 |
// Ajout de filtre sur la requête (dossier_autorisation_type_detaille) |
127 |
if(isset($datd) AND $datd != "") { |
128 |
$sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd; |
129 |
} else { |
130 |
$datd = $this->getVal("dossier_autorisation_type_detaille"); |
131 |
if ($datd != "") { |
132 |
$sql_demande_type .= " AND demande_type.dossier_autorisation_type_detaille = ".$datd; |
133 |
} |
134 |
} |
135 |
$sql_demande_type .= " ORDER BY demande_type.libelle"; |
136 |
$res = $db->query($sql_demande_type); |
137 |
|
138 |
// logger |
139 |
$this->f->addToLog("setSelect(): db->query(\"".$sql_demande_type."\");", |
140 |
VERBOSE_MODE); |
141 |
if ( database::isError($res)){ |
142 |
die(); |
143 |
} |
144 |
|
145 |
$contenu[0][0] = ''; |
146 |
$contenu[1][0] = _('choisir')." "._("demande_type"); |
147 |
|
148 |
$k=1; |
149 |
while($row =& $res->fetchRow()){ |
150 |
|
151 |
$contenu[0][$k] = $row[0]; |
152 |
$contenu[1][$k] = $row[1]; |
153 |
$k++; |
154 |
} |
155 |
|
156 |
$form->setSelect("demande_type", $contenu); |
157 |
} |
158 |
|
159 |
} |
160 |
/* |
161 |
* Ajout du fielset |
162 |
* Add fieldset |
163 |
*/ |
164 |
function setLayout(&$form, $maj){ |
165 |
if ( $maj < 2 OR $maj == 3 ) { |
166 |
|
167 |
/*Champ sur lequel s'ouvre le bloc 1 */ |
168 |
$form->setBloc('dossier_autorisation_type_detaille','D',"","dossier_type col_8"); |
169 |
|
170 |
$form->setFieldset('dossier_autorisation_type_detaille','D' |
171 |
,_('Type de dossier/demande')); |
172 |
$form->setFieldset('demande_type','F',''); |
173 |
|
174 |
$form->setBloc('demande_type','F'); |
175 |
/*Fin bloc 1*/ |
176 |
|
177 |
/*Champ sur lequel s'ouvre le bloc 2 */ |
178 |
$form->setBloc('date_demande','D',"","col_4 demande_hidden_bloc"); |
179 |
$form->setFieldset('date_demande','D',_('Date de la demande')); |
180 |
$form->setFieldset('date_demande','F',''); |
181 |
$form->setBloc('date_demande','F'); |
182 |
/*Fin bloc 2*/ |
183 |
|
184 |
/*Champ sur lequel s'ouvre le bloc 3 */ |
185 |
$form->setBloc('terrain_references_cadastrales','D',"", |
186 |
"localisation col_12 demande_hidden_bloc"); |
187 |
$form->setFieldset('terrain_references_cadastrales','D',_('Localisation du terrain')); |
188 |
$form->setFieldset('terrain_superficie','F',''); |
189 |
$form->setBloc('terrain_superficie','F'); |
190 |
/*Fin bloc 4*/ |
191 |
|
192 |
} |
193 |
} |
194 |
|
195 |
/* |
196 |
* Ajoute des actions sur les deux premiers select |
197 |
* Add actions on the two first select |
198 |
*/ |
199 |
function setOnchange(&$form,$maj){ |
200 |
parent::setOnchange($form,$maj); |
201 |
|
202 |
$form->setOnchange("dossier_autorisation_type_detaille","changeDemandeType();"); |
203 |
$form->setOnchange("demande_type","showFormsDemande();"); |
204 |
} |
205 |
|
206 |
function setLib(&$form,$maj) { |
207 |
parent::setLib($form,$maj); |
208 |
//libelle des champs |
209 |
|
210 |
$form->setLib('complement',_('terrain_adresse')); |
211 |
} |
212 |
/* |
213 |
* Cache le champ terrain_references_cadastrales |
214 |
* Hide the fiels terrain_references_cadastrales |
215 |
*/ |
216 |
function setType(&$form,$maj) { |
217 |
parent::setType($form,$maj); |
218 |
|
219 |
$form->setType('dossier_instruction', 'hidden'); |
220 |
$form->setType('dossier_autorisation', 'hidden'); |
221 |
|
222 |
$form->setType('instruction_recepisse', 'hidden'); |
223 |
$form->setType('arrondissement', 'hidden'); |
224 |
|
225 |
// Si il s'agit d'une demande sur dossier existant on desactive tous les champs |
226 |
// sauf demande_type |
227 |
if(($maj == 0 AND $this-> getParameter("idx_dossier"))) { |
228 |
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
229 |
$form->setType('terrain_references_cadastrales', 'hiddenstatic'); |
230 |
$form->setType('terrain_adresse_voie_numero', 'hiddenstatic'); |
231 |
$form->setType('complement', 'hiddenstatic'); |
232 |
$form->setType('terrain_adresse_lieu_dit', 'hiddenstatic'); |
233 |
$form->setType('terrain_adresse_localite', 'hiddenstatic'); |
234 |
$form->setType('terrain_adresse_code_postal', 'hiddenstatic'); |
235 |
$form->setType('terrain_adresse_bp', 'hiddenstatic'); |
236 |
$form->setType('terrain_adresse_cedex', 'hiddenstatic'); |
237 |
$form->setType('terrain_superficie', 'hiddenstatic'); |
238 |
} |
239 |
if($maj == 1) { |
240 |
$form->setType('dossier_autorisation_type_detaille', 'selecthiddenstatic'); |
241 |
$form->setType('demande_type', 'selecthiddenstatic'); |
242 |
} |
243 |
if($maj == 3) { |
244 |
$form->setType('terrain_references_cadastrales', 'referencescadastralesstatic'); |
245 |
} |
246 |
|
247 |
} |
248 |
|
249 |
/** |
250 |
* Méthode permettant d'ajouter un dossier d'autorisation |
251 |
*/ |
252 |
function ajoutDossierAutorisation($id, &$db, $val, $DEBUG){ |
253 |
require_once '../obj/dossier_autorisation.class.php'; |
254 |
$dossier_autorisation = new dossier_autorisation("]",$db,$DEBUG); |
255 |
$id_etat_initial_da = $this->f->getParameter('etat_initial_dossier_autorisation'); |
256 |
$error = false; |
257 |
|
258 |
// Vérification de l'existance d'un état initial des DA dans la table om_parametre |
259 |
// afin d'éviter d'eventuelle erreur de base de données |
260 |
if(isset($id_etat_initial_da)) { |
261 |
$sql = "SELECT count(*) FROM ".DB_PREFIXE."etat_dossier_autorisation |
262 |
WHERE etat_dossier_autorisation = ".$id_etat_initial_da; |
263 |
$count = $this->db->getOne($sql); |
264 |
$this->f->addToLog("ajoutDossierAutorisation() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
265 |
if ( database::isError($count)){ |
266 |
die(); |
267 |
} |
268 |
if($count != 1) { |
269 |
$error = true; |
270 |
} else { |
271 |
// La méthode ajouter prend en paramètre un tableau associatif |
272 |
// contenant toutes les champs de la classe instanciée, |
273 |
// d'où l'initialisation du tableau en bouclant sur la liste des champs du DA |
274 |
foreach($dossier_autorisation->champs as $value) { |
275 |
$valAuto[$value] = NULL; |
276 |
} |
277 |
// Définition des valeurs à insérer |
278 |
$valAuto['dossier_autorisation']=""; |
279 |
$valAuto['exercice']=NULL; |
280 |
$valAuto['insee']=NULL; |
281 |
$valAuto['arrondissement']=NULL; |
282 |
$valAuto['etat_dossier_autorisation']=$this->f->getParameter('etat_initial_dossier_autorisation'); |
283 |
$valAuto['erp_numero_batiment']=NULL; |
284 |
$valAuto['erp_ouvert']=NULL; |
285 |
$valAuto['erp_arrete_decision']=NULL; |
286 |
$valAuto['dossier_autorisation_type_detaille']=$this->valF['dossier_autorisation_type_detaille']; |
287 |
$valAuto['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
288 |
$valAuto['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
289 |
$valAuto['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
290 |
$valAuto['complement']=$this->valF['complement']; |
291 |
$valAuto['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
292 |
$valAuto['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
293 |
$valAuto['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
294 |
$valAuto['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
295 |
$valAuto['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
296 |
$valAuto['terrain_superficie']=$this->valF['terrain_superficie']; |
297 |
$valAuto['numero_version']=-1; |
298 |
// Ajout du dossier dans la base |
299 |
$dossier_autorisation->ajouter($valAuto, $db, $DEBUG); |
300 |
// Liaison du dossier ajouter à la demande |
301 |
$this->valF['dossier_autorisation'] = $dossier_autorisation->valF['dossier_autorisation']; |
302 |
} |
303 |
} else { |
304 |
$error = true; |
305 |
} |
306 |
// Affichage de l'erreur et stop de l'affichage |
307 |
if( $error ) { |
308 |
echo "</div>"; |
309 |
$class = "error"; |
310 |
$message = _("Erreur de parametrage. Contactez votre administrateur."); |
311 |
$this->f->displayMessage($class, $message); |
312 |
die(); |
313 |
} |
314 |
|
315 |
} |
316 |
|
317 |
function getCodeDemandeType($demande_type){ |
318 |
|
319 |
$sql = "SELECT |
320 |
code |
321 |
FROM |
322 |
".DB_PREFIXE."demande_type |
323 |
WHERE |
324 |
demande_type = ".$demande_type; |
325 |
$codeDemandeType = $this->db->getOne($sql); |
326 |
$this->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE); |
327 |
|
328 |
return $codeDemandeType; |
329 |
} |
330 |
|
331 |
/** |
332 |
* Méthode permettant d'ajouter un dossier d'instruction |
333 |
*/ |
334 |
function ajoutDossierInstruction($id, &$db, $val, $DEBUG, $dossier_instruction_type){ |
335 |
require_once '../obj/dossier.class.php'; |
336 |
$dossier = new dossier("]",$db,$DEBUG); |
337 |
foreach($dossier->champs as $value) { |
338 |
$valInstr[$value] = NULL; |
339 |
} |
340 |
require_once '../obj/dossier_autorisation_type_detaille.class.php'; |
341 |
$datd = new dossier_autorisation_type_detaille( |
342 |
$this->valF['dossier_autorisation_type_detaille'],$db,$DEBUG); |
343 |
|
344 |
/*Ajout de la variable dossier_instruction_type à l'objet dossier pour le |
345 |
* versionning |
346 |
*/ |
347 |
$dossier->setDossierInstructionType($dossier_instruction_type); |
348 |
|
349 |
// Définition des valeurs à entrée dans la table |
350 |
$valInstr['dossier_instruction_type']=$dossier_instruction_type; |
351 |
$valInstr['date_depot']=$this->dateDBToForm($this->valF['date_demande']); |
352 |
$valInstr['date_dernier_depot']=$this->dateDBToForm($this->valF['date_demande']); |
353 |
$valInstr['date_demande']=$this->dateDBToForm($this->valF['date_demande']); |
354 |
$valInstr['depot_initial']=$this->dateDBToForm($this->valF['date_demande']); |
355 |
$valInstr['terrain_references_cadastrales']=$this->valF['terrain_references_cadastrales']; |
356 |
$valInstr['terrain_adresse_voie_numero']=$this->valF['terrain_adresse_voie_numero']; |
357 |
$valInstr['complement']=$this->valF['complement']; |
358 |
$valInstr['terrain_adresse_lieu_dit']=$this->valF['terrain_adresse_lieu_dit']; |
359 |
$valInstr['terrain_adresse_localite']=$this->valF['terrain_adresse_localite']; |
360 |
$valInstr['terrain_adresse_code_postal']=$this->valF['terrain_adresse_code_postal']; |
361 |
$valInstr['terrain_adresse_bp']=$this->valF['terrain_adresse_bp']; |
362 |
$valInstr['terrain_adresse_cedex']=$this->valF['terrain_adresse_cedex']; |
363 |
$valInstr['terrain_superficie']=$this->valF['terrain_superficie']; |
364 |
$valInstr['description']=""; |
365 |
$valInstr['dossier_autorisation']=$this->valF['dossier_autorisation']; |
366 |
|
367 |
/* |
368 |
* Gestion de la qualification |
369 |
* */ |
370 |
//Récupérer le code du type de la demande |
371 |
$codeDemandeType = $this->getCodeDemandeType($val['demande_type']); |
372 |
|
373 |
//Marque le dossier comme à qualifier selon le type de dossier d'instruction |
374 |
if ( strcasecmp($codeDemandeType, "DI") == 0 || |
375 |
strcasecmp($codeDemandeType, "DT") == 0 || |
376 |
strcasecmp($codeDemandeType, "DM") == 0 || |
377 |
strcasecmp($codeDemandeType, "DP") == 0 || |
378 |
strcasecmp($codeDemandeType, "DTP") == 0 || |
379 |
strcasecmp($codeDemandeType, "DAACT") == 0 || |
380 |
strcasecmp($codeDemandeType, "DOC") == 0 ){ |
381 |
|
382 |
$valInstr['a_qualifier'] = TRUE; |
383 |
} |
384 |
|
385 |
// Récupération du cerfa pour le type d'instruction sélectionnée et valide |
386 |
$sql = "SELECT |
387 |
dossier_instruction_type.cerfa |
388 |
FROM |
389 |
".DB_PREFIXE."dossier_instruction_type |
390 |
JOIN |
391 |
".DB_PREFIXE."cerfa |
392 |
ON |
393 |
dossier_instruction_type.cerfa = cerfa.cerfa |
394 |
WHERE |
395 |
now()<=om_validite_fin |
396 |
AND now()>=om_validite_debut |
397 |
AND dossier_instruction_type=".$dossier_instruction_type; |
398 |
$valInstr['cerfa'] = $db->getOne($sql); |
399 |
$this->f->addToLog("ajoutDossierInstruction() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
400 |
if ( database::isError($valInstr['cerfa'])){ |
401 |
die(); |
402 |
} |
403 |
$dossier->ajouter($valInstr, $db, $DEBUG); |
404 |
// Liaison du dossier ajouter à la demande |
405 |
$this->valF['dossier_instruction'] = $dossier->valF['dossier']; |
406 |
} |
407 |
|
408 |
/** |
409 |
* Méthode permettant d'ajouter les données techniques au dossier d'instruction |
410 |
*/ |
411 |
function ajoutDonneesTechniques($id, &$db, $val, $DEBUG){ |
412 |
|
413 |
require_once '../obj/donnees_techniques.class.php'; |
414 |
$donnees_techniques = new donnees_techniques("]",$db,$DEBUG); |
415 |
|
416 |
// Champs tous à NULL car seul le champ concernant le dossier d'instruction sera rempli |
417 |
foreach($donnees_techniques->champs as $value) { |
418 |
$val[$value] = NULL; |
419 |
} |
420 |
|
421 |
// Ajout du numéro de dossier d'instruction |
422 |
$val['dossier_instruction']=$this->valF['dossier_instruction']; |
423 |
|
424 |
// Ajout des données techniques |
425 |
$donnees_techniques->ajouter($val, $db, $DEBUG); |
426 |
} |
427 |
|
428 |
/** |
429 |
* Ajout des liens demandeurs / dossier d'autorisation |
430 |
**/ |
431 |
function ajoutLiensDossierAutorisation($id, &$db, $val, $DEBUG) { |
432 |
// Création des liens entre le dossier autorisation et les demandeurs |
433 |
include '../sql/pgsql/demande.form.inc.php'; |
434 |
require_once '../obj/lien_dossier_autorisation_demandeur.class.php'; |
435 |
$ldad = new lien_dossier_autorisation_demandeur("]",$db,$DEBUG); |
436 |
// Recupération des demandeurs liés à la demande |
437 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
438 |
$res = $db->query($sql); |
439 |
$this->f->addToLog("ajoutLiensDossierAutorisation() : db->query(\"".$sql."\");", VERBOSE_MODE); |
440 |
if ( database::isError($res)){ |
441 |
die(); |
442 |
} |
443 |
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
444 |
$row['lien_dossier_autorisation_demandeur'] = NULL; |
445 |
$row['dossier_autorisation'] = $this->valF['dossier_autorisation']; |
446 |
$ldad->ajouter($row, $db, $DEBUG); |
447 |
} |
448 |
} |
449 |
|
450 |
/** |
451 |
* Ajout des liens demandeurs / dossier d'autorisation |
452 |
**/ |
453 |
function ajoutLiensDossierInstruction($id, &$db, $val, $DEBUG) { |
454 |
// Création des liens entre le dossier instruction et les demandeurs |
455 |
include '../sql/pgsql/demande.form.inc.php'; |
456 |
require_once '../obj/lien_dossier_demandeur.class.php'; |
457 |
$ldd = new lien_dossier_demandeur("]",$db,$DEBUG); |
458 |
// Recupération des demandeurs liés à la demande |
459 |
$sql = str_replace("<demande>",$this->valF['demande'],$sql_lien_demande_demandeur); |
460 |
$res = $db->query($sql); |
461 |
$this->f->addToLog("ajoutLiensDossierInstruction() : db->query(\"".$sql."\");", VERBOSE_MODE); |
462 |
if ( database::isError($res)){ |
463 |
die(); |
464 |
} |
465 |
while($row = &$res->fetchRow(DB_FETCHMODE_ASSOC)) { |
466 |
$row['lien_dossier_demandeur'] = NULL; |
467 |
$row['dossier'] = $this->valF['dossier_instruction']; |
468 |
$ldd->ajouter($row, $db, $DEBUG); |
469 |
} |
470 |
} |
471 |
|
472 |
/* |
473 |
* Récupère l'identifiant d'un arrondissement à partir d'un code postal |
474 |
*/ |
475 |
function getArrondissement($terrain_adresse_code_postal){ |
476 |
|
477 |
$arrondissement = NULL; |
478 |
|
479 |
$sql = "SELECT |
480 |
arrondissement |
481 |
FROM |
482 |
".DB_PREFIXE."arrondissement |
483 |
WHERE |
484 |
code_postal = '$terrain_adresse_code_postal' "; |
485 |
$this->addToLog("demande.class.php : ".$sql." execute <br>", EXTRA_VERBOSE_MODE); |
486 |
|
487 |
$res = $this->db->query($sql); |
488 |
$this->f->addToLog("getArrondissement() : db->query(\"".$sql."\")", VERBOSE_MODE); |
489 |
if ( database::isError($res)){ |
490 |
die(); |
491 |
} |
492 |
|
493 |
if( $res->numrows() > 0 ) { |
494 |
|
495 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
496 |
$arrondissement = $row['arrondissement']; |
497 |
} |
498 |
|
499 |
return $arrondissement; |
500 |
} |
501 |
|
502 |
/* |
503 |
* Récupère l'évènement lié à un type de demande |
504 |
*/ |
505 |
function getEvenement($demande_type){ |
506 |
|
507 |
$evenement = NULL; |
508 |
|
509 |
$sql = |
510 |
"SELECT |
511 |
evenement |
512 |
FROM |
513 |
".DB_PREFIXE."demande_type |
514 |
WHERE |
515 |
demande_type = $demande_type"; |
516 |
|
517 |
$res = $this->db->query($sql); |
518 |
$this->f->addToLog("getEvenement() : db->query(\"".$sql."\")", VERBOSE_MODE); |
519 |
if ( database::isError($res)){ |
520 |
die(); |
521 |
} |
522 |
|
523 |
if ( $res->numrows() > 0 ){ |
524 |
|
525 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
526 |
$evenement = $row['evenement']; |
527 |
} |
528 |
|
529 |
return $evenement; |
530 |
} |
531 |
|
532 |
/* |
533 |
* Récupère la lettre type lié à un événement |
534 |
*/ |
535 |
function getLettreType($evenement){ |
536 |
|
537 |
$lettretype = NULL; |
538 |
|
539 |
$sql = |
540 |
"SELECT |
541 |
lettretype |
542 |
FROM |
543 |
".DB_PREFIXE."evenement |
544 |
WHERE |
545 |
evenement = $evenement"; |
546 |
|
547 |
$res = $this->db->query($sql); |
548 |
$this->f->addToLog("getLettreType() : db->query(\"".$sql."\")", VERBOSE_MODE); |
549 |
if ( database::isError($res)){ |
550 |
die(); |
551 |
} |
552 |
|
553 |
if ( $res->numrows() > 0 ){ |
554 |
|
555 |
$row=& $res->fetchRow(DB_FETCHMODE_ASSOC); |
556 |
$lettretype = $row['lettretype']; |
557 |
} |
558 |
|
559 |
return $lettretype; |
560 |
} |
561 |
|
562 |
/** |
563 |
* Ajout des dossiers |
564 |
**/ |
565 |
function triggerAjouter($id, &$db, $val, $DEBUG){ |
566 |
include '../sql/pgsql/demande.form.inc.php'; |
567 |
if($this->valF["demande_type"] != NULL) { |
568 |
$res = $db->query(str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)); |
569 |
$this->f->addToLog("triggerAjouter() : db->query(\"".str_replace('<idx>', $this->valF['demande_type'], $sql_demande_type_details_by_id)."\")", VERBOSE_MODE); |
570 |
if ( database::isError($res)){ |
571 |
die(); |
572 |
} |
573 |
// Attribut permettant de définir si un dossier a été créé |
574 |
$this->ajoutDI = FALSE; |
575 |
$dossier_type = $res->fetchRow(DB_FETCHMODE_ASSOC); |
576 |
// Création du dossier_autorisation |
577 |
if($this->valF['dossier_autorisation'] == "") { |
578 |
$this->ajoutDossierAutorisation($id, $db, $val, $DEBUG); |
579 |
$this -> addToMessage(_("Creation du dossier d'autorisation no").$this->valF['dossier_autorisation']); |
580 |
} |
581 |
// Enregistrement du numéro dossier existant (il sera écrasé si un DI est créé) |
582 |
if ($this->getParameter("idx_dossier") != "") { |
583 |
$this->valF['dossier_instruction'] = $this->getParameter("idx_dossier"); |
584 |
} |
585 |
// Création du dossier d'instruction |
586 |
if($dossier_type['dossier_instruction_type'] != NULL) { |
587 |
$this->ajoutDossierInstruction($id, $db, $val, $DEBUG, $dossier_type['dossier_instruction_type']); |
588 |
$this -> addToMessage(_("Creation du dossier d'instruction no").$this->valF['dossier_instruction']); |
589 |
// Attribut permettant de définir si un dossier a été créé. |
590 |
$this->ajoutDI = TRUE; |
591 |
|
592 |
//Ajout des données techniques au dossier d'instruction |
593 |
$this->ajoutDonneesTechniques($id, $db, $val, $DEBUG); |
594 |
} |
595 |
|
596 |
/*Création du lien de téléchargement de récépissé de demande*/ |
597 |
if ( $this->valF['demande_type'] != "" && is_numeric($this->valF['demande_type']) |
598 |
&& isset($this->valF['dossier_instruction']) && $this->valF['dossier_instruction'] !== "" ){ |
599 |
|
600 |
/*Récupérer l'événement lié à ce type de demande*/ |
601 |
$evenement = $this->getEvenement($this->valF['demande_type']); |
602 |
|
603 |
/*Récupération de la lettre type de l'événement*/ |
604 |
$lettretype = $this->getLettreType($evenement); |
605 |
|
606 |
/*Création d'une nouvelle instruction avec cet événement*/ |
607 |
/*Données*/ |
608 |
$valInstr['instruction']=NULL; |
609 |
|
610 |
$valInstr['destinataire']=$this->valF['dossier_instruction']; |
611 |
$valInstr['dossier']=$this->valF['dossier_instruction']; |
612 |
|
613 |
$valInstr['date_evenement']=date("d/m/Y"); |
614 |
$valInstr['evenement']=$evenement; |
615 |
$valInstr['lettretype']=$lettretype; |
616 |
$valInstr['complement']=""; |
617 |
$valInstr['complement2']=""; |
618 |
|
619 |
$valInstr['action']="initialisation"; |
620 |
$valInstr['delai']="2"; |
621 |
$valInstr['etat']="notifier"; |
622 |
$valInstr['accord_tacite']="Oui"; |
623 |
$valInstr['delai_notification']="1"; |
624 |
$valInstr['archive_delai']="0"; |
625 |
$valInstr['archive_date_complet']=NULL; |
626 |
$valInstr['archive_date_dernier_depot']=NULL; |
627 |
$valInstr['archive_date_rejet']=NULL; |
628 |
$valInstr['archive_date_limite']=NULL; |
629 |
$valInstr['archive_date_notification_delai']=NULL; |
630 |
$valInstr['archive_accord_tacite']="Non"; |
631 |
$valInstr['archive_etat']="initialiser"; |
632 |
$valInstr['archive_date_decision']=NULL; |
633 |
$valInstr['archive_avis']=""; |
634 |
$valInstr['archive_date_validite']=NULL; |
635 |
$valInstr['archive_date_achevement']=NULL; |
636 |
$valInstr['archive_date_chantier']=NULL; |
637 |
$valInstr['archive_date_conformite']=NULL; |
638 |
$valInstr['archive_incompletude']=NULL; |
639 |
$valInstr['archive_evenement_suivant_tacite']=""; |
640 |
$valInstr['archive_evenement_suivant_tacite_incompletude']=NULL; |
641 |
$valInstr['archive_etat_pendant_incompletude']=NULL; |
642 |
$valInstr['archive_date_limite_incompletude']=NULL; |
643 |
$valInstr['archive_delai_incompletude']=NULL; |
644 |
$valInstr['complement3']=""; |
645 |
$valInstr['complement4']=""; |
646 |
$valInstr['complement5']=""; |
647 |
$valInstr['complement6']=""; |
648 |
$valInstr['complement7']=""; |
649 |
$valInstr['complement8']=""; |
650 |
$valInstr['complement9']=""; |
651 |
$valInstr['complement10']=""; |
652 |
$valInstr['complement11']=""; |
653 |
$valInstr['complement12']=""; |
654 |
$valInstr['complement13']=""; |
655 |
$valInstr['complement14']=""; |
656 |
$valInstr['complement15']=""; |
657 |
$valInstr['avis_decision']=NULL; |
658 |
$valInstr['date_finalisation_courrier']=NULL; |
659 |
$valInstr['date_envoi_signature']=NULL; |
660 |
$valInstr['date_retour_signature']=NULL; |
661 |
$valInstr['date_envoi_rar']=NULL; |
662 |
$valInstr['date_retour_rar']=NULL; |
663 |
$valInstr['date_envoi_controle_legalite']=NULL; |
664 |
$valInstr['date_retour_controle_legalite']=NULL; |
665 |
$valInstr['signataire_arrete']=NULL; |
666 |
$valInstr['numero_arrete']=NULL; |
667 |
$valInstr['code_barres']=NULL; |
668 |
$valInstr['om_fichier_instruction']=NULL; |
669 |
$valInstr['om_final_instruction']=NULL; |
670 |
$valInstr['document_arrete']=NULL; |
671 |
|
672 |
/*Fichier requis*/ |
673 |
require_once '../obj/instruction.class.php'; |
674 |
|
675 |
/*Création d'un nouveau dossier*/ |
676 |
$instruction = new instruction("]",$db,$DEBUG); |
677 |
$instruction->valF = ""; |
678 |
$instruction->ajouter($valInstr, $db, $DEBUG); |
679 |
|
680 |
//Finalisation du document |
681 |
$_GET['obj']='instruction'; |
682 |
$_GET['idx']=$instruction->valF[$instruction->clePrimaire]; |
683 |
$instruction = new instruction($_GET['idx'],$db,$DEBUG); |
684 |
$res = $instruction->finaliser('', 1, '', ''); |
685 |
|
686 |
/*Si la création a réussie*/ |
687 |
if ( $instruction->valF['instruction'] != "" ){ |
688 |
|
689 |
/*Affichage du récépissé de la demande*/ |
690 |
$this->valF['instruction_recepisse'] = $instruction->valF['instruction']; |
691 |
$this -> addToMessage("<br/><a |
692 |
class='lien' |
693 |
href='" |
694 |
.((isset($res['pdf'])&&$instruction->valF['om_final_instruction'])?$res['pdf']: |
695 |
"../pdf/pdflettretype.php?obj=".$lettretype."&idx=".$instruction->valF['instruction'])."' |
696 |
target='_blank'> |
697 |
<span |
698 |
class=\"om-icon om-icon-16 om-icon-fix pdf-16\" |
699 |
title=\""._("Telecharger le recepisse de la demande")."\">". |
700 |
_("Telecharger le recepisse de la demande"). |
701 |
"</span> |
702 |
". |
703 |
_("Telecharger le recepisse de la demande")." |
704 |
</a><br/>"); |
705 |
} |
706 |
/*Sinon affiche un message d'erreur*/ |
707 |
else { |
708 |
|
709 |
$this -> addToMessage(_("Une erreur s'est produite lors de la creation du recepisse")); |
710 |
} |
711 |
} |
712 |
|
713 |
/*Ajout de l'arrondissement à partir du code postal*/ |
714 |
if ( !is_null($this->valF["terrain_adresse_code_postal"]) && is_numeric($this->valF["terrain_adresse_code_postal"]) ){ |
715 |
|
716 |
$this->valF["arrondissement"] = $this->getArrondissement($this->valF["terrain_adresse_code_postal"]); |
717 |
} |
718 |
} |
719 |
} |
720 |
|
721 |
/** |
722 |
* Ajout des délégataires et pétitionnaires |
723 |
**/ |
724 |
function triggerAjouterApres($id, &$db, $val, $DEBUG){ |
725 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
726 |
|
727 |
// Ajout des lliens entre dossier_autorisation et demandeur |
728 |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] == "" ) { |
729 |
$this->ajoutLiensDossierAutorisation($id, $db, $val, $DEBUG); |
730 |
} |
731 |
// Ajout des lliens entre dossier et demandeur |
732 |
if($this->ajoutDI === TRUE) { |
733 |
$this->ajoutLiensDossierInstruction($id, $db, $val, $DEBUG); |
734 |
} |
735 |
|
736 |
// Duplication des lots et liaison au nouveau dossier_d'instruction |
737 |
if(!empty($this->valF['dossier_autorisation']) AND $val['dossier_autorisation'] != "" ) { |
738 |
$this->lienLotDossierInstruction($id, $db, $val, $DEBUG); |
739 |
} |
740 |
} |
741 |
|
742 |
/*Ajout du lien demande / demandeur(s)*/ |
743 |
function triggerModifierApres($id, &$db, $val, $DEBUG){ |
744 |
$this->listeDemandeur("demande",$this->val[array_search('demande', $this->champs)]); |
745 |
$this->insertLinkDemandeDemandeur($db, $DEBUG); |
746 |
$this->valIdDemandeur=$this->postedIdDemandeur; |
747 |
|
748 |
} |
749 |
|
750 |
/** |
751 |
* Gestion des liens entre les lots du DA et le nouveau dossier |
752 |
**/ |
753 |
function lienLotDossierInstruction($id, $db, $val, $DEBUG) { |
754 |
require_once ("../obj/lot.class.php"); |
755 |
$lot = new lot("]", $db, $DEBUG); |
756 |
require_once ("../obj/lien_dossier_lot.class.php"); |
757 |
$ldl = new lien_dossier_lot("]", $db, $DEBUG); |
758 |
require_once ("../obj/lien_lot_demandeur.class.php"); |
759 |
$lld = new lien_lot_demandeur("]", $db, $DEBUG); |
760 |
|
761 |
|
762 |
$sqlLots = "SELECT * FROM ".DB_PREFIXE."lot |
763 |
WHERE dossier_autorisation = '".$this->valF['dossier_autorisation']."'"; |
764 |
$resLot = $db -> query($sqlLots); |
765 |
$this->f->addToLog("db->query(\"".$sqlLots."\");", VERBOSE_MODE); |
766 |
$this->f->isDatabaseError($resLot); |
767 |
while ($rowLot=& $resLot->fetchRow(DB_FETCHMODE_ASSOC)){ |
768 |
// Insertion du nouveau lot |
769 |
$valLot['lot'] = ""; |
770 |
$valLot['libelle'] = $rowLot['libelle']; |
771 |
$valLot['dossier_autorisation'] = NULL; |
772 |
$lot -> ajouter($valLot, $db, $DEBUG); |
773 |
|
774 |
//Insertion du lien entre le lot et le dossier d'instruction |
775 |
$valLdl['lien_dossier_lot'] = ""; |
776 |
$valLdl['dossier'] = $this->valF['dossier_instruction']; |
777 |
$valLdl['lot'] = $lot->valF['lot']; |
778 |
$ldl->ajouter($valLdl, $db, $DEBUG); |
779 |
|
780 |
//Insertion des liens entre dossier et les lots |
781 |
$sqlDemandeurs = "SELECT * FROM ".DB_PREFIXE."lien_lot_demandeur |
782 |
WHERE lot = ".$rowLot['lot']; |
783 |
$res = $db -> query($sqlDemandeurs); |
784 |
$this->f->addToLog("lienLotDossierInstruction() : db->query(\"".$sqlDemandeurs."\");", VERBOSE_MODE); |
785 |
if ( database::isError($res)){ |
786 |
die(); |
787 |
} |
788 |
|
789 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
790 |
$valLld["lien_lot_demandeur"] = ""; |
791 |
$valLld["lot"]=$lot->valF['lot']; |
792 |
$valLld["demandeur"] = $row['demandeur']; |
793 |
$valLld["petitionnaire_principal"] = $row['petitionnaire_principal']; |
794 |
$lld->ajouter($valLld, $db, $DEBUG); |
795 |
} |
796 |
} |
797 |
} |
798 |
|
799 |
/** |
800 |
* Gestion des liens entre la demande et les demandeurs recemment ajoutés |
801 |
**/ |
802 |
function insertLinkDemandeDemandeur($db, $DEBUG) { |
803 |
// |
804 |
require_once "../obj/lien_demande_demandeur.class.php"; |
805 |
// Comparaison de l'id petitionnaire principal |
806 |
if(isset($this->postedIdDemandeur['petitionnaire_principal']) AND |
807 |
!empty($this->postedIdDemandeur['petitionnaire_principal']) AND |
808 |
$this->valIdDemandeur['petitionnaire_principal'] != |
809 |
$this->postedIdDemandeur['petitionnaire_principal']) { |
810 |
// Ajout du nouveau lien |
811 |
$this->addLinkDemandeDemandeur($this->postedIdDemandeur['petitionnaire_principal'], true, $db, $DEBUG); |
812 |
if(!empty($this->valIdDemandeur['petitionnaire_principal'])) { |
813 |
$this->deleteLinkDemandeDemandeur($this->valIdDemandeur['petitionnaire_principal'], $db, $DEBUG); |
814 |
} |
815 |
} |
816 |
|
817 |
// Comparaison du delegataire |
818 |
if(isset($this->postedIdDemandeur['delegataire']) AND |
819 |
!empty($this->postedIdDemandeur['delegataire']) AND |
820 |
$this->valIdDemandeur['delegataire'] != |
821 |
$this->postedIdDemandeur['delegataire']) { |
822 |
// Ajout du nouveau lien |
823 |
$this->addLinkDemandeDemandeur($this->postedIdDemandeur['delegataire'], false, $db, $DEBUG); |
824 |
if(!empty($this->valIdDemandeur['delegataire'])) { |
825 |
$this->deleteLinkDemandeDemandeur($this->valIdDemandeur['delegataire'], $db, $DEBUG); |
826 |
} |
827 |
} |
828 |
|
829 |
// Comparaison des different petitionnaires |
830 |
if(isset($this->postedIdDemandeur['petitionnaire'])) { |
831 |
// Suppression des liens non valides |
832 |
foreach ($this->valIdDemandeur['petitionnaire'] as $petitionnaire) { |
833 |
if(!in_array($petitionnaire, $this->postedIdDemandeur['petitionnaire'])) { |
834 |
$this->deleteLinkDemandeDemandeur($petitionnaire, $db, $DEBUG); |
835 |
} |
836 |
} |
837 |
// Ajout des nouveaux liens |
838 |
foreach ($this->postedIdDemandeur['petitionnaire'] as $petitionnaire) { |
839 |
if(!in_array($petitionnaire, $this->valIdDemandeur['petitionnaire'])) { |
840 |
$this->addLinkDemandeDemandeur($petitionnaire, false, $db, $DEBUG); |
841 |
} |
842 |
} |
843 |
} |
844 |
} |
845 |
|
846 |
|
847 |
/** |
848 |
* Fonction permettant d'ajouter un lien |
849 |
* entre la table demande et demandeur |
850 |
**/ |
851 |
function addLinkDemandeDemandeur($id, $principal, $db, $DEBUG) { |
852 |
$lienAjout = new lien_demande_demandeur( |
853 |
"]", |
854 |
$db, |
855 |
$DEBUG); |
856 |
$lien = array('lien_demande_demandeur' => "", |
857 |
'petitionnaire_principal' => (($principal)?"t":"f"), |
858 |
'demande' => $this->valF['demande'], |
859 |
'demandeur' => $id); |
860 |
$lienAjout->ajouter($lien, $db, $DEBUG); |
861 |
$lienAjout->__destruct(); |
862 |
} |
863 |
|
864 |
/** |
865 |
* Fonction permettant de supprimer un lien |
866 |
* entre la table demande et demandeur |
867 |
**/ |
868 |
function deleteLinkDemandeDemandeur($id, $db, $DEBUG) { |
869 |
// Suppression |
870 |
$sql = "DELETE FROM ".DB_PREFIXE."lien_demande_demandeur ". |
871 |
"WHERE demande=".$this->valF['demande']. |
872 |
" AND demandeur=".$id; |
873 |
// Execution de la requete de suppression de l'objet |
874 |
$res = $db->query($sql); |
875 |
// Logger |
876 |
$this->f->addToLog("deleteLinkDemandeDemandeur(): db->query(\"".$sql."\");", VERBOSE_MODE); |
877 |
if ( database::isError($res)){ |
878 |
die(); |
879 |
} |
880 |
|
881 |
} |
882 |
|
883 |
/* |
884 |
* Teste si le lien entre une demande et un demandeur existe |
885 |
* */ |
886 |
function isLinkDemandeDemandeurExist($idDemandeur) { |
887 |
$sql = "SELECT count(*) |
888 |
FROM ".DB_PREFIXE."lien_demande_demandeur |
889 |
WHERE demande = ".$this->valF['demande']. |
890 |
"AND demandeur = ".$idDemandeur; |
891 |
$count = $this->f->db->getOne($sql); |
892 |
$this->f->addToLog("isLinkDemandeDemandeurExist() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
893 |
if ( database::isError($count)){ |
894 |
die(); |
895 |
} |
896 |
if ($count === 0) { |
897 |
return false; |
898 |
} else { |
899 |
return true; |
900 |
} |
901 |
|
902 |
} |
903 |
|
904 |
/** |
905 |
* Methode de recupération des valeurs postées |
906 |
**/ |
907 |
function getPostedValues() { |
908 |
// Récupération des demandeurs dans POST |
909 |
if (isset($_POST['petitionnaire_principal']) OR |
910 |
isset($_POST['delegataire']) OR |
911 |
isset($_POST['petitionnaire'])) { |
912 |
if( isset($_POST['petitionnaire_principal']) AND |
913 |
!empty($_POST['petitionnaire_principal'])) { |
914 |
$this->postedIdDemandeur['petitionnaire_principal'] = $_POST['petitionnaire_principal']; |
915 |
} |
916 |
if( isset($_POST['delegataire']) AND |
917 |
!empty($_POST['delegataire'])) { |
918 |
$this->postedIdDemandeur['delegataire'] = $_POST['delegataire']; |
919 |
} |
920 |
if( isset($_POST['petitionnaire']) AND |
921 |
!empty($_POST['petitionnaire'])) { |
922 |
$this->postedIdDemandeur['petitionnaire'] = $_POST['petitionnaire']; |
923 |
} |
924 |
} |
925 |
} |
926 |
|
927 |
/** |
928 |
* Méthode permettant de récupérer les id des demandeurs liés à la table |
929 |
* liée passée en paramètre |
930 |
* |
931 |
* @param string $from Table liée : "demande", "dossier", dossier_autorisation" |
932 |
* @param string $id Identifiant (clé primaire de la table liée en question) |
933 |
*/ |
934 |
function listeDemandeur($from, $id) { |
935 |
// Récupération des demandeurs de la base |
936 |
$sql = "SELECT demandeur.demandeur, |
937 |
demandeur.type_demandeur, |
938 |
lien_".$from."_demandeur.petitionnaire_principal |
939 |
FROM ".DB_PREFIXE."lien_".$from."_demandeur |
940 |
INNER JOIN ".DB_PREFIXE."demandeur |
941 |
ON demandeur.demandeur=lien_".$from."_demandeur.demandeur |
942 |
WHERE ".$from." = '".$id."'"; |
943 |
$res = $this->f->db->query($sql); |
944 |
$this->f->addToLog("listeDemandeur(): db->query(\"".$sql."\")", VERBOSE_MODE); |
945 |
if ( database::isError($res)){ |
946 |
die(); |
947 |
} |
948 |
// Stockage du résultat dans un tableau |
949 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
950 |
if ($row['petitionnaire_principal'] == 't' AND |
951 |
$row['type_demandeur']=="petitionnaire") { |
952 |
$this->valIdDemandeur['petitionnaire_principal']=$row['demandeur']; |
953 |
} elseif ($row['petitionnaire_principal'] == 'f' AND |
954 |
$row['type_demandeur']=="petitionnaire"){ |
955 |
$this->valIdDemandeur['petitionnaire'][]=$row['demandeur']; |
956 |
} elseif ($row['type_demandeur']=="delegataire"){ |
957 |
$this->valIdDemandeur['delegataire']=$row['demandeur']; |
958 |
} |
959 |
} |
960 |
} |
961 |
|
962 |
|
963 |
/** |
964 |
* Surcharge du bouton retour afin de retourner sur la recherche de dossiers |
965 |
* d'instruction existant |
966 |
*/ |
967 |
function retour($premier = 0, $recherche = "", $tricol = "") { |
968 |
|
969 |
echo "\n<a class=\"retour\" "; |
970 |
echo "href=\""; |
971 |
// |
972 |
if($this->getParameter("idx_dossier") != "") { |
973 |
echo "tab.php?"; |
974 |
echo "obj=recherche_dossier"; |
975 |
|
976 |
} else { |
977 |
if($this->getParameter("retour")=="form" AND !($this->getParameter("validation")>0 AND $this->getParameter("maj")==2 AND $this->correct)) { |
978 |
echo "form.php?"; |
979 |
} else { |
980 |
echo "tab.php?"; |
981 |
} |
982 |
echo "obj=".get_class($this); |
983 |
if($this->getParameter("retour")=="form") { |
984 |
echo "&idx=".$this->getParameter("idx"); |
985 |
echo "&action=3"; |
986 |
} |
987 |
} |
988 |
echo "&premier=".$this->getParameter("premier"); |
989 |
echo "&tricol=".$this->getParameter("tricol"); |
990 |
echo "&recherche=".$this->getParameter("recherche"); |
991 |
echo "&selectioncol=".$this->getParameter("selectioncol"); |
992 |
echo "&advs_id=".$this->getParameter("advs_id"); |
993 |
echo "&valide=".$this->getParameter("valide"); |
994 |
// |
995 |
echo "\""; |
996 |
echo ">"; |
997 |
// |
998 |
echo _("Retour"); |
999 |
// |
1000 |
echo "</a>\n"; |
1001 |
|
1002 |
} |
1003 |
|
1004 |
|
1005 |
/** |
1006 |
* Cette méthode permet d'afficher des informations spécifiques dans le |
1007 |
* formulaire de l'objet |
1008 |
* |
1009 |
* @param integer $maj Mode de mise à jour |
1010 |
*/ |
1011 |
function formSpecificContent($maj) { |
1012 |
|
1013 |
/** |
1014 |
* Gestion du bloc des demandeurs |
1015 |
*/ |
1016 |
// Si le mode est (modification ou suppression ou consultation) ET que |
1017 |
// le formulaire n'est pas correct (c'est-à-dire que le formulaire est |
1018 |
// actif) |
1019 |
if (!$this->correct AND $maj != 0) { |
1020 |
// Alors on récupère les demandeurs dans la table lien pour |
1021 |
// affectation des résultats dans this->valIdDemandeur |
1022 |
$this->listeDemandeur("demande", $this->val[array_search('demande', $this->champs)]); |
1023 |
} |
1024 |
|
1025 |
// Si le mode est (ajout ou modification) ET que le formulaire n'est pas |
1026 |
// correct (c'est-à-dire que le formulaire est actif) |
1027 |
if ($maj < 2 AND !$this->correct) { |
1028 |
// Alors on positionne le marqueur linkable a true qui permet |
1029 |
// d'afficher ou non les actions de gestion des demandeurs |
1030 |
$linkable = true; |
1031 |
} else { |
1032 |
// Sinon on positionne le marqueur linkable a false qui permet |
1033 |
// d'afficher ou non les actions de gestion des demandeurs |
1034 |
$linkable = false; |
1035 |
} |
1036 |
|
1037 |
// Affichage des demandeurs et des actions |
1038 |
// Conteneur de la listes des demandeurs |
1039 |
echo "<div id=\"liste_demandeur\" class=\"demande_hidden_bloc col_12\">"; |
1040 |
echo "<fieldset class=\"cadre ui-corner-all ui-widget-content\">"; |
1041 |
echo " <legend class=\"ui-corner-all ui-widget-content ui-state-active\">" |
1042 |
._("Petitionnaire")."</legend>"; |
1043 |
// Si des demandeurs sont liés à la demande |
1044 |
require_once "../obj/petitionnaire.class.php"; |
1045 |
require_once "../obj/delegataire.class.php"; |
1046 |
// Affichage du bloc pétitionnaire principal / délégataire |
1047 |
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1048 |
echo "<div id=\"petitionnaire_principal_delegataire\">"; |
1049 |
// Affichage de la synthèse |
1050 |
if (isset ($this->valIdDemandeur["petitionnaire_principal"]) AND |
1051 |
!empty($this->valIdDemandeur["petitionnaire_principal"])) { |
1052 |
$demandeur = new petitionnaire( |
1053 |
$this->valIdDemandeur["petitionnaire_principal"], |
1054 |
$this->f->db,false); |
1055 |
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
1056 |
$demandeur -> __destruct(); |
1057 |
} elseif ( isset ($this->postedIdDemandeur["petitionnaire_principal"]) AND |
1058 |
!empty($this->postedIdDemandeur["petitionnaire_principal"]) ) { |
1059 |
$demandeur = new petitionnaire( |
1060 |
$this->postedIdDemandeur["petitionnaire_principal"], |
1061 |
$this->f->db,false); |
1062 |
$demandeur -> afficherSynthese("petitionnaire_principal", $linkable); |
1063 |
$demandeur -> __destruct(); |
1064 |
} |
1065 |
// Si en édition de formulaire |
1066 |
if($maj < 2) { |
1067 |
// Bouton d'ajout du pétitionnaire principal |
1068 |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1069 |
echo "<span id=\"add_petitionnaire_principal\" |
1070 |
class=\"om-form-button add-16\">". |
1071 |
_("Saisir le petitionnaire principal"). |
1072 |
"</span>"; |
1073 |
} |
1074 |
// Bouton d'ajout du delegataire |
1075 |
// L'ID DU DIV ET DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1076 |
echo "<div id=\"delegataire\">"; |
1077 |
// Affichage de la synthèse |
1078 |
if (isset ($this->valIdDemandeur["delegataire"]) AND |
1079 |
!empty($this->valIdDemandeur["delegataire"])) { |
1080 |
$demandeur = new delegataire($this->valIdDemandeur["delegataire"], |
1081 |
$this->f->db,false); |
1082 |
$demandeur -> afficherSynthese("delegataire", $linkable); |
1083 |
$demandeur -> __destruct(); |
1084 |
} elseif ( isset ($this->postedIdDemandeur["delegataire"]) AND |
1085 |
!empty($this->postedIdDemandeur["delegataire"]) ) { |
1086 |
|
1087 |
$demandeur = new delegataire($this->postedIdDemandeur["delegataire"], |
1088 |
$this->f->db,false); |
1089 |
$demandeur -> afficherSynthese("delegataire", $linkable); |
1090 |
$demandeur -> __destruct(); |
1091 |
} |
1092 |
if($maj < 2) { |
1093 |
echo "<span id=\"add_delegataire\" |
1094 |
class=\"om-form-button add-16\">". |
1095 |
_("Saisir le delegataire"). |
1096 |
"</span>"; |
1097 |
} |
1098 |
echo "</div>"; |
1099 |
echo "<div class=\"both\"></div>"; |
1100 |
echo "</div>"; |
1101 |
// Bloc des pétitionnaires secondaires |
1102 |
// L'ID DU DIV SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1103 |
echo "<div id=\"listePetitionnaires\">"; |
1104 |
|
1105 |
// Affichage de la synthèse |
1106 |
if (isset ($this->valIdDemandeur["petitionnaire"]) AND |
1107 |
!empty($this->valIdDemandeur["petitionnaire"])) { |
1108 |
|
1109 |
foreach ($this->valIdDemandeur["petitionnaire"] as $petitionnaire) { |
1110 |
$demandeur = new petitionnaire($petitionnaire, |
1111 |
$this->f->db,false); |
1112 |
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
1113 |
$demandeur -> __destruct(); |
1114 |
} |
1115 |
|
1116 |
} elseif ( isset ($this->postedIdDemandeur["petitionnaire"]) AND |
1117 |
!empty($this->postedIdDemandeur["petitionnaire"]) ) { |
1118 |
foreach ($this->postedIdDemandeur["petitionnaire"] as $petitionnaire) { |
1119 |
$demandeur = new petitionnaire($petitionnaire, |
1120 |
$this->f->db,false); |
1121 |
$demandeur -> afficherSynthese("petitionnaire", $linkable); |
1122 |
$demandeur -> __destruct(); |
1123 |
} |
1124 |
} |
1125 |
if ($maj < 2) { |
1126 |
// L'ID DE L'INPUT SUIVANT EST NECESSAIRE AU BON FONCTIONNEMENT DU JS |
1127 |
echo "<span id=\"add_petitionnaire\" |
1128 |
class=\"om-form-button add-16\">". |
1129 |
_("Ajouter un petitionnaire") |
1130 |
."</span>"; |
1131 |
} |
1132 |
echo "</div>"; |
1133 |
echo "</fieldset>"; |
1134 |
echo "</div>"; |
1135 |
} |
1136 |
|
1137 |
// {{{ |
1138 |
|
1139 |
// getter |
1140 |
function getValIdDemandeur() { |
1141 |
return $this->valIdDemandeur; |
1142 |
} |
1143 |
// setter |
1144 |
function setValIdDemandeur($valIdDemandeur) { |
1145 |
$this->valIdDemandeur = $valIdDemandeur; |
1146 |
} |
1147 |
|
1148 |
//Supression du lien entre la demandeur et le(s) demandeur(s) |
1149 |
function triggerSupprimer($id, &$db, $val, $DEBUG){ |
1150 |
|
1151 |
//Création de la requête |
1152 |
$sql = "DELETE FROM |
1153 |
".DB_PREFIXE."lien_demande_demandeur |
1154 |
WHERE |
1155 |
demande = $id"; |
1156 |
|
1157 |
$res = $this->f->db->query($sql); |
1158 |
$this->f->addToLog("triggerSupprimer() : db->query(\"".$sql."\")"); |
1159 |
if ( database::isError($res)){ |
1160 |
die(); |
1161 |
} |
1162 |
} |
1163 |
|
1164 |
// }}} |
1165 |
}// fin classe |
1166 |
?> |