function content_56853f85a58ff($_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_replace')) {
            include '/var/www/html/vtigercrm/libraries/Smarty/libs/plugins/modifier.replace.php';
        }
        ?>
<div class="contents-topscroll"><div class="topscroll-div container-fluid">&nbsp;</div></div><div id="reportDetails" class="contents-bottomscroll"><div class="bottomscroll-div"><input type="hidden" id="updatedCount" value="<?php 
        echo $_smarty_tpl->tpl_vars['NEW_COUNT']->value;
        ?>
" /><?php 
        if (!empty($_smarty_tpl->tpl_vars['CALCULATION_FIELDS']->value)) {
            ?>
<table class=" table-bordered table-condensed marginBottom10px" width="100%"><thead><tr class="blockHeader"><th><?php 
            echo vtranslate('LBL_FIELD_NAMES', $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</th><th><?php 
            echo vtranslate('LBL_SUM', $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</th><th><?php 
            echo vtranslate('LBL_AVG', $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</th><th><?php 
            echo vtranslate('LBL_MIN', $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</th><th><?php 
            echo vtranslate('LBL_MAX', $_smarty_tpl->tpl_vars['MODULE']->value);
            ?>
</th></tr></thead><?php 
            $_smarty_tpl->tpl_vars['ESCAPE_CHAR'] = new Smarty_variable(array('_SUM', '_AVG', '_MIN', '_MAX'), null, 0);
            $_smarty_tpl->tpl_vars['CALCULATION_FIELD'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->_loop = false;
            $_smarty_tpl->tpl_vars['index'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['CALCULATION_FIELDS']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->key => $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->value) {
                $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->_loop = true;
                $_smarty_tpl->tpl_vars['index']->value = $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->key;
                ?>
<tr><?php 
                $_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS'] = new Smarty_variable(array_keys($_smarty_tpl->tpl_vars['CALCULATION_FIELD']->value), null, 0);
                $_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS'] = new Smarty_variable(smarty_modifier_replace($_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS']->value, $_smarty_tpl->tpl_vars['ESCAPE_CHAR']->value, ''), null, 0);
                $_smarty_tpl->tpl_vars['FIELD_IMPLODE'] = new Smarty_variable(explode('_', $_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS']->value['0']), null, 0);
                $_smarty_tpl->tpl_vars['MODULE_NAME'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_IMPLODE']->value['0'], null, 0);
                $_smarty_tpl->tpl_vars['FIELD_LABEL'] = new Smarty_variable(implode(" ", $_smarty_tpl->tpl_vars['FIELD_IMPLODE']->value), null, 0);
                $_smarty_tpl->tpl_vars['FIELD_LABEL'] = new Smarty_variable(smarty_modifier_replace($_smarty_tpl->tpl_vars['FIELD_LABEL']->value, $_smarty_tpl->tpl_vars['MODULE_NAME']->value, ''), null, 0);
                ?>
<td><?php 
                echo vtranslate($_smarty_tpl->tpl_vars['MODULE_NAME']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
 <?php 
                echo vtranslate($_smarty_tpl->tpl_vars['FIELD_LABEL']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</td><?php 
                $_smarty_tpl->tpl_vars['CALCULATION_VALUE'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->key => $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->value) {
                    $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->_loop = true;
                    ?>
<td width="15%"><?php 
                    echo $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->value;
                    ?>
</td><?php 
                }
                ?>
</tr><?php 
            }
            ?>
</table><?php 
            if ($_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'Invoice' || $_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'Quotes' || $_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'SalesOrder' || $_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'PurchaseOrder') {
                $_smarty_tpl->tpl_vars['BASE_CURRENCY_INFO'] = new Smarty_variable(Vtiger_Util_Helper::getCurrentInfoOfUser(), null, 0);
                ?>
<div class="alert alert-info"><?php 
                echo vtranslate('LBL_NOTE', 'Vtiger');
                ?>
 : <?php 
                echo vtranslate('LBL_CALCULATION_CONVERSION_MESSAGE', 'Reports');
                ?>
 - <?php 
                echo $_smarty_tpl->tpl_vars['BASE_CURRENCY_INFO']->value['currency_name'];
                ?>
 (<?php 
                echo $_smarty_tpl->tpl_vars['BASE_CURRENCY_INFO']->value['currency_code'];
                ?>
)</div><?php 
            }
        }
        if ($_smarty_tpl->tpl_vars['DATA']->value != '') {
            $_smarty_tpl->tpl_vars['HEADERS'] = new Smarty_variable($_smarty_tpl->tpl_vars['DATA']->value[0], null, 0);
            ?>
<table class="table table-bordered table-striped"><thead><tr class="blockHeader"><?php 
            $_smarty_tpl->tpl_vars['HEADER'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['HEADER']->_loop = false;
            $_smarty_tpl->tpl_vars['NAME'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['HEADERS']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['HEADER']->key => $_smarty_tpl->tpl_vars['HEADER']->value) {
                $_smarty_tpl->tpl_vars['HEADER']->_loop = true;
                $_smarty_tpl->tpl_vars['NAME']->value = $_smarty_tpl->tpl_vars['HEADER']->key;
                ?>
<th nowrap><?php 
                echo vtranslate($_smarty_tpl->tpl_vars['NAME']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</th><?php 
            }
            ?>
</tr></thead><?php 
            $_smarty_tpl->tpl_vars['REPORTRUN'] = new Smarty_variable($_smarty_tpl->tpl_vars['REPORT_RUN_INSTANCE']->value, null, 0);
            $_smarty_tpl->tpl_vars['GROUPBYFIELDS'] = new Smarty_variable(array_keys($_smarty_tpl->tpl_vars['REPORTRUN']->value->getGroupingList($_smarty_tpl->tpl_vars['RECORD_ID']->value)), null, 0);
            $_smarty_tpl->tpl_vars['GROUPBYFIELDSCOUNT'] = new Smarty_variable(count($_smarty_tpl->tpl_vars['GROUPBYFIELDS']->value), null, 0);
            if ($_smarty_tpl->tpl_vars['GROUPBYFIELDSCOUNT']->value > 0) {
                $_smarty_tpl->tpl_vars['FIELDNAMES'] = new Smarty_variable(array(), null, 0);
                $_smarty_tpl->tpl_vars['i'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['i']->step = 1;
                $_smarty_tpl->tpl_vars['i']->total = (int) ceil(($_smarty_tpl->tpl_vars['i']->step > 0 ? $_smarty_tpl->tpl_vars['GROUPBYFIELDSCOUNT']->value - 1 + 1 - 0 : 0 - ($_smarty_tpl->tpl_vars['GROUPBYFIELDSCOUNT']->value - 1) + 1) / abs($_smarty_tpl->tpl_vars['i']->step));
                if ($_smarty_tpl->tpl_vars['i']->total > 0) {
                    for ($_smarty_tpl->tpl_vars['i']->value = 0, $_smarty_tpl->tpl_vars['i']->iteration = 1; $_smarty_tpl->tpl_vars['i']->iteration <= $_smarty_tpl->tpl_vars['i']->total; $_smarty_tpl->tpl_vars['i']->value += $_smarty_tpl->tpl_vars['i']->step, $_smarty_tpl->tpl_vars['i']->iteration++) {
                        $_smarty_tpl->tpl_vars['i']->first = $_smarty_tpl->tpl_vars['i']->iteration == 1;
                        $_smarty_tpl->tpl_vars['i']->last = $_smarty_tpl->tpl_vars['i']->iteration == $_smarty_tpl->tpl_vars['i']->total;
                        $_smarty_tpl->tpl_vars['FIELD'] = new Smarty_variable(explode(':', $_smarty_tpl->tpl_vars['GROUPBYFIELDS']->value[$_smarty_tpl->tpl_vars['i']->value]), null, 0);
                        $_smarty_tpl->tpl_vars['FIELD_EXPLODE'] = new Smarty_variable(explode('_', $_smarty_tpl->tpl_vars['FIELD']->value[2]), null, 0);
                        $_smarty_tpl->tpl_vars['j'] = new Smarty_Variable();
                        $_smarty_tpl->tpl_vars['j']->step = 1;
                        $_smarty_tpl->tpl_vars['j']->total = (int) ceil(($_smarty_tpl->tpl_vars['j']->step > 0 ? count($_smarty_tpl->tpl_vars['FIELD_EXPLODE']->value) - 1 + 1 - 1 : 1 - (count($_smarty_tpl->tpl_vars['FIELD_EXPLODE']->value) - 1) + 1) / abs($_smarty_tpl->tpl_vars['j']->step));
                        if ($_smarty_tpl->tpl_vars['j']->total > 0) {
                            for ($_smarty_tpl->tpl_vars['j']->value = 1, $_smarty_tpl->tpl_vars['j']->iteration = 1; $_smarty_tpl->tpl_vars['j']->iteration <= $_smarty_tpl->tpl_vars['j']->total; $_smarty_tpl->tpl_vars['j']->value += $_smarty_tpl->tpl_vars['j']->step, $_smarty_tpl->tpl_vars['j']->iteration++) {
                                $_smarty_tpl->tpl_vars['j']->first = $_smarty_tpl->tpl_vars['j']->iteration == 1;
                                $_smarty_tpl->tpl_vars['j']->last = $_smarty_tpl->tpl_vars['j']->iteration == $_smarty_tpl->tpl_vars['j']->total;
                                $_smarty_tpl->createLocalArrayVariable('FIELDNAMES', null, 0);
                                $_smarty_tpl->tpl_vars['FIELDNAMES']->value[$_smarty_tpl->tpl_vars['i']->value] = $_smarty_tpl->tpl_vars['FIELDNAMES']->value[$_smarty_tpl->tpl_vars['i']->value] . $_smarty_tpl->tpl_vars['FIELD_EXPLODE']->value[$_smarty_tpl->tpl_vars['j']->value] . " ";
                            }
                        }
                    }
                }
                if ($_smarty_tpl->tpl_vars['GROUPBYFIELDSCOUNT']->value == 1) {
                    $_smarty_tpl->tpl_vars['FIRST_FIELD'] = new Smarty_variable(vtranslate(trim($_smarty_tpl->tpl_vars['FIELDNAMES']->value[0]), $_smarty_tpl->tpl_vars['MODULE']->value), null, 0);
                } elseif ($_smarty_tpl->tpl_vars['GROUPBYFIELDSCOUNT']->value == 2) {
                    $_smarty_tpl->tpl_vars['FIRST_FIELD'] = new Smarty_variable(vtranslate(trim($_smarty_tpl->tpl_vars['FIELDNAMES']->value[0]), $_smarty_tpl->tpl_vars['MODULE']->value), null, 0);
                    $_smarty_tpl->tpl_vars['SECOND_FIELD'] = new Smarty_variable(vtranslate(trim($_smarty_tpl->tpl_vars['FIELDNAMES']->value[1]), $_smarty_tpl->tpl_vars['MODULE']->value), null, 0);
                } elseif ($_smarty_tpl->tpl_vars['GROUPBYFIELDSCOUNT']->value == 3) {
                    $_smarty_tpl->tpl_vars['FIRST_FIELD'] = new Smarty_variable(vtranslate(trim($_smarty_tpl->tpl_vars['FIELDNAMES']->value[0]), $_smarty_tpl->tpl_vars['MODULE']->value), null, 0);
                    $_smarty_tpl->tpl_vars['SECOND_FIELD'] = new Smarty_variable(vtranslate(trim($_smarty_tpl->tpl_vars['FIELDNAMES']->value[1]), $_smarty_tpl->tpl_vars['MODULE']->value), null, 0);
                    $_smarty_tpl->tpl_vars['THIRD_FIELD'] = new Smarty_variable(vtranslate(trim($_smarty_tpl->tpl_vars['FIELDNAMES']->value[2]), $_smarty_tpl->tpl_vars['MODULE']->value), null, 0);
                }
                $_smarty_tpl->tpl_vars['FIRST_VALUE'] = new Smarty_variable(" ", null, 0);
                $_smarty_tpl->tpl_vars['SECOND_VALUE'] = new Smarty_variable(" ", null, 0);
                $_smarty_tpl->tpl_vars['THIRD_VALUE'] = new Smarty_variable(" ", null, 0);
                $_smarty_tpl->tpl_vars['VALUES'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['VALUES']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['DATA']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['VALUES']->key => $_smarty_tpl->tpl_vars['VALUES']->value) {
                    $_smarty_tpl->tpl_vars['VALUES']->_loop = true;
                    ?>
<tr><?php 
                    $_smarty_tpl->tpl_vars['VALUE'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['VALUE']->_loop = false;
                    $_smarty_tpl->tpl_vars['NAME'] = new Smarty_Variable();
                    $_from = $_smarty_tpl->tpl_vars['VALUES']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['VALUE']->key => $_smarty_tpl->tpl_vars['VALUE']->value) {
                        $_smarty_tpl->tpl_vars['VALUE']->_loop = true;
                        $_smarty_tpl->tpl_vars['NAME']->value = $_smarty_tpl->tpl_vars['VALUE']->key;
                        ob_start();
                        echo $_smarty_tpl->tpl_vars['FIRST_FIELD']->value;
                        $_tmp1 = ob_get_clean();
                        if (($_smarty_tpl->tpl_vars['NAME']->value == $_smarty_tpl->tpl_vars['FIRST_FIELD']->value || strstr($_smarty_tpl->tpl_vars['NAME']->value, $_tmp1)) && ($_smarty_tpl->tpl_vars['FIRST_VALUE']->value == $_smarty_tpl->tpl_vars['VALUE']->value || $_smarty_tpl->tpl_vars['FIRST_VALUE']->value == " ")) {
                            if ($_smarty_tpl->tpl_vars['FIRST_VALUE']->value == " " || $_smarty_tpl->tpl_vars['VALUE']->value == "-") {
                                ?>
<td><?php 
                                echo $_smarty_tpl->tpl_vars['VALUE']->value;
                                ?>
</td><?php 
                            } else {
                                ?>
<td class="summary"><?php 
                                echo " ";
                                ?>
</td><?php 
                            }
                            if ($_smarty_tpl->tpl_vars['VALUE']->value != " ") {
                                $_smarty_tpl->tpl_vars['FIRST_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['VALUE']->value, null, 0);
                            }
                        } elseif (($_smarty_tpl->tpl_vars['NAME']->value == $_smarty_tpl->tpl_vars['SECOND_FIELD']->value || strstr($_smarty_tpl->tpl_vars['NAME']->value, $_smarty_tpl->tpl_vars['SECOND_FIELD']->value)) && ($_smarty_tpl->tpl_vars['SECOND_VALUE']->value == $_smarty_tpl->tpl_vars['VALUE']->value || $_smarty_tpl->tpl_vars['SECOND_VALUE']->value == " ")) {
                            if ($_smarty_tpl->tpl_vars['SECOND_VALUE']->value == " " || $_smarty_tpl->tpl_vars['VALUE']->value == "-") {
                                ?>
<td><?php 
                                echo $_smarty_tpl->tpl_vars['VALUE']->value;
                                ?>
</td><?php 
                            } else {
                                ?>
<td class="summary"><?php 
                                echo " ";
                                ?>
</td><?php 
                            }
                            if ($_smarty_tpl->tpl_vars['VALUE']->value != " ") {
                                $_smarty_tpl->tpl_vars['SECOND_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['VALUE']->value, null, 0);
                            }
                        } elseif (($_smarty_tpl->tpl_vars['NAME']->value == $_smarty_tpl->tpl_vars['THIRD_FIELD']->value || strstr($_smarty_tpl->tpl_vars['NAME']->value, $_smarty_tpl->tpl_vars['THIRD_FIELD']->value)) && ($_smarty_tpl->tpl_vars['THIRD_VALUE']->value == $_smarty_tpl->tpl_vars['VALUE']->value || $_smarty_tpl->tpl_vars['THIRD_VALUE']->value == " ")) {
                            if ($_smarty_tpl->tpl_vars['THIRD_VALUE']->value == " " || $_smarty_tpl->tpl_vars['VALUE']->value == "-") {
                                ?>
<td><?php 
                                echo $_smarty_tpl->tpl_vars['VALUE']->value;
                                ?>
</td><?php 
                            } else {
                                ?>
<td class="summary"><?php 
                                echo " ";
                                ?>
</td><?php 
                            }
                            if ($_smarty_tpl->tpl_vars['VALUE']->value != " ") {
                                $_smarty_tpl->tpl_vars['THIRD_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['VALUE']->value, null, 0);
                            }
                        } else {
                            ?>
<td><?php 
                            echo $_smarty_tpl->tpl_vars['VALUE']->value;
                            ?>
</td><?php 
                            if ($_smarty_tpl->tpl_vars['NAME']->value == $_smarty_tpl->tpl_vars['FIRST_FIELD']->value || strstr($_smarty_tpl->tpl_vars['NAME']->value, $_smarty_tpl->tpl_vars['FIRST_FIELD']->value)) {
                                $_smarty_tpl->tpl_vars['FIRST_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['VALUE']->value, null, 0);
                            } elseif ($_smarty_tpl->tpl_vars['NAME']->value == $_smarty_tpl->tpl_vars['SECOND_FIELD']->value || strstr($_smarty_tpl->tpl_vars['NAME']->value, $_smarty_tpl->tpl_vars['SECOND_FIELD']->value)) {
                                $_smarty_tpl->tpl_vars['SECOND_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['VALUE']->value, null, 0);
                            } elseif ($_smarty_tpl->tpl_vars['NAME']->value == $_smarty_tpl->tpl_vars['THIRD_FIELD']->value || strstr($_smarty_tpl->tpl_vars['NAME']->value, $_smarty_tpl->tpl_vars['THIRD_FIELD']->value)) {
                                $_smarty_tpl->tpl_vars['THIRD_VALUE'] = new Smarty_variable($_smarty_tpl->tpl_vars['VALUE']->value, null, 0);
                            }
                        }
                    }
                    ?>
</tr><?php 
                }
            } else {
                $_smarty_tpl->tpl_vars['VALUES'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['VALUES']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['DATA']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['VALUES']->key => $_smarty_tpl->tpl_vars['VALUES']->value) {
                    $_smarty_tpl->tpl_vars['VALUES']->_loop = true;
                    ?>
<tr><?php 
                    $_smarty_tpl->tpl_vars['VALUE'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['VALUE']->_loop = false;
                    $_smarty_tpl->tpl_vars['NAME'] = new Smarty_Variable();
                    $_from = $_smarty_tpl->tpl_vars['VALUES']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['VALUE']->key => $_smarty_tpl->tpl_vars['VALUE']->value) {
                        $_smarty_tpl->tpl_vars['VALUE']->_loop = true;
                        $_smarty_tpl->tpl_vars['NAME']->value = $_smarty_tpl->tpl_vars['VALUE']->key;
                        ?>
<td><?php 
                        echo $_smarty_tpl->tpl_vars['VALUE']->value;
                        ?>
</td><?php 
                    }
                    ?>
</tr><?php 
                }
            }
            ?>
</table><?php 
            if ($_smarty_tpl->tpl_vars['LIMIT_EXCEEDED']->value) {
                ?>
<center><?php 
                echo vtranslate('LBL_LIMIT_EXCEEDED', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
 <span class="pull-right"><a href="#top" ><?php 
                echo vtranslate('LBL_TOP', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</a></span></center><?php 
            }
        } else {
            echo vtranslate('LBL_NO_DATA_AVAILABLE', $_smarty_tpl->tpl_vars['MODULE']->value);
        }
        ?>
</div></div><br></div></div>
<?php 
    }
    function content_56755f9495a47($_smarty_tpl)
    {
        if (!is_callable('smarty_modifier_replace')) {
            include '/home/c/charter7ru/crm/public_html/libraries/Smarty/libs/plugins/modifier.replace.php';
        }
        ?>
<div class="contents-topscroll"><div class="topscroll-div container-fluid">&nbsp;</div></div><div id="reportDetails" class="contents-bottomscroll"><div class="bottomscroll-div"><input type="hidden" id="updatedCount" value="<?php 
        echo $_smarty_tpl->tpl_vars['NEW_COUNT']->value;
        ?>
" /><?php 
        if (!empty($_smarty_tpl->tpl_vars['CALCULATION_FIELDS']->value)) {
            ?>
<table class=" table-bordered table-condensed marginBottom10px" width="100%" style="width:500px;margin:20px auto;"><thead><tr class="blockHeader"><th><?php 
            echo vtranslate('LBL_FIELD_NAMES', $_smarty_tpl->tpl_vars['MODULE']->value);
            echo $_smarty_tpl->tpl_vars['CALCULATION_FIELDS']->value['SalesOrder_Total_SUM'];
            ?>
</th><?php 
            if ($_smarty_tpl->tpl_vars['COLUMNS']->value['SUM']) {
                ?>
<th><?php 
                echo vtranslate('LBL_SUM', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</th><?php 
            }
            if ($_smarty_tpl->tpl_vars['COLUMNS']->value['AVG']) {
                ?>
<th><?php 
                echo vtranslate('LBL_AVG', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</th><?php 
            }
            if ($_smarty_tpl->tpl_vars['COLUMNS']->value['MIN']) {
                ?>
<th><?php 
                echo vtranslate('LBL_MIN', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</th><?php 
            }
            if ($_smarty_tpl->tpl_vars['COLUMNS']->value['MAX']) {
                ?>
<th><?php 
                echo vtranslate('LBL_MAX', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</th><?php 
            }
            ?>
</tr></thead><?php 
            $_smarty_tpl->tpl_vars['ESCAPE_CHAR'] = new Smarty_variable(array('_SUM', '_AVG', '_MIN', '_MAX'), null, 0);
            $_smarty_tpl->tpl_vars['CALCULATION_FIELD'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->_loop = false;
            $_smarty_tpl->tpl_vars['index'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['CALCULATION_FIELDS']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->key => $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->value) {
                $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->_loop = true;
                $_smarty_tpl->tpl_vars['index']->value = $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->key;
                ?>
<tr><?php 
                $_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS'] = new Smarty_variable(array_keys($_smarty_tpl->tpl_vars['CALCULATION_FIELD']->value), null, 0);
                $_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS'] = new Smarty_variable(smarty_modifier_replace($_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS']->value, $_smarty_tpl->tpl_vars['ESCAPE_CHAR']->value, ''), null, 0);
                $_smarty_tpl->tpl_vars['FIELD_IMPLODE'] = new Smarty_variable(explode('_', $_smarty_tpl->tpl_vars['CALCULATION_FIELD_KEYS']->value['0']), null, 0);
                $_smarty_tpl->tpl_vars['MODULE_NAME'] = new Smarty_variable($_smarty_tpl->tpl_vars['FIELD_IMPLODE']->value['0'], null, 0);
                $_smarty_tpl->tpl_vars['FIELD_LABEL'] = new Smarty_variable(implode(" ", $_smarty_tpl->tpl_vars['FIELD_IMPLODE']->value), null, 0);
                $_smarty_tpl->tpl_vars['FIELD_LABEL'] = new Smarty_variable(smarty_modifier_replace($_smarty_tpl->tpl_vars['FIELD_LABEL']->value, $_smarty_tpl->tpl_vars['MODULE_NAME']->value, ''), null, 0);
                ?>
<td><?php 
                echo vtranslate($_smarty_tpl->tpl_vars['MODULE_NAME']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
 <?php 
                echo vtranslate($_smarty_tpl->tpl_vars['FIELD_LABEL']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</td><?php 
                $_smarty_tpl->tpl_vars['CALCULATION_VALUE'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->_loop = false;
                $_smarty_tpl->tpl_vars['subindex'] = new Smarty_Variable();
                $_from = $_smarty_tpl->tpl_vars['CALCULATION_FIELD']->value;
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->key => $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->value) {
                    $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->_loop = true;
                    $_smarty_tpl->tpl_vars['subindex']->value = $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->key;
                    $_smarty_tpl->tpl_vars['COLUMN'] = new Smarty_variable(substr($_smarty_tpl->tpl_vars['subindex']->value, -3, 3), null, 0);
                    if ($_smarty_tpl->tpl_vars['CALCULATION_VALUE']->value != '') {
                        ?>
<td width="15%"><?php 
                        echo $_smarty_tpl->tpl_vars['CALCULATION_VALUE']->value;
                        ?>
</td><?php 
                    } elseif ($_smarty_tpl->tpl_vars['COLUMNS']->value[$_smarty_tpl->tpl_vars['COLUMN']->value]) {
                        ?>
<td></td><?php 
                    }
                }
                ?>
</tr><?php 
            }
            ?>
</table><?php 
            if ($_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'Invoice' || $_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'Quotes' || $_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'SalesOrder' || $_smarty_tpl->tpl_vars['PRIMARY_MODULE']->value == 'PurchaseOrder') {
                $_smarty_tpl->tpl_vars['BASE_CURRENCY_INFO'] = new Smarty_variable(Vtiger_Util_Helper::getCurrentInfoOfUser(), null, 0);
                ?>
<div class="alert alert-info"><?php 
                echo vtranslate('LBL_NOTE', 'Vtiger');
                ?>
 : <?php 
                echo vtranslate('LBL_CALCULATION_CONVERSION_MESSAGE', 'Reports');
                ?>
 - <?php 
                echo $_smarty_tpl->tpl_vars['BASE_CURRENCY_INFO']->value['currency_name'];
                ?>
 (<?php 
                echo $_smarty_tpl->tpl_vars['BASE_CURRENCY_INFO']->value['currency_code'];
                ?>
)</div><?php 
            }
        }
        if ($_smarty_tpl->tpl_vars['DATA']->value != '') {
            $_smarty_tpl->tpl_vars['HEADERS'] = new Smarty_variable($_smarty_tpl->tpl_vars['DATA']->value[0], null, 0);
            ?>
<div class="container"><div class="panel panel-default"><table class="table table-bordered"><tr colspan="8" class="blockHeader panel-heading" ><?php 
            $_smarty_tpl->tpl_vars['HEADER'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['HEADER']->_loop = false;
            $_smarty_tpl->tpl_vars['NAME'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['HEADERS']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['HEADER']->key => $_smarty_tpl->tpl_vars['HEADER']->value) {
                $_smarty_tpl->tpl_vars['HEADER']->_loop = true;
                $_smarty_tpl->tpl_vars['NAME']->value = $_smarty_tpl->tpl_vars['HEADER']->key;
                ?>
<td nowrap><?php 
                echo vtranslate($_smarty_tpl->tpl_vars['NAME']->value, $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</td><?php 
            }
            ?>
</tr><?php 
            $_smarty_tpl->tpl_vars['val'] = new Smarty_Variable();
            $_smarty_tpl->tpl_vars['val']->_loop = false;
            $_smarty_tpl->tpl_vars['groupval'] = new Smarty_Variable();
            $_from = $_smarty_tpl->tpl_vars['DATAGROUPED']->value;
            if (!is_array($_from) && !is_object($_from)) {
                settype($_from, 'array');
            }
            foreach ($_from as $_smarty_tpl->tpl_vars['val']->key => $_smarty_tpl->tpl_vars['val']->value) {
                $_smarty_tpl->tpl_vars['val']->_loop = true;
                $_smarty_tpl->tpl_vars['groupval']->value = $_smarty_tpl->tpl_vars['val']->key;
                ?>
<tr data-rel="parent" data-groupval="<?php 
                echo $_smarty_tpl->tpl_vars['groupval']->value;
                ?>
" style="background: grey; color: black; cursor:pointer;"><?php 
                $_smarty_tpl->tpl_vars['summval'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['summval']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['val']->value['summary'];
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['summval']->key => $_smarty_tpl->tpl_vars['summval']->value) {
                    $_smarty_tpl->tpl_vars['summval']->_loop = true;
                    ?>
<td><?php 
                    echo $_smarty_tpl->tpl_vars['summval']->value;
                    ?>
</td><?php 
                }
                ?>
</tr><?php 
                $_smarty_tpl->tpl_vars['row'] = new Smarty_Variable();
                $_smarty_tpl->tpl_vars['row']->_loop = false;
                $_from = $_smarty_tpl->tpl_vars['val']->value['rows'];
                if (!is_array($_from) && !is_object($_from)) {
                    settype($_from, 'array');
                }
                foreach ($_from as $_smarty_tpl->tpl_vars['row']->key => $_smarty_tpl->tpl_vars['row']->value) {
                    $_smarty_tpl->tpl_vars['row']->_loop = true;
                    ?>
<tr data-rel="children_<?php 
                    echo $_smarty_tpl->tpl_vars['groupval']->value;
                    ?>
"  style="display:none;"><?php 
                    $_smarty_tpl->tpl_vars['rowValue'] = new Smarty_Variable();
                    $_smarty_tpl->tpl_vars['rowValue']->_loop = false;
                    $_from = $_smarty_tpl->tpl_vars['row']->value;
                    if (!is_array($_from) && !is_object($_from)) {
                        settype($_from, 'array');
                    }
                    foreach ($_from as $_smarty_tpl->tpl_vars['rowValue']->key => $_smarty_tpl->tpl_vars['rowValue']->value) {
                        $_smarty_tpl->tpl_vars['rowValue']->_loop = true;
                        ?>
<td><?php 
                        echo $_smarty_tpl->tpl_vars['rowValue']->value;
                        ?>
</td><?php 
                    }
                    ?>
</tr><?php 
                }
            }
            ?>
</table></div></div>
            <script>
                $('tr[data-rel="parent"]').on('click', function(){
                    var groupval = $(this).attr('data-groupval'),
                        childrenEls = $('tr[data-rel="children_'+groupval+'"]');

                    if ( $(this).hasClass('active') ) {
                        $(this).removeClass('active');
                        childrenEls.hide();
                    } else {
                        $(this).addClass('active');
                        childrenEls.show();
                    }
                });
            </script>
            </table><?php 
            if ($_smarty_tpl->tpl_vars['LIMIT_EXCEEDED']->value) {
                ?>
<center><?php 
                echo vtranslate('LBL_LIMIT_EXCEEDED', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
 <span class="pull-right"><a href="#top" ><?php 
                echo vtranslate('LBL_TOP', $_smarty_tpl->tpl_vars['MODULE']->value);
                ?>
</a></span></center><?php 
            }
        } else {
            echo vtranslate('LBL_NO_DATA_AVAILABLE', $_smarty_tpl->tpl_vars['MODULE']->value);
        }
        ?>
</div></div><br></div></div>
<?php 
    }