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