-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinv_chk_ajx.php
82 lines (77 loc) · 2.13 KB
/
inv_chk_ajx.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
<?php
require_once 'util.php';
$function = @$_POST['function'];
if($function == "inventoryHas")
{
$pid = $_POST["pid"];
$found = db("select * from inventory where pid='$pid' limit 1");
if($found == [])
{
echo "false";
}
else
{
echo "true";
}
}
if($function == "getQtyOf")
{
$pid = $_POST["pid"];
$entry = @$_POST["qty"];
$descr = getDescription($pid);
$found = db("select * from inventory where pid='$pid' limit 1");
if (ifExists($pid))
{
// $inv = db("select * from inventory_check where pid = '$pid' limit 1");
// $prevQty = $inv["checked"];
// $entry = $entry + $prevQty;
// db("update inventory_check set checked = '$entry' where pid = '$pid' ");
}
else
{
db("insert into inventory_check (pid, checked) values ('$pid', '$entry')");
}
// db("insert into inventory_check (pid, checked) values ('$pid', '$entry')");
$qty = $found["total_qty"];
$rem = $qty - $entry;
echo "<tr class=\"product-col\">
<td class=\"pid\">$pid</td>
<td class=\"descr\">$descr</td>
<td class=\"entry\">$entry</td>
<td class=\"qty\">$qty</td>
<td></td>
<td class=\"rem\">$rem</td>
<td class=\"\"><span class=\"pull-right del\">x</span></td>
</tr>";
// echo $found["total_qty"];
}
if($function == "updateInfo")
{
$pid = $_POST["pid"];
$entry = @$_POST["qty"];
//$descr = getDescription($pid);
$found = db("select * from inventory_check where pid='$pid' limit 1");
$qty = $found["checked"];
$entry = $qty + $entry;
db("update inventory_check set checked = '$entry' where pid = '$pid')");
echo $entry;
// echo $found["total_qty"];
}
if($function == "updateDb")
{
$pid = $_POST["pid"];
$newEntry = @$_POST["newEntry"];
db("update inventory_check set checked = '$newEntry' where pid = '$pid'");
echo "update inventory_check set checked = '$newEntry' where pid = '$pid'";
}
if($function == "deleteFromDb")
{
$pid = $_POST["pid"];
db("delete from inventory_check where pid = '$pid'");
echo "delete from inventory_check where pid = '$pid'";
}
if($function == "inventoryHasThe")
{
echo "ajax success";
}
?>