Would i be able to apply the same Principle in changing what menu ITEMS are displayed in a drop down. ie Sales agent only sees certain status update options to select where as >dealers see a different set of status options?
If you mean to hide or show some menu items depending on who is logged in, then enable dynamic user level permissions(read about it in advanced security), this can help you create specific user levels and assign then specific permissions to add,edit,list,view specific tables, hence the menu will automatically hide those they dont have permissions for.
As for what you have explained you want to achieve, as long as you stick to the good database principals and set up each entity separate but allow it to extend it can be achived.
***********NOTE: Just look at this structure and see how to adjust what you have**********************
************For example if i was to go about it**********
the Supplier needs the application assigned to his User ID however the sales agent still needs it assigned to his userID so as to keep track of the Sale and the progress, (Each >Application has a Status Field).
1.create a table for customer
2.create a table for sales agents
3.create a table for supplier
- NOTE: since all the above people can log into the system. each of the above tables should have alink to a specifc user account. ie
CREATE TABLE sales_agent, cutomer, supplier(
------------------
user_account_id int(11), (linking to the user_account table)
-----------------
);
NOTE:You can also create different userlevels for each groups such that you can limit what each of them accesses
With this you can even have the same user account being a customer, a sales agent and a supplier at the same time
- Create global fucntions to give you customer, sales agent and supplier ids of each logged in user. eg in global fucnitons write.
//NOTE:these return the respective id or return null if user is not one of those people
function GetMyCustomerID()
{
$current_user_id = CurrentUserID();
return ew_ExecuteScalar("select id from customer where user_account_id = '".$current_user_id."'");
}
function GetMySalesAgentID()
{
$current_user_id = CurrentUserID();
return ew_ExecuteScalar("select id from sales_agent where user_account_id = '".$current_user_id."'");
}
function GetMySupplierID()
{
$current_user_id = CurrentUserID();
return ew_ExecuteScalar("select id from supplier where user_account_id = '".$current_user_id."'");
}
NOTE:now you can call thses functions anywhere to use them as well as check if a logged in user is a supplier or if he is a customer etc etc.
- IMPORTANT:WHEN ADDING leads or applications, DO NOT ASSIGN then to a user_id directly.
INSTEAD:ensure that the leads tabe and applications table have fields to hold specific attachements to respective customer, sales_agent, supplier, forexample the table would look something like
CREATE TABLE leads, applications(
-------------------------------------
customer_id int(11) this links to your customer table to show which customer this belongs to
sales_agent_id int(11) this links to your sales_agent table to show which sales agent this belongs to
supplier_id int(11) this links to your supplier table to show which supplier this belongs to
-------------------------------------
);
NOTE: just ensure to update these fileds whenever you assign something to a specific customer, sales_agent and supplier, whenever this happnes, or update them when this cahnges.
- We such a structure,a ll am left with is to filter out the leads or applications list to show only those belongint to a given customer, supplier or sales_Agent. which I can easily do in record_slecting depending on how many types of users can access that list.
For example assuming that customer,sales_Agent and supplier both access the ame list page to see applications I would filter it like this.
function Recordset_Selecting(&$filter) {
//get current informtion based on logged in user
$current_customer_id = GetMyCustomerID();
$current_supplier_id = GetMySupplierID();
$current_sales_agent_id = GetMySalesAgentID();
//ASSUMING THIS table has all the three fields indicated previously
//show all records for this customer, or this supplier or this sales agent
ew_AddFilter($filter, " (customer_id = '$current_customer_id' OR supplier_id = '$current_supplier_id' OR sales_agent_id = '$current_sales_agent_id' ) "); // Add your own filter expression
}
HINT: database structure is very important so whenever you are making a given tables try to think ahead into what your ultimate goal is so you can know if you need to extend it or add some sort of foreign keys and think about all the other entities that are likely to use and it will be affected etc etc