<?php
require ("../connection.php");
$curdate = date('Y-m-d h:i:s');
date_default_timezone_set('Asia/Calcutta');
$date=date("H:i"); 
$current_date=date("d-m-Y"); 
date_default_timezone_set('Etc/UTC');

?>
<html>
<title>Asset Management System</title>
<body>
<script src="js/jquery.js"></script>
<script src="js/html2canvas.js"></script>
<script src="js/jspdf.js"></script>
<script type="text/javascript">		
$(document).ready(function(){
var specialElementHandlers = {
'#editor': function(element, renderer) { return true; }
};
//$('#cmd').click(function() {
window.onload = function(){
var numItems = $('.target').length;//2
var valData= '"'+ get_id() +'"'; 

var valNew=valData.split(',');
//alert(valData);

for(i=0;i<valNew.length;i++)
{
var myStr = valNew[i].replace(/"/g, '');
var id="#"+myStr;
//var doc = new jsPDF('l', 'mm', [297, 210]);	

var doc = new jsPDF('l', 'mm', [497, 410], 'p','pt', 'letter', true);

doc.fromHTML($(id).html(), 15, 15, {
'width': 170,'elementHandlers': specialElementHandlers
});

doc.save(myStr+'.pdf');
continue;
}
}; 

function get_id(){
var idArray =[];
$('.target').each(function () {
idArray.push(this.id);
});	
return idArray;
}
});
</script>
<div id="content" id="visitor_report" class="target">
<center>
<h1>Asset Management System</h1>
<h1>
<h2>For Reference Kindly check the below details <?php echo $current_date;?></h2>
<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>
                <tbody>
				<?php
				$row= mysqli_query($con, "SELECT * FROM item_master where expiry_date in(select date(DATE_ADD(NOW(), INTERVAL 30 DAY)))");
				$s=1;
				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'];
						?>
                        <tr>
					        <td style="font-size:20px;"><?php echo $s++;?></td>
							<td style="font-size:20px;"><?php echo $po_dates;?></td>
							<td style="font-size:20px;"><?php echo $expiry_dates;?></td>
							<td style="font-size:20px;"><?php echo $fa_serial_no;?></td>
							<td style="font-size:20px;"><?php echo $category;?></td>
							<td style="font-size:20px;"><?php echo $category_description;?></td>
							<td style="font-size:20px;"><?php echo $location;?></td>
						</tr>	
				<?php
				}
				?>
     </tbody>
    </table>	
</h1>
	 </center>
<div>		
	 </body>
 <div style="page-break-before:always;"></div>
</html>