-
Notifications
You must be signed in to change notification settings - Fork 1
/
supplier.php
executable file
·370 lines (351 loc) · 16.3 KB
/
supplier.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
<?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['supplierid']))
{
$supplierid=sanitizeString($_GET['supplierid']);
if($_GET['func']=="view")
{
$query="Select * from suppliers where supplierid=$supplierid";
$result= queryMysql($query);
$row=mysqli_fetch_array($result);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
View Suppliers
<small>Enter Supplier 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>Supplier Name</label>
<?php
echo $row['name'];
?>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Supplier Address</label>
<?php
echo $row['address'];
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Supplier Contact</label>
<?php
echo $row['contact'];
?>
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Supplier 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="supplier.php?supplierid=$supplierid&func=edit">
<button class="btn btn-block btn-primary focus">
Edit Supplier Details
</button>
</a>
_END;
?>
</div>
<!-- <div class="col-md-2">
<?php
// echo<<<_END
// <a href="supplier.php?supplierid=$supplierid&func=delete">
// <button class="btn btn-block btn-warning">
// Delete Supplier
// </button>
// </a>
//_END;
?>
</div>-->
</div>
</div>
</div>
<h3>
Previous Purchases
<small>Previous Purchases from this supplier</small>
</h3>
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-body">
<table class="table table-bpurchaseed table-striped purchase-table">
<thead>
<tr>
<th>#</th>
<th>Purchase Id</th>
<th>Purchase Date</th>
<th>Supplier Name</th>
<th>Manager</th>
<th>View</th>
</tr>
</thead>
<tbody>
<?php
$query="Select purchases.*,suppliers.name as suppliername,suppliers.city as suppliercity,managers.name as managername from purchases join suppliers on purchases.supplierid=suppliers.supplierid join managers on purchases.managerid=managers.managerid where purchases.supplierid=$supplierid order by purchaseid desc";
$result=queryMysql($query);
$count=1;
while($row=mysqli_fetch_array($result))
{
$id=id($row['purchaseid']);
$id="PU-".$id;
$purchasedate=dmyDate($row['purchasedate']);
echo<<<_END
<tr>
<td>$count</td>
<td>$id</td>
<td>$purchasedate</td>
<td>$row[suppliername], $row[suppliercity]</td>
<td>$row[managername]</td>
<td><a href="purchase.php?purchaseid=$row[purchaseid]&func=view">View</a></td>
_END;
// if($row['invoice']==0)
// {
// echo<<<_END
// <td><a href="purchase.php?purchaseid=$row[purchaseid]&func=invoice">Add Rates</a></td>
// </tr>
//_END;
// }
// else
// {
// echo<<<_END
// <td><a href="purchase.php?purchaseid=$row[purchaseid]&func=invoice">View Rates</a></td>
// </tr>
//_END;
//
// }
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<h3>
Previous Rentals
<small>Previous Rentals from this supplier</small>
</h3>
<div class="row">
<div class="col-md-12">
<div class="box box-primary">
<div class="box-body">
<table class="table table-bPurchaseed table-striped Purchase-table">
<thead>
<tr>
<th>#</th>
<th>Rental Id</th>
<th>Entry Date</th>
<th>Supplier Name</th>
<th>Manager</th>
<th>Rental from</th>
<th>Rental upto</th>
<th>View</th>
</tr>
</thead>
<tbody>
<?php
$query="Select rentalsfrom.*,suppliers.name as suppliername,suppliers.city as suppliercity,managers.name as managername from rentalsfrom join suppliers on rentalsfrom.supplierid=suppliers.supplierid join managers on rentalsfrom.managerid=managers.managerid where rentalsfrom.supplierid=$supplierid order by rentalsfromid desc";
$result=queryMysql($query);
$count=1;
while($row=mysqli_fetch_array($result))
{
$id=id($row['rentalsfromid']);
$id="RF-".$id;
$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>$row[suppliername], $row[suppliercity]</td>
<td>$row[managername]</td>
<td>$rentfrom</td>
<td>$rentupto</td>
<td><a href="rentalfrom.php?rentalsfromid=$row[rentalsfromid]&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['supplierid']))
{
$supplierid=sanitizeString($_POST['supplierid']);
$name=sanitizeString($_POST['name']);
$address=sanitizeString($_POST['address']);
$city=sanitizeString($_POST['city']);
$contact=sanitizeString($_POST['contact']);
$query="Update suppliers set name='$name', address='$address', city='$city', contact='$contact' where supplierid=$supplierid";
queryMysql($query);
echo<<<_END
<script type="text/javascript">
window.location.replace("supplier.php?supplierid=$supplierid&func=view");
</script>
_END;
}
else
{
$query="Select * from suppliers where supplierid=$supplierid";
$result= queryMysql($query);
$row=mysqli_fetch_array($result);
?>
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Edit Suppliers
<small>Enter Supplier 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="supplier.php?supplierid=$supplierid&func=edit" method="post">
_END;
?>
<div class="box-body">
<div class="row">
<div class="col-md-3">
<div class="form-group has-success">
<label>Supplier Name</label>
<?php
echo<<<_END
<input type="text" name="name" value="$row[name]" class="form-control mandatory" placeholder="Supplier Name"/>
<input type="hidden" name="supplierid" value="$row[supplierid]" class="form-control"/>
_END;
?>
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Supplier Address</label>
<?php
echo<<<_END
<input type="text" name="address" value="$row[address]" class="form-control" placeholder="Supplier Address"/>
_END;
?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
<div class="form-group">
<label>Supplier Contact</label>
<?php
echo<<<_END
<input type="text" name="contact" value="$row[contact]" class="form-control" placeholder="Supplier Contact"/>
_END;
?>
</div>
</div>
<div class="col-md-3">
<div class="form-group has-success">
<label>Supplier City</label>
<div class="form-group">
<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 Supplier 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
}
}
}
include_once 'footer.php';
?>
</div><!-- ./wrapper -->
</body>
</html>