Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | {* |
2 | +--------------------------------------------------------------------+ | |
819d0d41 | 3 | | CiviCRM version 4.5 | |
6a488035 | 4 | +--------------------------------------------------------------------+ |
819d0d41 | 5 | | Copyright CiviCRM LLC (c) 2004-2014 | |
6a488035 TO |
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 --> | |
24e7a504 | 43 | <table class="contact-activity-selector-{$context}"> |
6a488035 TO |
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> | |
6a488035 TO |
53 | <th class='crm-contact-activity-links nosort'> </th> |
54 | <th class='hiddenElement'> </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"> | |
2c68626a DJ |
62 | var {/literal}{$context}{literal}oTable; |
63 | CRM.$(function($) { | |
64 | var context = {/literal}"{$context}"{literal}; | |
65 | var filterSearchOnLoad = false; | |
66 | if (context == 'activity') { | |
67 | filterSearchOnLoad = true; | |
68 | } | |
69 | buildContactActivities{/literal}{$context}{literal}( filterSearchOnLoad ); | |
6a488035 | 70 | |
2c68626a DJ |
71 | $('.crm-activity-selector-'+ context +' #activity_type_filter_id').change( function( ) { |
72 | buildContactActivities{/literal}{$context}{literal}( true ); | |
6a488035 TO |
73 | }); |
74 | ||
2c68626a DJ |
75 | $('.crm-activity-selector-'+ context +' #activity_type_exclude_filter_id').change( function( ) { |
76 | buildContactActivities{/literal}{$context}{literal}( true ); | |
77 | }); | |
6a488035 | 78 | |
2c68626a DJ |
79 | function buildContactActivities{/literal}{$context}{literal}( filterSearch ) { |
80 | if ( filterSearch && {/literal}{$context}{literal}oTable ) { | |
81 | {/literal}{$context}{literal}oTable.fnDestroy(); | |
82 | } | |
6a488035 | 83 | |
2c68626a DJ |
84 | var context = {/literal}"{$context}"{literal}; |
85 | var columns = ''; | |
86 | var sourceUrl = {/literal}'{crmURL p="civicrm/ajax/contactactivity" h=0 q="snippet=4&context=$context&cid=$contactId"}'{literal}; | |
6a488035 | 87 | |
2c68626a DJ |
88 | var ZeroRecordText = {/literal}'{ts escape="js"}No matches found{/ts}'{literal}; |
89 | if ( $('.crm-activity-selector-'+ context +' select#activity_type_filter_id').val( ) ) { | |
90 | ZeroRecordText += {/literal}'{ts escape="js"} for Activity Type = "{/ts}'{literal} + $('.crm-activity-selector-'+ context +' select#activity_type_filter_id :selected').text( ) + '"'; | |
91 | } | |
92 | else { | |
93 | ZeroRecordText += '.'; | |
94 | } | |
6a488035 | 95 | |
2c68626a DJ |
96 | {/literal}{$context}{literal}oTable = $('.contact-activity-selector-' + context ).dataTable({ |
97 | "bFilter" : false, | |
98 | "bAutoWidth" : false, | |
99 | "aaSorting" : [], | |
100 | "aoColumns" : [ | |
101 | {sClass:'crm-contact-activity-activity_type'}, | |
102 | {sClass:'crm-contact-activity_subject'}, | |
103 | {sClass:'crm-contact-activity-source_contact'}, | |
104 | {sClass:'crm-contact-activity-target_contact', bSortable:false}, | |
105 | {sClass:'crm-contact-activity-assignee_contact', bSortable:false}, | |
106 | {sClass:'crm-contact-activity-activity_date'}, | |
107 | {sClass:'crm-contact-activity-activity_status'}, | |
108 | {sClass:'crm-contact-activity-links', bSortable:false}, | |
109 | {sClass:'hiddenElement', bSortable:false} | |
110 | ], | |
111 | "bProcessing": true, | |
112 | "sPaginationType": "full_numbers", | |
113 | "sDom" : '<"crm-datatable-pager-top"lfp>rt<"crm-datatable-pager-bottom"ip>', | |
114 | "bServerSide": true, | |
115 | "bJQueryUI": true, | |
116 | "sAjaxSource": sourceUrl, | |
117 | "iDisplayLength": 25, | |
118 | "oLanguage": { | |
119 | "sZeroRecords": ZeroRecordText, | |
120 | "sProcessing": {/literal}"{ts escape='js'}Processing...{/ts}"{literal}, | |
121 | "sLengthMenu": {/literal}"{ts escape='js'}Show _MENU_ entries{/ts}"{literal}, | |
122 | "sInfo": {/literal}"{ts escape='js'}Showing _START_ to _END_ of _TOTAL_ entries{/ts}"{literal}, | |
123 | "sInfoEmpty": {/literal}"{ts escape='js'}Showing 0 to 0 of 0 entries{/ts}"{literal}, | |
124 | "sInfoFiltered": {/literal}"{ts escape='js'}(filtered from _MAX_ total entries){/ts}"{literal}, | |
125 | "sSearch": {/literal}"{ts escape='js'}Search:{/ts}"{literal}, | |
126 | "oPaginate": { | |
127 | "sFirst": {/literal}"{ts escape='js'}First{/ts}"{literal}, | |
128 | "sPrevious": {/literal}"{ts escape='js'}Previous{/ts}"{literal}, | |
129 | "sNext": {/literal}"{ts escape='js'}Next{/ts}"{literal}, | |
130 | "sLast": {/literal}"{ts escape='js'}Last{/ts}"{literal} | |
131 | } | |
132 | }, | |
133 | "fnDrawCallback": function() { setSelectorClass{/literal}{$context}{literal}( context ); }, | |
134 | "fnServerData": function ( sSource, aoData, fnCallback ) { | |
135 | aoData.push( {name:'contact_id', value: {/literal}{$contactId}{literal}}, | |
136 | {name:'admin', value: {/literal}'{$admin}'{literal}} | |
6a488035 | 137 | ); |
2c68626a DJ |
138 | |
139 | if ( filterSearch ) { | |
140 | aoData.push( | |
141 | {name:'activity_type_id', value: $('.crm-activity-selector-'+ context +' select#activity_type_filter_id').val()}, | |
142 | {name:'activity_type_exclude_id', value: $('.crm-activity-selector-'+ context +' select#activity_type_exclude_filter_id').val()} | |
143 | ); | |
144 | } | |
145 | $.ajax( { | |
146 | "dataType": 'json', | |
147 | "type": "POST", | |
148 | "url": sSource, | |
149 | "data": aoData, | |
150 | "success": fnCallback, | |
151 | // CRM-10244 | |
152 | "dataFilter": function(data, type) { return data.replace(/[\n\v\t]/g, " "); } | |
153 | }); | |
6a488035 | 154 | } |
2c68626a DJ |
155 | }); |
156 | } | |
6a488035 | 157 | |
2c68626a DJ |
158 | function setSelectorClass{/literal}{$context}{literal}( context ) { |
159 | $('.contact-activity-selector-' + context + ' td:last-child').each( function( ) { | |
160 | $(this).parent().addClass($(this).text() ); | |
161 | }); | |
162 | } | |
163 | }); | |
6a488035 TO |
164 | </script> |
165 | {/literal} |