<?php
if(isset($_GET['act'])){
	if($_GET['act']== 'excel'){
		header("Content-Type: application/xls");
		header("Content-Disposition: attachment; filename=Project.xls");
		header("Pragma: no-cache");
		header("Expires: 0");
	}
}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>Customer DB Export To Excel</title>
		<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
	</head>
	<body>
		<div class="container">
			<div class="row">
				<div class="col-md-5">
					<br /><br /><br />
					<h4>DB EXPORT TO EXCEL</h4>
                    <div style="width: 500px;">
					<p>
						<a href="?act=excel" class="btn btn-primary"> Project Export->Excel </a>
						<?php session_start();
							if($_SESSION['Status']=='ADMIN'){ ?>
								<a href="../home.php" class="btn btn-primary"> Home </a>
							<?php }else{ ?>
								<a href="../homeOther.php" class="btn btn-primary"> Home </a>
							<?php } ?>		
						<a href="../logout.php" class="btn btn-primary"> Logout </a>
					</p>
                    </div>
					
					<table border="1" class="table table-hover">
						<thead>
							<tr>
								<th style="text-align: center;">ประเภท</th>
								<th style="text-align: center;">ชื่อ</th>
                                <th style="text-align: center;">ที่อยู่</th>
                                <th style="text-align: center;">โทร.1</th>
                                <th style="text-align: center;">โทร.2</th>
                                <th style="text-align: center;">ผู้ประสานงาน</th>
                                <th style="text-align: center;">ที่ปรึกษา</th>
								<th style="text-align: center;">หมายเหตุ</th>									
							</tr>
						</thead>
						<?php
							include "../functions/dblink.php" ;
							$sql = "SELECT * FROM proj001" ;
							$result = mysqli_query($con,$sql) ;
							while($row = mysqli_fetch_assoc($result)){ ?>
								<tr>
                                    <td style="text-align: left;"><?php echo $row['PJKIND']; ?></td>
									<td style="text-align: left;"><?php echo $row['PJNAME']; ?></td>
                                    <td style="text-align: left;"><?php echo $row['PJADRS'].' '.$row['PJDSTRT'].' '.$row['PJPRVN'].' '.$row['PJZIP']; ?></td>
                                    <td style="text-align: left;"><?php echo $row['PJTELC1'].' '.$row['PJTEL1'];?></td>
                                    <td style="text-align: left;"><?php echo $row['PJTELC2'].' '.$row['PJTEL2'];?></td>
                                    <td style="text-align: left;"><?php echo $row['PJCONTRCT']; ?></td>
                                    <td style="text-align: left;"><?php echo $row['PJADVISER']; ?></td>
									<td style="text-align: left;"><?php echo $row['PJNOTE']; ?></td>
								</tr>
						<?php } ?>
					</table>
				</div>
			</div>
		</div>
	</body>
</html>