Assistance with array

6 posts by 2 authors in: Forums > CMS Builder
Last Post: January 20, 2014   (RSS)

By nmsinc - January 5, 2014

I have an array listed below I need help with:

if ($CURRENT_USER['isAdmin']) {
   $currentUserMemberCompany       = @$accountsRecords;
  }
  else {
   $accountsRecordsByMemberCompany = array_groupBy($accountsRecords, 'member_company_accounts', true);
   $currentUserMemberCompany       = @$accountsRecordsByMemberCompany[$CURRENT_USER['member_company_accounts']];
  }

I have an instance where if the [$CURRENT_USER['member_company_accounts'] has the field "offers_third_party_claims' set as true and $accountsRecordsByMemberCompany has the filed "adjusts_third_party_claims" set as true, then the  $currentUserMemberCompany  = @$accountsRecordsByMemberCompany[$CURRENT_USER['member_company_accounts']]; listed above needs to add these to the array

Any help would be appreciated - Thanks NMSINC

nmsinc

By ross - January 7, 2014

Hi nmsinc

Thanks for posting! Could you give me more detail on what you are setting up here?  With some more detail, I am sure options will start popping up :).

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By nmsinc - January 9, 2014

Hi Ross,

The list array below in bold, I need it to list all accounts where the user has the field adjusts_third_party_claims check-marked in addition to those that match the $CURRENT_USER['member_company_accounts']

$accountsRecordsByMemberCompany = array_groupBy($accountsRecords, 'member_company_accounts', true);
$currentUserMemberCompany       = @$accountsRecordsByMemberCompany[$CURRENT_USER['member_company_accounts']];

Thanks - NMSINC

nmsinc

By ross - January 20, 2014

Hi there.

Thanks for hanging on!

What I'm thinking for this array is that we actually look at it at the MySQL level. How about something like this when you are loading the account records:

 // load records from 'accounts'
 list($accountsRecords, $accountsMetaData) = getRecords(array(
   'tableName'   => 'accounts',
   'loadUploads' => true,
   'allowSearch' => false,
   'where'       => "adjusts_third_party_claims = '1' AND field_name = '". mysql_real_escape_string($CURRENT_USER['member_company_accounts'])  ."'",
 ));

The only thing is that I don't see in your description which field $CURRENT_USER['member_company_accounts'] needs to compare to in the accounts record so you'll see in my code where I used "field_name ".  You'll need to swap in the appropriate field.

Once you have that setup though, you'll have $accountsRecords setup right off the bat and there's no fussing about with combining arrays.  Let me know what you think.

Thanks!

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/

By ross - January 20, 2014

You're welcome! Let me know if it gets things going for you or not :)

-----------------------------------------------------------
Cheers,
Ross Fairbairn - Consulting
consulting@interactivetools.com

Hire me! Save time by getting our experts to help with your project.
Template changes, advanced features, full integration, whatever you
need. Whether you need one hour or fifty, get it done fast with
Priority Consulting: http://www.interactivetools.com/consulting/