{extends "reports/reports_base.tpl.html"}
{block "title"}{t}Workload Date Range{/t}{/block}

{block "report_content"}
<h3 align="center">
    {t}Workload by Date Range Report{/t}
</h3>
<form name="workload_report" method="post">
    <table class="bordered filters">
        {if $categories|@count > 0}
        <tr>
            <th align="right">
                {t}Category{/t}:
            </th>
            <td align="left">
                &nbsp;&nbsp;
                <select name="category">
                    <option value=""></option>
                    {html_options options=$categories selected=$category}
                </select>
            </td>
        </tr>
        {/if}
        <tr>
            <th align="right">
                {t}Type{/t}:
            </th>
            <td align="left">
                &nbsp;&nbsp;
                <select name="type" onChange="setIntervals('')">
                    {html_options options=$types selected=$type}
                </select>
            </td>
        </tr>
        <tr>
            <th align="right">
                {t}Interval{/t}:
            </th>
            <td align="left">
                &nbsp;&nbsp;
                <select name="interval">
                </select>
            </td>
        </tr>
        <tr>
            <th align="right">
                {t}Start{/t}:
            </th>
            <td align="left">
                &nbsp;&nbsp;
                {html_select_date time=$start_date prefix="" field_array="start" start_year="-2" end_year="+1" field_order="YMD" month_format="%b" all_extra="class='default'"}
            </td>
        </tr>
        <tr>
            <th align="right">
                {t}End{/t}:
            </th>
            <td align="left">
                &nbsp;&nbsp;
                {html_select_date time=$end_date prefix="" field_array="end" start_year="-2" end_year="+1" field_order="YMD" month_format="%b" all_extra="class='default'"}
            </td>
        </tr>
        <tr class="buttons">
            <td colspan="2">
                <input type="submit" name="submit" value="{t}Generate{/t}">
            </td>
        </tr>
    </table>
    <div style="color: red" align="center">
        {t escape=no}Warning: Some type and interval options, combined with large <br />date ranges can produce extremely large graphs.{/t}
    </div>
</form>
<script type="text/javascript">

    var f = document.forms["workload_report"];
    var options = new Array(2);
    options[0] = new Array(3);// individual
    options[0][0] = new Option('{t escape=js}Day{/t}', '{t}day{/t}');
    options[0][1] = new Option('{t escape=js}Week{/t}', '{t}week{/t}');
    options[0][2] = new Option('{t escape=js}Month{/t}', '{t}month{/t}');

    options[1] = new Array(4);// aggregate
    options[1][0] = new Option('{t escape=js}Day of Week{/t}', '{t}dow{/t}');
    options[1][1] = new Option('{t escape=js}Week{/t}', '{t}week{/t}');
    options[1][2] = new Option('{t escape=js}Day of Month{/t}', '{t}dom{/t}');
    options[1][3] = new Option('{t escape=js}Month{/t}', '{t}month{/t}');

    function setIntervals(selectedValue)
    {
        var i;
        f.interval.length = options[f.type.selectedIndex].length;
        for (i = 0; i < options[f.type.selectedIndex].length; i++) {
            f.interval.options[i] = options[f.type.selectedIndex][i];
            if (options[f.type.selectedIndex][i].value == selectedValue) {
                f.interval.options[i].selected = true;
            }
        }
    }

        setIntervals('{$interval}');
</script>
{if $data|default:'' != ''}
<center>
    {* TRANSLATORS: %1: project name *}
    <h3>{t 1=$core.project_name}Project: %1{/t}</h3>
</center>
<table class="bordered">
    <tr>
        <th>&nbsp;

        </th>
        <th>
            {t}Total{/t}
        </th>
        <th>
            {t}Avg{/t}
        </th>
        <th>
            {t}Med{/t}
        </th>
        <th>
            {t}Max{/t}
        </th>
    </tr>
    {foreach name="workload" from=$data key=loop_name item=row}
    <tr class="{cycle values='odd,even'}">
        <td align="center">{$loop_name}</td>
        <td align="center">{$row.stats.total}</td>
        <td align="center">{$row.stats.avg|round:2}</td>
        <td align="center">{$row.stats.median}</td>
        <td align="center">{$row.stats.max}</td>
    </tr>
    {/foreach}
</table>
<div align="center">
    {t}Avg/Med/Max Issues/Emails{/t}
    {if $interval == 'day'}
    {t}per day{/t}
    {elseif $interval == 'week'}
    {t}per week{/t}
    {elseif $interval == 'month'}
    {t}per month{/t}
    {elseif $interval == 'dow'}
    {t}per day of week{/t}
    {/if}
    {* TRANSLATORS: %1: start_date, 2: end_date *}
    {t 1=$start_date 2=$end_date}for %1 through %2{/t}.
</div>
<br />
<div align="center">
    <img src="graph.php?graph=workload_date_range&subgraph=issue&interval={$interval}&start_date={$start_date}&end_date={$end_date}&category={$category}"><br /><br />
    <img src="graph.php?graph=workload_date_range&subgraph=issue&type=pie&interval={$interval}&start_date={$start_date}&end_date={$end_date}&category={$category}"><br /><br />
    <img src="graph.php?graph=workload_date_range&subgraph=email&interval={$interval}&start_date={$start_date}&end_date={$end_date}&category={$category}"><br /><br />
    <img src="graph.php?graph=workload_date_range&subgraph=email&type=pie&interval={$interval}&start_date={$start_date}&end_date={$end_date}&category={$category}">
</div>
{/if}
{/block}
