par
ptitgenie69 » 09 oct. 2006, 15:30
Bonjour ;
Gros problème que je vous expose là ! le bout de code qui va suivre est un formulaire, et le soucis que je rencontre c'est que je ne parviens pas a récupérer la valeur de "id_client" qui reste égal à zéro alors qu'elle devrait changer en fonction du choix dans la liste.
pour faire plus simple, il y a la liste : clients concerné
On va chercher dans la BDD la table des clients pour remplir cette liste af de faire un choix.
lors de l'envoi du formulaire, la bdd est mise a jour mais la variable id_client reste définitivemetn égal a zéro ...
mon code :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bienvenue sur Vesta Gestion</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
for (var i=1; i<args.length;i=i+4){
if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
myV=myObj.value;
if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
if (myReq&&myObj.value.length==0){addErr=true}
if ((myV.length>0)&&(args[i+2]==1)){ //fromto
var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
} else if ((myV.length>0)&&(args[i+2]==2)){
var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
} else if ((myV.length>0)&&(args[i+2]==3)){ // date
var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
if(myAt){
var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
var myDate=new Date(myY,myM,myD);
if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
}else{addErr=true}
} else if ((myV.length>0)&&(args[i+2]==4)){ // time
var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
} else if (myV.length>0&&args[i+2]==5){ // check this 2
var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
if(!myObj1.checked){addErr=true}
} else if (myV.length>0&&args[i+2]==6){ // the same
var myObj1 = MM_findObj(args[i+1]);
if(myV!=myObj1.value){addErr=true}
}
} else
if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
if (args[i+2]==2){
var myDot=false;
for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
if(!myDot){myErr+='* ' +args[i+3]+'\n'}
}
} else if (myObj.type=='checkbox'){
if(args[i+2]==1&&myObj.checked==false){addErr=true}
if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
} else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
}else if (myObj.type=='textarea'){
if(myV.length<args[i+1]){addErr=true}
}
if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
}
if (myErr!=''){alert(' Les erreurs suivantes sont survenues :\t\t\t\t\t\n\n'+myErr)}
document.MM_returnValue = (myErr=='');
}
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
<link href="../style/style.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">
<?
//connexion à la base
include("../modules/inc_connec.php");
//inclusion des modules nécessaires
include("../modules/inc_upload.php");
include("../modules/inc_resize.php");
if($modif==1){
//upload des fichier si nécessaire
if($vi_name!=""){
$dest_vi="images/fiche/".$id_fiche."_photo.jpg";
if(!upload($vi,"../".$dest_vi,$vi_size,200))
print("Une erreur est survenue durant l'upload de la vignette<br>");
}
if($pdf_name!=""){
$dest_pdf="pdf/".$id_fiche."_pdf.pdf";
if(!upload($pdf,"../".$dest_pdf,$pdf_size,200))
print("Une erreur est survenue durant l'upload du pdf<br>");
}
if($plan_name!=""){
$dest_plan="images/fiche/".$id_fiche."_plan.jpg";
if(!upload($plan,"../".$dest_plan,$plan_size,200))
print("Une erreur est survenue durant l'upload du plan<br>");
}
//insertion dans la bas
$req="update fiche set id_client='$id_client',id_region='$id_region',id_type='$id_type',nom='$nom',adresse='$adresse',acces='$acces',nb_emp='$nb_emp',surface='$surface',reglement='$reglement',redevance='$redevance',fluides='$fluides',point_eau_I='$point_eau_I',point_eau_C='$point_eau_C',toilette_I='$toilette_I',toilette_C='$toilette_C',douche_I='$douche_I',douche_C='$douche_C',electricite_I='$electricite_I',electricite_C='$electricite_C',incendie_I='$incendie_I',incendie_C='$incendie_C',dechet_I='$dechet_I',dechet_C='$dechet_C',ordure='$ordure',entretien='$entretien',pass_quot='$pass_quot',pass_hebdo='$pass_hebdo',controle='$controle',gardien='$gardien',reception='$reception',polyvalente='$polyvalente',espace='$espace',parking='$parking',sej_court='$sej_court',sej_moyen='$sej_moyen',enfant='$enfant',suivi='$suivi',date_crea='$date_crea',date_gestion='$date_gestion'";
if($dest_vi!="")
$req.=",chem_im='$dest_vi'";
if($dest_plan!="")
$req.=",chem_plan='$dest_plan'";
if($dest_pdf!="")
$req.=",chem_pdf='$dest_pdf'";
$req.=" where id_fiche='$id_fiche'";
if(mysql_query($req))
print("La modification s'est effectuée avec succès<br>".$id_client);
else
print("Une erreur est survenue durant la modification<br>");
}
$req="select * from fiche where id_fiche='$id_fiche'";
$res=mysql_query($req);
$row=mysql_fetch_array($res);
?>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><form name="form1" method="post" enctype="multipart/form-data" action="modif_terrain.php?modif=1">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" colspan="2" align="center" class="adminMenu">Modifier un terrain </td>
</tr>
<tr>
<td class="adminTxt">Terrain concerné</td>
<td><select name="id_fiche" class="admin_txt" id="id_fiche" onChange="MM_callJS('document.form1.action=\"modif_terrain.php\"');MM_callJS('document.form1.submit();')">
<option value="0" selected>Choisissez un terrain</option>
<?
$reqT="select f.id_fiche, f.nom,r.libelle from fiche f,region r where f.id_region=r.id_region order by r.libelle, f.nom";
$resT=mysql_query($reqT);
$aR="";
while($rowT=mysql_fetch_array($resT)){
if($aR!=$rowT[libelle]){
if($aR!="")
print("</optgroup>");
print("<optgroup label=\"".str_replace("<br>"," ",$rowT[libelle])."\">");
$aR=$rowT[libelle];
}
print("<option value='$rowT[id_fiche]'");
if($id_fiche==$rowT[id_fiche])
print(" selected");
print(">$rowT[nom]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt"> </td>
<td> </td>
</tr>
<tr>
<td class="adminTxt">Client concerné </td>
<td><select name="id_client" class="adminChamp" id="id_client">
<option value="0" selected>Selectionner un client</option>
<?
$reqC="select * from client order by nom";
$resC=mysql_query($reqC);
while($rowC=mysql_fetch_array($resC)){
print("<option value='$row[id_client]'");
if($row['id_client']==$rowC[id_client])
print(" selected");
print(">$rowC[nom] $rowC[prenom]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt">Identifiant du terrain </td>
<td><input name="textfield" type="text" value="<?=$id_fiche?>" size="5"></td>
</tr>
<tr>
<td width="200" class="adminTxt">Région correspondante </td>
<td><select name="id_region" class="adminChamp" id="id_region">
<option value="0" selected>Selectionner une région</option>
<?
$reqR="select * from region order by libelle";
$resR=mysql_query($reqR);
while($rowR=mysql_fetch_array($resR)){
print("<option value='$rowR[id_region]'");
if($row[id_region]==$rowR[id_region])
print(" selected");
print(">$rowR[libelle]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt">Type de terrain </td>
<td><select name="id_type" class="adminChamp" id="id_type">
<option value="0" selected>Selectionner un type de terrain</option>
<?
$reqT="select * from type_region order by libelle";
$resT=mysql_query($reqT);
while($rowT=mysql_fetch_array($resT)){
print("<option value='$rowT[id_type]'");
if($row[id_type]==$rowT[id_type])
print(" selected");
print(">$rowT[libelle]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt">Nom</td>
<td><input name="nom" type="text" class="adminChamp" id="nom" value="<?print($row[nom]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Adresse</td>
<td><textarea name="adresse" cols="35" rows="4" class="adminChamp" id="adresse"><?print($row[adresse]);?></textarea></td>
</tr>
<tr>
<td class="adminTxt">Accès</td>
<td><textarea name="acces" cols="35" rows="4" class="adminChamp" id="acces"><?print($row[acces]);?></textarea></td>
</tr>
<tr>
<td class="adminTxt">Nombre d'emplacement </td>
<td><input name="nb_emp" type="text" class="adminChamp" id="nb_emp" value="<?print($row[nb_emp]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Surface</td>
<td><input name="surface" type="text" class="adminChamp" id="surface" value="<?print($row[surface]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Règlement</td>
<td><input name="reglement" type="checkbox" id="reglement" value="1" <? if($row[reglement]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Redevance</td>
<td><input name="redevance" type="text" class="adminChamp" id="redevance" value="<?print($row[redevance]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Fluides</td>
<td><input name="fluides" type="text" class="adminChamp" id="fluides" value="<?print($row[fluides]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Date de création </td>
<td><input name="date_crea" type="text" class="adminChamp" id="date_crea" value="<?print($row[date_crea]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Date de début de Gestion VESTA </td>
<td><input name="date_gestion" type="text" class="adminChamp" id="date_gestion" value="<?print($row[date_gestion]);?>"></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> EQUIPEMENTS</td>
</tr>
<tr>
<td class="adminTxt">Point d'eau extérieur </td>
<td class="adminTxt">Emplacement
<input name="point_eau_I" type="checkbox" id="point_eau_I" value="1" <? if($row[point_eau_I]==1) print("checked");?>>
Collectif
<input name="point_eau_C" type="checkbox" id="point_eau_C" value="1" <? if($row[point_eau_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Toilettes</td>
<td class="adminTxt"> Emplacement
<input name="toilette_I" type="checkbox" id="toilette_I" value="1" <? if($row[toilette_I]==1) print("checked");?>>
Collectif
<input name="toilette_C" type="checkbox" id="toilette_C" value="1" <? if($row[toilette_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Douche(s)</td>
<td class="adminTxt"> Emplacement
<input name="douche_I" type="checkbox" id="douche_I" value="1" <? if($row[douche_I]==1) print("checked");?>>
Collectif
<input name="douche_C" type="checkbox" id="douche_C" value="1" <? if($row[douche_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Electricité</td>
<td class="adminTxt"> Emplacement
<input name="electricite_I" type="checkbox" id="electricite_I" value="1" <? if($row[electricite_I]==1) print("checked");?>>
Collectif
<input name="electricite_C" type="checkbox" id="electricite_C" value="1" <? if($row[electricite_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Protection incendie</td>
<td class="adminTxt"> Emplacement
<input name="incendie_I" type="checkbox" id="incendie_I" value="1" <? if($row[incendie_I]==1) print("checked");?>>
Collectif
<input name="incendie_C" type="checkbox" id="incendie_C" value="1" <? if($row[incendie_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Containers déchets </td>
<td class="adminTxt"> Emplacement
<input name="dechet_I" type="checkbox" id="dechet_I" value="1" <? if($row[dechet_I]==1) print("checked");?>>
Collectif
<input name="dechet_C" type="checkbox" id="dechet_C" value="1" <? if($row[dechet_C]==1) print("checked");?>></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> SERVICES</td>
</tr>
<tr>
<td class="adminTxt">Ramassage des ordures</td>
<td><input name="ordure" type="checkbox" id="ordure" value="1" <? if($row[ordure]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Entretien des espaces communs </td>
<td><input name="entretien" type="checkbox" id="entretien" value="1" <? if($row[entretien]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Passage quotidien </td>
<td><input name="pass_quot" type="checkbox" id="pass_quot" value="1" <? if($row[pass_quot]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Passage Hebdomadaire </td>
<td><input name="pass_hebdo" type="checkbox" id="pass_hebdo" value="1" <? if($row[pass_hebdo]==1) print("checked")?>></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> EQUIPEMENT COLLECTIF </td>
</tr>
<tr>
<td class="adminTxt">Contrôle d'accès </td>
<td><input name="controle" type="checkbox" id="controle" value="1" <? if($row[controle]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Logement gardien</td>
<td><input name="gardien" type="checkbox" id="gardien" value="1" <? if($row[gardien]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Bureau de réception</td>
<td><input name="reception" type="checkbox" id="reception" value="1" <? if($row[reception]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Salle polyvalente</td>
<td><input name="polyvalente" type="checkbox" id="polyvalente" value="1" <? if($row[polyvalente]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Espace verts </td>
<td><input name="espace" type="checkbox" id="espace" value="1" <? if($row[espace]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Parking visiteurs </td>
<td><input name="parking" type="checkbox" id="parking" value="1" <? if($row[parking]==1) print("checked")?>></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> POPULATION</td>
</tr>
<tr>
<td class="adminTxt">Séjour court </td>
<td><input name="sej_court" type="checkbox" id="sej_court" value="1" <? if($row[sej_court]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Séjour moyen </td>
<td><input name="sej_moyen" type="checkbox" id="sej_moyen" value="1" <? if($row[sej_moyen]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Enfant scolarisés </td>
<td><input name="enfant" type="checkbox" id="enfant" value="1" <? if($row[enfant]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Suivi social </td>
<td><input name="suivi" type="checkbox" id="suivi" value="1" <? if($row[suivi]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Plan : </td>
<td><? if($row[chem_plan]!="" && file_exists("../".$row[chem_plan])) print("<img src='../$row[chem_plan]' ".resize(80,"../".$row[chem_plan])."><br>");?><input name="plan" type="file" class="adminChamp" id="plan"></td>
</tr>
<tr>
<td class="adminTxt">PDF: </td>
<td><? if($row[chem_pdf]!="" && file_exists("../".$row[chem_pdf])) print("<a href='../$row[chem_pdf]' target='_blank'>voir le pdf</a><br>");?><input name="pdf" type="file" class="adminChamp" id="pdf"></td>
</tr>
<tr>
<td class="adminTxt">Vignette : </td>
<td><? if($row[chem_im]!="" && file_exists("../".$row[chem_im])) print("<img src='../$row[chem_im]' ".resize(80,"../".$row[chem_im])."><br>");?><input name="vi" type="file" class="adminChamp" id="vi"></td>
</tr>
<tr>
<td height="30" colspan="2" align="center"><input name="Submit" type="submit" class="adminChamp" onClick="YY_checkform('form1','id_region','#q','1','Vous devez sélectionner une région','id_type','#q','1','Vous devez sélectionner un type de données');return document.MM_returnValue" value="Modifier"></td>
</tr>
</table>
</form></td>
</tr>
</table>
<?
mysql_close();
?>
</body>
</html>
merci pour vos futus contributions ...
Bonjour ;
Gros problème que je vous expose là ! le bout de code qui va suivre est un formulaire, et le soucis que je rencontre c'est que je ne parviens pas a récupérer la valeur de "id_client" qui reste égal à zéro alors qu'elle devrait changer en fonction du choix dans la liste.
pour faire plus simple, il y a la liste : clients concerné
On va chercher dans la BDD la table des clients pour remplir cette liste af de faire un choix.
lors de l'envoi du formulaire, la bdd est mise a jour mais la variable id_client reste définitivemetn égal a zéro ...
mon code :
[php]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Bienvenue sur Vesta Gestion</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function YY_checkform() { //v4.66
//copyright (c)1998,2002 Yaromat.com
var args = YY_checkform.arguments; var myDot=true; var myV=''; var myErr='';var addErr=false;var myReq;
for (var i=1; i<args.length;i=i+4){
if (args[i+1].charAt(0)=='#'){myReq=true; args[i+1]=args[i+1].substring(1);}else{myReq=false}
var myObj = MM_findObj(args[i].replace(/\[\d+\]/ig,""));
myV=myObj.value;
if (myObj.type=='text'||myObj.type=='password'||myObj.type=='hidden'){
if (myReq&&myObj.value.length==0){addErr=true}
if ((myV.length>0)&&(args[i+2]==1)){ //fromto
var myMa=args[i+1].split('_');if(isNaN(myV)||myV<myMa[0]/1||myV > myMa[1]/1){addErr=true}
} else if ((myV.length>0)&&(args[i+2]==2)){
var rx=new RegExp("^[\\w\.=-]+@[\\w\\.-]+\\.[a-z]{2,4}$");if(!rx.test(myV))addErr=true;
} else if ((myV.length>0)&&(args[i+2]==3)){ // date
var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);
if(myAt){
var myD=(myAt[myMa[1]])?myAt[myMa[1]]:1; var myM=myAt[myMa[2]]-1; var myY=myAt[myMa[3]];
var myDate=new Date(myY,myM,myD);
if(myDate.getFullYear()!=myY||myDate.getDate()!=myD||myDate.getMonth()!=myM){addErr=true};
}else{addErr=true}
} else if ((myV.length>0)&&(args[i+2]==4)){ // time
var myMa=args[i+1].split("#"); var myAt=myV.match(myMa[0]);if(!myAt){addErr=true}
} else if (myV.length>0&&args[i+2]==5){ // check this 2
var myObj1 = MM_findObj(args[i+1].replace(/\[\d+\]/ig,""));
if(myObj1.length)myObj1=myObj1[args[i+1].replace(/(.*\[)|(\].*)/ig,"")];
if(!myObj1.checked){addErr=true}
} else if (myV.length>0&&args[i+2]==6){ // the same
var myObj1 = MM_findObj(args[i+1]);
if(myV!=myObj1.value){addErr=true}
}
} else
if (!myObj.type&&myObj.length>0&&myObj[0].type=='radio'){
var myTest = args[i].match(/(.*)\[(\d+)\].*/i);
var myObj1=(myObj.length>1)?myObj[myTest[2]]:myObj;
if (args[i+2]==1&&myObj1&&myObj1.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
if (args[i+2]==2){
var myDot=false;
for(var j=0;j<myObj.length;j++){myDot=myDot||myObj[j].checked}
if(!myDot){myErr+='* ' +args[i+3]+'\n'}
}
} else if (myObj.type=='checkbox'){
if(args[i+2]==1&&myObj.checked==false){addErr=true}
if(args[i+2]==2&&myObj.checked&&MM_findObj(args[i+1]).value.length/1==0){addErr=true}
} else if (myObj.type=='select-one'||myObj.type=='select-multiple'){
if(args[i+2]==1&&myObj.selectedIndex/1==0){addErr=true}
}else if (myObj.type=='textarea'){
if(myV.length<args[i+1]){addErr=true}
}
if (addErr){myErr+='* '+args[i+3]+'\n'; addErr=false}
}
if (myErr!=''){alert(' Les erreurs suivantes sont survenues :\t\t\t\t\t\n\n'+myErr)}
document.MM_returnValue = (myErr=='');
}
function MM_callJS(jsStr) { //v2.0
return eval(jsStr)
}
//-->
</script>
<link href="../style/style.css" rel="stylesheet" type="text/css">
</head>
<body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor="#FFFFFF">
<?
//connexion à la base
include("../modules/inc_connec.php");
//inclusion des modules nécessaires
include("../modules/inc_upload.php");
include("../modules/inc_resize.php");
if($modif==1){
//upload des fichier si nécessaire
if($vi_name!=""){
$dest_vi="images/fiche/".$id_fiche."_photo.jpg";
if(!upload($vi,"../".$dest_vi,$vi_size,200))
print("Une erreur est survenue durant l'upload de la vignette<br>");
}
if($pdf_name!=""){
$dest_pdf="pdf/".$id_fiche."_pdf.pdf";
if(!upload($pdf,"../".$dest_pdf,$pdf_size,200))
print("Une erreur est survenue durant l'upload du pdf<br>");
}
if($plan_name!=""){
$dest_plan="images/fiche/".$id_fiche."_plan.jpg";
if(!upload($plan,"../".$dest_plan,$plan_size,200))
print("Une erreur est survenue durant l'upload du plan<br>");
}
//insertion dans la bas
$req="update fiche set id_client='$id_client',id_region='$id_region',id_type='$id_type',nom='$nom',adresse='$adresse',acces='$acces',nb_emp='$nb_emp',surface='$surface',reglement='$reglement',redevance='$redevance',fluides='$fluides',point_eau_I='$point_eau_I',point_eau_C='$point_eau_C',toilette_I='$toilette_I',toilette_C='$toilette_C',douche_I='$douche_I',douche_C='$douche_C',electricite_I='$electricite_I',electricite_C='$electricite_C',incendie_I='$incendie_I',incendie_C='$incendie_C',dechet_I='$dechet_I',dechet_C='$dechet_C',ordure='$ordure',entretien='$entretien',pass_quot='$pass_quot',pass_hebdo='$pass_hebdo',controle='$controle',gardien='$gardien',reception='$reception',polyvalente='$polyvalente',espace='$espace',parking='$parking',sej_court='$sej_court',sej_moyen='$sej_moyen',enfant='$enfant',suivi='$suivi',date_crea='$date_crea',date_gestion='$date_gestion'";
if($dest_vi!="")
$req.=",chem_im='$dest_vi'";
if($dest_plan!="")
$req.=",chem_plan='$dest_plan'";
if($dest_pdf!="")
$req.=",chem_pdf='$dest_pdf'";
$req.=" where id_fiche='$id_fiche'";
if(mysql_query($req))
print("La modification s'est effectuée avec succès<br>".$id_client);
else
print("Une erreur est survenue durant la modification<br>");
}
$req="select * from fiche where id_fiche='$id_fiche'";
$res=mysql_query($req);
$row=mysql_fetch_array($res);
?>
<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="center" valign="middle"><form name="form1" method="post" enctype="multipart/form-data" action="modif_terrain.php?modif=1">
<table width="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="30" colspan="2" align="center" class="adminMenu">Modifier un terrain </td>
</tr>
<tr>
<td class="adminTxt">Terrain concerné</td>
<td><select name="id_fiche" class="admin_txt" id="id_fiche" onChange="MM_callJS('document.form1.action=\"modif_terrain.php\"');MM_callJS('document.form1.submit();')">
<option value="0" selected>Choisissez un terrain</option>
<?
$reqT="select f.id_fiche, f.nom,r.libelle from fiche f,region r where f.id_region=r.id_region order by r.libelle, f.nom";
$resT=mysql_query($reqT);
$aR="";
while($rowT=mysql_fetch_array($resT)){
if($aR!=$rowT[libelle]){
if($aR!="")
print("</optgroup>");
print("<optgroup label=\"".str_replace("<br>"," ",$rowT[libelle])."\">");
$aR=$rowT[libelle];
}
print("<option value='$rowT[id_fiche]'");
if($id_fiche==$rowT[id_fiche])
print(" selected");
print(">$rowT[nom]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt"> </td>
<td> </td>
</tr>
<tr>
<td class="adminTxt">Client concerné </td>
<td><select name="id_client" class="adminChamp" id="id_client">
<option value="0" selected>Selectionner un client</option>
<?
$reqC="select * from client order by nom";
$resC=mysql_query($reqC);
while($rowC=mysql_fetch_array($resC)){
print("<option value='$row[id_client]'");
if($row['id_client']==$rowC[id_client])
print(" selected");
print(">$rowC[nom] $rowC[prenom]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt">Identifiant du terrain </td>
<td><input name="textfield" type="text" value="<?=$id_fiche?>" size="5"></td>
</tr>
<tr>
<td width="200" class="adminTxt">Région correspondante </td>
<td><select name="id_region" class="adminChamp" id="id_region">
<option value="0" selected>Selectionner une région</option>
<?
$reqR="select * from region order by libelle";
$resR=mysql_query($reqR);
while($rowR=mysql_fetch_array($resR)){
print("<option value='$rowR[id_region]'");
if($row[id_region]==$rowR[id_region])
print(" selected");
print(">$rowR[libelle]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt">Type de terrain </td>
<td><select name="id_type" class="adminChamp" id="id_type">
<option value="0" selected>Selectionner un type de terrain</option>
<?
$reqT="select * from type_region order by libelle";
$resT=mysql_query($reqT);
while($rowT=mysql_fetch_array($resT)){
print("<option value='$rowT[id_type]'");
if($row[id_type]==$rowT[id_type])
print(" selected");
print(">$rowT[libelle]</option>");
}
?>
</select></td>
</tr>
<tr>
<td class="adminTxt">Nom</td>
<td><input name="nom" type="text" class="adminChamp" id="nom" value="<?print($row[nom]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Adresse</td>
<td><textarea name="adresse" cols="35" rows="4" class="adminChamp" id="adresse"><?print($row[adresse]);?></textarea></td>
</tr>
<tr>
<td class="adminTxt">Accès</td>
<td><textarea name="acces" cols="35" rows="4" class="adminChamp" id="acces"><?print($row[acces]);?></textarea></td>
</tr>
<tr>
<td class="adminTxt">Nombre d'emplacement </td>
<td><input name="nb_emp" type="text" class="adminChamp" id="nb_emp" value="<?print($row[nb_emp]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Surface</td>
<td><input name="surface" type="text" class="adminChamp" id="surface" value="<?print($row[surface]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Règlement</td>
<td><input name="reglement" type="checkbox" id="reglement" value="1" <? if($row[reglement]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Redevance</td>
<td><input name="redevance" type="text" class="adminChamp" id="redevance" value="<?print($row[redevance]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Fluides</td>
<td><input name="fluides" type="text" class="adminChamp" id="fluides" value="<?print($row[fluides]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Date de création </td>
<td><input name="date_crea" type="text" class="adminChamp" id="date_crea" value="<?print($row[date_crea]);?>"></td>
</tr>
<tr>
<td class="adminTxt">Date de début de Gestion VESTA </td>
<td><input name="date_gestion" type="text" class="adminChamp" id="date_gestion" value="<?print($row[date_gestion]);?>"></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> EQUIPEMENTS</td>
</tr>
<tr>
<td class="adminTxt">Point d'eau extérieur </td>
<td class="adminTxt">Emplacement
<input name="point_eau_I" type="checkbox" id="point_eau_I" value="1" <? if($row[point_eau_I]==1) print("checked");?>>
Collectif
<input name="point_eau_C" type="checkbox" id="point_eau_C" value="1" <? if($row[point_eau_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Toilettes</td>
<td class="adminTxt"> Emplacement
<input name="toilette_I" type="checkbox" id="toilette_I" value="1" <? if($row[toilette_I]==1) print("checked");?>>
Collectif
<input name="toilette_C" type="checkbox" id="toilette_C" value="1" <? if($row[toilette_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Douche(s)</td>
<td class="adminTxt"> Emplacement
<input name="douche_I" type="checkbox" id="douche_I" value="1" <? if($row[douche_I]==1) print("checked");?>>
Collectif
<input name="douche_C" type="checkbox" id="douche_C" value="1" <? if($row[douche_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Electricité</td>
<td class="adminTxt"> Emplacement
<input name="electricite_I" type="checkbox" id="electricite_I" value="1" <? if($row[electricite_I]==1) print("checked");?>>
Collectif
<input name="electricite_C" type="checkbox" id="electricite_C" value="1" <? if($row[electricite_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Protection incendie</td>
<td class="adminTxt"> Emplacement
<input name="incendie_I" type="checkbox" id="incendie_I" value="1" <? if($row[incendie_I]==1) print("checked");?>>
Collectif
<input name="incendie_C" type="checkbox" id="incendie_C" value="1" <? if($row[incendie_C]==1) print("checked");?>></td>
</tr>
<tr>
<td class="adminTxt">Containers déchets </td>
<td class="adminTxt"> Emplacement
<input name="dechet_I" type="checkbox" id="dechet_I" value="1" <? if($row[dechet_I]==1) print("checked");?>>
Collectif
<input name="dechet_C" type="checkbox" id="dechet_C" value="1" <? if($row[dechet_C]==1) print("checked");?>></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> SERVICES</td>
</tr>
<tr>
<td class="adminTxt">Ramassage des ordures</td>
<td><input name="ordure" type="checkbox" id="ordure" value="1" <? if($row[ordure]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Entretien des espaces communs </td>
<td><input name="entretien" type="checkbox" id="entretien" value="1" <? if($row[entretien]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Passage quotidien </td>
<td><input name="pass_quot" type="checkbox" id="pass_quot" value="1" <? if($row[pass_quot]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Passage Hebdomadaire </td>
<td><input name="pass_hebdo" type="checkbox" id="pass_hebdo" value="1" <? if($row[pass_hebdo]==1) print("checked")?>></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> EQUIPEMENT COLLECTIF </td>
</tr>
<tr>
<td class="adminTxt">Contrôle d'accès </td>
<td><input name="controle" type="checkbox" id="controle" value="1" <? if($row[controle]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Logement gardien</td>
<td><input name="gardien" type="checkbox" id="gardien" value="1" <? if($row[gardien]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Bureau de réception</td>
<td><input name="reception" type="checkbox" id="reception" value="1" <? if($row[reception]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Salle polyvalente</td>
<td><input name="polyvalente" type="checkbox" id="polyvalente" value="1" <? if($row[polyvalente]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Espace verts </td>
<td><input name="espace" type="checkbox" id="espace" value="1" <? if($row[espace]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Parking visiteurs </td>
<td><input name="parking" type="checkbox" id="parking" value="1" <? if($row[parking]==1) print("checked")?>></td>
</tr>
<tr bgcolor="996699" class="fiche_titre">
<td colspan="2"> POPULATION</td>
</tr>
<tr>
<td class="adminTxt">Séjour court </td>
<td><input name="sej_court" type="checkbox" id="sej_court" value="1" <? if($row[sej_court]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Séjour moyen </td>
<td><input name="sej_moyen" type="checkbox" id="sej_moyen" value="1" <? if($row[sej_moyen]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Enfant scolarisés </td>
<td><input name="enfant" type="checkbox" id="enfant" value="1" <? if($row[enfant]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Suivi social </td>
<td><input name="suivi" type="checkbox" id="suivi" value="1" <? if($row[suivi]==1) print("checked")?>></td>
</tr>
<tr>
<td class="adminTxt">Plan : </td>
<td><? if($row[chem_plan]!="" && file_exists("../".$row[chem_plan])) print("<img src='../$row[chem_plan]' ".resize(80,"../".$row[chem_plan])."><br>");?><input name="plan" type="file" class="adminChamp" id="plan"></td>
</tr>
<tr>
<td class="adminTxt">PDF: </td>
<td><? if($row[chem_pdf]!="" && file_exists("../".$row[chem_pdf])) print("<a href='../$row[chem_pdf]' target='_blank'>voir le pdf</a><br>");?><input name="pdf" type="file" class="adminChamp" id="pdf"></td>
</tr>
<tr>
<td class="adminTxt">Vignette : </td>
<td><? if($row[chem_im]!="" && file_exists("../".$row[chem_im])) print("<img src='../$row[chem_im]' ".resize(80,"../".$row[chem_im])."><br>");?><input name="vi" type="file" class="adminChamp" id="vi"></td>
</tr>
<tr>
<td height="30" colspan="2" align="center"><input name="Submit" type="submit" class="adminChamp" onClick="YY_checkform('form1','id_region','#q','1','Vous devez sélectionner une région','id_type','#q','1','Vous devez sélectionner un type de données');return document.MM_returnValue" value="Modifier"></td>
</tr>
</table>
</form></td>
</tr>
</table>
<?
mysql_close();
?>
</body>
</html>
[/php]
merci pour vos futus contributions ...