--HR-313 Split case activity datatable tpl into separate file
authorDivya Jose <divya@divya.(none)>
Mon, 24 Mar 2014 10:00:33 +0000 (15:30 +0530)
committerDivya Jose <divya@divya.(none)>
Mon, 24 Mar 2014 10:00:33 +0000 (15:30 +0530)
CRM/Case/Form/ActivityForm.php [new file with mode: 0644]
CRM/Case/Form/CaseView.php
templates/CRM/Case/Form/ActivityTab.tpl [new file with mode: 0644]
templates/CRM/Case/Form/CaseView.tpl

diff --git a/CRM/Case/Form/ActivityForm.php b/CRM/Case/Form/ActivityForm.php
new file mode 100644 (file)
index 0000000..3ac4dd9
--- /dev/null
@@ -0,0 +1,72 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | 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 actitvity form elements
+ *
+ */
+class CRM_Case_Form_ActivityForm extends CRM_Core_Form {
+
+  function activityform ($form) {
+    $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($form->_contactID, $form->_caseID);   
+    //build reporter select
+    $reporters = array("" => ts(' - any reporter - '));
+    foreach ($caseRelationships as $key => & $value) {
+      $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )";
+    }
+    $form->add('select', 'reporter_id', ts('Reporter/Role'), $reporters);
+
+    // take all case activity types for search filter, CRM-7187
+    $aTypesFilter = array();
+    $allCaseActTypes = CRM_Case_PseudoConstant::caseActivityType();
+    foreach ($allCaseActTypes as $typeDetails) {
+      if (!in_array($typeDetails['name'], array('Open Case'))) {
+        $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails);
+      }
+    }
+    asort($aTypesFilter);
+    $form->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter);
+
+    $activityStatus = CRM_Core_PseudoConstant::activityStatus();
+    $form->add('select', 'status_id', ts('Status'), array("" => ts(' - any status - ')) + $activityStatus);
+
+    // activity dates
+    $form->addDate('activity_date_low', ts('Activity Dates - From'), FALSE, array('formatType' => 'searchDate'));
+    $form->addDate('activity_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
+
+    if (CRM_Core_Permission::check('administer CiviCRM')) {
+      $form->add('checkbox', 'activity_deleted', ts('Deleted Activities'));
+    }
+  }
+}
\ No newline at end of file
index 0865c54e4eb139708a71a5d0b2de690e354e8ef4..1bd185b5d218b0434546dfb761ec2869df6b0b6a 100644 (file)
@@ -328,16 +328,8 @@ 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);
-
-    // activity dates
-    $this->addDate('activity_date_low', ts('Activity Dates - From'), FALSE, array('formatType' => 'searchDate'));
-    $this->addDate('activity_date_high', ts('To'), FALSE, array('formatType' => 'searchDate'));
-
-    if (CRM_Core_Permission::check('administer CiviCRM')) {
-      $this->add('checkbox', 'activity_deleted', ts('Deleted Activities'));
-    }
+    //call activity form
+    CRM_Case_Form_ActivityForm::activityform($this);
 
     //get case related relationships (Case Role)
     $caseRelationships = CRM_Case_BAO_Case::getCaseRoles($this->_contactID, $this->_caseID);
