-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_collection.php
320 lines (275 loc) · 10.6 KB
/
show_collection.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
<?php
session_start();
if (!isset($_SESSION["username"])) {
header("location:admin_login.php");
exit;
}
include "include/connect.php";
include "include/gensettings.php";
include "include/function.php";
include "user.php";
//if delete has been clicked
if ($_GET['id']) {
//authorized
if ($del_book == "on") {
$id = $_GET['id'];
$s = "DELETE FROM income WHERE id='$id'";
mysql_query($s, $connect) or die("cant execute query!....2.");
$message = "You have successfully deleted an item in the income table!";
} else {
$message = "You are not allowed to delete an item in the Income table!";
}
} // if delete link is clicked
$window = 1;
//#################################################################################################
//default income
$total_income = 0;
//collection with date range
if (isset($_POST['op'])) {
$type_code = $_POST['type'];
$start = $_POST['start'];
$end = $_POST['ending'];
$_SESSION['borrow_type'] = $_POST['type']; //school code
$_SESSION['start'] = $_POST['start']; //start date
$_SESSION['ending'] = $_POST['ending']; //end date
$s = date($start);
$e = date($end);
//if school code is equal to all
if (($start != "") && ($end != "")) {
$sql = "select * from income where pay_date BETWEEN
'$start' AND '$end' order by pay_date,id";
$sql2 = "select * from income where pay_date BETWEEN
'$start' AND '$end' order by pay_date,id";
$income_msg = "Total Income from " . $start . " to " . $end;
} else {
$sql = "select * from income order by pay_date,id";
$sql2 = "select * from income order by pay_date,id";
$income_msg = "Total Income";
}
}
if ($_POST['op'] != 1) {
$sql = "select * from income order by pay_date,id";
$sql2 = "select * from income order by pay_date,id";
$income_msg = "Total Income";
}
//compute total income
$nyoy = mysql_query($sql2, $connect) or die(mysql_error());
while ($rownyoy = mysql_fetch_array($nyoy)) {
$total_amount = $rownyoy['total_amount'];
$total_income = $total_income + $total_amount;
}
//############PAGINATION ################
/**Set current,
*prev and next page
*/
$page = (!isset($_GET['page'])) ? 1 : $_GET['page'];
$prev = ($page - 1);
$next = ($page + 1);
/**Max results
*per page
*/
$max_results = $rec_per_page;
/* Calculate the offset */
$from = (($page * $max_results) - $max_results);
/**Query the db for total
*results. You need to edit
*the sql to fit your needs
*/
$result = mysql_query($sql) or die(mysql_error());
$total_results = mysql_num_rows($result);
$number = $total_results;
$total_pages = ceil($total_results / $max_results);
$pagination = '';
/* Create a PREV link if there is one */
if ($page > 1) {
//pass the values of the $txt variables
$pagination .= '<a href="show_collection.php?sql=' . $sql . '&page=' . $prev . '"
title="Previous"> <Previous</a> ';
} else {
$pagination .= '<strong> <Previous</strong> ';
}
// Loop through the total pages
for ($i = 1; $i <= $total_pages; $i++) {
if (($page) == $i) {
$pagination .= $i;
} else {
$pagination .= ' <a href="show_collection.php?type=' . $type . '&sql=' . $sql . '&search=' . $search . '&page=' . $i . '" title="page ' . $i . '">' . $i . '</a> ';
}
}
/* Print NEXT link if there is one */
if ($page < $total_pages) {
$pagination .= '<a href="show_collection.php?type=' . $type . '&sql=' . $sql . '&search=' . $search . '&page=' . $next . '"
title="Next">Next ></a>';
} else {
$pagination .= ' <strong>Next ></strong>';
}
//############PAGINATION END################
//echo $from;
//echo $max_results;
//perform the query
$sql .= " LIMIT $from, $max_results";
$result2 = mysql_query($sql) or die(mysql_error());
$number = mysql_num_rows($result2);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/JavaScript" src="js/function.js">
</script>
<SCRIPT language=javascript>
//-->
function trash()
{
var answer = confirm("Are you sure you wish to delete this item?\n Click OK to proceed otherwise click Cancel.")
if (!answer){
return false;
}
document.supportform.action = "show_collection.php"
document.supportform.method="post"
document.supportform.submit();
return true;
}
</SCRIPT>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title><?php echo $system_title . "--" . $footer; ?></title>
<link rel="stylesheet" type="text/css" href="css/<?php echo $css; ?>" />
</head>
<body >
<div class="header">
<div class="logo"><?php echo " " . $header_title; ?> </div>
<div id="Layer1"><img src="images/<?php echo $logo; ?>" width="117" height="110" />
<div id="Layer2"></div>
</div>
</div>
<div class="navbg">
<div id="navcontainer">
<ul id="navlist">
<li id="active"><a href="home.php" id="current" title="Home">Home</a></li>
<li><a href="admin.php" title="Search">Search</a></li>
<li><a href="admin_add_new.php" title="Add book">Add book</a></li>
<li><a href="barrower.php" title="Borrower">Borrower</a></li>
<li><a href="inventory.php" title="Inventory">Inventory</a></li>
<li><a href="settings.php" title="Settings">Settings</a></li>
<li><a href="help1.php" title="Help">Help</a></li>
<li><a href="logout.php" title="Logout">Logout</a></li>
</ul>
</div>
</div>
<div class="maincontent">
<div class="floatelft">
<h2><a href="inventory.php">Inventory</a>>>Income Collection </h2>
<form id="form1" name="myform" method="post" action="show_collection.php">
<table width="100%" cellpadding="5" cellspacing="5" class="bg">
<tr>
<td colspan="3"><strong>Enter the date:(yyyy-mm-dd) format </strong></td>
<td width="11%"> </td>
<td width="9%"> </td>
<td width="23%"> </td>
</tr>
<tr>
<td width="19%" valign="top"><strong>Start</strong> <input type="text" name="start" id="start" size="10" value="<?php echo $start; ?>"/></td>
<td width="18%" valign="top"><strong>End</strong> <input type="text" name="ending" id="ending" size="10" value="<?php echo $end; ?>"/></td>
<td width="20%" valign="top"><input name="submit" type="submit" class="btn" value="Search"/></td>
<td valign="top"> </td>
<td><a href="show_book_borrow.php?show=do"></a></td>
<td> </td>
</tr>
<tr><td> </td>
<td colspan="2"> </td>
<td> </td>
<td><input name="op" type="hidden" id="op" value="1" /></td>
<td> </td>
</tr>
</table>
</form>
<p>
<?php
display_pagination($pagination);
?>
<a href="show_collection.php"></a></p>
<?php
if ($window == 1) {
//output if there is
if (mysql_num_rows($result2) != 0) {
echo '<img src="images/arrowr.gif" width="15" height="9" />You have <strong>' . $total_results . '</strong> transactions made<br><br><hr/>';
?>
<table width="100%" border="0">
<tr>
<td colspan="2"><h3><strong>INCOME RECORDS </strong></h3></td>
<td colspan="3"><?php echo $message; ?></td>
<td width="7%"> </td>
<td width="1%"> </td>
</tr>
<tr>
<td width="16%"><div align="center"><strong>Borrower's ID</strong></div></td>
<td width="16%"><div align="center"><strong>Payable</strong></div></td>
<td width="18%"><div align="center"><strong>Deduction</strong></div></td>
<td width="13%"><div align="center"><strong>Amount Paid</strong></div></td>
<td width="29%"><div align="center"><strong>Pay Date</strong></div></td>
</tr>
<?php
$x = 2;
$y = 1;
$i = 0;
while ($row = mysql_fetch_array($result2)) {
$id = $row['id'];
$bar_id = $row['bar_id'];
$subtotal = $row['subtotal'];
$deduct = $row['deduct'];
$total_amount = $row['total_amount'];
$pay_date = $row['pay_date'];
if ($x > $y) {
$y += 2;
$bg = "#ECE9D8";
} else {
$x += 2;
$bg = "#Ffffff";
}
?>
<tr >
<td bgcolor="<?php echo $bg; ?>"><div align="center"><b><?php echo $bar_id; ?> </b></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center">P <?php echo $subtotal; ?></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center">P <?php echo $deduct; ?></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center">P <?php echo $total_amount; ?></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center"><?php echo $pay_date; ?></div></td>
</tr>
<?php
}
?>
<tr >
<td bgcolor="<?php echo $bg; ?>"><div align="center"><br /></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center"><br /></div></td>
<td colspan="2" bgcolor="<?php echo $bg; ?>"><div align="center"><br /></div>
<div align="right"><strong><?php echo $income_msg; ?> : </strong></div></td>
<td bgcolor="<?php echo $bg; ?>"><div align="center"><strong>P <?php echo $total_income; ?></strong></div></td>
</tr>
</table>
<?php
} else {
echo '<img src="images/arrowr.gif" width="15" height="9" />You have <strong>' . $total_results . '</strong> transactions made<br><br><hr/>';}
}
?>
<p>
<?php
display_pagination($pagination);
?><br />
<input type="button" name="submit2" value="Print..." class="btn" onclick="MM_openBrWindow1('report/index.php?sql=99&start=<?php echo $start; ?>&end=<?php echo $end; ?>&income=<?php echo $total_income; ?>&income_msg=<?php echo $income_msg; ?>','','scrollbars=yes,width=1000,height=800')" onmouseover="this.className='btn btnhov'" onmouseout="this.className='btn'"/>
<a href="show_collection.php"></a></p>
<p> </p>
<p> </p>
</div>
</div>
<div class="lowercontent"></div>
<div class="footer1">
<table align="center">
<tr>
<td><img src="logo/anilag systems logo 300x155 trnsparent.png" /></td>
<td> </td>
<td><img src="images/isch.gif" width="200" height="70"/></td>
</tr>
</table></div>
<div class="footer">
<?php echo $system_title; ?><br/><?php echo $footer; ?>
</div>
</body>
</html>