Above is a brief idea of what I want to do.To simply get the fee type and amount on the fee item in order of priority.Ignoring fee type items that have already been paid for or covered. I have 3 tables in my Sqlfiddle :
If previous payment already covered the 1st few items then it should start from current item. Example scenario. If 550 was paid initially and 400 paid now it should start at Ltt with amount 20, EWC 200,RMI 180.Because BES 250 and a part of LTT of 300 is already paid for
This is my html and php code attempt
<?php
$sql = "SELECT t.type,p.amount as payable FROM fee_types t INNER JOIN fee_periods p ON t.feetype_id = p.feetype_id
WHERE p.term_name='Term 1' AND p.class_for='Class 1' order by t.type_priority ASC ";
$result = mysql_query($sql) or die('Cannot get Info7.');
$row5 = mysql_fetch_assoc($result);
extract($row5);
$sql = "SELECT * , DATE_FORMAT( pay_date, '%d/%m/%Y' ) AS pay_date FROM fees_payment WHERE adminNo = '$adminNo' AND term_id = '$term_id'
ORDER BY pay_id DESC";
$result = mysql_query($sql) or die('Cannot get Info.');
?>
<table width="700" border="1" cellspacing="0" cellpadding="5">
<tr>
<td width="5%"><strong>ID</strong></td>
<td width="42.5%"><strong>Fee Type</strong></td>
<td width="42.5%"><strong>Amount</strong></td>
</tr>
<?php
if (mysql_num_rows($result) > 0) {
$i = 0;
while($row = mysql_fetch_assoc($result)) {
extract($row);
if ($i%2) {
$class = 'row1';
} else {
$class = 'row2';
}
$i += 1;
?>
<tr>
<td>#</td>
<td><?php if ($payable<$amount) {echo $type;} ?></td>
<td><?php echo number_format($amount,2);?></td>
</tr>
<?php
}
}
else{
echo 'No Details for now.';
}
?>
</table>
This is how i would do it. Have a table structure as this
student_details(id,name,class..)//student table
fee_terms(term_id,class,total_fee)//Entry for fees to be paid by student in that class
fee_term_specifics(item_id,total_amount,term_id)//items paid for in that term
student_payments(stud_id,item_id,amt_paid,date_paid)//Store student payments
During entering of fee payments the clerk selects a student and the system generates a list the items not paid by student and their balance.(A join of fee_term_specifics & student_payments).
Let the clerk enter the total amount the student has paid upon which the system distributes the amount to the specific item until the paid amount is exhausted.
NB:: The clerk should be able alter the distibution.
Upon submission of form save the data in the student_payments table.
Hint:: Have a form with inputs for all the payment types but only display for those not yet paid for. You can use a javascript method to distribute the students payment depending on item weight. Also have a way to handle situations of excess payments. You can have an item type called excess-payment that is filled last.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.