From ccfd6962061ca1331f7285aa29a58f9cb1a1fcf2 Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 6 Apr 2017 14:14:06 -0400 Subject: [PATCH] CRM-16633 - Allow user to change case subject --- CRM/Upgrade/Incremental/php/FourSeven.php | 20 +++++++++++++++ templates/CRM/Case/Form/CaseView.js | 12 +++++++++ templates/CRM/Case/Form/CaseView.tpl | 30 ++++++++++++++++++++++- xml/templates/civicrm_data.tpl | 9 +++---- 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/CRM/Upgrade/Incremental/php/FourSeven.php b/CRM/Upgrade/Incremental/php/FourSeven.php index f06f714eb9..e27f43143c 100644 --- a/CRM/Upgrade/Incremental/php/FourSeven.php +++ b/CRM/Upgrade/Incremental/php/FourSeven.php @@ -340,6 +340,7 @@ class CRM_Upgrade_Incremental_php_FourSeven extends CRM_Upgrade_Incremental_Base 'civicrm_sms_provider', 'domain_id', 'int(10) unsigned', "Which Domain is this sms provier for"); $this->addTask('CRM-19961 - Populate domain id table and perhaps add foreign key', 'populateSMSProviderDomainId'); $this->addTask(ts('Upgrade DB to %1: SQL', array(1 => $rev)), 'runSql', $rev); + $this->addTask('CRM-16633 - Add "Change Case Subject" activity', 'addChangeCaseSubjectActivityType'); $this->addTask('Add is_public column to civicrm_custom_group', 'addColumn', 'civicrm_custom_group', 'is_public', "boolean DEFAULT '1' COMMENT 'Is this property public?'"); } @@ -1091,4 +1092,23 @@ FROM `civicrm_dashboard_contact` JOIN `civicrm_contact` WHERE civicrm_dashboard_ return TRUE; } + /** + * CRM-16633 - Add activity type for Change Case Status + * + * @param \CRM_Queue_TaskContext $ctx + * + * @return bool + */ + public static function addChangeCaseSubjectActivityType(CRM_Queue_TaskContext $ctx) { + CRM_Core_BAO_OptionValue::ensureOptionValueExists(array( + 'option_group_id' => 'activity_type', + 'name' => 'Change Case Subject', + 'label' => ts('Change Case Subject'), + 'is_active' => TRUE, + 'component_id' => 'CiviCase', + 'icon' => 'fa-pencil-square-o', + )); + return TRUE; + } + } diff --git a/templates/CRM/Case/Form/CaseView.js b/templates/CRM/Case/Form/CaseView.js index 43ae02172a..06fdec4b00 100644 --- a/templates/CRM/Case/Form/CaseView.js +++ b/templates/CRM/Case/Form/CaseView.js @@ -206,6 +206,18 @@ $(this).select2('val', ''); } }) + // When changing case subject, record an activity + .on('crmFormSuccess', '[data-field=subject]', function(e, value) { + var id = caseId(); + CRM.api3('Activity', 'create', { + case_id: id, + activity_type_id: 'Change Case Subject', + subject: value, + status_id: 'Completed' + }).done(function() { + $('#case_id_' + id).dataTable().api().draw(); + }); + }) .on('click', 'a.case-miniform', function(e) { var dialog, $el = $(this), diff --git a/templates/CRM/Case/Form/CaseView.tpl b/templates/CRM/Case/Form/CaseView.tpl index 002e008c31..351ee62afb 100644 --- a/templates/CRM/Case/Form/CaseView.tpl +++ b/templates/CRM/Case/Form/CaseView.tpl @@ -80,7 +80,7 @@ {/if} - {ts}Subject{/ts}: {$caseDetails.case_subject} + {ts}Subject{/ts}: {$caseDetails.case_subject} {ts}Type{/ts}: {$caseDetails.case_type}  @@ -325,3 +325,31 @@
{include file="CRM/common/formButtons.tpl" location="bottom"}
{/if} {* view related cases if end *} +{literal} + +{/literal} diff --git a/xml/templates/civicrm_data.tpl b/xml/templates/civicrm_data.tpl index 3ddce5e41f..f08616e60d 100644 --- a/xml/templates/civicrm_data.tpl +++ b/xml/templates/civicrm_data.tpl @@ -327,6 +327,8 @@ VALUES (@option_group_id_act, '{ts escape="sql"}Follow up{/ts}', 14, 'Follow up', NULL, 0, 0, 14, '', 0, 1, 1, @caseCompId, NULL, 'fa-share-square-o'), (@option_group_id_act, '{ts escape="sql"}Change Case Type{/ts}', 15, 'Change Case Type', NULL, 0, 0, 15, '', 0, 1, 1, @caseCompId, NULL, 'fa-random'), (@option_group_id_act, '{ts escape="sql"}Change Case Status{/ts}', 16, 'Change Case Status', NULL, 0, 0, 16, '', 0, 1, 1, @caseCompId, NULL, 'fa-pencil-square-o'), + (@option_group_id_act, '{ts escape="sql"}Change Case Subject{/ts}',53, 'Change Case Subject',NULL, 0, 0, 53, '', 0, 1, 1, @caseCompId, NULL, 'fa-pencil-square-o'), + (@option_group_id_act, '{ts escape="sql"}Change Custom Data{/ts}', 33, 'Change Custom Data', NULL, 0, 0, 33, '', 0, 1, 1, @caseCompId, NULL, 'fa-table'), (@option_group_id_act, '{ts escape="sql"}Membership Renewal Reminder{/ts}', 17, 'Membership Renewal Reminder', NULL, 1, NULL, 17, '{ts escape="sql"}offline membership renewal reminder.{/ts}', 0, 1, 1, @memberCompId, NULL, NULL), (@option_group_id_act, '{ts escape="sql"}Change Case Start Date{/ts}', 18, 'Change Case Start Date', NULL, 0, 0, 18, '', 0, 1, 1, @caseCompId, NULL , 'fa-calendar'), @@ -345,12 +347,9 @@ VALUES (@option_group_id_act, '{ts escape="sql"}Canvass{/ts}', 29, 'Canvass', NULL,0, 0, 28, '', 0, 1, 1, @campaignCompId, NULL, NULL), (@option_group_id_act, '{ts escape="sql"}PhoneBank{/ts}', 30, 'PhoneBank', NULL,0, 0, 29, '', 0, 1, 1, @campaignCompId, NULL, NULL), (@option_group_id_act, '{ts escape="sql"}WalkList{/ts}', 31, 'WalkList', NULL,0, 0, 30, '', 0, 1, 1, @campaignCompId, NULL, NULL), - (@option_group_id_act, '{ts escape="sql"}Petition Signature{/ts}', 32, 'Petition', NULL,0, 0, 31, '', 0, 1, 1, @campaignCompId, NULL, NULL), + (@option_group_id_act, '{ts escape="sql"}Petition Signature{/ts}', 32, 'Petition', NULL,0, 0, 31, '', 0, 1, 1, @campaignCompId, NULL, NULL), (@option_group_id_act, '{ts escape="sql"}Mass SMS{/ts}', 34, 'Mass SMS', NULL, 1, NULL, 34, '{ts escape="sql"}Mass SMS{/ts}', 0, 1, 1, NULL, NULL, NULL), --- Activity Types for CiviCampaign CiviCase - (@option_group_id_act, '{ts escape="sql"}Change Custom Data{/ts}', 33, 'Change Custom Data', NULL,0, 0, 33, '', 0, 1, 1, @caseCompId, NULL, 'fa-table'), - -- Additional Membership-related Activity Types (@option_group_id_act, '{ts escape="sql"}Change Membership Status{/ts}', 35, 'Change Membership Status', NULL, 1, NULL, 35, '{ts escape="sql"}Change Membership Status.{/ts}', 0, 1, 1, @memberCompId, NULL, NULL), (@option_group_id_act, '{ts escape="sql"}Change Membership Type{/ts}', 36, 'Change Membership Type', NULL, 1, NULL, 36, '{ts escape="sql"}Change Membership Type.{/ts}', 0, 1, 1, @memberCompId, NULL, NULL), @@ -386,7 +385,7 @@ VALUES (@option_group_id_act, '{ts escape="sql"}Contact Deleted by Merge{/ts}', 52, 'Contact Deleted by Merge', NULL, 1, NULL, 52, '{ts escape="sql"}Contact was merged into another contact{/ts}',0, 1, 1, NULL, NULL, NULL), -- Activity Type for failed payment - (@option_group_id_act, 'Failed Payment', 53, 'Failed Payment', NULL, 1, 0, 53, 'Failed Payment', 0, 1, 1, @contributeCompId, NULL, NULL), + (@option_group_id_act, 'Failed Payment', 54, 'Failed Payment', NULL, 1, 0, 54, 'Failed Payment', 0, 1, 1, @contributeCompId, NULL, NULL), (@option_group_id_gender, '{ts escape="sql"}Female{/ts}', 1, 'Female', NULL, 0, NULL, 1, NULL, 0, 0, 1, NULL, NULL, NULL), (@option_group_id_gender, '{ts escape="sql"}Male{/ts}', 2, 'Male', NULL, 0, NULL, 2, NULL, 0, 0, 1, NULL, NULL, NULL), -- 2.25.1