<?php
include("../../../include/startup.php"); 
if(isset($_REQUEST['action']) && $_REQUEST['action']=='get_admin_by_job'){
	$job_id = $_REQUEST['job_id'];
	$admin_ids = "";
	$sql_for_admin = "SELECT * FROM job_admin_mapping WHERE job_id = '$job_id' ";
	$rs_for_admin = mysqli_query($conn,$sql_for_admin);
	if(mysqli_num_rows($rs_for_admin) > 0){
		while($row_for_admin = mysqli_fetch_assoc($rs_for_admin)){
			$admin_ids .= $row_for_admin["admin_id"].",";
		}
		$admin_ids = substr($admin_ids,0,-1);
	}
	if(isset($admin_ids) && $admin_ids !=""){
		print Admin::getAdminList("admin_id",$admin_id,"100%",true,"form-control","required",$admin_ids); 
	}else{
		echo "<span style='color:red;' id='span'>No consultant assign to this job. First assign consultant.</span>";
		//print Admin::getAdminList("admin_id",$admin_id,"100%",false,"form-control","required",999999); 
	}
	die;
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='calculate_time'){
	$from_time = $_REQUEST['from_time'];
	$to_time = $_REQUEST['to_time'];
	
	$from_time = strtotime("$from_time:00");
	$to_time = strtotime("$to_time:00");
	
	$seconds  = $to_time - $from_time;
	$hours = floor($seconds / 3600);
	$mins = floor(($seconds - ($hours*3600)) / 60);
	$returnArray["calculate_time"] = $hours.":".$mins;
	echo json_encode($returnArray);
	die;
}else if(isset($_REQUEST['action']) && $_REQUEST['action']=='for_ajax_calculate_time'){
	$from_time = $_REQUEST['from_time'];
	$to_time = $_REQUEST['to_time'];
	
	$from_time = strtotime("$from_time");
	$to_time = strtotime("$to_time");
	
	$seconds  = $to_time - $from_time;
	$hours = floor($seconds / 3600);
	$mins = floor(($seconds - ($hours*3600)) / 60);
	$returnArray["calculate_time"] = date("H:i:s",strtotime($hours.":".$mins.":00"));
	echo json_encode($returnArray);
	die;
}
?>