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 |
|
|
AND ($this->valF['personne_morale_denomination'] == "" |
49 |
|
|
OR $this->valF['personne_morale_raison_sociale'] == "")) { |
50 |
|
|
$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 |
1042 |
// Champs disabled pour la modif de petitionnaires frequents |
90 |
|
|
// Solution temporaire |
91 |
|
|
if ($maj==1){ //modifier |
92 |
|
|
if($this->getVal('frequent') == 't') { |
93 |
|
|
$form->setType('qualite','selectdisabled'); |
94 |
|
|
$form->setType('particulier_nom','textdisabled'); |
95 |
|
|
$form->setType('particulier_prenom','textdisabled'); |
96 |
|
|
$form->setType('particulier_date_naissance','datedisabled'); |
97 |
|
|
$form->setType('particulier_commune_naissance','textdisabled'); |
98 |
|
|
$form->setType('particulier_departement_naissance','textdisabled'); |
99 |
|
|
$form->setType('personne_morale_denomination','textdisabled'); |
100 |
|
|
$form->setType('personne_morale_raison_sociale','textdisabled'); |
101 |
|
|
$form->setType('personne_morale_siret','textdisabled'); |
102 |
|
|
$form->setType('personne_morale_categorie_juridique','textdisabled'); |
103 |
|
|
$form->setType('personne_morale_nom','textdisabled'); |
104 |
|
|
$form->setType('personne_morale_prenom','textdisabled'); |
105 |
|
|
$form->setType('numero','textdisabled'); |
106 |
|
|
$form->setType('voie','textdisabled'); |
107 |
|
|
$form->setType('complement','textdisabled'); |
108 |
|
|
$form->setType('lieu_dit','textdisabled'); |
109 |
|
|
$form->setType('localite','textdisabled'); |
110 |
|
|
$form->setType('code_postal','textdisabled'); |
111 |
|
|
$form->setType('bp','textdisabled'); |
112 |
|
|
$form->setType('cedex','textdisabled'); |
113 |
|
|
$form->setType('pays','textdisabled'); |
114 |
|
|
$form->setType('division_territoriale','textdisabled'); |
115 |
|
|
$form->setType('telephone_fixe','textdisabled'); |
116 |
|
|
$form->setType('telephone_mobile','textdisabled'); |
117 |
|
|
$form->setType('indicatif','textdisabled'); |
118 |
|
|
$form->setType('courriel','textdisabled'); |
119 |
|
|
$form->setType('notification','checkboxdisabled'); |
120 |
|
|
$form->setType('frequent','checkboxdisabled'); |
121 |
|
|
$form->setType('particulier_civilite','selectdisabled'); |
122 |
|
|
$form->setType('personne_morale_civilite','selectdisabled'); |
123 |
|
|
} |
124 |
|
|
}// fin modifier |
125 |
vpihour |
799 |
} |
126 |
nhaye |
850 |
$form->setType('demandeur', 'hidden'); |
127 |
nhaye |
1042 |
|
128 |
vpihour |
799 |
} |
129 |
|
|
|
130 |
|
|
/* |
131 |
|
|
* Select pour le type_demandeur et qualite |
132 |
|
|
*/ |
133 |
|
|
function setSelect(&$form, $maj,&$db,$debug) { |
134 |
|
|
parent::setSelect($form, $maj,$db,$debug); |
135 |
|
|
|
136 |
|
|
/*Lors d'un ajout ou d'une modification*/ |
137 |
|
|
if( $maj < 2 ){ |
138 |
|
|
|
139 |
|
|
/* type_demandeur*/ |
140 |
|
|
$contenu=array(); |
141 |
|
|
|
142 |
|
|
$contenu[0][0]=""; |
143 |
|
|
$contenu[1][0]=_('choisir')." "._('type_demandeur'); |
144 |
|
|
$contenu[0][1]="petitionnaire"; |
145 |
|
|
$contenu[1][1]=_('petitionnaire'); |
146 |
|
|
$contenu[0][2]="delegataire"; |
147 |
|
|
$contenu[1][2]=_('delegataire'); |
148 |
|
|
|
149 |
|
|
$form->setSelect("type_demandeur",$contenu); |
150 |
|
|
|
151 |
|
|
/* qualite*/ |
152 |
|
|
$contenu=array(); |
153 |
|
|
|
154 |
vpihour |
805 |
$contenu[0][0]="particulier"; |
155 |
|
|
$contenu[1][0]=_('particulier'); |
156 |
|
|
$contenu[0][1]="personne_morale"; |
157 |
|
|
$contenu[1][1]=_('personne morale'); |
158 |
vpihour |
799 |
|
159 |
|
|
$form->setSelect("qualite",$contenu); |
160 |
|
|
} |
161 |
|
|
} |
162 |
|
|
|
163 |
|
|
/* |
164 |
vpihour |
1058 |
* Ajoute l'action javascript sur le select de la qualité |
165 |
vpihour |
799 |
*/ |
166 |
|
|
function setOnchange(&$form,$maj){ |
167 |
|
|
parent::setOnchange($form,$maj); |
168 |
|
|
|
169 |
|
|
$form->setOnchange("qualite","changeDemandeurType('qualite');"); |
170 |
|
|
} |
171 |
nhaye |
802 |
|
172 |
|
|
/** |
173 |
nhaye |
807 |
* Ajout d'un champs caché permettant de linker l'id du demandeur |
174 |
|
|
* recement ajouté |
175 |
|
|
**/ |
176 |
|
|
function sousFormSpecificContent($maj) { |
177 |
|
|
if(isset($this->valF['demandeur']) AND !empty($this->valF['demandeur'])) { |
178 |
|
|
echo "<input id=\"id_retour\" name=\"idRetour\" type=\"hidden\" value=\"". |
179 |
|
|
$this->valF['demandeur']."\" />"; |
180 |
|
|
} |
181 |
|
|
} |
182 |
|
|
/** |
183 |
nhaye |
802 |
* Surcharge du lien de retour permettant de linker l'id du demandeur |
184 |
|
|
* recement ajouté |
185 |
|
|
**/ |
186 |
|
|
function retoursousformulaire($idxformulaire, $retourformulaire, $val, |
187 |
|
|
$objsf, $premiersf, $tricolsf, $validation, |
188 |
|
|
$idx, $maj, $retour) { |
189 |
nhaye |
807 |
if($retourformulaire === "demande") { |
190 |
nhaye |
802 |
echo "\n<a class=\"retour\" "; |
191 |
nhaye |
807 |
echo "href=\"#\">"; |
192 |
nhaye |
802 |
// |
193 |
|
|
echo _("Retour"); |
194 |
|
|
// |
195 |
|
|
echo "</a>\n"; |
196 |
|
|
} else { |
197 |
|
|
parent::retoursousformulaire($idxformulaire, $retourformulaire, $val, |
198 |
|
|
$objsf, $premiersf, $tricolsf, $validation, |
199 |
|
|
$idx, $maj, $retour); |
200 |
|
|
} |
201 |
|
|
} |
202 |
nhaye |
807 |
|
203 |
|
|
/** |
204 |
|
|
* Ajout du paramètre principal |
205 |
|
|
*/ |
206 |
|
|
function getDataSubmitSousForm() { |
207 |
vpihour |
1058 |
/*Création du lien de validation du sous-formulaire*/ |
208 |
nhaye |
807 |
$datasubmit = ""; |
209 |
|
|
$datasubmit .= "../scr/sousform.php"; |
210 |
|
|
$datasubmit .= "?"; |
211 |
|
|
$datasubmit .= "obj=".get_class($this); |
212 |
|
|
$datasubmit .= "&validation=".$this->getParameter("validation"); |
213 |
|
|
if ($this->getParameter("idx") != "]") { |
214 |
|
|
// |
215 |
|
|
if ($this->getParameter("maj") == 1) { // modifier |
216 |
|
|
$datasubmit .= "&action=1"; |
217 |
|
|
$datasubmit .= "&idx=".$this->getParameter("idx"); |
218 |
|
|
} else { // supprimer |
219 |
|
|
$datasubmit .= "&action=2"; |
220 |
|
|
$datasubmit .= "&idx=".$this->getParameter("idx"); |
221 |
|
|
} |
222 |
|
|
} |
223 |
|
|
$datasubmit .= "&premiersf=".$this->getParameter("premiersf"); |
224 |
|
|
$datasubmit .= "&retourformulaire=".$this->getParameter("retourformulaire"); |
225 |
|
|
$datasubmit .= "&trisf=".$this->getParameter("tricolsf"); |
226 |
|
|
$datasubmit .= "&idxformulaire=".$this->getParameter("idxformulaire"); |
227 |
|
|
$datasubmit .= "&principal=".$this->getParameter("principal"); |
228 |
|
|
// |
229 |
|
|
return $datasubmit; |
230 |
|
|
} |
231 |
nhaye |
828 |
|
232 |
|
|
/** |
233 |
|
|
* Synthèse des demandeurs pour le formulaire de la demande |
234 |
|
|
*/ |
235 |
nhaye |
838 |
function afficherSynthese($type, $linkable) { |
236 |
|
|
|
237 |
|
|
// Conteneur du demandeur |
238 |
|
|
echo "<div class=\"".$type."\" id=\"".$type."_".$this->val[array_search('demandeur', $this->champs)]."\">\n"; |
239 |
|
|
if($linkable) { |
240 |
|
|
echo "<a href=\"#\" onclick=\"removeDemandeur('". |
241 |
|
|
$type."_".$this->val[array_search('demandeur', $this->champs)]. |
242 |
|
|
"'); return false;\"> |
243 |
|
|
<span class=\"demandeur_del om-icon om-icon-16 om-icon-fix delete-16\" title=\"". |
244 |
|
|
_("Supprimer le demandeur")."\">"._("Supprimer le demandeur")."</span> |
245 |
|
|
</a>"; |
246 |
|
|
} |
247 |
vpihour |
1058 |
|
248 |
nhaye |
838 |
// Valeur de formulaire à retourner |
249 |
nhaye |
1062 |
echo "<input type=\"hidden\" class=\"demandeur_id\" name=\"".$type. |
250 |
nhaye |
838 |
(($type == "petitionnaire")? "[]":"" ). |
251 |
|
|
"\" value=\"".$this->val[array_search('demandeur', $this->champs)]."\" />\n"; |
252 |
vpihour |
1058 |
|
253 |
nhaye |
838 |
// Lien de modification du demandeur |
254 |
|
|
if($linkable) { |
255 |
|
|
echo "<a class=\"edit_demandeur\" href=\"#\" |
256 |
nhaye |
931 |
onclick=\"editDemandeur('".$this->val[array_search('type_demandeur', $this->champs)]."',". |
257 |
|
|
$this->val[array_search('demandeur', $this->champs)].",'". |
258 |
|
|
$type."',". |
259 |
nhaye |
838 |
$type."_".$this->val[array_search('demandeur', $this->champs)]. |
260 |
|
|
");return false;\">\n"; |
261 |
|
|
} |
262 |
vpihour |
1058 |
|
263 |
nhaye |
838 |
// Affichage des infos du demandeur |
264 |
nhaye |
828 |
if($this->val[array_search('qualite', $this->champs)] == 'particulier') { |
265 |
nhaye |
847 |
if(!empty($this->val[array_search('civilite', $this->champs)])) { |
266 |
fmichon |
926 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=". |
267 |
nhaye |
847 |
$this->val[array_search('civilite', $this->champs)]; |
268 |
|
|
$civilite = $this->f->db->getone($sql); |
269 |
|
|
$this->f->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE); |
270 |
|
|
$this->f->isDatabaseError($civilite); |
271 |
|
|
echo $civilite." "; |
272 |
|
|
} |
273 |
|
|
echo $this->val[array_search('particulier_nom', $this->champs)]." ". |
274 |
nhaye |
838 |
$this->val[array_search('particulier_prenom', $this->champs)]."<br/>\n"; |
275 |
nhaye |
828 |
} else { |
276 |
|
|
echo $this->val[array_search('personne_morale_raison_sociale', $this->champs)]." ". |
277 |
nhaye |
838 |
$this->val[array_search('personne_morale_denomination', $this->champs)]."<br/>\n"; |
278 |
nhaye |
847 |
if(!empty($this->val[array_search('personne_morale_civilite', $this->champs)])) { |
279 |
fmichon |
926 |
$sql = "SELECT libelle FROM ".DB_PREFIXE."civilite WHERE civilite=". |
280 |
nhaye |
847 |
$this->val[array_search('personne_morale_civilite', $this->champs)]; |
281 |
|
|
$civilite = $this->f->db->getone($sql); |
282 |
|
|
$this->f->addToLog("db->getone(\"".$sql."\");", VERBOSE_MODE); |
283 |
|
|
$this->f->isDatabaseError($civilite); |
284 |
|
|
echo $civilite." "; |
285 |
|
|
} |
286 |
|
|
echo $this->val[array_search('personne_morale_nom', $this->champs)]." ". |
287 |
nhaye |
838 |
$this->val[array_search('personne_morale_nom', $this->champs)]."<br/>\n"; |
288 |
nhaye |
828 |
} |
289 |
|
|
echo (($this->val[array_search('numero', $this->champs)] != "")? |
290 |
|
|
$this->val[array_search('numero', $this->champs)]." " : ""). |
291 |
|
|
(($this->val[array_search('voie', $this->champs)] != "")? |
292 |
|
|
$this->val[array_search('voie', $this->champs)]." " : ""). |
293 |
|
|
(($this->val[array_search('complement', $this->champs)] != "")? |
294 |
nhaye |
839 |
$this->val[array_search('complement', $this->champs)]." " : "")."<br/>\n". |
295 |
nhaye |
828 |
(($this->val[array_search('code_postal', $this->champs)] != "")? |
296 |
|
|
$this->val[array_search('code_postal', $this->champs)]." " : ""). |
297 |
|
|
(($this->val[array_search('localite', $this->champs)] != "")? |
298 |
|
|
$this->val[array_search('localite', $this->champs)]." " : ""). |
299 |
|
|
(($this->val[array_search('bp', $this->champs)] != "")? |
300 |
|
|
$this->val[array_search('bp', $this->champs)]." " : ""). |
301 |
|
|
(($this->val[array_search('cedex', $this->champs)] != "")? |
302 |
nhaye |
838 |
$this->val[array_search('cedex', $this->champs)]." " : "")."<br/>\n". |
303 |
nhaye |
828 |
(($this->val[array_search('telephone_fixe', $this->champs)] != "")? |
304 |
|
|
$this->val[array_search('telephone_fixe', $this->champs)]." " : ""). |
305 |
|
|
(($this->val[array_search('telephone_mobile', $this->champs)] != "")? |
306 |
|
|
$this->val[array_search('telephone_mobile', $this->champs)]." " : ""); |
307 |
nhaye |
838 |
if($linkable) { |
308 |
|
|
echo "</a>\n"; |
309 |
|
|
} |
310 |
|
|
echo "</div>\n"; |
311 |
nhaye |
828 |
} |
312 |
|
|
|
313 |
vpihour |
633 |
}// fin classe |
314 |
|
|
?> |