Browse Source

prbl search

master
BARRAUX Arthur 3 years ago
parent
commit
72cd1fdfce
  1. BIN
      font/raleway.ttf
  2. BIN
      img/voile.JPG
  3. 6
      login/index.php
  4. 2
      prof/include/champ.php
  5. 14
      prof/index.php
  6. 12
      referant/cible/search.php
  7. 6
      referant/export.php
  8. 10
      referant/include/line.php
  9. 5
      referant/index.php
  10. 2
      referant/js/edit.js
  11. 55
      referant/js/search.js
  12. 33
      referant/search.php

BIN
font/raleway.ttf

Binary file not shown.

BIN
img/voile.JPG

Binary file not shown.

After

Width:  |  Height:  |  Size: 87 KiB

6
login/index.php

@ -9,7 +9,7 @@
<form id='form' action="cible.php" method="post"> <form id='form' action="cible.php" method="post">
<div class="container-champ"> <div class="container-champ">
<p>Login:</p> <p>Login:</p>
<div class="champ"> <div class="input">
<select class="entry" name="login"> <select class="entry" name="login">
<option value="prof">prof</option> <option value="prof">prof</option>
<option value="referant">Référant</option> <option value="referant">Référant</option>
@ -18,12 +18,12 @@
</div> </div>
<div class="container-champ"> <div class="container-champ">
<p>Pwd:</p> <p>Pwd:</p>
<div class="champ"> <div class="input">
<input class="entry" type="password" name="pwd"> <input class="entry" type="password" name="pwd">
</div> </div>
</div> </div>
<div class="container-champ"> <div class="container-champ">
<div class="submit"> <div class="input" id="submit">
<input class="entry" type="submit" value="conexion"> <input class="entry" type="submit" value="conexion">
</div> </div>
</div> </div>

2
prof/include/champ.php

@ -4,7 +4,7 @@ if ($help) {
echo '<a class="int" href="#" onmouseover=displayHelp(',$sql_name,') onmouseout=hideHelp(',$sql_name,') ><img src="../img/int.png" alt="point_int" width=20px ></a>'; echo '<a class="int" href="#" onmouseover=displayHelp(',$sql_name,') onmouseout=hideHelp(',$sql_name,') ><img src="../img/int.png" alt="point_int" width=20px ></a>';
} }
echo '</p> echo '</p>
<div class="champ"> <div class="input">
<input class="entry" type=',$type,' name=',$sql_name,'><br> <input class="entry" type=',$type,' name=',$sql_name,'><br>
<img class="check" src="../img/check.png" alt="check"> <img class="check" src="../img/check.png" alt="check">
<img class="excla" src="../img/excla.png" alt="exclamation"> <img class="excla" src="../img/excla.png" alt="exclamation">

14
prof/index.php

@ -15,7 +15,7 @@ include '../session.php';
<body id="page"> <body id="page">
<?php <?php
if ($_SESSION['login'] == 'referant') { if ($_SESSION['login'] == 'referant') {
echo '<a class="champ" href="../referant/index.php">site référant</a>'; echo '<a class="input" href="../referant/index.php">site référant</a>';
} }
?> ?>
<h1 id="titre"> <h1 id="titre">
@ -34,7 +34,7 @@ include '../session.php';
</div> </div>
<div class="container-champ"> <div class="container-champ">
<p>Détails :</p> <p>Détails :</p>
<div class="champ"> <div class="input">
<textarea class="entry" rows="10" cols="30" name='details'></textarea><br> <textarea class="entry" rows="10" cols="30" name='details'></textarea><br>
<img class="check" src="../img/check.png" alt="check"> <img class="check" src="../img/check.png" alt="check">
<img class="excla" src="../img/excla.png" alt="exclamation"> <img class="excla" src="../img/excla.png" alt="exclamation">
@ -85,7 +85,7 @@ include '../session.php';
</div> </div>
<div class="container-champ"> <div class="container-champ">
<p>Matériel :</p> <p>Matériel :</p>
<div class="champ"> <div class="input">
<select class="entry" name='materiel'> <select class="entry" name='materiel'>
<option value="UC">Unité Centrale</option> <option value="UC">Unité Centrale</option>
<option value="IMP">Imprimante</option> <option value="IMP">Imprimante</option>
@ -132,9 +132,13 @@ include '../session.php';
$sql_name = 'nserie'; $sql_name = 'nserie';
$type = 'text'; $type = 'text';
$error = "Vous n'avez saisie le n° de série"; $error = "Vous n'avez saisie le n° de série";
$help = false; $help = true;
include("include/champ.php"); include("include/champ.php");
?> ?>
<div class="help" id="nserie">
<img src="../img/voile.JPG" alt="voile"> <br>
<code>Ex: bâtiment A</code>
</div>
</div> </div>
<div class="container-champ"> <div class="container-champ">
<?php <?php
@ -148,7 +152,7 @@ include '../session.php';
</div> </div>
<div class="container-champ"> <div class="container-champ">
<br> <br>
<div class="submit"> <div class="input" id="submit">
<input class="entry" type="submit" value="Valider"> <input class="entry" type="submit" value="Valider">
</div> </div>
</div> </div>

