(This specification supports the use cases described here: http://blog.civicrm.org/node/318 )
1. Configure Online Contribution Page
1.1 Add a boolean flag and a text field to Contribution Page object (civicrm_contribution_page) which enables the "On behalf of an organization" feature and allows user to customize the prompt:
- is_for_organization boolean default 0
++ If enabled, the contribution page will allow a contact to contribute or signup or renew a membership on behalf of an organization.
- for_organization_text varchar 255 default NULL
++ Field label for the checkbox to include on contribution form.
1.2 Add fields to Configure Contribution Page - Title and Settings form
- is_for_organization = checkbox, label = "Allow individuals to contribute and / or signup for membership on behalf of an organization?"
- for_organization_text = text field, label = "On behalf of label"
++ This text field is shown when is_for_organization is checked. Form setDefaults() provides default text for the field: "I am contributing on behalf on an organization"
1.3 Note the "DB upgrade task" on wiki : http://wiki.civicrm.org/confluence/display/CRM/Upgrade+Requirements+-+2.0+to+2.1
2. Changes to Online Contribution Page (contribute/transact)
2.1 If is_for_organization is true, include a checkbox with the for_organization_text label just below the Email Address field.
2.2 If for_organization checked by contributor, use Ajax/dojo to load a fieldset below the checkbox consisting of the following fields:
(all address fields as configured in preferences.address_options)
- Organization Name and Email are required. All other fields are optional.
NOTE: This is the same set of fields provided for permissioned contacts to edit "their related contacts" via the Contact Dashboard - as specified here: http://issues.civicrm.org/jira/browse/CRM-2963
2.3 Logic for authenticated user
If the individual is authenticated, we can check for existing permissioned employee<->employer relationships. If found, use the radio button + dojoComboBox interface to allow them to select an existing related organization or enter a new one.
2.4 Post Process steps
When for_organization is true - we will be either finding matching contact records or creating contact records for both the Individual (who is filling out the form) as well as for the "on behalf of" organization. The create / update contact logic for the submitting individual should not need to be modified. For the organization contact:
- Use the configured Duplicate Contact Rules for Organizations to determine if this is an existing contact Org record or not.
++ If NO match found: Create organization contact with the form field values (on behalf of org fieldset)
++ if SINGLE match found: Use found contact record id - and update the contact data with any non-blank values from the submitted form (including org name, address, email or phone info).
++ If MORE THAN ONE match found : Do NOT use matching contact ID. Handle this as a NO match case (insert contact, link new contact to contrib etc.). AND send an email to the civicrm_contribution_page.receipt_from_email alerting that there is a possible duplicate contact situation. (see below for content of this email)
- Check for existing employee - employer relationship between individual and organization. Create if relationship if needed. Set is_permission_a_b = true.
- Use the ORGANIZATION contact ID when creating the contribution record. If this is a membership signup case, also use ORGANIZATION contact ID in membership record.
- If receipt is generated, and Organization Email is ! = Individual's Email - then send receipt to BOTH addresses.
3. Online Membership Renewals
When an authenticated user goes to an Online Contribution page which includes a Membership Block - we currently check to see if they have an existing membership matching one of the membership types included in the block. If true, we display status and expiration date of that membership next to it's radio button option. Post process then renews the membership. In order to support "on behalf of" memberships - we need to know which membership the user wants to renew. The "infrastructure" for this is to allow a membership ID to be passed in to Online Contribution pages - see http://issues.civicrm.org/jira/browse/CRM-2971 for the implementation of this functionality.
3.1 If a valid membership id (mid=x) is passed AND that membership ID is for a related (permissioned) organization - then set the for_organization checkbox to "CHECKED" and load the member (organization) contact data into the organization fieldset FROZEN (read-only).
3.2 PostProcess should then renew the specified membership for the organization.
4. Email Alert for Duplicate Organization Warning
This email is sent only when we insert an "on behalf of organization" contact record because we found MORE THAN ONE matching existing organization contact using the default strict dupe matching rule.
Subject: Possible Duplicate Contact Record
The contribution listed below was submitted on behalf of an organization, and the organization information matches existing records in your database. Please review the following record:
http://<link to view the inserted organization contact record>
If you think this may be a duplicate contact which should be merged with an existing record - use the following link to identify the potential duplicates and merge them if appropriate:
http://<link to Find Dupes function>
— (Put copy of entire contribution receipt here )----
— End Body of Email ----
NOTE: If we support this (check w/ Piotr or Pankaj), add a param in the Find Dupes link in the email (above) which tells that function to look for dupes OF THE INSERTED CONTACT. Otherwise - just put in a generic link to that page (...civicrm/admin/deduperules?reset=1)