<script {literal}data-pace-options='{ "ajax": false }'{/literal} src="{$urls.JS_PATH}/pace.js"></script>
<link href="{$urls.CSS_PATH}/pace.css" rel="stylesheet" type="text/css" media="all" />

<script src="{$urls.JS_PATH}/jquery/jquery-1.8.3.min.js"></script>
<script src="{$urls.JS_PATH}/legacy/startwith.js"></script>
<script type="text/javascript">
    jQuery.noConflict();
    jQuery('link[rel="stylesheet"][href*="nvd3.css"]').attr('disabled', 'disabled');
    jQuery('link[rel="stylesheet"][href*="nvd3.css"]').remove();

    // Add EventSource polyfill for Internet Explorer
    {literal}
    if(!window.EventSource){
        document.write('<script type="text/javascript" src="{/literal}{$urls.JS_PATH}{literal}/EventSource.js"><\/script>');
    }
</script>
{/literal}

<script>
    var $sugar_flavor = '{$sugar_flavor}';
    var $isSidecar = '{$isSidecar}';
    var $systemType = '{$systemType}';
    var $site_url = '{$site_url}';

    /**
     * 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};

    var userFields = {$userFields};
    //#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 = {$permissions};
    var scheduling = {$scheduling};
    var moduleName = "AnalyticReporting";
    var urls = {$urlsJSON};

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

    var currentUser = {$currentUser};
</script>

<script src="{$urls.JS_PATH}/jquery-ui/jquery-ui.min.js"></script>

<script src="{$urls.JS_PATH}/jquery/jquery.select2.min.js"></script>
<script src="{$urls.JS_PATH}/jquery/jquery.event.drag-2.2.js"></script>
<script src="{$urls.JS_PATH}/spectrum.js"></script>
<script src="{$urls.JS_PATH}/toastr.min.js"></script>
<script src="{$urls.JS_PATH}/jquery.fileDownload.js"></script>

<script src="{$urls.JS_PATH}/moment.min.js"></script>

<script src="{$urls.JS_PATH}/ractive/Ractive.min.js"></script>
<script src="{$urls.JS_PATH}/ractive/ractive-decorators-select2.min.js"></script>
<script src="{$urls.JS_PATH}/ractive/Ractive-decorators-sortable.js"></script>
<script src="{$urls.JS_PATH}/lodash.min.js"></script>
<link href="{$urls.CSS_PATH}/jquery.select2.css" rel="stylesheet" type="text/css" media="all" />

<link href="{$urls.CSS_PATH}/jquery-ui/redmond/jquery-ui.css" rel="stylesheet" type="text/css" media="all" />
<link href="{$urls.CSS_PATH}/spectrum.css" rel="stylesheet" type="text/css">
<link href="{$urls.CSS_PATH}/toastr.min.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%;
    }
    /* Remove leaflet legend bars scale "stairs" */
    .scale-bars i {
        height:20px !important
    }

    /* style overrides for new report table */
    #ar-table-app ul li {
         list-style-type: none;
         margin-left: 0;
         margin-bottom: 0;
    }
</style>
{/literal}

{*
* Fixed SuiteCRM issue with selects in reporting filters (for example between),
*  where selectboxes have high padding (0 52px 0 5px) and therefore breaks filter lines.
*}
{if $systemType eq 'SUITECRM'}
{literal}
<style>
    body {
        font-size:12px !important;
    }
    #ar-report-app * {
        font-size:12px !important;
    }
    select {padding:0 32px 0 5px}
</style>
{/literal}
{/if}

<div id="modalWindow" style="display:none;"></div>
<div id="ar-container">
    <div id="reportControls" style="position:relative;margin-left:5px;"></div>
    <h2 style="margin-top:20px;margin-left:5px;color:#333;" id="reportTitleContainer">
    <span id="reportTitle">{$REPORTTITLE}</span>{if $CANEDIT eq true}<a id="ar-rv-editor-title" href="#"><img src="{$urls.IMG_PATH}/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="$TPL_PATH/templates.tpl"}



<script src="{$urls.JS_PATH}/multiselect/jquery.multiselect.js"></script>
<link href="{$urls.CSS_PATH}/multiselect/jquery.multiselect.css" rel="stylesheet" type="text/css">

<link href="{$urls.CSS_PATH}/{$moduleName}.css" rel="stylesheet" type="text/css" media="all" />
<!-- env:dev --#>
<script src="{$urls.JS_PATH}/components/reports/shared.js"></script>
<script src="{$urls.JS_PATH}/components/shared.js"></script>
<script src="{$urls.JS_PATH}/components/reportManager.js"></script>
<script src="{$urls.JS_PATH}/components/componentUtils.js"></script>
<script src="{$urls.JS_PATH}/components/manager/filterManager.js"></script>
<script src="{$urls.JS_PATH}/components/manager/fieldManager.js"></script>
<script src="{$urls.JS_PATH}/components/manager/aggregateManager.js"></script>
<script src="{$urls.JS_PATH}/components/manager/TotalTable.js"></script>
<script src="{$urls.JS_PATH}/components/manager/calcColumns.js"></script>
<script src="{$urls.JS_PATH}/components/manager/SortingByField.js"></script>
<script src="{$urls.JS_PATH}/components/manager/SortingByCombinedField.js"></script>
<script src="{$urls.JS_PATH}/components/manager/SortingBy.js"></script>
<script src="{$urls.JS_PATH}/components/manager/SortingByCombined.js"></script>
<script src="{$urls.JS_PATH}/components/manager/groupingManager.js"></script>
<script src="{$urls.JS_PATH}/components/manager/templateManager.js"></script>
<script src="{$urls.JS_PATH}/components/manager/labelManager.js"></script>
<script src="{$urls.JS_PATH}/components/manager/calcFieldManager.js"></script>
<!-- env:dev:end -->
<!-- env:prod -->
<script src="{$urls.JS_PATH}/{$moduleName}.min.js?v=3.0.278"></script>
<!-- env:prod:end -->

<script src="{$urls.JS_PATH}/report/reportApp.min.js"></script>

<script>
    {literal}
    try {
        window.ARReportApp.init(
            "ar-report-app",
            Object.assign({}, window.ReportData, { permissions, scheduling }),
            window.envConfig
        );
    } catch (e) { }
    {/literal}
</script>


<!-- env:dev --#>
<script src="{$urls.JS_PATH}/components/reports/standart.js"></script>
<!-- env:dev:end -->
