Merge branch 4.5 into 4.6
[civicrm-core.git] / templates / CRM / Case / Form / ActivityTab.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.6 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2015 |
6 +--------------------------------------------------------------------+
7 | This file is a part of CiviCRM. |
8 | |
9 | CiviCRM is free software; you can copy, modify, and distribute it |
10 | under the terms of the GNU Affero General Public License |
11 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
12 | |
13 | CiviCRM is distributed in the hope that it will be useful, but |
14 | WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
16 | See the GNU Affero General Public License for more details. |
17 | |
18 | You should have received a copy of the GNU Affero General Public |
19 | License and the CiviCRM Licensing Exception along |
20 | with this program; if not, contact CiviCRM LLC |
21 | at info[AT]civicrm[DOT]org. If you have questions about the |
22 | GNU Affero General Public License or the licensing of CiviCRM, |
23 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
24 +--------------------------------------------------------------------+
25 *}
26 {*this template is used for activity accordion*}
27 <div class="crm-accordion-wrapper crm-case_activities-accordion crm-case-activities-block">
28 <div class="crm-accordion-header">
29 {ts}Activities{/ts}
30 </div>
31 <div id="activities" class="crm-accordion-body">
32 <div class="crm-accordion-wrapper crm-accordion-inner crm-search_filters-accordion collapsed">
33 <div class="crm-accordion-header">
34 {ts}Search Filters{/ts}
35 </div><!-- /.crm-accordion-header -->
36 <div class="crm-accordion-body">
37 <table class="no-border form-layout-compressed" id="searchOptions">
38 <tr>
39 <td class="crm-case-caseview-form-block-repoter_id"colspan="2"><label for="reporter_id">{ts}Reporter/Role{/ts}</label><br />
40 {$form.reporter_id.html|crmAddClass:twenty}
41 </td>
42 <td class="crm-case-caseview-form-block-status_id"><label for="status_id">{$form.status_id.label}</label><br />
43 {$form.status_id.html}
44 </td>
45 <td style="vertical-align: bottom;">
46 {assign var=caseid value=$caseID}
47 <span class="crm-button crm-icon-button">
48 <span class="crm-button-icon ui-icon-check"></span>
49 <input class="crm-form-submit default" name="_qf_Basic_refresh" value="{ts}Search{/ts}" type="button" data-case-id="{$caseid}" />
50 </span>
51 </td>
52 </tr>
53 <tr>
54 <td class="crm-case-caseview-form-block-activity_date_low">
55 {assign var=activitylow value=activity_date_low_$caseID}
56 {$form.$activitylow.label}<br />
57 {include file="CRM/common/jcalendar.tpl" elementName=$activitylow}
58 </td>
59 <td class="crm-case-caseview-form-block-activity_date_high">
60 {assign var=activityhigh value=activity_date_high_$caseID}
61 {$form.$activityhigh.label}<br />
62 {include file="CRM/common/jcalendar.tpl" elementName=$activityhigh}
63 </td>
64 <td class="crm-case-caseview-form-block-activity_type_filter_id">
65 {$form.activity_type_filter_id.label}<br />
66 {$form.activity_type_filter_id.html}
67 </td>
68 </tr>
69 {if $form.activity_deleted}
70 <tr class="crm-case-caseview-form-block-activity_deleted">
71 <td>
72 {$form.activity_deleted.html}{$form.activity_deleted.label}
73 </td>
74 </tr>
75 {/if}
76 </table>
77 </div><!-- /.crm-accordion-body -->
78 </div><!-- /.crm-accordion-wrapper -->
79
80 <table id=case_id_{$caseid} class="nestedActivitySelector">
81 <thead><tr>
82 <th class='crm-case-activities-date'>{ts}Date{/ts}</th>
83 <th class='crm-case-activities-subject'>{ts}Subject{/ts}</th>
84 <th class='crm-case-activities-type'>{ts}Type{/ts}</th>
85 <th class='crm-case-activities-with'>{ts}With{/ts}</th>
86 <th class='crm-case-activities-assignee'>{ts}Reporter / Assignee{/ts}</th>
87 <th class='crm-case-activities-status'>{ts}Status{/ts}</th>
88 <th class='crm-case-activities-status' id="nosort">&nbsp;</th>
89 <th class='hiddenElement'>&nbsp;</th>
90 </tr></thead>
91 </table>
92
93 </div><!-- /.crm-accordion-body -->
94 </div><!-- /.crm-accordion-wrapper -->
95
96 {literal}
97 <script type="text/javascript">
98 CRM.$(function($) {
99 var CaseId = {/literal}{$caseID}{literal};
100 buildCaseActivities(false);
101 $('input.crm-form-submit[data-case-id=' + CaseId + ']').click(buildCaseActivities);
102
103 function buildCaseActivities(filterSearch) {
104 if (filterSearch) {
105 oTable.fnDestroy();
106 }
107 var count = 0;
108 var columns = '';
109 var sourceUrl = {/literal}"{crmURL p='civicrm/ajax/activity' h=0 q='snippet=4&caseID='}"{literal}+CaseId;
110 sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
111 sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
112
113 $('#case_id_'+CaseId+' th').each(function( ) {
114 if ($(this).attr('id') != 'nosort') {
115 columns += '{"sClass": "' + $(this).attr('class') +'"},';
116 }
117 else {
118 columns += '{ "bSortable": false },';
119 }
120 count++;
121 });
122
123 columns = columns.substring(0, columns.length - 1 );
124 eval('columns =[' + columns + ']');
125
126 oTable = $('#case_id_'+CaseId).dataTable({
127 "bFilter" : false,
128 "bAutoWidth" : false,
129 "aaSorting" : [],
130 "aoColumns" : columns,
131 "bProcessing": true,
132 "bJQueryUI": true,
133 "asStripClasses" : [ "odd-row", "even-row" ],
134 "sPaginationType": "full_numbers",
135 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
136 "bServerSide": true,
137 "sAjaxSource": sourceUrl,
138 "iDisplayLength": 10,
139 "bDestroy": true,
140 "fnDrawCallback": function() {
141 setSelectorClass();
142 setRowIds();
143 // FIXME: trigger crmLoad and crmEditable would happen automatically
144 $('.crm-editable', '#case_id_'+CaseId).crmEditable();
145 },
146 "fnServerData": function ( sSource, aoData, fnCallback ) {
147
148 if ( filterSearch ) {
149 var activity_deleted = 0;
150 if ( $("#activity_deleted_"+CaseId+":checked").val() == 1 ) {
151 activity_deleted = 1;
152 }
153 aoData.push(
154 {name:'status_id', value: $("select#status_id_"+CaseId).val()},
155 {name:'reporter_id', value: $("select#reporter_id_"+CaseId).val()},
156 {name:'activity_type_id', value: $("select#activity_type_filter_id_"+CaseId).val()},
157 {name:'activity_date_low', value: $("#activity_date_low_"+CaseId).val()},
158 {name:'activity_date_high', value: $("#activity_date_high_"+CaseId).val() },
159 {name:'activity_deleted', value: activity_deleted }
160 );
161 }
162 $.ajax( {
163 "dataType": 'json',
164 "type": "POST",
165 "url": sSource,
166 "data": aoData,
167 "success": fnCallback
168 } );
169 }
170 });
171 }
172
173 function setRowIds() {
174 $("#case_id_"+CaseId+" tbody tr").each(function() {
175 var link, id;
176 link = $('a.action-item', this).attr('href');
177 if (link) {
178 id = link.match(/&id=(\d+)/);
179 }
180 if (id) {
181 $(this)
182 .addClass('crm-entity')
183 .data('entity', 'activity')
184 .data('id', id[1]);
185 }
186 });
187 }
188
189 function setSelectorClass() {
190 $("#case_id_"+CaseId+" td:last-child").each(function() {
191 $(this).parent().addClass($(this).text());
192 });
193 }
194 });
195 </script>
196 {/literal}