-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathview_out_standing.php
393 lines (228 loc) · 15.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
<?php
include_once("init.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PDV Web - Payment</title>
<!-- Stylesheets -->
<!---->
<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 src="js/view_out_standing.js"></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">
<?php require_once ("mainmenu.php");?>
<!-- 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="PDV Web"/></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">CLIQUE PARA FECHAR</span>
<span class="fr expand-collapse-text initial-expand">CLIQUE PARA ABRIR</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 ORDER BY id DESC";
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%' ORDER BY id DESC";
}
$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 ORDER BY id DESC";
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%' ORDER BY id DESC";
}
$total_pages = mysqli_fetch_array(mysqli_query($db->connection, $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 = isset($_GET['page']) ? $_GET['page'] : 0;
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%' 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%' ORDER BY date desc LIMIT $start, $limit";
}
$result = mysqli_query($db->connection, $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>ID</th>
<th>Stock ID</th>
<th>Supplier</th>
<th>Total</th>
<th>Payment</th>
</tr>
<?php $i = 1;
$no = $page - 1;
$no = $no * $limit;
while ($row = mysqli_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>
</td>-->
</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>Nome da Empresa - www.nomedaempresa.com.br</a>.
</p>
</div>
<!-- end footer -->
</body>
</html>