-
-{literal}
-<script type="text/javascript">
-CRM.$(function($) {
- var CaseId = {/literal}{$caseID}{literal};
- buildCaseActivities(false);
- $('input.crm-form-submit[data-case-id=' + CaseId + ']').click(buildCaseActivities);
-
- 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='}"{literal}+CaseId;
- sourceUrl = sourceUrl + '&cid={/literal}{$contactID}{literal}';
- sourceUrl = sourceUrl + '&userID={/literal}{$userID}{literal}';
-
- $('#case_id_'+CaseId+' th').each(function( ) {
- if ($(this).attr('id') != 'nosort') {
- columns += '{"sClass": "' + $(this).attr('class') +'"},';
- }
- else {
- columns += '{ "bSortable": false },';
- }
- count++;
- });
-
- columns = columns.substring(0, columns.length - 1 );
- eval('columns =[' + columns + ']');
-
- oTable = $('#case_id_'+CaseId).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,
- "bDestroy": true,
- "fnDrawCallback": function() {
- setSelectorClass();
- setRowIds();
- // FIXME: trigger crmLoad and crmEditable would happen automatically
- $('.crm-editable', '#case_id_'+CaseId).crmEditable();
- },
- "fnServerData": function ( sSource, aoData, fnCallback ) {
-
- if ( filterSearch ) {
- var activity_deleted = 0;
- if ( $("#activity_deleted_"+CaseId+":checked").val() == 1 ) {
- activity_deleted = 1;
- }
- aoData.push(
- {name:'status_id', value: $("select#status_id_"+CaseId).val()},
- {name:'reporter_id', value: $("select#reporter_id_"+CaseId).val()},
- {name:'activity_type_id', value: $("select#activity_type_filter_id_"+CaseId).val()},
- {name:'activity_date_low', value: $("#activity_date_low_"+CaseId).val()},
- {name:'activity_date_high', value: $("#activity_date_high_"+CaseId).val() },
- {name:'activity_deleted', value: activity_deleted }
- );
- }
- $.ajax( {
- "dataType": 'json',
- "type": "POST",
- "url": sSource,
- "data": aoData,
- "success": fnCallback
- } );
- }
- });
- }
-
- function setRowIds() {
- $("#case_id_"+CaseId+" tbody tr").each(function() {
- var link, id;
- link = $('a.action-item', this).attr('href');
- if (link) {
- id = link.match(/&id=(\d+)/);
- }
- if (id) {
- $(this)
- .addClass('crm-entity')
- .data('entity', 'activity')
- .data('id', id[1]);
- }
- });
- }
-
- function setSelectorClass() {
- $("#case_id_"+CaseId+" td:last-child").each(function() {
- $(this).parent().addClass($(this).text());
- });
- }
-});
-</script>
-{/literal}