if($_GET['afterDate'] != 0) { $queryReports.=" AND supplierInvoiceDate >= '".$_GET['afterDate']."'";}
if($_GET['beforeDate'] != 0) { $queryReports.=" AND supplierInvoiceDate <= '".$_GET['beforeDate']."'";}
$queryReports.=" ORDER BY supplierInvoiceDate desc limit 200";
$reports = mysql_query($queryReports, $conexion);
$tbody = "<table class='listing form' cellpadding='0' cellspacing='0' ><tr>
	<th>ID</th>
	<th>Supplier</th>
	<th>Invoice #</th>
	<th>Date</th>
	<th>Total</th>
	<th>Paid</th>
	<th>Balance</th>
	<th colspan='2'></th>
</tr>";
while($invoice = mysql_fetch_assoc($reports)) {
	$paidTotal = getSuppliedPaid($invoice['supplierInvoiceId'], $conexion);
	$reportTotal = decimalPad($invoice['supplierInvoiceAmount']);
	
	if($paidTotal == null || $paidTotal <= 0 ){ $paid = 'Unpaid';if($paidR)continue;}
	if($paidTotal != null && $paidTotal >= $reportTotal && $paidTotal != 0){ $paid = 'Paid'; if($unpaidR)continue;}
	if($paidTotal != null && $paidTotal > 0 && $paidTotal < $reportTotal){ $paid = 'Warning';if($paidR)continue;}
	if($paidTotal != null && $paidTotal > $reportTotal){ $paid = 'Overpaid'; if($unpaid)continue;}
	
	if($colorFlag){$tbody.= "<tr class='even".$paid." printable' id='report".$invoice['supplierInvoiceId']."' invoice='".$invoice['supplierInvoiceId']."'>";}
	else{$tbody.= "<tr class='odd".$paid." printable' id='report".$invoice['supplierInvoiceId']."' invoice='".$invoice['supplierInvoiceId']."'>";}
	$colorFlag=!$colorFlag;
	
	$tbody.= "<td>".$invoice['supplierInvoiceId']."</td>";
	$tbody.= "<td>".$invoice['supplierName']."</td>";
	$tbody.= "<td>".$invoice['supplierInvoiceNumber']."</td>";
	$tbody.= "<td>".to_MDY($invoice['supplierInvoiceDate'])."</td>";
	return data;
}
</script>
<div id='formDiv' class='table'>
	<img src="/mfi/img/bg-th-left.gif" width="8" height="7" alt="" class="left" />
	<img src="/mfi/img/bg-th-right.gif" width="7" height="7" alt="" class="right" />
	<table class="listing form" cellpadding="0" cellspacing="0">
		<tr>
			<th colspan='2'>New Pay Cheque for Broker Invoice [<?php 
echo $supplierInvoice['supplierInvoiceNumber'];
?>
]</th>
		</tr>
		<?php 
$reportTotal = decimalPad($supplierInvoice['supplierInvoiceAmount']);
$paidTotal = getSuppliedPaid($reportId, $conexion);
$balance = decimalPad($reportTotal - $paidTotal);
$nextCheck = getNextAutoIncrement($conexion, 'suppliercheque');
//Truck
$flag = true;
echo createFormRowTextField('Check Id', 'newSupplierChequeId', $flag ? 'class="bg"' : '', true, " disabled='disabled' size='10px' value='" . $nextCheck . "'");
$flag = !$flag;
echo createFormRowTextField('Check Number', 'newSupplierCheckNumber', $flag ? 'class="bg"' : '', false, "size='10px' ");
$flag = !$flag;
echo createFormRowTextField('Check Date', 'newSupplierCheckDate', $flag ? 'class="bg"' : '', false, "size='10px' value='" . to_MDY($supplierInvoice['supplierInvoiceDate']) . "'");
$flag = !$flag;
echo createFormRowTextField('Amount', 'newSupplierCheckAmount', $flag ? 'class="bg"' : '', false, "size='10px' value='" . $balance . "'");
$flag = !$flag;
?>
	</table>
	<table>