Your IP : 216.73.216.40


Current Path : /var/www/html/mmishra/iws8/html/ilight/
Upload File :
Current File : /var/www/html/mmishra/iws8/html/ilight/elexternalarrears.inc

<?php
$tbl = "el_billing";

//get the new rates
$rs = mysql_query("select * from el_config");
if (mysql_num_rows($rs)) {
	$o = mysql_fetch_object($rs);
	$unitrate1 = $o->unitrate;
	$fixedrate1 = $o->fixedrate;
	$plrate1 = $o->plrate;
	$edrate1 = $o->edrate;
	$rscrate1 = $o->rscrate;
	$arrearrate = $o->arrear_rate;
}

//loop through readings
$rs = mysql_query("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' 
  	order by left(flatno, pos-1), mid(flatno, pos, length(flatno)-pos+1)+0");

while ($o = mysql_fetch_object($rs)) {
	$i++;
	$flatno = $o->flatno;
	$userfees = $o->userfees;
	$licensee = $o->licensee;
	$meterno = $o->meterno;
	$contactedload = $o->contactedload;
	$unitrate2 = $o->unitrate;
	$fixedrate2 = $o->fixedrate;
	$plrate2 = $o->plrate;
	$edrate2 = $o->edrate;
	$rscrate2 = $o->rscrate;
	
	$prevreading = $o->prevreading;
	$curreading = $o->curreading;
	$addunits = $o->addunits;
	$arrear = $o->arrear;

	$consumedunits = $curreading - $prevreading + $addunits;
	$payable = 0.00;
	
	$consumedcharge1 = $consumedunits * $unitrate1;
	$fixedcharge1 = $contactedload * $fixedrate1;
	$subtotal1 = $consumedcharge1 + $fixedcharge1;
	$plcharge1 = $contactedload * $plrate1;
	$edcharge1 = $subtotal1 * $edrate1/100;
	$rscharge1 = $subtotal1 * $rscrate1/100;
	$totalamount1 = $subtotal1 + $plcharge1 + $edcharge1 + $rscharge1;

	$consumedcharge2 = $consumedunits * $unitrate2;
	$fixedcharge2 = $contactedload * $fixedrate2;
	$subtotal2 = $consumedcharge2 + $fixedcharge2;
	$plcharge2 = $contactedload * $plrate2;
	$edcharge2 = $subtotal2 * $edrate2/100;
	$rscharge2 = $subtotal2 * $rscrate2/100;
	$totalamount2 = $subtotal2 + $plcharge2 + $edcharge2 + $rscharge2;
	
	$payable = $totalamount1 - $totalamount2;//arrear;//totalamount + $userfees;
	//summarized figures
	$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($consumedcharge1,2)."</td>
	
	<td align='right'>Rs.".number_format($totalamount2,2)."</td>
	<td align='right'>Rs.".number_format($totalamount1,2)."</td>
	<td align='right'>Rs.".number_format($payable,2)."</td></tr>";
}

echo "<table width='100%' border='1' style='border-collapse: collapse'>
<thead>
<tr><th colspan='12'><h3>Electricity bill for the month of $month</h3>
(Unit rate: Rs. $unitrate1/unit, Fixed rate: $fixedrate1/KVA/month, P.Load rate: $plrate1/KVA/month, ED rate: $edrate1%, Reg. Surcharge: $rscrate1%)</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'>Paid<br>Amount</th>
<th rowspan='2'>Arrear<br>Amount</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='11' align='right'>Total</th><th>Rs.".number_format(round($tpayable),2)."</th></tr>
<tr><th colspan='12'>Above readings have been taken on the last dates of this and previous month.</th></tr>
</tfoot>
<tbody>$data</tbody>
</table>";

?>