-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcustomer.php
executable file
·380 lines (362 loc) · 16.9 KB
/
customer.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
<?php
include_once 'header.php';
include_once 'headerfiles.php';
?>
<body class="skin-blue sidebar-collapse">
<div class="wrapper">
<?php
include_once 'navigation.php';
include_once 'sidebar.php';
if(isset($_GET['customerid']))
{
$customerid=sanitizeString($_GET['customerid']);
if($_GET['func']=="view")
{
$query="Select * from customers where customerid=$customerid";
$result= queryMysql($query);
$row=mysqli_fetch_array($result);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
View Customers
<small>Enter Customer details</small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li>Items</li>
<li class="active">Add</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Your Page Content Here -->
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-body">
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Customer Name</label>
<?php
echo $row['name'];
?>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Customer Address</label>
<?php
echo $row['address'];
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Customer Contact</label>
<?php
echo $row['contact'];
?>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Customer City</label>
<?php
echo $row['city'];
?>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="box-body">
<div class="box-body">
<div class="col-md-2">
<?php
echo<<<_END
<a href="customer.php?customerid=$customerid&func=edit">
<button class="focusable btn btn-block btn-primary focus">
Edit Customer Details
</button>
</a>
_END;
?>
</div>
<!-- <div class="col-md-2">
<?php
// echo<<<_END
// <a href="customer.php?customerid=$customerid&func=delete">
// <button class="focusable delete btn btn-block btn-danger">
// Delete Customer
// </button>
// </a>
//_END;
?>
</div>-->
</div>
</div>
</div>
<h3>
Previous Orders
<small>Previous Orders from this customer</small>
</h3>
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-body">
<table class="table table-bordered table-striped order-table">
<thead>
<tr>
<th>#</th>
<th>Order Id</th>
<th>Order Date</th>
<th>Customer Name</th>
<th>Venue</th>
<th>Manager</th>
<th>Event from</th>
<th>Event upto</th>
<th>Event Type</th>
<th>View</th>
</tr>
</thead>
<tbody>
<?php
$query="select orders.*,customers.name as customername,customers.city as customercity,managers.name as managername,godowns.name as godownname from orders inner join customers on orders.customerid=customers.customerid inner join managers on orders.managerid=managers.managerid inner join godowns on orders.godownid=godowns.godownid where orders.customerid=$customerid order by orderid desc";
$result=queryMysql($query);
$count=1;
while($row=mysqli_fetch_array($result))
{
$id=id($row['orderid']);
$id="OR-".$id;
$orderdate=dmyDate($row['orderdate']);
$eventfrom=dmyDate($row['eventfrom']);
$eventto=dmyDate($row['eventto']);
echo<<<_END
<tr>
<td>$count</td>
<td>$id</td>
<td>$orderdate</td>
<td>$row[customername], $row[customercity]</td>
<td>$row[godownname]</td>
<td>$row[managername]</td>
<td>$eventfrom</td>
<td>$eventto</td>
<td>$row[eventtype]</td>
<td><a href="order.php?orderid=$row[orderid]&func=view">View</a></td>
_END;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<h3>
Previous Rentals
<small>Previous rental orders from this customer</small>
</h3>
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-body">
<table class="table table-bordered table-striped order-table">
<thead>
<tr>
<th>#</th>
<th>Rental Id</th>
<th>Rental Date</th>
<th>Customer Name</th>
<th>Manager</th>
<th>Rent from</th>
<th>Rent upto</th>
<th>View</th>
</tr>
</thead>
<tbody>
<?php
$query="Select rentalsto.*, customers.name as customername,customers.city as customercity,managers.name as managername from rentalsto join customers on rentalsto.customerid=customers.customerid join managers on rentalsto.managerid=managers.managerid where rentalsto.customerid=$customerid order by rentalstoid desc";
$result=queryMysql($query);
$count=1;
while($row=mysqli_fetch_array($result))
{
$id=id($row['rentalstoid']);
$id="RT-".$id;
$query1="Select name,city from customers where customerid=$row[customerid]";
$result1=queryMysql($query1);
$row1=mysqli_fetch_array($result1);
$query2="Select name from managers where managerid=$row[managerid]";
$result2=queryMysql($query2);
$row2=mysqli_fetch_array($result2);
$rentaldate=dmyDate($row['date']);
$rentfrom=dmyDate($row['rentfrom']);
$rentupto=dmyDate($row['rentupto']);
echo<<<_END
<tr>
<td>$count</td>
<td>$id</td>
<td>$rentaldate</td>
<td>$row1[name], $row1[city]</td>
<td>$row2[name]</td>
<td>$rentfrom</td>
<td>$rentupto</td>
<td><a href="rentalto.php?rentalstoid=$row[rentalstoid]&func=view">View</a></td>
</tr>
_END;
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</section><!-- /.content -->
</div><!-- /.content-wrapper -->
<!-- Main Footer -->
<?php
}
elseif($_GET['func']=="edit")
{
if(isset($_POST['customerid']))
{
$customerid=sanitizeString($_POST['customerid']);
$name=sanitizeString($_POST['name']);
$address=sanitizeString($_POST['address']);
$city=sanitizeString($_POST['city']);
$contact=sanitizeString($_POST['contact']);
$query="Update customers set name='$name', address='$address', city='$city', contact='$contact' where customerid=$customerid";
queryMysql($query);
echo<<<_END
<script type="text/javascript">
window.location.replace("customer.php?customerid=$customerid&func=view");
</script>
_END;
}
else
{
$query="Select * from customers where customerid=$customerid";
$result= queryMysql($query);
$row=mysqli_fetch_array($result);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Edit Customers
<small>Enter Customer details</small>
</h1>
<ol class="breadcrumb">
<li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
<li>Items</li>
<li class="active">Add</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Your Page Content Here -->
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<?php
echo<<<_END
<form class="myform" action="customer.php?customerid=$customerid&func=edit" method="post">
_END;
?>
<div class="box-body">
<div class="row">
<div class="col-md-3">
<div class="form-group has-success">
<label>Customer Name</label>
<?php
echo<<<_END
<input type="text" name="name" value="$row[name]" class="form-control mandatory" placeholder="Customer Name"/>
<input type="hidden" name="customerid" value="$row[customerid]" class="form-control"/>
_END;
?>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Customer Address</label>
<?php
echo<<<_END
<input type="text" name="address" value="$row[address]" class="form-control" placeholder="Customer Address"/>
_END;
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Customer Contact</label>
<?php
echo<<<_END
<input type="text" name="contact" value="$row[contact]" class="form-control" placeholder="Customer Contact"/>
_END;
?>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Customer City</label>
<div class="form-group has-success">
<select name="city" class="form-control mandatory">
<?php
echo "<option value=\"$row[city]\">$row[city]</option>";
?>
<option>Bhopal</option>
<option>Gwalior</option>
<option>Indore</option>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="box-body">
<div class="col-md-2">
<button class="focusable btn btn-block btn-primary submit">Save Customer Details</button>
</div>
<div class="col-md-2">
<button class="focusable btn btn-block btn-warning cancel">Cancel</button>
</div>
</div>
</div>
</div>
<?php
echo "</form>";
?>
</div>
</div>
</div>
</section><!-- /.content -->
</div>
<?php
}
}
// elseif($_GET['func']=="delete")
// {
// $query="Delete from customers where customerid=$customerid";
// queryMysql($query);
// echo<<<_END
// <script type="text/javascript">
// window.location.replace("viewcustomers.php");
// </script>
//_END;
// }
}
include_once 'footer.php';
?>
</div><!-- ./wrapper -->
</body>
</html>