1 |
<?php |
2 |
/** |
3 |
* Ce fichier est destine a gerer les transferts sitadel |
4 |
* @package openmairie_foncier |
5 |
* @version SVN : $Id |
6 |
*/ |
7 |
|
8 |
class sitadel { |
9 |
|
10 |
var $dossier; |
11 |
var $row; // dossier |
12 |
var $val; // parametre par defaut |
13 |
var $parametre; //parametre dossier |
14 |
var $DEBUG=0; // 1 = valeur |
15 |
|
16 |
function sitadel($dossier) { |
17 |
$this->dossier=$dossier; |
18 |
// recherche de parametre |
19 |
}// fin constructeur |
20 |
|
21 |
function entete($mouvement, $departement, $commune,$pf_departement){ |
22 |
// sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod |
23 |
$entete=$mouvement."|".$this->row['nature']."||".$pf_departement.$departement."|".$commune."|".$this->row['annee']. |
24 |
"|".substr($this->dossier,4,5)."|".substr($this->dossier,9,2)."|"; |
25 |
return $entete; |
26 |
} |
27 |
|
28 |
function etatcivil(){ |
29 |
// etat civil demandeur |
30 |
// codemo| |
31 |
if($this->row['demandeur_categorie']==9 |
32 |
or $this->row['demandeur_categorie']=="") |
33 |
$codemo=1;// personne physique |
34 |
else |
35 |
$codemo=2;// personne morale |
36 |
$etatcivil=$codemo."|"; // 1 personne physique ; 2 sinon |
37 |
// openfoncier civilite (5/8 ok), nom (80/30-> substr), societe (80/50->substr) |
38 |
// civpart|prenompart|nompart|denopm|rspm|siret|catjur|civrep|prenomrep|nomrep| |
39 |
// suivant codemo = 1 (personne physique) ou 2 (personne morale) |
40 |
// demandeur_civilite n est pas normalise Madame ou Monsieur |
41 |
if($codemo==1){ |
42 |
// *civpart*|*prenompart*|nompart|||||| |
43 |
$etatcivil.= $this->p('civpart')."|".$this->p('prenompart')."|"; |
44 |
$etatcivil.= $this->maj(substr($this->row['demandeur_nom'],0,30))."||||||||"; |
45 |
}else{ |
46 |
//denopm|*rspm*|*siret*|*catjur*|*civrep*|*prenomrep*|nomrep| |
47 |
$etatcivil.="|||"; // codemo=1 |
48 |
$etatcivil.=$this->maj(substr($this->row['demandeur_societe'],0,50))."|"; |
49 |
$etatcivil.=$this->maj(substr($this->row['categorie_libelle'],0,30))."|"; |
50 |
$etatcivil.=$this->p('rspm')."|".$this->p('siret')."|".$this->p('catjur')."|". |
51 |
$this->p('civrep')."|".$this->p('prenomrep'); // *** +1 |
52 |
$etatcivil.=$this->maj(substr($this->row['demandeur_nom'],0,30))."|"; |
53 |
} |
54 |
return $etatcivil; |
55 |
} |
56 |
|
57 |
function adresse(){ |
58 |
// openfoncier : adresse (80/ 26+38 -> substr sur 2 zones) - cp (5/5 OK) - ville (30/36 -> OK) |
59 |
// *numvoiemo*|*typvoiemo*|libvoiemo|lieuditmo(+)|communemo|codposmo|*bpmo*|*cedexmo*|*paysmo*|*divetermo| |
60 |
$adresse=""; |
61 |
$adresse = $this->p('numvoiemo')."|".$this->p('typvoiemo')."|". |
62 |
$adresse.= $this->maj(substr($this->row['demandeur_adresse'],0,26))."|". |
63 |
$this->maj(substr($this->row['demandeur_adresse'],26,38))."|"; |
64 |
$adresse.= $this->maj($this->row['demandeur_ville'])."|".$this->row['demandeur_cp']."|"; |
65 |
$adresse.= $this->p('bpmo')."|".$this->p('cedexmo')."|".$this->p('paysmo')."|".$this->p('divtermo')."|"; |
66 |
return $adresse; |
67 |
} |
68 |
|
69 |
|
70 |
function delegataire(){ |
71 |
// openFoncier civilite (non normalise monsieur/madame), nom (80/30 substr) |
72 |
// openfoncier : adresse (80/ 26+38 -> substr sur 2 zones) - cp (5/5 OK) - ville (30/32 -> OK) |
73 |
// *civtiers*|*prenomtier*|nomtier|*numvoietiers*|*typvoietiers*| |
74 |
// libvoietiers|lieudittier|communetier|codpostier |
75 |
// |*bptier*|*cedextier*|*paystier*|*divtertier*| |
76 |
$delegataire=""; |
77 |
if($this->row['delegataire']=='Oui'){ |
78 |
$delegataire.= $this->p('civtier')."|".$this->p('prenomtier'); |
79 |
$delegataire.="|".$this->maj(substr($this->row['delegataire_nom'],0,30))."|"; |
80 |
$delegataire.= "|".$this->p('typevoietier')."|".$this->maj(substr($this->row['delegataire_adresse'],0,26))."|". |
81 |
$this->maj(substr($this->row['delegataire_adresse'],26,38))."|"; |
82 |
$delegataire.= $this->maj($this->row['delegataire_ville'])."|". |
83 |
$this->row['delegataire_cp']."|"; |
84 |
$delegataire.= $this->p('bptier')."|".$this->p('cedextier')."|"; |
85 |
$delegataire.= $this->p('paystier')."|".$this->p('divtertier')."|"; |
86 |
}else{ |
87 |
$delegataire.= "|||||||||||||"; // *** 13 | |
88 |
} |
89 |
return $delegataire; |
90 |
} |
91 |
|
92 |
function meltel($mouvement){ |
93 |
// sitadel : telmo|melmo| |
94 |
$meltel=""; |
95 |
if($mouvement != "Transfert") |
96 |
$meltel.=$this->row['demandeur_telephone']."|"; |
97 |
$meltel.= $this->row['demandeur_email']."|"; |
98 |
// suivi electronique |
99 |
if($this->row['delegataire']=='Oui'){ |
100 |
$meltel.= "1"; |
101 |
}else{ |
102 |
$meltel.= "0"; |
103 |
} |
104 |
// suivi -> fin enr pour transfert (sans |) |
105 |
if($mouvement != "Transfert") |
106 |
$meltel.= "|"; |
107 |
return $meltel; |
108 |
} |
109 |
|
110 |
function adresse_terrain(){ |
111 |
// openfoncier numero (4/5 substr), adresse(80, 26 +38 -> substr), complement (non utilise (80)), cp (5/5 ok), ville (30/32 ok) |
112 |
// sitadel : |numvoiete|*typvoiete*|libvoiete|lieudite|communete|codposte|*bpte*|*cedexte*| |
113 |
// mettre le | en debut pour info du 2eme groupe (suite 1er groupe) |
114 |
$adresse=""; |
115 |
// |
116 |
$adresse.= substr($this->row['terrain_numero'],0,4)."|".$this->p('typvoiete')."|"; |
117 |
$adresse.= $this->maj(substr($this->row['terrain_adresse'],0,26))."|". |
118 |
$this->maj(substr($this->row['terrain_adresse'],26,38))."|"; |
119 |
$adresse.= $this->maj($this->row['terrain_ville'])."|"; |
120 |
$adresse.= $this->row['terrain_cp']."|"; |
121 |
$adresse.= $this->p('bpte')."|".$this->p('cedexte')."|"; |
122 |
return $adresse; |
123 |
} |
124 |
|
125 |
function parcelle(){ |
126 |
// ======== |
127 |
// parcelle |
128 |
// ======== |
129 |
// cadastre 3 parcelles + 3 sections |
130 |
// openfoncier = 1 seule parcelle (6/3+5) |
131 |
// sitadel : scadastre1|ncadastre1|*scadastre2*|*ncadastre2*|*scadastre3*|*ncadastre3*| |
132 |
$parcelle= substr($this->row['parcelle'],0,2)."|"; |
133 |
$parcelle.= substr($this->row['parcelle'],2,4)."|"; |
134 |
$parcelle.= $this->p('scadastre2')."|".$this->p('ncadastre2')."|"; |
135 |
$parcelle.= $this->p('scadastre3')."|".$this->p('ncadastre3')."|"; |
136 |
return $parcelle; |
137 |
} |
138 |
|
139 |
function decision_groupe1($avis_sitadel, $avis_sitadel_motif,$structure){ |
140 |
$decision= $structure.'|'; // au nom de la commune |
141 |
$decision.= $avis_sitadel."|"; |
142 |
// date au format francais 8 caracteres |
143 |
$decision.= substr($this->row['date_decision'],8,2).''. |
144 |
substr($this->row['date_decision'],5,2)."". |
145 |
substr($this->row['date_decision'],0,4)."|"; |
146 |
$decision.= $avis_sitadel_motif."|"; |
147 |
return $decision; |
148 |
} |
149 |
|
150 |
function terrain(){ |
151 |
$contenu=""; |
152 |
$contenu= floor($this->row['terrain_surface'])."|"; |
153 |
return $contenu; |
154 |
} |
155 |
|
156 |
function amenagement(){ |
157 |
// renseignement du groupe 2 *** |
158 |
// lotissement|zac|afu| |
159 |
$contenu=""; |
160 |
if($this->row['amenagement']!='') |
161 |
$contenu.= "1|"; |
162 |
else |
163 |
$contenu.= "0|"; |
164 |
$contenu.= $this->p('zac')."|".$this->p('afu')."|"; |
165 |
return $contenu; |
166 |
} |
167 |
|
168 |
function travaux($travaux, $lascot,$mouvement){ |
169 |
// libnattrav| ou libmotif dans MODIFICATIF |
170 |
$contenu=$this->maj($travaux)."|"; |
171 |
// natproj| innexistant en MODIFICATIF |
172 |
if($mouvement != "Modificatif"){ |
173 |
if($lascot=='1' |
174 |
or $lascot=='2' |
175 |
or $lascot=='3') |
176 |
$contenu.= $lascot."|"; // natproj 1:construction 2:extension ou 3:surelevation |
177 |
else |
178 |
$contenu.= "|"; |
179 |
} |
180 |
// INITIAL (ou TRANSFERT)natdp|nattrav|*annexe*|*nivmax* |
181 |
// MODIFICATIF nattrav|*annexe*|*nivmax* |
182 |
if($mouvement != "Modificatif"){ |
183 |
$natdp='00000'; |
184 |
if($lascot=='1') $natdp="10000"; // nouvelle construction |
185 |
if($lascot=='2') $natdp="01000"; // travaux sur construction existante |
186 |
if($lascot=='3') $natdp="01000"; // |
187 |
if($lascot=='X') $natdp="00001"; // cloture |
188 |
$contenu.= $natdp."|"; |
189 |
} |
190 |
// nattrav |
191 |
$nattrav = "0000"; |
192 |
if($lascot=='2') $nattrav="1000"; |
193 |
if($lascot=='3') $nattrav="0100"; |
194 |
$contenu.= $nattrav."|"; |
195 |
// annexe non renseigner defaut 00000 |
196 |
$contenu.= $this->p('annexe')."|"; |
197 |
//nivmax non saisi |
198 |
$contenu.=$this->p('nivmax')."|"; |
199 |
return $contenu; |
200 |
} |
201 |
|
202 |
function destination($shon){ |
203 |
$contenu=""; |
204 |
for($i=1;$i<=9;$i++){ |
205 |
if(!isset($shon[$i])) $shon[$i]=0; |
206 |
$contenu.=$shon[$i].'|'; |
207 |
|
208 |
} |
209 |
return $contenu; |
210 |
} |
211 |
|
212 |
function descriptif($mouvement){ |
213 |
// cpublic : non renseignee N par defaut |
214 |
// O/N transport/enseignement/sante/social/special/culture |
215 |
|
216 |
$contenu= $this->p('cpublic')."|"; //* supp| |
217 |
// nblogdem |
218 |
if($mouvement != "Modificatif"){ |
219 |
$contenu.= $this->row['logement_nombre']."|"; |
220 |
} |
221 |
// nbmaison : nombre de maison |
222 |
$contenu.= $this->p('nbmaison')."|"; |
223 |
// nblogcoll : nombre de logement collectif |
224 |
$contenu.= $this->p('nblogcoll')."|"; |
225 |
// nbtotlog : nombre de logement total |
226 |
$contenu.= $this->p('nbtotlog')."|"; |
227 |
// natres : nature des residences |
228 |
// O/N 1=ages, 2=etudiant, 3=tourisme, 4=hotel, 5=social, 6= handicap, 7=autres |
229 |
$contenu.= $this->p('natres')."|"; |
230 |
// libres= si autre residence (long max 1000 c) |
231 |
$contenu.= $this->p('libres')."|"; |
232 |
// util : O/N personnel, principale, secondaire, vente, location |
233 |
$contenu.= $this->p('util')."|"; |
234 |
//chambre |
235 |
$contenu.= $this->p('chambre')."|"; |
236 |
// nb logement sociaux |
237 |
$contenu.= $this->p('finis')."|"; |
238 |
// nb logt financt aides |
239 |
$contenu.= $this->p('finaa')."|"; |
240 |
// nb de logt pret a taux 0 |
241 |
$contenu.= $this->p('finptz')."|"; |
242 |
// nb de logt finances autrt |
243 |
$contenu.= $this->p('finaf')."|"; |
244 |
// nb pieces en maison individuelle |
245 |
if($mouvement != "Modificatif") |
246 |
$contenu.= $this->row['piece_nombre']."|"; // voir si 0 |
247 |
// chambre (num capacite accueil locaux hebergement) |
248 |
// $contenu.= "|"; |
249 |
// nb de logement 1piece |
250 |
$contenu.= $this->p('piec1')."|"; |
251 |
// nb de logement 2 pieces |
252 |
$contenu.= $this->p('piec2')."|"; |
253 |
// nb de logement 3 pieces |
254 |
$contenu.= $this->p('piec3')."|"; |
255 |
// nb de logement 4 pieces |
256 |
$contenu.= $this->p('piec4')."|"; |
257 |
// nb de logement 5 pieces |
258 |
$contenu.= $this->p('piec5')."|"; |
259 |
// nb de logement 6 pieces |
260 |
$contenu.= $this->p('piec6'); |
261 |
// (derniere zone decision et modificatif) |
262 |
return $contenu; |
263 |
} |
264 |
|
265 |
function chantier(){ |
266 |
//datereoc| |
267 |
$suivi1=""; |
268 |
$suivi1.=substr($this->row['date_chantier'],8,2).substr($this->row['date_chantier'],5,2). |
269 |
substr($this->row['date_chantier'],0,4)."|"; // *** au format francais |
270 |
//nblogoc|nbmaisoc|nbcolloc| |
271 |
$suivi1.=$this->p('nblogoc')."|".$this->p('nbmaisoc')."|".$this->p('nbcolloc')."|"; |
272 |
//shonoc| |
273 |
$suivi1.=floor($this->row['shon'])."|"; // ok *** enlever les decimales |
274 |
//*finisoc*|*finaaoc*|*finptzoc*|*finafoc|*indoc*| |
275 |
$suivi1.=$this->p('finisoc')."|".$this->p('finaaoc')."|". |
276 |
$this->p('finptzoc')."|".$this->p('finafoc')."|".$this->p('indoc')."|"; |
277 |
$suivi1.="|||||||||||"; // achevement 11| |
278 |
return $suivi1; |
279 |
} |
280 |
|
281 |
function achevement(){ |
282 |
$suivi2="||||||||||"; // occupation 10 | |
283 |
//datereat| |
284 |
$suivi2.=substr($this->row['date_achevement'],8,2). |
285 |
substr($this->row['date_achevement'],5,2). |
286 |
substr($this->row['date_achevement'],0,4)."|"; // ok *** au format francais |
287 |
//nblogat|nbmaisat|nbcollat| |
288 |
$suivi2.=$this->p('nblogat')."|".$this->p('nbmaisat')."|".$this->p('nbcollat')."|"; |
289 |
//shonat| |
290 |
$suivi2.=floor($this->row['shon'])."|"; // ok *** enlever les decimales |
291 |
//finisat|finaaat|finptzat|finafat|indat| |
292 |
$suivi2.=$this->p('finisat')."|".$this->p('finaaat')."|".$this->p('finptzat'). |
293 |
"|".$this->p('finafat')."|".$this->p('indat')."|"; |
294 |
// Finchantier 1 si etat=cloturer sinon 0 |
295 |
if ($this->row['etat']=="cloturer"){ |
296 |
$suivi2.="1|"; |
297 |
}else{ |
298 |
$suivi2.="0|"; |
299 |
} |
300 |
// Origat 1 par defaut |
301 |
$suivi2.=$this->p('origat'); |
302 |
return $suivi2; |
303 |
} |
304 |
|
305 |
function p($champ){ |
306 |
if($this->DEBUG==2) return $champ; |
307 |
if(isset($this->parametre[$champ])){ |
308 |
return $this->parametre[$champ]; |
309 |
}else |
310 |
return $this->val[$champ]; |
311 |
} |
312 |
|
313 |
function maj($val) { |
314 |
$val = strtoupper($val); |
315 |
$val=str_replace(chr(195), "", $val); // supprime le premier code des accents en UTF-8 |
316 |
$s = array('/[âàäÀ]/', '/[éêèëÉÈ]/', '/[îï]/', '/[ôöÔ]/', '/[ûùü]/', '/[çÇ]/', '/\'|\"|^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\-\s\r/'); |
317 |
$r = array('A', 'E', 'I', 'O', 'U', 'C', ' '); |
318 |
$val = preg_replace($s , $r, $val); |
319 |
return $val; |
320 |
} |
321 |
} |
322 |
?> |