<?php 	
require_once '../../Server/connection.php';

$sql = "SELECT staff.staff_id,staff.firstname,staff.middlename,staff.lastname,staff.staffId,staff.gender,staff.email,staff.phone_number,staff.birth_date,staff.emply_date,staff.MaritalStatus,positions.name,staff.staff_image FROM staff,positions WHERE positions.pos_id = staff.pos_id and staff.status='CURRENT'";

$result = $conn->query($sql);

$output = array('data' => array());

if($result->num_rows > 0) { 

 // $row = $result->fetch_array();
 $active = ""; 
 $x = 1;

 while($row = $result->fetch_array()){
 	$productId = $row['staff_id'];
	
	
	$button = '<!-- Single button -->
	<div class="btn-group">
	    <a type="button" class="btn btn-primary" data-toggle="modal"  data-target="#MyModal" data-id='.$productId.' id="getUser11"> <i class="glyphicon glyphicon-eye-open"></i></a>
	</div>';
	
	
	$button1 = '<!-- Single button -->
	<div class="btn-group">
	    <a type="button" class="btn btn-primary" data-toggle="modal" id="editProductModalBtn" data-target="#editVehicleModal" onclick="editProduct('.$productId.')"> <i class="glyphicon glyphicon-edit"></i></a>
	</div>';
	
	$button2 = '<!-- Single button -->
	<div class="btn-group">
	<a type="button" class="btn btn-primary" data-toggle="modal" data-target="#removeProductModal" id="removeProductModalBtn" onclick="removeProduct('.$productId.')"> <i class="glyphicon glyphicon-trash"></i></a>
	
	</div>';
	
	
	$imageUrl = substr($row['staff_image'], 3);
	$phone = substr($row['phone_number'], 3);
	$phone_number = '0'.$phone;
	
	$staffImage = "<img class='img-round' src='".$imageUrl."' style='height:40px; width:70px;'  />";

 	$output['data'][] = array( 

	    $x,
 		
 		$staffImage,
	
 		$row['firstname'].'&nbsp'.$row['middlename'].'&nbsp'.$row['lastname'], 
		
		$row['name'],
 		
 		$row['email'],
 	
 		$phone_number, 		 	
 		$button,
        $button1  		
 		); 
        
		$x++;
		
 } // /while 

}// if num_rows

$conn->close();

echo json_encode($output);