-
Notifications
You must be signed in to change notification settings - Fork 0
/
viewpaymentbyfn.php
95 lines (64 loc) · 1.83 KB
/
viewpaymentbyfn.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
<?php
// Start the session
session_start();
?>
<html>
<head>
<?php require "header.php"; ?>
</head>
<body>
<div class=wraper>
<?php require "nav_bar.php"; ?>
<a href=index.php>Home</a> - View Payments by Family Number
<h2>View Payments by Family Number</h2>
<?php
if(isset($_POST["submit"]) || isset($_GET["fn"])){
if(isset($_POST["submit"])){ $fn = $_POST["fn"];} else {$fn = $_GET["fn"]; $slip = $_GET["slip"]; echo "<a href=payment.php?slip=".$_GET["slip"].">Back to Slip</a>";}
$fndata = mysqli_query($con,"SELECT * FROM slips WHERE faimlynum = $fn");
echo "<table class='table table-light table-hover' ><th>Slip Sr. No.</th><th>Fee Month</th><th>Amount</th><th>Paid</th><th>Balance</th>";
while($row = mysqli_fetch_array($fndata)){
$id = $row["id"];
$paid = mysqli_fetch_array(mysqli_query($con,"SELECT SUM(amount) AS amount FROM payments WHERE srno = $id"));
if($row["total"] - $paid["amount"]>0){echo "<tr class='table-danger' >";} else {echo "<tr>";}
echo "<td>";
echo "<a href=payment.php?slip=".$row["id"].">".$row["id"]."</a>";
echo "</td>";
echo "<td>";
echo $row["month"];
echo "</td>";
echo "<td>";
echo $row["total"];
echo "</td>";
echo "<td>";
echo $paid["amount"];
echo "</td>";
echo "<td>";
echo $row["total"] - $paid["amount"];
echo "</td>";
echo "</tr>";
}
echo "</table>";
}
else{
echo "<form action=viewpaymentbyfn.php method=post >";
echo "<table>";
echo "<tr><td>";
echo "Enter Family Number: ";
echo "</td><td>";
echo " <select name=fn>";
$dt = mysqli_query($con,"SELECT DISTINCT faimlynum FROM slips ");
while($fai = mysqli_fetch_array($dt)){
echo "<option value=".$fai["faimlynum"]." >".$fai["faimlynum"]."</option>";
}
echo " </select>";
echo "</td></tr>";
echo "<tr><td></td><td>";
echo "<input type=submit name=submit value=View >";
echo "</td></tr>";
echo "</table>";
echo "</form>";
}
?>
</div>
</body>
</html>