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">
<div class="container-champ">
<p>Login:</p>
<div class="champ">
<div class="input">
<select class="entry" name="login">
<option value="prof">prof</option>
<option value="referant">Référant</option>
@ -18,12 +18,12 @@
</div>
<div class="container-champ">
<p>Pwd:</p>
<div class="champ">
<div class="input">
<input class="entry" type="password" name="pwd">
</div>
</div>
<div class="container-champ">
<div class="submit">
<div class="input" id="submit">
<input class="entry" type="submit" value="conexion">
</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 '</p>
<div class="champ">
<div class="input">
<input class="entry" type=',$type,' name=',$sql_name,'><br>
<img class="check" src="../img/check.png" alt="check">
<img class="excla" src="../img/excla.png" alt="exclamation">

14
prof/index.php

@ -15,7 +15,7 @@ include '../session.php';
<body id="page">
<?php
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">
@ -34,7 +34,7 @@ include '../session.php';
</div>
<div class="container-champ">
<p>Détails :</p>
<div class="champ">
<div class="input">
<textarea class="entry" rows="10" cols="30" name='details'></textarea><br>
<img class="check" src="../img/check.png" alt="check">
<img class="excla" src="../img/excla.png" alt="exclamation">
@ -85,7 +85,7 @@ include '../session.php';
</div>
<div class="container-champ">
<p>Matériel :</p>
<div class="champ">
<div class="input">
<select class="entry" name='materiel'>
<option value="UC">Unité Centrale</option>
<option value="IMP">Imprimante</option>
@ -132,9 +132,13 @@ include '../session.php';
$sql_name = 'nserie';
$type = 'text';
$error = "Vous n'avez saisie le n° de série";
$help = false;
$help = true;
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 class="container-champ">
<?php
@ -148,7 +152,7 @@ include '../session.php';
</div>
<div class="container-champ">
<br>
<div class="submit">
<div class="input" id="submit">
<input class="entry" type="submit" value="Valider">
</div>
</div>

12
referant/cible/search.php

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

6
referant/export.php

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

10
referant/include/line.php

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

5
referant/index.php

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

2
referant/js/edit.js

@ -20,7 +20,7 @@ function Slider(id) {
};
xhr.open('POST', 'cible/slider.php', true);
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) {

55
referant/js/search.js

@ -1,25 +1,38 @@
const ticket = document.getElementsByClassName('ticket');
var tr = '';
document.getElementById('form').addEventListener('submit', function(e) {
e.preventDefault();
// try {
// while (document.getElementsByName('tr')) {
// document.getElementsByName('tr')[0].remove();
// }
// } catch (e) {
//
// }
let data = new FormData(this);
console.log(data);
let xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if (this.response != false) {
console.log(this.response);
for (let i=0; i < 11; i++) {
ticket[i].textContent = this.response[i];
}
if (this.response[11] == 1) {
ticket[11].querySelector('img').src = "../img/check.png";
}
else {
ticket[11].querySelector('img').src = "../img/excla.png";
}
document.getElementsByTagName('table')[0].style.display = 'block';
this.response.forEach((item, i) => {
console.log(push_line(item[0]));
console.log('salut' + tr);
document.getElementsByTagName('tbody')[0].innerHTML = tr;
let ticket = document.getElementsByClassName("'" + item[0] + "'");
console.log(ticket);
for (let i=0; i < 11; i++) {
ticket[i].textContent = item[i];
}
if (item[11] == 1) {
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 {
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.responseType = 'json';
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'>
<?php include 'include/nav.php'; ?>
<form id="form" action="js/search.php" method="POST">
<div class="champ">
<input class="entry" type="input" name="id">
<div class="container-champ">
<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 class="submit">
<input id="submit" class="entry" type="submit">
<div class="container-champ">
<p>mot clé :</p><br>
<div class="input">
<input class="entry" type="input" name="value">
</div>
</div>
<div class="container-champ">
<div class="input" id="submit">
<input class="entry" type="submit">
</div>
</div>
</form>
<table style="display: none;">
<thead>

Loading…
Cancel
Save