-
Notifications
You must be signed in to change notification settings - Fork 1
/
checkin.php
98 lines (77 loc) · 4.95 KB
/
checkin.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
<?php include('header.php');?>
<body class="checkinpage">
<?php include('nav.php');?>
<?php
//grabs the first note and ties the customer and transactions ID together
$lastquery = mysqli_query($connection,"SELECT logged_info.tid,logged_info.date_sent,logged_info.cid,products.name,customers.name,products.protected,logged_info.note,logged_info.location FROM products INNER JOIN logged_info ON logged_info.selected_product=products.id JOIN customers ON customers.cid=logged_info.cid WHERE date_returned = '' AND products.protected = 'yes' AND logged_info.location = 1 ORDER BY logged_info.tid DESC");
//Checkin note for the transaction.
$theNewNote = mysqli_real_escape_string($connection, $_POST['secondNote']);
//Show me what product is selected in the database for the row
$chosen_product = mysqli_query($connection, "SELECT logged_info.note,logged_info.selected_product,logged_info.tid,products.id,products.name FROM logged_info INNER JOIN products ON logged_info.selected_product=products.id WHERE date_returned = '' AND products.protected = 'yes' AND logged_info.location = 1 ORDER BY tid DESC");
//Show me everything in the database that does not have a return stamp
$checkin = mysqli_query($connection,"SELECT logged_info.tid,logged_info.date_sent,logged_info.cid,products.name,customers.name,products.protected,logged_info.note,logged_info.location FROM logged_info INNER JOIN products ON logged_info.selected_product=products.id JOIN customers ON customers.cid=logged_info.cid WHERE date_returned = '' AND products.protected = 'yes' AND logged_info.location = 1 ORDER BY tid DESC");
//Show me the notes associated with returned row
$checkinNotes = mysqli_query($connection,"SELECT logged_info.tid,logged_info.note,logged_info.note2 FROM logged_info INNER JOIN customers ON logged_info.cid=customers.cid JOIN products ON logged_info.selected_product=products.id WHERE date_returned = '' AND products.protected = 'yes' ORDER BY logged_info.tid DESC");
//Count how many items are not checked in.
$number_of_items = mysqli_query($connection, "SELECT COUNT(*) FROM logged_info INNER JOIN products ON logged_info.selected_product=products.id WHERE date_returned='' AND products.protected = 'yes' AND logged_info.location = 1 ");
$number_of_items_displayed = mysqli_fetch_array($number_of_items);
$last3 = mysqli_query($connection, "SELECT logged_info.date_returned,customers.name,logged_info.cid FROM logged_info INNER JOIN customers ON customers.cid=logged_info.cid WHERE date_returned != '' AND logged_info.location = 1 ORDER BY date_returned DESC LIMIT 3");
$chosen_product_for_3 = mysqli_query($connection, "SELECT logged_info.selected_product,products.name,products.id FROM logged_info INNER JOIN products ON products.id=logged_info.selected_product WHERE date_returned != '' AND logged_info.location = 1 AND products.protected = 'yes' ORDER BY date_returned DESC LIMIT 3");
echo "<div class='last3'>Last 3 items checked in";
echo "<table>";
while ($row = mysqli_fetch_array($last3)) {
echo "<tr><td>" . $row['date_returned'] . "</td>";
echo "<td><a href=\"customers.php?cid=" . $row['cid'] . "\">" . $row['name'] . "</a></td>"; ?>
<?php
if ($row = mysqli_fetch_array($chosen_product_for_3)) {
echo "<td class='product'>" . $row['name'] . "</td>";
}
};
echo "</table></div>";
?>
<?php
echo "<div class='last3'>There are " . $number_of_items_displayed[0] . " items to be checked in.</div>";
?>
<?php while ($row = mysqli_fetch_array($checkin)) { ?>
<div class="container" id="<?php echo $row['tid'] ?>">
<div>
<table>
<tr>
<td class="current"><?php echo $row['date_sent']; ?></td>
<td class="current"><?php echo "<a href=\"customers.php?cid=" . $row['cid'] . "\">" . $row['name'] . "</a></td>"; ?>
<td class="product"><?php if ($row = mysqli_fetch_array($chosen_product)) { echo "<a href=\"results.php?id=" . $row['id'] ."\">". $row['name'] . "</a>"; }; ?></td>
</tr>
</table>
</div>
<?php if ($row = mysqli_fetch_array($lastquery)) { ?>
<table>
<tr>
<td><?php echo $row['note']; ?></td>
</tr>
</table>
<form action="checkindate.php?" method="GET" name="checkindata" class="checkindata" >
<textarea placeholder="Checkin Note..." name="secondNote"></textarea>
<input type="text" class="firmware" placeholder="Firmware Version" name="date_code"/> |
<input type="text" class="date_code" placeholder="Date Code" name="firmware"/>|
Re-usable?
<input type="radio" name="reuse" value="1" />Yes
<input type="radio" name="reuse" value="2" />No
<?php
echo "<br /><br />";
echo "Issue: ";
$issues = mysqli_query($connection, "SELECT id,issue FROM issues");
echo "\n<select name=\"issues\">\n";
while($issue = mysqli_fetch_array($issues)){
echo "\t<option value=\"". $issue["issue"] . "\" >". $issue["issue"] . "</option>\n";
}
echo "</select>\n";
?>
<input type="hidden" name="id" value="<?php echo $row['tid'] ?>">
<span class="movesubmit"><input type="submit" class="checkinsubmit"></span>
</form>
<?php }; ?>
</div>
<?php }; ?>
</body>
</html>