-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathmanage-purchase.php
293 lines (274 loc) · 13.1 KB
/
manage-purchase.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
<?php
session_start();
if(!isset($_SESSION['store_id'])) {
header("location:login.php");
exit();
}else{
include('config/db.php');
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Pharmacy</title>
<!-- Data Table CSS -->
<?php include("part/data-table-css.php");?>
<!-- Data Table CSS end -->
<!-- All CSS -->
<?php include("part/all-css.php");?>
<!-- All CSS end -->
</head>
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">
<!-- Navbar -->
<?php include("part/navbar.php");?>
<!-- Navbar end -->
<!-- Sidebar -->
<?php include("part/sidebar.php");?>
<!-- Sidebar end -->
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Main content -->
<section class="content">
<div class="container-fluid">
<div class="row">
<div class="col-12">
<div class="card">
<div class="card-header">
<h3 class="card-title">Order</h3>
</div>
<div class="card-body">
<table id="orderTable" class="table table-bordered table-hover">
<thead>
<tr class="bg-info">
<!-- <th class="rmThText">SL</th> -->
<th class="adThText">Order</th>
<th class="adThText">Items</th>
<th class="adThText">Date</th>
<th class="adThText">Total Price</th>
<th class="adThText">Payment Status</th>
<th class="adThText">Order Status</th>
<th class="rmThText">Actions</th>
</tr>
</thead>
<tbody>
<?php
$n = 0;
$sql = $conn->query("SELECT * FROM `p_purchase_summary` WHERE `store` = '$_SESSION[store_id]' ORDER BY `id` DESC");
while($row = mysqli_fetch_assoc($sql)){
?>
<tr>
<!-- <td><?php echo ++$n; ?></td> -->
<td>#<?php echo $row['invoice']; ?></td>
<td>
<ul>
<?php
$purchaseCost = 0;
$medicine = $conn->query("SELECT * FROM `p_purchase` WHERE `invoice` = $row[invoice]");
while($medicineName = mysqli_fetch_assoc($medicine)){
?>
<li>
<?php
echo $medicineName['product']." (".$medicineName['qty'].")";
?>
</li>
<?php } ?>
</ul>
</td>
<td><?php echo $row['date']; ?></td>
<td><?php echo $row['total_price']-$row['discounted']; ?></td>
<td>
<?php
if($row['paid_status'] == "paid"){
$badge = "badge badge-success";
}elseif($row['paid_status'] == "on review"){
$badge = "badge badge-purple";
}elseif($row['paid_status'] == "cancel"){
$badge = "badge badge-danger";
}else{
$badge = "badge badge-warning";
}
?>
<p class="<?php echo $badge; ?> text-uppercase"><?php echo $row['paid_status']; ?></p>
</td>
<td>
<?php
if($row['status'] == "received"){
$badge = "badge badge-success";
}elseif($row['status'] == "confirm"){
$badge = "badge badge-primary";
}elseif($row['status'] == "on the way"){
$badge = "badge badge-purple";
}elseif($row['status'] == "cancel"){
$badge = "badge badge-danger";
}else{
$badge = "badge badge-warning";
}
?>
<p class="<?php echo $badge; ?> text-uppercase"><?php echo $row['status']; ?></p>
</td>
<td class="text-center">
<div class="btn-group">
<button class="btn btn-info btn-sm dropdown-toggle" data-toggle="dropdown" aria-expanded="false"> <i class="fa fa-cogs"></i> Manage</button>
<div class="dropdown-menu" x-placement="bottom-start" style="position: absolute; top: 30px; left: 0px; will-change: top, left;">
<a class="dropdown-item" href="purchase-invoice.php?id=<?php echo $row['invoice']; ?>"> <i class="fa fa-print text-cyan"></i> Print Invoice </a>
<?php if($row['paid_status'] == "unpaid" && $row['status'] != "cancel"){ ?>
<button type="button" class="form-control border-0" data-toggle="modal" data-target="#orderModal" data-whatever="<?php echo $row['invoice']; ?>"><i class="fa fa-credit-card text-success"></i> Add Payment</button>
<?php } ?>
<?php if($row['paid_status'] == "unpaid"){ ?>
<a class="dropdown-item" href="actions/purchaseInvoice.php?cancel&invoice=<?php echo $row['invoice']; ?>"> <i class="fa fa-minus-square text-danger"></i> Cancel Order </a>
<?php } ?>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<!-- Modal start -->
<div class="modal fade" id="orderModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<form action="actions/purchaseInvoice.php" method="post">
<div class="modal-header">
<h5 class="modal-title">Add Payment - Invoice #</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
<label>Payment Date</label>
<input type="date" class="form-control" name="date" required readonly value="<?php echo date("Y-m-d"); ?>">
<label class="mt-3">Transection With</label>
<select name="trandectionWith" class="form-control" id="trans" required>
<option value="Bkash" selected>Bkash</option>
<option value="Rocket">Rocket</option>
<option value="Nagad">Nagad</option>
<option value="Bank">Bank</option>
</select>
<input type="text" name="transectionInfo" class="form-control mt-1" placeholder="Transection ID / Bank account number" required>
<textarea name="transectionDetails" class="form-control mt-1 transTxt" placeholder="Enter Transection ID and other details " rows="3"></textarea>
<label class="mt-3">Amount</label>
<input type="number" name="amount" class="form-control" placeholder="0.00" required>
<input type="hidden" name="invoice" class="form-control ini">
</div>
</div>
<div class="modal-footer">
<small class="text-danger"><strong>Note: </strong> You will be able to submit payment information one time. Carefully enter these information. After submission for any change/query <a href=""> contact us</a> or call at <a href="">+8801958-586986</a></small>
<button type="button" class="btn btn-light" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-info" name="update" onclick="return confirm('Are you sure to submit?')">Submit Payment</button>
</div>
</form>
</div>
</div>
</div>
<!-- Modal end -->
</div>
</div>
</div>
</div>
</div>
</section>
</div>
<!-- Footer -->
<?php include("part/footer.php");?>
<!-- Footer End -->
</div>
<!-- Alert -->
<?php include("part/alert.php");?>
<!-- Alert end -->
<!-- All JS -->
<?php include("part/all-js.php");?>
<!-- All JS end -->
<!-- Data Table JS -->
<?php include("part/data-table-js.php");?>
<!-- Data Table JS end -->
<!-- Page specific script -->
<script>
$(function () {
//Initialize Select2 Elements
$(".select2").select2();
//Initialize Select2 Elements
$(".select2bs4").select2({
theme: "bootstrap4",
});
$('.transTxt').attr('placeholder', "Enter Transection details. \n Ex. Phone (send from): ")
$('#trans').on('change', function(){
var val = $(this).val();
if(val == "Bank"){
$('.transTxt').attr('placeholder', "Enter Bank details. \n Ex. Bank Name: ")
}else{
$('.transTxt').attr('placeholder', "Enter Transection details. \n Ex. Phone (send from): ")
}
});
});
</script>
<!-- Data table -->
<script>
$(document).ready(function() {
$('#orderTable thead tr').clone(true).addClass('filters bg-light shadow-sm').removeClass('bg-info').appendTo('#orderTable thead');
$('#orderTable').DataTable( {
dom: 'rtip',
orderCellsTop: true,
// buttons: [],
select: false,
aaSorting: [],
initComplete: function () {
var api = this.api();
// For each column
api.columns( '.adThText' ).eq(0).each(function (colIdx) {
// Set the header cell to contain the input element
var cell = $('.filters th').eq($(api.column(colIdx).header()).index());
var title = $(cell).text();
$(cell).html('<input type="text" class="form-control" placeholder="' + title + '" />');
$('.filters th.rmThText').text('');
// On every keypress in this input
$(
'input',
$('.filters th').eq($(api.column(colIdx).header()).index())
)
.off('keyup change')
.on('change', function (e) {
// Get the search value
$(this).attr('title', $(this).val());
var regexr = '({search})'; //$(this).parents('th').find('select').val();
var cursorPosition = this.selectionStart;
// Search the column for that value
api
.column(colIdx)
.search(
this.value != ''
? regexr.replace('{search}', '(((' + this.value + ')))')
: '',
this.value != '',
this.value == ''
)
.draw();
})
.on('keyup', function (e) {
e.stopPropagation();
$(this).trigger('change');
$(this)
.focus()[0]
.setSelectionRange(cursorPosition, cursorPosition);
});
});
},
} );
} );
</script>
<script>
// Bootstrap dynamic modal
$('#orderModal').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var recipient = button.data('whatever');
var modal = $(this);
modal.find('.modal-title').html('<strong>Invoice #' + recipient+'</strong>')
modal.find('.ini').val(recipient);
});
</script>
</body>
</html>