1 |
fmichon |
1022 |
<?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 |
|
|
function commission($id,&$db,$debug) { |
10 |
|
|
$this->constructeur($id,$db,$debug); |
11 |
|
|
}// fin constructeur |
12 |
|
|
|
13 |
fmichon |
1332 |
function afterFormSpecificContent() { |
14 |
vpihour |
1389 |
|
15 |
|
|
//Le sous-formulaire spécifique ne s'affiche qu'en consultation |
16 |
|
|
if ( $this->parameters['maj'] == 3 ){ |
17 |
|
|
$f = $this->f; |
18 |
|
|
include "../app/manage_commission.php"; |
19 |
|
|
} |
20 |
fmichon |
1332 |
} |
21 |
vpihour |
1389 |
|
22 |
|
|
//Le type de commission n'est pas modifiable une fois la commission ajoutée |
23 |
|
|
function setType(&$form,$maj) { |
24 |
|
|
parent::setType($form,$maj); |
25 |
|
|
|
26 |
vpihour |
1401 |
//Cache le champ code en ajout |
27 |
|
|
if ( $maj == 0 ){ |
28 |
|
|
|
29 |
|
|
$form->setType('code', 'hidden'); |
30 |
|
|
} |
31 |
|
|
|
32 |
vpihour |
1389 |
if ( $maj > 0 ) { |
33 |
vpihour |
1390 |
$form->setType('commission_type', 'selecthiddenstatic'); |
34 |
vpihour |
1401 |
$form->setType('code', 'hiddenstatic'); |
35 |
vpihour |
1389 |
} |
36 |
|
|
} |
37 |
fmichon |
1332 |
|
38 |
vpihour |
1389 |
//Action javascript au changement du type de la commission |
39 |
|
|
function setOnchange(&$form,$maj){ |
40 |
|
|
parent::setOnchange($form,$maj); |
41 |
|
|
|
42 |
|
|
$form->setOnchange("commission_type","chargeDonneesCommissionType(this.value);"); |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
// Date du jour par défaut |
46 |
|
|
function setVal(&$form, $maj, $validation, &$db) { |
47 |
|
|
|
48 |
|
|
if( $maj == 0 ) { |
49 |
|
|
|
50 |
|
|
$form->setVal("date_commission",date('d/m/Y')); |
51 |
|
|
} |
52 |
|
|
} |
53 |
vpihour |
1401 |
|
54 |
|
|
// Génération automatique du code de la commission |
55 |
|
|
function triggerajouter($id,&$db,$val,$DEBUG) { |
56 |
|
|
|
57 |
|
|
// Récupération du code du type de la commission |
58 |
|
|
$codeTypeCommission = $this->getCodeTypeCommission($val['commission_type']); |
59 |
|
|
|
60 |
|
|
//Formatte la date |
61 |
|
|
$dateFormatee = $this->formatDate($val['date_commission']); |
62 |
|
|
|
63 |
|
|
$this->valF['code'] = $codeTypeCommission.$dateFormatee; |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
// Génération automatique du numéro de commission |
67 |
|
|
function triggermodifier($id,&$db,$val,$DEBUG) { |
68 |
|
|
|
69 |
|
|
// Récupération du code du type de la commission |
70 |
|
|
$codeTypeCommission = $this->getCodeTypeCommission($val['commission_type']); |
71 |
|
|
|
72 |
|
|
//Formatte la date |
73 |
|
|
$dateFormatee = $this->formatDate($val['date_commission']); |
74 |
|
|
|
75 |
|
|
$this->valF['code'] = $codeTypeCommission.$dateFormatee; |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
//Retourne le code du type de la commission passée en paramètre |
79 |
|
|
function getCodeTypeCommission($typeCommission){ |
80 |
|
|
|
81 |
|
|
$codeTypeCommission = ""; |
82 |
|
|
|
83 |
|
|
$sql = "SELECT |
84 |
|
|
code |
85 |
|
|
FROM |
86 |
|
|
".DB_PREFIXE."commission_type |
87 |
|
|
WHERE |
88 |
|
|
commission_type = ".$typeCommission; |
89 |
|
|
$codeTypeCommission = $this->db->getOne($sql); |
90 |
|
|
$this->addToLog("getDivisionFromDossier(): db->getone(\"".$sql."\")", VERBOSE_MODE); |
91 |
|
|
$this->f->isDatabaseError(); |
92 |
|
|
|
93 |
|
|
return $codeTypeCommission; |
94 |
|
|
} |
95 |
|
|
|
96 |
|
|
// Prend une date au format JJ/MM/AAAA et retourne AAAAMMJJ |
97 |
|
|
function formatDate($date){ |
98 |
|
|
|
99 |
|
|
$dateFormatee = explode('/',$date); |
100 |
|
|
$dateFormatee = $dateFormatee[2].$dateFormatee[1].$dateFormatee[0]; |
101 |
|
|
|
102 |
|
|
return $dateFormatee; |
103 |
|
|
} |
104 |
fmichon |
1022 |
}// fin classe |
105 |
|
|
?> |