| Current Path : /var/www/html/mmishra/mybp1/ |
| Current File : /var/www/html/mmishra/mybp1/elrmailing.inc |
<h1><img src='images/bulb7.jpg' height='12'> Receipt Mailing</h1>
<?php
$tbl = "el_billing";
$month = previous_month();//date("M-Y");
$id = $_REQUEST["id"];
$mailing = $_REQUEST["mailing"];
echo "<b>For individual mail, select FlatNo</b> <select name='id'>";
//$rs = mysql_query("select * from $tbl where month='$month' and subsidy>0 order by flatno");
$rs = mysql_query("select * from $tbl where subsidy>0 order by flatno");
while ($o = mysql_fetch_object($rs)) {
echo "<option value='$o->id'";
if ($o->id == $id) echo " selected";
echo ">$o->flatno (Rs. $o->amount/$o->payable)</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 ($id) {
echo " [ <a href='?pg=$pg&id=$id&mailing=1'>Send Mail</a> ]";
$rs = mysql_query("select * from $tbl where id=$id");
} else {
echo " [ <a href='?pg=$pg&mailing=1'>Send Mails</a> ]";
$rs = mysql_query("select * from $tbl where month='$month' and subsidy>0 order by id");
}
while ($o = mysql_fetch_object($rs)) {
$i++;
$id = $o->id;
$flatno = $o->flatno;
$curreading = $o->curreading;
$prevreading = $o->prevreading;
$units = $o->units;
$amount = $o->amount;
if (!$amount) $amount = 0;
$subsidy = $o->subsidy;
if (!$subsidy) $subsidy = 0;
$payable = $o->payable;
if (!$payable) $payable = 0;
//get flat details
$sr = mysql_query("select * from el_flats where flatno='$flatno'");
while ($q = mysql_fetch_object($sr)) {
$flattype = $q->flattype;
$meterno = $q->meterno;
}
//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;
}
//mysql_query("update el_config set datemailing=now()");
$mailbody = "<div align='right'>Ref: IIITA/$id/$month<br>Date: ".date("d/m/Y")."</div><b>
To-<dir>
$fullname<br>
$flatno, $flattype<br>
IIITA Campus, Deoghat<br>
Jhalwa, Allahabad - 211012
</dir></b></p>
<table width='100%' border='1' style='border-collapse: collapse'>
<thead>
<tr><th colspan='7'>Electricity charges 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)</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 last date of $month 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'>$units</td><td align='center'>Rs. $amount</td><td align='center'>Rs. $subsidy</td><td align='center'>Rs. $payable</td></tr>
</tbody>
</table><br>
<p>$receipt</p>";
if ($receiptto) $email = $receiptto;
if ($email && $mailing == 1) {
if (sendmail($email, "Electricity charges for the month of $month", $mailbody) == TRUE) {
echo "<i>Status: OK</i>";
mysql_query("update el_config set datemailing=now()");
} else
echo "<i>Status: XX</i>";
}
$str .= "<hr>($i) $mailbody";
}
echo $str;
?>