1 |
vpihour |
633 |
<?php |
2 |
|
|
//$Id$ |
3 |
|
|
//gen openMairie le 08/11/2012 14:59 |
4 |
|
|
|
5 |
|
|
require_once ("../gen/obj/demandeur.class.php"); |
6 |
|
|
|
7 |
|
|
class demandeur extends demandeur_gen { |
8 |
|
|
|
9 |
nhaye |
1105 |
var $required_tag = array("particulier_nom", |
10 |
|
|
"personne_morale_denomination", |
11 |
|
|
"personne_morale_raison_sociale"); |
12 |
vpihour |
633 |
function demandeur($id,&$db,$debug) { |
13 |
|
|
$this->constructeur($id,$db,$debug); |
14 |
|
|
}// fin constructeur |
15 |
vpihour |
703 |
|
16 |
vpihour |
805 |
/* |
17 |
|
|
* Pays par défaut : France |
18 |
|
|
*/ |
19 |
|
|
function setVal(&$form, $maj, $validation, &$db) { |
20 |
|
|
if($maj == 0) { |
21 |
|
|
$form->setVal("pays",'France'); |
22 |
|
|
} |
23 |
|
|
} |
24 |
vpihour |
799 |
|
25 |
|
|
/* |
26 |
nhaye |
1048 |
* Pays par défaut : France |
27 |
|
|
*/ |
28 |
|
|
function setValSousFormulaire(&$form, $maj, $validation, &$db) { |
29 |
|
|
if($maj == 0) { |
30 |
|
|
$form->setVal("pays",'France'); |
31 |
|
|
} |
32 |
|
|
} |
33 |
|
|
|
34 |
nhaye |
1105 |
/** |
35 |
|
|
* Surcharge de la méthode de vérification |
36 |
|
|
**/ |
37 |
|
|
function verifier($val, &$db, $DEBUG) { |
38 |
|
|
parent::verifier($val, $db, $DEBUG); |
39 |
|
|
// le nom du particulier est obligatoire |
40 |
|
|
if($this->valF['qualite'] == "particulier" AND $this->valF['particulier_nom'] == "") { |
41 |
|
|
$this->correct = false; |
42 |
|
|
$this->addToMessage(_("Le champ")." <span class=\"bold\">". |
43 |
|
|
_("particulier_nom")."</span> "._("est obligatoire.")); |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
// la dénomination ou la raison sociale est obligatoire pour une personne morale |
47 |
|
|
if($this->valF['qualite'] == "personne_morale" |
48 |
vpihour |
1456 |
AND $this->valF['personne_morale_denomination'] == "" |
49 |
|
|
AND $this->valF['personne_morale_raison_sociale'] == "") { |
50 |
nhaye |
1105 |
$this->correct = false; |
51 |
|
|
$this->addToMessage(_("Un des champs")." <span class=\"bold\">". |
52 |
|
|
_("personne_morale_denomination")."</span> ou <span class=\"bold\">". |
53 |
|
|
_("personne_morale_raison_sociale")."</span> "._("doit etre rempli.")); |
54 |
|
|
} |
55 |
|
|
|
56 |
|
|
} |
57 |
|
|
|
58 |
nhaye |
1048 |
/* |
59 |
vpihour |
799 |
* Select pour les champs qualite et type_demandeur |
60 |
|
|
*/ |
61 |
|
|
function setType(&$form,$maj) { |
62 |
|
|
parent::setType($form,$maj); |
63 |
|
|
if ($maj < 2) { //ajouter et modifier |
64 |
|
|
|
65 |
|
|
$form->setType('type_demandeur', 'select'); |
66 |
|
|
$form->setType('qualite', 'select'); |
67 |
nhaye |
1048 |
if($maj == 0 AND $this->getParameter("idx_demandeur") != "") { |
68 |
|
|
$form->setType('frequent','hidden'); |
69 |
|
|
$form->setType('qualite','selectdisabled'); |
70 |
|
|
$form->setType('particulier_nom','textdisabled'); |
71 |
|
|
$form->setType('particulier_prenom','textdisabled'); |
72 |
|
|
$form->setType('particulier_date_naissance','datedisabled'); |
73 |
|
|
$form->setType('particulier_commune_naissance','textdisabled'); |
74 |
|
|
$form->setType('particulier_departement_naissance','textdisabled'); |
75 |
|
|
$form->setType('personne_morale_denomination','textdisabled'); |
76 |
|
|
$form->setType('personne_morale_raison_sociale','textdisabled'); |
77 |
|
|
$form->setType('personne_morale_siret','textdisabled'); |
78 |
|
|
$form->setType('personne_morale_categorie_juridique','textdisabled'); |
79 |
|
|
$form->setType('personne_morale_nom','textdisabled'); |
80 |
|
|
$form->setType('personne_morale_prenom','textdisabled'); |
81 |
|
|
$form->setType('particulier_civilite','selectdisabled'); |
82 |
|
|
$form->setType('personne_morale_civilite','selectdisabled'); |
83 |
|
|
$form->setType('telephone_fixe','textdisabled'); |
84 |
|
|
$form->setType('telephone_mobile','textdisabled'); |
85 |
|
|
$form->setType('indicatif','textdisabled'); |
86 |
|
|
$form->setType('courriel','textdisabled'); |
87 |
|
|
|
88 |
|
|
} |
89 |
nhaye |
1617 |
// XXX |
90 |
nhaye |
1042 |
// Champs disabled pour la modif de petitionnaires frequents |
91 |
|
|
// Solution temporaire |
92 |
|
|
if ($maj==1){ //modifier |
93 |
|
|
if($this->getVal('frequent') == 't') { |
94 |
nhaye |
1118 |
$form->setType('qualite','selecthiddenstatic'); |
95 |
|
|
$form->setType('particulier_nom','static'); |
96 |
|
|
$form->setType('particulier_prenom','static'); |
97 |
|
|
$form->setType('particulier_date_naissance','datestatic'); |
98 |
|
|
$form->setType('particulier_commune_naissance','static'); |
99 |
|
|
$form->setType('particulier_departement_naissance','static'); |
100 |
|
|
$form->setType('personne_morale_denomination','static'); |
101 |
|
|
$form->setType('personne_morale_raison_sociale','static'); |
102 |
|
|
$form->setType('personne_morale_siret','static'); |
103 |
|
|
$form->setType('personne_morale_categorie_juridique','static'); |
104 |
|
|
$form->setType('personne_morale_nom','static'); |
105 |
|
|
$form->setType('personne_morale_prenom','static'); |
106 |
|
|
$form->setType('numero','static'); |
107 |
|
|
$form->setType('voie','static'); |
108 |
|
|
$form->setType('complement','static'); |
109 |
|
|
$form->setType('lieu_dit','static'); |
110 |
|
|
$form->setType('localite','static'); |
111 |
|
|
$form->setType('code_postal','static'); |
112 |
|
|
$form->setType('bp','static'); |
113 |
|
|
$form->setType('cedex','static'); |
114 |
|
|
$form->setType('pays','static'); |
115 |
|
|
$form->setType('division_territoriale','static'); |
116 |
|
|
$form->setType('telephone_fixe','static'); |
117 |
|
|
$form->setType('telephone_mobile','static'); |
118 |
|
|
$form->setType('indicatif','static'); |
119 |
|
|
$form->setType('courriel','static'); |
120 |
|
|
$form->setType('notification','checkboxstatic'); |
121 |
|
|
$form->setType('frequent','checkboxstatic'); |
122 |
|
|
$form->setType('particulier_civilite','selecthiddenstatic'); |
123 |
|
|
$form->setType('personne_morale_civilite','selecthiddenstatic'); |
124 |
nhaye |
1042 |
} |
125 |
|
|
}// fin modifier |
126 |
vpihour |
799 |
} |
127 |
nhaye |
850 |
$form->setType('demandeur', 'hidden'); |
128 |
nhaye |
1042 |
|
129 |
vpihour |
799 |
} |
130 |
|
|
|
131 |
|
|
/* |
132 |
|
|
* Select pour le type_demandeur et qualite |
133 |
|
|
*/ |
134 |
|
|
function setSelect(&$form, $maj,&$db,$debug) { |
135 |
|
|
parent::setSelect($form, $maj,$db,$debug); |
136 |
|
|
|
137 |
|
|
/*Lors d'un ajout ou d'une modification*/ |
138 |
|
|
if( $maj < 2 ){ |
139 |
|
|
|
140 |
|
|
/* type_demandeur*/ |
141 |
|
|
$contenu=array(); |
142 |
|
|
|
143 |
|
|
$contenu[0][0]=""; |
144 |
|
|
$contenu[1][0]=_('choisir')." "._('type_demandeur'); |
145 |
|
|
$contenu[0][1]="petitionnaire"; |
146 |
|
|
$contenu[1][1]=_('petitionnaire'); |
147 |
|
|
$contenu[0][2]="delegataire"; |
148 |
|
|
$contenu[1][2]=_('delegataire'); |
149 |
|
|
|
150 |
|
|
$form->setSelect("type_demandeur",$contenu); |
151 |
|
|
|
152 |
|
|
/* qualite*/ |
153 |
|
|
$contenu=array(); |
154 |
|
|
|
155 |
vpihour |
805 |
$contenu[0][0]="particulier"; |
156 |
|
|
$contenu[1][0]=_('particulier'); |
157 |
|
|
$contenu[0][1]="personne_morale"; |
158 |
|
|
$contenu[1][1]=_('personne morale'); |
159 |
vpihour |
799 |
|
160 |
|
|
$form->setSelect("qualite",$contenu); |
161 |
|
|
} |
162 |
|
|
} |
163 |
|
|
|
164 |
|
|
/* |
165 |
vpihour |
1058 |
* Ajoute l'action javascript sur le select de la qualité |
166 |
vpihour |
799 |
*/ |
167 |
|
|
function setOnchange(&$form,$maj){ |
168 |
|
|
parent::setOnchange($form,$maj); |
169 |
|
|
|
170 |
|
|
$form->setOnchange("qualite","changeDemandeurType('qualite');"); |
171 |
|
|
} |
172 |
nhaye |
802 |
|
173 |
|
|
/** |
174 |
nhaye |
807 |
* Ajout d'un champs caché permettant de linker l'id du demandeur |
175 |
|
|
* recement ajouté |
176 |
|
|
**/ |
177 |
|
|
function sousFormSpecificContent($maj) { |
178 |
nhaye |
1429 |
$id_demandeur = $this->getVal("demandeur"); |
179 |
|
|
if(isset($this->valF["demandeur"]) AND !empty($this->valF["demandeur"])) { |
180 |
nhaye |
807 |
echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"". |
181 |
nhaye |
1429 |
$this->valF["demandeur"]."\" />"; |
182 |
|
|
} elseif(isset($id_demandeur) AND !empty($id_demandeur) AND $maj == 1) { |
183 |
|
|
echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"". |
184 |
|
|
$this->getVal("demandeur")."\" />"; |
185 |
nhaye |
807 |
} |
186 |
|
|
} |
187 |
|
|
/** |
188 |
nhaye |
802 |
* Surcharge du lien de retour permettant de linker l'id du demandeur |
189 |
|
|
* recement ajouté |
190 |
|
|
**/ |
191 |
|
|
function retoursousformulaire($idxformulaire, $retourformulaire, $val, |
192 |
|
|
$objsf, $premiersf, $tricolsf, $validation, |
193 |
|
|
$idx, $maj, $retour) { |
194 |
nhaye |
807 |
if($retourformulaire === "demande") { |
195 |
nhaye |
802 |
echo "\n<a class=\"retour\" "; |
196 |
nhaye |
807 |
echo "href=\"#\">"; |
197 |
nhaye |
802 |
// |
198 |
|
|
echo _("Retour"); |
199 |
|
|
// |
200 |
|
|
echo "</a>\n"; |
201 |
|
|
} else { |
202 |
|
|
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
203 |
|
|
$objsf, $premiersf, $tricolsf, $validation, |
204 |
|
|
$idx, $maj, $retour); |
205 |
|
|
} |
206 |
|
|
} |
207 |
nhaye |
807 |
|
208 |
|
|
/** |
209 |
|
|
* Ajout du paramètre principal |
210 |
|
|
*/ |
211 |
|
|
function getDataSubmitSousForm() { |
212 |
vpihour |
1058 |
/*Création du lien de validation du sous-formulaire*/ |
213 |
nhaye |
807 |
$datasubmit = ""; |
214 |
|
|
$datasubmit .= "../scr/sousform.php"; |
215 |
|
|
$datasubmit .= "?"; |
216 |
|
|
$datasubmit .= "obj=".get_class($this); |
217 |
|
|
$datasubmit .= "&validation=".$this->getParameter("validation"); |
218 |
|
|
if ($this->getParameter("idx") != "]") { |
219 |
|
|
// |
220 |
|
|
if ($this->getParameter("maj") == 1) { // modifier |
221 |
|
|
$datasubmit .= "&action=1"; |
222 |
|
|
$datasubmit .= "&idx=".$this->getParameter("idx"); |
223 |
|
|
} else { // supprimer |
224 |
|
|
$datasubmit .= "&action=2"; |
225 |
|
|
$datasubmit .= "&idx=".$this->getParameter("idx"); |
226 |
|
|
} |
227 |
|
|
} |
228 |
|
|
$datasubmit .= "&premiersf=".$this->getParameter("premiersf"); |
229 |
|
|
$datasubmit .= "&retourformulaire=".$this->getParameter("retourformulaire"); |
230 |
|
|
$datasubmit .= "&trisf=".$this->getParameter("tricolsf"); |
231 |
|
|
$datasubmit .= "&idxformulaire=".$this->getParameter("idxformulaire"); |
232 |
|
|
$datasubmit .= "&principal=".$this->getParameter("principal"); |
233 |
|
|
// |
234 |
|
|
return $datasubmit; |
235 |
|
|
} |
236 |
nhaye |
828 |
|
237 |
|
|
/** |
238 |
|
|
* Synthèse des demandeurs pour le formulaire de la demande |
239 |
|
|
*/ |
240 |
nhaye |
838 |
function afficherSynthese($type, $linkable) { |
241 |
nhaye |
1108 |
switch ($type) { |
242 |
|
|
case 'petitionnaire_principal': |
243 |
|
|
$legend = _("Petitionnaire principal :"); |
244 |
|
|
break; |
245 |
nhaye |
838 |
|
246 |
nhaye |
1108 |
case 'delegataire': |
247 |
|
|
$legend = _("Delegataire :"); |
248 |
|
|
break; |
249 |
|
|
|
250 |
|
|
case 'petitionnaire': |
251 |
|
|
$legend = _("Petitionnaire :"); |
252 |
|
|
break; |
253 |
|
|
} |
254 |
nhaye |
1118 |
|
255 |
|
|
// Conteneur du demandeur |
256 |
|
|
echo "<div class=\"".$type." col_3\" id=\"".$type."_".$this->val[array_search('demandeur', $this->champs)]."\">\n"; |
257 |
|
|
echo "<div class=\"legend_synthese_demandeur\">\n"; |
258 |
nhaye |
1108 |
echo $legend; |
259 |
nhaye |
1118 |
echo "</div>\n"; |
260 |
|
|
echo "<div class=\"synthese_demandeur\">\n"; |
261 |
nhaye |
838 |
if($linkable) { |
262 |
|
|
echo "<a href=\"#\" onclick=\"removeDemandeur('". |
263 |
|
|
$type."_".$this->val[array_search('demandeur', $this->champs)]. |
264 |
|
|
"'); return false;\"> |
265 |
|
|
<span class=\"demandeur_del om-icon om-icon-16 om-icon-fix delete-16\" title=\"". |
266 |
|
|
_("Supprimer le demandeur")."\">"._("Supprimer le demandeur")."</span> |
267 |
|
|
</a>"; |
268 |
|
|
} |
269 |
vpihour |
1058 |
|
270 |
nhaye |
838 |
// Valeur de formulaire à retourner |
271 |
nhaye |
1062 |
echo "<input type=\"hidden\" class=\"demandeur_id\" name=\"".$type. |
272 |
nhaye |
838 |
(($type == "petitionnaire")? "[]":"" ). |
273 |
|
|
"\" value=\"".$this->val[array_search('demandeur', $this->champs)]."\" />\n"; |
274 |
vpihour |
1058 |
|
275 |
nhaye |
838 |
// Lien de modification du demandeur |
276 |
|
|
if($linkable) { |
277 |
|
|
echo "<a class=\"edit_demandeur\" href=\"#\" |
278 |
nhaye |
931 |
onclick=\"editDemandeur('".$this->val[array_search('type_demandeur', $this->champs)]."',". |
279 |
|
|
$this->val[array_search('demandeur', $this->champs)].",'". |
280 |
|
|
$type."',". |
281 |
nhaye |
838 |
$type."_".$this->val[array_search('demandeur', $this->champs)]. |
282 |
|
|
");return false;\">\n"; |
283 |
|
|
} |
284 |
vpihour |
1058 |
|
285 |
nhaye |
838 |
// Affichage des infos du demandeur |
286 |
nhaye |
828 |
if($this->val[array_search('qualite', $this->champs)] == 'particulier') { |
287 |
nhaye |
847 |
if(!empty($this->val[array_search('civilite', $this->champs)])) { |
288 |
fmichon |
926 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=". |
289 |
nhaye |
847 |
$this->val[array_search('civilite', $this->champs)]; |
290 |
vpihour |
1777 |
$civilite = $this->db->getone($sql); |
291 |
|
|
$this->f->addToLog("afficherSynthese() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
292 |
|
|
if ( database::isError($civilite)){ |
293 |
|
|
die(); |
294 |
|
|
} |
295 |
nhaye |
847 |
echo $civilite." "; |
296 |
|
|
} |
297 |
|
|
echo $this->val[array_search('particulier_nom', $this->champs)]." ". |
298 |
nhaye |
838 |
$this->val[array_search('particulier_prenom', $this->champs)]."<br/>\n"; |
299 |
nhaye |
828 |
} else { |
300 |
|
|
echo $this->val[array_search('personne_morale_raison_sociale', $this->champs)]." ". |
301 |
nhaye |
838 |
$this->val[array_search('personne_morale_denomination', $this->champs)]."<br/>\n"; |
302 |
nhaye |
847 |
if(!empty($this->val[array_search('personne_morale_civilite', $this->champs)])) { |
303 |
fmichon |
926 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=". |
304 |
nhaye |
847 |
$this->val[array_search('personne_morale_civilite', $this->champs)]; |
305 |
|
|
$civilite = $this->f->db->getone($sql); |
306 |
vpihour |
1777 |
$this->f->addToLog("afficherSynthese() : db->getone(\"".$sql."\");", VERBOSE_MODE); |
307 |
|
|
if ( database::isError($civilite)){ |
308 |
|
|
die(); |
309 |
|
|
} |
310 |
nhaye |
847 |
echo $civilite." "; |
311 |
|
|
} |
312 |
|
|
echo $this->val[array_search('personne_morale_nom', $this->champs)]." ". |
313 |
nhaye |
838 |
$this->val[array_search('personne_morale_nom', $this->champs)]."<br/>\n"; |
314 |
nhaye |
828 |
} |
315 |
|
|
echo (($this->val[array_search('numero', $this->champs)] != "")? |
316 |
|
|
$this->val[array_search('numero', $this->champs)]." " : ""). |
317 |
|
|
(($this->val[array_search('voie', $this->champs)] != "")? |
318 |
|
|
$this->val[array_search('voie', $this->champs)]." " : ""). |
319 |
|
|
(($this->val[array_search('complement', $this->champs)] != "")? |
320 |
nhaye |
839 |
$this->val[array_search('complement', $this->champs)]." " : "")."<br/>\n". |
321 |
nhaye |
828 |
(($this->val[array_search('code_postal', $this->champs)] != "")? |
322 |
|
|
$this->val[array_search('code_postal', $this->champs)]." " : ""). |
323 |
|
|
(($this->val[array_search('localite', $this->champs)] != "")? |
324 |
|
|
$this->val[array_search('localite', $this->champs)]." " : ""). |
325 |
|
|
(($this->val[array_search('bp', $this->champs)] != "")? |
326 |
|
|
$this->val[array_search('bp', $this->champs)]." " : ""). |
327 |
|
|
(($this->val[array_search('cedex', $this->champs)] != "")? |
328 |
nhaye |
838 |
$this->val[array_search('cedex', $this->champs)]." " : "")."<br/>\n". |
329 |
nhaye |
828 |
(($this->val[array_search('telephone_fixe', $this->champs)] != "")? |
330 |
|
|
$this->val[array_search('telephone_fixe', $this->champs)]." " : ""). |
331 |
|
|
(($this->val[array_search('telephone_mobile', $this->champs)] != "")? |
332 |
|
|
$this->val[array_search('telephone_mobile', $this->champs)]." " : ""); |
333 |
nhaye |
838 |
if($linkable) { |
334 |
|
|
echo "</a>\n"; |
335 |
|
|
} |
336 |
|
|
echo "</div>\n"; |
337 |
nhaye |
1118 |
echo "</div>\n"; |
338 |
nhaye |
828 |
} |
339 |
|
|
|
340 |
vpihour |
633 |
}// fin classe |
341 |
|
|
?> |