1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 16/02/2015 10:29 |
4 |
|
5 |
require_once "../obj/om_dbform.class.php"; |
6 |
|
7 |
class groupe_gen extends om_dbform { |
8 |
|
9 |
var $table = "groupe"; |
10 |
var $clePrimaire = "groupe"; |
11 |
var $typeCle = "N"; |
12 |
var $required_field = array( |
13 |
"genre", |
14 |
"groupe" |
15 |
); |
16 |
|
17 |
var $foreign_keys_extended = array( |
18 |
"genre" => array("genre", ), |
19 |
); |
20 |
|
21 |
|
22 |
|
23 |
function setvalF($val) { |
24 |
//affectation valeur formulaire |
25 |
if (!is_numeric($val['groupe'])) { |
26 |
$this->valF['groupe'] = ""; // -> requis |
27 |
} else { |
28 |
$this->valF['groupe'] = $val['groupe']; |
29 |
} |
30 |
if ($val['code'] == "") { |
31 |
$this->valF['code'] = NULL; |
32 |
} else { |
33 |
$this->valF['code'] = $val['code']; |
34 |
} |
35 |
if ($val['libelle'] == "") { |
36 |
$this->valF['libelle'] = NULL; |
37 |
} else { |
38 |
$this->valF['libelle'] = $val['libelle']; |
39 |
} |
40 |
$this->valF['description'] = $val['description']; |
41 |
if (!is_numeric($val['genre'])) { |
42 |
$this->valF['genre'] = ""; // -> requis |
43 |
} else { |
44 |
$this->valF['genre'] = $val['genre']; |
45 |
} |
46 |
} |
47 |
|
48 |
//================================================= |
49 |
//cle primaire automatique [automatic primary key] |
50 |
//================================================== |
51 |
|
52 |
function setId(&$dnu1 = null) { |
53 |
//numero automatique |
54 |
$this->valF[$this->clePrimaire] = $this->f->db->nextId(DB_PREFIXE.$this->table); |
55 |
} |
56 |
|
57 |
function setValFAjout($val) { |
58 |
//numero automatique -> pas de controle ajout cle primaire |
59 |
} |
60 |
|
61 |
function verifierAjout() { |
62 |
//numero automatique -> pas de verfication de cle primaire |
63 |
} |
64 |
|
65 |
//========================== |
66 |
// Formulaire [form] |
67 |
//========================== |
68 |
/** |
69 |
* |
70 |
*/ |
71 |
function setType(&$form, $maj) { |
72 |
|
73 |
// MODE AJOUTER |
74 |
if ($maj == 0) { |
75 |
$form->setType("groupe", "hidden"); |
76 |
$form->setType("code", "text"); |
77 |
$form->setType("libelle", "text"); |
78 |
$form->setType("description", "textarea"); |
79 |
if ($this->is_in_context_of_foreign_key("genre", $this->retourformulaire) |
80 |
&& $form->val["genre"] == $this->getParameter("idxformulaire")) { |
81 |
$form->setType("genre", "selecthiddenstatic"); |
82 |
} else { |
83 |
$form->setType("genre", "select"); |
84 |
} |
85 |
} |
86 |
|
87 |
// MDOE MODIFIER |
88 |
if ($maj == 1) { |
89 |
$form->setType("groupe", "hiddenstatic"); |
90 |
$form->setType("code", "text"); |
91 |
$form->setType("libelle", "text"); |
92 |
$form->setType("description", "textarea"); |
93 |
if ($this->is_in_context_of_foreign_key("genre", $this->retourformulaire) |
94 |
&& $form->val["genre"] == $this->getParameter("idxformulaire")) { |
95 |
$form->setType("genre", "selecthiddenstatic"); |
96 |
} else { |
97 |
$form->setType("genre", "select"); |
98 |
} |
99 |
} |
100 |
|
101 |
// MODE SUPPRIMER |
102 |
if ($maj == 2) { |
103 |
$form->setType("groupe", "hiddenstatic"); |
104 |
$form->setType("code", "hiddenstatic"); |
105 |
$form->setType("libelle", "hiddenstatic"); |
106 |
$form->setType("description", "hiddenstatic"); |
107 |
$form->setType("genre", "selectstatic"); |
108 |
} |
109 |
|
110 |
// MODE CONSULTER |
111 |
if ($maj == 3) { |
112 |
$form->setType("groupe", "static"); |
113 |
$form->setType("code", "static"); |
114 |
$form->setType("libelle", "static"); |
115 |
$form->setType("description", "textareastatic"); |
116 |
$form->setType("genre", "selectstatic"); |
117 |
} |
118 |
|
119 |
} |
120 |
|
121 |
|
122 |
function setOnchange(&$form, $maj) { |
123 |
//javascript controle client |
124 |
$form->setOnchange('groupe','VerifNum(this)'); |
125 |
$form->setOnchange('genre','VerifNum(this)'); |
126 |
} |
127 |
/** |
128 |
* Methode setTaille |
129 |
*/ |
130 |
function setTaille(&$form, $maj) { |
131 |
$form->setTaille("groupe", 11); |
132 |
$form->setTaille("code", 20); |
133 |
$form->setTaille("libelle", 30); |
134 |
$form->setTaille("description", 80); |
135 |
$form->setTaille("genre", 11); |
136 |
} |
137 |
|
138 |
/** |
139 |
* Methode setMax |
140 |
*/ |
141 |
function setMax(&$form, $maj) { |
142 |
$form->setMax("groupe", 11); |
143 |
$form->setMax("code", 20); |
144 |
$form->setMax("libelle", 100); |
145 |
$form->setMax("description", 6); |
146 |
$form->setMax("genre", 11); |
147 |
} |
148 |
|
149 |
|
150 |
function setLib(&$form, $maj) { |
151 |
//libelle des champs |
152 |
$form->setLib('groupe',_('groupe')); |
153 |
$form->setLib('code',_('code')); |
154 |
$form->setLib('libelle',_('libelle')); |
155 |
$form->setLib('description',_('description')); |
156 |
$form->setLib('genre',_('genre')); |
157 |
} |
158 |
/** |
159 |
* |
160 |
*/ |
161 |
function setSelect(&$form, $maj, &$dnu1 = null, $dnu2 = null) { |
162 |
|
163 |
// Inclusion du fichier de requêtes |
164 |
if (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php")) { |
165 |
include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc.php"; |
166 |
} elseif (file_exists("../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc")) { |
167 |
include "../sql/".OM_DB_PHPTYPE."/".$this->table.".form.inc"; |
168 |
} |
169 |
|
170 |
// genre |
171 |
$this->init_select($form, $this->f->db, $maj, null, "genre", $sql_genre, $sql_genre_by_id, false); |
172 |
} |
173 |
|
174 |
|
175 |
//================================== |
176 |
// sous Formulaire |
177 |
//================================== |
178 |
|
179 |
|
180 |
function setValsousformulaire(&$form, $maj, $validation, $idxformulaire, $retourformulaire, $typeformulaire, &$dnu1 = null, $dnu2 = null) { |
181 |
$this->retourformulaire = $retourformulaire; |
182 |
if($validation == 0) { |
183 |
if($this->is_in_context_of_foreign_key('genre', $this->retourformulaire)) |
184 |
$form->setVal('genre', $idxformulaire); |
185 |
}// fin validation |
186 |
$this->set_form_default_values($form, $maj, $validation); |
187 |
}// fin setValsousformulaire |
188 |
|
189 |
//================================== |
190 |
// cle secondaire |
191 |
//================================== |
192 |
|
193 |
/** |
194 |
* Methode clesecondaire |
195 |
*/ |
196 |
function cleSecondaire($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
197 |
// On appelle la methode de la classe parent |
198 |
parent::cleSecondaire($id); |
199 |
// Verification de la cle secondaire : demande_type |
200 |
$this->rechercheTable($this->f->db, "demande_type", "groupe", $id); |
201 |
// Verification de la cle secondaire : dossier_autorisation_type |
202 |
$this->rechercheTable($this->f->db, "dossier_autorisation_type", "groupe", $id); |
203 |
} |
204 |
|
205 |
|
206 |
} |
207 |
|
208 |
?> |