<?php

include ($PATH . 'globals/globals.php');

$adminAct = $_REQUEST['adminAct']; 
$editID = $_REQUEST['editID']; 
$page = $_REQUEST['page']; 

$query = 'SELECT t.*, p.clientID AS client, p.projectName, ts.taskStatDesc AS taskStat, pp.ppName AS taskPriority FROM tasks t LEFT JOIN projects p ON (t.projectID = p.projectID) LEFT JOIN taskStatus AS ts ON (t.taskStatus = ts.taskStatID) LEFT JOIN projectPriority pp on (t.priority = pp.ppID)  WHERE taskID=' . $editID; 
$result = $con->query($query);
		
while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
	$op = 'edit';
	$taskID = $row['taskID'];
	$projectID = $row['projectID'];
	$projectName = $row['projectName'];
	$taskName = $row['taskName'];
	$taskDesc = $row['taskDesc'];
	$projectClient = $row['clientName'];
	$startDate = $row['startDate'];
	$dueDate = $row['dueDate'];
	$taskEstimate = $row['taskEstimate'];
	$taskProgress = $row['taskProgress'];
	$client = $row['client'];
	$subBtn = 'Save Changes';
	$modalTitle = 'Apply Time to Task: '. $taskName;
	$taskStatus = $row['taskStatus']; 
	$taskPriority = $row['priority']; 
	$taskStatusSelect = getTaskStatus($taskStatus,$con);
	$taskPrioritySelect = getProjPriority($taskPriority,$con);
}
include('list/task-time.php');
	
if ($hoursTotal == $hoursBillable)
	$hoursTotal = '<span class="timeExact">'. $hoursTotal .'<span>';
elseif ($hoursTotal > $hoursBillable)
	$hoursTotal = '<span class="timeOver">'. $hoursTotal .'<span>';
else
	$hoursTotal = '<span class="timeUnder">'. $hoursTotal .'<span>';

if (!empty($client))
	$taskClient = getClientName($client,$con);
else
	$taskClient = ''; 
	
include('form/task-time.php');

?>