-
Notifications
You must be signed in to change notification settings - Fork 0
/
set_checkoutdate.php
65 lines (51 loc) · 1.31 KB
/
set_checkoutdate.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
<?
include_once(dirname(__FILE__) . "/first.php");
$checkout_ID = urldecode($query[0]);
$new_datetime = urldecode($query[1]);
if(! $_SESSION['library_account_ID'])
{
exit_error("Not Signed In", "You must be signed into perform that action.");
}; // end if
if(! $db->is_librarian_account)
{
exit_error("Access Denied", "Only a librarian can perform that action.");
}; // end if
$checkout_sql = "
SELECT
*
FROM
`" . $db->table_library_checkout . "`
WHERE
`ID`='" . $checkout_ID . "'
";
$checkout_result = mysql_query($checkout_sql, $mysql->link);
$checkout_record = mysql_fetch_object($checkout_result);
$patron_sql = "
SELECT
*
FROM
`" . $db->table_account . "`
WHERE
`ID`='" . $checkout_record->{$db->field_account_ID} . "'
";
$patron_result = mysql_query($patron_sql, $mysql->link);
$patron_record = mysql_fetch_object($patron_result);
$due_date = date("Y-m-d 23:59:59", strtotime($new_datetime) + (60 * 60 * 24 * $patron_record->library_checkout_length_read));
$sql = "
UPDATE
`" . $db->table_library_checkout . "`
SET
`out_datetime`='" . mysql_escape_string($new_datetime) . "',
`due_datetime`='" . $due_date . "'
WHERE
`ID`='" . $checkout_ID . "'
";
if(! mysql_query($sql, $mysql->link))
{
?>
<script language="javascript">
alert("error setting checkout date");
</script>
<?
}; // end if
?>