-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfixture-complete.php
95 lines (78 loc) · 2.96 KB
/
fixture-complete.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
<?php
$head = ['title' => 'Mark Fixture Complete',
'scripts' =>"<script>
function reset(){
//reset session scanned data
//not how that works jimmy!
//reset other session variables
//redirect
window.location.href = 'index.php';
}
$(document).ready(function(){
$('#reset').on('click',function(){
//reset session scanned data
//reset other session variables
//redirect
window.location.href = 'index.php';
});
});
</script>"];
$header = "Mark Fixture <strong>Complete</strong>";
include 'classes/header.php';
?>
<div class="contain" style="text-align: center;">
<h2>Is <strong>fixture <?php echo $_SESSION['fixnum']; ?></strong> complete?</h2>
<?php
//print all fixture data already in db
$dept = $_SESSION['dept'];
$store = $_SESSION['storenum'];
$fixt = $_SESSION['fixnum'];
//Get items already in the db
$query = "SELECT * FROM scanned WHERE dept='$dept' AND store='$store' AND fixtureNum='$fixt'";
$items = mysqli_fetch_all(mysqli_query($conn,$query),MYSQLI_ASSOC);
foreach($items as $item){
$qty = $item["QTY"];
$key = $item["sku"];
$desc = getItemDetails($key,$_SESSION['storenum'])['description'];
echo("<p><strong> $qty </strong> - $key - $desc </p>");
}
//print all the scanned data
$data = $_SESSION["barcode"];
$keys = array_keys($data);
$descriptions = $_SESSION['descriptions'];
//combine duplicate barcodes while printing data
foreach($keys as $key){
$wrongFixt=false;
//get the array of fixture,box,shelf info with this barcode
$currentarray = $data[$key];
$desc = $descriptions[$key];
//removes consecutive leading zeros (remove this if runtimes begin to slow down)
$currentChar = 0;
while($currentChar < strlen($key) && substr($key, $currentChar, 1) == "0"){
$currentChar++;
}
$key = substr($key, $currentChar);
$qty = 0;
foreach($currentarray as $datastring){
//Does this apply to this fixture? if not, don't display it.
//we'll worry about the rest of the logic on the other side of the form submission.
if((substr($datastring, 0, strpos($datastring, "-", 0)))!==$_SESSION['fixnum'])
$wrongFixt=true;
$additionalQty = (int)(substr($datastring, strrpos($datastring, "-")+1));
$qty = $qty + $additionalQty;
}
//update this for quantities of the same barcode
if(!$wrongFixt)
echo('<p><strong>'.$qty.'</strong> - '.$key.' - '.$desc.'</p>');
}
?>
<form align="center" method="post" action="import-scanned-data.php">
<input type="hidden" name="fixtComplete" value="1">
<label>Comments: <input type="text" name="comments"></label>
<br>
<input class="button textcenter" style="width: 180px; display: inline-block; line-height:30px;" name="reset" value="No, keep scanning" type="submit">
<input class="button textcenter" style="width: 180px;" type="submit" id="submit" name="submit" value="This is correct, submit" tabindex="13" readonly />
</form>
<small>Note: this includes data from previous sessions, not just this scanning session.</small>
</div><!-- end contain -->
<?php include 'classes/footer.php'; ?>