-
Notifications
You must be signed in to change notification settings - Fork 0
/
customer_dash.php
386 lines (291 loc) · 11.9 KB
/
customer_dash.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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
<!DOCTYPE html>
<html lang="en">
<head>
<title>Sales View</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
</head>
<body>
<!--------------------------------------------------------------- PHP Code ------------------------------------------------------------------>
<?php
//-----------------------------------------------------Processing SQL Database queries--------------------------------------------------------
function database ($sql, $h_success, $h_fail)
{
$servername = "localhost";
$username = "root";
$password = "College@2015";
$dbname = "ESPDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($conn->query($sql) === TRUE) {
echo $h_success;
} else {
$h_fail = $h_fail. "Error : " . $conn->error;
echo "<div class='alert alert-danger'><strong>Sorry!</strong>" . $h_fail . "</div>";
echo "<script type='text/javascript'>alert('$h_fail');</script>";
}
$conn->close();
}
//---------------------------------------------- Add tower -------------------------------------------------------------------------------
function add_tower($tw_id, $desc)
{
$sql = "INSERT INTO tower (tw_id, name, cr_dt) values ('$tw_id', '$desc', now());";
$h_success = "Tower: " . $desc . " Added Successfully";
$h_success = "<script type='text/javascript'>alert('$h_success');</script>";
$h_fail = "Tower: " . $tw_id . " Not Added";
database($sql, $h_success, $h_fail);
}
//---------------------------------------------- Add Type -------------------------------------------------------------------------------
function add_type($type_id, $desc, $tw_id,$price)
{
$sql = "INSERT INTO type (type_id, name, tw_id, price, cr_dt) VALUES ('$type_id', '$desc', '$tw_id', '$price', now());";
$h_success = "Tower: " . $desc . " Added Successfully";
$h_success = "<script type='text/javascript'>alert('$h_success');</script>";
$h_fail = "Type: " . $type_id . " Not Added";
database($sql, $h_success, $h_fail);
}
//---------------------------------------------- Add Unit -------------------------------------------------------------------------------
function add_unit($ut_id, $type, $tw_id, $floor, $area)
{
$sql = "INSERT INTO unit (ut_id, type, tw_id, floor, area, cr_dt)
VALUES ('$ut_id', '$type', '$tw_id', '$floor', '$area', now());";
$h_success = "Tower: " . $desc . " Added Successfully";
$h_success = "<script type='text/javascript'>alert('$h_success');</script>";
$h_fail = "Unit: " . $ut_id . " Not Added";
database($sql, $h_success, $h_fail);
}
//---------------------------------------------- Add Billing Plan ---------------------------------------------------------------------------
function add_plan($bill_plan, $name, $years, $roi)
{
$sql = "INSERT INTO bill_plan (bill_plan, name, no_years, roi, cr_dt)
VALUES ('$bill_plan', '$name', '$years', '$roi', now());";
$h_success = "Billing Plan: " . $desc . " Added Successfully";
$h_success = "<script type='text/javascript'>alert('$h_success');</script>";
$h_fail = "Billing Plan: " . $bill_plan . " Not Added";
database($sql, $h_success, $h_fail);
}
switch ($_POST[add])
{
case "tower" : unset($msg); add_tower($_POST['tw_id'], $_POST['desc']); break; //add tower
case "type" : unset($msg); add_type($_POST[type_id],$_POST[desc],$_POST[tw_id],$_POST[price]); break; //add type
case "unit" : unset($msg); add_unit($_POST[ut_id], $_POST[type], $_POST[tw_id], $_POST[floor], $_POST[area]); break; //add unit
case "plan" : unset($msg); add_plan($_POST[bill_plan], $_POST[name], $_POST[years], $_POST[roi]); break; //add billing plan
}
?>
<div class="container">
<h2>Customer View</h2>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#home">Sales Order</a></li>
<li><a data-toggle="tab" href="#menu1">Payment</a></li>
<li><a data-toggle="tab" href="#menu2">Owner</a></li>
<li><a data-toggle="tab" href="#menu4">Construction Progress</a></li>
<ul class="nav navbar-nav navbar-right">
<li><a href="logout.php"><span class="glyphicon glyphicon-user"></span>Logout</a></li>
</ul>
</ul>
<div class="tab-content">
<!tab 1>
<div id="home" class="tab-pane fade in active">
<h3>Sales Order Details</h3>
<div class="container">
<form role="form" action = "sales_dash.php" method = "POST">
<div class="form-group">
<label>Sales Order Number :</label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Unit Number : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Customer Name : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Tower Number : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Type : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Unit Price : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Bill Plan Chosen : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Created On : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
<div class="form-group">
<label>Last Changed On : </label>
<div id="so_no" class="well well-sm">Sales Order Number</div>
</div>
</form>
</div>
</div>
<!tab2>
<div id="menu1" class="tab-pane fade">
<h3>Add Type</h3>
<div class="container">
<form role="form" action = "sales_dash.php" method = "POST">
<div class="form-group">
<label>Type ID:</label>
<input type="text" class="form-control" name="type_id" placeholder="Enter Type ID " required>
</div>
<div class="form-group">
<label for="tower">Description:</label>
<input type="text" class="form-control" name="desc" placeholder="Enter Type Description " required>
</div>
<div class="form-group">
<label for="tw_id">Choose Tower (select one):</label>
<select class="form-control" name="tw_id">
<!-------- code for fetching available values from Database for input dropdown options ------------------------------------------------------>
<?php
$servername = "localhost";
$username = "root";
$password = "College@2015";
$dbname = "ESPDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT tw_id, name from tower where tw_id != ''";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<option value=". $row['tw_id'] . ">" . $row['name'] . "</option>";
}
}
$conn->close();
?>
<!-------------------------------------------------- End of Dropdown --------------------------------------------------------------------->
</select>
</div>
<div class="form-group">
<label>Price:(in USD)</label>
<input type="text" class="form-control" name="price" placeholder="Enter Price " required>
</div>
<button type="submit" class="btn pull-right" name="add" value="type" >Add Type</button>
</form>
</div>
</div>
<!tab3>
<div id="menu2" class="tab-pane fade">
<h3>Add Unit Details</h3>
<div class="container">
<form role="form" action = "sales_dash.php" method = "POST">
<div class="form-group">
<label>Unit ID:</label>
<input type="text" class="form-control" name="ut_id" placeholder="Enter Unit Number " required>
</div>
<div class="form-group">
<label for="type">Choose Type (select one):</label>
<select class="form-control" name="type">
<!-------- code for fetching available values from Database for input dropdown options ------------------------------------------------------>
<?php
$servername = "localhost";
$username = "root";
$password = "College@2015";
$dbname = "ESPDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT type_id, name from type where type_id != ''";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<option value=". $row['type_id'] . ">" . $row['name'] . "</option>";
}
}
$conn->close();
?>
<!-------------------------------------------------- End of Dropdown --------------------------------------------------------------------->
</select>
</div>
<div class="form-group">
<label for="tw_id">Choose Tower (select one):</label>
<select class="form-control" name="tw_id">
<!-------- code for fetching available values from Database for input dropdown options ------------------------------------------------------>
<?php
$servername = "localhost";
$username = "root";
$password = "College@2015";
$dbname = "ESPDB";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SELECT tw_id, name from tower where tw_id != ''";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
echo "<option value=". $row['tw_id'] . ">" . $row['name'] . "</option>";
}
}
$conn->close();
?>
<!-------------------------------------------------- End of Dropdown --------------------------------------------------------------------->
</select>
</div>
<div class="form-group">
<label>Floor:</label>
<input type="text" class="form-control" name="floor" placeholder="Enter Floor " required>
</div>
<div class="form-group">
<label>Area in Sqft:</label>
<input type="text" class="form-control" name="area" placeholder="Enter Area " required>
</div>
<button type="submit" class="btn pull-right" name="add" value="unit" >Add Unit</button>
</form>
</div>
</div>
<!---Add Billing Plan -->
<div id="menu4" class="tab-pane fade">
<h3>Add Billing Plan</h3>
<div class="container">
<form role="form" action = "sales_dash.php" method = "POST">
<div class="form-group">
<label>Billing Plan Number:</label>
<input type="text" class="form-control" name="bill_plan" placeholder="Enter Billing Plan Number " required>
</div>
<div class="form-group">
<label >Billing Plan Description</label>
<input type="text" class="form-control" name="name" placeholder="Enter Billing Plan Description " required>
</div>
<div class="form-group">
<label >Number of Installments</label>
<input type="text" class="form-control" name="years" placeholder="Enter Number of Installments " required>
</div>
<div class="form-group">
<label >Rate of Interest(in %)</label>
<input type="text" class="form-control" name="roi" placeholder="Enter Rate of Interest " required>
</div>
<button type="submit" class="btn pull-right" name="add" value="plan" >Add Billing Plan</button>
</form>
</div>
</div>
<!---End of Add Billing Plan -->
</div>
</div>
</div>
</body>
</html>