You can have something like this,
function my_controller
{
$crud->set_table('other');
if($user->is_manager())
{
$crud->fields(...); // all except company
$crud->columns(...); // everything
$crud->where('company',$user->company);
$crud->callback_before_insert(array($this, 'mycallback');
}
}
function mycallback($post_array)
{
$post_array['company'] = $user->company;
return $post_array;
}
But I am still unsure how you differentiate between records that an admin has inserted from a manager.
Hence, do managers see the records added by the admins, if not then you need to put something more in your logic in order to support this.
If that's not the case then your case is simple and it doesn't need any complex joins or something similar.
-----------------------------------------------
The admin sees a superset of values - the manager sees only those locations and others that are relevant to the company they are in.
Managers will see any records added by admin for their company.
In your solution you have set_table ('other'), but the where clause introduces another table (company). How does that table end up in the from clause (or is that a standard part of CI?)
Also how do you filter for the chain of locations that are connected to companies?
thanks,