Skip to content
Snippets Groups Projects
dashboard.inc.php 4.43 KiB
Newer Older
Jared Hancock's avatar
Jared Hancock committed
<?php
$report = new OverviewReport($_POST['start'], $_POST['period']);
$plots = $report->getPlotData();

?>
<script type="text/javascript" src="js/raphael-min.js"></script>
<script type="text/javascript" src="js/g.raphael.js"></script>
<script type="text/javascript" src="js/g.line-min.js"></script>
<script type="text/javascript" src="js/g.dot-min.js"></script>
<script type="text/javascript" src="js/dashboard.inc.js"></script>

<link rel="stylesheet" type="text/css" href="css/dashboard.css"/>

<form method="post" action="dashboard.php">
<div id="basic_search">
    <div style="min-height:25px;">
        <!--<p><?php //echo __('Select the starting time and period for the system activity graph');?></p>-->
Jared Hancock's avatar
Jared Hancock committed
            <?php echo csrf_token(); ?>
Jared Hancock's avatar
Jared Hancock committed
                <input type="text" class="dp input-medium search-query" name="start" placeholder="<?php echo __('Last month');?>"i
                    value="<?php echo Format::htmlchars($_POST['start']); ?>" />
            </label>
            <label>
                <?php echo __( 'period');?>:
                <select name="period">
                    <option value="now" selected="selected">
                        <?php echo __( 'Up to today');?>
                    </option>
                    <option value="+7 days">
                        <?php echo __( 'One Week');?>
                    </option>
                    <option value="+14 days">
                        <?php echo __( 'Two Weeks');?>
                    </option>
                    <option value="+1 month">
                        <?php echo __( 'One Month');?>
                    </option>
                    <option value="+3 months">
                        <?php echo __( 'One Quarter');?>
                    </option>
                </select>
            </label>
            <button class="green button action-button muted" type="submit">
                <?php echo __( 'Refresh');?>
            </button>
            <i class="help-tip icon-question-sign" href="#report_timeframe"></i>
    </div>
</div>
<div class="clear"></div>
<div style="margin-bottom:20px; padding-top:5px;">
    <div class="pull-left flush-left">
        <h2><?php echo __('Ticket Activity');
            ?>&nbsp;<i class="help-tip icon-question-sign" href="#ticket_activity"></i></h2>
    </div>
</div>
<div class="clear"></div>
<!-- Create a graph and fetch some data to create pretty dashboard -->
<div style="position:relative">
    <div id="line-chart-here" style="height:300px"></div>
    <div style="position:absolute;right:0;top:0" id="line-chart-legend"></div>
</div>

<hr/>
<h2><?php echo __('Statistics'); ?>&nbsp;<i class="help-tip icon-question-sign" href="#statistics"></i></h2>
<p><?php echo __('Statistics of tickets organized by department, help topic, and agent.');?></p>
Jared Hancock's avatar
Jared Hancock committed

<ul class="clean tabs">
<?php
$first = true;
$groups = $report->enumTabularGroups();
foreach ($groups as $g=>$desc) { ?>
    <li class="<?php echo $first ? 'active' : ''; ?>"><a href="#<?php echo Format::slugify($g); ?>"
        ><?php echo Format::htmlchars($desc); ?></a></li>
<?php
    $first = false;
} ?>
Jared Hancock's avatar
Jared Hancock committed
$first = true;
foreach ($groups as $g=>$desc) {
    $data = $report->getTabularData($g); ?>
    <div class="tab_content <?php echo (!$first) ? 'hidden' : ''; ?>" id="<?php echo Format::slugify($g); ?>">
Nathan Febuary's avatar
Nathan Febuary committed
    <table class="dashboard-stats table"><tbody><tr>
Jared Hancock's avatar
Jared Hancock committed
<?php
    foreach ($data['columns'] as $j=>$c) { ?>
        <th <?php if ($j === 0) echo 'width="30%" class="flush-left"'; ?>><?php echo Format::htmlchars($c); ?></th>
Jared Hancock's avatar
Jared Hancock committed
<?php
    } ?>
    </tr></tbody>
    <tbody>
<?php
    foreach ($data['data'] as $i=>$row) {
        echo '<tr>';
        foreach ($row as $j=>$td) {
            if ($j === 0) { ?>
                <th class="flush-left"><?php echo Format::htmlchars($td); ?></th>
Jared Hancock's avatar
Jared Hancock committed
<?php       }
            else { ?>
                <td><?php echo Format::htmlchars($td);
                if ($td) { // TODO Add head map
                }
                echo '</td>';
            }
        }
        echo '</tr>';
    }
    $first = false; ?>
    </tbody></table>
    <div style="margin-top: 5px"><button type="submit" class="link button" name="export"
        value="<?php echo Format::htmlchars($g); ?>">
        <i class="icon-download"></i>
        <?php echo __('Export'); ?></a></div>
Jared Hancock's avatar
Jared Hancock committed
    </div>
<?php
}
?>
Jared Hancock's avatar
Jared Hancock committed
<script>
    $.drawPlots(<?php echo JsonDataEncoder::encode($report->getPlotData()); ?>);
</script>