-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstorico_ordini.php
185 lines (141 loc) · 4.99 KB
/
storico_ordini.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
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
<?php
require_once('config.php');
session_start();
$per_page_record = 10; // Number of entries to show in a page.
// Look for a GET variable page if not found default is 1.
if (isset($_GET["page"])) {
$page = $_GET["page"];
}
else {
$page=1;
}
$start_from = ($page-1) * $per_page_record;
$select_borrow_data = "SELECT max(idcliente) as idcliente, max(datains) as datains, max(returndate) as returndate, numord, max(status) as status FROM ordini GROUP BY numord ORDER BY numord DESC LIMIT $start_from, $per_page_record";
$select_borrow_data_result = mysqli_query($db, $select_borrow_data);
?>
<!doctype html>
<html>
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap-color.min.css" >
<!-- Additional CSS -->
<link rel="stylesheet" href="css/main.css" >
<title>Storico ordini</title>
</head>
<body>
<?php include('header.php'); ?>
</br>
<div class="container">
<div class="row">
<div class="col-12">
<table class="table" >
<thead class="thead-dark">
<tr>
<th scope="col">Ordine</th>
<th scope="col">Cliente</th>
<th scope="col">Data inizio</th>
<th scope="col">Data restituzione</th>
<th scope="col">Stato</th>
<th scope="col">Azioni</th>
</tr>
</thead>
<tbody>
<?php
while ($row = mysqli_fetch_array($select_borrow_data_result)) {
$userid = $row['idcliente'];
$select_all_users = "SELECT * FROM users WHERE id = '$userid' ORDER BY id DESC LIMIT 1";
$select_all_user_result = mysqli_query($db, $select_all_users);
$row_users = mysqli_fetch_assoc($select_all_user_result);
$user_name = $row_users['username'];
// $user_nic = $row_users['nic'];
// Display each field of the records.
?>
<tr>
<td><?php echo $row['numord']; ?></td>
<td><?php echo $user_name; ?></td>
<td><?php echo $row['datains']; ?></td>
<td><?php echo $row['returndate'];
$today = date('Y-m-d');
$returnday = $row['returndate'];
$datetime1 = strtotime($today);
$datetime2 = strtotime($returnday);
$calculate_seconds = $datetime2 - $datetime1;// == <seconds between the two times>
$days = floor($calculate_seconds / (24 * 60 * 60 ));
if($days < 0){
?> <span class="badge badge-danger"> Scaduto </span> <?php
}else{
?> <span class="badge badge-success"> In Corso </span> <?php
}
?></td>
<td> <?php
if($row['status'] == 'finish'){
?> <span class="badge badge-success"> Finito </span> <?php
}else{
?> <span class="badge badge-warning"> Attivo </span> <?php
}
?> </td>
<?php
if($row_borrow_data['status'] != 'finish'){
?> <td align="center"> <a class="btn btn-dark btn-sm" href="fine_noleggio.php?numord=<?php echo $row['numord']; ?>" role="button">Dettaglio</a> </td> <?php
} else {
?> <td align="center"> <a class="btn btn-dark btn-sm" href="fine_noleggio.php?numord=<?php echo $row['numord']; ?>" role="button">Dettaglio</a> </td> <?php
}
?>
</tr>
<?php
};
?>
</tbody>
</table>
</div>
</div>
</br>
<div class="pagination" style="display: flex;justify-content: center;align-items: center;">
<?php
$query = "SELECT COUNT(*) FROM ordini";
$rs_result = mysqli_query($db, $query);
$row = mysqli_fetch_row($rs_result);
$total_records = $row[0];
echo "</br>";
// Number of pages required.
$total_pages = ceil($total_records / $per_page_record);
$pagLink = "";
if($page>=2){
echo "<a href='storico_ordini.php?page=".($page-1)."'> Precedente </a>";
}
for ($i=1; $i<=$total_pages; $i++) {
if ($i == $page) {
$pagLink .= "<a class = 'active' href='storico_ordini.php?page="
.$i."'>".$i." </a>";
}
else {
$pagLink .= "<a href='storico_ordini.php?page=".$i."'>
".$i." </a>";
}
};
echo $pagLink;
if($page<$total_pages){
echo "<a href='storico_ordini.php?page=".($page+1)."'> Successivo </a>";
}
?>
</div>
</br>
</br>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="js/jquery-3.2.1.slim.min.js"></script>
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>