-
Notifications
You must be signed in to change notification settings - Fork 0
/
item_new_barcode.php
73 lines (60 loc) · 1.56 KB
/
item_new_barcode.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
<?
include_once(dirname(__FILE__) . "/first.php");
$item_ID = $query[0];
$item_barcode = $query[1];
if(strlen(trim($item_barcode)) != $db->barcode_length || substr(trim($item_barcode), 0, 1) != $db->barcode_item_prefix)
{
exit_error("Invalid Barcode: " . $item_barcode, "The barcode you entered is not valid.");
}; // end if
$barcode_sql = "
SELECT
*
FROM
`" . $db->table_library_item . "`
WHERE
`barcode`='" . mysql_escape_string(trim($item_barcode)) . "'
AND `ID`!='" . $item_ID . "'
";
$barcode_result = mysql_query($barcode_sql, $mysql->link);
if(mysql_num_rows($barcode_result) > 0)
{
exit_error("Duplicate Barcode: " . $item_barcode, "The barcode you entered is already in use.");
}; // end if
$sql = "
SELECT
*
FROM
`" . $db->table_library_item . "`
WHERE
`ID`='" . $item_ID . "'
";
$result = mysql_query($sql, $mysql->link);
$record = mysql_fetch_object($result);
if(
$record->{$db->field_category_ID} == 16
|| $record->{$db->field_category_ID} == 7
|| $record->call_number == "E"
|| substr($record->call_number, 0, 2) == "E,"
)
{
$authors = lookup_author($record->ID);
$new_call_number = "E," . strtoupper(substr($authors[0]->last_name, 0, 3));
}
else
{
$new_call_number = $record->call_number;
}; // end if
$sql = "
UPDATE
`" . $db->table_library_item . "`
SET
`barcode`='" . mysql_escape_string($item_barcode) . "',
`call_number`='" . $new_call_number . "'
WHERE
`ID`='" . $item_ID . "'
";
//exit($sql);
mysql_query($sql, $mysql->link);
header("location:" . $db->url_root . "/item_details.php/barcode/" . $item_barcode);
exit();
?>