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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4275 - (show annotations)
Mon May 23 15:43:30 2016 UTC (8 years, 8 months ago) by nmeucci
File size: 13815 byte(s)
Amélioration des métadonnées des documents relatifs aux commissions.

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26