/[openfoncier]/trunk/app/export_pc.php
ViewVC logotype

Contents of /trunk/app/export_pc.php

Parent Directory Parent Directory | Revision Log Revision Log


Revision 510 - (show annotations)
Wed Oct 17 11:02:35 2012 UTC (12 years, 3 months ago) by vpihour
File size: 8802 byte(s)
Mise à jour de la table service et du formulaire
Suppression des fichiers inutiles
Modification des etats pdf dans init.sql
Mise à jour des scripts concernant l'ancienne table avis

1 <?php
2 // $Id: export_pc.php,v 1.10 2010-03-16 19:45:04 fraynaud Exp $
3 /*
4 transfert de dossier � la DGI Cadstre
5 */
6 require_once "../obj/utils.class.php";
7 $f = new utils(NULL, "export_pc", _("export PC"), "ico_export.png", "export");
8 $f->addHTMLHeadJs(array("../js/script.js"));
9 // GET ========================================================================
10 if (isset ($_GET['validation'])){
11 $validation=$_GET['validation'];
12 }else{
13 $validation=0;
14 }
15 if (isset ($_GET['idx'])){
16 $idx=$_GET['idx'];
17 }else{
18 $idx=0;
19 }
20 /**
21 * Description de la page
22 */
23 $description = _("Cette page vous permet de Transmettre les PC au cadastre DGI (procedure LASCOT.");
24 $f->displayDescription($description);
25 // =============================================================================
26 // validation = 0
27 // =============================================================================
28 if($validation==0){
29 $validation=1;
30 echo "<form method=\"POST\" action=\"export_pc.php?validation=".$validation."\" name=f1>";
31 echo " "._("DATE DEBUT DEPOT")." ";
32 echo "<input type='text' name='datedebut' id=\"datedebut\" value=\"";
33 echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />";
34 echo " "._("DATE FIN DEPOT")." ";
35 echo "<input type='text' name='datefin' id=\"datefin\" value=\"";
36 echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />";
37 echo " avis ";
38 echo "<select name='avis_decision' class='champFormulaire' >";
39 $sql = "SELECT distinct(typeavis) from avis_decision where typeavis <> ''";
40 $res = $f->db->query($sql);
41 $f->isDatabaseError($res);
42 echo "<option value='S'>Sans</option>";
43 echo "<option value='T'>Tous</option>";
44 while ($row=& $res->fetchRow()){
45 echo "<option value='".$row[0]."'>".$row[0]."</option>";
46 }
47 echo "</select>";
48 echo "<br><br><input type='submit' value='export PC' >";
49 echo "<br><br></form>";
50 }else { // ===================== extraction =================================
51 $correct=true;
52 if($_POST["datedebut"]=="") $correct=false;
53 if($_POST["datefin"]=="") $correct=false;
54 if (isset ($_POST['typeavis'])){ // ***
55 $typeavis=$_POST['typeavis'];
56 }else{
57 $typeavis="";
58 } // *
59 if ($correct==true){
60 $departement =$f->collectivite["departement"];
61 $commune =$f->collectivite["commune"];
62 $sql= "select date_depot,annee, dossier.dossier, demandeur_civilite,
63 demandeur_nom,demandeur_societe,demandeur_adresse,demandeur_ville,demandeur_cp,
64 parcelle, terrain_numero,terrain_numero_complement,
65 terrain_adresse,terrain_adresse_complement, terrain_ville,
66 shon,logement_nombre,codelascot
67 from dossier left join travaux on dossier.travaux=travaux.travaux";
68 if($typeavis!="" or $typeavis=='T'){ // ***
69 $sql.=" left join avis_decision on avis_decision.avis_decision = dossier.avis_decision";
70 } //*
71 $sql.= " where dossier.nature = 'PC'";
72 if($typeavis!="" or $typeavis=='T'){ // ***
73 $sql.=" AND typeavis ='".$typeavis."'";
74 }//*
75 $sql.= " AND date_depot>='".substr($_POST["datedebut"],6,4).
76 "-".substr($_POST["datedebut"],3,2)."-".
77 substr($_POST["datedebut"],0,2)."'";
78 $sql.= " AND date_depot<='".substr($_POST["datefin"],6,4).
79 "-".substr($_POST["datefin"],3,2)."-".
80 substr($_POST["datefin"],0,2)."'";
81 $res = $f->db -> query ($sql);
82 $f->isDatabaseError($res);
83 $export="";
84 $bl="";
85 while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){
86 $export.= $departement;
87 $export.= $commune;
88 $export.= $row['annee'];
89 $export.=substr($row['dossier'],4,5);// numero dossier 5
90 // modificatif sur 2 caracteres et non sur 1
91 $export.=str_pad(substr($row['dossier'],10,1),1," ", STR_PAD_RIGHT);// modificatif 9,2
92 // dossier precedent ? annee numero modificatif
93 $export.=" "." "." "; // 2-5-1
94 // maitre ouvrage
95 $export.= str_pad(substr($row['demandeur_civilite'],0,5),5," ", STR_PAD_RIGHT); //nom du maitre d ouvrage
96 $export.= str_pad(substr($row['demandeur_nom'],0,27),27," ", STR_PAD_RIGHT); //nom du maitre d ouvrage
97 $export.= str_pad(substr($row['demandeur_societe'],0,32),32," ", STR_PAD_RIGHT); //1ere ligne
98 $export.= str_pad(substr($row['demandeur_adresse'],0,32),32," ", STR_PAD_RIGHT); // adresse
99 $export.= str_pad($bl,32," ", STR_PAD_RIGHT); //2eme ligne
100 $export.= str_pad($bl,32," ", STR_PAD_RIGHT); //3eme Ligne
101 $export.= str_pad($row['demandeur_cp'],5," ", STR_PAD_RIGHT);
102 $export.= str_pad(substr($row['demandeur_ville'],0,26),26," ", STR_PAD_RIGHT);
103 $export.= str_pad ($bl, 20, " ", STR_PAD_RIGHT); // telephone
104 // terrain
105 $export.= str_pad(substr($row['parcelle'],0,7),7," ", STR_PAD_RIGHT); //nom du maitre d ouvrage
106 $export.= str_pad($bl,32," ", STR_PAD_RIGHT); //1ere ligne
107 $export.= str_pad(substr($row['terrain_numero'].
108 " ".$row['terrain_numero_complement']." ".
109 $row['terrain_adresse'],0,32),32," ", STR_PAD_RIGHT);
110 $export.= str_pad(substr($row['terrain_adresse_complement'],0,32),32," ", STR_PAD_RIGHT);
111 $export.= str_pad(substr($row['terrain_cp'],0,5),5," ", STR_PAD_RIGHT);
112 $export.= str_pad(substr($row['terrain_ville'],0,26),26," ", STR_PAD_RIGHT);
113 // decision format yyyymm
114 $temp= substr($row['date_depot'],0,4).substr($row['date_depot'],5,2);
115 if($temp=='000000') $temp=' '; // date vide si 0000/00/00
116 $export.=$temp;// numero dossier 5
117 // categorie
118 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
119 // Nature de travaux
120 $export.= str_pad ($row['codelascot'], 1, " ", STR_PAD_RIGHT);
121 //type annexe habitation
122 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
123 // shon total autoris�e ?
124 $export.= str_pad (substr($row['shon'],0,6), 6, " ", STR_PAD_LEFT);
125 // shon habitation autoris� ?
126 $export.= str_pad (substr($row['shon'],0,6), 6, " ", STR_PAD_LEFT);
127 // mode utilisation principal locaux hab
128 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
129 // mode utilisation autre locaux autre que hab
130 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
131 // destination principale des logements
132 // table destination 1 a plusieurs
133 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
134 // nb logement
135 $export.= str_pad (substr($row['logement_nombre'],0,3), 3, " ", STR_PAD_LEFT);
136 // nb batiment individuel ?
137 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
138 // nb batiment collectif ?
139 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
140 // nb batiments autoris�s
141 $export.= str_pad (substr($row['batiment_nombre'],0,3), 3, " ", STR_PAD_LEFT);
142 // nb log 1 piece
143 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
144 // nb log 2 piece
145 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
146 // nb log 3 piece
147 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
148 // nb log 4 piece
149 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
150 // nb log 5 piece
151 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
152 // nb log 6 piece +
153 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
154 // shon non hab autorise
155 $export.= str_pad ($bl, 6, " ", STR_PAD_LEFT);
156 // 1er type d ouvrage
157 $export.= str_pad ($bl, 2, " ", STR_PAD_LEFT);
158 // shon ass au 1er type ouvrage
159 $export.= str_pad ($bl, 6, " ", STR_PAD_LEFT);
160 // code APET
161 $export.= str_pad ($bl, 4, " ", STR_PAD_LEFT);
162 // Nature des logements
163 $export.= str_pad ($bl, 1, " ", STR_PAD_RIGHT);
164 // capacite accueil locaux hebergt
165 $export.= str_pad ($bl, 3, " ", STR_PAD_LEFT);
166 $export.="\n";
167 }
168 }
169
170 // ecriture des fichiers en tmp
171 $fichier = "../tmp/LO".substr($_POST["datedebut"],3,2).
172 "".substr($_POST["datedebut"],8,4)."PC.132";
173 $inf = fopen($fichier,"w");
174 //$export=substr($export,0,strlen($export)-1); // un \n en trop
175 fwrite($inf,$export);
176 fclose($inf);
177 echo "<br>Fichier ".$fichier." sauvegarde<br><br><br>";
178 echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">";
179 echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier\" title=\"Telecharger le fichier\" />";
180 echo "</a> avec le bouton droit et enregistrer la cible du lien sous. <br /><br />";
181 }//validation
182 ?>

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26