CRM-21419 Radio options create separate activities
authorSean Madsen <sean@seanmadsen.com>
Thu, 9 Nov 2017 16:02:32 +0000 (11:02 -0500)
committerSean Madsen <sean@seanmadsen.com>
Thu, 9 Nov 2017 18:20:14 +0000 (13:20 -0500)
Instead of a checkbox for the user to choose to create separate
activities for each contact, use a set of radio options in order to
prompt the user to make a decision. This helps prevent users from
accidentally choosing to create combined activities.

CRM/Activity/Form/Activity.php
templates/CRM/Activity/Form/Activity.hlp
templates/CRM/Activity/Form/Activity.tpl

index 9cdfd4a74a204f7454cb5f154f7f69ace0c4fbdf..58d7eadff2fb64eb957ea421c1b5d15cfdb4c5f6 100644 (file)
@@ -704,7 +704,14 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
 
     // this option should be available only during add mode
     if ($this->_action != CRM_Core_Action::UPDATE) {
-      $this->add('advcheckbox', 'is_multi_activity', ts('Create a separate activity for each contact.'));
+      $this->addRadio(
+        'separation',
+        ts('Activity Separation'),
+        array(
+          'separate' => ts('Create separate activities for each contact'),
+          'combined' => ts('Create one activity with all contacts together'),
+        )
+      );
     }
 
     $this->addRule('duration',
@@ -832,6 +839,12 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
     if ((!empty($fields['followup_activity_subject']) || !empty($fields['followup_date'])) && empty($fields['followup_activity_type_id'])) {
       $errors['followup_activity_subject'] = ts('Follow-up Activity type is a required field.');
     }
+    $actionIsAdd = $self->_action == CRM_Core_Action::ADD;
+    $hasMultipleTargetContacts = !empty($fields['target_contact_id']) && strpos($fields['target_contact_id'], ',') !== FALSE;
+    $separationFieldIsEmpty = empty($fields['separation']);
+    if ($actionIsAdd && $hasMultipleTargetContacts && $separationFieldIsEmpty) {
+      $errors['separation'] = ts('Activity Separation is a required field.');
+    }
     return $errors;
   }
 
@@ -916,6 +929,8 @@ class CRM_Activity_Form_Activity extends CRM_Contact_Form_Task {
       $this->_activityId
     );
 
+    $params['is_multi_activity'] = CRM_Utils_Array::value('separation', $params) == 'separate';
+
     $activity = array();
     if (!empty($params['is_multi_activity']) &&
       !CRM_Utils_Array::crmIsEmptyArray($params['target_contact_id'])
index e0d55672350023419abd512f9f72071c276e7cf1..25c4b7193f3da4576eb41886cae310a07a011771 100644 (file)
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
 *}
-{htxt id="id-is_multi_activity-title"}
-  {ts}Create Separate Activity Records?{/ts}
+{htxt id="separation-title"}
+  {ts}Activity Separation{/ts}
 {/htxt}
-{htxt id="id-is_multi_activity"}
-  <p>{ts}By default a single activity record will be created and linked to all the contacts listed above. However, if you think you might be editing the activity later - and entering different information for different contacts - check this box to create separate activity records.{/ts}</p>
+{htxt id="separation"}
+  <p>{ts}With separate activities, you can enter different activity information for different contacts after creating the activities.{/ts}</p>
+  <p>{ts}With a single activity, the activity information cannot be customized for each contact.{/ts}</p>
 {/htxt}
 
 {htxt id="assignee_contact_id"}
index 278475ca831979ca011addf02dc464d7771c87a5..4365241d03841e9ebf7a3b41048350d6316d2b51 100644 (file)
   <td class="label">{$form.target_contact_id.label}</td>
     <td class="view-value">
       {$form.target_contact_id.html}
-      {if $action eq 1 or $single eq false}
-      <div class="crm-is-multi-activity-wrapper">
-        {$form.is_multi_activity.html}&nbsp;{$form.is_multi_activity.label} {help id="id-is_multi_activity"}
-      </div>
-      {/if}
     </td>
   </tr>
 
+  {if $action eq 1 or $single eq false}
+    <tr class="crm-activity-form-block-separation crm-is-multi-activity-wrapper">
+      <td class="label">{$form.separation.label}</td>
+      <td>{$form.separation.html} {help id="separation"}</td>
+    </tr>
+  {/if}
+
   <tr class="crm-activity-form-block-assignee_contact_id">
       <td class="label">
         {$form.assignee_contact_id.label}