Hi,
I hope some one can help, this is not my strong suit.
I have two tables, *Sales Leger and Payments
I want to display a list of the sales ledger records with a sum of the amount outstanding (this will be the *sales ledger.invoice total minus the sum of payments.payment amount). There will only be one sales ledger record but there can be many payment records that link to it.
I can already sisplay a list of the sales ledger records using this:
$sl_query = “SELECT * FROM *Sales Ledger WHERE Customer ID = :customersID”;
$sl_query = $db->bindVars($sl_query, ‘:customersID’, $_SESSION[‘customer_id’], ‘integer’);
$sl = $db->Execute($sl_query);
$alArray = array();
while (!$sl->EOF) {
$slArray[] = array(‘Transaction Date’=>$sl->fields[‘Transaction Date’],
‘Sales Ledger ID’=>$sl->fields[‘Sales Ledger ID’],
‘Doc Type’=>$sl->fields[‘Doc Type’],
‘Document Number’=>$sl->fields[‘Document Number’],
‘Work Order ID’=>$sl->fields[‘Work Order ID’],
‘order number’=>$sl->fields[‘order number’],
‘invoice net’=>$sl->fields[‘invoice net’],
‘invoice vat’=>$sl->fields[‘invoice vat’],
‘invoice total’=>$sl->fields[‘invoice total’],
‘due date’=>$sl->fields[‘due date’],
);
$sl->MoveNext();
}
| Date | Due Date | T | Number | Work Order | Order Number | Net | VAT | Total | View |
|---|---|---|---|---|---|---|---|---|---|
| <?php echo zen_date_short($sl['Transaction Date']); ?> | <?php echo zen_date_short($sl['due date']); ?> | <?php echo $sl['Doc Type']; ?> | <?php echo $sl['Document Number']; ?> | <?php echo $sl['Work Order ID']; ?> | <?php echo $sl['order number']; ?> | £<?php echo $sl['invoice net']; ?> | £<?php echo $sl['invoice vat']; ?> | £<?php echo $sl['invoice total']; ?> | <?php echo ' ' . zen_image_button(BUTTON_IMAGE_VIEW_SMALL, BUTTON_VIEW_SMALL_ALT) . ''; ?> |
I want to have the amount due in the same table, I just have no idear how to proceed.
Can any one help?