Your IP : 216.73.216.40


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

<h1><img src='images/bulb7.jpg' height='12'> Licensee Receipt</h1>
<?php
$tbl = "el_billing";
$month = previous_month();//date("M-Y");
$id = $_REQUEST["id"];
$ext = $_REQUEST["ext"];
$mailing = $_REQUEST["mailing"];
$month='Jun-2015';

echo "<b>Receipt of</b> <select name='id'>
<option value=''></option>";
$rs = mysql_query("select * from $tbl order by flatno");
while ($o = mysql_fetch_object($rs)) {
	echo "<option value='$o->id'";
	if ($o->id == $id) echo " selected";
	echo ">$o->flatno ($o->licensee)</option>";
}
echo "</select> <input type='submit' name='submit' value='OK'>
<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;
	$subsidymode = $o->subsidymode;
	$receipt = $o->receipt;
	$receiptto = $o->receiptto;
	$summary = $o->summary;
	$summaryto = $o->summaryto;
	$bill = $o->bill;
	$billto = $o->billto;
}

if ($id) {
	$rs = mysql_query("select * from $tbl where id=$id");
} else {
	$rs = mysql_query("select * from $tbl where month='$month' order by id");
}
while ($o = mysql_fetch_object($rs)) {
        $i++;
        $id = $o->id;
        $flatno = $o->flatno;
        $licensee = $o->licensee;
        $category = $o->category;
        $meterno = $o->meterno;
        $contactedload = $o->contactedload;
        $unitrate = $o->unitrate;
        $fixedrate = $o->fixedrate;
        $plrate = $o->plrate;
        $edrate = $o->edrate;
        $rscrate = $o->rscrate;
        $subsidy = $o->subsidy;
        $external = $o->external;

        $prevreading = $o->prevreading;
        $curreading = $o->curreading;

        //get licensee details
        $sr = mysql_query("select * from el_licensee where flatno='$flatno'");
        while ($q = mysql_fetch_object($sr)) {
                $fullname = $q->fullname;
                $designation = $q->designation;
                $email = $q->email;
                $category = $q->category;
        }
        
	$consumedunit = $curreading - $prevreading;
        $consumedcharge = $consumedunit * $unitrate;

        if ($external == 'Yes') {
                $fixedcharge = $contactedload * $fixedrate;
                $subtotal = $consumedcharge + $fixedcharge;

                $plcharge = $contactedload * $plrate;
                $edcharge = $subtotal * $edrate/100;
                $rscharge = $subtotal * $rscrate/100;

                $totalamount = $subtotal + $plcharge + $edcharge + $rscharge;

                $payable = $totalamount;
        } else {
                if ($consumedunit > $subsidy) {
                        $excessunit =  $consumedunit - $subsidy;
                        $payable = $excessunit * $unitrate;
                } else {
                        $excessunit =  0;
                        $payable = $totalamount;
                }
        }
        $tunit += $consumedunit;
        $tcharge += $consumedcharge;
        $tamount += $totalamount;
        $tsubsidy += $subsidy;
        $tpayable += $payable;

        $data = "<tr>
        <td align='center'>$meterno</td>
        <td align='center'>$contactedload</td>
        <td align='center'>$prevreading</td>
        <td align='center'>$curreading</td>
        <td align='center'>".number_format($consumedunit,2)."</td>
        <td  align='center'>Rs.".number_format($consumedcharge,2)."</td>";

        if ($external == 'Yes') {
                $data .= "<td align='center'>".number_format($fixedcharge,2)."</td>
                <td align='center'>".number_format(round($subtotal),2)."</td>
                <td align='center'>".number_format($plcharge,2)."</td>
                <td align='center'>".number_format($edcharge,2)."</td>
                <td align='center'>".number_format($rscharge,2)."</td>
                <td align='center'>Rs.".number_format($totalamount,2)."</td>";
        } else {
                $data .= "<td align='center'>".number_format($subsidy,2)."</td>
                <td align='center'>".number_format($excessunit,2)."</td>";
        }
        $data .= "<td align='center'>Rs.".number_format($payable,2)."</td></tr>";

	$mailbody = "<div align='right'>Ref.No.: IIIT-A/iLight-$id/$month<br>Date: ".date("d/m/Y")."</div><b>
        	To-<dir> 
                	$fullname<br>
                	$flatno, IIITA Campus<br>
                	Devghat, Jhalwa, Allahabad-211012
        	</dir></b>
		<table width='100%' border='1' style='border-collapse: collapse'>
		<thead>";

	if ($ext == 1) {
		$mailbody .= "
		<tr><th colspan='13'>Electricity bill for the month of $month<br> 
		(Unit rate: Rs. $unitrate, Fixed rate: $fixedrate/KVA/month, P.Load rate: $plrate/KVA/month, ED rate: $edrate%, Reg. Surcharge: $rscrate%)</th></tr>
		<tr>
		<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'>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='4'>Total</th>
		<th>".number_format($tunit,2)."</th>
		<th>Rs.".number_format(round($tcharge),2)."</th>
		<td colspan='5'></td><th nowrap>Rs.".number_format($tamount,2)."</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><br>
		<p>$bill</p>";
	} else {
		$mailbody .= "
		<tr><th colspan='7'>Electricity charge for the month of $month</th></tr>
		<tr><th rowspan='2'>MeterNo</th><th colspan='3'>Readings & Consumption</th>
		<th colspan='3'>Consumption Charges (@ Rs. $unitrate/Unit)</th></tr>
		<tr><th>Previous</th><th>Current</th><th>Units</th><th>Amount</th><th>Admissibility</th><th>Payable</th></tr>
		</thead>
		<tfoot>
		<tr><th colspan='7'>Above readings have been taken on the last dates of this and previous month.</th></tr>
		</tfoot>
		<tbody>
		<tr><td align='center'>$meterno</td><td align='center'>$prevreading</td><td align='center'>$curreading</td>
		<td align='center'>".number_format($consumedunit,2)."</td><td align='center' nowrap>Rs.".number_format($consumedcharge,2)."</td>
		<td align='center' nowrap>".($subsidymode == 'Rupees' ? 'Rs.' : '').number_format($subsidy,2).
		($subsidymode == 'Units' ? ' Units': '')."</td>
		<td align='center' nowrap>Rs.".number_format($payable,2)."</td></tr>
		</tbody>
		</table><br>
		<p>$receipt</p>";
	}
	
	$str .= "<hr>($i) $mailbody";
}
echo $str;

?>