1 |
<?php |
<?php |
2 |
// $Id: export_sitadel.php,v 1.20 2010-11-15 14:50:40 fraynaud Exp $ |
// $Id: sitadel.php,v 1.20 2010-11-15 14:50:40 fraynaud Exp $ |
3 |
/* |
/* |
4 |
transfert de dossier � SITADEL |
transfert de dossier � SITADEL |
5 |
realis� ville arles par fr+jlb |
realis� ville arles par fr+jlb |
25 |
$f->displayDescription($description); |
$f->displayDescription($description); |
26 |
//controle |
//controle |
27 |
$DEBUG=1; |
$DEBUG=1; |
28 |
|
$t10 = "||||||||||"; // 10 | |
29 |
|
|
30 |
// parametres collectivite |
// parametres collectivite |
|
|
|
31 |
// ============================================================================= |
// ============================================================================= |
32 |
// validation = 0 |
// validation = 0 |
33 |
// ============================================================================= |
// ============================================================================= |
49 |
echo "<br><br></form>"; |
echo "<br><br></form>"; |
50 |
}else{ // ===================== extraction ================================= |
}else{ // ===================== extraction ================================= |
51 |
$correct=true; |
$correct=true; |
52 |
$longueurenregistrement= 0 ; // a calculer |
$longueurenregistrement= 0 ; |
53 |
//$nombreenregistrement=1; // l entete est compt�e dans le nombre enregistrement |
$t10 = "||||||||||"; // 10 | |
54 |
|
$datedebut =''; |
55 |
|
$datefin=''; |
56 |
if($_POST["datedebut"]=="") |
if($_POST["datedebut"]=="") |
57 |
$correct=false; |
$correct=false; |
58 |
else |
else |
65 |
$datefin = substr($_POST["datefin"],6,4). |
$datefin = substr($_POST["datefin"],6,4). |
66 |
"-".substr($_POST["datefin"],3,2)."-". |
"-".substr($_POST["datefin"],3,2)."-". |
67 |
substr($_POST["datefin"],0,2); |
substr($_POST["datefin"],0,2); |
|
//$correct=true; // a enlever apres test |
|
68 |
if ($correct==true){ // *** |
if ($correct==true){ // *** |
69 |
// dossiers concern�s |
// dossiers concern�s |
70 |
$sql= "select * from dossier"; |
$sql= "select * from ".DB_PREFIXE."dossier"; |
71 |
$sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')"; |
$sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')"; |
72 |
$sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')"; |
$sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')"; |
73 |
$sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')"; |
$sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')"; |
74 |
$sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))"; |
$sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))"; |
75 |
$sql.= " order by date_depot"; |
$sql.= " order by date_depot"; |
|
//$sql.= " and dossier = 'PC11R000402'"; |
|
76 |
$res = $f->db -> query ($sql); |
$res = $f->db -> query ($sql); |
77 |
$f->isDatabaseError($res); |
$f->isDatabaseError($res); |
78 |
$export=""; |
$export=""; |
83 |
// sitadel |
// sitadel |
84 |
$g->val=$val; |
$g->val=$val; |
85 |
// parametre |
// parametre |
86 |
$sql = "select parametre, valeur from statistique where dossier ='".$row['dossier']."'"; |
$sql = "select parametre, valeur from ".DB_PREFIXE."statistique where dossier ='".$row['dossier']."'"; |
87 |
$res1 = $f->db -> query ($sql); |
$res1 = $f->db -> query ($sql); |
88 |
$f->isDatabaseError($res1); |
$f->isDatabaseError($res1); |
89 |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
100 |
and $row['date_depot']<=$datefin) |
and $row['date_depot']<=$datefin) |
101 |
or ($row['date_decision'] >= $datedebut |
or ($row['date_decision'] >= $datedebut |
102 |
and $row['date_decision']<=$datefin))){ |
and $row['date_decision']<=$datefin))){ |
103 |
$depot.=$g->entete("DEPOT",$departement,$commune); |
$depot.=$g->entete("DEPOT",$departement,$commune,$pf_departement); |
104 |
$depot.=$g->etatcivil(); |
$depot.=$g->etatcivil(); |
105 |
$depot.=$g->adresse(); |
$depot.=$g->adresse(); |
106 |
$depot.=$g->delegataire(); |
$depot.=$g->delegataire(); |
137 |
if($row['types']=='Transfert' |
if($row['types']=='Transfert' |
138 |
and $row['date_depot'] >= $datedebut |
and $row['date_depot'] >= $datedebut |
139 |
and $row['date_depot']<=$datefin){ |
and $row['date_depot']<=$datefin){ |
140 |
$transfert.=$g->entete("TRANSFERT",$departement,$commune); |
$transfert.=$g->entete("TRANSFERT",$departement,$commune,$pf_departement); |
141 |
$transfert.=$g->etatcivil(); |
$transfert.=$g->etatcivil(); |
142 |
$transfert.=$g->adresse(); |
$transfert.=$g->adresse(); |
143 |
$transfert.=$g->meltel($row['types']); |
$transfert.=$g->meltel($row['types']); |
148 |
//decision |
//decision |
149 |
// type different de modificatif |
// type different de modificatif |
150 |
$decision=""; |
$decision=""; |
151 |
if($row['types']!='Modificatif' and $row['types']!='Transfert'){ |
if($row['types']!='Modificatif' |
152 |
|
and $row['types']!='Transfert' |
153 |
|
and (($row['date_depot'] >= $datedebut and $row['date_depot']<=$datefin) |
154 |
|
or ($row['date_decision'] >= $datedebut and $row['date_decision']<=$datefin))){ |
155 |
$avis_sitadel=""; |
$avis_sitadel=""; |
156 |
$avis_sitadel_motif=""; |
$avis_sitadel_motif=""; |
157 |
// enregistrement decision dans tous les cas |
// enregistrement decision dans tous les cas |
158 |
$decision.=$g->entete("DECISION",$departement,$commune); |
$decision.=$g->entete("DECISION",$departement,$commune,$pf_departement); |
159 |
//if ($row['date_decision']== '0000-00-00' |
//if ($row['date_decision']== '0000-00-00' |
160 |
// or !isset($row['date_decision'])){ |
// or !isset($row['date_decision'])){ |
161 |
//if(isset($row['date_decision']) and $row['date_decision']!=""){ |
//if(isset($row['date_decision']) and $row['date_decision']!=""){ |
163 |
if($row['avis']!=''){ |
if($row['avis']!=''){ |
164 |
$avis_sitadel = "0"; |
$avis_sitadel = "0"; |
165 |
$avis_sitadel_motif="0" ; |
$avis_sitadel_motif="0" ; |
166 |
$sql="select sitadel, sitadel_motif from avis where avis ='". |
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='". |
167 |
$row['avis']."'"; |
$row['avis']."'"; |
168 |
$res1 = $f->db -> query ($sql); |
$res1 = $f->db -> query ($sql); |
169 |
$f->isDatabaseError($res1); |
$f->isDatabaseError($res1); |
171 |
$avis_sitadel = $row1['sitadel']; |
$avis_sitadel = $row1['sitadel']; |
172 |
$avis_sitadel_motif = $row1['sitadel_motif']; |
$avis_sitadel_motif = $row1['sitadel_motif']; |
173 |
} |
} |
174 |
$decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif); |
$decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure); |
175 |
}else |
}else{ |
176 |
$decision.= $g->decision_groupe1("0",""); // pas d avis |
$decision.= $g->decision_groupe1("0","",$structure); // pas d avis |
177 |
|
//$decision.= "***".$t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 |
178 |
|
} |
179 |
// si la decision est favorable, envoi des informations statistiques |
// si la decision est favorable, envoi des informations statistiques |
180 |
if($avis_sitadel==2 or $avis_sitadel==4 |
if($avis_sitadel==2 or $avis_sitadel==4 |
181 |
or $avis_sitadel==5){ |
or $avis_sitadel==5){ |
184 |
$decision.= $g->amenagement(); |
$decision.= $g->amenagement(); |
185 |
if($row['travaux']!=''){ |
if($row['travaux']!=''){ |
186 |
$sql= "select codelascot,libelle |
$sql= "select codelascot,libelle |
187 |
from travaux where travaux=".$row['travaux']; |
from ".DB_PREFIXE."travaux where travaux=".$row['travaux']; |
188 |
$res2 = $f->db -> query ($sql); |
$res2 = $f->db -> query ($sql); |
189 |
$f->isDatabaseError($res2); |
$f->isDatabaseError($res2); |
190 |
|
$temp=$row['description']; |
191 |
|
// enlever les RC |
192 |
|
$temp = str_replace( chr(10), " ", $temp); |
193 |
|
$temp = str_replace( chr(13), " ", $temp); |
194 |
while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){ |
195 |
$travaux = $row2['libelle']; |
$travaux = $row2['libelle']." "; // *** |
196 |
$lascot = $row2['codelascot']; |
$lascot = $row2['codelascot']; |
197 |
} |
} |
198 |
|
$travaux.=" ".$temp; |
199 |
$decision.= $g->travaux($travaux,$lascot, $row['types']); |
$decision.= $g->travaux($travaux,$lascot, $row['types']); |
200 |
} |
} |
201 |
$sql3="select * from destination_shon where dossier = '". |
$sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '". |
202 |
$row['dossier']."' order by destination"; |
$row['dossier']."' order by destination"; |
203 |
$res3 = $f->db -> query ($sql3); |
$res3 = $f->db -> query ($sql3); |
204 |
$f->isDatabaseError($res3); |
$f->isDatabaseError($res3); |
219 |
$decision.= $g->destination($shoncr2); |
$decision.= $g->destination($shoncr2); |
220 |
|
|
221 |
$decision.= $g->descriptif($row['types']); |
$decision.= $g->descriptif($row['types']); |
222 |
} |
}else // decision defavorable ou pas de decision |
223 |
//}else |
$decision.= $t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 | + 12 | = 95 | pour 96 zones |
|
// $decison.= "|0***"; // avis = 0 si pas de decision |
|
224 |
$decision.="\n"; |
$decision.="\n"; |
225 |
} |
} |
226 |
|
|
229 |
if($row['types']=='Modificatif' |
if($row['types']=='Modificatif' |
230 |
and $row['date_depot'] >= $datedebut |
and $row['date_depot'] >= $datedebut |
231 |
and $row['date_depot']<=$datefin){ |
and $row['date_depot']<=$datefin){ |
232 |
$modificatif.=$g->entete("MODIFICATIF",$departement,$commune); |
$modificatif.=$g->entete("MODIFICATIF",$departement,$commune,$pf_departement); |
233 |
if(isset($row['date_decision']) or $row['date_decision']==""){ |
if(isset($row['date_decision']) or $row['date_decision']==""){ |
234 |
// avis_sitadel et avis_sitadel_motif |
// avis_sitadel et avis_sitadel_motif |
235 |
if($row['avis']!=''){ |
if($row['avis']!=''){ |
236 |
$avis_sitadel = 0; |
$avis_sitadel = 0; |
237 |
$avis_sitadel_motif=0 ; |
$avis_sitadel_motif=0 ; |
238 |
$sql="select sitadel, sitadel_motif from avis where avis ='". |
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='". |
239 |
$row['avis']."'"; |
$row['avis']."'"; |
240 |
$res1 = $f->db -> query ($sql); |
$res1 = $f->db -> query ($sql); |
241 |
$f->isDatabaseError($res1); |
$f->isDatabaseError($res1); |
243 |
$avis_sitadel = $row1['sitadel']; |
$avis_sitadel = $row1['sitadel']; |
244 |
$avis_sitadel_motif = $row1['sitadel_motif']; |
$avis_sitadel_motif = $row1['sitadel_motif']; |
245 |
} |
} |
246 |
$modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif); |
$modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure); |
247 |
} |
} |
248 |
// si la decision est favorable, envoi des informations statistiques |
// si la decision est favorable, envoi des informations statistiques |
249 |
if($avis_sitadel==2 or $avis_sitadel==4 |
if($avis_sitadel==2 or $avis_sitadel==4 |
252 |
$modificatif.=$g->adresse_terrain(); //*** |
$modificatif.=$g->adresse_terrain(); //*** |
253 |
$modificatif.=$g->parcelle(); //*** |
$modificatif.=$g->parcelle(); //*** |
254 |
$modificatif.=$g->terrain(); //*** |
$modificatif.=$g->terrain(); //*** |
255 |
|
// enlever les RC |
256 |
|
$temp=$row['description']; |
257 |
|
$temp = str_replace( chr(10), " ", $temp); |
258 |
|
$temp = str_replace( chr(13), " ", $temp); |
259 |
if($row['travaux']!=''){ |
if($row['travaux']!=''){ |
260 |
$sql= "select codelascot,libelle |
$sql= "select codelascot,libelle |
261 |
from travaux where travaux=".$row['travaux']; |
from ".DB_PREFIXE."travaux where ".DB_PREFIXE."travaux=".$row['travaux']; |
262 |
$res2 = $f->db -> query ($sql); |
$res2 = $f->db -> query ($sql); |
263 |
$f->isDatabaseError($res2); |
$f->isDatabaseError($res2); |
264 |
while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){ |
265 |
$travaux = $row2['libelle']; |
$travaux = $row2['libelle']." ".$row['description']; // ***; |
266 |
$lascot = $row2['codelascot']; |
$lascot = $row2['codelascot']; |
267 |
} |
} |
268 |
|
$travaux.=" ".$temp; |
269 |
$modificatif.= $g->travaux($travaux,$lascot, $row['types']); |
$modificatif.= $g->travaux($travaux,$lascot, $row['types']); |
270 |
} |
} |
271 |
$sql3="select * from destination_shon where dossier = '". |
$sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '". |
272 |
$row['dossier']."' order by destination"; |
$row['dossier']."' order by destination"; |
273 |
$res3 = $f->db -> query ($sql3); |
$res3 = $f->db -> query ($sql3); |
274 |
$f->isDatabaseError($res3); |
$f->isDatabaseError($res3); |
294 |
} |
} |
295 |
} |
} |
296 |
|
|
297 |
// suivi DOC |
// suivi DOC |
298 |
$suivi1=""; |
$suivi1=""; |
299 |
if($row['date_chantier'] >= $datedebut and $row['date_chantier']<=$datefin){ |
if($row['date_chantier'] >= $datedebut and $row['date_chantier']<=$datefin){ |
300 |
$suivi1.=$g->entete("SUIVI",$departement,$commune); |
$suivi1.=$g->entete("SUIVI",$departement,$commune,$pf_departement); |
301 |
$suivi1.=$g->chantier(); |
$suivi1.=$g->chantier(); |
302 |
$suivi1.="\n"; |
$suivi1.="\n"; |
303 |
} |
} |
304 |
// suivi DAT |
// suivi DAT |
305 |
$suivi2=""; |
$suivi2=""; |
306 |
if($row['date_achevement'] >= $datedebut and $row['date_achevement']<=$datefin){ |
if($row['date_achevement'] >= $datedebut and $row['date_achevement']<=$datefin){ |
307 |
$suivi2.=$g->entete("SUIVI",$departement,$commune); |
$suivi2.=$g->entete("SUIVI",$departement,$commune,$pf_departement); |
308 |
$suivi2.=$g->achevement(); |
$suivi2.=$g->achevement(); |
309 |
$suivi2.="\n"; |
$suivi2.="\n"; |
310 |
} |
} |
317 |
// numero |
// numero |
318 |
// $numero= $db -> nextId('sitadel'); |
// $numero= $db -> nextId('sitadel'); |
319 |
$numero=$_POST["numero"]; |
$numero=$_POST["numero"]; |
320 |
$fichiertransmis = date('ymj').$departement.$commune; |
$fichiertransmis = date('ymj').$pf_departement.$departement.$commune; |
321 |
$longueurenregistrement= 0 ; // a calculer *** enregistrement le plus long |
$longueurenregistrement= 0 ; // a calculer *** enregistrement le plus long |
322 |
$entete = "SITADEL|".$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|"; |
$entete = "SITADEL|".$pf_departement.$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|"; |
323 |
// calcul enregistrement le plus long |
// calcul enregistrement le plus long |
324 |
if(CHARSET=='UTF8'){ |
if(CHARSET=='UTF8'){ |
325 |
$export=utf8_decode($export); |
$export=utf8_decode($export); |
342 |
$datemodification = date('y').str_pad (DATE('m'), 2, "0", STR_PAD_LEFT).str_pad (DATE('j'), 2, "0", STR_PAD_LEFT); |
$datemodification = date('y').str_pad (DATE('m'), 2, "0", STR_PAD_LEFT).str_pad (DATE('j'), 2, "0", STR_PAD_LEFT); |
343 |
// export |
// export |
344 |
$version = substr($version,0,8); |
$version = substr($version,0,8); |
345 |
$entete.= $longueurenregistrement."|".$datemodification."|".$nombreenregistrement."|openFoncier|".$version."\n"; |
$entete.= $longueurenregistrement."|".$datemodification."|". |
346 |
|
$nombreenregistrement."|openFoncier|".$version."\n"; |
347 |
$export=$entete.$export; |
$export=$entete.$export; |
348 |
//$str = htmlentities($str, ENT_QUOTES); |
// $str = htmlentities($str, ENT_QUOTES); |
349 |
// ecriture des fichiers en tmp |
// ecriture des fichiers en tmp |
350 |
$fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2). |
$fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2). |
351 |
"".substr($_POST["datedebut"],8,4)."_test"; |
"".substr($_POST["datedebut"],8,4)."_test"; |
352 |
$inf = fopen($fichier,"w"); |
$inf = fopen($fichier,"w"); |
|
//$export=substr($export,0,strlen($export)-1); // un \n en trop |
|
353 |
fwrite($inf,$export); |
fwrite($inf,$export); |
354 |
fclose($inf); |
fclose($inf); |
355 |
echo "<br>Fichier ".$fichier." sauvegarde<br><br><br>"; |
echo "<br>"._("Fichier")." ".$fichier." "._("sauvegarde")."<br /><br /><br />"; |
|
|
|
356 |
// affichage |
// affichage |
357 |
echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">"; |
echo "<br /><br />Pour telecharger le fichier, cliquer ici : <a href=\"".$fichier."\" target=\"_blank\">"; |
358 |
echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier CNEN\" title=\"Telecharger le fichier CNEN\" />"; |
echo "<img src=\"../app/img/ico_trace.png\" alt=\"Telecharger le fichier CNEN\" title=\"Telecharger le fichier CNEN\" />"; |
359 |
echo "</a> avec le bouton droit et enregistrer la cible du lien sous. <br /><br />"; |
echo "</a>"._("avec le bouton droit et enregistrer la cible du lien sous.")."<br /><br />"; |
|
|
|
360 |
if($DEBUG==1){ |
if($DEBUG==1){ |
361 |
$affiche=""; |
$affiche=""; |
362 |
$affiche= str_replace("\n","<br>",$export); |
$affiche= str_replace("\n","<br>",$export); |
363 |
echo $affiche; |
echo $affiche; |
364 |
} |
} |
|
|
|
|
|
|
365 |
}else // correct = false |
}else // correct = false |
366 |
echo "remplissez les 2 dates"; |
echo _("remplissez les 2 dates"); |
367 |
}//validation |
}//validation |
|
?> |
|
368 |
|
?> |