<?php

// Get Hours History For Project
$query = 'SELECT * FROM projectTime WHERE taskID=' . $editID .' AND timeDisp=1 ORDER BY timeDate DESC, timeID DESC'; 
$result = $con->query($query);
$hoursBillable = ''; 
$hoursTotal = ''; 

while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
	$timeCurrent_name = "timeCurrent_". $row['timeID'];
	$timeString_name = "time_". $row['timeID'];
	$datCurrent_name = "datCurrent_". $row['timeID'];
	$datString_name = "dat_". $row['timeID'];
	$descCurrent_name = "descCurrent_". $row['timeID'];
	$descString_name = "desc_". $row['timeID'];
	$invCurrent_name = "invCurrent_". $row['timeID'];
	$invString_name = "inv_". $row['timeID'];
	$ppInvCurrent_name = "ppInvCurrent_". $row['timeID'];
	$ppInvString_name = "ppInv_". $row['timeID'];
	$ppPaidCurrent_name = "ppPaidCurrent_". $row['timeID'];
	$ppPaidString_name = "ppPaid_". $row['timeID'];
	$billCurrent_name = "billCurrent_". $row['timeID'];
	$billString_name = "bill_". $row['timeID'];
	$delString_name = "delete_". $row['timeID'];
		
	if ($row['timeInvoiced'] == 1)
		$invCheck = ' checked';
	else 
		$invCheck = '';
		
	if ($row['ppInv'] == 1)
		$ppInvCheck = ' checked';
	else 
		$ppInvCheck = '';
		
	if ($row['ppPaid'] == 1)
		$ppPaidCheck = ' checked';
	else 
		$ppPaidCheck = '';
			
	if ($row['billable'] == 1)
		$billCheck = ' checked';
	else 
		$billCheck = '';
		
	$timeInfo .= '<tr'. $rowShad .'>
						<td>
							<input type="hidden" name="'. $datCurrent_name .'" value="'. $row['timeDate'] .'" />
							<input type="text" name="'. $datString_name .'" value="'. $row['timeDate'] .'" class="dateField datepicker" />
						</td>
						<td>
							<input type="hidden" name="'. $timeCurrent_name .'" value="'. $row['timeAmount'] .'" />
							<!--<input type="text" name="'. $timeString_name .'" value="'. $row['timeAmount'] .'" style="width: 50px" />-->
							<input type="number" pattern="^\d+(\.|\,)\d{2}$" step="0.25" name="'. $timeString_name .'" value="'. $row['timeAmount'] .'" class="timeField" />
						</td>
						<td>
							<input type="hidden" name="'. $descCurrent_name .'" value="'. $row['timeDesc'] .'" />
							<textarea name="'. $descString_name .'" value="'. $row['timeDesc'] .'" class="descAdmin">'. $row['timeDesc'] .'</textarea>
						</td>
						<td style="text-align: center">
							<label>Billable</label><br>
							<input type="hidden" name="'. $billCurrent_name .'" value="'. $row['billable'] .'" />
							<input type="checkbox" name="'. $billString_name .'" value="1"'. $billCheck .' />
						</td>
						<td style="text-align: center">
							<label>Invoiced</label><br>
							<input type="hidden" name="'. $invCurrent_name .'" value="'. $row['timeInvoiced'] .'" />
							<input type="checkbox" name="'. $invString_name .'" value="1"'. $invCheck .' />
						</td>
						<td style="text-align: center">
							<label>Parent Inv</label><br>
							<input type="hidden" name="'. $ppInvCurrent_name .'" value="'. $row['ppInv'] .'" />
							<input type="checkbox" name="'. $ppInvString_name .'" value="1"'. $ppInvCheck .' />
						</td>
						<td style="text-align: center">
							<label>Parent Paid</label><br>
							<input type="hidden" name="'. $ppPaidCurrent_name .'" value="'. $row['ppPaid'] .'" />
							<input type="checkbox" name="'. $ppPaidString_name .'" value="1"'. $ppPaidCheck .' />
						</td>
						<td style="text-align: center"><label>Delete</label><br><input type="checkbox" name="'. $delString_name .'" value="0" /></td>
					</tr>';	
		
	$hoursTotal = $hoursTotal + $row['timeAmount'];
	if ($row['billable'] == 1)
		$hoursBillable = $hoursBillable + $row['timeAmount'];
}

?>