<th class='first' >Invoice</th> <th>Project</th> <th>Date</th> <th>Total</th> <th>Paid</th> <th>Balance</th> <th>This check</th> <th>after Balance</th> <th class='last' >Remove</th> </tr> <? $queryInvoices = "select * from receiptcheques JOIN invoice using (invoiceId) JOIN project using (projectId) where customerSuperCheckId = ".$paymentInfo['customerSuperCheckId']; $invoices = mysql_query($queryInvoices, $conexion); while($invoice = mysql_fetch_assoc($invoices)){ $total = getInvoiceTotal($invoice['invoiceId'], $conexion); $paid = getInvoicePaid($invoice['invoiceId'], $conexion); echo "<tr id='receipt".$invoice['receiptchequesId']."' receiptId='".$invoice['receiptchequesId']."'> <td>".$invoice['invoiceId']."</td> <td>".$invoice['projectName']."</td> <td>".to_MDY($invoice['invoiceDate'])."</td> <td>".decimalPad($total)."</td> <td>".decimalPad($paid - $invoice['receiptchequesAmount'])."</td> <td>".decimalPad($total - ($paid - $invoice['receiptchequesAmount']))."</td> <td class='sumable'>".decimalPad($invoice['receiptchequesAmount'])."</td> <td>".decimalPad($total - $paid)."</td> <td><img src='/trucking/img/118.png' width='20px' height='20px' class='removableInvoice' /></td> </tr>"; } ?> </table> </div>
<?php include_once '../function_header.php'; include '../common_server_functions.php'; //print_r($_REQUEST); $responseCode = 0; $invoice = $_REQUEST['reportId']; if ($invoice == '') { die(wrapFormError(ERROR_CODE_INVALID_VALUE, 'Internal Error', '')); } $invoiceTotal = getInvoiceTotal($invoice, $conexion); $invoicePaid = getInvoicePaid($invoice, $conexion); $invoiceBalance = $invoiceTotal - $invoicePaid; if ($invoiceBalance <= 0) { die(wrapFormError(ERROR_CODE_INVALID_VALUE, 'This invoice is already paid. Please refresh your page.', '')); } $check = $_REQUEST['check']; if ($check == '') { die(wrapFormError(ERROR_CODE_INVALID_VALUE, 'Internal Error', '')); } $number = $_REQUEST['number']; if ($number == '') { die(wrapFormError(ERROR_CODE_INVALID_VALUE, 'Internal Error', '')); } $date = $_REQUEST['date']; if ($date == '0') { die(wrapFormError(ERROR_CODE_INVALID_VALUE, 'The date si not in a correct format', '')); } $amount = $_REQUEST['amount']; if ($amount > $invoiceBalance) { die(wrapFormError(ERROR_CODE_INVALID_VALUE, "The amount you want to pay ({$amount}) is greater than the amount left to pay ({$invoiceBalance}). Please refresh your page. ", ''));
if($_GET['listed']!='all'){ $queryTickets .= "limit ".$_GET['listed']; } //echo $queryTickets; //echo $queryTickets; $colorFlag=true; $terms = mysql_query($queryTickets,$conexion); $numTerms = mysql_num_rows($terms); $tbody = "<tbody>"; while($term = mysql_fetch_assoc($terms)){ //get invoice balance $invoiceTotal = getInvoiceTotal($term['invoiceId'], $conexion); $invoicePaid = getInvoicePaid($term['invoiceId'], $conexion); $balance = decimalPad($invoiceTotal - $invoicePaid); $cheques = mysql_fetch_assoc(mysql_query("select count(*) as paidCheques from receiptcheques WHERE invoiceId = ".$term['invoiceId'], $conexion)); if($cheques['paidCheques'] > 0 && $balance <= 0)continue; //if already paid continue if($balance <= 0)/*continue;*/$paid = true; else $paid = false; // //TODO: try with mysql query //if($_GET['vendorId']!=0 && $_GET['vendorId']!=$term['vendorId'])continue; //if($_GET['supplierId']!=0 && $_GET['supplierId']!=$term['supplierId'])continue; /*if($term['supplierInvoiceId'] == null){ }else{ $supplierInvoiceQuery = "select * from supplierinvoice where supplierInvoiceId = ".$term['supplierInvoiceId'];
<tr> <th colspan='5'>Payment for Customer Invoice [<?php echo $reportId; ?> ]</th> </tr> <tr> <th>Customer Check</th> <th>Credit</th> <th>Amount to Pay</th> <th>Date</th> <th></th> </tr> <?php $reportTotal = getInvoiceTotal($reportId, $conexion); $paidTotal = getInvoicePaid($reportId, $conexion); $balance = decimalPad($reportTotal - $paidTotal); $invoiceInfo = getCustomerInvoiceInfo($conexion, $reportId); //Truck $flag = true; $credits = mysql_query("SELECT * FROM customer_credit JOIN customer_super_check USING (customerSuperCheckId) WHERE\tcustomerId = '" . $invoiceInfo['customerId'] . "'", $conexion); while ($credit = mysql_fetch_assoc($credits)) { $creditValue = decimalPad($credit['customerCreditAmount']); echo printRow(($flag ? "class='bg'" : "") . " rowId='F" . $reportId . "W" . $credit['customerSuperCheckId'] . "' ", array($credit['customerSuperCheckNumber'], $creditValue, createInputText("paymentF" . $reportId . "W" . $credit['customerSuperCheckId'], '', "size='10px'", decimalPad($creditValue > $balance ? $balance : $creditValue)), createInputText("dateF" . $reportId . "W" . $credit['customerSuperCheckId'], "", "size='10px'", to_MDY($credit['customerSuperCheckDate'])), createInputHidden("checkF" . $reportId . "W" . $credit['customerSuperCheckId'], "", "size='10px'", $credit['customerSuperCheckId']) . " " . createInputHidden("numberF" . $reportId . "W" . $credit['customerSuperCheckId'], "", "size='10px'", $credit['customerSuperCheckNumber']) . " " . printImgLink(IMG_PAY, "customerPayable", "Pay with check " . $credit['customerSuperCheckNumber'], ' width="22" height="22"'))); $flag = !$flag; //createInputText($id, $name = '', $attributes = '', $startingValue ='') } echo printRow(($flag ? "class='bg'" : "") . " rowId='F" . $reportId . "W0' ", array("Cash", "N/A", createInputText("paymentF" . $reportId . "W0", '', "size='10px'", decimalPad($balance)), createInputText("dateF" . $reportId . "W0", "", "size='10px'", date('m/d/Y')), createInputHidden("checkF" . $reportId . "W0", '', "size='10px'", "0") . " " . createInputHidden("numberF" . $reportId . "W0", '', "size='10px'", "Cash") . " " . printImgLink(IMG_PAY, "customerPayable", "Pay with cash", ' width="22" height="22"'))); ?> </table> <table>