Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-09-25-01-46-57
[civicrm-core.git] / templates / CRM / Activity / Selector / Selector.tpl
1 {*
2 +--------------------------------------------------------------------+
3 | CiviCRM version 4.4 |
4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC (c) 2004-2013 |
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
27 <div class="crm-activity-selector-{$context}">
28 <div class="crm-accordion-wrapper crm-search_filters-accordion">
29 <div class="crm-accordion-header">
30 {ts}Filter by Activity Type{/ts}</a>
31 </div><!-- /.crm-accordion-header -->
32 <div class="crm-accordion-body">
33 <div class="no-border form-layout-compressed" id="searchOptions">
34 <div class="crm-contact-form-block-activity_type_filter_id crm-inline-edit-field">
35 {$form.activity_type_filter_id.label} {$form.activity_type_filter_id.html|crmAddClass:big}
36 </div>
37 <div class="crm-contact-form-block-activity_type_exclude_filter_id crm-inline-edit-field">
38 {$form.activity_type_exclude_filter_id.label} {$form.activity_type_exclude_filter_id.html|crmAddClass:big}
39 </div>
40 </div>
41 </div><!-- /.crm-accordion-body -->
42 </div><!-- /.crm-accordion-wrapper -->
43 <table id="contact-activity-selector-{$context}">
44 <thead>
45 <tr>
46 <th class='crm-contact-activity-activity_type'>{ts}Type{/ts}</th>
47 <th class='crm-contact-activity_subject'>{ts}Subject{/ts}</th>
48 <th class='crm-contact-activity-source_contact'>{ts}Added By{/ts}</th>
49 <th class='crm-contact-activity-target_contact nosort'>{ts}With{/ts}</th>
50 <th class='crm-contact-activity-assignee_contact nosort'>{ts}Assigned{/ts}</th>
51 <th class='crm-contact-activity-activity_date'>{ts}Date{/ts}</th>
52 <th class='crm-contact-activity-activity_status'>{ts}Status{/ts}</th>
53 <th class='crm-contact-activity-links nosort'>&nbsp;</th>
54 <th class='hiddenElement'>&nbsp;</th>
55 </tr>
56 </thead>
57 </table>
58 </div>
59 {include file="CRM/Case/Form/ActivityToCase.tpl" contactID=$contactId}
60 {literal}
61 <script type="text/javascript">
62 var {/literal}{$context}{literal}oTable;
63
64 cj(function ( ) {
65 cj().crmAccordions();
66 var context = {/literal}"{$context}"{literal};
67 var filterSearchOnLoad = false;
68 if (context == 'activity') {
69 filterSearchOnLoad = true;
70 }
71 buildContactActivities{/literal}{$context}{literal}( filterSearchOnLoad );
72
73 cj('.crm-activity-selector-'+ context +' #activity_type_filter_id').change( function( ) {
74 buildContactActivities{/literal}{$context}{literal}( true );
75 });
76
77 cj('.crm-activity-selector-'+ context +' #activity_type_exclude_filter_id').change( function( ) {
78 buildContactActivities{/literal}{$context}{literal}( true );
79 });
80 });
81
82 function buildContactActivities{/literal}{$context}{literal}( filterSearch ) {
83 if ( filterSearch && {/literal}{$context}{literal}oTable ) {
84 {/literal}{$context}{literal}oTable.fnDestroy();
85 }
86
87 var context = {/literal}"{$context}"{literal};
88 var columns = '';
89 var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/contactactivity" h=0 q="snippet=4&context=$context&cid=$contactId"}'{literal};
90
91 var ZeroRecordText = {/literal}'{ts escape="js"}No matches found{/ts}'{literal};
92 if ( cj('.crm-activity-selector-'+ context +' select#activity_type_filter_id').val( ) ) {
93 ZeroRecordText += {/literal}'{ts escape="js"} for Activity Type = "{/ts}'{literal} + cj('.crm-activity-selector-'+ context +' select#activity_type_filter_id :selected').text( ) + '"';
94 }
95 else {
96 ZeroRecordText += '.';
97 }
98
99 {/literal}{$context}{literal}oTable = cj('#contact-activity-selector-' + context ).dataTable({
100 "bFilter" : false,
101 "bAutoWidth" : false,
102 "aaSorting" : [],
103 "aoColumns" : [
104 {sClass:'crm-contact-activity-activity_type'},
105 {sClass:'crm-contact-activity_subject'},
106 {sClass:'crm-contact-activity-source_contact'},
107 {sClass:'crm-contact-activity-target_contact', bSortable:false},
108 {sClass:'crm-contact-activity-assignee_contact', bSortable:false},
109 {sClass:'crm-contact-activity-activity_date'},
110 {sClass:'crm-contact-activity-activity_status'},
111 {sClass:'crm-contact-activity-links', bSortable:false},
112 {sClass:'hiddenElement', bSortable:false}
113 ],
114 "bProcessing": true,
115 "sPaginationType": "full_numbers",
116 "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>',
117 "bServerSide": true,
118 "bJQueryUI": true,
119 "sAjaxSource": sourceUrl,
120 "iDisplayLength": 25,
121 "oLanguage": {
122 "sZeroRecords": ZeroRecordText,
123 "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal},
124 "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal},
125 "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal},
126 "sInfoEmpty": {/literal}"{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}"{literal},
127 "sInfoFiltered": {/literal}"{ts escape='js'}(filtered from _MAX_ total entries){/ts}"{literal},
128 "sSearch": {/literal}"{ts escape='js'}Search:{/ts}"{literal},
129 "oPaginate": {
130 "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal},
131 "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal},
132 "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal},
133 "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal}
134 }
135 },
136 "fnDrawCallback": function() { setSelectorClass{/literal}{$context}{literal}( context ); },
137 "fnServerData": function ( sSource, aoData, fnCallback ) {
138 aoData.push( {name:'contact_id', value: {/literal}{$contactId}{literal}},
139 {name:'admin', value: {/literal}'{$admin}'{literal}}
140 );
141
142 if ( filterSearch ) {
143 aoData.push(
144 {name:'activity_type_id', value: cj('.crm-activity-selector-'+ context +' select#activity_type_filter_id').val()},
145 {name:'activity_type_exclude_id', value: cj('.crm-activity-selector-'+ context +' select#activity_type_exclude_filter_id').val()}
146 );
147 }
148 cj.ajax( {
149 "dataType": 'json',
150 "type": "POST",
151 "url": sSource,
152 "data": aoData,
153 "success": fnCallback,
154 // CRM-10244
155 "dataFilter": function(data, type) { return data.replace(/[\n\v\t]/g, " "); }
156 });
157 }
158 });
159 }
160
161 function setSelectorClass{/literal}{$context}{literal}( context ) {
162 cj('#contact-activity-selector-' + context + ' td:last-child').each( function( ) {
163 cj(this).parent().addClass(cj(this).text() );
164 });
165 }
166 </script>
167 {/literal}