1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
<?php
$erreur = null;
if(isset($_POST['go']) && $_POST['go']=='Valider')
{
foreach($_POST as $key=>$value)
if(empty($value)) $erreur = "Au moins un de vos champs est vide!!!";
if($erreur)
{
echo "<p style='color:red;text-align:center'>".$erreur."</p>";
}
else
{
$sql = "INSERT INTO `intervention` (
`id` ,
`reparer` ,
`date_panne` ,
`id_type_panne` ,
`id_mat` ,
`commentaire` ,
`id_personne` ,
`id_technicien`
)
VALUES (
NULL , 'non', NOW(), '".$_POST['panne']."', '".$_POST['materiel']."', '".mysql_escape_string($_POST['commentaire'])."', '".$_POST['utilisateur']."', '".$_POST['technicien']."');" ;
mysql_query($sql) or die(mysql_error());
$c=$_POST['technicien'];
$exe = mysql_query("SELECT email FROM personne WHERE profil = 3 and nom = '{$c}' " ) or die(mysql_error());
$type_panne=$_POST['panne'];
$mat=$_POST['materiel'];
$commentaire=$_POST['commentaire'];
$mail_from="errabi.jihane@gmail.com";
$mail_to=$exe['email'] ;
$mail_body="signalisation de la panne:
".$commentaire;
$mail_subject="le matériel:".$mat." ι panne: ".$type_panne;
$mail_header="From: ".$mail_from."< ".$mail_from.">\r\n";
ini_set("SMTP","webmail.meditel.ma");
$sendmail=mail($mail_to,$mail_subject,$mail_body,$mail_from);
if($sendmail)
{
echo "<h1>signalisation effectuée</h1>";}
else
{
echo "<h1>Erreur</h1>
"; }
}}
?>
<form name="" method="post" action="">
<h3 style="text-align:center">affectation d'une panne</h3>
<table style="width:100%">
<tr>
<td>Materiel</td>
<td>
<select style="width:200px" name="materiel">
<?php
$exe = mysql_query("SELECT * FROM materiel") or die(mysql_error());
while($data = mysql_fetch_array($exe))
{
echo "<option value='".$data['id_mat']."'>".$data['nom_mat']."</option>";
}
?>
</select> </td>
</tr>
<tr>
<td>Utilisateur</td>
<td><select style="width:200px" name="utilisateur">
<?php
$exe = mysql_query("SELECT * FROM personne where profil='2'") or die(mysql_error());
while($data = mysql_fetch_array($exe))
{
echo "<option value='".$data['id_personne']."'>".$data['nom']."</option>";
}
?>
</select>
</td>
</tr>
<tr>
<td>Spécialité du technicien </td>
<td>
<select style="width:200px" Onchange="javascript:submit();" name="specialite" >
<?php
$exe = mysql_query("SELECT * FROM personne where profil='3' ") or die(mysql_error());
echo "<option>Choix</option>";while($data = mysql_fetch_array($exe))
{
echo "<option value='".$data['specialite']."'>".$data['specialite']."</option>";
}
?>
</select> </td>
</tr>
<tr>
<td> Téchnicien</td>
<td>
<select style="width:200px" name="technicien">
<?php
$s=$_POST['specialite'];
if(isset($s)){
$exe = mysql_query("SELECT * FROM personne WHERE profil = 3 and specialite = '{$s}' " ) or die(mysql_error());
while($data = mysql_fetch_array($exe))
{
echo "<option value='".$data['id_personne']."'>".$data['nom']."</option>";
}}
?>
</select> </td>
</tr>
<tr>
<td width="34%">Type de Panne</td>
<td width="66%">
<input type="text"name="panne" value="" width="200px">
</select> </td>
</tr>
<tr>
<td>Commentaire </td>
<td><textarea name="commentaire" width="200px"></textarea></td>
</tr>
</table>
<center><input type="submit" name="go" value="Valider"/></center>
</form> |
Partager