Assign user to company

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
Eric1982
User
Posts: 57

Assign user to company

Post by Eric1982 »

I would like to assign a user to a company, which I can choose from an list in the admin panel.

User 1 --> assign to Company X
User 2 --> assign to Company Y
User 3 --> assign to Company Z

etcetera.

How can I achieve this ?


scs
User
Posts: 694

Post by scs »

Add additional field (to save company info) into necessary tables. and do the filtering on records after login (if not admin).


Eric1982
User
Posts: 57

Post by Eric1982 »

Thank you. I already created a new table (a separate one), with several details like: company name, address, company registration number etc. How can I achieve this ? : and do the filtering on records after login

Do I have to allocate it to each user ?


scs
User
Posts: 694

Post by scs »

Company table should have a primary field (normally is AI field)

User table should have a field related to the Primary key in Company. (for single company only, not for multiple companies)

The do something in Recordset Selecting or (maybe) Recordset Searching...


Eric1982
User
Posts: 57

Post by Eric1982 »

I have created a primary field in Company (with AI). I created the same field in User.

How can I related these to each other ?


scs
User
Posts: 694

Post by scs »

Use lookup table option in Edit Tag for the field.


Eric1982
User
Posts: 57

Post by Eric1982 »

I have tried this with the manual 'Field Setup' section, but I don't know exactly how this works.

Can you help me a little bit ?


scs
User
Posts: 694

Post by scs »

Try download the Demo Project from phpmaker website to get idea how to do it.

Hope this help


Eric1982
User
Posts: 57

Post by Eric1982 »

I already did. I took the manual next to it, but it could not figure it out.

When I have the table 'Company' with the field: 'name'
And I would like to lookup the field 'name' in another field, called 'company_name' in the table 'Details'

What should I have to fill out in the 'Lookup Table', in 'Table name', 'Link field' and 'Display field' ?


mobhar
User
Posts: 11745

Post by mobhar »

Just follow this topic "Using Lookup Table for Edit Tag (Text/Radio/Checkbox/Select)" under "Field Setup" of PHPMaker Help menu.


Eric1982
User
Posts: 57

Post by Eric1982 »

Hello,

When I try to add a name to a field I get an error: ''Value does not exist''

Do I have to modify something in the database ?

Thank you.

Kind regards,
Eric


mobhar
User
Posts: 11745

Post by mobhar »

Eric1982 wrote:
When I try to add a name to a field I get an error: ''Value does not exist''

Not clear enough. Please explain it in more detail, how did you do that?

For example:

  1. Click this ... from ... pane
  2. Choose this ... under something
  3. Do that ... using blabla
    and so forth.

danielc
User
Posts: 1601

Post by danielc »

Eric1982 wrote:
''Value does not exist''

Did you enabled "Force selection"? If the value does not already exist, it will show this error message. Either you have to use "Add Option" to add the value or uncheck this option. See Field Setup (Force selection explanation) in help file.


Eric1982
User
Posts: 57

Post by Eric1982 »

Thank you Danielc, indeed, I had enabled ''force selection'' and I have disabled it now and it works !

I am happy, thanks again.


andyrav
User
Posts: 641

Post by andyrav »

I have assigned a user to a company, how would i add a filter to only show records of that company when the users log ins?

cheers


mobhar
User
Posts: 11745

Post by mobhar »

@andyrav,

Please read "Tutorial - Advanced Security - User ID Security" topic from PHPMaker Help menu for more information and example.


andyrav
User
Posts: 641

Post by andyrav »

function Recordset_Selecting(&$filter) {
if (CurrentUserID() == 2)
ew_AddFilter($filter, "EnterpriseID = 'users.enterpriseid'");
}

this worked


Post Reply