<?php
    //download popup
    $current = 0;
    $number_of_rows = 0;
    include APPPATH . 'views/searchpages/Form_downloadPDFCSV.php';
?>
<base href="/reports/">
<div ng-app="reports" id="ng-app">
    <div id="SQLBuilder" class="contentWrapper" ng-view></div>
</div>

<script type="text/javascript">
    var BASE_URL  = '<?php echo site_url() ?>';
    var emailFrom = '<?= htmlspecialchars($emailFrom) ?>';
   // var defaultEmailBody = '<?php //echo $emailBody ?>';
    var defaultReportTitle = '<?= htmlspecialchars($report_title) ?>';
    var defaultReportDescription = '<?= htmlspecialchars($report_description) ?>';

    var emailFrom = "<?= htmlspecialchars($emailFrom) ?>";
    var realPath = "<?php echo realpath($this->config->item('scheduled_reports_save_path')) ?>";

    var userRoles = <?php echo json_encode($roles); ?>;
    var userName = '<?= htmlspecialchars($username) ?>';


    $('.bind-datetimepicker').on('focusin', function() {
        var $this = $(this);
        if(!$this.is(':data(datetimepicker)')) {
            //this will attach a datepicker control &amp; datepicker will immediately fire
            bindDatetimepicker(this);
        }
    });

    $('.scheduleForm').on("click", '.bind-datetimepicker', function(event) {

     var params = {};
        bindDatetimepicker(this, params);
    });
    function bindDatetimepicker(elem, params) {
        var dateFormat  = 'yy-mm-dd';
        var timeFormat  = '';
        var updateScope = true;

        $(elem).datetimepicker({
            dateFormat: dateFormat,
            timeFormat: timeFormat,
            timezone: '+0000',
            minDate: '<?php echo date('Y-m-d') ?>',
            hourGrid  : 4,
            minuteGrid: 10,
            showHour  : false,
            showMinute: false,
            showTime  : false,
            showOn    : 'focus',
            onClose: function(dateText, inst) {
                var $elem_scope =  $(elem).scope();
                $(elem).val($.trim(dateText));
                $elem_scope.updateDayField(dateText);
            }
        });
    }
    // hide when load
    $(document).ready(function() {
        $("#SQLBuilder").show();
    });
</script>
