<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>บริษัท เอ เอฟ เอ็ม ฟลาวเวอร์ ซีดส์ (ไทยแลนด์) จำกัด</title>
<link type"text/css" rel="Stylesheet" href="bootstrap/css/bootstrap.css" />
<style type="text/css">
<!--
.style2 {
	font-size: xx-large
}
-->
</style>
<script type="text/javascript">  
function printDiv(divName) {  
     var printContents = document.getElementById(divName).innerHTML;  
     var originalContents = document.body.innerHTML;  
  
     document.body.innerHTML = printContents;  
     window.print();  
  
     document.body.innerHTML = originalContents;  
}  
</script> 
</head>
<body>
<?php // ทำวันที่ให้เป็นแบบไทย
function DateThai($strDate)
{
	$strYear		=		date("Y",strtotime($strDate))+543;
	$strMonth=		date("n",strtotime($strDate));
	$strDay=		date("j",strtotime($strDate));
	$strHour=		date("H",strtotime($strDate));
	$strMinute=		date("i",strtotime($strDate));
	$strSeconds=	date("s",strtotime($strDate));
	$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
	$strMonthThai=$strMonthCut[$strMonth];	
	$strYearCut = substr($strYear,2,2); //เอา2ตัวท้ายของปี .พ.ศ. 
	return "$strDay $strMonthThai $strYearCut";
}
?>
<form>
<div id="divprint">  
<table width="100%" height="250" border="0" align="center">
  <tr>
    <td align="center"><table width="100%" height="87" border="0">
      <tr>
        <td width="72%" align="center"><h5 class="style2">รายงานข้อมูลสินทรัพย์‎</h5></td>
        <td width="28%"><img src="img/logo.png" width="152" height="55" /></td>
      </tr>
    </table>
      <table width="90%" height="77" border="1" align="center" cellpadding="1" cellspacing="1">

      <tr>
        <td width="109" align="center" class="h5">วันที่ซื้อ</td>
        <td width="103" align="center" class="h5">หมวดหมู่</td>
        <td width="174" align="center" class="h5">ชื่อรุ่น</td>
        <td width="85" align="center" class="h5">จำนวน</td>
        <td width="74" align="center" class="h5">การซ่อม</td>
        <td width="157" align="center" class="h5">ผู้ใช้/แผนก</td>
      </tr>
<?php
$objConnect = mysql_connect("localhost","root","1234") or die("Error Connect to Database");
mysql_query("SET NAMES UTF8");
$objDB = mysql_select_db("afm_ass");
$strSQL = "SELECT * FROM tb_gadget,tb_department,tb_gadgettype
where
tb_gadget.Gadgettype_id = tb_gadgettype.Gadgettype_id
AND
tb_gadget.Department_user = tb_department.Department_id";
$objQuery = mysql_query($strSQL);
$i = 2;
while($objResult = mysql_fetch_array($objQuery))
{	
?>
      <tr>
        <td align="center"><?php
        echo DateThai($objResult["Date_purchase"]);?>
         </td>
        <td align="center"><?php echo $objResult["Gadgettype"];?></td>
        <td align="center" valign="middle" ><?php echo $objResult["Brand"]." ".$objResult["Model"];?></td>
        <td align="center" ><?php echo $objResult["Amount"];?></td>
        <td align="center" ><?php echo $objResult["Number_repair"];?></td>
        <td align="center" ><?php echo $objResult["Gadget_user"]." / ".$objResult["Departmentname"];?></td>
      </tr>
<?php
}
?>
    </table>
    
      </div>
     
      <p>&nbsp;</p>
      <table width="127" height="55">
        <tr>
          <td><input type="button" name="Button" value="Print" onclick="javascript:this.style.display='none';window.print();">  </td>
          <td></td>
        </tr>
      </table>      <p>&nbsp;</p></td>
  </tr>
</table>
</form>
<script src="js/jquery.js"></script>
<script src="bootstrap/js/bootstrap.js"></script>
</body>
</html>