/[openfoncier]/trunk/obj/export_sitadel.class.php
ViewVC logotype

Contents of /trunk/obj/export_sitadel.class.php

Parent Directory Parent Directory | Revision Log Revision Log


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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26