| Current Path : /var/www/html/mmishra/ilight/ |
| Current File : /var/www/html/mmishra/ilight/elarrear.inc |
<h3>Arrear Billing</h3>
<center>
<?php
$tbl = "el_billing";
$recal = $_REQUEST["recal"];
$ext = $_REQUEST["ext"];
$month = $_REQUEST["month"];
if (!$month) $month = previous_month();//date("M-Y");
echo "<font size='+1'>[ </font>";
if ($ext == 1) {
echo "<a href='?pg=$pg&month=$month&ext=0'>Internal</a> | <font color='red' size='+1'>External</font>";
} else {
echo "<font color='red' size='+1'>Internal</font> | <a href='?pg=$pg&month=$month&ext=1'>External</a>";
}
echo "<font size='+1'> ]</font>
Month <select name='month' onchange=\"javascript: document.location.href='?pg=$pg&ext=$ext&month='+this.value\">";
$rs = mysql_query("select distinct month from el_reading 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>
";
if ($month != previous_month()) {
echo "Calculate <font size='+1'>[ </font><a href='?pg=$pg&month=$month&ext=$ext&recal=2'>Arrear</a><font size='+1'> ]</font>";
}
echo "<input type='hidden' name='ext' value='$ext'>";
$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;
$arrearrate = $o->arrear_rate;
}
if ($recal == 2) {
$subsidymode = 'None';
$subsidy = 0.00;
$rs = mysql_query("select * from $tbl where month='$month' order by id");
while ($o = mysql_fetch_object($rs)) {
$id = $o->id;
$unitrate = $o->unitrate;
$subsidy = $o->subsidy;
$subsidymode = $o->subsidymode;
$consumedunits = $o->curreading - $o->prevreading + $addunits;
$consumedcharge = $consumedunits * $unitrate;
$arrear = 0.00;
//calculate arrear
if ($subsidymode == 'Rupees') {
$arrearcharge = $consumedcharge + ($consumedunits * $arrearrate);
if ($arrearcharge > $subsidy) {
$arrear = $arrearcharge - $consumedcharge;
}
} else if ($subsidymode == 'Units') {
if ($consumedunits > $subsidy) {
$arrear = ($consumedunits - $subsidy) * $arrearrate;
}
} else if ($subsidymode == 'None') {
$arrear = $consumedunits * $arrearrate;
}
//update arrear field in the table
mysql_query("update $tbl set arrear=$arrear where id=$id");
}
}
if ($ext == 1) {
include "elexternalarrears.inc";
} else {
include "elinternalarrears.inc";
}
?>
</center>