-
Notifications
You must be signed in to change notification settings - Fork 0
/
myCurrentBorrows.php
72 lines (67 loc) · 2.1 KB
/
myCurrentBorrows.php
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
<?php require('sharedFiles/pageStart.inc.php'); ?>
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="author" content="Martin Desharnais">
<title><?php echo Application::APPLICATION_NAME; ?> - Mes emprunts en cours</title>
<?php include('sharedFiles/style.inc.php'); ?>
<?php include('sharedFiles/javascript.inc.php'); ?>
<script src="javascript/jquery/jquery.tablesorter.min.js"></script>
<script>
$(document).ready(function() {
$('table').tablesorter();
});
</script>
</head>
<body>
<?php require('sharedFiles/header.inc.php'); ?>
<div id="content">
<div>
<?php
if($application->currentUser->isVisitor())
{
echo '<h1>Erreur</h1>';
echo '<p>Vous devez être connectés pour consulter vos emprunts en cours.<p>';
}
else
{
echo '<h1>Mes emprunts en cours</h1>';
$query = $application->database->prepare('
SELECT medias.ID,
medias.titre,
emprunts.date_emprunt,
emprunts.duree
FROM medias
INNER JOIN emprunts ON medias.ID = emprunts.mediaID
WHERE emprunts.utilisateurID = ? AND emprunts.date_retour IS NULL AND emprunts.date_emprunt IS NOT NULL');
$query->execute(array($application->currentUser->getID()));
echo '<table>';
echo ' <thead>';
echo ' <tr>';
echo ' <th>Média</th>';
echo ' <th>Date d\'emprunt</th>';
echo ' <th>Date de retour</th>';
echo ' </tr>';
echo ' </thead>';
echo ' <tbody>';
foreach($query as $row)
{
$dateEmprunt = DateTime::createFromFormat('Y-m-d', $row['date_emprunt']);
$dateRetour = $dateEmprunt->add(new DateInterval('P'.$row['duree'].'D'));
echo ' <tr>';
echo ' <td><a href="media.php?id='.$row['ID'].'">'.$row['titre'].'</a></td>';
echo ' <td>'.$dateEmprunt->format('Y-m-d').'</td>';
echo ' <td>'.$dateRetour->format('Y-m-d').'</td>';
echo ' <td><a href="#">Renouveler</a></td>';
echo ' </tr>';
}
echo ' </tbody>';
echo '</table>';
}
?>
</div>
</div>
<?php require('sharedFiles/footer.inc.php'); ?>
</body>
</html>