Help With List And Sorting

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

By nmsinc - June 22, 2013

I am using the display option within CMS: checkboxes (multi value) and I’m having some problems coding a list/sort in the bold area below.

I need to sort by two fields:

  1. ‘accepts_clearing_house_claims`
  2. `remove_this_clearing_house`

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

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

<?php echo join(', ', $member_companiesRecord['remove_this_clearing_house:values']); ?>

<?php foreach (mysql_select('member_companies', "member_type = 'Independent' ORDER BY member_company_name") as $independent): ?>

 <?php if ($independent['accepts_clearing_house_claims']): ?>

<option value = "<?php echo $independent['num'];?>"><?php echo $independent['member_company_name'];?> - <?php echo $independent['city'];?> <?php echo $independent['state'];?></option>

<?php endif; ?>

<?php endforeach ?>

</select>

I want to list only those that have not been checked – any ideas welcomed!

Regards

NMSINC

nmsinc

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/