Help With List And Sorting

6 posts by 2 authors in: Forums > CMS Builder
Last Post: June 25, 2013   (RSS)

By Jason - June 24, 2013

Hi,

I'm a little unclear as what you are trying to display.  Currently, you are selecting all member_companies with a member_type of "Independent" and then putting a value into the drop down if they have a value in the accepts_clearing_house_claims field.  Can you please let me know how you want this to work differently than it currently is?  How should the remove_this_clearing_house field apply?

Let me know and we'll see if we can work out a solution.

Thanks

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - June 24, 2013

Hi Jason,

The CMS viewer code would be: <?php echo join(', ', $record['remove_this_clearing_house:values']); ?> which would list only items in the list that have been checked . I need this same type of filter applied to the "if" statement and I do not have any idea as to how this can be done!

Thanks

NMSINC

nmsinc

By Jason - June 25, 2013

Hi,

Thanks for the additional details.  Just want to make sure I'm on the same page when it comes to what you are looking for.

As I understand it, you want to populate a drop down with options from the accepts_clearing_house_claims field, but only those options that have been selected in at least 1 record from member_companies where member_type is Independent.

Does that sound right?  Let me know and we'll get it sorted.

Thanks

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By nmsinc - June 25, 2013

That's correct!

Thanks

NMSINC

nmsinc

By Jason - June 25, 2013

Hi,

Okay, no problem.  First we need to compile an array with all selected values from that field like this:

<?php
  $selectedClearingHouseClaimsOptions = array();
  $memberCompanies = mysql_select("member_companies", "member_type = 'Independent'");
  
  foreach ($memberCompanies as $company) {
    $tempArray = array_filter(explode("\t", trim($company['accepts_clearing_house_claims'], "\t")));
    $selectedClearingHouseClaimsOptions = array_merge($selectedClearingHouseClaimsOptions, $tempArray);
  }
  
?>

After that, we look through all possible options using the getListOptions() function.  We then have an if statement that looks for the current value in our selected values array.

<select name="accepts_clearing_house_claims" onchange = "populateAdjusterList(this, 'independent');"  // populate list code in j >

<option value="">All</option>

<?php foreach (getListOptions("member_companies", 'accepts_clearing_house_claims') as $value => $label): ?>
  <?php if (in_array($value, $selectedClearingHouseClaimsOptions)): ?>
    <option value = "<?php echo $value;?>" <?php selectedIf($value, @$_REQUEST['accepts_clearing_house_claims']);?>><?php echo $label;?></option>
  <?php endif; ?>

<?php endforeach ?>

</select>

That should give you the results you are looking for.  Please note that this code snippet hasn't been tested, so there may be a few bugs/typos.

Hope this helps,

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/