This topic is locked

Dropdown dependant on user

6/4/2009 4:30:05 PM
PHPRunner General questions
J
joevoirol author

I need to be pointed in the right direction.
I have created a time sheet and expense reporting site for our field technicians.
I would like to have a drop down display different choices depending on either a field in the user table or group membership, not sure which one would work best.
I have a table with payment types (cash, MC, Visa, Account, etc.) that is used for the Lookup Wizard drop down and I do not want all of the users having all of the choices. I have a field in the payment types table to classify the payment type as a regular payment type or a corporate payment type (all payment types should be displayed for the corporate user).
I think this would be a Where clause in the Lookup Wizard screen but I do not know where to start, I have not written any custom PHP code before, but I am willing to learn.
Any help would be appreciated.

J
Jane 6/5/2009

Hi,
here are some tips:

  1. add new field (payment_type for example) to the payments table,
  2. use $_SESSION["customwhere"] as where clause on the "Edit as" settings dialog,
  3. and fill $_SESSION["customwhere"] in the Add page: Before process event on the Events tab.

    Here is a sample:
    if (@$_SESSION["GroupID"]!="corporate user")

    $_SESSION["customwhere"] = " payment_type!='corporate' ";

    else

    $_SESSION["customwhere"] = "";

J
joevoirol author 6/9/2009

Hello!
Thanks very much for the tip.
I have implemented this as you describe and it kind of works. If I put corporate in the payment_type field in the payment_method table and assign the user to the "corporate user" group the payment type does not display for any user, even the users in the group "corporate user"

If I log in as a regular user (not a member of the "corporate user" group) it does not display the payment_method records that have the payment_type field as "corporate", so that part works.
I have checked all of my syntax and it seems correct.
Just to be clear, I want all of the payment_method records to be displayed if the user is a member of the "corporate user" group and the payment_type field contains anything. If the payment_type contains "corporate" and the user is NOT a member of the "corporate user" group, do not display the record in the drop down.
Thanks for all of your help!

Hi,

here are some tips:

  1. add new field (payment_type for example) to the payments table,
  2. use $_SESSION["customwhere"] as where clause on the "Edit as" settings dialog,
  3. and fill $_SESSION["customwhere"] in the Add page: Before process event on the Events tab.

    Here is a sample:

J
Jane 6/10/2009

Hi,
I recommend you to publish your project on Demo Account and open a ticket at http://support.xlinesoft.com sending a URL to your pages.

I'll find what's wrong with your project inspecting it at Demo account site.

J
joevoirol author 6/10/2009

I published it to the Demo site.
I think that I failed to mention the fact that I am using dynamic permissions in the original post, so this might have some bearing on the problem also.
I added some debug code to display the GroupID in the Add form and it displays the UserID instead.
Kind of weird, huh?