1 |
<?php |
<?php |
2 |
// $Id: sitadel.php,v 1.20 2010-11-15 14:50:40 fraynaud Exp $ |
// $Id$ |
3 |
/* |
/* |
4 |
transfert de dossier � SITADEL |
transfert de dossier � SITADEL |
5 |
realis� ville arles par fr+jlb |
realis� ville arles par fr+jlb |
6 |
voir parametrage trt/sitadel.inc |
voir parametrage trt/sitadel.inc |
7 |
*/ |
*/ |
8 |
require_once "../obj/utils.class.php"; |
require_once "../obj/utils.class.php"; |
10 |
require_once "../dyn/locales.inc.php"; |
require_once "../dyn/locales.inc.php"; |
11 |
require_once "../dyn/version.inc.php"; |
require_once "../dyn/version.inc.php"; |
12 |
require_once "sitadel.inc"; |
require_once "sitadel.inc"; |
13 |
$f = new utils(NULL, "export", _("export SITADEL"), "ico_reqmo.png", "export"); |
$f = new utils(NULL, "export_sitadel", _("export SITADEL"), "ico_reqmo.png", "export"); |
14 |
$f->addHTMLHeadJs(array("../js/script.js")); |
$f->addHTMLHeadJs(array("../js/script.js")); |
15 |
// GET |
// GET |
16 |
if (isset ($_GET['validation'])){ |
if (isset ($_GET['validation'])){ |
66 |
"-".substr($_POST["datefin"],3,2)."-". |
"-".substr($_POST["datefin"],3,2)."-". |
67 |
substr($_POST["datefin"],0,2); |
substr($_POST["datefin"],0,2); |
68 |
if ($correct==true){ // *** |
if ($correct==true){ // *** |
69 |
// dossiers concern�s |
// dossiers concern�s |
70 |
$sql= "select * from ".DB_PREFIXE."dossier"; |
$sql= "select * from ".DB_PREFIXE."dossier"; |
71 |
$sql.= " where (nature='PC' or nature = 'PD' or nature = 'PA' or nature = 'DP')"; |
$sql.= " INNER JOIN ".DB_PREFIXE."dossier_autorisation |
72 |
|
ON dossier.dossier_autorisation=dossier_autorisation.dossier_autorisation |
73 |
|
INNER JOIN ".DB_PREFIXE."dossier_autorisation_type_detaille |
74 |
|
ON dossier_autorisation.dossier_autorisation_type_detaille |
75 |
|
= dossier_autorisation_type_detaille.dossier_autorisation_type_detaille"; |
76 |
|
$sql.= " where (dossier_autorisation_type_detaille.code='PCI' |
77 |
|
or dossier_autorisation_type_detaille.code='PCA' |
78 |
|
or dossier_autorisation_type_detaille.code = 'PD' |
79 |
|
or dossier_autorisation_type_detaille.code = 'PA' |
80 |
|
or dossier_autorisation_type_detaille.code = 'DP')"; |
81 |
$sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')"; |
$sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')"; |
82 |
$sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')"; |
$sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')"; |
83 |
$sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))"; |
$sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))"; |
169 |
// or !isset($row['date_decision'])){ |
// or !isset($row['date_decision'])){ |
170 |
//if(isset($row['date_decision']) and $row['date_decision']!=""){ |
//if(isset($row['date_decision']) and $row['date_decision']!=""){ |
171 |
// avis_sitadel et avis_sitadel_motif |
// avis_sitadel et avis_sitadel_motif |
172 |
if($row['avis']!=''){ |
if($row['avis_decision']!=''){ |
173 |
$avis_sitadel = "0"; |
$avis_sitadel = "0"; |
174 |
$avis_sitadel_motif="0" ; |
$avis_sitadel_motif="0" ; |
175 |
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='". |
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis_decision where avis_decision ='". |
176 |
$row['avis']."'"; |
$row['avis_decision']."'"; |
177 |
$res1 = $f->db -> query ($sql); |
$res1 = $f->db -> query ($sql); |
178 |
$f->isDatabaseError($res1); |
$f->isDatabaseError($res1); |
179 |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
211 |
$row['dossier']."' order by destination"; |
$row['dossier']."' order by destination"; |
212 |
$res3 = $f->db -> query ($sql3); |
$res3 = $f->db -> query ($sql3); |
213 |
$f->isDatabaseError($res3); |
$f->isDatabaseError($res3); |
214 |
$temp = array(); |
// *** |
215 |
while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){ |
$temp = array(); |
216 |
$shonant[$row3['destination']]=$row3["shon_anterieure"]; |
$shonant = array(); |
217 |
$shondem[$row3['destination']]=$row3["shon_demolie"]; |
$shondem = array(); |
218 |
$shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"]; |
$shonanttr = array(); |
219 |
$shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"]; |
$shonprojtr = array(); |
220 |
$shoncr1[$row3['destination']]=$row3["shon_nouvelle"]; |
$shoncr1 = array(); |
221 |
$shoncr2[$row3['destination']]=$row3["shon_shob_transformee"]; |
$shoncr2 = array(); |
222 |
} |
while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){ |
223 |
$decision.= $g->destination($shonant); |
// round(8.5, 0, PHP_ROUND_HALF_DOWN); |
224 |
$decision.= $g->destination($shondem); |
if(isset($row3["shon_anterieure"])) |
225 |
$decision.= $g->destination($shonanttr); |
$shonant[$row3['destination']]=round($row3["shon_anterieure"], 0); |
226 |
$decision.= $g->destination($shonprojtr); |
else |
227 |
$decision.= $g->destination($shoncr1); |
$shonant[$row3['destination']]=0; |
228 |
$decision.= $g->destination($shoncr2); |
if(isset($row3["shon_demolie"])) |
229 |
|
$shondem[$row3['destination']]=round($row3["shon_demolie"], 0); |
230 |
|
else |
231 |
|
$shondem[$row3['destination']]=0; |
232 |
|
if(isset($row3["shon_anterieure_supprimee"])) |
233 |
|
$shonanttr[$row3['destination']]=round($row3["shon_anterieure_supprimee"], 0); |
234 |
|
else |
235 |
|
$shonanttr[$row3['destination']]=0; |
236 |
|
if(isset($row3["shon_nouvelle_transformee"])) |
237 |
|
$shonprojtr[$row3['destination']]=round($row3["shon_nouvelle_transformee"], 0); |
238 |
|
else |
239 |
|
$shonprojtr[$row3['destination']]=0; |
240 |
|
if(isset($row3["shon_nouvelle"])) |
241 |
|
$shoncr1[$row3['destination']]=round($row3["shon_nouvelle"], 0); |
242 |
|
else |
243 |
|
$shoncr1[$row3['destination']]=0; |
244 |
|
if(isset($row3["shon_shob_transformee"])) |
245 |
|
$shoncr2[$row3['destination']]=round($row3["shon_shob_transformee"], 0); |
246 |
|
else |
247 |
|
$shoncr2[$row3['destination']]=0; |
248 |
|
|
249 |
|
//$shonant[$row3['destination']]=$row3["shon_anterieure"]; |
250 |
|
//$shondem[$row3['destination']]=$row3["shon_demolie"]; |
251 |
|
//$shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"]; |
252 |
|
//$shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"]; |
253 |
|
//$shoncr1[$row3['destination']]=$row3["shon_nouvelle"]; |
254 |
|
//$shoncr2[$row3['destination']]=$row3["shon_shob_transformee"]; |
255 |
|
|
256 |
|
} |
257 |
|
$decision.= $g->destination($shonant); |
258 |
|
$decision.= $g->destination($shondem); |
259 |
|
$decision.= $g->destination($shonanttr); |
260 |
|
$decision.= $g->destination($shonprojtr); |
261 |
|
$decision.= $g->destination($shoncr1); |
262 |
|
$decision.= $g->destination($shoncr2); |
263 |
|
|
264 |
$decision.= $g->descriptif($row['types']); |
$decision.= $g->descriptif($row['types']); |
265 |
}else // decision defavorable ou pas de decision |
}else // decision defavorable ou pas de decision |
266 |
$decision.= $t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 | + 12 | = 95 | pour 96 zones |
$decision.= $t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 | + 12 | = 95 | pour 96 zones |
267 |
$decision.="\n"; |
$decision.="\n"; |
275 |
$modificatif.=$g->entete("MODIFICATIF",$departement,$commune,$pf_departement); |
$modificatif.=$g->entete("MODIFICATIF",$departement,$commune,$pf_departement); |
276 |
if(isset($row['date_decision']) or $row['date_decision']==""){ |
if(isset($row['date_decision']) or $row['date_decision']==""){ |
277 |
// avis_sitadel et avis_sitadel_motif |
// avis_sitadel et avis_sitadel_motif |
278 |
if($row['avis']!=''){ |
if($row['avis_decision']!=''){ |
279 |
$avis_sitadel = 0; |
$avis_sitadel = 0; |
280 |
$avis_sitadel_motif=0 ; |
$avis_sitadel_motif=0 ; |
281 |
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='". |
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis_decision where avis_decision ='". |
282 |
$row['avis']."'"; |
$row['avis_decision']."'"; |
283 |
$res1 = $f->db -> query ($sql); |
$res1 = $f->db -> query ($sql); |
284 |
$f->isDatabaseError($res1); |
$f->isDatabaseError($res1); |
285 |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
358 |
// entete de l enregistrement page 8 et 9 |
// entete de l enregistrement page 8 et 9 |
359 |
// *************************************** |
// *************************************** |
360 |
// numero |
// numero |
361 |
// $numero= $db -> nextId('sitadel'); |
// $numero= $db -> nextId('sitadel'); |
362 |
|
$departement =$f->collectivite["departement"]; |
363 |
|
$commune =$f->collectivite["commune"]; |
364 |
|
$region =$f->collectivite["region"]; |
365 |
$numero=$_POST["numero"]; |
$numero=$_POST["numero"]; |
366 |
$fichiertransmis = date('ymj').$pf_departement.$departement.$commune; |
$fichiertransmis = date('ymj').$pf_departement.$departement.$commune; |
367 |
$longueurenregistrement= 0 ; // a calculer *** enregistrement le plus long |
$longueurenregistrement= 0 ; // a calculer *** enregistrement le plus long |
368 |
$entete = "SITADEL|".$pf_departement.$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|"; |
$entete = "SITADEL|".$pf_departement.$departement."|".$commune."|".$region."|".$fichiertransmis."|".$numero."|"; |
369 |
// calcul enregistrement le plus long |
// calcul enregistrement le plus long |
370 |
if(CHARSET=='UTF8'){ |
if(DBCHARSET=='UTF8'){ |
371 |
$export=utf8_decode($export); |
$export=utf8_decode($export); |
372 |
} |
} |
373 |
// nombreenrgistremment et longueurenregistrement |
// nombreenrgistremment et longueurenregistrement |
376 |
$cpt=0; |
$cpt=0; |
377 |
for($i=0;$i<sizeof($nbenr);$i++){ |
for($i=0;$i<sizeof($nbenr);$i++){ |
378 |
// mb_strlen( variable,encoding) PHP 4 >= 4.0.6, PHP 5 |
// mb_strlen( variable,encoding) PHP 4 >= 4.0.6, PHP 5 |
379 |
// Le param�tre encoding est l'encodage des caract�res. |
// Le param�tre encoding est l'encodage des caract�res. |
380 |
// S'il est omis, l'encodage de caracteres interne sera utilis�. |
// S'il est omis, l'encodage de caracteres interne sera utilis�. |
381 |
$tmp[$i] = strlen($nbenr[$i]); |
$tmp[$i] = strlen($nbenr[$i]); |
382 |
//echo strlen($nbenr[$i])." ".$nbenr[$i]."<br>"; |
//echo strlen($nbenr[$i])." ".$nbenr[$i]."<br>"; |
383 |
$cpt++; |
$cpt++; |
394 |
// $str = htmlentities($str, ENT_QUOTES); |
// $str = htmlentities($str, ENT_QUOTES); |
395 |
// ecriture des fichiers en tmp |
// ecriture des fichiers en tmp |
396 |
$fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2). |
$fichier = "../tmp/SITADEL".substr($_POST["datedebut"],3,2). |
397 |
"".substr($_POST["datedebut"],8,4)."_test"; |
"".substr($_POST["datedebut"],8,4).""; |
398 |
$inf = fopen($fichier,"w"); |
$inf = fopen($fichier,"w"); |
399 |
fwrite($inf,$export); |
fwrite($inf,$export); |
400 |
fclose($inf); |
fclose($inf); |
401 |
echo "<br>"._("Fichier")." ".$fichier." "._("sauvegarde")."<br /><br /><br />"; |
echo "<br>"._("Fichier")." ".$fichier." "._("sauvegarde")."<br /><br /><br />"; |
402 |
// affichage |
// affichage |
403 |
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\">"; |
404 |
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 Sitadel\" />"; |
405 |
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 />"; |
406 |
if($DEBUG==1){ |
if($DEBUG==1){ |
407 |
$affiche=""; |
$affiche=""; |