| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/elpaybill.inc |
<h3>Bill Payment</h3>
<center>
<?php
$tbl = 'el_billing';
$id = $_REQUEST['id'];
$mode = $_POST['mode'];
$month = previous_month();
$dated = date("Y-m-d");
if ($_POST["submit"] == 'SAVE') {
if (mysql_num_rows(mysql_query("select * from $tbl where id=$id"))) {
mysql_query("update $tbl set paid='Yes',mode='$mode' where id=$id");
}
}
$sql = "select *,
least(
case when locate('0', flatno)>0 then locate('0', flatno) else length(flatno)+1 end,
case when locate('1', flatno)>0 then locate('1', flatno) else length(flatno)+1 end,
case when locate('2', flatno)>0 then locate('2', flatno) else length(flatno)+1 end,
case when locate('3', flatno)>0 then locate('3', flatno) else length(flatno)+1 end,
case when locate('4', flatno)>0 then locate('4', flatno) else length(flatno)+1 end,
case when locate('5', flatno)>0 then locate('5', flatno) else length(flatno)+1 end,
case when locate('6', flatno)>0 then locate('6', flatno) else length(flatno)+1 end,
case when locate('7', flatno)>0 then locate('7', flatno) else length(flatno)+1 end,
case when locate('8', flatno)>0 then locate('8', flatno) else length(flatno)+1 end,
case when locate('9', flatno)>0 then locate('9', flatno) else length(flatno)+1 end) pos
from $tbl where month='$month' and external='Yes' and paid='No'
order by left(flatno, pos-1), mid(flatno, pos, length(flatno)-pos+1)+0";
$rs = mysql_query("select * from el_config");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$unitrate = $o->unitrate;
$subsidymode = $o->subsidymode;
$receipt = $o->receipt;
$receiptto = $o->receiptto;
$summary = $o->summary;
$summaryto = $o->summaryto;
$bill = $o->bill;
$billto = $o->billto;
}
$rs = mysql_query($sql);
while ($o = mysql_fetch_object($rs)) {
$i++;
$flatno = $o->flatno;
$licensee = $o->licensee;
$userfees = $o->userfees;
$meterno = $o->meterno;
$contactedload = $o->contactedload;
$unitrate = $o->unitrate;
$fixedrate = $o->fixedrate;
$plrate = $o->plrate;
$edrate = $o->edrate;
$rscrate = $o->rscrate;
$subsidy = $o->subsidy;
$external = $o->external;
$prevreading = $o->prevreading;
$curreading = $o->curreading;
$addunits = $o->addunits;
$paid = $o->paid;
$mode = $o->mode;
//get licensee details
$sr = mysql_query("select * from el_licensee where flatno='$flatno'");
while ($q = mysql_fetch_object($sr)) {
$fullname = $q->fullname;
$designation = $q->designation;
$email = $q->email;
$category = $q->category;
$external = $q->external;
$sharing = $q->sharing;
}
$consumedunit = $curreading - $prevreading + $addunits;
$consumedcharge = $consumedunit * $unitrate;
if ($external == 'Yes') {
$fixedcharge = $contactedload * $fixedrate;
$subtotal = $consumedcharge + $fixedcharge;
$plcharge = $contactedload * $plrate;
$edcharge = $subtotal * $edrate/100;
$rscharge = $subtotal * $rscrate/100;
$totalamount = $subtotal + $plcharge + $edcharge + $rscharge;
$payable = $totalamount;
} else {
$excessunit = $consumedunit - $subsidy;
if ($excessunit > 0) {
$excesscharge = $excessunit * $unitrate;
} else {
$excessunit = 0;
$excesscharge = 0;
}
$payable = $excesscharge;
}
//payable with userfees
$payable += $userfees;
//summarized figures
$tunit += $consumedunit;
$tcharge += $consumedcharge;
$tamount += $totalamount;
$tsubsidy += $subsidy;
$tpayable += $payable;
echo "<a name='$o->id'></a>
<div align='right'>Ref.No.: IIIT-A/iLight-$o->id/$month<br>Date: ".date("d/m/Y")."</div>
<div align='left'>[ $i ]<dir>
$fullname ($email)<br>
$flatno, IIITA Campus, Devghat, Jhalwa<br>
Allahabad-211012 (UP) INDIA
</dir></div>
<table width='100%' border='1' style='border-collapse: collapse'>
<thead>
<tr><th colspan='14'><h3>Electricity bill for the month of $month</h3>
(Unit rate: Rs. $unitrate/unit, Fixed rate: $fixedrate/KVA/month,
P.Load rate: $plrate/KVA/month, ED rate: $edrate%, Reg.Surcharge: $rscrate%)</th></tr>
<tr><th rowspan='2'>MeterNo</th>
<th rowspan='2'>Contacted<br>Load</th>
<th colspan='2'>KWH Meter Reading</th>
<th colspan='2'>Consumption</th>
<th colspan='8'>Connection Charges</th></tr>
<tr><th>Previous</th><th>Current</th><th>Units</th><th>Charge</th>
<th>Fixed</th><th>SubTotal</th><th>PLC</th><th>ED</th><th>Sur</th>
<th>Total</th><th>Rent</th><th>Payable</th></tr>
</thead>
<tfoot>
<tr><th colspan='13' align='right'>Total Payable Amount</th>
<th>Rs.".number_format($tpayable,2)."</th></tr>";
if ($id == $o->id) {
echo "<tr><td colspan='14'>Payment mode <input type='text' name='mode' value='$mode' size='80'></th></tr>
<tr><th colspan='14'><input type='hidden' name='id' value='$o->id'>
<input type='submit' name='submit' value='SAVE'></th></tr>";
} else {
echo "<tr><td align='right' colspan='14'>[ <a href='?pg=$pg&id=$o->id#$o->id'>Mark as Paid</a> ]</td></tr>";
}
echo "</tfoot>
<tbody>
<tr>
<td align='center'>$meterno</td>
<td align='center'>$contactedload</td>
<td align='center'>$prevreading</td>
<td align='center'>$curreading</td>
<td align='center'>".number_format($consumedunit,2)."</td>
<td align='center'>Rs.".number_format($consumedcharge,2)."</td>
<td align='center'>Rs.".number_format($fixedcharge,2)."</td>
<td align='center'>Rs.".number_format(round($subtotal),2)."</td>
<td align='center'>Rs.".number_format($plcharge,2)."</td>
<td align='center'>Rs.".number_format($edcharge,2)."</td>
<td align='center'>Rs.".number_format($rscharge,2)."</td>
<td align='center'>Rs.".number_format($totalamount,2)."</td>
<td align='center'>Rs.".number_format($userfees,2)."</td>
<td align='center'>Rs.".number_format($payable,2)."</td>
</tr>
</tbody>
</table><br>";
$tunit = 0; $tcharge = 0; $tamount = 0; $tsubsidy = 0; $tpayable = 0;
}
?>