Main
Index
Search
Posts
Who's
Online
Log
In

Home: Products: CMS Builder:
Problem with List Options in CMS

 

 


nmsinc
User

Dec 8, 2011, 4:47 PM

Post #1 of 15 (1100 views)
Shortcut
Problem with List Options in CMS Can't Post

Problem with List Options in CMS



Users are setup in the user ‘accounts’ section with a service company that is populated from a Company record list as follows:



Company A

Company B

Company C



And with user types as follows:



Admin

Agent

Preparer



In populating a new record section named ‘files’:

  1. I again choose a company from a drop down list same as above.
  2. I then need to complete three sections in this record labeled “Admin”, “Agent” and “Preparer”
  3. These sections need to populate with a drop down list of users that match the company chosen above with the company assigned in the user ‘accounts’ and the ‘user_type’ associated with the section.




Here is what I have for code - I know I have errors, but where - anyone?



<?php

$where = "";

$where = "WHERE assigned_company = '"($accounts[user_company])."' and user_type = 'agent'";

?>

SELECT num, fullname

FROM `<?php echo $TABLE_PREFIX ?>accounts`

<?php echo $where; ?>



Thanks - nmsinc


Jason
Staff / Moderator


Dec 9, 2011, 10:58 AM

Post #2 of 15 (1083 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Hi,

Try using this query for agent (example)


Code
SELECT num, fullname 
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE assigned_company = '<?php echo $ESCAPED_FILTER_VALUE;?>' AND user_type = 'agent'


Then under "Advanced Filter" select the name of the company field for this section.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


nmsinc
User

Dec 9, 2011, 11:17 AM

Post #3 of 15 (1082 views)
Shortcut
Re: [Jason] Problem with List Options in CMS [In reply to] Can't Post

Hi Jason,

Used your suggestion and now I get the error below:

Warning: Cannot modify header information - headers already sent by (output started at /var/www/vhosts/claimscaddy.com/httpdocs/cmsAdmin/lib/menus/header.php:60) in /var/www/vhosts/claimscaddy.com/httpdocs/cmsAdmin/lib/database_functions.php on line 611 There was an error creating the list field 'assigned_adjuster'. MySQL Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Parse error: syntax error, unexpected T_ELSE in /var/www/vhosts/claimscaddy.com/' at line 1

Thanks - nmsinc


Jason
Staff / Moderator


Dec 9, 2011, 11:38 AM

Post #4 of 15 (1080 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Hi,

Could you post the exact query you used for the assigned_adjuster field.

Also note that the variable assigned_company needs to be the name of the field in the accounts table, not in the section your in.

Thanks
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


nmsinc
User

Dec 9, 2011, 1:30 PM

Post #5 of 15 (1077 views)
Shortcut
Re: [Jason] Problem with List Options in CMS [In reply to] Can't Post

Back again - thought I would give you waht I have just in case...

Ans: I used the query you provided in post #2



Here is what needs to happen.



(a) The user must first choose a company to assign to this record from a drop-down list (field=’assigned_company’).

(DONE see below)

<?php if ($CURRENT_USER['isAdmin']):?>

SELECT num, name_of_company

FROM `<?php echo $TABLE_PREFIX ?>company_information`

<?php elseif (!$CURRENT_USER['isAdmin']):?>

<?php

$where = "";

$where = "WHERE num = '".$CURRENT_USER['claim_company']."'";

?>

SELECT num, name_of_company

FROM `<?php echo $TABLE_PREFIX ?>company_information`

<?php echo $where; ?>

<?php else: ?>

SELECT num, name_of_company

FROM `<?php echo $TABLE_PREFIX ?>company_information`

<?php endif ?>







(b) The next field down (field=’assigned_dispatcher’)





This field needs to post a list of all users who have been assigned the designation of “Dispatcher” in the user accounts records (field=’user_type’) that also match (field=’ company_type’) in the user accounts record with the selection of the

“assigned_company” in (a) above!



Users are assigned a claim company and user-type or insurance company and user-type within the user accounts record. The claim file needs to populate based on the user setup!



The idea is to keep the user from seeing other users who have been designated to other companies!



Thanks

- nmsinc




Jason
Staff / Moderator


Dec 11, 2011, 10:07 PM

Post #6 of 15 (1058 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Hi,

I think problem is that the query in the second post was using the field "assigned_company", instead of "company_type".

Try this:


Code
SELECT num, fullname  
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE company_type = '<?php echo $ESCAPED_FILTER_VALUE;?>' AND user_type = 'dispatcher'


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


nmsinc
User

Dec 16, 2011, 7:10 AM

Post #7 of 15 (1035 views)
Shortcut
Re: [Jason] Problem with List Options in CMS [In reply to] Can't Post

Hi Jason,

Thanks for the update - you can see below where I took your suggestion and tweaked it a little. Now I have another issue I'm dealing with. The top section listed below is code placed in the field "List Options". This allows (if admin) to choose any company from the "member_companies" table, all other users are subject only to the member company that has been assigned to them in the user "accounts" table. This section works as needed! The field labled "assigned_adjuster" follows within the same record. If the user is the "admin" or the user has the rights of an Independent, then I need this field to list only user "accounts" that match the company choice in the previous field - see the if admin code I already have that does not work in the section labeld "Assign Adjuster" blelow:

--------------- Field = "member_company" -------------- [all of this works OK]

<?php if ($CURRENT_USER['isAdmin']):?>

SELECT num, member_company_name
FROM `<?php echo $TABLE_PREFIX ?>member_companies`

