summaryrefslogtreecommitdiff
path: root/www/crm/wp-content/uploads/civicrm/templates_c/es_ES/%%24/24E/24E27851%%jsortable.tpl.php
blob: 773c30fc3f3fd993648aaf2f976ee2fc9e6a5ba0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<?php /* Smarty version 2.6.31, created on 2019-08-30 19:48:24
         compiled from CRM/common/jsortable.tpl */ ?>
<?php require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins(array('plugins' => array(array('block', 'crmScope', 'CRM/common/jsortable.tpl', 1, false),array('block', 'ts', 'CRM/common/jsortable.tpl', 116, false),)), $this); ?>
<?php $this->_tag_stack[] = array('crmScope', array('extensionKey' => "")); $_block_repeat=true;smarty_block_crmScope($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?><?php echo '
<script type="text/javascript">
  CRM.$(function($) {

    function getElementClass(element) {
      return $(element).attr(\'class\') || \'\';
    }

    // fetch the occurrence of element
    function getRowId(row, str) {
      var optionId;
      $.each(row, function(i, n) {
        if (str === $(n).attr(\'class\')) {
          optionId = i;
        }
      });
      return optionId;
    }

    // for date sorting see http://wiki.civicrm.org/confluence/display/CRMDOC/Sorting+Date+Fields+in+dataTables+Widget
    var useAjax = '; ?>
<?php if ($this->_tpl_vars['useAjax']): ?>1<?php else: ?>0<?php endif; ?><?php echo ',
      sourceUrl = \'\',
      useClass  = \'display\',
      tcount = 1,
      tableId = [];

    if ( useAjax ) {
      '; ?>
<?php if (isset ( $this->_tpl_vars['sourceUrl'] )): ?>sourceUrl = "<?php echo $this->_tpl_vars['sourceUrl']; ?>
";<?php endif; ?><?php echo '
      useClass = \'pagerDisplay\';
      tcount = 5;
    }

    CRM.dataTableCount = CRM.dataTableCount || 1;

    // FIXME: Rewriting DOM ids is probably a bad idea, and could be avoided
    $(\'table.\' + useClass).not(\'.dataTable\').each(function() {
      $(this).attr(\'id\',\'option\' + tcount + CRM.dataTableCount);
      tableId.push(CRM.dataTableCount);
      CRM.dataTableCount++;
    });

    $.each(tableId, function(i,n){
      var tabId = \'#option\' + tcount + n;
      //get the object of first tr data row.
      var tdObject = $(tabId + \' tr:nth(1) td\');
      var id = -1; var count = 0; var columns=\'\'; var sortColumn = \'\';
      //build columns array for sorting or not sorting
      $(tabId + \' th\').each( function( ) {
        var option = $(this).prop(\'id\').split("_");
        option  = ( option.length > 1 ) ? option[1] : option[0];
        var stype   = \'numeric\';
        switch( option ) {
          case \'sortable\':
            sortColumn += \'[\' + count + \', "asc" ],\';
            columns += \'{"sClass": "\'+ getElementClass( this ) +\'"},\';
            break;
          case \'date\':
            stype = \'date\';
          case \'order\':
            if ( $(this).attr(\'class\') == \'sortable\' ){
              sortColumn += \'[\' + count + \', "asc" ],\';
            }
            var sortId   = getRowId(tdObject, $(this).attr(\'id\') +\' hiddenElement\' );
            columns += \'{ "render": function ( data, type, row ) { return "<div style=\\\'display:none\\\'>"+ data +"</div>" + row[sortId] ; }, "targets": sortColumn,"bUseRendered": false},\';
            break;
          case \'nosort\':
            columns += \'{ "bSortable": false, "sClass": "\'+ getElementClass( this ) +\'"},\';
            break;
          case \'currency\':
            columns += \'{ "sType": "currency" },\';
            break;
          case \'link\':
            columns += \'{"sType": "html"},\';
            break;
          default:
            if ( $(this).text() ) {
              columns += \'{"sClass": "\'+ getElementClass( this ) +\'"},\';
            } else {
              columns += \'{ "bSortable": false },\';
            }
            break;
        }
        count++;
      });
      // Fixme: this could be done without eval
      columns    = columns.substring(0, columns.length - 1 );
      sortColumn = sortColumn.substring(0, sortColumn.length - 1 );
      eval(\'sortColumn =[\' + sortColumn + \']\');
      eval(\'columns =[\' + columns + \']\');

      var noRecordFoundMsg  = '; ?>
'<?php $this->_tag_stack[] = array('ts', array('escape' => 'js')); $_block_repeat=true;smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], null, $this, $_block_repeat);while ($_block_repeat) { ob_start(); ?>None found.<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_ts($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); }  array_pop($this->_tag_stack); ?>'<?php echo ';

      var oTable;
      if ( useAjax ) {
        oTable = $(tabId).dataTable({
          "iDisplayLength": 25,
          "bFilter": false,
          "bAutoWidth": false,
          "aaSorting": sortColumn,
          "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,
          "oLanguage":{
            "sEmptyTable": noRecordFoundMsg,
            "sZeroRecords": noRecordFoundMsg
          },
          "fnServerData": function ( sSource, aoData, fnCallback ) {
            $.ajax( {
              "dataType": \'json\',
              "type": "POST",
              "url": sSource,
              "data": aoData,
              "success": fnCallback
            });
          }
        });
      } else {
        oTable = $(tabId).dataTable({
          "aaSorting": sortColumn,
          "bPaginate": false,
          "bLengthChange": true,
          "bFilter": false,
          "bInfo": false,
          "asStripClasses": [ "odd-row", "even-row" ],
          "bAutoWidth": false,
          "aoColumns": columns,
          "bSort": true,
          "sDom": \'ti\',
          "oLanguage":{
            "sEmptyTable": noRecordFoundMsg,
            "sZeroRecords": noRecordFoundMsg
          }
        });
      }
    });
  });

  //plugin to sort on currency
  cj.fn.dataTableExt.oSort[\'currency-asc\']  = function(a,b) {
    var symbol = "'; ?>
<?php echo $this->_tpl_vars['defaultCurrencySymbol']; ?>
<?php echo '";
    var x = (a == "-") ? 0 : a.replace( symbol, "" );
    var y = (b == "-") ? 0 : b.replace( symbol, "" );
    x = parseFloat( x );
    y = parseFloat( y );
    return ((x < y) ? -1 : ((x > y) ?  1 : 0));
  };

  cj.fn.dataTableExt.oSort[\'currency-desc\'] = function(a,b) {
    var symbol = "'; ?>
<?php echo $this->_tpl_vars['defaultCurrencySymbol']; ?>
<?php echo '";
    var x = (a == "-") ? 0 : a.replace( symbol, "" );
    var y = (b == "-") ? 0 : b.replace( symbol, "" );
    x = parseFloat( x );
    y = parseFloat( y );
    return ((x < y) ?  1 : ((x > y) ? -1 : 0));
  };
</script>
'; ?>

<?php $_block_content = ob_get_contents(); ob_end_clean(); $_block_repeat=false;echo smarty_block_crmScope($this->_tag_stack[count($this->_tag_stack)-1][1], $_block_content, $this, $_block_repeat); }  array_pop($this->_tag_stack); ?>