CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Creating Profile for Employee Listing
Pages: [1]

Author Topic: Creating Profile for Employee Listing  (Read 3736 times)

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Creating Profile for Employee Listing
January 24, 2013, 02:14:04 pm
Is there a way to create a profile that would display the listing of employees for an organization based on the logged in organization?

We allow orgs to log in to the system to renew memberships and want to provide a simple listing of employees that we could include the edit link in the profile to edit the individuals.  We only want to list employees that are relevant to that particular organization.

We do this because there is not a transitive property for relationships in that the org can be granted rights to edit the individuals but granting rights to an individual to edit the organization does not grant the right for the individual to edit other individuals. I know we could create relationships between employees but that is cumbersome and time consuming to do for 2700+ individuals through 350+ organizations especially when the person changes.
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Creating Profile for Employee Listing
January 24, 2013, 04:30:22 pm

when you are logged in as the org, check the "contact dashboard link"

http://drupal.demo.civicrm.org/civicrm/user/dashboard?reset=1

the last section should give all the contacts you have a permissioned relationship on

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Re: Creating Profile for Employee Listing
January 25, 2013, 06:00:37 am
Thanks, I knew that the dashboard did this but I was trying to make a profile that did the same thing for simplicity for our users.  I didn't know if anyone had done this with a profile or perhaps a view in drupal.
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Creating Profile for Employee Listing
January 25, 2013, 02:53:54 pm
I would think this would be a pretty straightforward Views Block
would need Contextual Filters and relationships that do the following
- link the logged in user to their Civi record
- pulls the 'employees of' relationship via a Relationship
- uses Contextual Filter to only show results for User based on Logged in user

hth
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Re: Creating Profile for Employee Listing
January 29, 2013, 01:46:35 pm
Thanks Pete,  just about got it but I can't find a way to filter based on current logged in user, it shows all contacts not just the ones with the Employee Of the current logged in contact ID. Any ideas?
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Creating Profile for Employee Listing
January 29, 2013, 01:52:42 pm
DId you start with a User based View or a civicontact based view?
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Re: Creating Profile for Employee Listing
January 29, 2013, 02:58:22 pm
A CiviContact View
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

NASACT

  • I post frequently
  • ***
  • Posts: 289
  • Karma: 9
    • National Association of State Auditors, Comptrollers and Treasurers
  • CiviCRM version: 4.2.2
  • CMS version: Drupal 7
  • MySQL version: 5.1.58 (ubuntu)
  • PHP version: 5.3.5
Re: Creating Profile for Employee Listing
January 29, 2013, 03:28:58 pm
I have the following view setup, A CiviCRM Contacts based view:

Format:
HTML list

Fields:
Sort Name
Job Title

Filter Criteria:
CiviCRM Contacts: Contact Type (= Individual)
CiviCRM Relationships: Is Relationship Active (True)
CiviCRM Relationships: Relationship Type A-to-B (= Employee of)

SORT CRITERIA:
CiviCRM Contacts: Sort Name (asc)

CONTEXTUAL FILTERS:
(Drupal User) CiviCRM Relationships: Relationship Type A-to-B

RELATIONSHIPS:
CiviCRM Contacts: Drupal ID
(Drupal User) CiviCRM Relationships: Contact ID A

This results in all Individuals rather than just the current Org (Drupal User) logged in

I am sure I am just not fully understanding the proper filter settings on this.
-AJ
My GChat - azon21@gmail.com -  This is where you can find me most days!

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Creating Profile for Employee Listing
January 31, 2013, 10:18:50 am
I would think you'd want to be filtering on contact type = org if that's what your view is showing.
Try asking your question on the new CiviCRM help site.

Hershel

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4640
  • Karma: 176
    • CiviHosting
  • CiviCRM version: Latest
  • CMS version: Mostly WordPress and Drupal
Re: Creating Profile for Employee Listing
May 13, 2013, 06:03:08 am
NASACT, your View shows all Contacts because you don't have a filter to show only the currently logged in user. What you could do is choose " Provide default value " for "When the filter value is NOT in the URL" and selected "PHP Code" and then use this code:

Code: [Select]
// Get current user
global $user;
// Find his Contact ID
if (module_exists('civicrm')) {
  $sql = "SELECT contact_id FROM {civicrm_uf_match} WHERE uf_id = {$user->uid}";
$r = db_query($sql);
foreach ($r as $record) {
  $contact_id = $record->contact_id;
}
}

return $contact_id;

Would be better to use the API but I will leave that as an exercise for the reader. ;)
CiviHosting and CiviOnline -- The CiviCRM hosting experts, since 2007

See here for the official: What to do if you think you've found a bug.

hbergin

  • I post occasionally
  • **
  • Posts: 66
  • Karma: 6
  • CiviCRM version: 3.4.5 to 4.4.1
  • CMS version: Drupal 6.28 to 7.23
  • MySQL version: 5.5.34
  • PHP version: 5.3.10
Re: Creating Profile for Employee Listing
May 13, 2013, 07:34:47 am
I was looking for a similar list to you (list of children for a logged in parent), and found the following settings seem to work for me.  Changing that relationship from "parent of" to "employer of" may work for you.  I didn't use any contextual filters:

RELATIONSHIPS
CiviCRM Relationships: Contact ID B (relationship required, parent of) - Identifier: CiviCRM Contact B
CiviCRM Contacts: Drupal ID (seems to work whether relationship required or not) - Identifier: Drupal User

FIELDS
(CiviCRM Contact B) CiviCRM Contacts: Job Title (Job Title)
(CiviCRM Contact B) CiviCRM Contacts: Sort Name (Sort Name)

FILTER CRITERIA
(Drupal User) User: Current (Yes)

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Profiles (Moderator: Dave Greenberg) »
  • Creating Profile for Employee Listing

This forum was archived on 2017-11-26.