1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 30/06/2016 13:14 |
4 |
|
5 |
require_once "../obj/om_dbform.class.php"; |
6 |
|
7 |
class civilite_gen extends om_dbform { |
8 |
|
9 |
var $table = "civilite"; |
10 |
var $clePrimaire = "civilite"; |
11 |
var $typeCle = "N"; |
12 |
var $required_field = array( |
13 |
"civilite", |
14 |
"code" |
15 |
); |
16 |
|
17 |
var $foreign_keys_extended = array( |
18 |
); |
19 |
|
20 |
|
21 |
|
22 |
function setvalF($val) { |
23 |
//affectation valeur formulaire |
24 |
$this->valF['code'] = $val['code']; |
25 |
if (!is_numeric($val['civilite'])) { |
26 |
$this->valF['civilite'] = ""; // -> requis |
27 |
} else { |
28 |
$this->valF['civilite'] = $val['civilite']; |
29 |
} |
30 |
if ($val['libelle'] == "") { |
31 |
$this->valF['libelle'] = NULL; |
32 |
} else { |
33 |
$this->valF['libelle'] = $val['libelle']; |
34 |
} |
35 |
if ($val['om_validite_debut'] != "") { |
36 |
$this->valF['om_validite_debut'] = $this->dateDB($val['om_validite_debut']); |
37 |
} else { |
38 |
$this->valF['om_validite_debut'] = NULL; |
39 |
} |
40 |
if ($val['om_validite_fin'] != "") { |
41 |
$this->valF['om_validite_fin'] = $this->dateDB($val['om_validite_fin']); |
42 |
} else { |
43 |
$this->valF['om_validite_fin'] = NULL; |
44 |
} |
45 |
} |
46 |
|
47 |
//================================================= |
48 |
//cle primaire automatique [automatic primary key] |
49 |
//================================================== |
50 |
|
51 |
function setId(&$dnu1 = null) { |
52 |
//numero automatique |
53 |
$this->valF[$this->clePrimaire] = $this->f->db->nextId(DB_PREFIXE.$this->table); |
54 |
} |
55 |
|
56 |
function setValFAjout($val) { |
57 |
//numero automatique -> pas de controle ajout cle primaire |
58 |
} |
59 |
|
60 |
function verifierAjout() { |
61 |
//numero automatique -> pas de verfication de cle primaire |
62 |
} |
63 |
/** |
64 |
* Methode verifier |
65 |
*/ |
66 |
function verifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
67 |
// On appelle la methode de la classe parent |
68 |
parent::verifier($val, $this->f->db, null); |
69 |
|
70 |
// gestion des dates de validites |
71 |
$date_debut = $this->valF['om_validite_debut']; |
72 |
$date_fin = $this->valF['om_validite_fin']; |
73 |
|
74 |
if ($date_debut != '' and $date_fin != '') { |
75 |
|
76 |
$date_debut = explode('-', $this->valF['om_validite_debut']); |
77 |
$date_fin = explode('-', $this->valF['om_validite_fin']); |
78 |
|
79 |
$time_debut = mktime(0, 0, 0, $date_debut[1], $date_debut[2], |
80 |
$date_debut[0]); |
81 |
$time_fin = mktime(0, 0, 0, $date_fin[1], $date_fin[2], |
82 |
$date_fin[0]); |
83 |
|
84 |
if ($time_debut > $time_fin or $time_debut == $time_fin) { |
85 |
$this->correct = false; |
86 |
$this->addToMessage(_('La date de fin de validite doit etre future a la de debut de validite.')); |
87 |
} |
88 |
} |
89 |
} |
90 |
|
91 |
|
92 |
//========================== |
93 |
// Formulaire [form] |
94 |
//========================== |
95 |
/** |
96 |
* |
97 |
*/ |
98 |
function setType(&$form, $maj) { |
99 |
// Récupération du mode de l'action |
100 |
$crud = $this->get_action_crud($maj); |
101 |
|
102 |
// MODE AJOUTER |
103 |
if ($maj == 0 || $crud == 'create') { |
104 |
$form->setType("code", "text"); |
105 |
$form->setType("civilite", "hidden"); |
106 |
$form->setType("libelle", "text"); |
107 |
if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) { |
108 |
$form->setType("om_validite_debut", "date"); |
109 |
} else { |
110 |
$form->setType("om_validite_debut", "hiddenstaticdate"); |
111 |
} |
112 |
if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) { |
113 |
$form->setType("om_validite_fin", "date"); |
114 |
} else { |
115 |
$form->setType("om_validite_fin", "hiddenstaticdate"); |
116 |
} |
117 |
} |
118 |
|
119 |
// MDOE MODIFIER |
120 |
if ($maj == 1 || $crud == 'update') { |
121 |
$form->setType("code", "text"); |
122 |
$form->setType("civilite", "hiddenstatic"); |
123 |
$form->setType("libelle", "text"); |
124 |
if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) { |
125 |
$form->setType("om_validite_debut", "date"); |
126 |
} else { |
127 |
$form->setType("om_validite_debut", "hiddenstaticdate"); |
128 |
} |
129 |
if ($this->f->isAccredited(array($this->table."_modifier_validite", $this->table, ))) { |
130 |
$form->setType("om_validite_fin", "date"); |
131 |
} else { |
132 |
$form->setType("om_validite_fin", "hiddenstaticdate"); |
133 |
} |
134 |
} |
135 |
|
136 |
// MODE SUPPRIMER |
137 |
if ($maj == 2 || $crud == 'delete') { |
138 |
$form->setType("code", "hiddenstatic"); |
139 |
$form->setType("civilite", "hiddenstatic"); |
140 |
$form->setType("libelle", "hiddenstatic"); |
141 |
$form->setType("om_validite_debut", "hiddenstatic"); |
142 |
$form->setType("om_validite_fin", "hiddenstatic"); |
143 |
} |
144 |
|
145 |
// MODE CONSULTER |
146 |
if ($maj == 3 || $crud == 'read') { |
147 |
$form->setType("code", "static"); |
148 |
$form->setType("civilite", "static"); |
149 |
$form->setType("libelle", "static"); |
150 |
$form->setType("om_validite_debut", "datestatic"); |
151 |
$form->setType("om_validite_fin", "datestatic"); |
152 |
} |
153 |
|
154 |
} |
155 |
|
156 |
|
157 |
function setOnchange(&$form, $maj) { |
158 |
//javascript controle client |
159 |
$form->setOnchange('civilite','VerifNum(this)'); |
160 |
$form->setOnchange('om_validite_debut','fdate(this)'); |
161 |
$form->setOnchange('om_validite_fin','fdate(this)'); |
162 |
} |
163 |
/** |
164 |
* Methode setTaille |
165 |
*/ |
166 |
function setTaille(&$form, $maj) { |
167 |
$form->setTaille("code", 20); |
168 |
$form->setTaille("civilite", 11); |
169 |
$form->setTaille("libelle", 30); |
170 |
$form->setTaille("om_validite_debut", 12); |
171 |
$form->setTaille("om_validite_fin", 12); |
172 |
} |
173 |
|
174 |
/** |
175 |
* Methode setMax |
176 |
*/ |
177 |
function setMax(&$form, $maj) { |
178 |
$form->setMax("code", 20); |
179 |
$form->setMax("civilite", 11); |
180 |
$form->setMax("libelle", 100); |
181 |
$form->setMax("om_validite_debut", 12); |
182 |
$form->setMax("om_validite_fin", 12); |
183 |
} |
184 |
|
185 |
|
186 |
function setLib(&$form, $maj) { |
187 |
//libelle des champs |
188 |
$form->setLib('code',_('code')); |
189 |
$form->setLib('civilite',_('civilite')); |
190 |
$form->setLib('libelle',_('libelle')); |
191 |
$form->setLib('om_validite_debut',_('om_validite_debut')); |
192 |
$form->setLib('om_validite_fin',_('om_validite_fin')); |
193 |
} |
194 |
/** |
195 |
* |
196 |
*/ |
197 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
198 |
|
199 |
// Inclusion du fichier de requêtes |
200 |
if (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) { |
201 |
include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"; |
202 |
} elseif (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) { |
203 |
include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"; |
204 |
} |
205 |
|
206 |
} |
207 |
|
208 |
|
209 |
//================================== |
210 |
// sous Formulaire |
211 |
//================================== |
212 |
|
213 |
|
214 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
215 |
$this->retourformulaire = $retourformulaire; |
216 |
$this->set_form_default_values($form, $maj, $validation); |
217 |
}// fin setValsousformulaire |
218 |
|
219 |
//================================== |
220 |
// cle secondaire |
221 |
//================================== |
222 |
|
223 |
/** |
224 |
* Methode clesecondaire |
225 |
*/ |
226 |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
227 |
// On appelle la methode de la classe parent |
228 |
parent::cleSecondaire($id); |
229 |
// Verification de la cle secondaire : demandeur |
230 |
$this->rechercheTable($this->f->db, "demandeur", "particulier_civilite", $id); |
231 |
// Verification de la cle secondaire : demandeur |
232 |
$this->rechercheTable($this->f->db, "demandeur", "personne_morale_civilite", $id); |
233 |
// Verification de la cle secondaire : signataire_arrete |
234 |
$this->rechercheTable($this->f->db, "signataire_arrete", "civilite", $id); |
235 |
} |
236 |
|
237 |
|
238 |
} |
239 |
|
240 |
?> |