1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 07/12/2012 17:33 |
4 |
|
5 |
require_once ("../gen/obj/commission.class.php"); |
6 |
|
7 |
class commission extends commission_gen { |
8 |
|
9 |
var $metadata = array( |
10 |
"om_fichier_commission_ordre_jour" => array( |
11 |
"dossier" => "getDossier", |
12 |
"dossier_autorisation" => "getDossierAutorisation", |
13 |
"date_demande_initiale" => "getDateDemandeInitiale", |
14 |
"dossier_instruction_type" => "getDossierInstructionType", |
15 |
"statut" => "getStatut", |
16 |
"dossier_autorisation_type" => "getDossierAutorisationType", |
17 |
"date_creation" => "getDateEvenement", |
18 |
"groupe_instruction" => 'getGroupeInstruction', |
19 |
), |
20 |
"om_fichier_commission_compte_rendu" => array( |
21 |
"dossier" => "getDossier", |
22 |
"dossier_autorisation" => "getDossierAutorisation", |
23 |
"date_demande_initiale" => "getDateDemandeInitiale", |
24 |
"dossier_instruction_type" => "getDossierInstructionType", |
25 |
"statut" => "getStatut", |
26 |
"dossier_autorisation_type" => "getDossierAutorisationType", |
27 |
"date_creation" => "getDateEvenement", |
28 |
"groupe_instruction" => 'getGroupeInstruction', |
29 |
), |
30 |
); |
31 |
|
32 |
function commission($id,&$db,$debug) { |
33 |
$this->constructeur($id,$db,$debug); |
34 |
}// fin constructeur |
35 |
|
36 |
function afterFormSpecificContent() { |
37 |
|
38 |
//Le sous-formulaire spécifique ne s'affiche qu'en consultation |
39 |
if ( $this->parameters['maj'] == 3 ){ |
40 |
$f = $this->f; |
41 |
include "../app/commission_manage.php"; |
42 |
} |
43 |
} |
44 |
|
45 |
//Le type de commission n'est pas modifiable une fois la commission ajoutée |
46 |
function setType(&$form,$maj) { |
47 |
parent::setType($form,$maj); |
48 |
|
49 |
//Cache le champ code en ajout |
50 |
if ( $maj == 0 ){ |
51 |
|
52 |
$form->setType('code', 'hidden'); |
53 |
} |
54 |
|
55 |
if ( $maj > 0 ) { |
56 |
$form->setType('commission_type', 'selecthiddenstatic'); |
57 |
$form->setType('code', 'hiddenstatic'); |
58 |
} |
59 |
|
60 |
//Cache les champs pour la finalisation |
61 |
$form->setType('om_fichier_commission_ordre_jour', 'hidden'); |
62 |
$form->setType('om_fichier_commission_ordre_jour', 'hidden'); |
63 |
$form->setType('om_fichier_commission_compte_rendu', 'hidden'); |
64 |
$form->setType('om_fichier_commission_compte_rendu', 'hidden'); |
65 |
} |
66 |
|
67 |
//Action javascript au changement du type de la commission |
68 |
function setOnchange(&$form,$maj){ |
69 |
parent::setOnchange($form,$maj); |
70 |
|
71 |
$form->setOnchange("commission_type","chargeDonneesCommissionType(this.value);"); |
72 |
} |
73 |
|
74 |
// Date du jour par défaut |
75 |
function setVal(&$form, $maj, $validation, &$db) { |
76 |
|
77 |
if( $maj == 0 ) { |
78 |
|
79 |
$form->setVal("date_commission",date('d/m/Y')); |
80 |
} |
81 |
} |
82 |
|
83 |
// Génération automatique du code de la commission |
84 |
function setvalF($val) { |
85 |
parent::setValF($val); |
86 |
|
87 |
// Récupération du code du type de la commission |
88 |
$codeTypeCommission = ""; |
89 |
if ( isset($val['commission_type']) && is_numeric($val['commission_type'])) |
90 |
$codeTypeCommission = $this->getCodeTypeCommission($val['commission_type']); |
91 |
|
92 |
//Formatte la date |
93 |
$dateFormatee = $this->formatDate($val['date_commission']); |
94 |
|
95 |
$this->valF['code'] = $codeTypeCommission.$dateFormatee; |
96 |
} |
97 |
|
98 |
//Retourne le code du type de la commission passée en paramètre |
99 |
function getCodeTypeCommission($typeCommission){ |
100 |
|
101 |
$codeTypeCommission = ""; |
102 |
|
103 |
$sql = "SELECT |
104 |
code |
105 |
FROM |
106 |
".DB_PREFIXE."commission_type |
107 |
WHERE |
108 |
commission_type = ".$typeCommission; |
109 |
$codeTypeCommission = $this->db->getOne($sql); |
110 |
$this->f->addToLog("getCodeTypeCommission(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
111 |
if ( database::isError($codeTypeCommission) ){ |
112 |
die(); |
113 |
} |
114 |
|
115 |
return $codeTypeCommission; |
116 |
} |
117 |
|
118 |
// Prend une date au format JJ/MM/AAAA et retourne AAAAMMJJ |
119 |
function formatDate($date){ |
120 |
|
121 |
$dateFormatee = explode('/',$date); |
122 |
$dateFormatee = $dateFormatee[2].$dateFormatee[1].$dateFormatee[0]; |
123 |
|
124 |
return $dateFormatee; |
125 |
} |
126 |
|
127 |
/** |
128 |
* Surcharge pour gérer les actions disponibles dans le portlet |
129 |
*/ |
130 |
function checkAccessibility() { |
131 |
// |
132 |
parent::checkAccessibility(); |
133 |
//Si le document est déjà finalisé, on affiche uniquement le lien de |
134 |
//dé-finalisation pour l'ordre du jour et le compte rendu |
135 |
$om_final_commission_ordre_jour = $this->getVal("om_final_commission_ordre_jour"); |
136 |
if ( isset($this->actions_sup["commission_ordre_jour"]) && |
137 |
$om_final_commission_ordre_jour== "t" ){ |
138 |
|
139 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
140 |
$this->actions_sup["commission_ordre_jour"]["lien"] = "../spg/file.php?id="; |
141 |
$this->actions_sup["commission_ordre_jour"]["id"] = |
142 |
"&obj=commission&champ=om_fichier_commission_ordre_jour"; |
143 |
} |
144 |
|
145 |
$om_final_commission_compte_rendu = $this->getVal("om_final_commission_compte_rendu"); |
146 |
if ( isset($this->actions_sup["finalisation"]) && |
147 |
$om_final_commission_compte_rendu== "t" ){ |
148 |
|
149 |
//On cache le lien de finalisation et on affiche le bon lien pour l'édition |
150 |
$this->actions_sup["commission_compte_rendu"]["lien"] = "../spg/file.php?id="; |
151 |
$this->actions_sup["commission_compte_rendu"]["id"] = |
152 |
"&obj=commission&champ=om_fichier_commission_compte_rendu"; |
153 |
} |
154 |
} |
155 |
|
156 |
/** |
157 |
* Finalisation des documents lors de la diffusion |
158 |
*/ |
159 |
function finaliser( $champ = '', $status, $sousform){ |
160 |
|
161 |
//Si on finalise le document |
162 |
//Génération du PDF |
163 |
$_GET['output'] = "string"; |
164 |
$_GET['obj'] = 'commission_'.$champ; |
165 |
$f = $this->f; |
166 |
include '../pdf/pdfetat.php'; |
167 |
|
168 |
//Métadonnées du document |
169 |
$metadata = array( |
170 |
'filename' => 'commission_'.$champ.'_'.$idx.'.pdf', |
171 |
'mimetype' => 'application/pdf', |
172 |
'size' => strlen($pdf_output) |
173 |
); |
174 |
// Récupération des métadonnées calculées après validation |
175 |
$spe_metadata = $this->getMetadata("om_fichier_commission_".$champ); |
176 |
$metadata = array_merge($metadata, $spe_metadata); |
177 |
|
178 |
$uid = $this->f->storage->create($pdf_output, $metadata); |
179 |
|
180 |
//Mise à jour des données |
181 |
if ( $uid != '' ){ |
182 |
// Logger |
183 |
$this->addToLog("finaliser() - begin", EXTRA_VERBOSE_MODE); |
184 |
// Recuperation de la valeur de la cle primaire de l'objet |
185 |
if($this->getVal($this->clePrimaire)!='') |
186 |
$id = $this->getVal($this->clePrimaire); |
187 |
else |
188 |
$id=$this->id; |
189 |
|
190 |
//Tableau contenant le lien vers le PDF et lien du portlet pour la mise |
191 |
//à jour de l'interface |
192 |
$lien = '../spg/file.php?obj=commission&'. |
193 |
'champ=om_fichier_commission_'.$champ.'&id='.$id; |
194 |
|
195 |
foreach ( $this->champs as $key=>$value ) |
196 |
$val[$value] = $this->val[$key]; |
197 |
$val['date_commission']=$this->dateDBToForm($val['date_commission']); |
198 |
|
199 |
$this->setvalF($val); |
200 |
|
201 |
// Verification de la validite des donnees |
202 |
$this->verifier($this->val, $this->db, DEBUG); |
203 |
// Verification du verrou |
204 |
$this->testverrou(); |
205 |
// Si les verifications precedentes sont correctes, on procede a |
206 |
// la modification, sinon on ne fait rien et on retourne une erreur |
207 |
if ($this->correct) { |
208 |
// Execution du trigger 'before' specifique au MODE 'update' |
209 |
$this->triggermodifier( $id, $this->db, $this->val, DEBUG); |
210 |
|
211 |
//Modifie uniquement les valeurs des champs concernant la finalisation |
212 |
//du document |
213 |
$valF = array( |
214 |
"om_final_commission_".$champ => TRUE, |
215 |
"om_fichier_commission_".$champ => $uid |
216 |
); |
217 |
|
218 |
// Execution de la requête de modification des donnees de l'attribut |
219 |
// valF de l'objet dans l'attribut table de l'objet |
220 |
$res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF, |
221 |
DB_AUTOQUERY_UPDATE, $this->getCle($id)); |
222 |
// Si une erreur survient |
223 |
if (database::isError($res)) { |
224 |
// Appel de la methode de recuperation des erreurs |
225 |
$this->erreur_db($res->getDebugInfo(), $res->getMessage(), ''); |
226 |
} else { |
227 |
// Log |
228 |
$this->addToLog(_("Requete executee"), VERBOSE_MODE); |
229 |
// Log |
230 |
$message = _("Enregistrement")." ".$id." "; |
231 |
$message .= _("de la table")." \"".$this->table."\" "; |
232 |
$message .= "[ ".$this->db->affectedRows()." "; |
233 |
$message .= _("enregistrement(s) mis a jour")." ]"; |
234 |
$this->addToLog($message, VERBOSE_MODE); |
235 |
// Mise en place du verrou pour ne pas finaliser plusieurs fois |
236 |
// le meme document |
237 |
$this->verrouille(); |
238 |
// Execution du trigger 'after' specifique au MODE 'update' |
239 |
$this->triggermodifierapres($id, $this->db, $this->val, DEBUG); |
240 |
|
241 |
return $lien; |
242 |
} |
243 |
} else { |
244 |
// Message d'echec (saut d'une ligne supplementaire avant le |
245 |
// message pour qu'il soit mis en evidence) |
246 |
$this->addToLog("Finalisation non enregistree"); |
247 |
return -1; |
248 |
} |
249 |
} |
250 |
// Si le document n'a pas été stocké |
251 |
else{ |
252 |
return -1; |
253 |
} |
254 |
} |
255 |
|
256 |
/** |
257 |
* Récupération du numéro de dossier d'instruction à ajouter aux métadonnées |
258 |
* @return [type] [description] |
259 |
*/ |
260 |
protected function getDossier() { |
261 |
return ""; |
262 |
} |
263 |
/** |
264 |
* Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées |
265 |
* @return [type] [description] |
266 |
*/ |
267 |
protected function getDossierAutorisation() { |
268 |
return ""; |
269 |
} |
270 |
/** |
271 |
* Récupération de la date de demande initiale du dossier à ajouter aux métadonnées |
272 |
* @return [type] [description] |
273 |
*/ |
274 |
protected function getDateDemandeInitiale() { |
275 |
return ""; |
276 |
} |
277 |
/** |
278 |
* Récupération du type de dossier d'instruction à ajouter aux métadonnées |
279 |
* @return [type] [description] |
280 |
*/ |
281 |
protected function getDossierInstructionType() { |
282 |
return ""; |
283 |
} |
284 |
/** |
285 |
* Récupération du statut du dossier d'autorisation à ajouter aux métadonnées |
286 |
* @return [type] [description] |
287 |
*/ |
288 |
protected function getStatut() { |
289 |
return ""; |
290 |
} |
291 |
/** |
292 |
* Récupération du type de dossier d'autorisation à ajouter aux métadonnées |
293 |
* @return [type] [description] |
294 |
*/ |
295 |
protected function getDossierAutorisationType() { |
296 |
return ""; |
297 |
} |
298 |
/** |
299 |
* Récupération de la date d'ajout de document à ajouter aux métadonnées |
300 |
* @return [type] [description] |
301 |
*/ |
302 |
protected function getDateEvenement() { |
303 |
return date("d/m/Y"); |
304 |
} |
305 |
/** |
306 |
* Récupération du groupe d'instruction à ajouter aux métadonnées |
307 |
* @return string Groupe d'instruction |
308 |
*/ |
309 |
protected function getGroupeInstruction() { |
310 |
return "ADS"; |
311 |
} |
312 |
|
313 |
}// fin classe |
314 |
?> |