-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscan-buttons.php
37 lines (29 loc) · 878 Bytes
/
scan-buttons.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
<?php
session_start();
if($_SESSION["verified"] != "v3r1f13d" && $_SESSION["verified"] != "v3r1f13d-adm1n"){
header("Location: http://www.info.campusstore.utah.edu/inventory/index.php");
exit();
}
$tmp = $_SESSION['barcode'];
$sku = substr($_POST['identifier'],0,strpos($_POST['identifier'], '-'));
$string = substr($_POST['identifier'],strpos($_POST['identifier'], '-')+1);
for($i = 0; $i < count($tmp[$sku]); $i++){
if(strpos($tmp[$sku][$i], $string) !== false){
$qty = (int)substr($tmp[$sku][$i], strrpos($tmp[$sku][$i], '-')+1);
if(isset($_POST['remove']))
$qty--;
if(isset($_POST['update']))
$qty = $_POST['newQuantity'];
if($qty <= 0){
array_splice($tmp[$sku], $i, 1);
if(count($tmp[$sku]) == 0){
unset($tmp[$sku]);
}
break;
}
$tmp[$sku][$i] = $string.$qty;
}
}
$_SESSION['barcode'] = $tmp;
header('Location: scan.php');
?>