-
Notifications
You must be signed in to change notification settings - Fork 47
/
view_out_standing.php
526 lines (322 loc) · 12.2 KB
/
view_out_standing.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
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
<?php
include_once("init.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>POSNIC - Payment</title>
<!-- Stylesheets -->
<!--<link href='http://fonts.googleapis.com/css?family=Droid+Sans:400,700' rel='stylesheet'>-->
<link rel="stylesheet" href="css/style.css">
<!-- Optimize for mobile devices -->
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- jQuery & JS files -->
<?php include_once("tpl/common_js.php"); ?>
<script src="js/script.js"></script>
<script LANGUAGE="JavaScript">
<!--
// Nannette Thacker http://www.shiningstar.net
function confirmSubmit()
{
var agree=confirm("Are you sure you wish to Delete this Entry?");
if (agree)
return true ;
else
return false ;
}
function confirmDeleteSubmit()
{
var flag=0;
var field=document.forms.deletefiles;
for (i = 0; i < field.length; i++){
if(field[i].checked ==true){
flag=flag+1;
}
}
if (flag <1) {
alert ("You must check one and only one checkbox!");
return false;
}else{
var agree=confirm("Are you sure you wish to Delete Selected Record?");
if (agree)
document.deletefiles.submit();
else
return false ;
}
}
function confirmLimitSubmit()
{
if(document.getElementById('search_limit').value!=""){
document.limit_go.submit();
}else{
return false;
}
}
function checkAll()
{
var field=document.forms.deletefiles;
for (i = 0; i < field.length; i++)
field[i].checked = true ;
}
function uncheckAll()
{
var field=document.forms.deletefiles;
for (i = 0; i < field.length; i++)
field[i].checked = false ;
}
// -->
</script>
<script>
/*$.validator.setDefaults({
submitHandler: function() { alert("submitted!"); }
});*/
$(document).ready(function() {
// validate signup form on keyup and submit
$("#form1").validate({
rules: {
name: {
required: true,
minlength: 3,
maxlength: 200
},
address: {
minlength: 3,
maxlength: 500
},
contact1: {
minlength: 3,
maxlength: 20
},
contact2: {
minlength: 3,
maxlength: 20
}
},
messages: {
name: {
required: "Please enter a supplier Name",
minlength: "supplier must consist of at least 3 characters"
},
address: {
minlength: "supplier Address must be at least 3 characters long",
maxlength: "supplier Address must be at least 3 characters long"
}
}
});
});
</script>
</head>
<body>
<!-- TOP BAR -->
<?php include_once("tpl/top_bar.php"); ?>
<!-- end top-bar -->
<!-- HEADER -->
<div id="header-with-tabs">
<div class="page-full-width cf">
<ul id="tabs" class="fl">
<li><a href="dashboard.php" class="dashboard-tab">Dashboard</a></li>
<li><a href="view_sales.php" class="sales-tab">Sales</a></li>
<li><a href="view_customers.php" class=" customers-tab">Customers</a></li>
<li><a href="view_purchase.php" class="purchase-tab">Purchase</a></li>
<li><a href="view_supplier.php" class=" supplier-tab">Supplier</a></li>
<li><a href="view_product.php" class=" stock-tab">Stocks / Products</a></li>
<li><a href="view_payments.php" class="active-tab payment-tab">Payments / Outstandings</a></li>
<li><a href="view_report.php" class="report-tab">Reports</a></li>
</ul> <!-- end tabs -->
<!-- Change this image to your own company's logo -->
<!-- The logo will automatically be resized to 30px height. -->
<a href="#" id="company-branding-small" class="fr"><img src="<?php if(isset($_SESSION['logo'])) { echo "upload/".$_SESSION['logo'];}else{ echo "upload/posnic.png"; } ?>" alt="Point of Sale" /></a>
</div> <!-- end full-width -->
</div> <!-- end header -->
<!-- MAIN CONTENT -->
<div id="content">
<div class="page-full-width cf">
<div class="side-menu fl">
<h3>Out Standing Payment</h3>
<ul>
<li><a href="view_payments.php">Payments</a></li>
<li><a href="view_out_standing.php">Out standings</a></li>
</ul>
</div> <!-- end side-menu -->
<div class="side-content fr">
<div class="content-module">
<div class="content-module-heading cf">
<h3 class="fl">Out Standing</h3>
<span class="fr expand-collapse-text">Click to collapse</span>
<span class="fr expand-collapse-text initial-expand">Click to expand</span>
</div> <!-- end content-module-heading -->
<div class="content-module-main cf">
<table>
<form action="" method="post" name="search" >
<input name="searchtxt" type="text" class="round my_text_box" placeholder="Search" >
<input name="Search" type="submit" class="my_button round blue text-upper" value="Search">
</form>
<form action="" method="get" name="limit_go">
Page per Record<input name="limit" type="text" class="round my_text_box" id="search_limit" style="margin-left:5px;" value="<?php if(isset($_GET['limit'])) echo $_GET['limit']; else echo "10"; ?>" size="3" maxlength="3">
<input name="go" type="button" value="Go" class=" round blue my_button text-upper" onclick="return confirmLimitSubmit()">
</form>
<form name="deletefiles" action="delete.php" method="post">
<table>
<?php
$SQL = "SELECT DISTINCT(stock_id) FROM stock_entries where type LIKE 'entry%' and balance>0";
if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
{
$SQL = "SELECT DISTINCT(stock_id) FROM stock_entries WHERE stock_name LIKE '%".$_POST['searchtxt']."%' and balance>0 AND type LIKE 'entry%'";
}
$tbl_name="stock_entries"; //your table name
// How many adjacent pages should be shown on each side?
$adjacents = 3;
/*
First get total number of rows in data table.
If you have a WHERE clause in your query, make sure you mirror it here.
*/
$query = "SELECT COUNT(stock_id) as num FROM $tbl_name where type LIKE 'entry%' and balance>0";
if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
{
$query = "SELECT COUNT(stock_id) as num FROM stock_entries WHERE stock_name LIKE '%".$_POST['searchtxt']."%' and balance>0 AND type LIKE 'entry%'";
}
$total_pages = mysql_fetch_array(mysql_query($query));
$total_pages = $total_pages[num];
/* Setup vars for query. */
$targetpage = "view_out_standing.php"; //your file name (the name of this file)
$limit = 10; //how many items to show per page
if(isset($_GET['limit']) && is_numeric($_GET['limit'])){
$limit=$_GET['limit'];
$_GET['limit']=10;
}
$page = $_GET['page'];
if($page)
$start = ($page - 1) * $limit; //first item to display on this page
else
$start = 0; //if no page var is given, set start to 0
/* Get data. */
$sql = "SELECT * FROM stock_entries where type LIKE 'entry%' and balance>0 ORDER BY date desc LIMIT $start, $limit ";
if(isset($_POST['Search']) AND trim($_POST['searchtxt'])!="")
{
$sql= "SELECT * FROM stock_entries WHERE stock_name LIKE '%".$_POST['searchtxt']."%' AND type LIKE 'entry%' and balance>0 ORDER BY date desc LIMIT $start, $limit";
}
$result = mysql_query($sql);
/* Setup page vars for display. */
if ($page == 0) $page = 1; //if no page var is given, default to 1.
$prev = $page - 1; //previous page is page - 1
$next = $page + 1; //next page is page + 1
$lastpage = ceil($total_pages/$limit); //lastpage is = total pages / items per page, rounded up.
$lpm1 = $lastpage - 1; //last page minus 1
/*
Now we apply our rules and draw the pagination object.
We're actually saving the code to a variable in case we want to draw it more than once.
*/
$pagination = "";
if($lastpage > 1)
{
$pagination .= "<div >";
//previous button
if ($page > 1)
$pagination.= "<a href=\"view_out_standing.php?page=$prev&limit=$limit\" class=my_pagination >Previous</a>";
else
$pagination.= "<span class=my_pagination>Previous</span>";
//pages
if ($lastpage < 7 + ($adjacents * 2)) //not enough pages to bother breaking it up
{
for ($counter = 1; $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=my_pagination>$counter</span>";
else
$pagination.= "<a href=\"view_out_standing.php?page=$counter&limit=$limit\" class=my_pagination>$counter</a>";
}
}
elseif($lastpage > 5 + ($adjacents * 2)) //enough pages to hide some
{
//close to beginning; only hide later pages
if($page < 1 + ($adjacents * 2))
{
for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)
{
if ($counter == $page)
$pagination.= "<span class=my_pagination>$counter</span>";
else
$pagination.= "<a href=\"view_out_standing.php?page=$counter&limit=$limit\" class=my_pagination>$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"view_out_standing.php?page=$lpm1&limit=$limit\" class=my_pagination>$lpm1</a>";
$pagination.= "<a href=\"view_out_standing.php?page=$lastpage&limit=$limit\" class=my_pagination>$lastpage</a>";
}
//in middle; hide some front and some back
elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))
{
$pagination.= "<a href=\"view_out_standing.php?page=1&limit=$limit\" class=my_pagination>1</a>";
$pagination.= "<a href=\"view_out_standing.php?page=2&limit=$limit\" class=my_pagination>2</a>";
$pagination.= "...";
for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=my_pagination>$counter</span>";
else
$pagination.= "<a href=\"view_out_standing.php?page=$counter&limit=$limit\" class=my_pagination>$counter</a>";
}
$pagination.= "...";
$pagination.= "<a href=\"view_out_standing.php?page=$lpm1&limit=$limit\" class=my_pagination>$lpm1</a>";
$pagination.= "<a href=\"view_out_standing.php?page=$lastpage&limit=$limit\" class=my_pagination>$lastpage</a>";
}
//close to end; only hide early pages
else
{
$pagination.= "<a href=\"$view_out_standing.php?page=1&limit=$limit\" class=my_pagination>1</a>";
$pagination.= "<a href=\"$view_out_standing.php?page=2&limit=$limit\" class=my_pagination>2</a>";
$pagination.= "...";
for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)
{
if ($counter == $page)
$pagination.= "<span class=my_pagination >$counter</span>";
else
$pagination.= "<a href=\"$targetpage?page=$counter&limit=$limit\" class=my_pagination>$counter</a>";
}
}
}
//next button
if ($page < $counter - 1)
$pagination.= "<a href=\"view_out_standing.php?page=$next&limit=$limit\" class=my_pagination>Next</a>";
else
$pagination.= "<span class= my_pagination >Next</span>";
$pagination.= "</div>\n";
}
?>
<tr>
<th>No</th>
<th>Stock ID</th>
<th>Due Date</th>
<th>Supplier</th>
<th>Total</th>
<th>Payment</th>
<th>Balance</th>
<th>Add Payment</th>
</tr>
<?php $i=1; $no=$page-1; $no=$no*$limit;
while($row = mysql_fetch_array($result))
{
?>
<tr>
<td> <?php echo $no+$i; ?></td>
<td><?php echo $row['stock_id']; ?></td>
<td> <?php echo $row['stock_id'];?></td>
<td> <?php echo $row['stock_supplier_name'];?></td>
<td> <?php echo $row['total']; ?></td>
<td> <?php echo $row['payment']; ?></td>
<td> <?php echo $row['balance']; ?></td>
<td> <a href="update_out_standing.php?sid=<?php echo $row['stock_id'];?>&table=stock_entries&return=view_out_standing.php" class="table-actions-button ">Pay Now</a>
</tr>
<?php $i++; } ?>
<tr>
<td align="center"><div style="margin-left:20px;"><?php echo $pagination; ?></div></td>
</tr>
</table>
</form>
</div>
</div>
<div id="footer">
<p>Any Queries email to <a href="mailto:[email protected]?subject=Stock%20Management%20System">[email protected]</a>.</p>
</div> <!-- end footer -->
</body>
</html>