| Current Path : /var/www/html/mmishra/iws8/html/ilight/mybp/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/mybp/elcsummary.inc |
<h1><img src='images/bulb7.jpg' height='12'> Consumption Chart</h1>
<?php
$tbl = "el_billing";
$month = $_REQUEST["month"];
if (!$month) $month = previous_month();//date("M-Y");
echo "<b>For consumption chart, select Month</b> <select name='month'>";
$rs = mysql_query("select distinct month from $tbl order by id desc");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->month'";
if ($o->month == $month) echo " selected";
echo ">$o->month</option>";
}
echo "</select> <input type='submit' name='submit' value='OK'>";
$rs = mysql_query("select * from el_config");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$unitrate = $o->unitrate;
$receipt = $o->receipt;
$receiptto = $o->receiptto;
$summary = $o->summary;
$summaryto = $o->summaryto;
}
if ($month) {
//$rs = mysql_query("select * from $tbl where month='$month' order by flatno");
$rs = mysql_query("select * from (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') el_cbilling
order by left(flatno, pos-1), mid(flatno, pos, length(flatno)-pos+1)+0");
while ($o = mysql_fetch_object($rs)) {
$i++;
$flatno = $o->flatno;
$curreading = $o->curreading;
$prevreading = $o->prevreading;
$units = $o->units;
$amount = $o->amount;
if (!$amount) $amount = 0.00;
$subsidy = $o->subsidy;
if (!$subsidy) $subsidy = 0.00;
$payable = $o->payable;
if (!$payable) $payable = 0.00;
//get category of licensee
$sr = mysql_query("select * from el_licensee where flatno='$flatno'");
if (mysql_num_rows($sr)) {
$q = mysql_fetch_object($sr);
$fullname = $q->fullname;
$category = $q->category;
$tunits += $units;
$tamount += $amount;
$tsubsidy += $subsidy;
$tpayable += $payable;
$data .= "<tr><td>$i</td><td>$flatno</td><td>$fullname</td>
<td align='right'>$units</td><td align='right'>Rs. $amount</td><td align='right'>Rs. $subsidy</td><td align='right'>Rs. $payable</td>
</tr>";
}
}
echo "<p>
<table width='100%' border='1' style='border-collapse: collapse'>
<thead>
<tr><th colspan='7'>Electricity consumption chart for the month of $month</th></tr>
<tr><th rowspan='2'>No</th><th rowspan='2'>FlatNo</th><th rowspan='2'>Licensee</th><th colspan='4'>Consumption & Charges (@ Rs. $unitrate)</th></tr>
<tr><th>Units</th><th>Amount</th><th>Admissibility</th><th>Payable</th></tr>
</thead>
<tfoot>
<tr><th colspan='3'>Total</th><th align='right'>".number_format($tunits,2,'.','')."</th><th align='right'>Rs. ".number_format($tamount,2,'.','')."</th>
<th></th><th align='right'>Rs. ".number_format($tpayable,2,'.','')."</th></tr>
<tr><th colspan='7'>Above readings have been taken on last date of $month and previous month.</th></tr>
</tfoot>
<tbody>$data</tbody>
</table></p>
<b>To-<br>
<dir>$summaryto</dir><p>$summary</p>";
}
?>