-
Notifications
You must be signed in to change notification settings - Fork 0
/
materialrequisition3_action.php
executable file
·159 lines (146 loc) · 5.4 KB
/
materialrequisition3_action.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<?php
session_start();
require_once("dbcontroller.php");
$db_handle = new DBController();
if(!empty($_POST["action"])) {
switch($_POST["action"]) {
case "add":
if(!empty($_POST["quantity"]) && !empty($_POST["po_no"])) {
$productByCode = $db_handle->runQuery("SELECT * FROM quotation_cart WHERE code='" . $_POST["code"] . "' and quote_no='" . $_POST["po_no"] . "' ORDER BY material_no ASC ");
$itemArray = array($productByCode[0]["code"]=>array('material_no'=>$productByCode[0]["material_no"], 'code'=>$productByCode[0]["code"], 'category'=>$productByCode[0]["category"], 'scategory_name'=>$productByCode[0]["scategory_name"], 'brand_name'=>$productByCode[0]["brand_name"], 'description'=>$productByCode[0]["description"], 'color'=>$productByCode[0]["color"], 'package'=>$productByCode[0]["package"], 'unit_measurement'=>$productByCode[0]["unit_measurement"],'quantitys'=>$productByCode[0]["quantity"], 'quantity'=>$_POST["quantity"],'abbre'=>$productByCode[0]["abbre"]));
if(!empty($_SESSION["cart_itemmq"])) {
if(in_array($productByCode[0]["code"],$_SESSION["cart_itemmq"])) {
foreach($_SESSION["cart_itemmq"] as $k => $v) {
if($productByCode[0]["code"] == $k)
$_SESSION["cart_itemmq"][$k]["quantity"] = $_POST["quantity"];
}
} else {
$_SESSION["cart_itemmq"] = array_merge($_SESSION["cart_itemmq"],$itemArray);
}
} else {
$_SESSION["cart_itemmq"] = $itemArray;
}
}
break;
case "remove":
if(!empty($_SESSION["cart_itemmq"])) {
foreach($_SESSION["cart_itemmq"] as $k => $v) {
if($_POST["code"] == $k)
unset($_SESSION["cart_itemmq"][$k]);
if(empty($_SESSION["cart_itemmq"]))
unset($_SESSION["cart_itemmq"]);
}
}
break;
case "empty":
unset($_SESSION["cart_itemmq"]);
break;
}
}
?>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">
<link rel="stylesheet" href="http://localhost/xampp/capstone/font-awesome-4.6.3/css/font-awesome.min.css">
<script src="jQuery/jQuery-2.1.3.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<!--- datatables -->
<link rel="stylesheet" href="http://localhost/xampp/capstone/DataTables/responsive/css/responsive.dataTables.min.css">
<link rel="stylesheet" href="http://localhost/xampp/capstone/DataTables/css/jquery.dataTables.min.css">
<script src="http://localhost/xampp/capstone/DataTables/js/jquery.dataTables.min.js"></script>
<script src="http://localhost/xampp/capstone/DataTables/responsive/js/dataTables.responsive.min.js"></script>
<!--- datatables -->
<style type="text/css">
body
{
background-color:#bcab90;
margin: 0px;
}
h6
{
border-bottom: 2px solid black;
}
.w3-camo-dark-green
{
color:#fff;background-color:#535640
}
.w3-camo-earth
{
color:#fff;background-color:#ac7e54
}
.w3-navbar
{
width: 103%;
margin-left: -17px;
}
</style>
</head>
<BODY>
<?php
if(isset($_SESSION["cart_itemmq"])){
$item_total = 0;
?>
<div class="container" style="width:100%; margin-left: 0px; margin-top:0px;">
<table class="table-bordered w3-table w3-bordered w3-striped w3-border w3-hoverable" id="tableko" name="tableko" style="font-size: 0.9em;">
<thead>
<tr class="w3-green">
<th><strong>Brand</strong></th>
<th><strong>Category</strong></th>
<th><strong>Sub-Category</strong></th>
<th><strong>Description</strong></th>
<th><strong>Color</strong></th>
<th><strong>Package</strong></th>
<th><strong>Measurement</strong></th>
<th><strong>Abbreviation</strong></th>
<th><strong>Quantity</strong></th>
<th><strong>Action</strong></th>
</tr>
</thead>
<tbody>
<?php
foreach ($_SESSION["cart_itemmq"] as $item){
?>
<?php
$code=$item["code"];
$brand_name = $item["brand_name"];
$category = $item["category"];
$scategory_name = $item["scategory_name"];
$description = $item["description"];
$color = $item["color"];
$package = $item["package"];
$unit_measurement = $item["unit_measurement"];
$abbre = $item["abbre"];
$quantity = $item["quantity"];
?>
<tr>
<td><strong><?php echo $brand_name; ?></strong></td>
<td><strong><?php echo $category; ?></strong></td>
<td><strong><?php echo $scategory_name; ?></strong></td>
<td><strong><?php echo $description; ?></strong></td>
<td><strong><?php echo $color; ?></strong></td>
<td><strong><?php echo $package; ?></strong></td>
<td><strong><?php echo $unit_measurement; ?></strong></td>
<td><strong><?php echo $abbre; ?></strong></td>
<td><strong><?php echo $quantity; ?></strong></td>
<td><button type="button" onClick="cartAction('remove','<?php echo $item["code"]; ?>')" class="btnRemoveAction cart-action">Remove Item</button></td>
</tr>
<?php
}
?>
</tbody>
</table>
<br>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#tableko').DataTable({
"lengthMenu": [[5,10, 25, 50, -1], [5,10, 25, 50, "All"]]
});
});
</script>
<?php
}
?>