| Current Path : /var/www/html/mmishra/iws8/html/ilight/ |
| Current File : /var/www/html/mmishra/iws8/html/ilight/elupreading.inc |
<h3>UPPCL Reading</h3>
<center>
<?php
$tbl = 'el_upreading';
$month = $_REQUEST['month'];
if (!$month) $month = previous_month();//date("M-Y");
$reading = $_POST['reading'];
$dated = date("Y-m-d");
/*
if ($_POST["submit"] == 'SAVE') {
if (mysql_num_rows(mysql_query("select * from $tbl where month='$month'"))) {
mysql_query("update $tbl set reading=$reading,dated='$dated'
where month='$month'");
} else {
mysql_query("insert into $tbl(month,reading,dated)
values('$month',$reading,now())");
}
}
*/
//existing records
$rs = mysql_query("select * from el_config");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$id = $o->id;
$meterno = $o->meterno;
$initreading = $o->initreading;
$unitrate = $o->unitrate;
$contactload = $o->contactload;
$fixedrate = $o->fixedrate;
$plrate = $o->plrate;
$edrate = $o->edrate;
$rscrate = $o->rscrate;
$excessrate = $o->excessrate;
}
echo "Month <select name='month' onchange=\"javascript: document.location.href='?pg=$pg&month='+this.value\">";
if (!mysql_num_rows(mysql_query("select distinct month from $tbl where month='$month'")))
echo "<option value='$month'>$month</option>";
$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>";
$rs = mysql_query("select * from $tbl where month='$month'");
if (mysql_num_rows($rs)) {
$o = mysql_fetch_object($rs);
$reading = $o->reading;
}
echo "<table width='60%' border='1' style='border-collapse: collapse'>
<tr><th colspan='2'>Meter reading for the month of $month</th></tr>
<tr><th>Meter No.</th><td>$meterno</td></tr>
<tr><th>Initial Reading</th><td>$initreading</td></tr>
<tr><th>Contacted Load</th><td>$contactload</td></tr>
<tr><th>Fixed Rate</th><td>$fixedrate</td></tr>
<tr><th>Protective Load Rate</th><td>$plrate</td></tr>
<tr><th>ED Charge Rate</th><td>$edrate</td></tr>
<tr><th>Regulatory Surcharge Rate</th><td>$rscrate</td></tr>
<tr><th>Excess Rate</th><td>$excessrate</td></tr>
<tr><th>Reading</th><td><input type='text' name='reading' value='$reading' size='20'></td></tr>
<tr><th colspan='2'><input type='submit' name='submit' value='SAVE'></th></tr>
";
if ($reading) {
$prevreading = $initreading;
$curreading = $reading;
$consumedunit = $curreading - $prevreading;
$consumedcharge = $consumedunit * $unitrate;
$payable = 0.00;
$fixedcharge = $contactedload * $fixedrate;
$subtotal = $consumedcharge + $fixedcharge;
$plcharge = $contactedload * $plrate;
$edcharge = $subtotal * $edrate/100;
$rscharge = $subtotal * $rscrate/100;
$totalamount = $subtotal + $plcharge + $edcharge + $rscharge;
$payable = $totalamount + $userfees;
$i = 1;
$data .= "<tr><td><a href='?pg=elreceipt&id=$o->id'>$i</a></td>
<td nowrap>IIITA</td><td>$meterno</td><td>$contactload</td><td>$prevreading</td><td>$curreading</td>
<td align='right'>".number_format($consumedunit,2)."</td>
<td align='right'>Rs.".number_format($consumedcharge,2)."</td>";
$data .= "<td align='right'>Rs.".number_format($fixedcharge,2)."</td>
<td align='right'>Rs.".number_format($subtotal,2)."</td>
<td align='right'>Rs.".number_format($plcharge,2)."</td>
<td align='right'>Rs.".number_format($edcharge,2)."</td>
<td align='right'>Rs.".number_format($rscharge,2)."</td>
<td align='right'>Rs.".number_format($totalamount,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>";
$str = "<table width='100%' border='1' style='border-collapse: collapse'>
<thead>
<tr><th colspan='16'><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'>No</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 colspan='6'>Connection Charges</th>
<th rowspan='2'>User<br>Rent</th>
<th rowspan='2'>Payable<br>Amount</th></tr>
<tr><th>Previous</th><th>Current</th><th>Units</th><th>Charges</th>
<th>Fixed</th><th>SubTotal</th><th>PLC</th><th>ED</th><th>Sur</th><th>Total</th>
</tr>
</thead>
<tfoot>
<tr><th colspan='15' align='right'>Total</th><th>Rs.".number_format(round($tpayable),2)."</th></tr>
<tr><th colspan='16'>Above readings have been taken on the last dates of this and previous month.</th></tr>
</tfoot>
<tbody>$data</tbody>
</table>";
echo $str;
}
?>
</table>
</center>