{* vTiger 6 support (vTiger 7 doesn't need this file)*}
{if !version_compare($VTIGER_VERSION, '7.0.0', '>=')}
    {if $customizations.includejQuery}
    <script src="modules/{$moduleName}/assets/js/jquery/jquery-1.8.3.min.js"></script>

    <script type="text/javascript">
        jQuery.noConflict();
    </script>
    {/if}
{/if}
<script src="modules/{$moduleName}/assets/js/pace.js"></script>
<link href="modules/{$moduleName}/assets/css/pace.css" rel="stylesheet" type="text/css" media="all" />

{* jquery-ui is for multiselect component *}
<script src="modules/{$moduleName}/assets/js/jquery-ui/jquery-ui.min.js"></script>

{* vTiger 7 doesn't need this file, because is already built-in *}
{if !version_compare($VTIGER_VERSION, '7.0.0', '>=')}
<script src="modules/{$moduleName}/assets/js/jquery/jquery.select2.min.js"></script>
{/if}
<script src="modules/{$moduleName}/assets/js/jquery/jquery.event.drag-2.2.js"></script>
<script src="modules/{$moduleName}/assets/js/spectrum.js"></script>



<script src="modules/{$moduleName}/assets/js/moment.min.js"></script>

<script src="modules/{$moduleName}/assets/js/ractive/Ractive.min.js"></script>
<script src="modules/{$moduleName}/assets/js/ractive/ractive-decorators-select2.min.js"></script>
<script src="modules/{$moduleName}/assets/js/ractive/Ractive-decorators-sortable.js"></script>
<script src="modules/{$moduleName}/assets/js/lodash.min.js"></script>
<script src="modules/{$moduleName}/assets/js/jquery.doubleScroll.js"></script>

{* vTiger 7 doesn't need this file, because is already built-in *}
{if !version_compare($VTIGER_VERSION, '7.0.0', '>=')}
<link href="modules/{$moduleName}/assets/css/jquery.select2.css" rel="stylesheet" type="text/css" media="all" />
{/if}

<link href="modules/{$moduleName}/assets/css/jquery-ui/redmond/jquery-ui.css" rel="stylesheet" type="text/css" media="all" />
<link href="modules/{$moduleName}/assets/css/spectrum.css" rel="stylesheet" type="text/css">
{literal}
<style>
    #ar-rv-data-grid {
        /*max-height:500px;*/
        border:1px solid #ddd;
    }
    #reportDescription{
        margin-left:18px;
        display: none;
    }
    /* Fix for gauge chart */
    .nvd3-svg {
        height:100%;
    }
    /* #4470 - Vtiger 6.1 fix */
    .ui-widget-content {
        box-shadow: none !important;
        margin-top: 0px !important;
        margin-left: 0px !important;
        height:auto !important;
    }
    .select2-search-field {
        width:auto !important;
    }
    .ui-tabs .ui-tabs-nav li a {
        border-color:none !important;
    }
    .ui-tabs .ui-tabs-nav li.ui-tabs-active a {
        background-color: none !important;
        border-color: #ddd #ddd none;
    }
    div.datepicker {
        height:auto;
    }
    .under-navigation {
        margin:0;
        padding:0;
    }
    .under-navigation li {
        list-style-type: none;
        display: inline;
    }
    .under-navigation li:not(:first-child):before {
        content: " | ";
    }
    /* Fix issue for VTiger and Material-UI style conflicts */
    .MuiPaper-root input[type=checkbox] {
        display: none;
    }
    .MuiPaper-root input[type=checkbox]:checked {
        opacity: 0
    }
    .MuiPaper-root input[type=checkbox]:checked::after {
        opacity: 0
    }
</style>
{/literal}
<div id="modalWindow" style="display:none;"></div>
<div id="ar-container">
    <div id="reportControls" style="margin-left:5px;"></div>
    <h2 style="margin-top:20px;margin-left:5px;color:#333;" id="reportTitleContainer">
    <span id="reportTitle">{$REPORTTITLE}</span>{if $CANEDIT eq 1}<a id="ar-rv-editor-title" href="#"><img src="modules/{$moduleName}/assets/img/slickgrid/pencil.gif"></a>{/if}
    </h2>
    <span id="reportDescription">{$REPORTDESCRIPTION}</span>

    <div id="ar-report-app"></div>
</div>

{* Include underscore.js and Ractive.js templates *}
{include file="modules/$moduleName/ReportViewer/templates.tpl"}


<script>
/**
 * Define defaults for ReportGrid and ReportChart
 */
var ReportData = {$REPORTDATA};
var isDebugMode = {$isDebugMode} ? true : false;
var isBasic = {$ISBASIC} ? true : false;
var wasNewInstall = {$WASNEWINST} ? true : false;
var envConfig = {literal}{{/literal}
    isDebugMode: isDebugMode,
    isBasic:isBasic,
    wasNewInstall:wasNewInstall,
    {literal}}{/literal};


//#5843 Adding widget to user and role is only allowed for the owner and admin
var current_user = {$CURRENTUSER};
//#3831 [start] - get report folders
var current_folder={$current_report_folder};
var report_folders=[];
{foreach from=$report_folders key=folder_key item=report_folder}
    report_folders[{$folder_key}] = "{$report_folder}";
{/foreach}
//#3831 [end]
var translated_labels = {$DICTIONARY}; // #5286 - Refactored to JSON object
ReportData.dictionary = translated_labels;
var excelTemplates = {$excelTemplates};

var reportNamesForTemplates = {$reportNamesForTemplates};
var userPermissions = {$userPermissions};
var permissions = userPermissions;
var canEdit = {$CANEDIT};
var urls = {$urlsJSON};

var aggregatesDefinitions = {$aggregatesDefinitionsJSON};
var aggregatesCheckBoxesChecked = {$aggregatesCheckBoxesChecked};
var aggregatesCheckBoxesNotChecked = {$aggregatesCheckBoxesNotChecked};

var currentUser = {$currentUser};


{literal}
// #5141 - When SlickGrid is finally rendered add top scroll
jQuery(document).on("slickRenderCompleted", function(){
    // By default check for double scroll in left (main) pane
    jQuery(".slick-viewport-top.slick-viewport-left").doubleScroll({
        beforeElement: ".slick-header.slick-header-left:first",
        onlyIfScroll: false,
        resetOnWindowResize: true,
        timeToWaitForResize:0,
            scrollCss: {                
                'overflow-x': 'scroll',
            },
            contentCss: {
                'overflow-x': 'scroll',
            },
    });
    // If there is some frozen columns, then add double scroll on second pane too
    if(ReportData.options.frozenColumn && ReportData.options.frozenColumn > 0) {
        jQuery(".slick-viewport-top.slick-viewport-right").doubleScroll({
            beforeElement: ".slick-header.slick-header-right:first",
            onlyIfScroll: false,
            resetOnWindowResize: true,
            timeToWaitForResize:0,
            scrollCss: {                
                'overflow-x': 'scroll',
            },
            contentCss: {
                'overflow-x': 'scroll',
            },
        });
    }
});
{/literal}
</script>

<script src="modules/{$moduleName}/assets/js/multiselect/jquery.multiselect.js"></script>
<link href="modules/{$moduleName}/assets/css/multiselect/jquery.multiselect.css" rel="stylesheet" type="text/css">

<link href="modules/{$moduleName}/assets/css/{$moduleName}.css" rel="stylesheet" type="text/css" media="all" />

<!-- env:dev --#>
<script src="modules/{$moduleName}/assets/js/components/reports/shared.js"></script>
<script src="modules/{$moduleName}/assets/js/components/reports/standart.js"></script>
<script src="modules/{$moduleName}/assets/js/components/shared.js"></script>
<script src="modules/{$moduleName}/assets/js/components/reportManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/componentUtils.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/filterManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/fieldManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/aggregateManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/TotalTable.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/calcColumns.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/SortingByField.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/SortingByCombinedField.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/SortingBy.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/SortingByCombined.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/groupingManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/templateManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/labelManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/accessManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/scheduleManager.js"></script>
<script src="modules/{$moduleName}/assets/js/components/manager/calcFieldManager.js"></script>
<!-- env:dev:end -->
<!-- env:prod -->
<script src="modules/{$moduleName}/assets/js/{$moduleName}.min.js"></script>
<!-- env:prod:end -->

<style media="print">{literal}
    body > * {
        display: none;
	}
	#page{
		display: block; !important;
	}
	#page > *{
		display: none;
	}
	#page > .bodyContents{
		display: block; !important;
	}
	#page > .bodyContents > * {
		display: none;
	}
	#page > .bodyContents > .mainContainer{
		display: block; !important;
	}
	.mainContainer > * {
		display: none;
	}
    #page > .main-container{
        display: block; !important;
    }
    #page > .main-container > * {
        display: none;
    }
    #page > .main-container > .row{
        display: block; !important;
    }
    #modules-menu {
        display: none;
    }
	#rightPanel{
		display: block; !important;
    }
    #ar-container{
        display: block !important;
    }
    #ar-container > * {
        display: none;
    }
    #reportTitleContainer > *{
        display: none;
    }
    #reportTitleContainer{
        display: block !important;
    }
    #reportTitle{
        display: block !important;
    }

    #ar-rv-data{
        display: block !important;
    }
    #ar-rv-data > * {
        display: none;
    }
    #ar-rv-data > div{
        display: block !important;
    }
    #ar-rv-data > div > *{
        display: none;
    }
    #displayData{
        display: block !important;
    }
    #ar-rv-chart-view{
        display: block !important;
        max-width: 250mm;
    }
    #ar-rv-chart-view > *{
        display: none;
    }
    #chart1{
        display: block !important;
        max-width: 230mm;
    }
    #chart1 > div{
        display: none;
    }
    {/literal}

    {* vTiger 6 support for ReportApp font size *}
    {if version_compare($VTIGER_VERSION, '7.0.0', '<')}
    {literal}
    #ar-report-app * {
        font-size:12px !important;
    }
    {/literal}
    {/if}
</style>

<script src="modules/{$moduleName}/assets/js/report/reportApp.min.js"></script>
<script>
    {literal}
    window.ARReportApp.init(
        "ar-report-app",
        Object.assign({}, window.ReportData, { permissions }),
        window.envConfig
    );
    {/literal}
</script>

{* vTiger 7 support (fix Material-UI/vTiger hybrid solutions *}
{if version_compare($VTIGER_VERSION, '7.0.0', '>=')}
    <link href="modules/{$moduleName}/assets/css/vtiger7fix.css" rel="stylesheet" type="text/css" media="all" />
{/if}