2 * This view lists all postgres usernames that are associated with a CRM
3 * Account that owns a resource. That associaiton is either the main user
4 * account, owner's user account, customer's sale rep's user account or
5 * a shared access that has been specifically granted.
7 * This view can be used to determine which users have personal privilege
8 * access to a Customer that a Ship To is on based on what CRM Account the
12 select xt.create_view('xt.share_users_shipto_cust', $$
14 -- Customer that is for a Ship To CRM Account's users.
16 shipto_cust_crmacct_id.obj_uuid::uuid AS obj_uuid,
17 username::text AS username
23 LEFT JOIN crmacct ON crmacct_cust_id = shipto_cust_id
24 LEFT JOIN custinfo ON cust_id = shipto_cust_id
25 ) shipto_cust_crmacct_id
26 LEFT JOIN xt.crmacct_users USING (crmacct_id)
28 AND username IS NOT NULL
29 AND obj_uuid IS NOT NULL;