<?php elseif ($CURRENT_USER['company_type'] == "Insurance"):?>
SELECT num, member_company_name
FROM `<?php echo $TABLE_PREFIX ?>member_companies`
WHERE <?php echo $CURRENT_USER['member_company_accounts'] ?> = `<?php echo $ESCAPED_FILTER_VALUE ?>num`

<?php else: ?>
SELECT num, member_company_name
FROM `<?php echo $TABLE_PREFIX ?>member_companies`

<?php endif ?>


---------------- Field = "assigned_adjuster" ---------------- [the first php if statement for admin is where I need help]

<?php if ($CURRENT_USER['isAdmin']):?>
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE "member_company" = '<?php echo $ESCAPED_FILTER_VALUE ?>num' AND user_type = 'Adjuster'

<?php elseif (!$CURRENT_USER['isAdmin']):?>
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE <?php echo $CURRENT_USER['member_company_accounts'] ?> = `<?php echo $ESCAPED_FILTER_VALUE ?>member_company_accounts` AND user_type = 'Adjuster'

<?php else: ?>
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE user_type = 'Adjuster'

<?php endif ?>
----------------------------------------------------------------------

Thanks nmsinc


(This post was edited by nmsinc on Dec 16, 2011, 7:18 AM)


Jason
Staff / Moderator


Dec 16, 2011, 8:19 AM

Post #8 of 15 (1028 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Hi,

I think the problem is that your if statement will never reach the "else" block. Since 'isAdmin' must be either true or false, only the first or second block will ever be executed.

What you need is to change the elseif portion of the code. For example, if you had a field called isIndependent and you wanted execute the second block if the current user isn't an admin, but was an independent, you could try this:


Code
<?php if ($CURRENT_USER['isAdmin']):?> 
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE "member_company" = '<?php echo $ESCAPED_FILTER_VALUE ?>num' AND user_type = 'Adjuster'

<?php elseif ($CURRENT_USER['isIndpendent']):?>
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE <?php echo $CURRENT_USER['member_company_accounts'] ?> = `<?php echo $ESCAPED_FILTER_VALUE ?>member_company_accounts` AND user_type = 'Adjuster'

<?php else: ?>
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE user_type = 'Adjuster'

<?php endif ?>


The "else" block would then be executed if the current user wasn't an admin or an independent.

Hope this helps get you started.
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


nmsinc
User

Dec 16, 2011, 8:56 AM

Post #9 of 15 (1025 views)
Shortcut
Re: [Jason] Problem with List Options in CMS [In reply to] Can't Post

Hi Jason,

That center elseif statement works fine, I'm having problems with the php if statement above it:

<?php if ($CURRENT_USER['isAdmin']):?>
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE "member_company" = '<?php echo $ESCAPED_FILTER_VALUE ?>num' AND user_type = 'Adjuster'


I need it to populate a list of users from the "accounts" table who match the company that the admin chooses in the preveious field labled "member_company"

Thanks - nmsinc


Jason
Staff / Moderator


Dec 16, 2011, 9:06 AM

Post #10 of 15 (1024 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Hi,

Try removing "num" from the end of <?php echo $ESCAPED_FILTER_VALUE ?>


Code
<?php if ($CURRENT_USER['isAdmin']):?> 
SELECT num, fullname
FROM `<?php echo $TABLE_PREFIX ?>accounts`
WHERE "member_company" = '<?php echo $ESCAPED_FILTER_VALUE ?>' AND user_type = 'Adjuster'


Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


nmsinc
User

Dec 16, 2011, 10:19 AM

Post #11 of 15 (1022 views)
Shortcut
Re: [Jason] Problem with List Options in CMS [In reply to] Can't Post

Followed your suggestion and it still returns zero listings in the drop-down. I did re-checked to make sure that the users were set correctly for what should have populated in the drop-down!


(This post was edited by nmsinc on Dec 16, 2011, 2:02 PM)


Jason
Staff / Moderator


Dec 19, 2011, 7:44 AM

Post #12 of 15 (922 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Hi,

So for some reason, no records are being returned by our query. Are you sure all the values match up? For example, does user_type store the value "Adjuster" or "adjuster".

Let me know.
Thanks
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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


nmsinc
User

Dec 19, 2011, 10:58 AM

Post #13 of 15 (917 views)
Shortcut
Re: [Jason] Problem with List Options in CMS [In reply to] Can't Post

Hi Jason,

I think the problem is that the record posting page loads with the set PHP fundamentals, the user then makes a field choice that needs to then affect the choice in the next field down. The poulation of the next field down cannot be performed because the set PHP code needed to effect the next field has already been parsed - correct?

If so, what needs to done to make this work?

Thanks - nmsinc


nmsinc
User

Dec 20, 2011, 10:36 AM

Post #14 of 15 (905 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Any ideas anyone?

I cannot be the only one who at some point and time needed this addressed!


Jason
Staff / Moderator


Dec 20, 2011, 11:10 AM

Post #15 of 15 (902 views)
Shortcut
Re: [nmsinc] Problem with List Options in CMS [In reply to] Can't Post

Hi,

When you're using one field to affect the values populated in another field, those values are retrieved dynamically through a jquery call. The problem here is that for some reason, the query in your second field is not returning any values.

If you could fill out a 2nd Level Support Request, I'll take a quick look and let you know if I see the problem.

Hope this helps
---------------------------------------------------
Jason Sauchuk - Programmer 
interactivetools.com

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