12
referant/cible/search.php

@ -2,13 +2,13 @@
$bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', ''); $bdd = new PDO('mysql:host=localhost;dbname=ticket;charset:utf8', 'root', '');
try { try {
$reponse = $bdd->query("SELECT * FROM pannes WHERE ID=" .$_POST['id']); $reponse = $bdd->query("SELECT * FROM pannes WHERE `" .$_POST['champ'] ."`='" .$_POST['value'] ."'");
$line = $reponse -> fetch(); $result = [];
while ($line = $reponse->fetch()) {
array_push($result, $line);
};
print_r(json_encode($result));
$result = json_encode($line);
print_r($result);
} catch (Exception) { } catch (Exception) {
echo false; echo false;
} }

6
referant/export.php

@ -13,7 +13,7 @@ include '../session_restraintes.php';
<form id='form' action="cible/export.php" method="post"> <form id='form' action="cible/export.php" method="post">
<div class="container-champ"> <div class="container-champ">
<p>Type:</p> <p>Type:</p>
<div class="champ"> <div class="input">
<select class="entry" name="type"> <select class="entry" name="type">
<option value="csv">CSV</option> <option value="csv">CSV</option>
<!-- <option value="sql">SQL</option> --> <!-- <option value="sql">SQL</option> -->
@ -22,7 +22,7 @@ include '../session_restraintes.php';
</div> </div>
<div class="container-champ"> <div class="container-champ">
<p>Base:</p> <p>Base:</p>
<div class="champ"> <div class="input">
<select class="entry" name="bdd"> <select class="entry" name="bdd">
<option value="pannes">pannes</option> <option value="pannes">pannes</option>
<option value="logins">logins</option> <option value="logins">logins</option>
@ -30,7 +30,7 @@ include '../session_restraintes.php';
</div> </div>
</div> </div>
<div class="container-champ"> <div class="container-champ">
<div class="submit"> <div class="input" id="submit">
<input class="entry" type="submit" value="Download"> <input class="entry" type="submit" value="Download">
</div> </div>
</div> </div>

10
referant/include/line.php

@ -1,4 +1,8 @@
<?php <?php
if (isset($_POST['class'])) {
$class = $_POST['class'];
}
if (isset($line)) { if (isset($line)) {
echo '<tr> echo '<tr>
<td class=', $class , ' style="font-weight: bold;" >',$class,'</td> <td class=', $class , ' style="font-weight: bold;" >',$class,'</td>
@ -14,10 +18,10 @@ if (isset($line)) {
<td class=', $class , '>',$line[10],'</td>'; <td class=', $class , '>',$line[10],'</td>';
if ($line[11] == 1) { if ($line[11] == 1) {
echo '<td class=', $class , '><img src="../img/check.png" width="40%"></td>'; echo '<td class=', $class , '><img src="../img/check.png"></td>';
} }
else { else {
echo '<td class=', $class , '><img src="../img/excla.png" width="40%"></td>'; echo '<td class=', $class , '><img src="../img/excla.png" ></td>';
} }
@ -44,7 +48,7 @@ else {
<td class=', $class , '></td> <td class=', $class , '></td>
<td class=', $class , '></td> <td class=', $class , '></td>
<td class=', $class , '></td> <td class=', $class , '></td>
<td class=', $class , '><img src="../img/check.png" width="40%"></td> <td class=', $class , '><img src="../img/check.png"></td>
<td class=', $class , '> <td class=', $class , '>
<label class="switch"> <label class="switch">
<input class="checkbox" type="checkbox" onchange="Slider(\'',$class,'\')"> <input class="checkbox" type="checkbox" onchange="Slider(\'',$class,'\')">

5
referant/index.php

@ -9,7 +9,7 @@ include '../session_restraintes.php';
</head> </head>
<body> <body>
<a class="champ" href="../prof/index.php">client</a> <a class="input" href="../prof/index.php">client</a>
<?php include 'include/nav.php'; ?> <?php include 'include/nav.php'; ?>
<script type="text/javascript" src="js/edit.js" defer></script> <script type="text/javascript" src="js/edit.js" defer></script>
<table id="table"> <table id="table">
@ -46,6 +46,9 @@ include '../session_restraintes.php';
$class = $line[0]; $class = $line[0];
include 'include/line.php'; include 'include/line.php';
} }
else {
$j--;
}
} }
$reponse->closeCursor(); $reponse->closeCursor();
?> ?>

