Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-8500

Support multiple profiles for 'on behalf of' form in online contribution pages

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.4.4, 4.0.4
    • Fix Version/s: 3.4.6, 4.0.6
    • Labels:
      None

      Description

      =======
      Summary
      =======
      Currently a single reserved profile is used in any online contribution page when "On behalf of an organization" feature is enabled. Some organizations need to collect different sets of information about "on behalf organizations" on different contribution pages. This feature will allow administrations to create and select different profiles for different contribution pages (as long as the profile contains a valid combination of field types - e.g. Contact, Organization, Contribution, Membership fields only).

      =========
      DB Changes
      =========
      No schema changes are required. The existing civicrm_uf_join table 'module' column will be used to indicate which profile has been assigned for a give contribution page On Behalf section.

      ===========
      Implementation
      ===========
      1. Configure Contribution Page - Settings form
      1.1 Add <select> field (onbehalf_profile_id) inside the table which contains the On Behalf fields (inside conditionally displayed <tr id="for_org_option"> row) - below the On behalf Label field.
      Field Label: "Organization Profile"
      Option values: '- select profile -' + title / id's of valid on-behalf profiles (profile type contains contact and / or organization, organization name field is included in profile, type may also include contribution and membership).

      NOTE: Seems like we need a new getValidProfiles BAO (or a new switch for CRM_Core_BAO_UFGroup::getProfiles) that makes it easier to retrieve profiles which do NOT contain certain types.

      1.2 FormRule
      If is_organization is checked, then organization profile (on_behalf_profile_id) is required. "Please select a profile to collect organization information on this contribution page."

      1.3 PreProcess
      Check for valid on-behalf profiles. If found, build the select values. If none found, freeze the is_organization checkbox and add status message below it: "You must <a href="$manageProfilesURL">configure a valid organization profile</a> in order to allow individuals to contribute on behalf of an organization. Valid profiles include Contact and / or Organization fields, and may include Contribution and Membership fields."

      1.4 Set Defaults
      Check for OnBehalfOrganization profile belonging to this contribution page (in uf_join table), and select option value if found.

      1.5 Post Process
      Insert or update uf_join row if onbehalf_profile_id has a value.

      2. Online Contribution Pages (CRM/Contribute/Form/Contribution/Main.php, Confirm.php, Thankyou.php)
      2.1 Main contribution form (Main.php)
      Retrieve the configured on behalf profile from uf_join table rather than grabbing the 'on_behalf_organization' profile

      2.2 Confirm, Thankyou and Message Templates (online contribution and online memberships)
      Same as above

      3. Miscellaneous cleanup
      Grep for remaining instances of 'on_behalf_organization' and review / modify if needed.
      EXAMPLE: In CRM/Contribute/Form/ContributionPage/Custom::buildQuickForm - I think the code which builds the $profiles array can be simplified a bit. I'm not sure why / if we care whether the 'on_behalf_organization' profile is included custom_pre_id / custom_post_id <select>. Rather we want to make sure that only valid profiles are offered (type excludes 'Organization', 'Household', 'Participant', 'Activity'). (Another reason for a new getValidProfiles BAO.)

      4. Upgrades
      Online contribution page(s) on existing sites which are utilizing the OnBehalf feature will need to be upgraded so that these contribution pages are linked to the default On Behalf profile in the uf_join table. Upgrade code:

      SELECT @proflleId := max(id) FROM civicrm_uf_group where name = 'on_behalf_organization';
      INSERT INTO civicrm_uf_join (module, entity_table, entity_id, weight, uf_group_id)
      SELECT 'OnBehalfOrganization', 'civicrm_contribution_page', civicrm_contribution_page.id, 1, @proflleId
      FROM civicrm_contribution_page
      WHERE is_for_organization = 1;

      Future Extension for Related Contact forms
      ==============================
      This approach can be extended to handle profile selections for the Contact Dashboard->Related Contact forms - storing each of the 3 options (Related Individual, Related Organization, Related Household) as additional uf_join rows with their own module strings (RelatedContactOrganization, RelatedContactIndividual. RelatedContactHousehold). Administrators would select the desired profile for each of these using 3 new dropdowns in the Contact Dashboard section of the Site Preferences form (CRM/Admin/Form/Preferences/Display.php).

        Attachments

          Activity

            People

            • Assignee:
              rajan Rajan P Mayekar
              Reporter:
              dgg David Greenberg
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: