1 |
<?php |
2 |
//$Id$ |
3 |
//gen openMairie le 22/06/2011 20:36 |
4 |
require_once (PATH_OPENMAIRIE."formulairedyn.class.php"); |
5 |
require_once (PATH_OPENMAIRIE."dbformdyn.class.php"); |
6 |
|
7 |
class om_widget_gen extends dbForm { |
8 |
var $table="om_widget"; |
9 |
var $clePrimaire="om_widget"; |
10 |
var $typeCle="N"; |
11 |
var $retourformulaire; |
12 |
|
13 |
function setvalF($val) { |
14 |
//affectation valeur formulaire |
15 |
$this->valF['om_widget'] = $val['om_widget']; |
16 |
$this->valF['om_collectivite'] = $val['om_collectivite']; |
17 |
$this->valF['libelle'] = $val['libelle']; |
18 |
$this->valF['lien'] = $val['lien']; |
19 |
$this->valF['texte'] = $val['texte']; |
20 |
$this->valF['om_profil'] = $val['om_profil']; |
21 |
} |
22 |
|
23 |
//================================================= |
24 |
//cle primaire automatique [automatic primary key] |
25 |
//================================================== |
26 |
|
27 |
function setId(&$db) { |
28 |
//numero automatique |
29 |
$this->valF[$this->table] = $db->nextId(DB_PREFIXE.$this->table); |
30 |
} |
31 |
|
32 |
function setValFAjout($val) { |
33 |
//numero automatique -> pas de controle ajout cle primaire |
34 |
} |
35 |
|
36 |
function verifierAjout() { |
37 |
//numero automatique -> pas de verfication de cle primaire |
38 |
} |
39 |
|
40 |
//==================================== |
41 |
// verifier avant validation [verify] |
42 |
//===================================== |
43 |
|
44 |
function verifier($val,&$db,$DEBUG) { |
45 |
// verifier le 2eme champ si $verifier = 1 dans gen/dyn/form.inc |
46 |
$this->correct=True; |
47 |
$f=" ! "; |
48 |
$imgv="<img src='../app/img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>"; |
49 |
if ($this->valF['om_collectivite']==""){ |
50 |
$this->msg= $this->msg.$imgv._('om_collectivite')." "._('obligatoire').$f; |
51 |
$this->correct=False; |
52 |
} |
53 |
} // fin verifier [end verify] |
54 |
|
55 |
//========================== |
56 |
// Formulaire [form] |
57 |
//========================== |
58 |
|
59 |
function setType(&$form,$maj) { |
60 |
//type |
61 |
if ($maj==0){ //ajout |
62 |
$form->setType('om_widget','hidden');// cle automatique |
63 |
if($this->retourformulaire=='om_collectivite') |
64 |
$form->setType('om_collectivite','hiddenstatic'); |
65 |
else |
66 |
if($_SESSION['niveau']==2) |
67 |
$form->setType('om_collectivite','select'); |
68 |
else |
69 |
$form->setType('om_collectivite','hiddenstatic'); |
70 |
$form->setType('libelle','text'); |
71 |
$form->setType('lien','text'); |
72 |
$form->setType('texte','textarea'); |
73 |
if($this->retourformulaire=='om_profil') |
74 |
$form->setType('om_profil','hiddenstatic'); |
75 |
else |
76 |
$form->setType('om_profil','select'); |
77 |
}// fin ajout |
78 |
if ($maj==1){ //modifier |
79 |
$form->setType('om_widget','hiddenstatic'); |
80 |
if($this->retourformulaire=='om_collectivite') |
81 |
$form->setType('om_collectivite','hiddenstatic'); |
82 |
else |
83 |
if($_SESSION['niveau']==2) |
84 |
$form->setType('om_collectivite','select'); |
85 |
else |
86 |
$form->setType('om_collectivite','hiddenstatic'); |
87 |
$form->setType('libelle','text'); |
88 |
$form->setType('lien','text'); |
89 |
$form->setType('texte','textarea'); |
90 |
if($this->retourformulaire=='om_profil') |
91 |
$form->setType('om_profil','hiddenstatic'); |
92 |
else |
93 |
$form->setType('om_profil','select'); |
94 |
}// fin modifier |
95 |
if ($maj==2){ //supprimer |
96 |
$form->setType('om_widget','hiddenstatic'); |
97 |
$form->setType('om_collectivite','hiddenstatic'); |
98 |
$form->setType('libelle','hiddenstatic'); |
99 |
$form->setType('lien','hiddenstatic'); |
100 |
$form->setType('texte','hiddenstatic'); |
101 |
$form->setType('om_profil','hiddenstatic'); |
102 |
}//fin supprimer |
103 |
} |
104 |
|
105 |
function setOnchange(&$form,$maj) { |
106 |
//javascript controle client |
107 |
$form->setOnchange('om_widget','VerifNum(this)'); |
108 |
$form->setOnchange('om_collectivite','VerifNum(this)'); |
109 |
} |
110 |
|
111 |
function setTaille(&$form,$maj) { |
112 |
//taille des champs affiches (text) |
113 |
$form->setTaille('om_widget',8); |
114 |
$form->setTaille('om_collectivite',8); |
115 |
$form->setTaille('libelle',40); |
116 |
$form->setTaille('lien',80); |
117 |
$form->setTaille('texte',80); |
118 |
$form->setTaille('om_profil',2); |
119 |
} |
120 |
|
121 |
function setMax(&$form,$maj) { |
122 |
//longueur max en saisie (text) |
123 |
$form->setMax('om_widget',8); |
124 |
$form->setMax('om_collectivite',8); |
125 |
$form->setMax('libelle',40); |
126 |
$form->setMax('lien',80); |
127 |
$form->setMax('texte',6); |
128 |
$form->setMax('om_profil',2); |
129 |
} |
130 |
|
131 |
function setLib(&$form,$maj) { |
132 |
//libelle des champs |
133 |
$form->setLib('om_widget',_('om_widget')); |
134 |
$form->setLib('om_collectivite',_('om_collectivite')); |
135 |
$form->setLib('libelle',_('libelle')); |
136 |
$form->setLib('lien',_('lien')); |
137 |
$form->setLib('texte',_('texte')); |
138 |
$form->setLib('om_profil',_('om_profil')); |
139 |
} |
140 |
|
141 |
function setSelect(&$form, $maj,&$db,$debug) { |
142 |
if(file_exists ("../sql/".$db->phptype."/".$this->table.".form.inc")) |
143 |
include ("../sql/".$db->phptype."/".$this->table.".form.inc"); |
144 |
if($maj<2){ |
145 |
// om_collectivite |
146 |
$contenu=array(); |
147 |
$res = $db->query($sql_om_collectivite); |
148 |
if (database::isError($res)) |
149 |
die($res->getMessage().$sql_om_collectivite); |
150 |
else{ |
151 |
if ($debug == 1) |
152 |
echo " la requete ".$sql_om_collectivite." est executee<br>"; |
153 |
$contenu[0][0]=''; |
154 |
$contenu[1][0]=_('choisir')." "._('om_collectivite'); |
155 |
$k=1; |
156 |
while ($row=& $res->fetchRow()){ |
157 |
$contenu[0][$k]=$row[0]; |
158 |
$contenu[1][$k]=$row[1]; |
159 |
$k++; |
160 |
} |
161 |
$form->setSelect('om_collectivite',$contenu); |
162 |
}// fin error db |
163 |
// om_profil |
164 |
$contenu=array(); |
165 |
$res = $db->query($sql_om_profil); |
166 |
if (database::isError($res)) |
167 |
die($res->getMessage().$sql_om_profil); |
168 |
else{ |
169 |
if ($debug == 1) |
170 |
echo " la requete ".$sql_om_profil." est executee<br>"; |
171 |
$contenu[0][0]=''; |
172 |
$contenu[1][0]=_('choisir')." "._('om_profil'); |
173 |
$k=1; |
174 |
while ($row=& $res->fetchRow()){ |
175 |
$contenu[0][$k]=$row[0]; |
176 |
$contenu[1][$k]=$row[1]; |
177 |
$k++; |
178 |
} |
179 |
$form->setSelect('om_profil',$contenu); |
180 |
}// fin error db |
181 |
}// fin maj |
182 |
}// fin select |
183 |
|
184 |
function setVal(&$form,$maj,$validation,&$db,$DEBUG=null){ |
185 |
if($validation==0 and $maj==0 and $_SESSION['niveau']==1) { |
186 |
$form->setVal('om_collectivite', $_SESSION['collectivite']); |
187 |
}// fin validation |
188 |
}// fin setVal |
189 |
|
190 |
//================================== |
191 |
// sous Formulaire [subform] |
192 |
//================================== |
193 |
|
194 |
function setValsousformulaire(&$form,$maj,$validation,$idxformulaire,$retourformulaire,$typeformulaire,&$db,$DEBUG=null){ |
195 |
$this->retourformulaire = $retourformulaire; |
196 |
if($validation==0) { |
197 |
if($retourformulaire =='om_collectivite') |
198 |
$form->setVal('om_collectivite', $idxformulaire); |
199 |
if($retourformulaire =='om_profil') |
200 |
$form->setVal('om_profil', $idxformulaire); |
201 |
}// fin validation |
202 |
}// fin setValsousformulaire |
203 |
|
204 |
//================================== |
205 |
// cle secondaire [secondary key] |
206 |
//================================== |
207 |
|
208 |
function cleSecondaire($id,&$db,$val,$debug) { |
209 |
$this->correct=True; |
210 |
$f=" ! "; |
211 |
$imgv="<img src='../app/img/punaise.png' style='vertical-align:middle' hspace='2' border='0'>"; |
212 |
// cle secondaire om_tdb |
213 |
$sql = "select * from ".DB_PREFIXE."om_tdb where om_widget ='".$id."'"; |
214 |
$res = $db->query($sql); |
215 |
if($debug==1) echo $sql; |
216 |
if (database::isError($res)) |
217 |
die($res->getMessage(). " => Echec ".$sql); |
218 |
else{ |
219 |
$nbligne=$res->numrows(); |
220 |
$this->msg = $this->msg.$imgv._('il_y_a')." ".$nbligne." "._('om_tdb')." "._('pour')." "._('om_widget')." [".$id."]<br>"; |
221 |
if($nbligne>0) |
222 |
$this->correct=false; |
223 |
} |
224 |
}// clesecondaire |
225 |
|
226 |
}// fin classe |
227 |
?> |