<?php if(isset($_SESSION['msg']) ){?>
<div class="alert alert-info">                
<h4>Info!</h4>
<?php echo $_SESSION['msg']; unset($_SESSION['msg']); ?>
</div> <?php }  ?> 
<?php
date_default_timezone_set('Asia/Calcutta');
$out_date			= date("Y-m-d");
$sql				= mysql_query(" SELECT distinct `state` FROM `tbl_emp_records` WHERE `status`='0' and `payment_status` !='Complete' order by `state` ")or die(mysql_error());
while($row			= mysql_fetch_array($sql))
{
	$message		= "";
	$message		= '<html><head><title>Rudraansh Holding LLP</title><head><style>body{background:#fff;color:#000;font-size:14px; font-family:Verdana, Geneva, sans-serif; margin:0; padding:0;}div.mailerwrapper{margin:auto;width:600px; border-bottom:#000 solid 2px;}.top_line{background: #000 none repeat scroll 0 0;height: 4px;}.dear{ padding:20px 0; font-size:14px;}.dear h2{margin:0; color:#000; font-size:17px;  padding-bottom:5px; font-weight:normal;}.products_items{padding:0; font-size:14px;}.orderid{margin:0; color:#fa903a; font-size:17px;  padding-bottom:5px; font-weight:normal;}.products_items{ border-bottom:#000 solid 1px; border-right:#000 solid 1px;}.products_items tr td{ border:#000 solid 1px; border-bottom:none; border-right:none; padding:5px;}.customer_detals{ background:#efefef; padding:5px 20px 0px 20px; margin:10px 0;}.customer_detals h2{ margin:0; color:#fa903a; font-size:16px; font-weight:normal; padding-bottom:8px;}.customer_detals ul{ list-style:none; padding:0; margin:0;}.customer_detals ul li{padding:0 0 0 35px;}.mail{ background:url(http://revateam.com/suresh/rd_cons/admin/images/mail.png) 0 0 no-repeat; display:block; line-height:30px; }.phone{ background:url(http://revateam.com/suresh/rd_cons/admin/images/phone.png) 0 0 no-repeat; display:block; line-height:30px; }.copy_rt{ text-align:center; font-size:13px; padding:5px 0 15px 0;}</style></head><body>	
	<div class="mailerwrapper">
<div class="top_line">&nbsp;</div>
<div class="banner"><img src="http://revateam.com/suresh/rd_cons/admin/images/banner_top.jpg" /></div>


<div class="dear">
<h2>Hello, Dear</h2>
Do note a received an Account Number Rudraansh Holding LLP
</div>
<div class="orderid">//  Rudraansh //</div>
<div class="products_items">

<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td width="8%">S.No.</td>
    <td width="25%">Staff Name</td>
    <td width="14%">Staff Code</td>
    <td width="11%">State</td>
    <td width="25%">A/c No</td>
    <td width="17%">IFSE Code</td>
  </tr>';
$sql_1				= mysql_query(" SELECT * FROM `tbl_emp_records` WHERE `payment_status` !='Complete' and `state`='".$row['state']."' order by `emp_name` ")or die(mysql_error());
$i					= 0;
while($row_1		= mysql_fetch_array($sql_1))
{
	$i++;
	$message       .= ' <tr>
    <td width="8%">'.$i.'</td>
    <td width="25%">'.$row_1['emp_name'].'</td>
    <td width="14%">'.$row_1['emp_code'].'</td>
    <td width="11%">'.$row_1['state'].'</td>
    <td width="25%">'.$row_1['account_no'].'</td>
    <td width="17%">'.$row_1['branch_ifsc'].'</td>
  </tr>';
}
$message .='</table></div><div class="customer_detals"><h2>Contact details </h2><ul><li class="mail">backend@renesolutions.com</li><li class="phone">+91 9252999978</li></ul></div><div class="copy_rt">All Rights Reserved. Rudraansh Holding LLP © Copyright 2017 </div></div></body></html>';

$sql_2				= mysql_query(" SELECT * FROM `tbl_admin` WHERE `post` like '%".$row['state']."%' order by `id` ")or die(mysql_error());
$row_2				= mysql_fetch_array($sql_2);
////Mail Content
	$to 	  = $row_2['email'];;//"revateamdoc@gmail.com";//
	$subject  = 'Update Account Detils At Rudraansh Web Portal';
	$from     = 'backend@renesolutions.com';
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$headers .= 'From: '.$from."\r\n".'Reply-To: '.$from."\r\n" .'X-Mailer: PHP/' . phpversion();	 
	// Sending email
	if(mail($to, $subject, $message, $headers))
	{
		$_SESSION['msg']= 'Your mail has been sent successfully.';
	}
	else
	{
		$_SESSION['msg']= 'Unable to send email. Please try again.';
	}
}
echo $_SESSION['msg'];
?>