-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinventory.php
75 lines (70 loc) · 2.16 KB
/
inventory.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
<?php include 'db_connect.php' ?>
<div class="container-fluid">
<div class="col-lg-12">
<div class="row">
<div class="col-md-12">
<div class="card">
<div class="card-header">
<h4><b>Inventory</b></h4>
</div>
<div class="card-body">
<table class="table table-bordered">
<thead>
<th class="text-center">#</th>
<th class="text-center">Product Name</th>
<th class="text-center">Stock In</th>
<th class="text-center">Stock Out</th>
<th class="text-center">Stock Available</th>
</thead>
<tbody>
<?php
$i = 1;
$product = $conn->query("SELECT * FROM product_list r order by name asc");
while($row=$product->fetch_assoc()):
$inn = $conn->query("SELECT sum(qty) as inn FROM inventory where type = 1 and product_id = ".$row['id']);
$inn = $inn && $inn->num_rows > 0 ? $inn->fetch_array()['inn'] : 0;
$out = $conn->query("SELECT sum(qty) as `out` FROM inventory where type = 2 and product_id = ".$row['id']);
$out = $out && $out->num_rows > 0 ? $out->fetch_array()['out'] : 0;
$available = $inn - $out;
?>
<tr>
<td class="text-center"><?php echo $i++ ?></td>
<td class=""><?php echo $row['name'] ?></td>
<td class="text-right"><?php echo $inn ?></td>
<td class="text-right"><?php echo $out ?></td>
<td class="text-right"><?php echo $available ?></td>
</tr>
<?php endwhile; ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
$('table').dataTable()
$('#new_receiving').click(function(){
location.href = "index.php?page=manage_receiving"
})
$('.delete_receiving').click(function(){
_conf("Are you sure to delete this data?","delete_receiving",[$(this).attr('data-id')])
})
function delete_receiving($id){
start_load()
$.ajax({
url:'ajax.php?action=delete_receiving',
method:'POST',
data:{id:$id},
success:function(resp){
if(resp==1){
alert_toast("Data successfully deleted",'success')
setTimeout(function(){
location.reload()
},1500)
}
}
})
}
</script>