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 |
7 |
*/ |
*/ |
8 |
require_once "../obj/utils.class.php"; |
require_once "../obj/utils.class.php"; |
9 |
require_once "../app/sitadel.class.php"; |
require_once "../app/sitadel.class.php"; |
10 |
|
require_once "../dyn/locales.inc.php"; |
11 |
|
require_once "../dyn/version.inc.php"; |
12 |
|
require_once "sitadel.inc"; |
13 |
$f = new utils(NULL, "export", _("export SITADEL"), "ico_reqmo.png", "export"); |
$f = new utils(NULL, "export", _("export SITADEL"), "ico_reqmo.png", "export"); |
14 |
$f->addHTMLHeadJs(array("../js/script.js")); |
$f->addHTMLHeadJs(array("../js/script.js")); |
15 |
// GET |
// GET |
25 |
$f->displayDescription($description); |
$f->displayDescription($description); |
26 |
//controle |
//controle |
27 |
$DEBUG=1; |
$DEBUG=1; |
28 |
$x=array(); |
$t10 = "||||||||||"; // 10 | |
|
$cpt_depot=0; |
|
|
$cpt_decision=0; |
|
|
$cpt_suivi1=0; |
|
|
$cpt_suivi2=0; |
|
|
$cpt_transfert=0; |
|
|
$cpt_modificatif=0; |
|
|
include("sitadel.inc"); |
|
|
// parametres collectivite |
|
29 |
|
|
30 |
|
// parametres collectivite |
31 |
// ============================================================================= |
// ============================================================================= |
32 |
// validation = 0 |
// validation = 0 |
33 |
// ============================================================================= |
// ============================================================================= |
47 |
echo "</select>"; |
echo "</select>"; |
48 |
echo "<br><br><input type='submit' value='export SITADEL'>"; |
echo "<br><br><input type='submit' value='export SITADEL'>"; |
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 |
// entete |
$t10 = "||||||||||"; // 10 | |
54 |
$nombreenregistrement=1; // l entete est compt�e dans le nombre enregistrement |
$datedebut =''; |
55 |
|
$datefin=''; |
56 |
if($_POST["datedebut"]=="") |
if($_POST["datedebut"]=="") |
57 |
$correct=false; |
$correct=false; |
58 |
if($_POST["datefin"]=="") $correct=false; |
else |
59 |
|
$datedebut = substr($_POST["datedebut"],6,4). |
60 |
|
"-".substr($_POST["datedebut"],3,2)."-". |
61 |
|
substr($_POST["datedebut"],0,2); |
62 |
|
if($_POST["datefin"]=="") |
63 |
|
$correct=false; |
64 |
|
else |
65 |
|
$datefin = substr($_POST["datefin"],6,4). |
66 |
|
"-".substr($_POST["datefin"],3,2)."-". |
67 |
|
substr($_POST["datefin"],0,2); |
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>='".$this->datedebut."' AND date_depot<='".$this->datefin."')"; |
$sql.= " AND ((date_depot >='".$datedebut."' AND date_depot<='".$datefin."')"; |
73 |
//$sql.= " OR (date_decision>='".$this->datedebut."' AND date_decision<='".$this->datefin."'))"; |
$sql.= " OR (date_decision>='".$datedebut."' AND date_decision<='".$datefin."')"; |
74 |
$sql.= " and dossier = 'PC11R0004'"; |
$sql.= " OR (date_chantier>='".$datedebut."' AND date_chantier<='".$datefin."'))"; |
75 |
$res = $f->db -> query ($sql); |
$sql.= " order by date_depot"; |
|
$f->isDatabaseError($res); |
|
|
//initialisation |
|
|
$export=""; |
|
|
$bl=""; |
|
|
|
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
// initialisation |
|
|
$g = new sitadel($row['dossier']); |
|
|
$g->row=$row; |
|
|
$departement =$f->collectivite["departement"]; |
|
|
$commune =$f->collectivite["commune"]; |
|
|
|
|
|
// depot |
|
|
$depot=""; |
|
|
// type different de transfert |
|
|
if($row['types']!='Transfert'){ |
|
|
$depot.=$g->entete("DEPOT",$departement,$commune); |
|
|
$depot.=$g->etatcivil(); |
|
|
$depot.=$g->adresse(); |
|
|
$depot.=$g->delegataire(); |
|
|
$depot.=$g->adresse_terrain(); |
|
|
$depot.=$g->parcelle(); |
|
|
// =========================== |
|
|
// contrat maison individuelle |
|
|
// =========================== |
|
|
// sitadel : contrat| |
|
|
// openfoncier : non renseigne |
|
|
$depot.= "|"; |
|
|
// ========== |
|
|
// architecte |
|
|
// ========== |
|
|
// sitadel : architecte| |
|
|
// openfoncier : architecte >0 |
|
|
if($row['architecte']>0) |
|
|
$depot.= "1|"; |
|
|
else |
|
|
$depot.= "0|"; |
|
|
// ===================== |
|
|
// utilisation data cnil |
|
|
// ====================== |
|
|
// sitadel : cnil |
|
|
// openfoncier : non renseigne |
|
|
$depot.= "1"; |
|
|
// fin d enregistrement depot |
|
|
$depot.="\n"; |
|
|
} |
|
|
|
|
|
//decision |
|
|
// type different de modificatif |
|
|
if($row['types']!='Modificatif'){ |
|
|
$decision=""; |
|
|
// enregistrement decision dans tous les cas |
|
|
$decision.=$g->entete("DECISION",$departement,$commune); |
|
|
//if ($row['date_decision']== '0000-00-00' |
|
|
// or !isset($row['date_decision'])){ |
|
|
//if(!isset($row['date_decision']) or $row['date_decision']==""){ |
|
|
// avis_sitadel et avis_sitadel_motif |
|
|
if($row['avis']!=''){ |
|
|
$avis_sitadel = 0; |
|
|
$avis_sitadel_motif=0 ; |
|
|
$sql="select sitadel, sitadel_motif from avis where avis ='".$row['avis']."'"; |
|
|
$res1 = $f->db -> query ($sql); |
|
|
$f->isDatabaseError($res1); |
|
|
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
$avis_sitadel = $row1['sitadel']; |
|
|
$avis_sitadel_motif = $row1['sitadel_motif']; |
|
|
} |
|
|
$decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif); |
|
|
} |
|
|
if($avis_sitadel==2 or $avis_sitadel==4 |
|
|
or $avis_sitadel==5){ |
|
|
// si decision favorable, expresse ou tacite GROUPE 2 |
|
|
$decision.= $g->amenagement(); |
|
|
if($row['travaux']!=''){ |
|
|
$sql= "select codelascot as lascot,libelle |
|
|
from travaux where travaux=".$row['travaux']; |
|
|
$res2 = $f->db -> query ($sql); |
|
|
$f->isDatabaseError($res2); |
|
|
while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
$travaux = $row2['libelle']; |
|
|
$lascot = $row2['lascot']; |
|
|
} |
|
|
$decision.= $g->travaux($travaux,$lascot); |
|
|
} |
|
|
$sql3="select * from destination_shon where dossier = '". |
|
|
$row['dossier']."' order by destination"; |
|
|
$res3 = $f->db -> query ($sql3); |
|
|
$f->isDatabaseError($res3); |
|
|
$temp = array(); |
|
|
while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
$shonant[$row3['destination']]=$row3["shon_anterieure"]; |
|
|
$shondem[$row3['destination']]=$row3["shon_demolie"]; |
|
|
$shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"]; |
|
|
$shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"]; |
|
|
$shoncr1[$row3['destination']]=$row3["shon_nouvelle"]; |
|
|
$shoncr2[$row3['destination']]=$row3["shon_shob_transformee"]; |
|
|
} |
|
|
$decision.= $g->destination($shonant); |
|
|
$decision.= $g->destination($shondem); |
|
|
$decision.= $g->destination($shonanttr); |
|
|
$decision.= $g->destination($shonprojtr); |
|
|
$decision.= $g->destination($shoncr1); |
|
|
$decision.= $g->destination($shoncr2); |
|
|
|
|
|
$decision.= $g->descriptif(); |
|
|
|
|
|
|
|
|
} |
|
|
//} |
|
|
} |
|
|
|
|
|
if($DEBUG==1){ |
|
|
echo $depot."<br>"; |
|
|
echo $decision."<br>"; |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ================================================================================== |
|
|
// evenement de decision sur une p�riode *** DECISION *** |
|
|
// ================================================================================== |
|
|
$sql= "select annee, dossier.dossier, dossier.nature, |
|
|
terrain_surface, amenagement, travaux.libelle as travaux_libelle, |
|
|
shon,logement_nombre, piece_nombre, |
|
|
date_decision, avis.sitadel as avis_sitadel, avis.sitadel_motif as avis_sitadel_motif, |
|
|
travaux.codelascot as lascot |
|
|
from dossier left join travaux on dossier.travaux=travaux.travaux |
|
|
left join avis on avis.avis= dossier.avis"; |
|
|
$sql.= " where date_decision>='".substr($_POST["datedebut"],6,4). |
|
|
"-".substr($_POST["datedebut"],3,2)."-". |
|
|
substr($_POST["datedebut"],0,2)."'"; |
|
|
$sql.= " AND date_decision<='".substr($_POST["datefin"],6,4). |
|
|
"-".substr($_POST["datefin"],3,2)."-". |
|
|
substr($_POST["datefin"],0,2)."'"; |
|
|
$sql.= " AND (dossier.nature='PC' or dossier.nature = 'PD' or dossier.nature = 'PA' or dossier.nature = 'DP')"; |
|
|
$sql.= " AND types != 'Modificatif'"; |
|
|
echo "<BR><br><font style='background-color:#ffffff;border : 1px solid #000000'>DECISION</font> ".$sql; |
|
76 |
$res = $f->db -> query ($sql); |
$res = $f->db -> query ($sql); |
77 |
$f->isDatabaseError($res); |
$f->isDatabaseError($res); |
78 |
|
$export=""; |
79 |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
80 |
$nombreenregistrement++; |
// initialisation |
81 |
$cpt_decision++; |
$g = new sitadel($row['dossier']); |
82 |
// Decision GROUPE 1 |
$g->row=$row; |
83 |
// sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod |
// sitadel |
84 |
$decision.="DECISION|".$row['nature']."||".$departement."|".$commune."|".$row['annee']."|".substr($row['dossier'],4,5)."|".substr($row['dossier'],9,2)."|"; |
$g->val=$val; |
85 |
// sitadel : collectivite|natdec|datedec|motifann |
// parametre |
86 |
|
$sql = "select parametre, valeur from ".DB_PREFIXE."statistique where dossier ='".$row['dossier']."'"; |
87 |
// ================================================== |
$res1 = $f->db -> query ($sql); |
88 |
/ |
$f->isDatabaseError($res1); |
89 |
// ================================================== |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
90 |
//avis sitadel |
$g->parametre[$row1['parametre']]=$row1['valeur']; |
91 |
if($row['avis_sitadel']==2 |
} |
92 |
or $row['avis_sitadel']==4 |
$departement =$f->collectivite["departement"]; |
93 |
or $row['avis_sitadel']==5){ |
$commune =$f->collectivite["commune"]; |
94 |
// renseignement du groupe 2 *** |
$region =$f->collectivite["region"]; |
95 |
//sitadel : terrain|lotissement|zac|afu|libnattrav|natproj| |
// depot |
96 |
$decision.= "|".floor($row['terrain_surface'])."|"; |
$depot=""; |
97 |
if($row['amenagement']!='') |
// type different de transfert |
98 |
$decision.= "1|"; |
if($row['types']!='Transfert' |
99 |
|
and (($row['date_depot'] >= $datedebut |
100 |
|
and $row['date_depot']<=$datefin) |
101 |
|
or ($row['date_decision'] >= $datedebut |
102 |
|
and $row['date_decision']<=$datefin))){ |
103 |
|
$depot.=$g->entete("DEPOT",$departement,$commune,$pf_departement); |
104 |
|
$depot.=$g->etatcivil(); |
105 |
|
$depot.=$g->adresse(); |
106 |
|
$depot.=$g->delegataire(); |
107 |
|
$depot.=$g->meltel($row['types']); |
108 |
|
$depot.=$g->adresse_terrain(); |
109 |
|
$depot.=$g->parcelle(); |
110 |
|
// =========================== |
111 |
|
// contrat maison individuelle |
112 |
|
// =========================== |
113 |
|
// sitadel : contrat| |
114 |
|
// openfoncier : non renseigne |
115 |
|
$depot.= $g->p('contrat')."|"; |
116 |
|
// ========== |
117 |
|
// architecte |
118 |
|
// ========== |
119 |
|
// sitadel : architecte| |
120 |
|
// openfoncier : architecte >0 |
121 |
|
if($row['architecte']>0) |
122 |
|
$depot.= "1|"; |
123 |
else |
else |
124 |
$decision.= "0|"; |
$depot.= "0|"; |
125 |
$decision.= "0|0|"; // zac afu -> non renseignee |
// ===================== |
126 |
$decision.= maj($row['travaux_libelle'])."|"; |
// utilisation data cnil |
127 |
// aout 2010 ????????????????? $decision.= "0|"; |
// ====================== |
128 |
if($row['lascot']=='1' |
// sitadel : cnil |
129 |
or $row['lascot']=='2' |
// openfoncier : non renseigne |
130 |
or $row['lascot']=='3') |
$depot.= $g->p('cnil'); |
131 |
$decision.= $row['lascot']."|"; // natproj 1:construction 2:extension ou 3:surelevation |
// fin d enregistrement depot |
132 |
else |
$depot.="\n"; |
|
$decision.= "|"; |
|
|
// natdp|nattrav|*annexe*|*nivmax* ========================= |
|
|
//natdp |
|
|
$natdp='00000'; |
|
|
if($row['lascot']=='1') $natdp="10000"; // nouvelle construction |
|
|
if($row['lascot']=='2') $natdp="01000"; // travaux sur construction existante |
|
|
if($row['lascot']=='3') $natdp="01000"; // |
|
|
if($row['lascot']=='X') $natdp="00001"; // cloture |
|
|
$decision.= $natdp."|"; |
|
|
// nattrav |
|
|
$nattrav = "0000"; |
|
|
if($row['lascot']=='2') $nattrav="1000"; |
|
|
if($row['lascot']=='3') $nattrav="0100"; |
|
|
$decision.= $nattrav."|"; |
|
|
// annexe non renseigner defaut 00000 |
|
|
$decision.= "00000|"; |
|
|
//nivmax non saisi |
|
|
// ajout nivmax aout 2010 |
|
|
$decision.="|"; |
|
|
// S H O N / DESTINATION ======================================== |
|
|
//shonant1 - shonnant9|shondem1 � 9| shonanttr1 � 9| shonprojtr 1 � 9|shoncr1 a 9 |shon2cr1 a 9 |
|
|
// 1 habitation, 2 hotel , 3 bureau ... 9 ... |
|
|
// les shon sont exprimees sans decimales |
|
|
$decision.= "|||||||||";// shon avant travaux -> non renseigne |
|
|
// table destination |
|
|
$sql1="select destination, shon from destination_shon where dossier = '". $row['dossier']."'"; |
|
|
$res1 = $f->db -> query ($sql1); |
|
|
$f->isDatabaseError($res1); |
|
|
// |
|
|
$tmpPD = array(); // shon existante demolie |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmpPD[$i]=''; |
|
|
} |
|
|
// |
|
|
$tmplascot4 = array(); // shon changement de destination |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmplascot4[$i]=''; |
|
|
} |
|
|
// |
|
|
$tmplascot1 = array(); // shon nouvellement construite |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmplascot1[$i]=''; |
|
|
} |
|
|
// |
|
|
$tmplascot2 = array(); // shon cree par transformation |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmplascot2[$i]=''; |
|
|
} |
|
|
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
// shonprojtr1 a 9 / shoncr1 a 9 / |
|
|
if($row['nature']== 'PD') { |
|
|
$tmpPD[$row1['destination']] = $row1['shon']; // shon existante demolie -> a remplir |
|
|
} |
|
|
if($row['lascot']== '4') { |
|
|
$tmplascot4[$row1['destination']] = $row1['shon'];// shon changement de destination -> a remplir |
|
|
} |
|
|
if($row['lascot']== '1'){ |
|
|
$tmplascot1[$row1['destination']] = $row1['shon'];// shon nouvellement construite -> a remplir |
|
|
} |
|
|
if($row['lascot']== '2') { |
|
|
$tmplascot2[$row1['destination']] = $row1['shon'];// shon cree par transformation -> a remplir |
|
|
} |
|
|
} |
|
|
// shon existante demolie -> a remplir |
|
|
for($i=1;$i<=9;$i++) |
|
|
{ |
|
|
$decision.=$tmpPD[$i].'|'; |
|
|
} |
|
|
// |
|
|
$decision.= "|||||||||";// shon supprimmee par changement de destination -> non renseigne |
|
|
// |
|
|
//$row['lascot']== '4' shon changement de destination |
|
|
for($i=1;$i<=9;$i++) |
|
|
{ |
|
|
$decision.=$tmplascot4[$i].'|'; |
|
|
} |
|
|
//shon nouvellement construite |
|
|
for($i=1;$i<=9;$i++) |
|
|
{ |
|
|
$decision.=$tmplascot1[$i].'|'; |
|
|
} |
|
|
//shon cree par transformation |
|
|
for($i=1;$i<=9;$i++) |
|
|
{ |
|
|
$decision.=$tmplascot2[$i].'|'; |
|
|
} |
|
|
// fin destination_shon ==================================== |
|
|
// cpublic : non renseignee N par defaut |
|
|
// O/N transport/enseignement/sante/social/special/culture |
|
|
$decision.= "000000"; //* supp| |
|
|
// nblogdem |
|
|
$decision.= "|".$row['logement_nombre']; |
|
|
// nbmaison : nombre de maison |
|
|
$decision.= "|"; |
|
|
// nblogcoll : nombre de logement collectif |
|
|
$decision.= "|"; |
|
|
// nbtotlog : nombre de logement total |
|
|
$decision.= "|"; |
|
|
// natres : nature des residences |
|
|
// O/N 1=ages, 2=etudiant, 3=tourisme, 4=hotel, 5=social, 6= handicap, 7=autres |
|
|
$decision.= "|0000000"; |
|
|
// libres= si autre residence (long max 1000 c) |
|
|
$decision.= "|"; |
|
|
// util : O/N personnel, principale, secondaire, vente, location |
|
|
$decision.= "|00000"; |
|
|
//chambres |
|
|
$decision.= "|"; |
|
|
// nb logement sociaux |
|
|
$decision.= "|"; |
|
|
// nb logt financt aides |
|
|
$decision.= "|"; |
|
|
// nb de logt pret a taux 0 |
|
|
$decision.= "|"; |
|
|
// nb de logt finances autrt |
|
|
$decision.= "|"; |
|
|
// nb pieces en maison individuelle |
|
|
$decision.= "|".$row['piece_nombre']; // voir si 0 |
|
|
// chambre (num capacite accueil locaux hebergement) |
|
|
$decision.= "|"; |
|
|
// nb de logement 1piece |
|
|
$decision.= "|"; |
|
|
// nb de logement 2 pieces |
|
|
$decision.= "|"; |
|
|
// nb de logement 3 pieces |
|
|
$decision.= "|"; |
|
|
// nb de logement 4 pieces |
|
|
$decision.= "|"; |
|
|
// nb de logement 5 pieces |
|
|
$decision.= "|"; |
|
|
// nb de logement 6 pieces |
|
|
$decision.= ""; |
|
|
}// fin decision favorable |
|
|
$decision.="\n"; |
|
|
} // end while decision |
|
|
if($DEBUG==1){ |
|
|
$temp=explode("\n",$decision); |
|
|
$temp1=sizeof($temp)-1; |
|
|
for($g=0;$g<$temp1;$g++){ |
|
|
$temp2=array(); |
|
|
$temp2 = explode("|",$temp[$g]); |
|
|
$v=$g+1; |
|
|
echo "<br><br>decision : ".$v." ============== <br>"; |
|
|
for($k=0;$k<sizeof($temp2);$k++){ |
|
|
$t=$k+1; |
|
|
echo $t." : ".$temp2[$k]."<br>"; |
|
|
} |
|
|
} |
|
|
} // fin debug decision |
|
|
// ================================================================================== |
|
|
// suivi DOC *** suivi DOC *** |
|
|
// ================================================================================== |
|
|
// Evenement declancheur DATE OUVERTURE DE CHANTIER |
|
|
$sql= "select annee, dossier.dossier, dossier.nature, annee, |
|
|
date_chantier, shon |
|
|
from dossier "; |
|
|
$sql.= " where date_chantier>='".substr($_POST["datedebut"],6,4). |
|
|
"-".substr($_POST["datedebut"],3,2)."-". |
|
|
substr($_POST["datedebut"],0,2)."'"; |
|
|
$sql.= " AND date_chantier<='".substr($_POST["datefin"],6,4). |
|
|
"-".substr($_POST["datefin"],3,2)."-". |
|
|
substr($_POST["datefin"],0,2)."'"; |
|
|
echo "<BR><br><font style='background-color:#ffffff;border : 1px solid #000000'>SUIVI</font> ".$sql; |
|
|
// faut il en faire suivi 1 et suivi 2 ou dans une meme requete |
|
|
$res = $f->db -> query ($sql); |
|
|
$f->isDatabaseError($res); |
|
|
$suivi1=""; |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
$nombreenregistrement++; |
|
|
$cpt_suivi1++; |
|
|
// sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod |
|
|
// typepermis = dossier.nature |
|
|
// annee = dossier.annee |
|
|
// andepnumpc|indmod = substr dossier.dossier |
|
|
$suivi1.="SUIVI|".$row['nature']."||".$departement."|".$commune."|".$row['annee']."|". |
|
|
substr($row['dossier'],4,5)."|".substr($row['dossier'],9,2).""; |
|
|
// datereoc date de chantier |
|
|
//|datereoc |
|
|
//echo $row['date_chantier']."****************************"; |
|
|
$suivi1.="|".substr($row['date_chantier'],8,2).substr($row['date_chantier'],5,2).substr($row['date_chantier'],0,4); // *** au format francais |
|
|
//|nblogoc|nbmaisoc|nbcolloc |
|
|
$suivi1.="|||"; |
|
|
//|shonoc |
|
|
$suivi1.="|".floor($row['shon']); // ok *** enlever les decimales |
|
|
//|finisoc|finaaoc|finptzoc|finafoc|indoc |
|
|
$suivi1.="|||||"; |
|
|
$suivi1.="||||||||||||"; // achevement |
|
|
$suivi1.="\n"; |
|
|
}// fin while doc |
|
|
|
|
|
if($DEBUG==1){ |
|
|
$temp=explode("\n",$suivi1); |
|
|
$temp1=sizeof($temp)-1; |
|
|
for($g=0;$g<$temp1;$g++){ |
|
|
$temp2=array(); |
|
|
$temp2 = explode("|",$temp[$g]); |
|
|
$v=$g+1; |
|
|
echo "<br><br> DOC : ".$v." ============== <br>"; |
|
|
for($k=0;$k<sizeof($temp2);$k++){ |
|
|
$t=$k+1; |
|
|
echo $t." : ".$temp2[$k]."<br>"; |
|
|
} |
|
|
} |
|
|
} // fin debug |
|
|
// ================================================================================== |
|
|
// suivi *** suivi DAT *** |
|
|
// ================================================================================== |
|
|
// element declancheur : DATE ACHEVEMENT DE TRAVAUX |
|
|
$sql= "select annee, dossier.dossier, dossier.nature, annee, |
|
|
date_achevement, shon,date_chantier,dossier.etat |
|
|
from dossier "; |
|
|
$sql.= " where date_achevement>='".substr($_POST["datedebut"],6,4). |
|
|
"-".substr($_POST["datedebut"],3,2)."-". |
|
|
substr($_POST["datedebut"],0,2)."'"; |
|
|
$sql.= " AND date_achevement<='".substr($_POST["datefin"],6,4). |
|
|
"-".substr($_POST["datefin"],3,2)."-". |
|
|
substr($_POST["datefin"],0,2)."'"; |
|
|
echo "<BR><font style='background-color:#ffffff;border : 1px solid #000000'>SUIVI</font> ".$sql; |
|
|
// ou dat ??? |
|
|
// *** |
|
|
$res = $f->db -> query ($sql); |
|
|
if (DB :: isError ($res)) |
|
|
die ($res -> getDebugInfo ()." Erreur ".$sql); |
|
|
else |
|
|
{ |
|
|
$cpt_suivi2=0; |
|
|
$suivi2=""; |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
$nombreenregistrement++; |
|
|
$cpt_suivi2++; |
|
|
// sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod |
|
|
// typepermis = dossier.nature |
|
|
// annee = dossier.annee |
|
|
// andepnumpc|indmod = substr dossier.dossier |
|
|
$suivi2.="SUIVI|".$row['nature']."||".$departement."|".$commune."|".$row['annee']."|". |
|
|
substr($row['dossier'],4,5)."|".substr($row['dossier'],9,2).""; |
|
|
$suivi2.="||||||||||"; |
|
|
// datereoc date de chantier |
|
|
//|datereat |
|
|
$suivi2.="|".substr($row['date_achevement'],8,2).substr($row['date_achevement'],5,2).substr($row['date_achevement'],0,4); // ok *** au format francais |
|
|
//|nblogat|nbmaisat|nbcollat |
|
|
$suivi2.="|||"; |
|
|
//|shonat |
|
|
$suivi2.="|".floor($row['shon']); // ok *** enlever les decimales |
|
|
//|finisat|finaaat|finptzat|finafat|indat| |
|
|
$suivi2.="||||||"; |
|
|
// Finchantier 1 si etat=cloturer sinon 0 |
|
|
if ($row['etat']=="cloturer"){ |
|
|
$suivi2.="1|"; |
|
|
}else{ |
|
|
$suivi2.="0|"; |
|
|
} |
|
|
// Origat 1 par defaut ????????????????????????????? |
|
|
$suivi2.="1"; |
|
|
$suivi2.="\n"; |
|
|
}// fin doc |
|
|
} |
|
|
if($DEBUG==1){ |
|
|
$temp=explode("\n",$suivi2); |
|
|
$temp1=sizeof($temp)-1; |
|
|
for($g=0;$g<$temp1;$g++){ |
|
|
$temp2=array(); |
|
|
$temp2 = explode("|",$temp[$g]); |
|
|
$v=$g+1; |
|
|
echo "<br><br> DAT : ".$v." ============== <br>"; |
|
|
for($k=0;$k<sizeof($temp2);$k++){ |
|
|
$t=$k+1; |
|
|
echo $t." : ".$temp2[$k]."<br>"; |
|
|
} |
|
|
} |
|
|
} |
|
|
//$res -> free (); |
|
|
|
|
|
|
|
|
// ================================================================================== |
|
|
// Transfert TRANSFERT |
|
|
// ================================================================================== |
|
|
// element declancheur : Transfert |
|
|
// zone types= Transfert |
|
|
$sql= "select date_achevement, annee, dossier.dossier, demandeur_civilite, dossier.nature,demandeur_categorie, |
|
|
categorie_demandeur.libelle as categorie_libelle,demandeur_nom,demandeur_societe,demandeur_adresse, |
|
|
demandeur_ville,demandeur_cp,demandeur_email,delegataire,parcelle, terrain_numero, |
|
|
terrain_numero_complement,terrain_adresse,terrain_adresse_complement, terrain_ville, terrain_cp, |
|
|
architecte from dossier |
|
|
left join categorie_demandeur on demandeur_categorie= categorie_demandeur.categorie_demandeur"; |
|
|
$sql.= " where date_depot>='".substr($_POST["datedebut"],6,4). |
|
|
"-".substr($_POST["datedebut"],3,2)."-". |
|
|
substr($_POST["datedebut"],0,2)."'"; |
|
|
$sql.= " AND date_depot<='".substr($_POST["datefin"],6,4). |
|
|
"-".substr($_POST["datefin"],3,2)."-". |
|
|
substr($_POST["datefin"],0,2)."'"; |
|
|
$sql.= " AND types= 'Transfert'"; |
|
|
echo "<BR><br><font style='background-color:#ffffff;border : 1px solid #000000'>TRANSFERT</font> ".$sql; |
|
|
// date du transfert ? |
|
|
$res = $f->db -> query ($sql); |
|
|
$f->isDatabaseError($res); |
|
|
$transfert=""; |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
$nombreenregistrement++; |
|
|
$cpt_transfert++; |
|
|
// sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod |
|
|
// typepermis = dossier.nature |
|
|
// annee = dossier.annee |
|
|
// andepnumpc|indmod = substr dossier.dossier |
|
|
$transfert.="TRANSFERT|".$row['nature']."||".$departement."|".$commune."|".$row['annee']."|". |
|
|
substr($row['dossier'],4,5)."|".substr($row['dossier'],9,2)."|"; |
|
|
//ajout aout2010-----IDEM DEPOT codedemo � suivi (---- sauf civtiers|*prenomtier*|nomtier|*numvoietiers*|*typvoietiers*| |
|
|
// libvoietiers|lieudittier|communetier|codpostier|*bptier*|*cedextier*|*paystier*| |
|
|
// *divtertier et telmo----) |
|
|
// codemo| |
|
|
if($row['demandeur_categorie']==9 or $row['demandeur_categorie']=="") |
|
|
$codemo=1;// personne physique |
|
|
else |
|
|
$codemo=2;// personne morale |
|
|
$transfert.=$codemo."|"; // 1 personne physique ; 2 sinon |
|
|
// openfoncier civilite (5/8 ok), nom (80/30-> substr), societe (80/50->substr) |
|
|
// civpart|prenompart|nompart|denopm|rspm|siret|catjur|civrep|prenomrep|nomrep| |
|
|
// suivant codemo = 1 (personne physique) ou 2 (personne morale) |
|
|
// attention : $row['demandeur_civilite']. non standart |
|
|
|
|
|
if($codemo==1){ |
|
|
// civpart|*prenompart*|nompart|||||| |
|
|
|
|
|
$transfert.= "||"; |
|
|
$transfert.= maj(substr($row['demandeur_nom'],0,30))."|||||||"; |
|
|
}else{ |
|
|
//denopm|rspm|*siret*|*catjur*|civrep|*prenomrep*|nomrep| |
|
|
$transfert.="|||".maj(substr($row['demandeur_societe'],0,50))."|"; |
|
|
$transfert.=maj(substr($row['categorie_libelle'],0,30))."|"; |
|
|
$transfert.="||||". |
|
|
maj(substr($row['demandeur_nom'],0,30))."|"; // pas de prenom |
|
|
} |
|
|
// openfoncier : adresse (80/ 26+38 -> substr sur 2 zones) - cp (5/5 OK) - ville (30/36 -> OK) |
|
|
// *numvoiemo*|*typvoiemo*|libvoiemo|lieuditmo(+)|communemo|codposmo|*bpmo*|*cedexmo*|*paysmo*|*divetermo| |
|
|
$transfert.= "|||".maj(substr($row['demandeur_adresse'],0,26))."|". |
|
|
maj(substr($row['demandeur_adresse'],26,38))."|"; |
|
|
$transfert.= maj($row['demandeur_ville'])."|".$row['demandeur_cp']."|||||"; |
|
|
// sitadel : melmo| |
|
|
$transfert.= $row['demandeur_email']."|"; |
|
|
// sitadel: suivi |
|
|
if($row['delegataire']=='Oui'){ |
|
|
$transfert.= "1"; |
|
|
}else{ |
|
|
$transfert.= "0"; |
|
133 |
} |
} |
134 |
//------------------- |
|
135 |
$transfert.="\n"; |
// transfert |
136 |
}// fin while transfert |
$transfert =""; |
137 |
//$res -> free (); |
if($row['types']=='Transfert' |
138 |
if($DEBUG==1){ |
and $row['date_depot'] >= $datedebut |
139 |
$temp=explode("\n",$transfert); |
and $row['date_depot']<=$datefin){ |
140 |
$temp1=sizeof($temp)-1; |
$transfert.=$g->entete("TRANSFERT",$departement,$commune,$pf_departement); |
141 |
for($g=0;$g<$temp1;$g++){ |
$transfert.=$g->etatcivil(); |
142 |
$temp2=array(); |
$transfert.=$g->adresse(); |
143 |
$temp2 = explode("|",$temp[$g]); |
$transfert.=$g->meltel($row['types']); |
144 |
$v=$g+1; |
$transfert.="\n"; |
|
echo "<br><br> DAT : ".$v." ============== <br>"; |
|
|
for($k=0;$k<sizeof($temp2);$k++){ |
|
|
$t=$k+1; |
|
|
echo $t." : ".$temp2[$k]."<br>"; |
|
|
} |
|
145 |
} |
} |
146 |
} // debug |
|
147 |
|
|
148 |
// ================================================================================== |
//decision |
149 |
// modificatif MODIFICATIF |
// type different de modificatif |
150 |
// ================================================================================== |
$decision=""; |
151 |
// element declancheur : modificatif |
if($row['types']!='Modificatif' |
152 |
// zone types= Modificatif |
and $row['types']!='Transfert' |
153 |
// suivant date-depot et dcision du modificatif |
and (($row['date_depot'] >= $datedebut and $row['date_depot']<=$datefin) |
154 |
$sql= "select annee, dossier.dossier, dossier.nature, |
or ($row['date_decision'] >= $datedebut and $row['date_decision']<=$datefin))){ |
155 |
dossier.date_decision, avis.sitadel as avis_sitadel, avis.sitadel_motif as avis_sitadel_motif, |
$avis_sitadel=""; |
156 |
dossier.terrain_numero,dossier.terrain_adresse,dossier.terrain_cp,dossier.terrain_ville, |
$avis_sitadel_motif=""; |
157 |
dossier.parcelle, |
// enregistrement decision dans tous les cas |
158 |
dossier.terrain_surface, |
$decision.=$g->entete("DECISION",$departement,$commune,$pf_departement); |
159 |
travaux.codelascot as lascot, |
//if ($row['date_decision']== '0000-00-00' |
160 |
date_achevement, shon, hauteur, piece_nombre, logement_nombre, batiment_nombre |
// or !isset($row['date_decision'])){ |
161 |
from dossier left join avis on avis.avis= dossier.avis |
//if(isset($row['date_decision']) and $row['date_decision']!=""){ |
162 |
left join travaux on dossier.travaux=travaux.travaux"; |
// avis_sitadel et avis_sitadel_motif |
163 |
$sql.= " where (date_depot>='".substr($_POST["datedebut"],6,4). |
if($row['avis']!=''){ |
164 |
"-".substr($_POST["datedebut"],3,2)."-". |
$avis_sitadel = "0"; |
165 |
substr($_POST["datedebut"],0,2)."'"; |
$avis_sitadel_motif="0" ; |
166 |
$sql.= " AND date_depot<='".substr($_POST["datefin"],6,4). |
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='". |
167 |
"-".substr($_POST["datefin"],3,2)."-". |
$row['avis']."'"; |
168 |
substr($_POST["datefin"],0,2)."'"; |
$res1 = $f->db -> query ($sql); |
169 |
$sql.= " AND types= 'Modificatif')"; |
$f->isDatabaseError($res1); |
170 |
$sql.= " or (date_decision>='".substr($_POST["datedebut"],6,4). |
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
171 |
"-".substr($_POST["datedebut"],3,2)."-". |
$avis_sitadel = $row1['sitadel']; |
172 |
substr($_POST["datedebut"],0,2)."'"; |
$avis_sitadel_motif = $row1['sitadel_motif']; |
173 |
$sql.= " AND date_decision<='".substr($_POST["datefin"],6,4). |
} |
174 |
"-".substr($_POST["datefin"],3,2)."-". |
$decision.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure); |
175 |
substr($_POST["datefin"],0,2)."'"; |
}else{ |
176 |
$sql.= " AND types= 'Modificatif')"; |
$decision.= $g->decision_groupe1("0","",$structure); // pas d avis |
177 |
echo "<BR><br><font style='background-color:#ffffff;border : 1px solid #000000'>MODIFICATIF</font>".$sql; |
//$decision.= "***".$t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 |
|
// ou dat ??? |
|
|
$res = $f->db -> query ($sql); |
|
|
$f->isDatabaseError($res); |
|
|
$modificatif=""; |
|
|
// aout 2010 ------------------------------------------------------------------- |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
$nombreenregistrement++; |
|
|
$cpt_modificatif++; |
|
|
// sitadel : mouv|typpermis|equivalence|dep|commune|andepnumpc|indmod |
|
|
// typepermis = dossier.nature |
|
|
// annee = dossier.annee |
|
|
// andepnumpc|indmod = substr dossier.dossier |
|
|
$modificatif.="MODIFICATIF|".$row['nature']."||".$departement."|".$commune."|".$row['annee']."|". |
|
|
substr($row['dossier'],4,5)."|".substr($row['dossier'],9,2)."|"; |
|
|
// sitadel : collectivite|natdec|datredec|motifannul difference avec decision -> *** dateredec a la place de datedec |
|
|
$modificatif.= '1|'; // au nom de la commune |
|
|
// zone supplementaire dans avis |
|
|
// ALTER TABLE `avis` ADD `sitadel_motif` VARCHAR( 1 ) NOT NULL ; |
|
|
// 0 � 8 |
|
|
$modificatif.= $row['avis_sitadel']."|"; |
|
|
// date au format francais 8 caracteres |
|
|
if ($row['date_decision']!= '0000-00-00' and isset($row['date_decision'])) |
|
|
$modificatif.= substr($row['date_decision'],8,2).''.substr($row['date_decision'],5,2)."".substr($row['date_decision'],0,4)."|"; |
|
|
else |
|
|
$modificatif.= "|"; |
|
|
// Motif d annulation |
|
|
// zone supplementaire dans avis; |
|
|
// ALTER TABLE `avis` ADD `sitadel_motif` VARCHAR( 1 ) NOT NULL ; |
|
|
$modificatif.= $row['avis_sitadel_motif'].""; |
|
|
if(isset($row['avis_sitadel'])) |
|
|
$avis = $row['avis_sitadel']; |
|
|
else |
|
|
$avis =0; |
|
|
// ============================================================= |
|
|
// GROUPE 2 si decision favorable, expresse ou tacite GROUPE 2 |
|
|
// ============================================================= |
|
|
if($avis==2 or $avis==4 or $avis==5 or $avis==0){// decision positive ou encours |
|
|
// sitadel : |numvoiete|*typvoiete*|libvoiete|lieudite|communete|codposte|*bpte*|*cedexte*| |
|
|
$modificatif.= "|".substr($row['terrain_numero'],0,4)."|"; // typevoie |
|
|
$modificatif.= "|".maj(substr($row['terrain_adresse'],0,26))."|". |
|
|
maj(substr($row['terrain_adresse'],26,38))."|"; |
|
|
$modificatif.= maj($row['terrain_ville'])."|"; |
|
|
$modificatif.= $row['terrain_cp']."|"; |
|
|
$modificatif.= "||"; |
|
|
// sitadel : scadastre1|ncadastre1|*scadastre2*|*ncadastre2*|*scadastre3*|*ncadastre3*| |
|
|
$modificatif.= substr($row['parcelle'],0,2)."|"; |
|
|
$modificatif.= substr($row['parcelle'],2,4)."|||||"; |
|
|
//terrain/libmotif/natrav/annexe/nvmax |
|
|
$modificatif.= floor($row['terrain_surface'])."|"; |
|
|
//libmotif |
|
|
$modificatif.= '|'; |
|
|
//natrav |
|
|
$nattrav="0000"; |
|
|
if($row['lascot']=='2') $nattrav="1000"; |
|
|
if($row['lascot']=='3') $nattrav="0100"; |
|
|
$modificatif.= $nattrav."|"; |
|
|
//annexe |
|
|
$modificatif.= "00000|"; |
|
|
//nvmax |
|
|
$modificatif.= "|"; |
|
|
// shon avant travaux shionnnant1 a 9 -> non renseigne |
|
|
$modificatif.= "|||||||||"; |
|
|
//shondem1 � 9| shonanttr1 � 9| shonprojtr 1 � 9|shoncr1 a 9 |shon2cr1 a 9 |
|
|
// table destination |
|
|
$sql1="select destination, shon from destination_shon where dossier = '". $row['dossier']."'"; |
|
|
// faire une boucle et remplir |
|
|
//************************************************************** |
|
|
$res1 = $f->db -> query ($sql1); |
|
|
$f->isDatabaseError($res); |
|
|
// |
|
|
$tmpPD = array(); // shon existante demolie |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmpPD[$i]=''; |
|
|
} |
|
|
// |
|
|
$tmplascot4 = array(); // shon changement de destination |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmplascot4[$i]=''; |
|
|
} |
|
|
// |
|
|
$tmplascot1 = array(); // shon nouvellement construite |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmplascot1[$i]=''; |
|
|
} |
|
|
// |
|
|
$tmplascot2 = array(); // shon cree par transformation |
|
|
for($i=0;$i<=9;$i++) |
|
|
{ |
|
|
$tmplascot2[$i]=''; |
|
|
} |
|
|
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
|
|
// shonprojtr1 a 9 / shoncr1 a 9 / |
|
|
if($row['nature']== 'PD') { |
|
|
$tmpPD[$row1['destination']] = $row1['shon']; // shon existante demolie -> a remplir |
|
|
} |
|
|
if($row['lascot']== '4') { |
|
|
$tmplascot4[$row1['destination']] = $row1['shon'];// shon changement de destination -> a remplir |
|
|
} |
|
|
if($row['lascot']== '1'){ |
|
|
$tmplascot1[$row1['destination']] = $row1['shon'];// shon nouvellement construite -> a remplir |
|
178 |
} |
} |
179 |
if($row['lascot']== '2') { |
// si la decision est favorable, envoi des informations statistiques |
180 |
$tmplascot2[$row1['destination']] = $row1['shon'];// shon cree par transformation -> a remplir |
if($avis_sitadel==2 or $avis_sitadel==4 |
181 |
|
or $avis_sitadel==5){ |
182 |
|
// si decision favorable, expresse ou tacite GROUPE 2 |
183 |
|
$decision.= $g->terrain(); |
184 |
|
$decision.= $g->amenagement(); |
185 |
|
if($row['travaux']!=''){ |
186 |
|
$sql= "select codelascot,libelle |
187 |
|
from ".DB_PREFIXE."travaux where travaux=".$row['travaux']; |
188 |
|
$res2 = $f->db -> query ($sql); |
189 |
|
$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)){ |
195 |
|
$travaux = $row2['libelle']." "; // *** |
196 |
|
$lascot = $row2['codelascot']; |
197 |
|
} |
198 |
|
$travaux.=" ".$temp; |
199 |
|
$decision.= $g->travaux($travaux,$lascot, $row['types']); |
200 |
|
} |
201 |
|
$sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '". |
202 |
|
$row['dossier']."' order by destination"; |
203 |
|
$res3 = $f->db -> query ($sql3); |
204 |
|
$f->isDatabaseError($res3); |
205 |
|
$temp = array(); |
206 |
|
while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){ |
207 |
|
$shonant[$row3['destination']]=$row3["shon_anterieure"]; |
208 |
|
$shondem[$row3['destination']]=$row3["shon_demolie"]; |
209 |
|
$shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"]; |
210 |
|
$shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"]; |
211 |
|
$shoncr1[$row3['destination']]=$row3["shon_nouvelle"]; |
212 |
|
$shoncr2[$row3['destination']]=$row3["shon_shob_transformee"]; |
213 |
|
} |
214 |
|
$decision.= $g->destination($shonant); |
215 |
|
$decision.= $g->destination($shondem); |
216 |
|
$decision.= $g->destination($shonanttr); |
217 |
|
$decision.= $g->destination($shonprojtr); |
218 |
|
$decision.= $g->destination($shoncr1); |
219 |
|
$decision.= $g->destination($shoncr2); |
220 |
|
|
221 |
|
$decision.= $g->descriptif($row['types']); |
222 |
|
}else // decision defavorable ou pas de decision |
223 |
|
$decision.= $t10.$t10.$t10.$t10.$t10.$t10.$t10.$t10."|||"; //83 | + 12 | = 95 | pour 96 zones |
224 |
|
$decision.="\n"; |
225 |
|
} |
226 |
|
|
227 |
|
// modificatif |
228 |
|
$modificatif=''; |
229 |
|
if($row['types']=='Modificatif' |
230 |
|
and $row['date_depot'] >= $datedebut |
231 |
|
and $row['date_depot']<=$datefin){ |
232 |
|
$modificatif.=$g->entete("MODIFICATIF",$departement,$commune,$pf_departement); |
233 |
|
if(isset($row['date_decision']) or $row['date_decision']==""){ |
234 |
|
// avis_sitadel et avis_sitadel_motif |
235 |
|
if($row['avis']!=''){ |
236 |
|
$avis_sitadel = 0; |
237 |
|
$avis_sitadel_motif=0 ; |
238 |
|
$sql="select sitadel, sitadel_motif from ".DB_PREFIXE."avis where avis ='". |
239 |
|
$row['avis']."'"; |
240 |
|
$res1 = $f->db -> query ($sql); |
241 |
|
$f->isDatabaseError($res1); |
242 |
|
while ($row1=& $res1->fetchRow(DB_FETCHMODE_ASSOC)){ |
243 |
|
$avis_sitadel = $row1['sitadel']; |
244 |
|
$avis_sitadel_motif = $row1['sitadel_motif']; |
245 |
|
} |
246 |
|
$modificatif.= $g->decision_groupe1($avis_sitadel,$avis_sitadel_motif,$structure); |
247 |
} |
} |
248 |
} |
// si la decision est favorable, envoi des informations statistiques |
249 |
// shon existante demolie -> a remplir |
if($avis_sitadel==2 or $avis_sitadel==4 |
250 |
for($i=1;$i<=9;$i++) |
or $avis_sitadel==5){ |
251 |
{ |
// si decision favorable, expresse ou tacite GROUPE 2 |
252 |
$modificatif.=$tmpPD[$i].'|'; |
$modificatif.=$g->adresse_terrain(); //*** |
253 |
} |
$modificatif.=$g->parcelle(); //*** |
254 |
// |
$modificatif.=$g->terrain(); //*** |
255 |
$modificatif.= "|||||||||";// shon supprimmee par changement de destination -> non renseigne |
// enlever les RC |
256 |
// |
$temp=$row['description']; |
257 |
//$row['lascot']== '4' shon changement de destination |
$temp = str_replace( chr(10), " ", $temp); |
258 |
for($i=1;$i<=9;$i++) |
$temp = str_replace( chr(13), " ", $temp); |
259 |
{ |
if($row['travaux']!=''){ |
260 |
$modificatif.=$tmplascot4[$i].'|'; |
$sql= "select codelascot,libelle |
261 |
} |
from ".DB_PREFIXE."travaux where travaux=".$row['travaux']; |
262 |
//shon nouvellement construite |
$res2 = $f->db -> query ($sql); |
263 |
for($i=1;$i<=9;$i++) |
$f->isDatabaseError($res2); |
264 |
{ |
while ($row2=& $res2->fetchRow(DB_FETCHMODE_ASSOC)){ |
265 |
$modificatif.=$tmplascot1[$i].'|'; |
$travaux = $row2['libelle']." ".$row['description']; // ***; |
266 |
} |
$lascot = $row2['codelascot']; |
267 |
//shon cree par transformation |
} |
268 |
for($i=1;$i<=9;$i++) |
$travaux.=" ".$temp; |
269 |
{ |
$modificatif.= $g->travaux($travaux,$lascot, $row['types']); |
270 |
$modificatif.=$tmplascot2[$i].'|'; |
} |
271 |
} |
$sql3="select * from ".DB_PREFIXE."destination_shon where dossier = '". |
272 |
//************************************************************** |
$row['dossier']."' order by destination"; |
273 |
// cpublic : non renseignee N par defaut |
$res3 = $f->db -> query ($sql3); |
274 |
// O/N transport/enseignement/sante/social/special/culture |
$f->isDatabaseError($res3); |
275 |
$modificatif.= "000000"; |
$temp = array(); |
276 |
// nbmaison : nombre de maison |
while ($row3=& $res3->fetchRow(DB_FETCHMODE_ASSOC)){ |
277 |
$modificatif.= "|".$row['batiment_nombre']; |
$shonant[$row3['destination']]=$row3["shon_anterieure"]; |
278 |
// nblogcoll : nombre de logement collectif |
$shondem[$row3['destination']]=$row3["shon_demolie"]; |
279 |
$modificatif.= "|".$row['logement_nombre']; |
$shonanttr[$row3['destination']]=$row3["shon_anterieure_supprimee"]; |
280 |
// nbtotlog : nombre de logement total |
$shonprojtr[$row3['destination']]=$row3["shon_nouvelle_transformee"]; |
281 |
$modificatif.= "|".$row['logement_nombre']; |
$shoncr1[$row3['destination']]=$row3["shon_nouvelle"]; |
282 |
// natres : nature des residences |
$shoncr2[$row3['destination']]=$row3["shon_shob_transformee"]; |
283 |
// O/N 1=ages, 2=etudiant, 3=tourisme, 4=hotel, 5=social, 6= handicap, 7=autres |
} |
284 |
$modificatif.= "|0000000"; |
$modificatif.= $g->destination($shonant); |
285 |
// libres= si autre residence (long max 1000 c) |
$modificatif.= $g->destination($shondem); |
286 |
$modificatif.= "|"; |
$modificatif.= $g->destination($shonanttr); |
287 |
// util : O/N personnel, principale, secondaire, vente, location |
$modificatif.= $g->destination($shonprojtr); |
288 |
$modificatif.= "|00000"; |
$modificatif.= $g->destination($shoncr1); |
289 |
//chambres |
$modificatif.= $g->destination($shoncr2); |
290 |
$modificatif.= "|"; |
|
291 |
//finis (nb logement locatif sociaux)/finaa(nb logementfinancement aid�) |
$modificatif.= $g->descriptif($row['types']); |
292 |
//finptz (nb logement pret taux 0)/finaf (nb logement autrement)/ |
$modificatif.="\n"; |
293 |
//piec1 � 6 (nb logement 1 a 6pieces ) |
} |
294 |
$modificatif.= "||||||||||"; |
} |
295 |
}//fin GROUPE 2 |
} |
|
$modificatif.="\n"; |
|
|
}// fin while modificatif |
|
296 |
|
|
297 |
if($DEBUG==1){ |
// suivi DOC |
298 |
$temp=explode("\n",$modificatif); |
$suivi1=""; |
299 |
$temp1=sizeof($temp)-1; |
if($row['date_chantier'] >= $datedebut and $row['date_chantier']<=$datefin){ |
300 |
for($g=0;$g<$temp1;$g++){ |
$suivi1.=$g->entete("SUIVI",$departement,$commune,$pf_departement); |
301 |
$temp2=array(); |
$suivi1.=$g->chantier(); |
302 |
$temp2 = explode("|",$temp[$g]); |
$suivi1.="\n"; |
303 |
$v=$g+1; |
} |
304 |
echo "<br><br> DAT : ".$v." ============== <br>"; |
// suivi DAT |
305 |
for($k=0;$k<sizeof($temp2);$k++){ |
$suivi2=""; |
306 |
$t=$k+1; |
if($row['date_achevement'] >= $datedebut and $row['date_achevement']<=$datefin){ |
307 |
echo $t." : ".$temp2[$k]."<br>"; |
$suivi2.=$g->entete("SUIVI",$departement,$commune,$pf_departement); |
308 |
} |
$suivi2.=$g->achevement(); |
309 |
|
$suivi2.="\n"; |
310 |
} |
} |
311 |
} // fin debug |
// export |
312 |
|
$export.=$depot.$decision.$transfert.$modificatif.$suivi1.$suivi2; |
313 |
|
} // fin while |
314 |
// *************************************** |
// *************************************** |
315 |
// entete de l enregistrement page 8 et 9 |
// entete de l enregistrement page 8 et 9 |
316 |
// *************************************** |
// *************************************** |
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 |
$tmpenr=""; |
if(CHARSET=='UTF8'){ |
325 |
$tmpenr=$depot.$decision.$suivi1.$suivi2.$transfert.$modificatif; |
$export=utf8_decode($export); |
|
if($flag_utf8_decode==1){ |
|
|
$tmpenr=utf8_decode($tmpenr); |
|
|
}else{ |
|
|
if($flag_utf8_encode==1){ |
|
|
$tmpenr=utf8_encode($tmpenr); |
|
|
} |
|
326 |
} |
} |
327 |
$nbenr = explode("\n",$tmpenr); |
// nombreenrgistremment et longueurenregistrement |
328 |
|
$nbenr = explode("\n",$export); |
329 |
$tmp=array(); |
$tmp=array(); |
330 |
$cpt=0; |
$cpt=0; |
331 |
for($i=0;$i<sizeof($nbenr);$i++){ |
for($i=0;$i<sizeof($nbenr);$i++){ |
332 |
// mb_strlen( variable,encoding) PHP 4 >= 4.0.6, PHP 5 |
// mb_strlen( variable,encoding) PHP 4 >= 4.0.6, PHP 5 |
333 |
// Le param�tre encoding est l'encodage des caract�res. |
// Le param�tre encoding est l'encodage des caract�res. |
334 |
// S'il est omis, l'encodage de caractres interne sera utilis�. |
// S'il est omis, l'encodage de caracteres interne sera utilis�. |
335 |
$tmp[$i] = strlen($nbenr[$i]); |
$tmp[$i] = strlen($nbenr[$i]); |
336 |
//echo strlen($nbenr[$i])." ".$nbenr[$i]."<br>"; |
//echo strlen($nbenr[$i])." ".$nbenr[$i]."<br>"; |
337 |
$cpt++; |
$cpt++; |
338 |
} |
} |
339 |
$longueurenregistrement=max($tmp); |
$longueurenregistrement=max($tmp); |
340 |
//tri tableau |
$nombreenregistrement=$cpt; // + entete |
|
array_multisort($tmp,SORT_DESC); |
|
|
//exact cpt-1+1 (cpt -1( tableau 0 � n ) +1(enregistrement entete) ) |
|
|
echo "<BR><br>Nombre Total Enregistrement : ".$cpt." <-> ".$nombreenregistrement."<br><br>"; |
|
|
echo "Detail :<BR> - DEPOT : ".$cpt_depot."<br>"; |
|
|
echo " - DECISION vide suite DEPOT: ".$cpt_decisionsuivantdepot."<br>"; |
|
|
echo " - DECISION : ".$cpt_decision."<br>"; |
|
|
echo " - SUIVI 1 : ".$cpt_suivi1."<br>"; |
|
|
echo " - SUIVI 2 : ".$cpt_suivi2."<br>"; |
|
|
echo " - TRANSFERT : ".$cpt_transfert."<br>"; |
|
|
echo " - MODIFICATIF : ".$cpt_modificatif."<br>"; |
|
|
echo "TOTAL : ".($cpt_depot+$cpt_decisionsuivantdepot+$cpt_decision+$cpt_suivi1+$cpt_suivi2+$cpt_transfert+$cpt_modificatif)." + 1 enregistrement(entete)"; |
|
|
echo "<br><br>Longueur Enregistrement le plus long : ".max($tmp)." <-> ".$tmp[0]; |
|
|
|
|
341 |
// Date de modification |
// Date de modification |
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 |
344 |
|
$version = substr($version,0,8); |
345 |
|
$entete.= $longueurenregistrement."|".$datemodification."|". |
346 |
$entete.= $longueurenregistrement."|".$datemodification."|".$nombreenregistrement."|openFoncier|".$versionapplicatif."\n"; |
$nombreenregistrement."|openFoncier|".$version."\n"; |
347 |
$export=$entete.$depot.$decision.$suivi1.$suivi2.$transfert.$modificatif; |
$export=$entete.$export; |
348 |
|
// $str = htmlentities($str, ENT_QUOTES); |
|
if($flag_utf8_decode==1){ |
|
|
$export=utf8_decode($export); |
|
|
}else{ |
|
|
if($flag_utf8_encode==1){ |
|
|
$export=utf8_encode($export); |
|
|
} |
|
|
} |
|
|
//$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 "<table class='dossier' width='95%'>"; |
echo "<br>"._("Fichier")." ".$fichier." "._("sauvegarde")."<br /><br /><br />"; |
|
echo "<tr class='dossier'><td>"; |
|
|
echo "<br>Fichier ".$fichier." sauvegarde<br><br><br>"; |
|
|
$affiche=""; |
|
|
if($DEBUG==1) |
|
|
$affiche= str_replace("\n","<br>",$export); |
|
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 |
echo $affiche; |
if($DEBUG==1){ |
361 |
//echo"<img src='../img/retour.png' align='top' border='0'>"; |
$affiche=""; |
362 |
// echo "</a></center>"; |
$affiche= str_replace("\n","<br>",$export); |
363 |
echo "</td></tr></table>"; |
echo $affiche; |
364 |
*/ |
} |
365 |
}else |
}else // correct = false |
366 |
echo "remplissez les 2 dates"; |
echo _("remplissez les 2 dates"); |
367 |
}//validation |
}//validation |
|
?> |
|
368 |
|
?> |