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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3730 - (show annotations)
Fri Mar 18 11:50:26 2016 UTC (8 years, 10 months ago) by mbroquet
File size: 13903 byte(s)
Actualisation du trunk
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 // Verification du verrou
223 $this->testverrou();
224 // Si les verifications precedentes sont correctes, on procede a
225 // la modification, sinon on ne fait rien et on retourne une erreur
226 if ($this->correct) {
227 // Execution du trigger 'before' specifique au MODE 'update'
228 $this->triggermodifier( $id, $this->db, $this->val, DEBUG);
229
230 //Modifie uniquement les valeurs des champs concernant la finalisation
231 //du document
232 $valF = array(
233 "om_final_commission_".$champ => TRUE,
234 "om_fichier_commission_".$champ => $uid
235 );
236
237 // Execution de la requête de modification des donnees de l'attribut
238 // valF de l'objet dans l'attribut table de l'objet
239 $res = $this->db->autoExecute(DB_PREFIXE.$this->table, $valF,
240 DB_AUTOQUERY_UPDATE, $this->getCle($id));
241 // Si une erreur survient
242 if (database::isError($res)) {
243 // Appel de la methode de recuperation des erreurs
244 $this->erreur_db($res->getDebugInfo(), $res->getMessage(), '');
245 } else {
246 // Log
247 $this->addToLog(_("Requete executee"), VERBOSE_MODE);
248 // Log
249 $message = _("Enregistrement")."&nbsp;".$id."&nbsp;";
250 $message .= _("de la table")."&nbsp;\"".$this->table."\"&nbsp;";
251 $message .= "[&nbsp;".$this->db->affectedRows()."&nbsp;";
252 $message .= _("enregistrement(s) mis a jour")."&nbsp;]";
253 $this->addToLog($message, VERBOSE_MODE);
254 // Mise en place du verrou pour ne pas finaliser plusieurs fois
255 // le meme document
256 $this->verrouille();
257 // Execution du trigger 'after' specifique au MODE 'update'
258 $this->triggermodifierapres($id, $this->db, $this->val, DEBUG);
259
260 return $lien;
261 }
262 } else {
263 // Message d'echec (saut d'une ligne supplementaire avant le
264 // message pour qu'il soit mis en evidence)
265 $this->addToLog(
266 _("Finalisation non enregistree")." - ".
267 _("id commission_").$champ." = ".$id." - ".
268 _("uid fichier")." = ".$uid
269 );
270 return -1;
271 }
272 }
273 // Si le document n'a pas été stocké
274 else{
275 $this->addToLog(
276 _("Finalisation non enregistree")." - ".
277 _("id commission_").$champ." = ".$id." - ".
278 _("uid fichier")." = ".$uid
279 );
280 return -1;
281 }
282 }
283
284 /**
285 * Récupération du numéro de dossier d'instruction à ajouter aux métadonnées
286 * @return chaîne vide
287 */
288 protected function getDossier() {
289 return "";
290 }
291 /**
292 * Récupération la version du dossier d'instruction à ajouter aux métadonnées
293 * @return chaîne vide
294 */
295 protected function getDossierVersion() {
296 return "";
297 }
298 /**
299 * Récupération du numéro de dossier d'autorisation à ajouter aux métadonnées
300 * @return chaîne vide
301 */
302 protected function getNumDemandeAutor() {
303 return "";
304 }
305 /**
306 * Récupération de la date de demande initiale du dossier à ajouter aux métadonnées
307 * @return chaîne vide
308 */
309 protected function getAnneemoisDemandeAutor() {
310 return "";
311 }
312 /**
313 * Récupération du type de dossier d'instruction à ajouter aux métadonnées
314 * @return chaîne vide
315 */
316 protected function getTypeInstruction() {
317 return "";
318 }
319 /**
320 * Récupération du statut du dossier d'autorisation à ajouter aux métadonnées
321 * @return chaîne vide
322 */
323 protected function getStatutAutorisation() {
324 return "";
325 }
326 /**
327 * Récupération du type de dossier d'autorisation à ajouter aux métadonnées
328 * @return chaîne vide
329 */
330 protected function getTypeAutorisation() {
331 return "";
332 }
333 /**
334 * Récupération de la date d'ajout de document à ajouter aux métadonnées
335 * @return date de l'évènement
336 */
337 protected function getDateEvenementDocument() {
338 return date("Y-m-d");
339 }
340 /**
341 * Récupération du groupe d'instruction à ajouter aux métadonnées
342 * @return string Groupe d'instruction
343 */
344 protected function getGroupeInstruction() {
345 return "ADS";
346 }
347 /**
348 * Récupération du type du document à ajouter aux métadonnées
349 * @return string Type de document
350 */
351 protected function getTitleOrdreCommission() {
352 return "Ordre du jour de commission";
353 }
354 /**
355 * Récupération du type du document à ajouter aux métadonnées
356 * @return string Type de document
357 */
358 protected function getTitleCompteRenduCommission() {
359 return "Compte-rendu de commission";
360 }
361
362 }// fin classe
363 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26