1 |
fraynaud |
88 |
<?php |
2 |
|
|
// $Id: export_dp.php,v 1.6 2010-03-16 19:45:04 fraynaud Exp $ |
3 |
|
|
// include ("../dyn/var.inc"); |
4 |
|
|
/* |
5 |
|
|
transfert de dossier à la DGI Cadstre |
6 |
|
|
*/ |
7 |
|
|
require_once "../obj/utils.class.php"; |
8 |
|
|
$f = new utils(NULL, "export", _("export DP"), "ico_dossier.png", "dossier"); |
9 |
|
|
$f->addHTMLHeadJs(array("../js/script.js")); |
10 |
|
|
// GET ======================================================================== |
11 |
|
|
if (isset ($_GET['validation'])){ |
12 |
|
|
$validation=$_GET['validation']; |
13 |
|
|
}else{ |
14 |
|
|
$validation=0; |
15 |
|
|
} |
16 |
|
|
if (isset ($_GET['idx'])){ |
17 |
|
|
$idx=$_GET['idx']; |
18 |
|
|
}else{ |
19 |
|
|
$idx=0; |
20 |
|
|
} |
21 |
|
|
/** |
22 |
|
|
* Description de la page |
23 |
|
|
*/ |
24 |
|
|
$description = _("Cette page vous permet de Transmettre les DP au cadastre DGI (procedure LASCOT."); |
25 |
|
|
$f->displayDescription($description); |
26 |
|
|
// ============================================================================= |
27 |
|
|
// validation = 0 |
28 |
|
|
// ============================================================================= |
29 |
|
|
if($validation==0){ |
30 |
|
|
$validation=1; |
31 |
|
|
echo "<form method=\"POST\" action=\"export_dp.php?validation=".$validation."\" name=f1>"; |
32 |
|
|
echo " "._("DATE DEBUT DEPOT")." "; |
33 |
|
|
echo "<input type='text' name='datedebut' id=\"datedebut\" value=\""; |
34 |
|
|
echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />"; |
35 |
|
|
echo " "._("DATE FIN DEPOT")." "; |
36 |
|
|
echo "<input type='text' name='datefin' id=\"datefin\" value=\""; |
37 |
|
|
echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />"; |
38 |
|
|
echo "<br><br><input type='submit' value='export DT et PD' ><br><br>"; |
39 |
|
|
echo "</form>"; |
40 |
|
|
}else { // ===================== extraction ================================= |
41 |
|
|
$correct=true; |
42 |
|
|
if($_POST["datedebut"]=="") $correct=false; |
43 |
|
|
if($_POST["datefin"]=="") $correct=false; |
44 |
|
|
if ($correct==true){ |
45 |
|
|
$departement =$f->collectivite["departement"]; |
46 |
|
|
$commune =$f->collectivite["commune"]; |
47 |
|
|
$sql= "select date_depot,annee, dossier.dossier, demandeur_civilite, dossier.nature, |
48 |
|
|
demandeur_nom,demandeur_societe,demandeur_adresse,demandeur_ville,demandeur_cp, |
49 |
|
|
parcelle, terrain_numero,terrain_numero_complement, |
50 |
|
|
terrain_adresse,terrain_adresse_complement, terrain_ville, |
51 |
|
|
shon,logement_nombre,travaux.libelle from dossier |
52 |
|
|
left join travaux on dossier.travaux=travaux.travaux"; |
53 |
|
|
$sql.= " where (dossier.nature = 'DP' or dossier.nature = 'PD')"; |
54 |
|
|
$sql.= " AND date_depot>='".substr($_POST["datedebut"],6,4). |
55 |
|
|
"-".substr($_POST["datedebut"],3,2)."-". |
56 |
|
|
substr($_POST["datedebut"],0,2)."'"; |
57 |
|
|
$sql.= " AND date_depot<='".substr($_POST["datefin"],6,4). |
58 |
|
|
"-".substr($_POST["datefin"],3,2)."-". |
59 |
|
|
substr($_POST["datefin"],0,2)."'"; |
60 |
|
|
$res = $f->db -> query ($sql); |
61 |
|
|
$f->isDatabaseError($res); |
62 |
|
|
$export=""; |
63 |
|
|
$bl=""; |
64 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
65 |
|
|
$export.= $departement; |
66 |
|
|
$export.= $commune; |
67 |
|
|
$export.= $row['annee']; |
68 |
|
|
$export.=substr($row['dossier'],4,5);// numero dossier 5 |
69 |
|
|
// decision format yyyymm |
70 |
|
|
$temp= substr($row['date_depot'],0,4).substr($row['date_depot'],5,2); |
71 |
|
|
if($temp=='000000') $temp=' '; // date vide si 0000/00/00 |
72 |
|
|
$export.=$temp;// |
73 |
|
|
// label |
74 |
|
|
$export.= str_pad($row['nature'],2," ", STR_PAD_RIGHT); //label DP ou PD |
75 |
|
|
// maitre ouvrage |
76 |
|
|
$export.= str_pad(substr($row['demandeur_civilite'],0,5),5," ", STR_PAD_RIGHT); //nom du maitre d ouvrage |
77 |
|
|
$export.= str_pad(substr($row['demandeur_nom'],0,27),27," ", STR_PAD_RIGHT); //nom du maitre d ouvrage |
78 |
|
|
|
79 |
|
|
$export.= str_pad(substr($row['demandeur_societe'],0,32),32," ", STR_PAD_RIGHT); //1ere ligne |
80 |
|
|
$export.= str_pad(substr($row['demandeur_adresse'],0,32),32," ", STR_PAD_RIGHT); // adresse |
81 |
|
|
$export.= str_pad($bl,32," ", STR_PAD_RIGHT); //2eme ligne |
82 |
|
|
$export.= str_pad($bl,32," ", STR_PAD_RIGHT); //3eme Ligne |
83 |
|
|
$export.= str_pad($row['demandeur_cp'],5," ", STR_PAD_RIGHT); |
84 |
|
|
$export.= str_pad(substr($row['demandeur_ville'],0,26),26," ", STR_PAD_RIGHT); |
85 |
|
|
// terrain |
86 |
|
|
$export.= str_pad($bl,32," ", STR_PAD_RIGHT); |
87 |
|
|
$export.= str_pad(substr($row['terrain_numero']. |
88 |
|
|
" ".$row['terrain_numero_complement']." ". |
89 |
|
|
$row['terrain_adresse'],0,32),32," ", STR_PAD_RIGHT); |
90 |
|
|
$export.= str_pad(substr($row['terrain_adresse_complement'],0,32),32," ", STR_PAD_RIGHT); |
91 |
|
|
$export.= str_pad(substr($row['terrain_cp'],0,5),5," ", STR_PAD_RIGHT); |
92 |
|
|
$export.= str_pad(substr($row['terrain_ville'],0,26),26," ", STR_PAD_RIGHT); |
93 |
|
|
$export.= str_pad(substr($row['parcelle'],0,7),7," ", STR_PAD_RIGHT); //nom du maitre d ouvrage |
94 |
|
|
|
95 |
|
|
// destination = travaux libelle |
96 |
|
|
$export.= str_pad (substr($row['libelle'],0,30), 30, " ", STR_PAD_RIGHT); |
97 |
|
|
|
98 |
|
|
$export.="\n"; |
99 |
|
|
} |
100 |
|
|
} |
101 |
|
|
// ecriture des fichiers en tmp |
102 |
|
|
$fichier = "../tmp/LO".substr($_POST["datedebut"],3,2). |
103 |
|
|
"".substr($_POST["datedebut"],8,4)."DT.132"; |
104 |
|
|
$inf = fopen($fichier,"w"); |
105 |
|
|
//$export=substr($export,0,strlen($export)-1); // un \n en trop |
106 |
|
|
fwrite($inf,$export); |
107 |
|
|
fclose($inf); |
108 |
|
|
echo "<table class='dossier' width='95%'>"; |
109 |
|
|
echo "<tr class='dossier'><td>"; |
110 |
|
|
echo "<br><br>Fichier ".$fichier."<br><br><br>"; |
111 |
|
|
//$affiche= str_replace("\n","<br>",$export); |
112 |
|
|
echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">"; |
113 |
|
|
echo "<img src=\"../img/ico_trace.png\" alt=\"Telecharger le fichier CNEN\" title=\"Telecharger le fichier CNEN\" />"; |
114 |
|
|
echo "</a> avec le bouton droit et enregistrer la cible du lien sous. <br /><br />"; |
115 |
|
|
echo "</td></tr></table>"; |
116 |
|
|
}//validation |
117 |
|
|
?> |