<?php 	
session_start();
require_once '../../Server/connection.php';
$user_id = $_SESSION['user_id'];
$sql = "SELECT assignstatus.id,assignstatus.client_id,assignstatus.assigned_by,assignstatus.remarks FROM clients,assignstatus where clients.client_id=assignstatus.client_id and assignstatus.assigned_to='$user_id' and assignstatus.status=0";

$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()){
 	$categoriesId = $row['id'];
	$clientId = $row['client_id'];
	$assignId = $row['id'];
	$assignedBy = $row['assigned_by'];
	$remarks = $row['remarks'];
	
	$query153 = "select * from clients where client_id='$clientId'";
    $result153 = $conn->query($query153);
    $row153 = $result153->fetch_array();
    $clientName = $row153['client_fname']." ".$row153['client_lname'];
	
	
	$query155 = "select * from staff,users,designation where staff.staff_id=users.staff_id and users.user_id='$assignedBy' and staff.des_id=designation.des_id";
    $result155 = $conn->query($query155);
    $row155 = $result155->fetch_array();
    $Name1 = $row155['firstname']." ".$row155['lastname']." ".$row155['des_short_name'];
	
	$button1 = '<!-- Single button -->
	<div class="btn-group">
	    <a type="button" class="btn btn-primary" href="viewDocs.php?i='.$clientId.'&assign_id='.$assignId.'" id="editOrderModalBtn"><center><i class="glyphicon glyphicon-eye-open"></i></center></a>
	</div>';
	
	$button2 = '<!-- Single button -->
	<div class="btn-group">
	    <a type="button" class="btn btn-primary" data-toggle="modal" id="editCategoriesModalBtn" data-target="#editCategoriesModal" onclick="editCategories('.$categoriesId.')"> Open</a>
	</div>';
	

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

	    $x,
 		$clientName, 
 		$Name1,
        $button1,
		$remarks,
        $button2  		
 		); 
        
		$x++;
		
 } // /while 

}// if num_rows

$conn->close();

echo json_encode($output);