1 |
fraynaud |
88 |
<?php |
2 |
|
|
// $Id: dossier_modificatif.php,v 1.21 2010-11-08 15:30:15 fraynaud Exp $ |
3 |
|
|
/** |
4 |
|
|
* Fichiers requis |
5 |
|
|
*/ |
6 |
|
|
|
7 |
|
|
require_once "../obj/utils.class.php"; |
8 |
|
|
/** |
9 |
|
|
* Classe utils () |
10 |
|
|
*/ |
11 |
|
|
$f = new utils(NULL, "traitement", _("dossier modicatif"), "ico_traitement.png", "traitement modificatif"); |
12 |
|
|
$f->addHTMLHeadJs(array("../js/script.js")); |
13 |
|
|
// Paramétrage =============================================================== |
14 |
|
|
$DEBUG=0; |
15 |
|
|
$msg=""; |
16 |
|
|
// GET |
17 |
|
|
if (isset ($_GET['validation'])){ |
18 |
|
|
$validation=$_GET['validation']; |
19 |
|
|
}else{ |
20 |
|
|
$validation=0; |
21 |
|
|
} |
22 |
|
|
if (isset ($_GET['idx'])){ |
23 |
|
|
$idx=$_GET['idx']; |
24 |
|
|
}else{ |
25 |
|
|
$idx=0; |
26 |
|
|
} |
27 |
|
|
// ============================================================================= |
28 |
|
|
// validation = 0 |
29 |
|
|
// ============================================================================= |
30 |
|
|
if($validation==0){ |
31 |
|
|
$validation=1; |
32 |
|
|
echo "<br>"._("dossier")." ".$idx."<br></td></tr>"; |
33 |
|
|
echo "<form method=\"POST\" action=\"dossier_modificatif.php?validation=".$validation. |
34 |
|
|
"&idx=".$idx."\" name=f1>"; |
35 |
|
|
// date du modificatif |
36 |
|
|
echo _("Date")." "._("modicatif"); |
37 |
|
|
echo "<input type='text' name='date_modificatif' id=\"datedebut\" value=\""; |
38 |
|
|
echo "\" size=\"15\" class=\"champFormulaire datepicker\" onchange='fdate(this)' onkeyup=\"\" onclick=\"\" />"; |
39 |
|
|
echo "<br>"._("module")." : "; |
40 |
|
|
echo "<td><select name='module' size=1>"; |
41 |
|
|
echo "<option value='modificatif'>"._("modificatif")."</option>"; |
42 |
|
|
echo "<option value='transfert'>"._("transfert")."</option>"; |
43 |
|
|
echo "</select>"; |
44 |
fraynaud |
116 |
echo "<br><br><input type='submit' value='"._("transfert")." / ". |
45 |
fraynaud |
88 |
_("modificatif")." "._("dossier")." ".$idx."'>"; |
46 |
|
|
}else { // ===================== mise a jour ================================= |
47 |
|
|
// debut de transaction |
48 |
|
|
$f -> db->autoCommit(false); |
49 |
|
|
// traitement des post_ |
50 |
|
|
$correct=true; |
51 |
|
|
if (isset($_POST['date_modificatif'])){ |
52 |
|
|
$date_modificatif= $_POST['date_modificatif']; |
53 |
|
|
}else{ |
54 |
|
|
$date_modificatif =""; |
55 |
|
|
$correct=false; |
56 |
|
|
$msg=$msg._("date_modificatif")." "._("vide"); // a verifier |
57 |
|
|
} |
58 |
|
|
if (isset($_POST['module'])){ |
59 |
|
|
$module= $_POST['module']; |
60 |
|
|
}else{ |
61 |
|
|
$module ="modificatif"; |
62 |
|
|
} |
63 |
|
|
|
64 |
|
|
if ($date_modificatif<>""){ |
65 |
|
|
if ($formatDate=="AAAA-MM-JJ"){ |
66 |
|
|
$date = explode("/", $date_modificatif); |
67 |
|
|
// controle de date |
68 |
|
|
if (sizeof($date) == 3 and (checkdate($date[1],$date[0],$date[2]))) { |
69 |
|
|
$date_modificatif = $date[2]."-".$date[1]."-".$date[0]; |
70 |
|
|
}else{ |
71 |
|
|
$msg= $msg."<br>".$date_modificatif." "._("pas_date"); |
72 |
|
|
$correct=false; |
73 |
|
|
} |
74 |
|
|
} |
75 |
|
|
if ($formatDate=="JJ/MM/AAAA"){ |
76 |
|
|
$date = explode("/", $date_modificatif); |
77 |
|
|
// controle de date |
78 |
|
|
if (sizeof($date) == 3 and checkdate($date[1],$date[0],$date[2])){ |
79 |
|
|
$datemodificatif = $date[0]."/".$date[1]."/".$date[2]; |
80 |
|
|
}else{ |
81 |
|
|
$msg= $msg."<br>".$date_modificatif." "._("pas_date"); |
82 |
|
|
$correct=false; |
83 |
|
|
} |
84 |
|
|
} |
85 |
|
|
}else{ |
86 |
|
|
$correct=false; |
87 |
|
|
$msg= $msg."<br>"._("date_modificatif")." "._("obligatoire"); |
88 |
|
|
} |
89 |
|
|
echo "<font class='parametre'> ".$module." </font><br>"; |
90 |
|
|
// traitement |
91 |
|
|
if ($correct==true){ |
92 |
|
|
$valF=array(); |
93 |
|
|
$sql= "select * from dossier where dossier ='".$idx."'"; |
94 |
|
|
$res=$f -> db->query($sql); |
95 |
|
|
$f->isDatabaseError($res); |
96 |
|
|
while ($row=& $res->fetchRow(DB_FETCHMODE_ASSOC)){ |
97 |
|
|
// nouveau dossier modificatif ou transfert |
98 |
|
|
$valF=array(); |
99 |
|
|
// nature |
100 |
|
|
$valF['nature']=$row['nature']; |
101 |
|
|
$valF['annee']=$row['annee']; |
102 |
|
|
$valF['instructeur']=$row['instructeur']; |
103 |
|
|
|
104 |
|
|
// caracteristique |
105 |
|
|
If($row['architecte']!='' or $row['architecte']!= null) |
106 |
|
|
$valF['architecte']=$row['architecte']; |
107 |
|
|
$valF['travaux']=$row['travaux']; |
108 |
|
|
// terrain |
109 |
|
|
$valF['terrain_numero']=$row['terrain_numero']; |
110 |
|
|
$valF['terrain_numero_complement']=$row['terrain_numero_complement']; |
111 |
|
|
$valF['terrain_adresse']=$row['terrain_adresse']; |
112 |
|
|
$valF['terrain_adresse_complement']=$row['terrain_adresse_complement']; |
113 |
|
|
$valF['terrain_cp']=$row['terrain_cp']; |
114 |
|
|
$valF['terrain_ville']=$row['terrain_ville']; |
115 |
|
|
$valF['terrain_surface']=$row['terrain_surface']; |
116 |
|
|
$valF['terrain_surface_calcul']=$row['terrain_surface_calcul']; |
117 |
|
|
$valF['rivoli']=$row['rivoli']; |
118 |
|
|
$valF['parcelle']=$row['parcelle']; |
119 |
|
|
// divers |
120 |
|
|
$valF['batiment_nombre']=$row['batiment_nombre']; |
121 |
|
|
$valF['logement_nombre']=$row['logement_nombre']; |
122 |
|
|
$valF['lot']=$row['lot']; |
123 |
|
|
$valF['hauteur']=$row['hauteur']; |
124 |
|
|
$valF['piece_nombre']=$row['piece_nombre']; |
125 |
|
|
$valF['shon']=$row['shon']; |
126 |
|
|
$valF['shon_calcul']=$row['shon_calcul']; |
127 |
|
|
$valF['shob']=$row['shob']; |
128 |
|
|
// |
129 |
|
|
$valF['objet_dossier']=$row['objet_dossier']; |
130 |
|
|
$valF['amenagement']=$row['amenagement']; |
131 |
|
|
// TEMP |
132 |
|
|
$valF['temp1']=$row['temp1']; |
133 |
|
|
$valF['temp2']=$row['temp2']; |
134 |
|
|
$valF['temp3']=$row['temp3']; |
135 |
|
|
$valF['temp4']=$row['temp4']; |
136 |
|
|
$valF['temp5']=$row['temp5']; |
137 |
|
|
if($row['geom']!='') |
138 |
|
|
$valF['geom']=$row['geom']; |
139 |
|
|
// *** MODIF DEMANDEE LE 08/11/2010 |
140 |
|
|
$valF['date_depot']=$date_modificatif; |
141 |
|
|
$valF['date_demande']=$date_modificatif; |
142 |
|
|
$valF['etat']='initialiser'; |
143 |
|
|
|
144 |
|
|
if($module=="transfert"){ // TRANSFERT sans instruction et sans nom |
145 |
|
|
$valF['types']="Transfert"; |
146 |
|
|
$valF['demandeur_nom']="*transfert*"; |
147 |
|
|
// TRANSFERT INSTRUCTION SUPPRIMEE |
148 |
|
|
}else{ // modificatif nouveau nom et pas d instruction |
149 |
|
|
// valeur fixe |
150 |
|
|
// demandeur |
151 |
|
|
$valF['demandeur_civilite']=$row['demandeur_civilite']; |
152 |
|
|
$valF['demandeur_nom']=$row['demandeur_nom']; |
153 |
|
|
$valF['demandeur_societe']=$row['demandeur_societe']; |
154 |
|
|
$valF['demandeur_adresse']=$row['demandeur_adresse']; |
155 |
|
|
$valF['demandeur_cp']=$row['demandeur_cp']; |
156 |
|
|
$valF['demandeur_ville']=$row['demandeur_ville']; |
157 |
|
|
$valF['demandeur_pays']=$row['demandeur_pays']; |
158 |
|
|
$valF['demandeur_telephone']=$row['demandeur_telephone']; |
159 |
|
|
$valF['demandeur_email']=$row['demandeur_email']; |
160 |
|
|
$valF['demandeur_categorie']=$row['demandeur_categorie']; |
161 |
|
|
// delegataire |
162 |
|
|
$valF['delegataire_civilite'] = $row['delegataire_civilite']; |
163 |
|
|
$valF['delegataire_nom'] = $row['delegataire_nom']; |
164 |
|
|
$valF['delegataire_societe'] = $row['delegataire_societe']; |
165 |
|
|
$valF['delegataire_adresse'] = $row['delegataire_adresse']; |
166 |
|
|
$valF['delegataire_cp'] = $row['delegataire_cp']; |
167 |
|
|
$valF['delegataire_ville'] = $row['delegataire_ville']; |
168 |
|
|
$valF['delegataire_email'] = $row['delegataire_email']; |
169 |
|
|
$valF['delegataire_pays'] = $row['delegataire_pays']; |
170 |
|
|
$valF['delegataire_telephone'] = $row['delegataire_telephone']; |
171 |
|
|
$valF['delegataire'] = $row['delegataire']; |
172 |
|
|
//$valF['etat']='initialiser'; |
173 |
|
|
$valF['types']="Modificatif"; |
174 |
|
|
//$valF['date_depot']=$date_modificatif; |
175 |
|
|
//$valF['date_demande']=$date_modificatif; |
176 |
|
|
} |
177 |
|
|
} // fin while |
178 |
|
|
|
179 |
|
|
// gestion numero modificatif ou transfert 00 à 99 |
180 |
|
|
if(strlen($idx)>9){ |
181 |
|
|
$temp = substr($idx,strlen($idx)-1,2); |
182 |
|
|
$temp=intval($temp) + 1; |
183 |
|
|
$temp=str_pad($temp,2,"0", STR_PAD_LEFT); |
184 |
|
|
$valF['dossier']=substr($idx,0,strlen($idx)-2).$temp; |
185 |
|
|
}else |
186 |
|
|
$valF['dossier']=$idx."01"; |
187 |
|
|
// insertion du dossier modificatif |
188 |
|
|
// protection cle secondaire numerique |
189 |
|
|
if(!is_numeric($val['instructeur'])) $valF['instructeur']= null; |
190 |
|
|
if(!is_numeric($val['architecte'])) $valF['architecte']= null; |
191 |
|
|
if(!is_numeric($val['travaux'])) $valF['travaux']= null; |
192 |
|
|
if(!is_numeric($val['demandeur_categorie'])) $valF['demandeur_categorie']= null; |
193 |
|
|
// protection des numeriques |
194 |
|
|
if(!is_numeric($val['delai'])) unset ($valF['delai']); |
195 |
|
|
if(!is_numeric($val['terrain_surface'])) unset ($valF['terrain_surface']); |
196 |
|
|
if(!is_numeric($val['batiment_nombre'])) unset ($valF['batiment_nombre']); |
197 |
|
|
if(!is_numeric($val['logement_nombre'])) unset ($valF['logement_nombre']); |
198 |
|
|
if(!is_numeric($val['shon'])) unset ($valF['shon']); |
199 |
|
|
if(!is_numeric($val['shob'])) unset ($valF['shob']); |
200 |
|
|
if(!is_numeric($val['lot'])) unset ($valF['lot']); |
201 |
|
|
if(!is_numeric($val['hauteur'])) unset ($valF['hauteur']); |
202 |
|
|
if(!is_numeric($val['piece_nombre'])) unset ($valF['piece_nombre']); |
203 |
|
|
if(!is_numeric($val['shon_calcul'])) unset ($valF['shon_calcul']); |
204 |
|
|
if(!is_numeric($val['terrain_surface_calcul'])) unset ($valF['terrain_surface_calcul']); |
205 |
|
|
// cle secondaire alpha vide (contrainte integrite pgsql) |
206 |
|
|
if($val['demandeur_civilite']=='') $valF['demandeur_civilite']= null; |
207 |
|
|
if($val['delegataire_civilite']=='') $valF['delegataire_civilite']= null; |
208 |
|
|
$res4= $f -> db->autoExecute("dossier",$valF,DB_AUTOQUERY_INSERT); |
209 |
|
|
$f->isDatabaseError($res4); |
210 |
|
|
echo _("dossier")." ".$valF['dossier']." ".$row['demandeur_nom']." "._("ajoute"). |
211 |
|
|
" ".$f -> db->affectedRows()." "._("table")." dossier <br>" ; |
212 |
|
|
} |
213 |
|
|
// insertion des parcelles dans TERRAIN pour le nouveau dossier |
214 |
|
|
$sql= "select * from terrain where dossier ='".$idx."'"; |
215 |
|
|
$res5=$f -> db->query($sql); |
216 |
|
|
$f->isDatabaseError($res5); |
217 |
|
|
$valG['dossier']=$valF['dossier']; |
218 |
|
|
while ($row5=& $res5->fetchRow(DB_FETCHMODE_ASSOC)){ |
219 |
|
|
$valG['parcelle']=$row5['parcelle']; |
220 |
|
|
$valG['terrain']=$f -> db->nextId('terrain'); |
221 |
|
|
// insertion des terrains concernes |
222 |
|
|
$res10= $f -> db->autoExecute("terrain",$valG,DB_AUTOQUERY_INSERT); |
223 |
|
|
if (DB :: isError($res10)) |
224 |
|
|
echo $res10->getDebugInfo()." ".$res10->getMessage()."<br>"; |
225 |
|
|
echo _("terrain")." ".$valG['terrain']." "._("ajoute")." ". |
226 |
|
|
$f -> db->affectedRows()." "._("table")." terrain <br>" ; |
227 |
|
|
} |
228 |
|
|
// transfert destination_shon |
229 |
|
|
$valH=array(); |
230 |
|
|
$sql= "select * from destination_shon where dossier ='".$idx."'"; |
231 |
|
|
$res11 =$f -> db->query($sql); |
232 |
|
|
$f->isDatabaseError($res11); |
233 |
|
|
$valH['dossier']=$valF['dossier']; |
234 |
|
|
while ($row11=& $res11->fetchRow(DB_FETCHMODE_ASSOC)){ |
235 |
|
|
$valH['destination_shon']=$f -> db->nextId('destination_shon'); |
236 |
|
|
$valH['destination']=$row11['destination']; |
237 |
|
|
$valH['shon']=$row11['shon']; |
238 |
|
|
$res12= $f -> db->autoExecute("destination_shon",$valH,DB_AUTOQUERY_INSERT); |
239 |
|
|
if (DB :: isError($res12)) |
240 |
|
|
echo $res12->getDebugInfo()." ".$res12->getMessage()."<br>"; |
241 |
|
|
echo _("destination")." ".$valH['destination_shon']." "._("ajoute"). |
242 |
|
|
" ".$f -> db->affectedRows()." "._("table")." destination_shon <br>" ; |
243 |
|
|
} |
244 |
|
|
// bloc note |
245 |
|
|
$valH=array(); |
246 |
|
|
$sql= "select * from blocnote where dossier ='".$idx."'"; |
247 |
|
|
$res13 =$f -> db->query($sql); |
248 |
|
|
$f->isDatabaseError($res); |
249 |
|
|
$valH['dossier']=$valF['dossier']; |
250 |
|
|
while ($row13=& $res13->fetchRow(DB_FETCHMODE_ASSOC)){ |
251 |
|
|
$valH['blocnote']=$f -> db->nextId('blocnote'); |
252 |
|
|
$valH['note']=$row13['note']; |
253 |
|
|
$valH['categorie']=$row13['categorie']; |
254 |
|
|
$res14= $f -> db->autoExecute("blocnote",$valH,DB_AUTOQUERY_INSERT); |
255 |
|
|
if (DB :: isError($res14)) |
256 |
|
|
echo $res14->getDebugInfo()." ".$res14->getMessage()."<br>"; |
257 |
|
|
echo _("blocnote")." ".$valH['blocnote']." "._("ajoute")." ". |
258 |
|
|
$f -> db->affectedRows()." "._("table")." blocnote <br>" ; |
259 |
|
|
} |
260 |
|
|
// pas dinstruction et de consultation en transfert |
261 |
|
|
// enregistrement $msg en /tmp ********************** |
262 |
|
|
/* |
263 |
|
|
$fichier = "../tmp/".$aff."_".date("dmy_Gis").".htm"; |
264 |
|
|
$inf = fopen($fichier,"w"); |
265 |
|
|
$ent= date("d/m/Y G:i:s"). |
266 |
|
|
"<br>Numéro collectivité : ".$coll. |
267 |
|
|
"<br>Utilisateur : ".$_SESSION['login']."<br>". |
268 |
|
|
"=========================================="."<br>"; |
269 |
|
|
$msg=$ent."<br>".$msg ; |
270 |
|
|
fwrite($inf,$msg); |
271 |
|
|
fclose($inf); |
272 |
|
|
*/ |
273 |
|
|
// ************************************************** |
274 |
|
|
echo $msg; |
275 |
|
|
//echo "</div>"; |
276 |
|
|
// fin de transaction |
277 |
|
|
$f -> db->commit() ; |
278 |
|
|
//$f -> db->rollback(); |
279 |
|
|
}//validation |
280 |
|
|
|
281 |
|
|
?> |