/[openfoncier]/branches/3.14.x/app/sitadel.class.php
ViewVC logotype

Contents of /branches/3.14.x/app/sitadel.class.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3362 - (show annotations)
Thu Mar 26 17:14:39 2015 UTC (9 years, 10 months ago) by vpihour
File size: 37085 byte(s)
Correction des problèmes d'encodage dans l'export SITADEL.

1 <?php
2 /**
3 * Classe permettant la mise en forme de chaque ligne de l'export SITADEL
4 * Les méthode retourne des morceaux de lignes en faisant correspondre les valeurs
5 * du dossier avec les valeurs définie pour l'export SITADEL
6 *
7 * @package openfoncier
8 * @version SVN : $Id$
9 */
10
11 class sitadel {
12
13 private $dossier; // identifiant du dossier à insérer dans l'export
14 private $row; // Valeurs du dossier
15 private $val; // parametre par defaut
16 private $parametre; //parametre dossier
17 private $DEBUG=0; // 1 = valeur
18 private $pays;
19
20 /**
21 * Instance de la classe utils
22 * @var utils
23 */
24 var $f = NULL;
25
26 /**
27 * Constructeur, initialisation de l'attribut dossier
28 *
29 * @param dossier string identifiant du dossier à traiter
30 */
31 function __construct($dossier, $f) {
32 $this->dossier=$dossier;
33 //
34 $this->f = $f;
35 //
36 $this->pays = array(
37 'ALLE' => 109, 'AMÉR' => 404, 'AUTR' => 990, 'BELG' => 131,
38 'GRAN' => 132, 'DANE' => 101, 'ESPA' => 134, 'FRAN' => 100,
39 'PAYS' => 135, 'ITAL' => 127, 'PORT' => 139, 'SUIS' => 140,
40 );
41 // Permet lors de l'instantiation d'objets métiers d'avoir accès à f
42 $GLOBALS['f'] = $this->f;
43 }// fin constructeur
44
45 /**
46 * Mutateur pour le tableau de données du dossier
47 *
48 * @param $row Le tableau de données du dossier
49 * @return void
50 * */
51 public function setRow($row){
52 $this->row = $row;
53 }
54
55 /**
56 * Mutateur pour le paramètre par défaut
57 *
58 * @param $val Le paramètre par défaut
59 * @return void
60 * */
61 public function setVal($val){
62 $this->val = $val;
63 }
64
65 /**
66 * Permet de mettre en forme le début de chaque la ligne
67 *
68 * @param mouvement string DEPOT, DECISION, SUIVI, TRANSFERT, MODIFICATIF, SUPPRESSION
69 * @param departement string non utilisé
70 * @param commune string code commune du dossier
71 *
72 * @return string entete de la ligne
73 */
74 function entete($mouvement, $departement, $commune){
75
76 // Si c'est une commune divisée en arrondissement, le code commune dans
77 // l'entete de chaque mouvement doit être le code impôt de l'arrondissement
78 if ($this->f->getParameter("option_arrondissement")==='true'&&$this->row['code_impots']!=''){
79 $commune=$this->row['code_impots'];
80 }
81 elseif($this->f->getParameter("option_arrondissement")==='true'&&$this->row['code_impots']==''){
82 $commune=0;
83 }
84 // sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod
85 // l'equivalence n'est pas utilisée
86 $indice_dossier = ($this->row['mouvement_sitadel']=='SUIVI')?"":$this->getDossierVersion($this->dossier);
87
88 $entete=$mouvement."|".$this->row['code']."||".$departement."|".$commune."|".substr($this->dossier,8,2).
89 "|".substr($this->dossier,10,5)."|".$indice_dossier."|";
90 return $entete;
91 }
92
93 /**
94 * Retourne le numéro de version du dossier d'instruction
95 * @param string $dossier
96 * @return string
97 */
98 private function getDossierVersion($dossier){
99 $numeroVersion[0] = "";
100
101 //Si le numéro de dossier est fourni
102 if ( $dossier !== "" ){
103 preg_match('/\d+$/', $dossier, $numeroVersion);
104 }
105
106 return ($numeroVersion[0]==='0')?'':$numeroVersion[0];
107 }
108
109 /**
110 * Permet de mettre en forme l'état civil :
111 * personne morale / physique
112 * société, siret, civilité, nom, prénom / civilité, nom, prénom
113 *
114 * @return string demandeur désigné
115 */
116 function etatcivil(){
117 // etat civil demandeur
118 // codemo|
119 if ($this->row['qualite'] == "particulier") {
120 $codemo=1;// personne physique
121 } else {
122 $codemo=2;// personne morale
123 }
124 $etatcivil=$codemo."|"; // 1 personne physique ; 2 sinon
125 // openfoncier civilite (5/8 ok), nom (80/30-> substr), societe (80/50->substr)
126 // civpart|prenompart|nompart|denopm|rspm|siret|catjur|civrep|prenomrep|nomrep|
127 // suivant codemo = 1 (personne physique) ou 2 (personne morale)
128 // demandeur_civilite n est pas normalise Madame ou Monsieur
129 if ($codemo == 1) {
130 // *civpart*|*prenompart*|nompart||||||
131 $etatcivil.= $this->maj(substr($this->row['civilite_pp'],0,8))."|";
132 $etatcivil.= $this->maj(substr($this->row['pp_particulier_prenom'],0,30))."|";
133
134 $etatcivil.= $this->maj(substr($this->row['pp_particulier_nom'],0,30))."||||||||";
135 } else {
136 //denopm|*rspm*|*siret*|*catjur*|*civrep*|*prenomrep*|nomrep|
137 $etatcivil.="|||"; // codemo=1
138 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_denomination'],0,50))."|";
139 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_raison_sociale'],0,30))."|";
140 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_siret'],0,14))."|";
141 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_categorie_juridique'],0,4))."|";
142 $etatcivil.=$this->maj(substr($this->row['civilite_pm_libelle'],0,8))."|";
143 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_prenom'],0,30))."|";
144 $etatcivil.=$this->maj(substr($this->row['pp_personne_morale_nom'],0,30))."|";
145 }
146 return $etatcivil;
147 }
148
149 function adresse(){
150 // openfoncier : adresse (80/ 26+38 -> substr sur 2 zones) - cp (5/5 OK) - ville (30/36 -> OK)
151 // *numvoiemo*|*typvoiemo*|libvoiemo|lieuditmo(+)|communemo|codposmo|*bpmo*|*cedexmo*|*paysmo*|*divetermo|
152 $adresse="";
153 $adresse.= $this->maj(substr($this->row['pp_numero'],0,5))."|";
154 $adresse.= $this->maj(substr("",0,5))."|";
155 $adresse.= $this->maj(substr($this->row['pp_voie'],0,26))."|";
156 $adresse.= $this->maj(substr($this->row['pp_lieu_dit'],0,38))."|";
157 $adresse.= $this->maj(substr($this->row['pp_localite'],0,32))."|";
158 $adresse.= $this->maj(substr($this->row['pp_code_postal'],0,5))."|";
159 $adresse.= $this->maj(substr($this->row['pp_bp'],0,5))."|";
160 $adresse.= $this->maj(substr($this->row['pp_cedex'],0,5))."|";
161 $adresse.= $this->maj($this->getCodeInseePays(strtoupper($this->row['pp_pays'])))."|";
162 $adresse.= $this->maj(substr($this->row['pp_division_territoriale'],0,38))."|";
163
164 return $adresse;
165 }
166
167
168 function delegataire(){
169
170 //On récupère le délégataire
171 $sql = "SELECT civilite.libelle as civilite_delegataire_libelle,
172 demandeur.particulier_nom as delegataire_particulier_nom,
173 demandeur.particulier_prenom as delegataire_particulier_prenom,
174 demandeur.numero as delegataire_numero,
175 demandeur.voie as delegataire_voie,
176 demandeur.complement as delegataire_complement,
177 demandeur.lieu_dit as delegataire_lieu_dit,
178 demandeur.localite as delegataire_localite,
179 demandeur.code_postal as delegataire_code_postal,
180 demandeur.bp as delegataire_bp,
181 demandeur.cedex as delegataire_cedex,
182 demandeur.pays as delegataire_pays,
183 demandeur.division_territoriale as delegataire_division_territoriale
184 FROM ".DB_PREFIXE."demandeur
185 LEFT JOIN ".DB_PREFIXE."lien_dossier_demandeur
186 ON demandeur.demandeur = lien_dossier_demandeur.demandeur AND lien_dossier_demandeur.petitionnaire_principal is FALSE
187 LEFT JOIN ".DB_PREFIXE."civilite
188 ON civilite.civilite = demandeur.particulier_civilite
189 WHERE demandeur.type_demandeur='delegataire' AND
190 lien_dossier_demandeur.dossier = '".$this->dossier."'";
191 $res = $this->f->db -> query ($sql);
192 $this->f->addToLog("app/sitadel.class.php : db->query(\"".$sql."\")", VERBOSE_MODE);
193 $this->f->isDatabaseError($res);
194 $row=& $res->fetchRow(DB_FETCHMODE_ASSOC);
195 // openFoncier civilite (non normalise monsieur/madame), nom (80/30 substr)
196 // openfoncier : adresse (80/ 26+38 -> substr sur 2 zones) - cp (5/5 OK) - ville (30/32 -> OK)
197 // *civtiers*|*prenomtier*|nomtier|*numvoietiers*|*typvoietiers*|
198 // libvoietiers|lieudittier|communetier|codpostier
199 // |*bptier*|*cedextier*|*paystier*|*divtertier*|
200 $delegataire="";
201 $delegataire.= $this->maj(substr($row['civilite_delegataire_libelle'],0,8))."|";
202 $delegataire.= $this->maj(substr($row['delegataire_particulier_prenom'],0,30))."|";
203 $delegataire.= $this->maj(substr($row['delegataire_particulier_nom'],0,30))."|";
204 $delegataire.= $this->maj(substr($row['delegataire_numero'],0,5))."|";
205 $delegataire.= $this->maj(substr("",0,5))."|";
206 $delegataire.= $this->maj(substr($row['delegataire_voie'],0,26))."|";
207 $delegataire.= $this->maj(substr($row['delegataire_lieu_dit'],0,38))."|";
208 $delegataire.= $this->maj(substr($row['delegataire_localite'],0,32))."|";
209 $delegataire.= $this->maj(substr($row['delegataire_code_postal'],0,5))."|";
210 $delegataire.= $this->maj(substr($row['delegataire_bp'],0,5))."|";
211 $delegataire.= $this->maj(substr($row['delegataire_cedex'],0,5))."|";
212 $delegataire.= $this->maj($this->getCodeInseePays(strtoupper($row['delegataire_pays'])))."|";
213 $delegataire.= $this->maj(substr($row['delegataire_division_territoriale'],0,38))."|";
214 return $delegataire;
215 }
216
217 function meltel($mouvement){
218 // openfoncier telephone_fixe (14/20), courriel(40, 50) pas de suivi
219 // sitadel : telmo|melmo|suivi
220 $meltel="";
221 if($mouvement != "TRANSFERT")
222 $meltel.=$this->maj($this->row['pp_telephone_fixe'])."|";
223 $meltel.= $this->maj($this->row['pp_courriel'])."|";
224 // suivi electronique
225 // Il n'y a pas de notification par mail gérée dans l'appli
226 $meltel.= "0";
227
228 // suivi -> fin enr pour transfert (sans |)
229 if($mouvement != "TRANSFERT")
230 $meltel.= "|";
231 return $meltel;
232 }
233
234 /**
235 * Permet de mettre en forme l'adresse du terrain
236 * @return string champs du terrain séparés par des |
237 */
238 function adresse_terrain(){
239 // openfoncier numero (4/5 substr), adresse(80, 26 +38 -> substr), complement (non utilise (80)), cp (5/5 ok), ville (30/32 ok)
240 // sitadel : |numvoiete|*typvoiete*|libvoiete|lieudite|communete|codposte|*bpte*|*cedexte*|
241 // mettre le | en debut pour info du 2eme groupe (suite 1er groupe)
242 $adresse="";
243 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_voie_numero'],0,5))."|";
244 $adresse.= $this->maj(substr("",0,5))."|";
245 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_voie'],0,26))."|";
246 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_lieu_dit'],0,38))."|";
247 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_localite'],0,32))."|";
248 $code_postal = substr($this->row['dossier_terrain_adresse_code_postal'],0,5);
249 $adresse.= $this->maj($code_postal)."|";
250 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_bp'],0,5))."|";
251 $adresse.= $this->maj(substr($this->row['dossier_terrain_adresse_cedex'],0,5))."|";
252
253 return $adresse;
254 }
255
256 /**
257 * Formalise la parcelle à partir de la référence cadastrale
258 *
259 * @return string la chaine formatée
260 */
261 function parcelle(){
262 // ========
263 // parcelle
264 // ========
265 // cadastre 3 parcelles + 3 sections
266 // openfoncier = 1 seule parcelle (6/3+5)
267 // sitadel : scadastre1|ncadastre1|*scadastre2*|*ncadastre2*|*scadastre3*|*ncadastre3*|
268 $parcelle = "";
269 if ($this->row['dossier_terrain_references_cadastrales'] != "" ) {
270 $tab_parcelles = $this->parseParcelles($this->row['dossier_terrain_references_cadastrales']);
271
272 $parcelle .= ( isset($tab_parcelles[0]) && count($tab_parcelles[0]) == 3 )
273 ? $this->maj(substr($tab_parcelles[0]['section'],0,3))."|".
274 $this->maj(substr($tab_parcelles[0]['parcelle'],0,5))."|"
275 : "||";
276 $parcelle .= ( isset($tab_parcelles[1]) && count($tab_parcelles[1]) == 3 )
277 ? $this->maj(substr($tab_parcelles[1]['section'],0,3))."|".
278 $this->maj(substr($tab_parcelles[1]['parcelle'],0,5))."|"
279 : "||";
280 $parcelle .= ( isset($tab_parcelles[2]) && count($tab_parcelles[2]) == 3 )
281 ? $this->maj(substr($tab_parcelles[2]['section'],0,3))."|".
282 $this->maj(substr($tab_parcelles[2]['parcelle'],0,5))."|"
283 : "||";
284 } else {
285 $parcelle= "||||||";
286 }
287
288 return $parcelle;
289 }
290
291 /**
292 * Permet de calculer la liste des parcelles à partir de la chaîne passée en paramètre
293 * et la retourner sous forme d'un tableau associatif
294 *
295 * @param string $strParcelles chaîne de la parcelles
296 * @return array (array(quartier, section, parcelle), ...)
297 */
298 function parseParcelles($strParcelles) {
299
300 // Séparation des lignes
301 $references = explode(";", $strParcelles);
302 $liste_parcelles = array();
303
304 // On boucle sur chaque ligne pour ajouter la liste des parcelles de chaque ligne
305 foreach ($references as $parcelles) {
306
307 // On transforme la chaîne de la ligne de parcelles en tableau
308 $ref = str_split($parcelles);
309 // Les 1er caractères sont numériques
310 $num = true;
311
312 // Tableau des champs de la ligne de références cadastrales
313 $reference_tab = array();
314 $temp = "";
315 foreach ($ref as $carac) {
316
317 // Permet de tester si le caractère courant est de même type que le précédent
318 if(is_numeric($carac) === $num) {
319 $temp .= $carac;
320 } else {
321 // Bascule
322 $num = !$num;
323 // On stock le champ
324 $reference_tab[] = $temp;
325 // re-init de la valeur temporaire pour le champ suivant
326 $temp = $carac;
327 }
328 }
329 // Stockage du dernier champ sur lequel il n'y a pas eu de bascule
330 $reference_tab[] = $temp;
331 // Calcul des parcelles
332 $quartier = $reference_tab[0];
333 $sect = $reference_tab[1];
334
335 $ancien_ref_parc = "";
336 for ($i=2; $i < count($reference_tab); $i+=2) {
337 $parc["quartier"] = $quartier;
338 $parc["section"] = $sect;
339 if( $ancien_ref_parc == "" OR $reference_tab[$i-1] == "/") {
340 // 1ere parcelle ou parcelle individuelle
341 $parc["parcelle"] = $reference_tab[$i];
342 // Ajout d'une parcelle à la liste
343 $liste_parcelles[] = $parc;
344 } elseif ($reference_tab[$i-1] == "A") {
345 // Interval de parcelles
346 for ($j=$ancien_ref_parc+1; $j <= $reference_tab[$i]; $j++) {
347 $parc["parcelle"] = $j;
348 // Ajout d'une parcelle à la liste
349 $liste_parcelles[] = $parc;
350 }
351 }
352 //Gestion des erreurs
353 else{
354
355 echo _("Une erreur de formattage a ete detecte dans la reference cadastrale du dossier ").$this->row['dossier'];
356 }
357 // Sauvegarde de la référence courante de parcelle
358 $ancien_ref_parc = $reference_tab[$i];
359 }
360 }
361
362 return $liste_parcelles;
363 }
364
365 /**
366 * Données pour le groupe 1 du mouvement décision
367 *
368 * @return string la chaine de données du groupe 1
369 */
370 function decision_groupe1(){
371 // openfoncier autorite_competente (integer/1), sitadel(integer, 1)
372 // date_limite (date, 8)| date_notification_delai (date, 8),
373 // sitadel_motif (integer, 1)
374 // sitadel : collectivite|natdec|datredec|motifann
375
376 $decision = $this->maj(substr($this->row['autorite_competente_sitadel'],0,1))."|";
377 $decision.= (($this->row['sitadel']!="")?$this->maj(substr($this->row['sitadel'],0,1)):"0")."|";
378
379 $datredec = "";
380 //Choix de la date
381 // Date limite de retour des pièces manquantes en cas de rejet tacite
382 if ( $this->row['sitadel'] == 1 ){
383 $datredec = ($this->row['date_limite_incompletude']!="")?$this->row['date_limite_incompletude']:$this->row['date_decision'];
384 } elseif( $this->row['sitadel'] == 2 || $this->row['sitadel'] == 3 ) {
385 $datredec = $this->row['date_limite'];
386 } elseif ( $this->row['sitadel'] == "" ){
387 $datredec = "";
388 } else {
389 $datredec = $this->row['date_decision'];
390 }
391
392 // date au format francais 8 caracteres
393 $decision.= $this->maj(substr($datredec,8,2).''.
394 substr($datredec,5,2)."".
395 substr($datredec,0,4))."|";
396
397 $decision.= $this->maj(substr($this->row['sitadel_motif'],0,1))."|";
398 return $decision;
399 }
400
401 /**
402 * Données pour le groupe 2 du mouvement décision concernant les aménagements et
403 * le terrain
404 *
405 * @return string la chaine de données du groupe 2
406 */
407 function amenagement_terrain(){
408 // openfoncier am_terr_surf (numeric/7) am_lotiss (bool/1) terr_juri_afu (20/1)
409 // co_cstr_nouv (20/1) co_cstr_exist (text/1000) co_modif_aspect (bool/1)
410 // co_modif_struct (bool/1) co_cloture (bool/1) co_trx_exten (bool/1)
411 // co_trx_surelev (bool/1) co_trx_nivsup (bool/1) co_trx_amgt (bool/1)
412 // co_anx_pisc (bool/1) co_anx_gara (bool/1) co_anx_veran (bool/1)
413 // co_anx_abri (bool/1) co_anx_autr (bool/1) co_bat_niv_nb (integer/3)
414 // sitadel : terrain|lotissement|ZAC|AFU|libnattrav|natproj|natdp|nattrav|
415 // annexe|niax
416 $amenagement_terrain="";
417 //Terrain
418 $amenagement_terrain .= ((isset($this->row['dossier_terrain_superficie'])) ? $this->maj(substr(floor($this->row['dossier_terrain_superficie']),0,7)) : 0)."|";
419 //Lotissement
420 $amenagement_terrain .= ((isset($this->row['am_lotiss']) && $this->row['am_lotiss'] == 't') ? 1 : 0)."|";
421 //ZAC
422 $amenagement_terrain .= ((isset($this->row['terr_juri_zac']) && $this->maj($this->row['terr_juri_zac']) != '') ? 1 : 0)."|";
423 //AFU
424 $amenagement_terrain .= ((isset($this->row['terr_juri_afu']) && $this->maj($this->row['terr_juri_afu']) != '') ? 1 : 0)."|";
425 //Libnattrav
426 if (isset($this->row['co_projet_desc'])&&$this->row['co_projet_desc']!=''){
427 $amenagement_terrain .= $this->maj(substr($this->row['co_projet_desc'],0,1000));
428 } elseif(isset($this->row['am_projet_desc'])&&$this->row['am_projet_desc']!=''){
429 $amenagement_terrain .= $this->maj(substr($this->row['am_projet_desc'],0,1000));
430 } elseif(isset($this->row['dm_projet_desc'])&&$this->row['dm_projet_desc']!=''){
431 $amenagement_terrain .= $this->maj(substr($this->row['dm_projet_desc'],0,1000));
432 }
433 $amenagement_terrain .= "|";
434
435 // Nouvelle construction et travaux sur construction (natproj)
436 if ( isset($this->row['co_cstr_nouv']) && isset($this->row['co_cstr_exist']) &&
437 $this->row['co_cstr_nouv'] == 't' &&
438 $this->row['co_cstr_exist'] == 't' ){
439 $amenagement_terrain .= "3";
440 }
441 //Nouvelle construction
442 elseif ( isset($this->row['co_cstr_nouv']) && $this->row['co_cstr_nouv'] == 't' ) {
443 $amenagement_terrain .= "1";
444 }
445 //Travaux sur construction existante
446 elseif(($this->row['co_cstr_nouv'] == 'f' && $this->row['co_cstr_exist'] == 'f') OR
447 $this->row['co_cstr_exist']=='t') {
448 $amenagement_terrain .= "2";
449 }
450 $amenagement_terrain .= "|";
451
452 //Nature du projet dans le cas d'un DP (natdp)
453 if ( $this->row['code'] == "DP" ){
454
455 $amenagement_terrain .= ((isset($this->row['co_cstr_nouv']) && $this->row['co_cstr_nouv'] == 't') ? 1 : 0);
456 $amenagement_terrain .= ((isset($this->row['co_cstr_exist']) && $this->row['co_cstr_exist'] == 't') ? 1 : 0);
457 $amenagement_terrain .= ((isset($this->row['co_modif_aspect']) && $this->row['co_modif_aspect'] == 't') ? 1 : 0);
458 $amenagement_terrain .= ((isset($this->row['co_modif_struct']) && $this->row['co_modif_struct'] == 't') ? 1 : 0);
459 $amenagement_terrain .= ((isset($this->row['co_cloture']) && $this->row['co_cloture'] == 't') ? 1 : 0);
460 }
461 $amenagement_terrain .= "|";
462
463 //Nature des travaux sur construction existante
464 //nattrav
465 $amenagement_terrain .= ((isset($this->row['co_trx_exten']) && $this->row['co_trx_exten'] == 't') ? 1 : 0);
466 $amenagement_terrain .= ((isset($this->row['co_trx_surelev']) && $this->row['co_trx_surelev'] == 't') ? 1 : 0);
467 $amenagement_terrain .= ((isset($this->row['co_trx_niv_sup']) && $this->row['co_trx_niv_sup'] == 't') ? 1 : 0);
468 $amenagement_terrain .= ((isset($this->row['co_trx_amgt']) && $this->row['co_trx_amgt'] == 't') ? 1 : 0)."|";
469
470 //Annexe
471 $amenagement_terrain .= ((isset($this->row['co_anx_pisc']) && $this->row['co_anx_pisc'] == 't') ? 1 : 0);
472 $amenagement_terrain .= ((isset($this->row['co_anx_gara']) && $this->row['co_anx_gara'] == 't') ? 1 : 0);
473 $amenagement_terrain .= ((isset($this->row['co_anxveran']) && $this->row['co_anxveran'] == 't') ? 1 : 0);
474 $amenagement_terrain .= ((isset($this->row['co_anx_abri']) && $this->row['co_anx_abri'] == 't') ? 1 : 0);
475 $amenagement_terrain .= ((isset($this->row['co_anx_autr']) && $this->row['co_anx_autr'] == 't') ? 1 : 0)."|";
476
477 //niax
478 $amenagement_terrain .= ((isset($this->row['co_bat_niv_nb']) && $this->maj($this->row['co_bat_niv_nb'])<=1)?"1":$this->row['co_bat_niv_nb'])."|";
479
480 return $amenagement_terrain;
481 }
482
483 /**
484 * Données pour le groupe 2 du mouvement décision concernant les SHON
485 *
486 * @return string la chaine de données du groupe 2
487 */
488 function shon($nom){
489 // openfoncier (numeric/7)
490
491 $shon = "";
492
493 $shon .= ((isset($this->row[$nom.'1'])) ? $this->maj(substr(floor($this->row[$nom.'1']),0,7)) : 0)."|";
494 $shon .= ((isset($this->row[$nom.'2'])) ? $this->maj(substr(floor($this->row[$nom.'2']),0,7)) : 0)."|";
495 $shon .= ((isset($this->row[$nom.'3'])) ? $this->maj(substr(floor($this->row[$nom.'3']),0,7)) : 0)."|";
496 $shon .= ((isset($this->row[$nom.'4'])) ? $this->maj(substr(floor($this->row[$nom.'4']),0,7)) : 0)."|";
497 $shon .= ((isset($this->row[$nom.'5'])) ? $this->maj(substr(floor($this->row[$nom.'5']),0,7)) : 0)."|";
498 $shon .= ((isset($this->row[$nom.'6'])) ? $this->maj(substr(floor($this->row[$nom.'6']),0,7)) : 0)."|";
499 $shon .= ((isset($this->row[$nom.'7'])) ? $this->maj(substr(floor($this->row[$nom.'7']),0,7)) : 0)."|";
500 $shon .= ((isset($this->row[$nom.'8'])) ? $this->maj(substr(floor($this->row[$nom.'8']),0,7)) : 0)."|";
501 $shon .= ((isset($this->row[$nom.'9'])) ? $this->maj(substr(floor($this->row[$nom.'9']),0,7)) : 0)."|";
502
503 return $shon;
504 }
505
506 /**
507 * Permet de mettre en forme le descriptif des modifications apportés sur le
508 * terrain dans les dossier d'instruction de type modificatif
509 *
510 * @return string chaîne mise en forme
511 */
512 function modificatif_terrain() {
513 $modificatif_terrain="";
514
515 // Terrain
516 $modificatif_terrain .= ((isset($this->row['dossier_terrain_superficie'])) ? $this->maj(substr(floor($this->row['dossier_terrain_superficie']),0,7)) : 0)."|";
517 // Description des modifications
518 $modificatif_terrain .= (isset($this->row['co_projet_desc'])) ? $this->maj(substr($this->row['co_projet_desc'],0,1000))."|" : "|";
519 //Nature des travaux sur construction existante
520 //nattrav
521 $modificatif_terrain .= ((isset($this->row['co_trx_exten']) && $this->row['co_trx_exten'] == 't') ? 1 : 0);
522 $modificatif_terrain .= ((isset($this->row['co_trx_surelev']) && $this->row['co_trx_surelev'] == 't') ? 1 : 0);
523 $modificatif_terrain .= ((isset($this->row['co_trx_niv_sup']) && $this->row['co_trx_niv_sup'] == 't') ? 1 : 0);
524 $modificatif_terrain .= ((isset($this->row['co_trx_amgt']) && $this->row['co_trx_amgt'] == 't') ? 1 : 0)."|";
525
526 //Annexe
527 $modificatif_terrain .= ((isset($this->row['co_anx_pisc']) && $this->row['co_anx_pisc'] == 't') ? 1 : 0);
528 $modificatif_terrain .= ((isset($this->row['co_anx_gara']) && $this->row['co_anx_gara'] == 't') ? 1 : 0);
529 $modificatif_terrain .= ((isset($this->row['co_anxveran']) && $this->row['co_anxveran'] == 't') ? 1 : 0);
530 $modificatif_terrain .= ((isset($this->row['co_anx_abri']) && $this->row['co_anx_abri'] == 't') ? 1 : 0);
531 $modificatif_terrain .= ((isset($this->row['co_anx_autr']) && $this->row['co_anx_autr'] == 't') ? 1 : 0)."|";
532
533 //niax
534 $modificatif_terrain .= (isset($this->row['co_bat_niv_nb']) && $this->maj(substr($this->row['co_bat_niv_nb'],0,3)))."|";
535
536 return $modificatif_terrain;
537 }
538
539 /**
540 * Données pour le groupe 2 du mouvement décision concernant les destinations
541 *
542 * @return string la chaine de données du groupe 2
543 */
544 function destination($mouvement){
545
546 $destination = "";
547
548 $destination .= ((isset($this->row['co_sp_transport']) && $this->row['co_sp_transport'] == 't') ? 1 : 0);
549 $destination .= ((isset($this->row['co_sp_enseign']) && $this->row['co_sp_enseign'] == 't') ? 1 : 0);
550 $destination .= ((isset($this->row['co_sp_sante']) && $this->row['co_sp_sante'] == 't') ? 1 : 0);
551 $destination .= ((isset($this->row['co_sp_act_soc']) && $this->row['co_sp_act_soc'] == 't') ? 1 : 0);
552 $destination .= ((isset($this->row['co_sp_ouvr_spe']) && $this->row['co_sp_ouvr_spe'] == 't') ? 1 : 0);
553 $destination .= ((isset($this->row['co_sp_culture']) && $this->row['co_sp_culture'] == 't') ? 1 : 0)."|";
554
555 if($mouvement != "MODIFICATIF"){
556 $destination .= ((isset($this->row['dm_tot_log_nb']) && !empty($this->row['dm_tot_log_nb'])) ? $this->row['dm_tot_log_nb'] : 0)."|";
557 }
558
559 $destination .= ((isset($this->row['co_tot_ind_nb']) && !empty($this->row['co_tot_ind_nb'])) ? $this->row['co_tot_ind_nb'] : 0)."|";
560 $destination .= ((isset($this->row['co_tot_coll_nb']) && !empty($this->row['co_tot_coll_nb'])) ? $this->row['co_tot_coll_nb'] : 0)."|";
561 $destination .= ((isset($this->row['co_tot_log_nb']) && !empty($this->row['co_tot_log_nb'])) ? $this->row['co_tot_log_nb'] : 0)."|";
562
563 $destination .= ((isset($this->row['co_resid_agees']) && $this->row['co_resid_agees']=='t') ? 1 : 0);
564 $destination .= ((isset($this->row['co_resid_etud']) && $this->row['co_resid_etud']=='t') ? 1 : 0);
565 $destination .= ((isset($this->row['co_resid_tourism']) && $this->row['co_resid_tourism']=='t') ? 1 : 0);
566 $destination .= ((isset($this->row['co_resid_hot_soc']) && $this->row['co_resid_hot_soc']=='t') ? 1 : 0);
567 $destination .= ((isset($this->row['co_resid_soc']) && $this->row['co_resid_soc']=='t') ? 1 : 0);
568 $destination .= ((isset($this->row['co_resid_hand']) && $this->row['co_resid_hand']=='t') ? 1 : 0);
569 $destination .= ((isset($this->row['co_resid_autr']) && $this->row['co_resid_autr']=='t') ? 1 : 0)."|";
570 $destination .= (isset($this->row['co_resid_autr_desc']) ? $this->maj($this->row['co_resid_autr_desc']) : "")."|";
571
572 $destination .= ((isset($this->row['co_uti_pers']) && $this->row['co_uti_pers']=='t') ? 1 : 0);
573 $destination .= ((isset($this->row['co_uti_princ']) && $this->row['co_uti_princ']=='t') ? 1 : 0);
574 $destination .= ((isset($this->row['co_uti_secon']) && $this->row['co_uti_secon']=='t') ? 1 : 0);
575 $destination .= ((isset($this->row['co_uti_vente']) && $this->row['co_uti_vente']=='t') ? 1 : 0);
576 $destination .= ((isset($this->row['co_uti_loc']) && $this->row['co_uti_loc']=='t') ? 1 : 0)."|";
577
578 $destination .= ((isset($this->row['co_foyer_chamb_nb']) && !empty($this->row['co_foyer_chamb_nb'])) ? $this->row['co_foyer_chamb_nb'] : 0)."|";
579
580 return $destination;
581 }
582
583 /**
584 * Données pour le groupe 2 du mouvement décision concernant la répartition des
585 * logements créées par type de financement
586 *
587 * @return string la chaine de données du groupe 2
588 */
589 function repartitionFinan(){
590
591 $repartitionFinan = "";
592
593 $repartitionFinan .= ((isset($this->row['co_fin_lls_nb']) && $this->row['co_fin_lls_nb']) ? $this->row['co_fin_lls_nb'] : 0)."|";
594 $repartitionFinan .= ((isset($this->row['co_fin_aa_nb']) && $this->row['co_fin_aa_nb']) ? $this->row['co_fin_aa_nb'] : 0)."|";
595 $repartitionFinan .= ((isset($this->row['co_fin_ptz_nb']) && $this->row['co_fin_ptz_nb']) ? $this->row['co_fin_ptz_nb'] : 0)."|";
596 $repartitionFinan .= ((isset($this->row['co_fin_autr_nb']) && $this->row['co_fin_autr_nb']) ? $this->row['co_fin_autr_nb'] : 0)."|";
597
598 return $repartitionFinan;
599 }
600
601 /**
602 * Données pour le groupe 2 du mouvement décision concernant la répartition des
603 * logements créées par nombre de pièces
604 *
605 * @return string la chaine de données du groupe 2
606 */
607 function repartitionNbPiece($mouvement){
608
609 $repartitionFinan = "";
610 if($mouvement != "MODIFICATIF"){
611 $repartitionFinan .= ((isset($this->row['co_mais_piece_nb']) && $this->row['co_mais_piece_nb'] == 't') ? 1 : 0)."|";
612 }
613
614 $repartitionFinan .= ((isset($this->row['co_log_1p_nb']) && is_numeric($this->row['co_log_1p_nb'])) ? $this->row['co_log_1p_nb'] : 0)."|";
615 $repartitionFinan .= ((isset($this->row['co_log_2p_nb']) && is_numeric($this->row['co_log_2p_nb'])) ? $this->row['co_log_2p_nb'] : 0)."|";
616 $repartitionFinan .= ((isset($this->row['co_log_3p_nb']) && is_numeric($this->row['co_log_3p_nb'])) ? $this->row['co_log_3p_nb'] : 0)."|";
617 $repartitionFinan .= ((isset($this->row['co_log_4p_nb']) && is_numeric($this->row['co_log_4p_nb'])) ? $this->row['co_log_4p_nb'] : 0)."|";
618 $repartitionFinan .= ((isset($this->row['co_log_5p_nb']) && is_numeric($this->row['co_log_5p_nb'])) ? $this->row['co_log_5p_nb'] : 0)."|";
619 $repartitionFinan .= ((isset($this->row['co_log_6p_nb']) && is_numeric($this->row['co_log_6p_nb'])) ? $this->row['co_log_6p_nb'] : 0);
620
621 return $repartitionFinan;
622 }
623
624 /**
625 * Permet de mettre en forme les données du mouvement suivi pour une ouverture de chantier
626 * @return string Chaîne contenant les infos spécifiques aux DOC séparé par "|"
627 */
628 function chantier($row){
629
630 $chantier="";
631 if(isset($row['date_chantier'])) {
632 $chantier .= substr($row['date_chantier'],8,2).substr($row['date_chantier'],5,2).
633 substr($row['date_chantier'],0,4); // *** au format francais
634 }
635 $chantier .= "|";
636 $chantier .= ((isset($row['doc_nb_log']) AND $row['doc_nb_log'] != "" ) ? $row['doc_nb_log'] : "")."|";
637 $chantier .= ((isset($row['doc_nb_log_indiv']) AND $row['doc_nb_log_indiv'] != "" ) ? $row['doc_nb_log_indiv'] : "")."|";
638 $chantier .= ((isset($row['doc_nb_log_coll']) AND $row['doc_nb_log_coll'] != "" ) ? $row['doc_nb_log_coll'] : "")."|";
639 $chantier .= ((isset($row['doc_surf']) AND $row['doc_surf'] != "" ) ? substr(floor($row['doc_surf']),0,7) : "")."|";
640 $chantier .= ((isset($row['doc_nb_log_lls']) AND $row['doc_nb_log_lls'] != "" ) ? $row['doc_nb_log_lls'] : "")."|";
641 $chantier .= ((isset($row['doc_nb_log_aa']) AND $row['doc_nb_log_aa'] != "" ) ? $row['doc_nb_log_aa'] : "")."|";
642 $chantier .= ((isset($row['doc_nb_log_ptz']) AND $row['doc_nb_log_ptz'] != "" ) ? $row['doc_nb_log_ptz'] : "")."|";
643 $chantier .= ((isset($row['doc_nb_log_autre']) AND $row['doc_nb_log_autre'] != "" ) ? $row['doc_nb_log_autre'] : "")."|";
644 // indice de la tranche commencée
645 $chantier .= "0|";
646
647 return $chantier;
648 }
649
650 /**
651 * Permet d'afficher le dessein correspondant à une DAACT
652 * @param array $row Les données à ajouter
653 *
654 * @return string Chaîne contenant les infos spécifiques aux DAACT séparé par "|"
655 */
656 function achevement($row){
657
658 $achevement="";
659 if(isset($row['date_achevement'])) {
660 $achevement .= substr($row['date_achevement'],8,2).substr($row['date_achevement'],5,2).
661 substr($row['date_achevement'],0,4); // *** au format francais
662 }
663 $achevement .= "|";
664
665 $achevement .= ((isset($row['daact_nb_log']) AND $row['daact_nb_log'] != "" ) ? $row['daact_nb_log'] : "")."|";
666 $achevement .= ((isset($row['daact_nb_log_indiv']) AND $row['daact_nb_log_indiv'] != "" ) ? $row['daact_nb_log_indiv'] : "")."|";
667 $achevement .= ((isset($row['daact_nb_log_coll']) AND $row['daact_nb_log_coll'] != "" ) ? $row['daact_nb_log_coll'] : "")."|";
668 $achevement .= ((isset($row['daact_surf']) AND $row['daact_surf'] != "" ) ? substr(floor($row['daact_surf']),0,7) : "")."|";
669 $achevement .= ((isset($row['daact_nb_log_lls']) AND $row['daact_nb_log_lls'] != "" ) ? $row['daact_nb_log_lls'] : "")."|";
670 $achevement .= ((isset($row['daact_nb_log_aa']) AND $row['daact_nb_log_aa'] != "" ) ? $row['daact_nb_log_aa'] : "")."|";
671 $achevement .= ((isset($row['daact_nb_log_ptz']) AND $row['daact_nb_log_ptz'] != "" ) ? $row['daact_nb_log_ptz'] : "")."|";
672 $achevement .= ((isset($row['daact_nb_log_autre']) AND $row['daact_nb_log_autre'] != "" ) ? $row['daact_nb_log_autre'] : "")."|";
673 // indice de la tranche complétée
674 $achevement .= "0|";
675 // Finchantier 1 si etat=cloturer sinon 0
676 if ($row['statut_di']=="cloture"){
677 $achevement.="1";
678 }else{
679 $achevement.="0";
680 }
681 // indique la provenance de l'info d'achèvement des travaux (déclaration/DGI)
682 $achevement .= "|";
683 return $achevement;
684 }
685
686 /**
687 * Permet de récupérer la valeur par defaut du champ passé en paramètre
688 * @param string $champ nom du champ dont on souhaite afficher la valeur par defaut
689 * @return string valeur par defaut
690 */
691 function defaultValue($champ){
692 if($this->DEBUG==2) return $champ;
693 if(isset($this->parametre[$champ])){
694 return $this->parametre[$champ];
695 }else
696 return $this->val[$champ];
697 }
698
699 /**
700 * Normalise la chaine de caractère ou renvoit "valeur manquant".
701 *
702 * @param $val La valeur du champ
703 * @return string la chaine formatée ou ""
704 */
705 function maj($val) {
706 $val = strtoupper($val);
707 $val=str_replace(chr(195), "", $val); // supprime le premier code des accents en UTF-8
708 $s = array('/[âàäÀÂ]/', '/[éêèëÉÈÊ]/', '/[îï]/', '/[ôöÔ]/', '/[ûùü]/', '/[çÇ]/', '/\'|\"|^abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ\-\s\r/', '/\n/');
709 $r = array('A', 'E', 'I', 'O', 'U', 'C', ' ', ' ');
710 $val = preg_replace($s , $r, $val);
711 // Formatage des valeurs manquantes
712 return $val;
713 }
714
715 /**
716 * Retourne le code INSEE d'un pays
717 *
718 * @param string $pays Le nom du pays
719 * @return int Le code insee du pays
720 */
721 function getCodeInseePays($pays) {
722 //
723 if($pays!=''&&isset($this->pays[substr($pays, 0, 4)])) {
724 return $this->pays[substr($pays, 0, 4)];
725 }
726 return $this->pays['FRAN'];
727 }
728 }
729
730 ?>

Properties

Name Value
svn:keywords Id

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26