/[openfoncier]/branches/old-trunk/obj/demandeur.class.php
ViewVC logotype

Contents of /branches/old-trunk/obj/demandeur.class.php

Parent Directory Parent Directory | Revision Log Revision Log


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26