-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathorder.php
More file actions
172 lines (144 loc) · 9.53 KB
/
order.php
File metadata and controls
172 lines (144 loc) · 9.53 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
include_once 'connection/checkUser.php';
include_once 'database/Order.php';
include_once 'help_functions.php';
$err = '';
//Check if post back
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$err = Order::testOrderForm();
}
if (($_SERVER["REQUEST_METHOD"] == "POST") && (empty($err))) {
Order::insertNewOrder();
header("Location: all_orders.php");
}
else {
include_once 'parts/header.php';?>
<body>
<div id="wrapper">
<?php include_once 'parts/nav.php';?>
<!-- Page Content -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Add Order</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="panel panel-default">
<div class="panel-heading">
New Order
</div>
<div class="panel-body">
<div class="row">
<div class="col-lg-6">
<form role="form" id="order-form" method="POST" action=<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>>
<?php if(!empty($err)) { ?>
<div class="alert alert-danger" role="alert">
<span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
<?php echo $err?>
</div>
<?php }?>
<div class="form-group">
<i class="fa fa-calendar"></i> <label>Date</label>
<div>
<input class="form-control" name="order-date" style="width:200px" type="date" value=<?php echo date("Y-m-d")?> >
</div>
</div>
<?php
$results = Customer::getAllCustomers();
?>
<div class="form-group">
<i class="fa fa-user"></i> <label>Customer</label>
<select name="customer" class="form-control" style="width:200px">
<?php foreach ($results as $result) { ?>
<option> <?php echo($result["CUST_ID"]." ".$result["FIRST_NAME"]." ".$result["LAST_NAME"]);?></option>
<?php } ?>
</select>
</div>
<div class="form-group">
<i class="fa fa-cubes"></i> <label>Items</label>
<?php
$results = Products::getAllProducts();
?>
<div>
<i class="fa fa-cube"></i> <label>Item #1</label>
</div>
<div>
Description: <select id="desc1" name="desc1" class="form-control" style="width:200px" onchange="showPrice(1)">
<?php foreach ($results as $result) {
?>
<option value='<?php echo($result['DESCRIPTION'].",".$result['PRICE'].",".$result['QUANTITY']);?>'><?php echo($result["DESCRIPTION"]);?></option>
<?php } ?>
</select>
</div>
<div>
<i class="fa fa-usd"></i> <label>Price</label>
<input class="form-control" id='price1' name="price1" style="width:200px" placeholder='Price' value='<?php echo $results[0]['PRICE'];?>' disabled>
</div>
<div>
<i class="fa fa-cubes"></i> <label>Quantity</label>
<input class="form-control" id='quantity1' name="quantity1" style="width:200px" placeholder='Quantity' maxlength="5" onkeypress='return event.charCode >= 48 && event.charCode <= 57'>
<label>In Store:</label> <input class="form-control" id='max_quantity1' style="width:200px" placeholder='Max Quantity' value='<?php echo ($results[0]['QUANTITY']);?>' disabled>
</div>
<div id="more-items"></div>
<div id="no-more-error"></div> <!-- Error too much items -->
<div>
<script type="text/javascript">
var i = 1;
</script>
Add Items:
<button type="button" id= "plus-items" class="btn btn-success btn-xs" onClick="addItemToDiv(++i)">+</button>
</div>
</div>
<div class="form-group">
<i class="fa fa-unlock-alt"></i> <label>Status</label>
<select name="status" class="form-control" style="width:200px">
<option>Open</option>
<option>Close</option>
</select>
</div>
<div>
<button type="submit" class="btn btn-default">Submit Order</button>
<button type="reset" class="btn btn-default">Reset</button>
</div>
</form>
</div>
</div>
<!-- /.row (nested) -->
</div>
<!-- /.panel-body -->
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<script>
function addItemToDiv(i)
{
// if(i > 5) { // Limit to maximum 5 items per order
// document.getElementById("no-more-error").innerHTML = "<div class='alert alert-danger'>Can't add more than 5 items in one order!</div></div>";
// document.getElementById("plus-items").className = "btn btn-danger btn-xs";
// } else {
var div = document.createElement('div');
div.innerHTML = "<i class='fa fa-cube'></i> <label>Item #"+i+"</label></div><div>Description: <select id='desc"+i+"' name='desc"+i+"' class='form-control' style='width:200px' onchange='showPrice("+i+")'><?php foreach ($results as $result) { ?><option value='<?php echo($result['DESCRIPTION'].",".$result['PRICE'].",".$result['QUANTITY']);?>'><?php echo($result["DESCRIPTION"]);?></option><?php } ?></select></div> <div><i class='fa fa-usd'></i> <label>Price</label><input class='form-control' id='price"+i+"' name='price"+i+"' style='width:200px' placeholder='Price' value='<?php echo $results[0]['PRICE'];?>' maxlength='10' onkeypress='return event.charCode >= 46 && event.charCode <= 57' disabled></div><div><i class='fa fa-cubes'></i> <label>Quantity</label><input class='form-control' id='quantity"+i+"' name='quantity"+i+"' style='width:200px' placeholder='Quantity' maxlength='5' onkeypress='return event.charCode >= 48 && event.charCode <= 57'> <label>In Store:</label><input class='form-control' id='max_quantity"+i+"' style='width:200px' placeholder='Max Quantity' value='<?php echo ($results[0]['QUANTITY']);?>' disabled>";
document.getElementById('more-items').appendChild(div);
// }
}
function showPrice(i)
{
var price = document.getElementById("desc"+i).value.split(",")[1];
var max_quantity = document.getElementById("desc"+i).value.split(",")[2];
document.getElementById("price"+i).value = price;
document.getElementById("max_quantity"+i).value = max_quantity;
}
</script>
<?php
include_once 'parts/bottom.php';
include_once 'parts/footer.php';
//}
}
?>