}
if ($allowEdit) {
- $values[$dao->id]['status'] = '<a class="crm-activity-status crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . '" href="javascript:changeActivityStatus(' . $dao->id . ',' . $contactID . ',' . $dao->status . ');" title=\'' . $statusTitle . '\'>' . $values[$dao->id]['status'] . '</a>';
+ $values[$dao->id]['status'] = '<a class="crm-activity-status crm-activity-status-' . $dao->id . ' ' . $values[$dao->id]['class'] . '" href="javascript:changeActivityStatus(' . $dao->id . ',' . $contactID . ',' . $dao->status . ', ' . $caseID . ');" title=\'' . $statusTitle . '\'>' . $values[$dao->id]['status'] . '</a>';
}
}
$dao->free();
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.3 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ * $Id$
+ *
+ */
+
+/**
+ * This class generates form components for building changing activity status interface in a case
+ *
+ */
+class CRM_Case_Form_ActivityChangeStatus extends CRM_Core_Form {
+
+ /**
+ * Function to build the form
+ *
+ * @return None
+ * @access public
+ */
+ public function buildQuickForm() {
+ $activityStatus = CRM_Core_PseudoConstant::activityStatus();
+ $this->add('select', 'activity_change_status', ts('New Status'), $activityStatus);
+ }
+}
+
* @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();
$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'));
*
*/
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.'));
<path>civicrm/ajax/delcaserole</path>
<page_callback>CRM_Case_Page_AJAX::deleteCaseRoles</page_callback>
</item>
+ <item>
+ <path>civicrm/case/changeactivitystatus</path>
+ <title>Change Activity Status</title>
+ <page_callback>CRM_Case_Form_ActivityChangeStatus</page_callback>
+ </item>
</menu>
--- /dev/null
+// http://civicrm.org/licensing
+function changeActivityStatus(activityId, contactId, current_status_id, caseId) {
+ var data = 'snippet=1&reset=1';
+ cj('<div>')
+ .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");
+ }
+ }
+ );
+}
+
+
+--------------------------------------------------------------------+
*}
{* CiviCase - change activity status inline *}
-<div id="changeStatusDialog">
<div class="crm-block crm-form-block crm-case-activitychangestatus-form-block">
-<table class="form-layout">
- <tr class="crm-case-activitychangestatus-form-block-status">
+ <table class="form-layout">
+ <tr class="crm-case-activitychangestatus-form-block-status">
<td class="label">{$form.activity_change_status.label}</td>
- <td>{$form.activity_change_status.html}</td>
- </tr>
-</table>
-</div>
-</div>
-
-{literal}
-<script type="text/javascript">
-cj( "#changeStatusDialog" ).hide( );
-function changeActivityStatus( activityID, contactId, current_status_id ) {
-
- cj("#changeStatusDialog").show();
- cj("#changeStatusDialog").dialog({
- title : "Change Activity Status",
- modal : true,
- bgiframe : true,
- width : 400,
- height : 170,
- close : function( event, ui ) { },
- overlay : { opacity: 0.5, background: "black" },
- beforeclose : function( event, ui ) {
- cj(this).dialog("destroy");
- },
- open : function() {
- cj("#activity_change_status").val( current_status_id );
- },
-
- buttons : {
- "Ok": function() {
- var status_id = cj("#activity_change_status").val( );
-
- cj(this).dialog("destroy");
-
- if ( status_id == current_status_id ) {
- return false;
- }
-
- var dataUrl = {/literal}"{crmURL p='civicrm/ajax/rest' h=0 }"{literal};
- var data = 'json=1&version=3&entity=Activity&action=update&id=' + activityID + '&status_id=' + status_id + '&case_id=' + {/literal}{$caseId}{literal};
- 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, '{/literal}{ts escape="js"}Unable to change status{/ts}{literal}', 'error');
- return false;
- } else {
- // Hmm, actually several links inside the row have to change to use the new activity id
- // and also the row class might change with the new status. So either we duplicate code here,
- // do a reload which defeats the purpose of ajax, or rewrite the way this table works.
- //cj( "a.crm-activity-status-" + activityID ).html(
- // cj("#activity_change_status option[value='" + status_id + "']").text()
- //);
- window.location.reload();
- }
- },
- error : function( jqXHR, textStatus, errorThrown ) {
- CRM.alert(jqXHR.responseText, jqXHR.statusText, 'error');
- return false;
- }
- });
- },
-
- "Cancel": function() {
- cj(this).dialog("close");
- cj(this).dialog("destroy");
- }
- }
- });
-}
-</script>
-{/literal}
+ <td>{$form.activity_change_status.html}</td>
+ </tr>
+ </table>
+</div>
\ No newline at end of file
</script>
{/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}