|
|
|
จากฟอร์มผม มีการนำเข้า เมนู เราจะทำปุ่มปริ๊นและส่งออก excel ยังงัยไม่ให้ติดเมนูไปครับ |
|
|
|
|
|
|
|
จากฟอร์มผม มีการนำเข้า เมนู เราจะทำปุ่มปริ๊นและส่งออก excel ยังงัยไม่ให้ติดเมนูไปครับ
Code (PHP)
<?php include("menu_user.php"); ?>
<?php
/**
* Database Connection
*/
ini_set('display_errors', 1);
error_reporting(0);
$serverName = "loca..lhost";
$userName = "root";
$userPassword = "..";
$dbName = "as..set";
//mysql_query("SET NAMES utf8");
$conn = mysqli_connect($serverName,$userName,$userPassword,$dbName);
mysqli_set_charset($conn, "utf8");
// Clear
$error_message = '';
$condition = '';
$where = '';
$where2 = '';
$condition2 = '';
$where3 = '';
$condition3 = '';
if(isset($_POST['opt0'])){
$condition .= " a.Branch_ID > 0";
}
if(isset($_POST['opt1'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 1";
}
if(isset($_POST['opt2'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 2";
}
if(isset($_POST['opt3'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 3";
}
if(isset($_POST['opt4'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 4";
}
if(isset($_POST['opt5'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 5";
}
if(isset($_POST['opt6'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 6";
}
if(isset($_POST['opt7'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 7";
}
if(isset($_POST['opt8'])){
$condition .= ($condition != '' ? ' or ' : '') . " a.Branch_ID = 8";
}
if($condition != ''){
$where = "WHERE ($condition) ";
}
if(isset($_POST['opt46'])){
$condition2 .= " a.Department_ID > 0";
}
if(isset($_POST['opt9'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 1";
}
if(isset($_POST['opt10'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 2";
}
if(isset($_POST['opt11'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 3";
}
if(isset($_POST['opt12'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 4";
}
if(isset($_POST['opt13'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 5";
}
if(isset($_POST['opt14'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 6";
}
if(isset($_POST['opt15'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 7";
}
if(isset($_POST['opt16'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 8";
}
if(isset($_POST['opt17'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 9";
}
if(isset($_POST['opt18'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 10";
}
if(isset($_POST['opt19'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 11";
}
if(isset($_POST['opt20'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 12";
}
if(isset($_POST['opt21'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 13";
}
if(isset($_POST['opt22'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 14";
}
if(isset($_POST['opt23'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 15";
}
if(isset($_POST['opt24'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 16";
}
if(isset($_POST['opt25'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 17";
}
if(isset($_POST['opt26'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 18";
}
if(isset($_POST['opt27'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 19";
}
if(isset($_POST['opt28'])){
$condition2 .= ($condition2 != '' ? ' or ' : '') . " a.Department_ID = 20";
}
if($condition2 != ''){
$where2 = "and ($condition2)";
}
if(isset($_POST['opt47'])){
$condition3 .= " a.AssetType_ID > 0";
}
if(isset($_POST['opt29'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 1";
}
if(isset($_POST['opt30'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 2";
}
if(isset($_POST['opt31'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 3";
}
if(isset($_POST['opt32'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 4";
}
if(isset($_POST['opt33'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 5";
}
if(isset($_POST['opt34'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 6";
}
if(isset($_POST['opt35'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 7";
}
if(isset($_POST['opt36'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 8";
}
if(isset($_POST['opt37'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 9";
}
if(isset($_POST['opt38'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 10";
}
if(isset($_POST['opt39'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 11";
}
if(isset($_POST['opt40'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 12";
}
if(isset($_POST['opt41'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 13";
}
if(isset($_POST['opt42'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 14";
}
if(isset($_POST['opt43'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 15";
}
if(isset($_POST['opt44'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 16";
}
if(isset($_POST['opt45'])){
$condition3 .= ($condition3 != '' ? ' or ' : '') . " a.AssetType_ID = 17";
}
if($condition3 != ''){
$where3 = "and ($condition3)";
}
$sql = 'SELECT a.Asset_ID,a.Asset_name,a.IP_address,bc.Branch_name,d.Department_name,ast.AssetType_name,bd.Brand_name,m.Model_name,a.Serial_number,a.Date_add,a.Order_ID,a.Expiration_date,a.Asset_cost
,wl.Windows_name,a.Product_Key,wd.Windows_Dep_name,o.Office_Dep_name,a.Access,a.User_Resp,a.User_nickname,a.User_position,a.Date_Sent
FROM asset a
LEFT JOIN branch bc on a.branch_id = bc.Branch_ID
LEFT JOIN department d on a.Department_ID = d.Department_ID
LEFT JOIN assettype ast on a.AssetType_ID = ast.AssetType_ID
LEFT JOIN brand bd ON a.Brand_ID = bd.Brand_id
LEFT JOIN model m ON a.Model_id = m.Model_id
LEFT JOIN windows_licence wl ON a.Windows_ID = wl.Windows_ID
LEFT JOIN windows_dep wd ON a.Windows_Dep_ID = wd.Windows_Dep_ID
LEFT JOIN office_dep o ON a.Office_Dep_ID = o.Office_Dep_ID
'. $where .$where2 .$where3;
$query = mysqli_query($conn,$sql);
$rows = mysqli_num_rows($query);
// $PER_NAME = $rows['PER_NAME'];
if($rows <= 0 )
{
echo "<center>ไม่พบข้อมูล</center>";
}
else echo "<center><strong>รายการสินทรัพย์<br></strong></h5>";
{
?>
<table width="" border="0">
<tr>
<th width="30" bgcolor="#6495ED"> <div align="center">ลำดับ </div></th>
<th width="50" bgcolor="#6495ED"> <div align="center">สาขา </div></th>
<th width="50" bgcolor="#6495ED"> <div align="center">แผนก </div></th>
<th width="120" bgcolor="#6495ED"> <div align="center">ประเภท </div></th>
<th width="80" bgcolor="#6495ED"> <div align="center">ชื่อเครื่อง </div></th>
<th width="80" bgcolor="#6495ED"> <div align="center">IP Address </div></th>
<th width="90" bgcolor="#6495ED"> <div align="center">ยี่ห้อ </div></th>
<th width="90" bgcolor="#6495ED"> <div align="center">รุ่น </div></th>
<th width="120" bgcolor="#6495ED"> <div align="center">S/N </div></th>
<th width="90" bgcolor="#6495ED"> <div align="center">windows li. </div></th>
<th width="120" bgcolor="#6495ED"> <div align="center">windows def. </div></th>
<th width="100" bgcolor="#6495ED"> <div align="center">office </div></th>
<th width="70" bgcolor="#6495ED"> <div align="center">access </div></th>
<th width="80" bgcolor="#6495ED"> <div align="center">วันรับ </div></th>
<th width="90" bgcolor="#6495ED"> <div align="center">เลขใบสั่งซื้อ </div></th>
<th width="100" bgcolor="#6495ED"> <div align="center">วันหมดประกัน </div></th>
<th width="70" bgcolor="#6495ED"> <div align="center">ราคา </div></th>
<th width="140" bgcolor="#6495ED"> <div align="center">ชื่อผู้ใช้ </div></th>
<th width="90" bgcolor="#6495ED"> <div align="center">ชื่อเล่น </div></th>
<th width="100" bgcolor="#6495ED"> <div align="center">วันส่งมอบ </div></th>
</tr>
<?php
$i=0;
while($result=mysqli_fetch_array($query,MYSQLI_ASSOC))
{
$i++;
if($i%2==0)
{
$bg = "#FFFFFF";
}
else
{
$bg = "#E0FFFF";
}
?>
<tr bgcolor="<?=$bg;?>">
<td><div align="center"><?php echo "$i"?></td>
<td><div align="left"><?php echo $result["Branch_name"];?></div></td>
<td><div align="left"><?php echo $result["Department_name"];?></div></td>
<td><div align="left"><?php echo $result["AssetType_name"];?></div></td>
<td><div align="left"><?php echo $result["Asset_name"];?></div></td>
<td><div align="left"><?php echo $result["IP_address"];?></div></td>
<td><div align="left"><?php echo $result["Brand_name"];?></div></td>
<td><div align="left"><?php echo $result["Model_name"];?></div></td>
<td><div align="left"><?php echo $result["Serial_number"];?></div></td>
<td><div align="left"><?php echo $result["Windows_name"];?></div></td>
<td><div align="left"><?php echo $result["Windows_Dep_name"];?></div></td>
<td><div align="left"><?php echo $result["Office_Dep_name"];?></div></td>
<td><div align="left"><?php echo $result["Access"];?></div></td>
<td><div align="left"><?php echo $result["Date_add"];?></div></td>
<td><div align="left"><?php echo $result["Order_ID"];?></div></td>
<td><div align="left"><?php echo $result["Expiration_date"];?></div></td>
<td><div align="right"><?php echo $result["Asset_cost"];?></div></td>
<td><div align="left"><?php echo $result["User_Resp"];?></div></td>
<td><div align="left"><?php echo $result["User_nickname"];?></div></td>
<td><div align="left"><?php echo $result["Date_Sent"];?></div></td>
</tr>
<?php
}
?>
</table>
<?php
mysqli_close($conn);
}
?>
<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
<script src="../../js/jquery.min.js"></script>
<!-- Include all compiled plugins (below), or include individual files as needed -->
<script src="../../bootstrap/js/bootstrap.min.js"></script>
<p><a href="print_all_asset.php?condition=<?php echo $condition;?>&condition2=<?php echo $condition2;?>&condition3=<?php echo $condition3;?>" style="text-decoration:none" target="_BLANK"><input type="button" name="button" id="button" value="พิมพ์">
<a href="excel_all_asset.php?>" style="text-decoration:none" target="_BLANK"><input type="button" name="button" id="button" value="EXCEL">
</body>
</html>
Tag : PHP, MySQL
|
|
|
|
|
|
Date :
2018-09-28 15:53:15 |
By :
sweerawat |
View :
515 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code (PHP)
<style type="text/css" media="print">
input{
display:none;
}
</style>
Code (PHP)
<input type="submit" name="Submit" value=" PRINT " onClick="javascript:this.style.display='none';window.print()">
|
|
|
|
|
Date :
2018-10-01 09:03:36 |
By :
panthipa |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 05
|