2
referant/js/edit.js

@ -20,7 +20,7 @@ function Slider(id) {
}; };
xhr.open('POST', 'cible/slider.php', true); xhr.open('POST', 'cible/slider.php', true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("is_checked=" + encodeURI(is_checked) + "&id=" + encodeURI(td[1].textContent)); xhr.send("is_checked=" + encodeURI(is_checked) + "&id=" + encodeURI(td[0].textContent));
} }
function Edit(clas) { function Edit(clas) {

55
referant/js/search.js

@ -1,25 +1,38 @@
const ticket = document.getElementsByClassName('ticket'); var tr = '';
document.getElementById('form').addEventListener('submit', function(e) { document.getElementById('form').addEventListener('submit', function(e) {
e.preventDefault(); e.preventDefault();
// try {
// while (document.getElementsByName('tr')) {
// document.getElementsByName('tr')[0].remove();
// }
// } catch (e) {
//
// }
let data = new FormData(this); let data = new FormData(this);
console.log(data);
let xhr = new XMLHttpRequest(); let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() { xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) { if (this.readyState == 4 && this.status == 200) {
if (this.response != false) { if (this.response != false) {
console.log(this.response); this.response.forEach((item, i) => {
for (let i=0; i < 11; i++) { console.log(push_line(item[0]));
ticket[i].textContent = this.response[i]; console.log('salut' + tr);
} document.getElementsByTagName('tbody')[0].innerHTML = tr;
if (this.response[11] == 1) { let ticket = document.getElementsByClassName("'" + item[0] + "'");
ticket[11].querySelector('img').src = "../img/check.png"; console.log(ticket);
} for (let i=0; i < 11; i++) {
else { ticket[i].textContent = item[i];
ticket[11].querySelector('img').src = "../img/excla.png"; }
} if (item[11] == 1) {
document.getElementsByTagName('table')[0].style.display = 'block'; ticket[11].querySelector('img').src = "../img/check.png";
}
else {
ticket[11].querySelector('img').src = "../img/excla.png";
}
document.getElementsByTagName('table')[0].style.display = 'block';
});
} }
else { else {
alert("Ce ticket n'existe pas"); alert("Ce ticket n'existe pas");
@ -31,5 +44,19 @@ document.getElementById('form').addEventListener('submit', function(e) {
xhr.open('POST', 'cible/search.php', true); xhr.open('POST', 'cible/search.php', true);
xhr.responseType = 'json'; xhr.responseType = 'json';
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("id=" + encodeURI(data.get('id'))); xhr.send("champ=" + encodeURI(data.get('champ')) + "&" + "value=" + encodeURI(data.get('value')));
}); });
function push_line(clas) {
let xhr = new XMLHttpRequest();
xhr.open('POST', 'include/line.php', true);
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
tr = this.response;
console.log(tr);
return tr;
}
}
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send("class=" + encodeURI(clas));
}

33
referant/search.php

@ -13,12 +13,37 @@ include '../session_restraintes.php';
<body id='corps'> <body id='corps'>
<?php include 'include/nav.php'; ?> <?php include 'include/nav.php'; ?>
<form id="form" action="js/search.php" method="POST"> <form id="form" action="js/search.php" method="POST">
<div class="champ"> <div class="container-champ">
<input class="entry" type="input" name="id"> <p>Recherche :</p><br>
<div class="input">
<select class="entry" name='champ'>
<option value="ID">ID</option>
<option value="dates">Date</option>
<option value="lieu">Lieu</option>
<option value="salle">Salle</option>
<option value="materiel">Matériel</option>
<option value="marque">Marque</option>
<option value="model">Modèle</option>
<option value="nserie">N°Série</option>
<option value="demandeur">Demandeur</option>
</select>
<img class="check" src="../img/check.png" alt="check">
<img class="excla" src="../img/excla.png" alt="exclamation">
</div>
</div> </div>
<div class="submit"> <div class="container-champ">
<input id="submit" class="entry" type="submit"> <p>mot clé :</p><br>
<div class="input">
<input class="entry" type="input" name="value">
</div>
</div> </div>
<div class="container-champ">
<div class="input" id="submit">
<input class="entry" type="submit">
</div>
</div>
</form> </form>
<table style="display: none;"> <table style="display: none;">
<thead> <thead>

Loading…
Cancel
Save