Need assistance combining content from two sections

3 posts by 2 authors in: Forums > CMS Builder
Last Post: July 25, 2008   (RSS)

By kevbarker - July 24, 2008

I am using CMSB to track sales orders. I need help combining the information in two sections into the detail page of one of those sections. I will try to explain what I need. I can post the code if necessary.

I have some key information for each sales order in a section called 'Orders'. The records from this section are displayed in table format showing most of the info except for two of the fields, with the Sales Order Number being a link to the detail page for each order where ALL of the information for that record is shown.

To track parts shortages on these orders, I originally had a textbox where we would enter any parts shortages for the orders. We would enter the part number, (carriage return), part number, etc. This worked well for a while but we needed more information about each missing part so I created another section called 'Shortages' to better track them for the orders. Once the information in the 'Orders' section is entered there is a 'Sales Order Number' in the database for each record. Since the Sales Order Number is in the database, I used a dropdown box with 'Get options from database' for the 'Shortages' section, and when you add a record you select the Sales Order Number from the list populated by the 'Get options from database' feature. You then fill out the details for the shortage and add the record. The list of shortages is displayed in a table with most of the information with (like the orders section) the exception of a couple of fields.

What I now need to do is to add any shortages for a given order to the details page for that order. I may have no shortages, one shortage, or multiple shortages. I would like to display any shortage(s) from the Shortages section for a specific order number in the Orders section to show up in the details page for that order.

Is there a quick and easy way to check for shortages in the Shortages section based on the sales order number and if present add them to the details page for a record in the Orders section with that sames sales order number? I am sure there is a simple way to do this but I seem to have a "brain freeze" right now and can't see the light. Any help would be appreciated.

Thanks,

Kevin

Re: [kevbarker] Need assistance combining content from two sections

By Dave - July 24, 2008

Hi Kevin,

Ok, I think I know what you want. Give this a try... Note that I don't know your fieldnames or variable names so just replace (or adapt) what I use in my examples with the names in your page.

On your order detail page add another list viewer to the bottom and tell it to only show records matching the record number. Like this:

<?php
require_once "admin/lib/viewer_functions.php";

list($shortagesRecords, $shortagesMetaData) = getRecords(array(
'tableName' => 'shortages',
'loadUploads' => '0',
'allowSearch' => '0',
'where' => "orderNum = '{$order['num']}'"
));

?>

...

<?php if (@$shortageRecords): ?>
<?php foreach ($shortageRecords as $shortage): ?>
Title: <?php echo $shortage['title'] ?><br/>
...
<?php endforeach ?>
<?php endif ?>


Let me know if that makes sense. :)
Dave Edis - Senior Developer
interactivetools.com