Hi Dave -
I am running into a few problems. I am getting the following error
Notice: Undefined variable: invoicesRecords in /home/sageme/public_html/includes/sections/invoice2.php on line 6
Warning: array_column() expects parameter 1 to be array, null given in /home/sageme/public_html/includes/sections/invoice2.php on line 6
Warning: array_unique() expects parameter 1 to be array, null given in /home/sageme/public_html/includes/sections/invoice2.php on line 7
Warning: array_filter() expects parameter 1 to be array, null given in /home/sageme/public_html/includes/sections/invoice2.php on line 7
Warning: Invalid argument supplied for foreach() in /home/sageme/public_html/webadmin/lib/mysql_functions.php on line 183
Notice: Undefined offset: 38 in /home/sageme/public_html/includes/sections/invoice2.php on line 43
My Page code looks like this:
<?php require_once "/home/sageme/public_html/webadmin/lib/viewer_functions.php";
$domain = "https://" . $_SERVER['HTTP_HOST'];
// get associated records
$clientNums = array_column($invoicesRecords, 'clientNum');
$clientNums = array_filter(array_unique($clientNums)); // remove blanks and duplicates
$clientNumsAsCSV = mysql_escapeCSV($clientNums); // comma separated values, eg: 1,2,3
$clientRecords = mysql_select('clients', " num IN ($clientNumsAsCSV) ");
$clientRecordsByNum = array_groupBy($clientRecords, 'num');
list($invoice_templateRecords, $invoice_templateMetaData) = getRecords(array(
'tableName' => 'invoice_template',
'where' => '', // load first record
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$invoice_templateRecord = @$invoice_templateRecords[0]; // get first record
list($invoicesRecords, $invoicesMetaData) = getRecords(array(
'tableName' => 'invoices',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$invoicesRecord = @$invoicesRecords[0]; // get first record
list($clientsRecords, $clientsMetaData) = getRecords(array(
'tableName' => 'clients',
'where' => whereRecordNumberInUrl(0),
'loadUploads' => true,
'allowSearch' => false,
'limit' => '1',
));
$clientsRecord = @$clientsRecords[0]; // get first record
?>
<address>
<?php echo $invoicesRecord['clientNum:label']; ?>
<?php $invoiceClient = $clientRecordsByNum[ $invoicesRecord['clientNum'] ]; ?>
<?php echo htmlencode($invoiceClient['address']); ?>
<?php echo htmlencode($invoiceClient['phone']); ?>
<?php echo htmlencode($invoiceClient['email']); ?>
</address>
I think I might be missing something in the implementation of the code you suggested.
Kenny