From 0ee2ad7690735ed2e0db46eb79887e2bfe03999e Mon Sep 17 00:00:00 2001 From: Kurund Jalmi Date: Wed, 27 Mar 2013 15:47:44 +0530 Subject: [PATCH] worked on CRM-12202, added new form for changing activity status and used it for dialog. also cleaned up js used for building dialog --- CRM/Case/BAO/Case.php | 2 +- CRM/Case/Form/ActivityChangeStatus.php | 53 ++++++++++++ CRM/Case/Form/CaseView.php | 5 +- CRM/Case/Page/DashBoard.php | 3 + CRM/Case/xml/Menu/Case.xml | 5 ++ .../CRM/Case/Form/ActivityChangeStatus.js | 59 +++++++++++++ .../CRM/Case/Form/ActivityChangeStatus.tpl | 84 ++----------------- templates/CRM/Case/Form/CaseView.tpl | 1 - 8 files changed, 130 insertions(+), 82 deletions(-) create mode 100644 CRM/Case/Form/ActivityChangeStatus.php create mode 100644 templates/CRM/Case/Form/ActivityChangeStatus.js diff --git a/CRM/Case/BAO/Case.php b/CRM/Case/BAO/Case.php index 30764eac00..3ccbff8aa2 100644 --- a/CRM/Case/BAO/Case.php +++ b/CRM/Case/BAO/Case.php @@ -1287,7 +1287,7 @@ SELECT case_status.label AS case_status, status_id, case_type.label AS case_type } if ($allowEdit) { - $values[$dao->id]['status'] = '' . $values[$dao->id]['status'] . ''; + $values[$dao->id]['status'] = '' . $values[$dao->id]['status'] . ''; } } $dao->free(); diff --git a/CRM/Case/Form/ActivityChangeStatus.php b/CRM/Case/Form/ActivityChangeStatus.php new file mode 100644 index 0000000000..1f671621bd --- /dev/null +++ b/CRM/Case/Form/ActivityChangeStatus.php @@ -0,0 +1,53 @@ +add('select', 'activity_change_status', ts('New Status'), $activityStatus); + } +} + diff --git a/CRM/Case/Form/CaseView.php b/CRM/Case/Form/CaseView.php index 7ddad8384c..615f7dee2a 100644 --- a/CRM/Case/Form/CaseView.php +++ b/CRM/Case/Form/CaseView.php @@ -51,8 +51,10 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { * @access public */ public function preProcess() { - $this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET); + // js for changing activity status + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); + $this->_showRelatedCases = CRM_Utils_Array::value('relatedCases', $_GET); $xmlProcessorProcess = new CRM_Case_XMLProcessor_Process(); $isMultiClient = $xmlProcessorProcess->getAllowMultipleCaseClients(); @@ -330,7 +332,6 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form { $activityStatus = CRM_Core_PseudoConstant::activityStatus(); $this->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus); - $this->add('select', 'activity_change_status', ts('New Status'), $activityStatus); // activity dates $this->addDate('activity_date_low', ts('Activity Dates - From'), FALSE, array('formatType' => 'searchDate')); diff --git a/CRM/Case/Page/DashBoard.php b/CRM/Case/Page/DashBoard.php index 9f3a4a33e6..083e781a48 100644 --- a/CRM/Case/Page/DashBoard.php +++ b/CRM/Case/Page/DashBoard.php @@ -47,6 +47,9 @@ class CRM_Case_Page_DashBoard extends CRM_Core_Page { * */ function preProcess() { + // js for changing activity status + CRM_Core_Resources::singleton()->addScriptFile('civicrm', 'templates/CRM/Case/Form/ActivityChangeStatus.js'); + //check for civicase access. if (!CRM_Case_BAO_Case::accessCiviCase()) { CRM_Core_Error::fatal(ts('You are not authorized to access this page.')); diff --git a/CRM/Case/xml/Menu/Case.xml b/CRM/Case/xml/Menu/Case.xml index 5d5e622429..af47eb036a 100644 --- a/CRM/Case/xml/Menu/Case.xml +++ b/CRM/Case/xml/Menu/Case.xml @@ -139,4 +139,9 @@ civicrm/ajax/delcaserole CRM_Case_Page_AJAX::deleteCaseRoles + + civicrm/case/changeactivitystatus + Change Activity Status + CRM_Case_Form_ActivityChangeStatus + diff --git a/templates/CRM/Case/Form/ActivityChangeStatus.js b/templates/CRM/Case/Form/ActivityChangeStatus.js new file mode 100644 index 0000000000..2c2dce7230 --- /dev/null +++ b/templates/CRM/Case/Form/ActivityChangeStatus.js @@ -0,0 +1,59 @@ +// http://civicrm.org/licensing +function changeActivityStatus(activityId, contactId, current_status_id, caseId) { + var data = 'snippet=1&reset=1'; + cj('
') + .load(CRM.url('civicrm/case/changeactivitystatus'), data, function() { + cj("#activity_change_status").val(current_status_id); + }) + .dialog({ + modal: true, + title: ts('Change Activity Status'), + buttons: { + "Ok" : function() { + // update the status + var status_id = cj("#activity_change_status").val( ); + + if (status_id === current_status_id) { + return false; + } + + var dataUrl = CRM.url('civicrm/ajax/rest'); + var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityId + '&status_id=' + status_id + + '&case_id=' + caseId; + cj.ajax({ + type : "POST", + dataType : "json", + url : dataUrl, + data : data, + success : function( values ) { + if ( values.is_error ) { + // seems to be some discrepancy as to which spelling it should be + var err_msg = values.error_msg ? values.error_msg : values.error_message; + CRM.alert(err_msg, ts('Unable to change status'), 'error'); + return false; + } + else { + // just reload the page on success + window.location.reload(); + } + }, + error : function( jqXHR, textStatus ) { + CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error'); + return false; + } + }); + + cj(this).dialog('close').remove(); + }, + "Cancel": function() { + cj(this).dialog('close').remove(); + } + }, + beforeClose: function() { + cj(this).dialog("destroy"); + } + } + ); +} + + diff --git a/templates/CRM/Case/Form/ActivityChangeStatus.tpl b/templates/CRM/Case/Form/ActivityChangeStatus.tpl index 9b6068bc05..c32650b09f 100644 --- a/templates/CRM/Case/Form/ActivityChangeStatus.tpl +++ b/templates/CRM/Case/Form/ActivityChangeStatus.tpl @@ -24,83 +24,11 @@ +--------------------------------------------------------------------+ *} {* CiviCase - change activity status inline *} -
- - +
+ - - -
{$form.activity_change_status.label}{$form.activity_change_status.html}
-
-
- -{literal} - -{/literal} + {$form.activity_change_status.html} + + +
\ No newline at end of file diff --git a/templates/CRM/Case/Form/CaseView.tpl b/templates/CRM/Case/Form/CaseView.tpl index 4321d24a54..955c03b06e 100644 --- a/templates/CRM/Case/Form/CaseView.tpl +++ b/templates/CRM/Case/Form/CaseView.tpl @@ -766,7 +766,6 @@ function addRole() { {/literal} {include file="CRM/Case/Form/ActivityToCase.tpl"} -{include file="CRM/Case/Form/ActivityChangeStatus.tpl"} {* pane to display / edit regular tags or tagsets for cases *} {if $showTags OR $showTagsets} -- 2.25.1