Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRM-21419 Prevent users from accidentally creating a single activity when they want multiple #11264

Merged
merged 1 commit into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion CRM/Activity/Form/Activity.php
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,14 @@ public function buildQuickForm() {

// 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',
Expand Down Expand Up @@ -832,6 +839,12 @@ public static function formRule($fields, $files, $self) {
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;
}

Expand Down Expand Up @@ -916,6 +929,8 @@ public function postProcess($params = NULL) {
$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'])
Expand Down
9 changes: 5 additions & 4 deletions templates/CRM/Activity/Form/Activity.hlp
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
| 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"}
Expand Down
12 changes: 7 additions & 5 deletions templates/CRM/Activity/Form/Activity.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,16 @@
<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}
Expand Down