<?php
// Get Payment History For Project
$query = 'SELECT * FROM payments WHERE projectID=' . $editID .' ORDER BY paymentDate DESC'; 
$result = $con->query($query);
$payments = ''; 
$odd = true;
while ($row=$result->fetch_array(MYSQLI_ASSOC)) {
	$invString_name = "inv_". $row['paymentID'];
	$amtString_name = "amt_". $row['paymentID'];	
	$pmtString_name = "pmt_". $row['paymentID'];
	$datString_name = "dat_". $row['paymentID'];
	$noteString_name = "note_". $row['paymentID'];
	if ($row['paymentStatus'] == 1)
		$pmtStatus = 'PAID&nbsp;&nbsp;<input type="checkbox" name="'. $pmtString_name .'" value="0" onclick="fillDate(\'\',\''. $datString_name .'\')" />&nbsp;<label>Check if UNPAID</label>';
	else
		$pmtStatus = 'INVOICED&nbsp;&nbsp;<input type="checkbox" name="'. $pmtString_name .'" value="1" onclick="fillDate(\''. $today .'\',\''. $datString_name .'\')" />&nbsp;<label>Check if PAID</label>';
		
	if ($row['invoiceDate'] == "0000-00-00")
		$invDate = '';
	else
		$invDate = $row['invoiceDate'];
	
	if ($row['paymentDate'] == "0000-00-00")
		$pmtDate = '';
	else
		$pmtDate = $row['paymentDate'];
		
	$paymentInfo .= '<tr>
						<td>
							<input type="text" name="'. $invString_name .'" id="'. $invString_name .'" value="'. $invDate .'" class="datepicker dateField" style="border: none;" />
						</td>
						<td>&#36;&nbsp;<input type="number" name="'.$amtString_name.'" id="'. $amtString_name .'" value="'. number_format($row['paymentAmount'],2,'.','') .'" style="border: none;"></td>
						<td>
							<input type="text" name="'. $datString_name .'" id="'. $datString_name .'" value="'. $pmtDate .'"  class="datepicker dateField" style="border: none;" />
						</td>
						<td>'. $pmtStatus .'</td>
					</tr>';
	$paymentInfo .= '<tr'. $rowShad .'><th style="text-align: right">Notes:</th><td colspan="4"><input type="text" name="'. $noteString_name .'" id="'. $noteString_name .'" value="'. $row['paymentNote']  .'" style="width: 98%; border: none;"></td></tr>';	
	$payments = $payments + $row['paymentAmount'];
}
?>