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

Recently added relationship to civicrm_phone to allow multiple phone numbers in views is limited

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Trivial
    • Resolution: Fixed/Completed
    • Affects Version/s: 3.3.5
    • Fix Version/s: None
    • Labels:
      None

      Description

      I recently submitted a patch that added a relationship to the civicrm_phone table in views. This met the goal of allowing the addition of multiple phone number types/fields to views. This patch has 2 limitations:

      1. If no filter is defined the resulting value is ambiguous.
      2. If a filter is defined, only contacts with a phone number are returned. In a contact search you usually want to see all contacts even if they don't have a phone number. This is compounded by each number added. If you add phone and fax you only get the contacts who have both numbers defined.

      This patch adds a new handler, civicrm_handler_field_phone. The handler lets the user select a phone type in the field options instead of in the filter. The handler also modifies the query by adding a join condition to the query object so the resulting sql looks like "LEFT JOIN civicrm_phone on civicrm_contact.id = civicrm_phone.contact_id AND civicrm_phone.phone_type_id = 1". This returns all contact records whether or not there is a matching record in the phone table and empty phone numbers return null, just as you would expect from a left join.

      The filter still exists for the situations when you do want only those contacts with a phone number.

      I believe this patch also includes the code from my original patch.

        Attachments

        1. civicrm_handler_field_phone.inc
          2 kB
          Quint Jensen
        2. complexjoin.patch
          3 kB
          Quint Jensen

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              qjensen Quint Jensen
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: