if (count($var['report_params']['filter'][0]) == 0) {
            $lnk_arr['mode'] = 'popular';
            $lnk_arr['group_by'] = '';
        }
        $name = '<a href="' . report_lnk($var['report_params'], $lnk_arr) . '">' . _e($name) . '</a>';
    } else {
        $name = _e($name);
    }
    echo '<tr><td nowrap="" class="report-header">' . $name . '</td><td>' . $r['cnt'] . '</td><td class="col_s">' . $r['sale'] . '</td><td class="col_l">' . $r['lead'] . '</td><td class="col_a">' . $r['act'] . '</td><td class="col_s">' . t_conversion($r) . '</td><td class="col_l">' . t_conversion_l($r) . '</td><td class="col_a">' . t_conversion_a($r) . '</td><td>' . t_price($r) . '</td><td class="col_s col_a ' . pos_class($r['income'] - $r['price']) . '">' . t_profit($r) . '</td><td class="col_s">' . t_epc($r) . '</td><td class="col_s col_a">' . t_roi($r) . '</td><td class="col_l">' . t_cpl($r) . '</td></tr>';
}
?>
        </tbody>
        <tfoot>
            <tr><td>Итого</td><?php 
$r = $column_total_data;
echo '<td>' . $r['cnt'] . '</td><td class="col_s">' . $r['sale'] . '</td><td class="col_l">' . $r['lead'] . '</td><td class="col_a">' . $r['act'] . '</td><td class="col_s">' . t_conversion($r) . '</td><td class="col_l">' . t_conversion_l($r) . '</td><td class="col_a">' . t_conversion_a($r) . '</td><td>' . t_price($r) . '</td><td class="col_s col_a">' . t_profit($r) . '</td><td class="col_s">' . t_epc($r) . '</td><td class="col_s col_a">' . t_roi($r) . '</td><td class="col_l">' . t_cpl($r) . '</td>';
?>
</tr>
        </tfoot>
    </table>
</div>

<script>
    $(document).ready(function() {
        jQuery.fn.dataTableExt.oApi.fnSortNeutral = function ( oSettings ){
            oSettings.aaSorting = [[1, "desc", 0]];
            oSettings.aiDisplay.sort( function (x,y) {
                return x-y;
            } );
            oSettings.aiDisplayMaster.sort( function (x,y) {
                return x-y;
        if (empty($var['report_params']['filter'][0]) or count($var['report_params']['filter'][0]) < 5) {
            $r['popular'] = '<a href="' . report_lnk($var['report_params'], array('filter_str' => array_merge($var['report_params']['filter_str'], array($r['name'] => _e($r['popular']))))) . '" title="' . _e($r['popular']) . '">' . _e($popular_str) . '</a>';
        } else {
            $r['popular'] = _e($popular_str);
        }
        echo '<tr><td nowrap=""><b><a href="' . report_lnk($var['report_params'], array('mode' => '', 'group_by' => $r['name'])) . '">' . $name . '</a></b></td><td>' . $r['popular'] . '</td>';
    } else {
        echo '<tr><td nowrap=""><a href="' . report_lnk($var['report_params'], array('group_by' => '', 'filter_str' => array_merge($var['report_params']['filter_str'], array($var['report_params']['group_by'] => _e($k))))) . '">' . $k . '</a></td>';
    }
    echo '<td>' . $r['cnt'] . '</td><td>' . round3($r['cnt'] / $r['total'] * 100) . '%</td>';
    if ($var['report_params']['conv'] != 'none') {
        echo '<td class="col_s">' . $r['sale'] . '</td><td class="col_l">' . $r['lead'] . '</td><td class="col_a">' . $r['act'] . '</td><td class="col_s">' . t_conversion($r) . '</td><td class="col_l">' . t_conversion_l($r) . '</td><td class="col_a">' . t_conversion_a($r) . '</td>';
    }
    echo '<td>' . t_price($r) . '</td>';
    if ($var['report_params']['conv'] != 'none') {
        echo '<td class="col_s col_a">' . t_profit($r) . '</td><td>' . t_epc($r) . '</td><td class="col_s col_a">' . t_roi($r) . '</td><td class="col_s">' . t_cps($r) . '</td><td class="col_l">' . t_cpl($r) . '</td><td class="col_a">' . t_cpa($r) . '</td>';
    }
    echo '</tr>';
}
?>
        </tbody>
    </table>
</div>

<script>
    $(document).ready(function() {
        jQuery.fn.dataTableExt.oApi.fnSortNeutral = function ( oSettings ){
            oSettings.aaSorting = [[<?php 
if ($var['report_params']['group_by'] == '') {
    ?>
2<?php