-
Notifications
You must be signed in to change notification settings - Fork 2
/
barcode_register.php
63 lines (54 loc) · 1.69 KB
/
barcode_register.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
<?php
require_once 'inc/standard.php';
foreach ($_GET as $key => $value) {
//echo '$user[\''.$key.'\'] = '.$value.';<br>';
$scan[$key] = trim(strip_tags($value));
}
//echo 'Registering...';
if($scan['barcode'])
{
$barcode = new Barcode($scan['barcode']);
$scanner = new Scanner();
$errors = 1;
if($barcode->validate())
{
//echo 'Validating...';
if(!$barcode->exists())
{
$sql = 'INSERT INTO barcodes
SET barcode = "'.$barcode->code.'",
date = "'.NOW_DATE.'",
time = "'.NOW_TIME.'",
volunteer = "'.$_SESSION['ucinetid'].'"';
$DB->query($sql);
$output['message']['text'] = 'The barcode <strong>'.$barcode->code.'</strong> has been registered';
$output['message']['status'] = 'success';
$sql = 'SELECT * FROM barcodes
WHERE barcode = "'.$barcode->code.'"';
$DB->query($sql);
$output['scan'] = $DB->resultToArray();
$DB->close();
//remove the 'undefined' in the ticker
$output['scan'][0]['name'] = ' ';
$output['scan'][0]['major'] = ' ';
$output['scan'][0]['level'] = ' ';
$output['scan'][0]['ucinetid'] = ' ';
}
else
{
$output['message']['text'] = 'The barcode <strong>'.$barcode->code.'</strong> is already registered';
$output['message']['status'] = 'error';
}
}
else
{
$output['message']['text'] = 'The barcode <strong>'.$barcode->code.'</strong> is not properly formatted';
$output['message']['status'] = 'error';
}
}
else
{
$output['message']['text'] = 'No Barcode Found';
$output['message']['status'] = 'error';
}
echo json_encode($output);