<?php
include_once '../includes/processes.php';
$Process = new Login_Process;

$pageLink = basename($_SERVER['REQUEST_URI']);
$Process->check_status($pageLink);
if($_SESSION['dept_id']!=7) {
	
	header("location:../");
}
$output='';
 if(isset($_POST['export_excel'])){
	 $sql="SELECT * FROM repair_list ";
	 $result = mysqli_query($connect,$sql);
	 if(mysqli_num_rows($result) > 0){
		 $output.='
		 <table class="table" bordered="3">
		 <tr>
		<th>S/n</th>
            <th>Name of item</th>
            <th>Serial number</th>
            <th>Originating station</th>
            <th>date in</th>
            <th>problem</th>
            <th>Date sent</th>
            <th>Work done</th>
            <th>Date returned</th>
            <th>Remark</th>
		 </tr>
		 ';
		 while($row = mysqli_fetch_array($result))
		 {
			 $output .='
			 <tr>
			 <td>'.$row["id"].'</td>
			 <td>'.$row["name_of_item"].'</td>
			 <td>'.$row["serial_number"].'</td>
			 <td>'.$row["originating_station"].'</td>
			 <td>'.$row["date_in"].'</td>
			 <td>'.$row["problem"].'</td>
			 <td>'.$row["date_sent"].'</td>
			 <td>'.$row["work_done"].'</td>
			 <td>'.$row["date_returned"].'</td>
			 <td>'.$row["remark"].'</td>
			 </tr>
			 ';
		 }
		 $output .='</table>';
		 header("Content-Type: application/xls");
		 header("Content-Disposition: attachment; filename=Repair track sheet.xls");
		 echo $output;
	 }
 }
?>