<script data-cfasync="false" type="text/javascript">
  report = {};
  $(document).ready(function(){
      <?php if ($this->graph_name) { ?>
        clientexec.populate_report("<?php echo $this->graph_name;?>",'#myChart');
      <?php } ?>
  });

  <?php if ($this->showCheckBoxPermissionOptions) { ?>
    function UpdatePublic(objCheck)
    {
        if(objCheck.checked) value=1;
        else value=0;

        $.ajax({
            url: 'index.php?fuse=reports&action=updatepublic',
            success: function(t) {
                ce.parseResponse(t);
            },
            data: {reporttype : '<?php echo $this->REPORTTYPE; ?>',
                reportname : '<?php echo $this->REPORTNAME; ?>',
                publishvalue : value
            }
        })
    }
  <?php } ?>;

  report.ShowGrid = function(data)
  {
      if (data.length > 0) {
          var template = "<div class='report-data-table' style='overflow-x:scroll'>" +
                              "{{#arr}}<div id='{{groupId}}' class='report-group-table {{#istotal}}istotal{{/istotal}}' style='display:{{#isHidden}}none{{/isHidden}};' >" +
                                  "<div class='report-group-name'>{{groupname}}</div>" +
                                  "<table class='table table-striped table-group-header'>" +
                                      "<thead><tr>{{#label}}<th style='white-space: nowrap; overflow: hidden;'>{{{.}}}</th>{{/label}}</tr></thead>" +
                                      "<tbody>" +
                                          "{{#group}}<tr>{{#.}}<td style='white-space: nowrap; overflow: hidden;{{colStyle}}'>{{{.}}}</td>{{/.}}</tr>{{/group}}" +
                                      "</tbody>" +
                                  "</table>" +
                              "</div>{{/arr}}"+
                          "</div>";

          var output = Mustache.render(template, {arr:data});
          $('#report_datarows').append(output);
      }

  }
</script>

<div class="alert alert-info ce-page-header">
  <div class="alert-header"><?php echo $this->user->lang("Report Management"); ?></div>
  <p class="alert-content"><?php echo $this->user->lang("The reports available below can be found in your plugins/reports directory."); ?></p>
</div>

<div class="blue-box">

    <table class="automation">
        <tbody>
            <tr>
                <td width="300">
                    <select onchange="jumpMenu('self',this,0);" style="width: 240px;display:none">
                        <option value="0"> <?php echo $this->user->lang("Select a report.."); ?></option>
                        <?php foreach ($this->reports as $report) { ?>
                            <option <?php echo $report['REPORTSELECTED']; ?> value="<?php echo $report['REPORTURL']; ?>"> <?php echo $this->user->lang($report['REPORTNAME']) ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <?php } ?>
                    </select>&nbsp;&nbsp;
                </td>
                <td align='left' style="height:30px;">

                        <?php if ($this->showCheckBoxPermissionOptions) { ?>
                          <form method=post action=index.php name='report_options'>
                            <input type=checkbox onclick='UpdatePublic(this);' name='public' <?php echo $this->PUBLICCHECKED; ?>>&nbsp;<span data-toggle="tooltip" class="tip-target" title="<?php echo $this->user->lang("If checked, the report will be visible to staff having access to the Reports. Additionally if report has a graph, it will be visible to all staff members") ;?>"><?php echo $this->user->lang("Available to all staff?"); ?></span>
                            </form>
                        <?php } ?>
                </td>
            </tr>
        </tbody>
    </table>

</div>

<br/>

<?php if ($this->graph_name) { ?>
<div class="graph-wrapper">
    <figure style="padding-left:0; margin-left:0; width: 98%; height: 300px;" id="myChart"></figure>
</div>
<?php } ?>
