<?php
include("../connection.php");

require 'PHPMailer/PHPMailerAutoload.php';

$mail = new PHPMailer;
$mail->IsSMTP(); 
$mail->Mailer = "smtp";
$mail->Host = "ssl://smtp.gmail.com";                                    // Set mailer to use SMTP
//$mail->Host = 'smtp.google.com';  // Specify main and backup SMTP servers
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'rizwanashaik676@gmail.com';                 // SMTP username
$mail->Password = 'quadsel12';                           // SMTP password
$mail->SMTPSecure = 'ssl';                            // Enable encryption, 'ssl' also accepted
$mail->Port = 465;

$mail->From = 'rizwanashaik676@gmail.com';
$mail->FromName = 'Mailer';
$mail->addAddress('rizwanashaik676@gmail.com');     // Add a recipient

 

$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
/* $mail->addAttachment('/var/tmp/file.tar.gz');         // Add attachments
$mail->addAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name */
$mail->isHTML(true);                                  // Set email format to HTML

$subject="Asset Management Details";			
				$html_table = 'Dear ADMIN ,<br><br>
							   This the Report of Expiry Asset Details.
					<table class="table table-hover table-bordered"  border=1 style="margin: 15px 0 98px 0px!important;">   
					<thead style="color:#0033FF;">					
						<tr style="text-align:center;">			
							<th style="font-size:15px;">#</th>
							<th style="font-size:15px;">PO DATE</th>
							<th style="font-size:15px;" >EXPIRY DATE</th>
							<th style="font-size:15px;">FA SERIAL NUMBER</th> 
							<th style="font-size:15px;">CATEGORY</th> 
							<th style="font-size:15px;" >CATEGORY DESCRIPTION</th>
							<th style="font-size:15px;" >LOCATION</th>
						</tr>	
					</thead>';
						$row= mysqli_query($con, "SELECT * FROM item_master where expiry_date in(select date(DATE_ADD(NOW(), INTERVAL 30 DAY)))");
						$s=1;
						 "bala";
							while($type=mysqli_fetch_array($row))
							{
								
							$po_dates=$type['po_date']; $po_date=date("d-m-Y",strtotime($po_dates));
							$expiry_dates=$type['expiry_date']; $expiry_date=date("d-m-Y",strtotime($expiry_dates));
							$fa_serial_no=$type['fa_serial_no'];
							$category=$type['category'];
							$category_description=$type['category_description'];
							$location=$type['location'];
								
						$html_table .='<tr>
									<td>' . $s++.'</td>
									<td>' . $po_date.'</td>
									<td>' . $expiry_date.'</td>
									<td>' . $fa_serial_no.'</td>
									<td>' . $category.'</td>
									<td>' . $category_description.'</td>
									<td>' . $location.'</td>
							  </tr>';
						}
				$html_table .=' </table>';
				$html_table .='<button class="btn btn-primary"><a href="assetserver.quadsel.in/asset_temp/mail/pdf_report.php">Generate PDF</a></button>';
				$html_table .=' <h4>Thanks & Regards,</h4><br>
				<p>Asset Management System</p>';

				$mail->Subject =$subject;
				$mail->Body =$html_table;

if(!$mail->send()) {
    echo 'Message could not be sent.';
    echo 'Mailer Error: ' . $mail->ErrorInfo;
} 
else {
    echo 'Message has been sent';
}

?>