@@ -345,11 +337,7 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form {
     //save special label because we unset it in the loop
     $managerLabel = empty($managerRoleId) ? '' : $caseRoles[$managerRoleId];
 
-    //build reporter select
-    $reporters = array("" => ts(' - any reporter - '));
     foreach ($caseRelationships as $key => & $value) {
-      $reporters[$value['cid']] = $value['name'] . " ( {$value['relation']} )";
-
       if (!empty($managerRoleId)) {
         if ($managerRoleId == $value['relation_type']) {
           $value['relation'] = $managerLabel;
@@ -362,18 +350,6 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form {
       }
     }
 
-    // take all case activity types for search filter, CRM-7187
-    $aTypesFilter = array();
-    $allCaseActTypes = CRM_Case_PseudoConstant::caseActivityType();
-    foreach ($allCaseActTypes as $typeDetails) {
-      if (!in_array($typeDetails['name'], array(
-        'Open Case'))) {
-        $aTypesFilter[$typeDetails['id']] = CRM_Utils_Array::value('label', $typeDetails);
-      }
-    }
-    asort($aTypesFilter);
-    $this->add('select', 'activity_type_filter_id', ts('Activity Type'), array('' => ts('- select activity type -')) + $aTypesFilter);
-
     $this->assign('caseRelationships', $caseRelationships);
 
     //also add client as role. CRM-4438
@@ -381,8 +357,6 @@ class CRM_Case_Form_CaseView extends CRM_Core_Form {
 
     $this->assign('caseRoles', $caseRoles);
 
-    $this->add('select', 'reporter_id', ts('Reporter/Role'), $reporters);
-
     // Retrieve ALL client relationships
     $relClient = CRM_Contact_BAO_Relationship::getRelationship($this->_contactID,
       CRM_Contact_BAO_Relationship::CURRENT,
diff --git a/templates/CRM/Case/Form/ActivityTab.tpl b/templates/CRM/Case/Form/ActivityTab.tpl
new file mode 100644 (file)
index 0000000..20a12d7
--- /dev/null
@@ -0,0 +1,165 @@
+{*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.4                                                |
+ +--------------------------------------------------------------------+
+ | 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        |
+ +--------------------------------------------------------------------+
+*}
+{*this template is used for activity accordion*}
+<div class="crm-accordion-wrapper crm-case_activities-accordion  crm-case-activities-block">
+  <div class="crm-accordion-header">
+    {ts}Activities{/ts}
+  </div>
+  <div id="activities" class="crm-accordion-body">
+    <div class="crm-accordion-wrapper crm-accordion-inner crm-search_filters-accordion collapsed">
+      <div class="crm-accordion-header">
+        {ts}Search Filters{/ts}</a>
+      </div><!-- /.crm-accordion-header -->
+      <div class="crm-accordion-body">
+        <table class="no-border form-layout-compressed" id="searchOptions">
+          <tr>
+            <td class="crm-case-caseview-form-block-repoter_id"colspan="2"><label for="reporter_id">{ts}Reporter/Role{/ts}</label><br />
+              {$form.reporter_id.html|crmAddClass:twenty}
+            </td>
+            <td class="crm-case-caseview-form-block-status_id"><label for="status_id">{$form.status_id.label}</label><br />
+              {$form.status_id.html}
+            </td>
+            <td style="vertical-align: bottom;">
+              <span class="crm-button"><input class="form-submit default" name="_qf_Basic_refresh" value="Search" type="button" onclick="buildCaseActivities( true )"; /></span>
+            </td>
+          </tr>
+          <tr>
+            <td class="crm-case-caseview-form-block-activity_date_low">
+              {$form.activity_date_low.label}<br />
+            {include file="CRM/common/jcalendar.tpl" elementName=activity_date_low}
+            </td>
+            <td class="crm-case-caseview-form-block-activity_date_high">
+              {$form.activity_date_high.label}<br />
+            {include file="CRM/common/jcalendar.tpl" elementName=activity_date_high}
+            </td>
+            <td class="crm-case-caseview-form-block-activity_type_filter_id">
+              {$form.activity_type_filter_id.label}<br />
+              {$form.activity_type_filter_id.html}
+            </td>
+          </tr>
+          {if $form.activity_deleted}
+            <tr class="crm-case-caseview-form-block-activity_deleted">
+              <td>
+                {$form.activity_deleted.html}{$form.activity_deleted.label}
+              </td>
+            </tr>
+          {/if}
+        </table>
+      </div><!-- /.crm-accordion-body -->
+    </div><!-- /.crm-accordion-wrapper -->
+
+    <table id="activities-selector"  class="nestedActivitySelector">
+      <thead><tr>
+        <th class='crm-case-activities-date'>{ts}Date{/ts}</th>
+        <th class='crm-case-activities-subject'>{ts}Subject{/ts}</th>
+        <th class='crm-case-activities-type'>{ts}Type{/ts}</th>
+        <th class='crm-case-activities-with'>{ts}With{/ts}</th>
+        <th class='crm-case-activities-assignee'>{ts}Reporter / Assignee{/ts}</th>
+        <th class='crm-case-activities-status'>{ts}Status{/ts}</th>
+        <th class='crm-case-activities-status' id="nosort">&nbsp;</th>
+        <th class='hiddenElement'>&nbsp;</th>
+      </tr></thead>
+    </table>
+
+  </div><!-- /.crm-accordion-body -->
+</div><!-- /.crm-accordion-wrapper -->
+
+{literal}
+<script type="text/javascript">
+cj(function( ) {
+  buildCaseActivities(false);
+});
+
+function buildCaseActivities(filterSearch) {
+  if (filterSearch) {
+    oTable.fnDestroy();
+  }
+  var count   = 0;
+  var columns = '';
+  var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}{$caseID}"{literal};
+  sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
+  sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
+
+  cj('#activities-selector th').each(function( ) {
+    if (cj(this).attr('id') != 'nosort') {
+      columns += '{"sClass": "' + cj(this).attr('class') +'"},';
+    }
+    else {
+      columns += '{ "bSortable": false },';
+    }
+    count++;
+  });
+
+  columns    = columns.substring(0, columns.length - 1 );
+  eval('columns =[' + columns + ']');
+
+  oTable = cj('#activities-selector').dataTable({
+    "bFilter"    : false,
+    "bAutoWidth" : false,
+    "aaSorting"  : [],
+    "aoColumns"  : columns,
+    "bProcessing": true,
+    "bJQueryUI": true,
+    "asStripClasses" : [ "odd-row", "even-row" ],
+    "sPaginationType": "full_numbers",
+    "sDom"       : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
+    "bServerSide": true,
+    "sAjaxSource": sourceUrl,
+    "iDisplayLength": 10,
+    "fnDrawCallback": function() { setSelectorClass(); },
+    "fnServerData": function ( sSource, aoData, fnCallback ) {
+
+      if ( filterSearch ) {
+        var activity_deleted = 0;
+        if ( cj("#activity_deleted:checked").val() == 1 ) {
+          activity_deleted = 1;
+        }
+        aoData.push(
+          {name:'status_id', value: cj("select#status_id").val()},
+          {name:'activity_type_id', value: cj("select#activity_type_filter_id").val()},
+          {name:'activity_date_low', value: cj("#activity_date_low").val()},
+          {name:'activity_date_high', value: cj("#activity_date_high").val() },
+          {name:'activity_deleted', value: activity_deleted }
+        );
+      }
+      cj.ajax( {
+        "dataType": 'json',
+        "type": "POST",
+        "url": sSource,
+        "data": aoData,
+        "success": fnCallback
+      } );
+    }
+  });
+}
+
+function setSelectorClass( ) {
+  cj("#activities-selector td:last-child").each( function( ) {
+    cj(this).parent().addClass(cj(this).text() );
+  });
+}
+</script>
+{/literal}
\ No newline at end of file
index 50991b2a4c5a380524e3b43e07f570ce7fe7518f..557146eaa11779b8ec8a1c5f31ad1d3aa9f6b9ba 100644 (file)
 
 {/if} {* end of tag block*}
 
-<div class="crm-accordion-wrapper crm-case_activities-accordion  crm-case-activities-block">
-  <div class="crm-accordion-header">
-    {ts}Activities{/ts}
-  </div>
-  <div id="activities" class="crm-accordion-body">
-    <div class="crm-accordion-wrapper crm-accordion-inner crm-search_filters-accordion collapsed">
-      <div class="crm-accordion-header">
-        {ts}Search Filters{/ts}</a>
-      </div><!-- /.crm-accordion-header -->
-      <div class="crm-accordion-body">
-        <table class="no-border form-layout-compressed" id="searchOptions">
-          <tr>
-            <td class="crm-case-caseview-form-block-repoter_id"colspan="2"><label for="reporter_id">{ts}Reporter/Role{/ts}</label><br />
-              {$form.reporter_id.html|crmAddClass:twenty}
-            </td>
-            <td class="crm-case-caseview-form-block-status_id"><label for="status_id">{$form.status_id.label}</label><br />
-              {$form.status_id.html}
-            </td>
-            <td style="vertical-align: bottom;">
-              <span class="crm-button"><input class="form-submit default" name="_qf_Basic_refresh" value="Search" type="button" onclick="buildCaseActivities( true )"; /></span>
-            </td>
-          </tr>
-          <tr>
-            <td class="crm-case-caseview-form-block-activity_date_low">
-              {$form.activity_date_low.label}<br />
-            {include file="CRM/common/jcalendar.tpl" elementName=activity_date_low}
-            </td>
-            <td class="crm-case-caseview-form-block-activity_date_high">
-              {$form.activity_date_high.label}<br />
-            {include file="CRM/common/jcalendar.tpl" elementName=activity_date_high}
-            </td>
-            <td class="crm-case-caseview-form-block-activity_type_filter_id">
-              {$form.activity_type_filter_id.label}<br />
-              {$form.activity_type_filter_id.html}
-            </td>
-          </tr>
-          {if $form.activity_deleted}
-            <tr class="crm-case-caseview-form-block-activity_deleted">
-              <td>
-                {$form.activity_deleted.html}{$form.activity_deleted.label}
-              </td>
-            </tr>
-          {/if}
-        </table>
-      </div><!-- /.crm-accordion-body -->
-    </div><!-- /.crm-accordion-wrapper -->
-
-    <table id="activities-selector"  class="nestedActivitySelector">
-      <thead><tr>
-        <th class='crm-case-activities-date'>{ts}Date{/ts}</th>
-        <th class='crm-case-activities-subject'>{ts}Subject{/ts}</th>
-        <th class='crm-case-activities-type'>{ts}Type{/ts}</th>
-        <th class='crm-case-activities-with'>{ts}With{/ts}</th>
-        <th class='crm-case-activities-assignee'>{ts}Reporter / Assignee{/ts}</th>
-        <th class='crm-case-activities-status'>{ts}Status{/ts}</th>
-        <th class='crm-case-activities-status' id="nosort">&nbsp;</th>
-        <th class='hiddenElement'>&nbsp;</th>
-      </tr></thead>
-    </table>
-
-  </div><!-- /.crm-accordion-body -->
-</div><!-- /.crm-accordion-wrapper -->
-
-{literal}
-<script type="text/javascript">
-var oTable;
-
-cj(function( ) {
-  buildCaseActivities(false);
-});
-
-function buildCaseActivities(filterSearch) {
-  if (filterSearch) {
-    oTable.fnDestroy();
-  }
-  var count   = 0;
-  var columns = '';
-  var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}{$caseID}"{literal};
-  sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
-  sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
-
-  cj('#activities-selector th').each(function( ) {
-    if (cj(this).attr('id') != 'nosort') {
-      columns += '{"sClass": "' + cj(this).attr('class') +'"},';
-    }
-    else {
-      columns += '{ "bSortable": false },';
-    }
-    count++;
-  });
-
-  columns    = columns.substring(0, columns.length - 1 );
-  eval('columns =[' + columns + ']');
-
-  oTable = cj('#activities-selector').dataTable({
-    "bFilter"    : false,
-    "bAutoWidth" : false,
-    "aaSorting"  : [],
-    "aoColumns"  : columns,
-    "bProcessing": true,
-    "bJQueryUI": true,
-    "asStripClasses" : [ "odd-row", "even-row" ],
-    "sPaginationType": "full_numbers",
-    "sDom"       : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
-    "bServerSide": true,
-    "sAjaxSource": sourceUrl,
-    "iDisplayLength": 10,
-    "fnDrawCallback": function() { setSelectorClass(); },
-    "fnServerData": function ( sSource, aoData, fnCallback ) {
-
-      if ( filterSearch ) {
-        var activity_deleted = 0;
-        if ( cj("#activity_deleted:checked").val() == 1 ) {
-          activity_deleted = 1;
-        }
-        aoData.push(
-          {name:'status_id', value: cj("select#status_id").val()},
-          {name:'activity_type_id', value: cj("select#activity_type_filter_id").val()},
-          {name:'activity_date_low', value: cj("#activity_date_low").val()},
-          {name:'activity_date_high', value: cj("#activity_date_high").val() },
-          {name:'activity_deleted', value: activity_deleted }
-        );
-      }
-      cj.ajax( {
-        "dataType": 'json',
-        "type": "POST",
-        "url": sSource,
-        "data": aoData,
-        "success": fnCallback
-      } );
-    }
-  });
-}
-
-function setSelectorClass( ) {
-  cj("#activities-selector td:last-child").each( function( ) {
-    cj(this).parent().addClass(cj(this).text() );
-  });
-}
-
-</script>
-{/literal}
+{include file="CRM/Case/Form/ActivityTab.tpl"}
 
 <div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl" location="bottom"}</div>