1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 07/01/2013 15:28 |
4 |
|
5 |
require_once ("../gen/obj/rapport_instruction.class.php"); |
6 |
|
7 |
class rapport_instruction extends rapport_instruction_gen { |
8 |
|
9 |
var $metadata = array( |
10 |
"om_fichier_rapport_instruction" => array( |
11 |
"dossier" => "getDossier", |
12 |
"dossier_version" => "getDossierVersion", |
13 |
"numDemandeAutor" => "getNumDemandeAutor", |
14 |
"anneemoisDemandeAutor" => "getAnneemoisDemandeAutor", |
15 |
"typeInstruction" => "getTypeInstruction", |
16 |
"statutAutorisation" => "getStatutAutorisation", |
17 |
"typeAutorisation" => "getTypeAutorisation", |
18 |
"dateEvenementDocument" => "getDateEvenementDocument", |
19 |
"groupeInstruction" => 'getGroupeInstruction', |
20 |
"title" => 'getTitle', |
21 |
), |
22 |
); |
23 |
|
24 |
var $abstract_type = array( |
25 |
"om_fichier_rapport_instruction" => "file", |
26 |
); |
27 |
|
28 |
function rapport_instruction($id,&$db,$debug) { |
29 |
$this->constructeur($id,$db,$debug); |
30 |
}// fin constructeur |
31 |
|
32 |
// Modification du style de certains champs |
33 |
function setType(&$form,$maj) { |
34 |
parent::setType($form,$maj); |
35 |
|
36 |
$form->setType('dossier_instruction', 'hidden'); |
37 |
|
38 |
if( $maj < 2 ){ |
39 |
// Select pour le proposition de décision |
40 |
$form->setType('proposition_decision', 'select'); |
41 |
} |
42 |
|
43 |
// Modification |
44 |
$form->setType('dossier_libelle', 'hiddenstatic'); |
45 |
|
46 |
//Cache les champs pour la finalisation |
47 |
$form->setType('om_fichier_rapport_instruction', 'hidden'); |
48 |
$form->setType('om_final_rapport_instruction', 'hidden'); |
49 |
} |
50 |
|
51 |
// Pré-remplir les champs |
52 |
function setValsousformulaire(&$form, $maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null) { |
53 |
|
54 |
parent::setValsousformulaire($form, $maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,$db,$DEBUG); |
55 |
|
56 |
if($maj == 0) { |
57 |
|
58 |
// Analyse réglementaire |
59 |
// Choisi par l'administrateur |
60 |
$temp_analyse_reglementaire = explode("\r",$this->f->getParameter('rapport_instruction_analyse_reglementaire')); |
61 |
$analyse_reglementaire = ""; |
62 |
foreach ($temp_analyse_reglementaire as $value) { |
63 |
$analyse_reglementaire .= "<p>".$value."</p>"; |
64 |
} |
65 |
|
66 |
$form->setVal("analyse_reglementaire_om_html",$analyse_reglementaire); |
67 |
|
68 |
// Description du projet |
69 |
// Libellé des travaux du dossier en cours |
70 |
// Création de la requête |
71 |
$sql = "SELECT dossier_libelle, |
72 |
CONCAT(donnees_techniques.am_projet_desc,' ',donnees_techniques.co_projet_desc) as libelle |
73 |
FROM |
74 |
".DB_PREFIXE."dossier |
75 |
LEFT JOIN ".DB_PREFIXE."donnees_techniques ON |
76 |
donnees_techniques.dossier_instruction = dossier.dossier |
77 |
WHERE |
78 |
dossier.dossier = '".$idxformulaire."'"; |
79 |
|
80 |
// Exécution de la requête |
81 |
$res = $db->query($sql); |
82 |
$this->f->addToLog("setVal(): db->query(\"".$sql."\");", VERBOSE_MODE); |
83 |
if ( database::isError($res)){ |
84 |
die(); |
85 |
} |
86 |
|
87 |
// Si le champ travaux est rempli |
88 |
while ($row=&$res->fetchrow(DB_FETCHMODE_ASSOC)){ |
89 |
|
90 |
if ( $row['libelle'] != "" ){ |
91 |
|
92 |
$description_projet = $row['libelle']; |
93 |
|
94 |
$form->setVal("description_projet_om_html",$description_projet); |
95 |
} |
96 |
|
97 |
// Ajout automatique du numéro de dossier d'instruction |
98 |
$form->setVal("dossier_libelle", $row['dossier_libelle']); |
99 |
} |
100 |
|
101 |
// Ajout automatique du numéro de dossier d'instruction |
102 |
$form->setVal("dossier_instruction",$idxformulaire); |
103 |
} |
104 |
} |
105 |
|
106 |
/* |
107 |
* Select pour le proposition_decision |
108 |
*/ |
109 |
function setSelect(&$form, $maj,&$db,$debug) { |
110 |
parent::setSelect($form, $maj,$db,$debug); |
111 |
|
112 |
// Lors d'un ajout ou d'une modification |
113 |
if( $maj < 2 ){ |
114 |
|
115 |
// proposition_decision |
116 |
$contenu=array(); |
117 |
|
118 |
$k = 0; |
119 |
$contenu[0][$k]=""; |
120 |
$contenu[1][$k++]=_('choisir')." "._('proposition_decision'); |
121 |
|
122 |
// Si le paramètre existe et a été remplie |
123 |
if ( !is_null($this->f->getParameter('rapport_instruction_proposition_decision'))){ |
124 |
|
125 |
$donnees = $this->f->getParameter('rapport_instruction_proposition_decision'); |
126 |
$donnees = explode('<br />', nl2br(htmlentities($donnees))); |
127 |
|
128 |
// Pour chaque ligne du paramètre, faire une ligne dans le select |
129 |
foreach ($donnees as $value) { |
130 |
|
131 |
$contenu[0][$k]=$value; |
132 |
$contenu[1][$k++]=$value; |
133 |
} |
134 |
} |
135 |
$form->setSelect("proposition_decision",$contenu); |
136 |
|
137 |
} |
138 |
|
139 |
} |
140 |
|
141 |
|
142 |
/** |
143 |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
144 |
* @return string numéro de dossier d'autorisation |
145 |
*/ |
146 |
protected function getDossier() { |
147 |
if(empty($this->specificMetadata)) { |
148 |
$this->getSpecificMetadata(); |
149 |
} |
150 |
return $this->specificMetadata->dossier; |
151 |
} |
152 |
/** |
153 |
* Récupération la version du dossier d'instruction à ajouter aux métadonnées |
154 |
* @return int Version |
155 |
*/ |
156 |
protected function getDossierVersion() { |
157 |
if(empty($this->specificMetadata)) { |
158 |
$this->getSpecificMetadata(); |
159 |
} |
160 |
return $this->specificMetadata->version; |
161 |
} |
162 |
/** |
163 |
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
164 |
* @return string numéro de dossier d'autorisation |
165 |
*/ |
166 |
protected function getNumDemandeAutor() { |
167 |
if(empty($this->specificMetadata)) { |
168 |
$this->getSpecificMetadata(); |
169 |
} |
170 |
return $this->specificMetadata->dossier_autorisation; |
171 |
} |
172 |
/** |
173 |
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
174 |
* @return date date de la demande initiale |
175 |
*/ |
176 |
protected function getAnneemoisDemandeAutor() { |
177 |
if(empty($this->specificMetadata)) { |
178 |
$this->getSpecificMetadata(); |
179 |
} |
180 |
return $this->specificMetadata->date_demande_initiale; |
181 |
} |
182 |
/** |
183 |
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
184 |
* @return string type du dossier d'instruction |
185 |
*/ |
186 |
protected function getTypeInstruction() { |
187 |
if(empty($this->specificMetadata)) { |
188 |
$this->getSpecificMetadata(); |
189 |
} |
190 |
return $this->specificMetadata->dossier_instruction_type; |
191 |
} |
192 |
/** |
193 |
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
194 |
* @return string avis |
195 |
*/ |
196 |
protected function getStatutAutorisation() { |
197 |
if(empty($this->specificMetadata)) { |
198 |
$this->getSpecificMetadata(); |
199 |
} |
200 |
return $this->specificMetadata->statut; |
201 |
} |
202 |
/** |
203 |
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
204 |
* @return string type de dossier d'autorisation |
205 |
*/ |
206 |
protected function getTypeAutorisation() { |
207 |
if(empty($this->specificMetadata)) { |
208 |
$this->getSpecificMetadata(); |
209 |
} |
210 |
return $this->specificMetadata->dossier_autorisation_type; |
211 |
} |
212 |
/** |
213 |
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
214 |
* @return date de l'évènement |
215 |
*/ |
216 |
protected function getDateEvenementDocument() { |
217 |
return date("Y-m-d"); |
218 |
} |
219 |
/** |
220 |
* Récupération du groupe d'instruction à ajouter aux métadonnées |
221 |
* @return string Groupe d'instruction |
222 |
*/ |
223 |
protected function getGroupeInstruction() { |
224 |
if(empty($this->specificMetadata)) { |
225 |
$this->getSpecificMetadata(); |
226 |
} |
227 |
return $this->specificMetadata->groupe_instruction; |
228 |
} |
229 |
/** |
230 |
* Récupération du type du document à ajouter aux métadonnées |
231 |
* @return string Type de document |
232 |
*/ |
233 |
protected function getTitle() { |
234 |
return "Rapport d'instruction"; |
235 |
} |
236 |
|
237 |
/** |
238 |
* Cette méthode permet de stocker en attribut toutes les métadonnées |
239 |
* nécessaire à l'ajout d'un document. |
240 |
*/ |
241 |
public function getSpecificMetadata() { |
242 |
//Requête pour récupérer les informations essentiels sur le dossier d'instruction |
243 |
$sql = "SELECT dossier.dossier as dossier, |
244 |
dossier_autorisation.dossier_autorisation as dossier_autorisation, |
245 |
to_char(dossier.date_demande, 'YYYY/MM') as date_demande_initiale, |
246 |
dossier_instruction_type.code as dossier_instruction_type, |
247 |
etat_dossier_autorisation.libelle as statut, |
248 |
dossier_autorisation_type.code as dossier_autorisation_type, |
249 |
groupe.code as groupe_instruction |
250 |
FROM ".DB_PREFIXE."dossier |
251 |
LEFT JOIN ".DB_PREFIXE."dossier_instruction_type |
252 |
ON dossier.dossier_instruction_type = dossier_instruction_type.dossier_instruction_type |
253 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation |
254 |
ON dossier.dossier_autorisation = dossier_autorisation.dossier_autorisation |
255 |
LEFT JOIN ".DB_PREFIXE."etat_dossier_autorisation |
256 |
ON dossier_autorisation.etat_dossier_autorisation = etat_dossier_autorisation.etat_dossier_autorisation |
257 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
258 |
ON dossier_autorisation.dossier_autorisation_type_detaille = dossier_autorisation_type_detaille.dossier_autorisation_type_detaille |
259 |
LEFT JOIN ".DB_PREFIXE."dossier_autorisation_type |
260 |
ON dossier_autorisation_type_detaille.dossier_autorisation_type = dossier_autorisation_type.dossier_autorisation_type |
261 |
LEFT JOIN ".DB_PREFIXE."groupe |
262 |
ON dossier_autorisation_type.groupe = groupe.groupe |
263 |
WHERE dossier.dossier = '".$this->getVal("dossier_instruction")."'"; |
264 |
$res = $this->db->query($sql); |
265 |
$this->f->addToLog("getSpecificMetadata() : db->query(".$sql.")", VERBOSE_MODE); |
266 |
if ( database::isError($res)){ |
267 |
die(); |
268 |
} |
269 |
|
270 |
//Le résultat est récupéré dans un objet |
271 |
$row =& $res->fetchRow(DB_FETCHMODE_OBJECT); |
272 |
|
273 |
//Si il y a un résultat |
274 |
if ($row !== null) { |
275 |
|
276 |
//Génération du numéro de version |
277 |
$sql = "SELECT |
278 |
count(*) |
279 |
FROM |
280 |
".DB_PREFIXE."dossier |
281 |
LEFT JOIN |
282 |
".DB_PREFIXE."dossier_autorisation |
283 |
ON |
284 |
dossier_autorisation.dossier_autorisation = dossier.dossier_autorisation |
285 |
LEFT JOIN |
286 |
".DB_PREFIXE."dossier_instruction_type |
287 |
ON |
288 |
dossier_instruction_type.dossier_instruction_type = dossier.dossier_instruction_type |
289 |
WHERE |
290 |
dossier_autorisation.dossier_autorisation = '".$row->dossier_autorisation."' |
291 |
AND |
292 |
dossier_instruction_type.code = '".$row->dossier_instruction_type."'"; |
293 |
$row->version = $this->db->getOne($sql); |
294 |
$this->f->addToLog("getSpecificMetadata() : db->getOne(\"".$sql."\")", VERBOSE_MODE); |
295 |
if ( database::isError($row->version)){ |
296 |
$this->f->addToError("", $row->version, $row->version); |
297 |
return false; |
298 |
} |
299 |
|
300 |
//Formatage du numéro de version |
301 |
$row->version = str_pad($row->version, 2, "0", STR_PAD_LEFT); |
302 |
|
303 |
//Alors on créé l'objet dossier_instruction |
304 |
$this->specificMetadata = $row; |
305 |
} |
306 |
} |
307 |
|
308 |
/** |
309 |
* Surcharge du bouton retour afin de retourner sur le dossier d'instruction selon de cas |
310 |
*/ |
311 |
function retoursousformulaire($idxformulaire, $retourformulaire, $val, |
312 |
$objsf, $premiersf, $tricolsf, $validation, |
313 |
$idx, $maj, $retour) { |
314 |
|
315 |
// Ajout et consultation, retour dossier |
316 |
if ( ( $maj == 0 && $validation == 0 ) || |
317 |
( $maj == 3 && $validation == 0 ) || |
318 |
( $maj == 0 && $validation == 1 ) ){ |
319 |
|
320 |
echo "\n<a class=\"retour\" "; |
321 |
echo "href=\"#\" "; |
322 |
echo "onclick=\"redirectPortletAction(1,'main');\" "; |
323 |
echo ">"; |
324 |
echo _("Retour"); |
325 |
echo "</a>\n"; |
326 |
} |
327 |
//Sinon affiche un retour normal |
328 |
else { |
329 |
|
330 |
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
331 |
$objsf, $premiersf, $tricolsf, $validation, |
332 |
$idx, $maj, $retour); |
333 |
} |
334 |
} |
335 |
|
336 |
/** |
337 |
* Surcharge pour gérer les actions disponibles dans le portlet |
338 |
*/ |
339 |
function checkAccessibility() { |
340 |
// |
341 |
parent::checkAccessibility(); |
342 |
|
343 |
//Si le document est déjà finalisé, on affiche uniquement le lien de |
344 |
//dé-finalisation |
345 |
$om_final_rapport_instruction = $this->getVal("om_final_rapport_instruction"); |
346 |
if ( isset($this->actions_sup["finalisation"]) && |
347 |
$om_final_rapport_instruction== "t" ){ |
348 |
|
349 |
//On cache le lien d'action |
350 |
$this->parameters["actions"]["modifier"] = NULL; |
351 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
352 |
unset($this->actions_sup["finalisation"]); |
353 |
$this->actions_sup["edition"]["lien"] = "../spg/file.php?id="; |
354 |
$this->actions_sup["edition"]["id"] = |
355 |
"&obj=rapport_instruction&champ=om_fichier_rapport_instruction"; |
356 |
} |
357 |
//Si le document n'est pas finalisé, on affiche uniquement le lien de |
358 |
//finalisation |
359 |
if ( isset($this->actions_sup["definalisation"]) && |
360 |
$om_final_rapport_instruction!= "t" ){ |
361 |
|
362 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
363 |
unset($this->actions_sup["definalisation"]); |
364 |
$this->actions_sup["edition"]["lien"] = "../pdf/pdfetat.php?idx="; |
365 |
$this->actions_sup["edition"]["id"] = "&obj=rapport_instruction"; |
366 |
} |
367 |
|
368 |
$idxformulaire = $this->getParameter("idxformulaire"); |
369 |
//Si le dossier d'instruction auquel sont rattachées les données techniques |
370 |
//est cloturé, on affiche pas les liens du portlet |
371 |
if ( $idxformulaire != '' ){ |
372 |
|
373 |
//On récuppère le statut du dossier d'instruction |
374 |
$statut = $this->f->getStatutDossier($idxformulaire); |
375 |
if ( $this->f->isUserInstructeur() && $statut == "cloture" ){ |
376 |
|
377 |
//On cache le lien de modification |
378 |
$this->parameters["actions"]["modifier"] = NULL; |
379 |
$this->actions_sup["finalisation"] = NULL; |
380 |
$this->actions_sup["definalisation"] = NULL; |
381 |
} |
382 |
} |
383 |
|
384 |
// Si l'utilisateur est un intructeur qui en correspond pas à la |
385 |
// division du dossier |
386 |
if ($this->f->isUserInstructeur() |
387 |
&& isset($this->f->om_utilisateur["division"]) |
388 |
&& $this->f->om_utilisateur["division"] != $this->getDivisionFromDossier()) { |
389 |
// |
390 |
$this->parameters["actions"]["modifier"] = NULL; |
391 |
$this->actions_sup["finalisation"] = NULL; |
392 |
$this->actions_sup["definalisation"] = NULL; |
393 |
} |
394 |
} |
395 |
|
396 |
/** |
397 |
* Cette methode est à surcharger elle permet de tester dans chaque classe |
398 |
* des droits des droits spécifiques en fonction des données |
399 |
*/ |
400 |
function canAccess() { |
401 |
// Si l'utilisateur est un instructeur et que le dossier est cloturé |
402 |
if ( $this->f->isUserInstructeur() && |
403 |
$this->f->getStatutDossier($this->getVal("idxformulaire")) == "cloture" |
404 |
&& $this->getParameter("maj") != 3) { |
405 |
|
406 |
return false; |
407 |
} |
408 |
// |
409 |
return true; |
410 |
} |
411 |
|
412 |
/** |
413 |
* Finalisation des documents. |
414 |
* @param string $champ champ du fichier à finaliser |
415 |
* @param booleen $status permet de définir si on finalise ou définalise |
416 |
* @param string $sousform permet de savoir si se trouve dans un sousformulaire (passé au javascript) |
417 |
*/ |
418 |
function finaliser( $champ = '', $status, $sousform, $retourformulaire){ |
419 |
|
420 |
// Recuperation de la valeur de la cle primaire de l'objet |
421 |
if($this->getVal($this->clePrimaire)!='') |
422 |
$id = $this->getVal($this->clePrimaire); |
423 |
else |
424 |
$id=$this->id; |
425 |
|
426 |
//Si on finalise le document |
427 |
if ( $status == 1 ){ |
428 |
|
429 |
//Génération du PDF |
430 |
$_GET['output'] = "string"; |
431 |
$f = $this->f; |
432 |
include '../pdf/pdfetat.php'; |
433 |
|
434 |
//Métadonnées du document |
435 |
$metadata = array( |
436 |
'filename' => 'rapport_instruction_'.$idx.'.pdf', |
437 |
'mimetype' => 'application/pdf', |
438 |
'size' => strlen($pdf_output) |
439 |
); |
440 |
// Récupération des métadonnées calculées après validation |
441 |
$spe_metadata = $this->getMetadata("om_fichier_rapport_instruction"); |
442 |
|
443 |
$metadata = array_merge($metadata, $spe_metadata); |
444 |
//Si le document a déjà été finalisé |
445 |
//on met à jour le document mais pas son uid |
446 |
if ( $this->getVal("om_fichier_rapport_instruction") != '' ){ |
447 |
$uid = $this->f->storage->update( |
448 |
$this->getVal("om_fichier_rapport_instruction"), $pdf_output, $metadata); |
449 |
} |
450 |
//Sinon, on joute le document et on récupère son uid |
451 |
else { |
452 |
//Stockage du PDF |
453 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
454 |
} |
455 |
} |
456 |
else { |
457 |
//Récupération de l'uid du document finalisé |
458 |
$uid = $this->getVal("om_fichier_rapport_instruction"); |
459 |
|
460 |
//On dé-finalise avant de finaliser |
461 |
if ( $uid == '' || $uid == 'OP_FAILURE' ){ |
462 |
// Message d'echec (saut d'une ligne supplementaire avant le |
463 |
// message pour qu'il soit mis en evidence) |
464 |
$this->addToLog( |
465 |
_("Finalisation non enregistree")." - ". |
466 |
_("id rapport_instruction")." = ".$id." - ". |
467 |
_("uid fichier")." = ".$uid |
468 |
); |
469 |
return -1; |
470 |
} |
471 |
} |
472 |
|
473 |
//Mise à jour des données |
474 |
if ( $uid != '' && $uid != 'OP_FAILURE' ){ |
475 |
// Logger |
476 |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
477 |
|
478 |
$actions = array(); |
479 |
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
480 |
//à jour de l'interface |
481 |
if ( $status == 0 ){ |
482 |
$lien = '../pdf/pdfetat.php?obj=rapport_instruction&idx='.$id; |
483 |
|
484 |
//Ajout des actions |
485 |
//Si l'utilisateur a le droit de modifier l'objet |
486 |
if ( $this->f->isAccredited('instruction') || |
487 |
$this->f->isAccredited('instruction_modifier') ){ |
488 |
|
489 |
$actions["modifier"] = ($sousform!='')? |
490 |
'<li><a href="#" onclick="ajaxIt(\'instruction\', |
491 |
\'../scr/sousform.php?obj=rapport_instruction&action=1&idx='. |
492 |
$this->getVal($this->clePrimaire). |
493 |
'&premiersf=0&trisf=&retourformulaire='.$retourformulaire.'&idxformulaire='. |
494 |
$this->getVal("dossier"). |
495 |
'&retour=form\');"> |
496 |
<span class="om-prev-icon om-icon-16 edit-16" title="'. |
497 |
_('Modifier').'">'. |
498 |
_('Modifier'). |
499 |
'</span></a></li>': |
500 |
'<li> |
501 |
<a href="form.php?obj=rapport_instruction&action=1'.'&idx='. |
502 |
$this->getVal($this->clePrimaire). |
503 |
'&premier=&advs_id=&recherche=&tricol=&selectioncol=&valide=&retour=form"> |
504 |
<span class="om-prev-icon om-icon-16 edit-16" title="'. |
505 |
_('Modifier').'">'. |
506 |
_('Modifier'). |
507 |
'</span></a></li>'; |
508 |
} |
509 |
//Si l'utilisateur a le droit de supprimer l'objet |
510 |
if ( $this->f->isAccredited('instruction') || |
511 |
$this->f->isAccredited('instruction_supprimer') ){ |
512 |
|
513 |
$actions["supprimer"] = ($sousform!='')? |
514 |
'<li><a href="#" onclick="ajaxIt(\'instruction\', |
515 |
\'../scr/sousform.php?obj=rapport_instruction&action=2&idx='. |
516 |
$this->getVal($this->clePrimaire). |
517 |
'&premiersf=0&trisf=&retourformulaire='.$retourformulaire.'&idxformulaire='. |
518 |
$this->getVal("dossier"). |
519 |
'&retour=form\');"> |
520 |
<span class="om-prev-icon om-icon-16 delete-16" title="'. |
521 |
_('Supprimer').'">'. |
522 |
_('Supprimer'). |
523 |
'</span></a></li>': |
524 |
'<li> |
525 |
<a href="form.php?obj=rapport_instruction&action=1'.'&idx='. |
526 |
$this->getVal($this->clePrimaire). |
527 |
'&premier=&advs_id=&recherche=&tricol=&selectioncol=&valide=&retour=form"> |
528 |
<span class="om-prev-icon om-icon-16 delete-16" title="'. |
529 |
_('Supprimer').'">'. |
530 |
_('Supprimer'). |
531 |
'</span></a></li>'; |
532 |
} |
533 |
} |
534 |
else { |
535 |
$lien = '../spg/file.php?obj=rapport_instruction&'. |
536 |
'champ=om_fichier_rapport_instruction&id='.$id; |
537 |
} |
538 |
|
539 |
|
540 |
|
541 |
$retour = array( |
542 |
"portlet"=> "<a href=\"#\" onclick=\"finalizeDocument(". |
543 |
$id.", 'rapport_instruction', '".$sousform."', ".(($status==0)?1:0).")\"> |
544 |
<span class=\"om-prev-icon om-icon-16 om-icon-fix " |
545 |
.(($status==1)?"de":"")."finalise\" title=\"". |
546 |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."\">". |
547 |
(($status==1)?_("Reprendre la redaction du document"):_("Finaliser le document"))."</span> |
548 |
</a>", |
549 |
"pdf" => $lien, |
550 |
"actions" => $actions |
551 |
); |
552 |
|
553 |
//Modifie uniquement les valeurs des champs concernant la finalisation |
554 |
//du document |
555 |
$this->valF = ''; |
556 |
$this->valF["om_final_rapport_instruction"] = ($status==1)?TRUE:FALSE; |
557 |
$this->valF["om_fichier_rapport_instruction"] = $uid; |
558 |
|
559 |
// Verification de la validite des donnees |
560 |
$this->verifier($this->val, $this->db, DEBUG); |
561 |
// Verification du verrou |
562 |
$this->testverrou(); |
563 |
// Si les verifications precedentes sont correctes, on procede a |
564 |
// la modification, sinon on ne fait rien et on retourne une erreur |
565 |
if ($this->correct) { |
566 |
// Execution du trigger 'before' specifique au MODE 'update' |
567 |
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
568 |
|
569 |
// Execution de la requête de modification des donnees de l'attribut |
570 |
// valF de l'objet dans l'attribut table de l'objet |
571 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $this->valF, |
572 |
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
573 |
// Si une erreur survient |
574 |
if (database::isError($res)) { |
575 |
// Appel de la methode de recuperation des erreurs |
576 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
577 |
} else { |
578 |
// Log |
579 |
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
580 |
// Log |
581 |
$message = _("Enregistrement")." ".$id." "; |
582 |
$message .= _("de la table")." \"".$this->table."\" "; |
583 |
$message .= "[ ".$this->db->affectedRows()." "; |
584 |
$message .= _("enregistrement(s) mis a jour")." ]"; |
585 |
$this->addToLog($message, VERBOSE_MODE); |
586 |
// Mise en place du verrou pour ne pas finaliser plusieurs fois |
587 |
// le meme document |
588 |
$this->verrouille(); |
589 |
// Execution du trigger 'after' specifique au MODE 'update' |
590 |
$this->triggermodifierapres($id, $this->db, $this->val, DEBUG); |
591 |
|
592 |
return $retour; |
593 |
} |
594 |
} else { |
595 |
// Message d'echec (saut d'une ligne supplementaire avant le |
596 |
// message pour qu'il soit mis en evidence) |
597 |
$this->addToLog( |
598 |
_("Finalisation non enregistree")." - ". |
599 |
_("id rapport_instruction")." = ".$id." - ". |
600 |
_("uid fichier")." = ".$uid |
601 |
); |
602 |
return -1; |
603 |
} |
604 |
} |
605 |
// Si le document n'a pas été stocké |
606 |
else{ |
607 |
$this->addToLog( |
608 |
_("Finalisation non enregistree")." - ". |
609 |
_("id rapport_instruction")." = ".$id." - ". |
610 |
_("uid fichier")." = ".$uid |
611 |
); |
612 |
return -1; |
613 |
} |
614 |
} |
615 |
|
616 |
/** |
617 |
* Cette variable permet de stocker le résultat de la méthode |
618 |
* getDivisionFromDossier() afin de ne pas effectuer le recalcul à chacun de |
619 |
* ces appels. |
620 |
* @var string Code de la division du dossier en cours |
621 |
*/ |
622 |
var $_division_from_dossier = NULL; |
623 |
|
624 |
/** |
625 |
* Cette méthode permet de récupérer le code de division correspondant |
626 |
* au dossier sur lequel on se trouve. |
627 |
* |
628 |
* @return string Code de la division du dossier en cours |
629 |
*/ |
630 |
function getDivisionFromDossier() { |
631 |
|
632 |
// Cette méthode peut être appelée plusieurs fois lors d'une requête. |
633 |
// Pour éviter de refaire le traitement de recherche de la division |
634 |
// alors on vérifie si nous ne l'avons pas déjà calculé. |
635 |
if ($this->_division_from_dossier != NULL) { |
636 |
// Logger |
637 |
$this->addToLog("getDivisionFromDossier(): retour de la valeur déjà calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
638 |
// On retourne la valeur déjà calculée |
639 |
return $this->_division_from_dossier; |
640 |
} |
641 |
|
642 |
// Par défaut, on définit la valeur du dossier à NULL |
643 |
$dossier = NULL; |
644 |
// Test sur le mode et le contexte du formulaire |
645 |
if ($this->getParameter("maj") == 0 |
646 |
&& ($this->getParameter("retourformulaire") == "dossier" |
647 |
|| $this->getParameter("retourformulaire") == "dossier_instruction" |
648 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_encours" |
649 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_encours" |
650 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_mes_clotures" |
651 |
|| $this->getParameter("retourformulaire") == "dossier_instruction_tous_clotures")) { |
652 |
// Si on se trouve en mode AJOUT (seul mode où l'enregistrement |
653 |
// n'existe pas en base de données) ET que nous nous trouvons |
654 |
// dans le contexte d'un dossier d'instruction alors on récupère |
655 |
// le numéro de dossier depuis le paramètre 'idxformulaire' |
656 |
$dossier = $this->getParameter("idxformulaire"); |
657 |
} else { |
658 |
// Sinon on récupère le numéro de dossier dans le champs dossier de |
659 |
// l'enregistrement (en base de données) |
660 |
$dossier = $this->getVal("dossier_instruction"); |
661 |
} |
662 |
|
663 |
// On appelle la méthode de la classe utils qui renvoi le code de la |
664 |
// division d'un dossier, on la stocke pour ne pas refaire le calcul au |
665 |
// prochain appel de cette méthode |
666 |
$this->_division_from_dossier = $this->f->getDivisionFromDossier($dossier); |
667 |
// Logger |
668 |
$this->addToLog("getDivisionFromDossier(): retour de la valeur nouvellement calculée - '".$this->_division_from_dossier."'", EXTRA_VERBOSE_MODE); |
669 |
// On retourne la valeur retournée |
670 |
return $this->_division_from_dossier; |
671 |
|
672 |
} |
673 |
}// fin classe |
674 |
?> |