{extends "base_full.tpl.html"}
{block "title"}Stats{/block}
{block "page_classes"}stats{/block}

{block "content"}
{if $core.current_role == $core.roles.customer}
  {include file="`$core.crm_template_path`/customer_report.tpl.html"}
{else}
<table width="100%">
  <tr>
  {if $hide_stats != true}
    <td valign="top">
        <table width="100%" class="bordered">
          <tr>
            <td>
              <span><b>{t}Overall Stats{/t}</b></span><br />
              <span>
              <label for="hide_closed"><input type="checkbox" id="hide_closed" name="hide_closed" {if $hide_closed}checked{/if}> {t}Hide Closed Issues{/t}</label>
              </span>
            </td>
          </tr>
          <tr>
            <td nowrap>
              <b>{t}Issues by Status{/t}:</b>
              <br /><br />
              <table width="100%">
                {section name="i" loop=$status}
                <tr>
                  <td><a href="list.php?keywords=&users=&category=&release=&priority=&status={$status[i].iss_sta_id}">{$status[i].sta_title|escape:"html"}</a></td>
                  <td align="right">{$status[i].total_items}</td>
                </tr>
                {sectionelse}
                <tr>
                  <td>{t}No issues could be found.{/t}</td>
                </tr>
                {/section}
              </table>
              <br /><br />
              <b>{t}Issues by Release{/t}:</b>
              <br /><br />
              <table width="100%">
                {section name="i" loop=$releases}
                <tr>
                  <td><a href="list.php?keywords=&users=&category=&status=&priority=&release={$releases[i].iss_pre_id}">{$releases[i].pre_title|escape:"html"}</a></td>
                  <td align="right">{$releases[i].total_open_items}{if !$hide_closed} / {$releases[i].total_closed_items}{/if}</td>
                </tr>
                {sectionelse}
                <tr>
                  <td>{t}No issues could be found.{/t}</td>
                </tr>
                {/section}
              </table>
              <br /><br />
              <b>{t}Issues by Priority{/t}:</b>
              <br /><br />
              <table width="100%">
                {section name="i" loop=$priorities}
                <tr>
                  <td><a href="list.php?keywords=&users=&category=&release=&status=&priority={$priorities[i].iss_pri_id}">{$priorities[i].pri_title|escape:"html"}</a></td>
                  <td align="right">{$priorities[i].total_open_items}{if !$hide_closed} / {$priorities[i].total_closed_items}{/if}</td>
                </tr>
                {sectionelse}
                <tr>
                  <td>{t}No issues could be found.{/t}</td>
                </tr>
                {/section}
              </table>
              <br /><br />
              <b>{t}Issues by Category{/t}:</b>
              <br /><br />
              <table width="100%">
                {section name="i" loop=$categories}
                <tr>
                  <td><a href="list.php?keywords=&users=&category={$categories[i].iss_prc_id}&status=&priority=&release=">{$categories[i].prc_title|escape:"html"}</a></td>
                  <td align="right">{$categories[i].total_open_items}{if !$hide_closed} / {$categories[i].total_closed_items}{/if}</td>
                </tr>
                {sectionelse}
                <tr>
                  <td>{t}No issues could be found.{/t}</td>
                </tr>
                {/section}
              </table>
              <br /><br />
              <b>{t}Assigned Issues{/t}:</b>
              <br /><br />
              <table width="100%">
                {section name="i" loop=$users}
                <tr>
                  <td><a href="list.php?keywords=&category=&release=&status=&priority=&users={$users[i].isu_usr_id}">{if $users[i].usr_status != 'active'}<strike>{/if}{$users[i].usr_full_name|escape:html}{if $users[i].usr_status != 'active'}</strike>{/if}</a></td>
                  <td align="right">{$users[i].total_open_items}{if !$hide_closed} / {$users[i].total_closed_items}{/if}</td>
                </tr>
                {sectionelse}
                <tr>
                  <td>{t}No issues could be found.{/t}</td>
                </tr>
                {/section}
              </table>
              {if $core.app_setup.support_email == 'enabled' and $core.current_role > $core.roles.reporter}
              <br /><br />
              <b>{t}Emails{/t}:</b>
              <br /><br />
              <table width="100%" border="0" cellpadding="0" cellspacing="0">
                <tr>
                  <td><a href="emails.php?hide_associated=0">{t}Associated{/t}</a></td>
                  <td align="right">{$emails.associated}</td>
                </tr>
                <tr>
                  <td><a href="emails.php?hide_associated=1">{t}Pending{/t}</a></td>
                  <td align="right">{$emails.pending}</td>
                </tr>
                <tr>
                  <td>{t}Removed{/t}</td>
                  <td align="right">{$emails.removed}</td>
                </tr>
              </table>
              {/if}
            </td>
          </tr>
        </table>
    </td>
    <td>
      &nbsp;
    </td>
    {/if}
    <td width="80%" valign="top">
      {include file="latest_news.tpl.html"}
      {if $pie_chart && $hide_stats != true}
            <table class="bordered">
              <tr>
                <td>
                  <span><b>{t}Graphical Stats{/t}
                  {if $hide_closed}
                    {t}(Open Issues){/t}
                  {else}
                    {t}(All Issues){/t}
                  {/if}
                  </b> </span>
                </td>
              </tr>
              <tr>
                <td class="light">
                  <img border="0" src="{$core.rel_url}stats_chart.php?plot=status&hide_closed={$hide_closed}">
                  <img border="0" src="{$core.rel_url}stats_chart.php?plot=priority&hide_closed={$hide_closed}">
                  <img border="0" src="{$core.rel_url}stats_chart.php?plot=user&hide_closed={$hide_closed}">
                  <img border="0" src="{$core.rel_url}stats_chart.php?plot=release&hide_closed={$hide_closed}">
                  <img border="0" src="{$core.rel_url}stats_chart.php?plot=category&hide_closed={$hide_closed}">
                </td>
              </tr>
            </table>
      {/if}
    </td>
  </tr>
</table>
{/if}
{/block}