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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322
|
<?php
include("../inc/fonctions.php");
include('index.php');
$bddtest = new PDO("mysql:host=localhost;dbname=projet-facturier", "root","root");
$bddtest->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
if (isset($_POST["submit"])) {
//récupère les données qui ont été saisie dans le formulaire
$probleme = !empty($_POST['probleme']) ? $_POST['probleme'] : NULL;
$resolution = !empty($_POST['resolution']) ? $_POST['resolution'] : NULL;
$status = !empty($_POST['status']) ? $_POST['status'] : NULL;
$password = !empty($_POST['password ']) ? $_POST['password '] : NULL;
$tel = !empty($_POST['tel ']) ? $_POST['tel '] : NULL;
$tel2 = !empty($_POST['tel2 ']) ? $_POST['tel2 '] : NULL;
$siteweb = !empty($_POST['siteweb ']) ? $_POST['siteweb '] : NULL;
$email = !empty($_POST['email ']) ? $_POST['email '] : NULL;
$user = !empty($_POST['user ']) ? $_POST['user'] : NULL;
$idmateriel = !empty($_POST['idmateriel ']) ? $_POST['idmateriel '] : NULL;
$login = !empty($_POST['login ']) ? $_POST['login'] : NULL;
$dt = new DateTime('Europe/Paris');
$date = $dt->format('Y-m-d H:i:s');
$idclient = !empty($_POST['idclient']) ? $_POST['idclient'] : NULL;
$client = !empty($_POST['client']) ? $_POST['client'] : NULL;
$nom = !empty($_POST['nom']) ? $_POST['nom '] : NULL;
$prenom = !empty($_POST['prenom ']) ? $_POST['prenom '] : NULL;
$ville = !empty($_POST['ville ']) ? $_POST['ville '] : NULL;
$codepostal = !empty($_POST['codepostal ']) ? $_POST['codepostal '] : NULL;
$adresse = !empty($_POST['adresse ']) ? $_POST['adresse '] : NULL;
$adresse2 = !empty($_POST['adresse2 ']) ? $_POST['adresse2 '] : NULL;
$pays = !empty($_POST['pays ']) ? $_POST['pays'] : NULL;
$societe = !empty($_POST['societe ']) ? $_POST['societe '] : NULL;
$goClient = !empty($_POST['goClient']) ? $_POST['goClient'] : NULL;
$civilite = !empty($_POST['civilite']) ? $_POST['civilite'] : NULL;
$choixgrp = !empty($_POST['choixgrp ']) ? $_POST['choixgrp '] : NULL;
$detail = !empty($_POST['detail']) ? $_POST['detail'] : NULL;
//insère les données dans la base de données
//si le client existe on le recherche
if ($goClient == 1)
{
if ($idclient == "")
{
$_GET["msg"] = "Veuillez choisir un client";
}
else
{
//fait un requête pour selection l'id de l'user pour savoir si il existe ou pas
$r = mysql_query("SELECT iduser FROM esf_clients WHERE idclient='$idclient';",$bdd2) or die(mysql_error());
if (mysql_num_rows($r)==0)
{
$_GET["msg"] = "Le client n'existe pas ...";
$idclient = 0;
}
else
{
$user = mysql_result($r,0,"iduser");
}
}
}
//si le client n'existe pas on le créer
if ($goClient == 0)
{
//prépare la requête sql
$r = mysql_query("INSERT INTO esf_clients VALUES ('','','$societe','$civilite','$nom','$prenom','$adresse','$adresse2','$ville','$codepostal','$pays','$tel','$tel2','','','$email','$siteweb','','','','','$login','$password','','','1','$user');",$bdd2) or die(mysql_error());
$idclient = mysql_insert_id();
foreach($choixgrp as $grp)
{
$r = mysql_query("INSERT INTO esf_clients_grp VALUES ('$idclient','$grp');",$bdd2) or die(mysql_error());
}
exit();
}
$req = $bddtest->prepare("INSERT INTO ticket (probleme, date_creation, resolution, status, idmateriel, idclient) VALUES (:probleme, :date_creation, :resolution, :status, :idmateriel, :idclient)");
$req->execute(array(
"probleme" => $probleme,
"date_creation" => $date,
"resolution" => $resolution,
"status" => $status,
"idmateriel" => $idmateriel,
"idclient" => $idclient,
));
}
else
{
//valeurs par default
$goClient = 1;
$idclient = !empty($_GET['idclient']) ? $_GET['idclient'] : NULL;
$client = !empty($_POST['client']) ? $_POST['client'] : NULL;
$nom = !empty($_POST['nom']) ? $_POST['nom '] : NULL;
$prenom = !empty($_POST['prenom ']) ? $_POST['prenom '] : NULL;
$ville = !empty($_POST['ville ']) ? $_POST['ville '] : NULL;
$codepostal = !empty($_POST['codepostal ']) ? $_POST['codepostal '] : NULL;
$adresse = !empty($_POST['adresse ']) ? $_POST['adresse '] : NULL;
$adresse2 = !empty($_POST['adresse2 ']) ? $_POST['adresse2 '] : NULL;
$pays = !empty($_POST['pays ']) ? $_POST['pays'] : NULL;
$societe = !empty($_POST['societe ']) ? $_POST['societe '] : NULL;
$fond = "";
$commentaire_interne = "";
$civilite = "Mr";
$detail = 0;
$tel = "";
$tel2 = "";
$siteweb = "http://";
$email = "";
$choixgrp = array();
$fichiers = array();
}
if ($goClient == 1) { $display0 = "none"; $display1 = "block"; $display2 = "none"; }
if ($goClient == 0) { $display0 = "block"; $display1 = "none"; $display2 = "none"; }
if ($detail == 1) $display2 = "block";
if ($idclient != 0) $client = infosClient($idclient);
?>
<!-- script pour quand on change de page par rapport au client existant ou au client non existant -->
<script type="text/javascript">
function changeClient() {
if (document.getElementById('goClient1').checked)
{
document.getElementById('clientExiste').style.display = 'none';
document.getElementById('clientExistePas').style.display = 'block';
}
else
{
document.getElementById('clientExiste').style.display = 'block';
document.getElementById('clientExistePas').style.display = 'none';
}
}
function changeClientDetail() {
if (document.getElementById('detail').checked)
{
document.getElementById('clientDetail').style.display = 'block';
}
else
{
document.getElementById('clientDetail').style.display = 'none';
}
}
</script>
<link href="style.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="JavaScript" src="js/jquery.js"></SCRIPT>
<SCRIPT LANGUAGE="JavaScript" src="js/script.js"></SCRIPT>
<meta charset="UTF-8">
<!-- formulaire pour ajout de ticket -->
<form method="post" action="ajoutTicket.php" >
<table border="0" align="center" width="95%">
<tr>
<td width="50%" style="height: 50px;background-color: #36393D;font-size: 16px;text-align: center; color: #ffffff;font-weight: bold;"><input class="cb" type="radio" name="goClient" onclick="javascript: changeClient();" id="goClient1" value="0" <?php if ($goClient == 0) echo("checked=\"checked\""); ?> /> <label for="goClient1">Le client n'existe pas</label></td>
<td width="50%" style="height: 50px;background-color: #C3D9FF;font-size: 16px;text-align: center; color: #000000;font-weight: bold;"><input class="cb" type="radio" name="goClient" onclick="javascript: changeClient();" id="goClient2" value="1" <?php if ($goClient == 1) echo("checked=\"checked\""); ?> /> <label for="goClient2">Le client existe déjà</label></td>
</tr>
</table>
<div id="clientExiste" style="display: <?php echo($display1); ?>;">
<table border="0" align="center" cellpadding="5" width="95%">
<tr class="titre">
<td colspan="4">Client : </td>
</tr>
<tr class="fond1">
<tr class="fond1"><td> Client :</td><td><input type="text" id="keyword" tabindex="0" autocomplete="off" class="infos"><img src="images/loading.gif" id="loading"></td></tr>
<tr><td><div id="ajax_response"></div></td></tr>
</table>
</div>
<div id="clientExistePas" style="display: <?php echo($display0); ?>;">
<table border="0" align="center" cellpadding="5" width="95%">
<tr class="titre">
<td colspan="4">Client : </td>
</tr>
<tr class="fond1">
<td>Civlité :</td>
<td colspan="3"><input type="radio" name="civilite" class="cb" value="Mr" <?php if ($civilite == "Mr") echo(" checked=\"checked\""); ?> /> Mr
<input type="radio" name="civilite" class="cb" value="Mme" <?php if ($civilite == "Mme") echo(" checked=\"checked\""); ?> /> Mme
<input type="radio" name="civilite" class="cb" value="Mlle" <?php if ($civilite == "Mlle") echo(" checked=\"checked\""); ?> /> Mlle</td>
</tr>
<tr class="fond2">
<td width="15%">Nom <span class="important">*</span> :</td>
<td width="35%"><input type="text" name="nom" size="25" value="<?php echo($nom); ?>" /></td>
<td width="15%">Prénom <span class="important">*</span> :</td>
<td width="35%"><input type="text" name="prenom" size="25" value="<?php echo($prenom); ?>" /></td>
</tr>
<tr class="fond1">
<td><u><b>ET / OU</b></u> Société <span class="important">*</span> :</td>
<td colspan="3"><input type="text" name="societe" size="45" value="<?php echo($societe); ?>" /></td>
</tr>
<tr class="fond2">
<td>Adresse :</td>
<td colspan="3"><input type="text" name="adresse" size="70" value="<?php echo($adresse); ?>" /></td>
</tr>
<tr class="fond1">
<td></td>
<td colspan="3"><input type="text" name="adresse2" size="70" value="<?php echo($adresse2); ?>" /></td>
</tr>
<tr class="fond2">
<td>Code postal</td>
<td><input type="text" name="codepostal" size="10" value="<?php echo($codepostal); ?>" /></td>
<td>Ville :</td>
<td><input type="text" name="ville" size="35" value="<?php echo($ville); ?>" /></td>
</tr>
<tr class="fond1">
<td>Pays :</td>
<td colspan="3"><input type="text" name="pays" size="25" value="<?php echo($pays); ?>" /></td>
</tr>
<tr class="fond2">
<td colspan="4"><input type="checkbox" class="cb" name="detail" id="detail" <?php if ($detail == 1) echo("checked=\"checked\""); ?> value="1" onclick="javascript: changeClientDetail();" /> Plus d'informations</td>
</tr>
</table>
</div>
<div id="clientDetail" style="display: <?php echo($display2); ?>;">
<table border="0" align="center" cellpadding="5" width="95%">
<tr class="titre">
<td colspan="4">Plus d'informations : </td>
</tr>
<tr class="fond1">
<td width="15%">Téléphone 1 :</td>
<td width="35%"><input type="text" name="tel" size="25" value="<?php echo($tel); ?>" /></td>
<td width="15%">Téléphone 2 :</td>
<td width="35%"><input type="text" name="tel2" size="25" value="<?php echo($tel2); ?>" /></td>
</tr>
<tr class="fond2">
<td>E-mail :</td>
<td><input type="text" name="email" size="30" value="<?php echo($email); ?>" /></td>
<td>Site Web :</td>
<td><input type="text" name="siteweb" size="30" value="<?php echo($siteweb); ?>" /></td>
</tr>
<tr class="fond1">
<td>Groupe :</td>
<td colspan="3"><select name="choixgrp[]" multiple="multiple" size="5" style="width: 350px;">
<?php
$r = mysql_query("select * from esf_clients_groupes order by titre;",$bdd2);
while($ligne = mysql_fetch_array($r))
{
$idgrp = $ligne["idgrp"];
$titregrp = $ligne["titre"];
echo("<option value=\"$idgrp\"");
if (in_array($idgrp,$choixgrp)) echo(" selected=\"selected\"");
echo(">$titregrp</option>");
}
?>
</select></td>
</tr>
</table>
</div>
<table border="0" align="center" cellpadding="5" width="95%">
<tr class="titre">
<td colspan="4">Ticket : </td>
</tr>
<!-- champ de texte probleme -->
<tr class="fond2">
<td>Problème :</td>
<td><textarea name="probleme" cols="45" rows="5"></textarea></td>
</tr>
<!-- champ de texte resolution -->
<tr class="fond1">
<td>Resolution :</td>
<td><textarea name="resolution" cols="45" rows="5"></textarea></td>
</tr>
<!-- liste déroulante pour les pc existants -->
<tr class="fond2"> <td>ordinateurs :
</td><td><a href="">Créer un nouvel ordinateur</a><br><br><select name="idmateriel">
<?php
$bdd = new PDO('mysql:host=localhost;dbname=projet-facturier', "root", 'root');
$reponse = $bdd->query("SELECT * FROM materiel where idclient = '.$idclient.'");
while ($donnees = $reponse->fetch()) {
?>
<option value="<?php echo $donnees['id'];?>"><?php echo $donnees['nom'], $donnees['processeur'];?></option>
<?php } ?>
</select></td></tr>
<!-- liste déroulante -->
<tr class="fond1">
<td>status : </td>
<td>
<select name="status" size="1">
<option>--Status--</option>
<option>en cours</option>
<option>en attente</option>
<option>clos</option>
</SELECT></td>
</tr>
<!-- bouton d'envoi -->
</table>
<div align="center" class="test"><input type="submit" name="submit" value="Créer" class="submit" /></div>
</form> |
Partager