<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "
http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta content="text/html; charset=utf-8" http-equiv="content-type">
<title>OutilsDeux</title>
<meta content="IP Pourrieres" name="author">
<link rel="icon" href="Logo.ico">
</head><body style="background-image: url(Images/Fond1.jpg);">
<div style="text-align: center;"><big><big><big><span style="color: white;">Bibliothèque
JLM</span></big></big></big><br>
</div>
[/html]
<?php // On prolonge la session
session_start();
//$_SESSION['pseudo'] = $Pseudo; // la session peut �tre appel�e diff�remment et son contenu aussi peut �tre autre chose que le pseudo
//$_SESSION['password']=$MotDePasse;
// On teste si la variable de session existe et contient une valeur
if(empty($_SESSION['pseudo']) && empty($_SESSION['password']))
//if(empty($_SESSION['pseudo']) && (empty($_SESSION['password']))
{
// Si inexistante ou nulle, on redirige vers le formulaire de login
// On d�marre la session
session_start ();
// On d�truit notre session
session_destroy ();
// On redirige le visiteur vers la page d'accueil
header ('location: index.php');
exit();
}
?>
<div style="text-align: center;">
<form method="post" action="outilsdeux.php" name="form_outils"><font style="color: white;" size="+3"><span style="font-family: Calibri;"> </span></font>
<font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1">Opérations Base de
Données </font></span></font>
<table style="text-align: left; height: 44px; width: 474px; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr align="center">
<td style="vertical-align: top; width: 331px; height: 22px;"><font style="color: white;" size="+3"><font size="+1">Enregistrer un Nouveau
Prêt</font></font></td>
</tr>
<tr align="center">
<td style="vertical-align: top; width: 331px; height: 16px;"><font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1">Créer Fichier Export pour Logiciel Bibliothèque<br>
</font></span></font></td>
</tr>
</tbody>
</table>
<br>
<font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1"> </font></span></font>
<table style="text-align: left; width: 1014px; margin-left: auto; margin-right: auto; height: 80px;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<th style="width: 388px; text-align: center; color: rgb(0, 0, 153); font-weight: bold; background-color: rgb(255, 255, 153);">Titre<br>
</th>
<th style="width: 187px; text-align: center; color: rgb(0, 0, 153); font-weight: bold; background-color: rgb(255, 255, 153);">Auteur<br>
</th>
<th style="width: 131px; text-align: center; color: rgb(0, 0, 153); font-weight: bold; background-color: rgb(255, 255, 153);">Année<br>
</th>
<th style="width: 125px; text-align: center; color: rgb(0, 0, 153); font-weight: bold; background-color: rgb(255, 255, 153);">Date
Emprunt<br>
</th>
<th style="width: 141px; text-align: center; color: rgb(0, 0, 153); font-weight: bold; background-color: rgb(255, 255, 153);">Date
Retour Théorique<br>
</th>
</tr>
<tr>
<td style="vertical-align: top; width: 388px; text-align: center; height: 28px;"><textarea cols="0" rows="1" name="txttitre"></textarea><br>
</td>
<td style="vertical-align: top; width: 187px; text-align: center; height: 28px;"><textarea cols="0" rows="1" name="txtauteur"></textarea> </td>
<td style="vertical-align: top; width: 131px; text-align: center; height: 28px;"><textarea title="Année sur 4 chiffres Ex 2016" cols="0" rows="1" name="txtannee"></textarea>
</td>
<td style="vertical-align: top; width: 125px; text-align: center; height: 28px;"><textarea title="Format de Date : 01/01/2016" cols="0" rows="1" name="txtdatepret"></textarea> </td>
<td style="vertical-align: top; width: 141px; text-align: center; height: 28px;"><textarea cols="0" rows="1" name="txtdateretour"></textarea> </td>
</tr>
</tbody>
</table>
<font style="color: white;" size="+3"><span style="font-family: Calibri;"><input name="cmb_valider" input="" value="Enregistrer le nouveau Prêt" type="submit"></span></font><br>
<br>
<?php if (isset($_POST['cmb_valider']))
{
if (empty($_POST['txttitre']) || empty($_POST['txtauteur']) || empty($_POST['txtannee']) || empty($_POST['txtdatepret']) || empty($_POST['txtdateretour']))
{
echo "ERREUR : tous les champs n'ont pas ete renseignés.";
}
else
{
//echo "C'est bon : tous les champs ont ete renseignés.";
// Create connection
$conn = new mysqli('xxxxxx''xxxxx'xxxxx');
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
//Nombre jours � ajouter
$datedin=28;
$datepret=$_POST["txtdatepret"];
$datefin = date('Y-m-d', strtotime($Datepret.' +'.$datefin.' days'));
echo "Date Retour Calcule : " .$datefin;
$dateretour=$datefin;
//$dateretour = implode("-", array_reverse(explode("/", $datecalcule)));
//$datepret = implode("-", array_reverse(explode("/", $_POST["txtdatepret"])));
$sql = "INSERT INTO emprunts(emp_titre, emp_auteur, emp_annee, emp_datepret, emp_dateretour) VALUES ('$_POST[txttitre]','$_POST[txtauteur]','$_POST[txtannee]','$datepret','$dateretour')";
if ($conn->query($sql) === TRUE)
{
echo "L'emprunt est correctement enregisté";
}
else
{
echo "Erreur: " . $sql . "<br>" . $conn->error;
}
$conn->close();
}
}
?>
</form>
<form method="post" action="outilsdeux.php" name="form_rendre">
<table style="text-align: left; width: 1536px; height: 140px; margin-left: auto; margin-right: auto;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: middle; text-align: center;">
<select name="combolivre">
<option value="Choisissez un Titre">Choisissez un Titre</option>
<?php $bdd = mysqli_connect('xx', 'xxx', 'xx', 'xxx');
$Requete = mysqli_query($bdd,"SELECT emp_titre FROM emprunts order by emp_titre");
while ($data = mysqli_fetch_assoc($Requete))
{
echo '<option>'.$data["emp_titre"].'</option><br/>';
}
mysqli_free_result($Requete);
echo "</select><p></p><input type='submit' value='Valider ce Titre'><br>";
?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: center;"> <font style="color: white;" size="+3"><font size="+1">
<?php $titre=$_POST['combolivre'];
//if(empty($titre))
//{
//echo("<center>Le '<b>Titre</b>' est vide !</center>");
//exit();
//}
$bdd = mysqli_connect('xxx', 'xxx', 'xxx', 'xxxx');
$Requete = mysqli_query($bdd,"SELECT emp_titre, emp_auteur, emp_annee, date_format(emp_datepret, '%d/%m/%Y') as datedupret, date_format(emp_dateretour, '%d/%m/%Y') as dateduretour FROM emprunts where emp_titre='$titre'");
while ($data = mysqli_fetch_assoc($Requete))
{
$titreselect=$data['emp_titre'];
$auteurselect=$data['emp_auteur'];
echo " Titre : ".$data['emp_titre']. " TitreSelect = ".$titreselect.'<br>';
echo " Auteur : ".$data['emp_auteur']." AuteurSelect = ".$auteurselect.'<br>';
echo " Année : " .$data['emp_annee'].'<br>';
echo " Date Emprunt : " .$data['datedupret'].'<br>';
echo " Date Retour prévue : " .$data['dateduretour'].'<br></tr></td>';
}
mysqli_free_result($Requete);
?>
<?php
function AfficheVariables()
{ // début de la fonction AffichePrenom
global $titreselect ; // déclaration de la variable en accès global pour cette fonction
global $auteurselect ;
echo "La variable contient le Titre $titreselect" ; // affiche le contenu de la variable
} // fin de la fonction AffichePrenom
?>
<br>
</font></font></td>
</tr>
<tr>
<td style="vertical-align: middle; text-align: center;"><input name="cmb_rendre" input="" value="Restituer ce Livre" type="submit"><font style="color: white;" size="+3"><span style="font-family: Calibri;"></span></font><a><font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1"> </font></span></font></a></td>
</tr>
</tbody>
</table>
<?php
if (isset($_POST['cmb_rendre']))
{
AfficheVariables();
//echo "Titre Selectionne : ".$titreselect;
//echo "Auteur Selectionne : ".$auteurselect;
// Create connection
$conn = new mysqli('xxxx', 'xxxxx', 'xxxxx', 'xxxx');
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
$bdd = mysqli_connect('xxxxxx', 'xxxx', 'xxxx', 'xxxx');
//$Requete = mysqli_query($bdd,"UPDATE emprunts set emp_dateretour= UTC_DATE() where emp_titre='$titre' and emp_auteur='$auteur'");
//if ($conn->query($Requete) === TRUE)
//{
//echo "L'emprunt est correctement enregisté";
//}
//else
//{
//echo "Erreur: " . $sql . "<br>" . $conn->error;
//}
$conn->close();
}
?>
<font style="color: white;" size="+3"><br>
<span style="font-family: Calibri;"></span></font> <a><font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1"><br>
<br>
</font> </span> <font style="color: white;" size="+3"><span style="font-family: Calibri;"></span></font></font></a> <font style="color: white;" size="+3"><font style="color: white;" size="+3"><font size="+1"><font><font><a><font style="color: white;" size="+3"> <font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1"> <font style="color: white;" size="+3"><span style="font-family: Calibri;"><input name="cmb_ExportPret" input="" value="Créer Fichier Export des Prêts" type="submit"></span></font></font></span></font></font></a></font><br>
<br>
<font style="color: white;" size="+3"><font size="+1"><a><font style="color: white;" size="+3"><span style="font-family: Calibri;"></span></font></a>
<font style="color: white;" size="+3"><font size="+1"> <br>
</font></font></font></font>
<table style="text-align: left; width: 343px; height: 32px; margin-left: auto; margin-right: auto; background-color: rgb(204, 204, 204);" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: middle; text-align: center;"><big><font style="color: white; font-weight: bold;"><span style="font-family: Calibri;"></span></font> </big><ahref="consultation.php" target="_top"><a href="consultation.php" target="_top"><span style="color: rgb(51, 51, 255);">Retour Page Consultation</span></a><br>
</ahref="consultation.php"></td>
</tr>
</tbody>
</table>
<a> </a> <font style="color: white;" size="+3"><font size="+1"> <a>
<span style="text-decoration: underline;"></span><br>
<big> <font style="color: white; font-weight: bold;"><span style="font-family: Calibri;">(c) IP - Pourrières 2016</span></font> </big>
</a><br>
<font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1"> <br>
</font></span></font><a> <br>
<font style="color: white;" size="+3"><span style="font-family: Calibri;"><font size="+1"><font style="color: white;" size="+3"><span style="font-family: Calibri;"></span></font>
</font> </span> </font> <br>
<font style="color: white;" size="+3"><span style="font-family: Calibri;"> <br>
</span> </font></a> </font> </font> </font> </font> </font> </font><font style="color: white;" size="+3"><font style="color: white;" size="+3"><font size="+1"><font> <font style="color: white;" size="+3"><font size="+1"><font style="color: white;" size="+3"><font size="+1"> </font></font> </font>
</font> </font> </font> </font> </font></form>
</div>
</body></html>