| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/elinternalgroups.inc |
<?php
$tbl = "el_billing";
//fetch rates
$rs = mysql_query("select * from el_config");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$unitrate = $o->unitrate;
$fixedrate = $o->fixedrate;
$plrate = $o->plrate;
$edrate = $o->edrate;
$rscrate = $o->rscrate;
$subsidymode = $o->subsidymode;
}
$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'";
$sql .= ($ext ? " and ext='No'" : '');
$sql .= ($catlist ? " and category in ($catlist)" : '');
$sql .= " order by left(flatno, pos-1), mid(flatno, pos, length(flatno)-pos+1)+0";
$rs = mysql_query($sql);
while ($o = mysql_fetch_object($rs)) {
$i++;
$flatno = $o->flatno;
$userfees = $o->userfees;
$licensee = $o->licensee;
$meterno = $o->meterno;
$contactedload = $o->contactedload;
$unitrate = $o->unitrate;
$fixedrate = $o->fixedrate;
$plrate = $o->plrate;
$edrate = $o->edrate;
$rscrate = $o->rscrate;
$subsidymode = $o->subsidymode;
$subsidy = $o->subsidy;
$external = $o->external;
$prevreading = $o->prevreading;
$curreading = $o->curreading;
$addunits = $o->addunits;
$consumedunits = $curreading - $prevreading + $addunits;;
$consumedcharge = $consumedunits * $unitrate;
$payable = 0.00;
//calculate payable
$excessunits = 0.00;
$excesscharge = 0.00;
if (!$subsidy) $subsidy = 0.00;
if ($subsidymode == 'Rupees') {
if ($consumedcharge > $subsidy) {
$excesscharge = $consumedcharge - $subsidy;
$payable = $excesscharge;
$excessunits = $payable;
}
} else if ($subsidymode == 'Units') {
if ($consumedunits > $subsidy) {
$excessunits = $consumedunits - $subsidy;
$excesscharge = $excessunits * $unitrate;
$payable = $excesscharge;
}
} else if ($subsidymode == 'None') {
$excessunits = $consumedunits;
$excesscharge = $excessunits * $unitrate;
$payable = $excesscharge;
}
//payable with userfees
$payable += $userfees;
//summarized figures
$tunit += $consumedunits;
$tcharge += $consumedcharge;
$tamount += $totalamount;
$tpayable += $payable;
$data .= "<tr><td><a href='?pg=elreceipt&id=$o->id'>$i</a></td>
<th>$flatno</th><td nowrap>$licensee</td><td>$meterno</td><td>$contactedload</td><td>$prevreading</td><td>$curreading</td>
<td align='right'>".number_format($consumedunits,2)."</td>
<td align='right'>Rs.".number_format($consumedcharge,2)."</td>
<td align='right'>".($subsidymode == 'Rupees' ? 'Rs.' : '').number_format($subsidy,2)."</td>
<td align='right'>".($subsidymode == 'Rupees' ? 'Rs.' : '').number_format($excessunits,2)."</td>
<td align='right'>Rs.".number_format($userfees,2)."</td>
<td align='right'>Rs.".($excessunits ? "<font color='red'>".number_format($payable,2)."</font>" : number_format($payable,2))."</td></tr>";
}
echo "<table width='100%' border='1' style='border-collapse: collapse'>
<thead>
<tr><th colspan='13'><h3>Electricity charges 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'>No</th>
<th rowspan='2'>SiteNo</th>
<th rowspan='2'>Licensee</th>
<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 rowspan='2'>Admissibility<br>(Rs./Units)</th><th rowspan='2'>Excess<br>(Rs./Units)</th>
<th rowspan='2'>User<br>Fees</th>
<th rowspan='2'>Payable<br>Amount</th></tr>
<tr><th>Previous</th><th>Current</th><th>Units</th><th>Charges</th></tr>
</thead>
<tfoot>
<tr><th colspan='12'>Total</th><th>Rs.".number_format(round($tpayable),2)."</th></tr>
<tr><th colspan='13'>Above readings have been taken on the last dates of this and previous month.</th></tr>
</tfoot>
<tbody>$data</tbody>
</table>";
?>