{capture assign="extra_title"}{t}Recent Activity{/t}{/capture}
{include file="header.tpl.html" extra_title=$extra_title}
<script language="javascript">
{include file="$app_path/js/httpclient.js"}
{include file="$app_path/js/expandable_cell.js"}
</script>
<br />
<form method="post" action="{$smarty.server.PHP_SELF}" name="recent_activity">
<input type="hidden" name="cat" value="generate">
<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td bgcolor="{$cell_color}" colspan="2" class="default_white">
            <b>{t}Recent Activity Report{/t}</b>
          </td>
        </tr>
        <tr>
          <td width="120" class="default">
            <b>{t}Report Type{/t}:</b>
          </td>
          <td width="200" class="default" NOWRAP>
            <input type="radio" name="report_type" value="recent" class="default" {if $smarty.request.report_type!='range'}checked{/if} onClick="changeType('recent');">
                <a id="link" class="link" href="javascript:void(null)"
                            onClick="javascript:checkRadio('recent_activity', 'report_type', 0);changeType('recent');">{t}Recent{/t}</a>&nbsp;
            <input type="radio" name="report_type" value="range" {if $smarty.request.report_type=='range'}CHECKED{/if} onClick="changeType('range');">
                <a id="link" class="link" href="javascript:void(null)"
                            onClick="javascript:checkRadio('recent_activity', 'report_type', 1);changeType('range');">{t}Date Range{/t}</a>&nbsp;
          </td>
        </tr>
        <tr>
          <td width="120" class="default">
            <b>{t}Activity Type{/t}:</b>
          </td>
          <td width="200">
            <select name="activity_types[]" size="5" multiple class="default">
              {html_options options=$type_list selected=$activity_types}
            </select>
          </td>
        </tr>
        <tr id="recent_row">
          <td width="120" class="default">
            <b>{t}Activity in Past{/t}:</b>
          </td>
          <td width="200">
            <input type="text" size="3" name="amount" value="{$amount|default:24}" class="default" style="text-align: right">&nbsp;
            <select name="unit" class="default">
                {html_options options=$units selected=$unit}
            </select>
          </td>
        </tr>
        <tr id="start_row">
          <td width="120" class="default">
            <b>{t}Start{/t}:</b>
          </td>
          <td width="200">
            {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 id="end_row">
          <td width="120" class="default">
            <b>{t}End{/t}:</b>
          </td>
          <td width="200">
            {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>
          <td width="120" class="default">
            <b>{t}Developer{/t}:</b>
          </td>
          <td width="200">
            <select class="default" name="developer">
                <option value="" label="All">{t}All{/t}</option>
                {html_options options=$users selected=$developer}
            </select>
          </td>
        </tr>
        <tr>
          <td width="120" class="default">
            <b>{t}Sort Order{/t}:</b>
          </td>
          <td width="200">
            <select class="default" name="sort_order">
                <option value="ASC" label="Ascending" {if $smarty.request.sort_order != 'DESC'}selected{/if}>{t}Ascending{/t}</option>
                <option value="DESC" label="Descending" {if $smarty.request.sort_order == 'DESC'}selected{/if}>{t}Descending{/t}</option>
            </select>
          </td>
        </tr>
        <tr>
          <td align="center" colspan="2">
            <input type="submit" value="{t}Generate{/t}" class="shortcut">
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
</form>
<script language="JavaScript">
{literal}
function changeType(type) {
    if (type == 'range') {
        document.getElementById('recent_row').style.display = 'none';
        document.getElementById('start_row').style.display = getDisplayStyle();
        document.getElementById('end_row').style.display = getDisplayStyle();
    } else {
        document.getElementById('recent_row').style.display = getDisplayStyle();
        document.getElementById('start_row').style.display = 'none';
        document.getElementById('end_row').style.display = 'none';
    }
}
{/literal}

changeType('{$smarty.request.report_type}');
</script>

{if $data|@count > 0}
{if $data.phone != ''}
<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td bgcolor="{$cell_color}" colspan="{if $has_customer_integration}8{else}7{/if}" class="default_white">
            <b>{t}Recent Phone Calls{/t}</b>
          </td>
        </tr>
        <tr>
          <td bgcolor="{$cell_color}" class="default_white" NOWRAP>{include file="expandable_cell/buttons.tpl.html" remote_func="getPhoneSupport" ec_id="phone"}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Issue ID{/t}</td>
          {if $has_customer_integration}
          <td bgcolor="{$cell_color}" class="default_white">{t}Customer{/t}</td>
          {/if}
          <td bgcolor="{$cell_color}" class="default_white">{t}Date{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Developer{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Type{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Line{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Description{/t}</td>
        </tr>
        {foreach from=$data.phone item=row}
        {cycle values=$cycle assign="row_color"}
        <tr>
          <td class="default" bgcolor="{$row_color}" NOWRAP>{include file="expandable_cell/buttons.tpl.html" ec_id="phone" list_id=$row.phs_id}</td>
          <td class="default" bgcolor="{$row.sta_color}" align="right">
            <a target="_blank" href="{$rel_url}view.php?id={$row.phs_iss_id}" class="link">{$row.phs_iss_id}</a>
          </td>
          {if $has_customer_integration}
          <td class="default" bgcolor="{$row_color}">{$row.customer}</td>
          {/if}
          <td class="default" bgcolor="{$row_color}" nowrap>{$row.date}</td>
          <td class="default" bgcolor="{$row_color}">{$row.usr_full_name}</td>
          <td class="default" bgcolor="{$row_color}">{$row.phs_type}</td>
          <td class="default" bgcolor="{$row_color}">{$row.phc_title}</td>
          <td class="default" bgcolor="{$row_color}">{$row.phs_description|nl2br}</td>
        </tr>
        {include file="expandable_cell/body.tpl.html" ec_id="phone" list_id=$row.phs_id colspan="8"}
        {foreachelse}
        <tr>
            <td colspan="8" class="default" align="center" bgcolor="{$dark_color}"><i>{t}No Phone Calls Found{/t}</i></td>
        </tr>
        {/foreach}
      </table>
    </td>
  </tr>
</table>
<br />
{/if}

{if $data.note != ''}
<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td bgcolor="{$cell_color}" colspan="{if $has_customer_integration}6{else}5{/if}" class="default_white">
            <b>{t}Recent Notes{/t}</b>
          </td>
        </tr>
        <tr>
          <td bgcolor="{$cell_color}" class="default_white" nowrap>{include file="expandable_cell/buttons.tpl.html" remote_func="getNote" ec_id="note"}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Issue ID{/t}</td>
          {if $has_customer_integration}
          <td bgcolor="{$cell_color}" class="default_white">{t}Customer{/t}</td>
          {/if}
          <td bgcolor="{$cell_color}" class="default_white">{t}Posted Date{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}User{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Title{/t}</td>
        </tr>
        {foreach from=$data.note item=row}
        {cycle values=$cycle assign="row_color"}
        <tr>
          <td class="default" bgcolor="{$row_color}" NOWRAP>{include file="expandable_cell/buttons.tpl.html" ec_id="note" list_id=$row.not_id}</td>
          <td class="default" bgcolor="{$row.sta_color}" align="right">
            <a target="_blank" href="{$rel_url}view.php?id={$row.not_iss_id}" class="link" title="{$row.iss_summary|htmlspecialchars}">{$row.not_iss_id}</a>
          </td>
          {if $has_customer_integration}
          <td class="default" bgcolor="{$row_color}">{$row.customer}</td>
          {/if}
          <td class="default" bgcolor="{$row_color}" nowrap>{$row.date}</td>
          <td class="default" bgcolor="{$row_color}">{$row.usr_full_name}</td>
          <td class="default" bgcolor="{$row_color}">{$row.not_title|nl2br}</td>
        </tr>
        {include file="expandable_cell/body.tpl.html" ec_id="note" list_id=$row.not_id colspan="6"}
        {foreachelse}
        <tr>
            <td colspan="6" class="default" align="center" bgcolor="{$dark_color}"><i>{t}No Notes Found{/t}</i></td>
        </tr>
        {/foreach}
      </table>
    </td>
  </tr>
</table>
<br />
{/if}

{if $data.email != ''}
<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td bgcolor="{$cell_color}" colspan="{if $has_customer_integration}7{else}6{/if}" class="default_white">
            <b>{t}Recent Emails{/t}</b>
          </td>
        </tr>
        <tr>
          <td bgcolor="{$cell_color}" class="default_white" align="center" NOWRAP>{include file="expandable_cell/buttons.tpl.html" ec_id="email" remote_func="getEmail"}</td>
          <td bgcolor="{$cell_color}" class="default_white" nowrap>{t}Issue ID{/t}</td>
          {if $has_customer_integration}
          <td bgcolor="{$cell_color}" class="default_white">{t}Customer{/t}</td>
          {/if}
          <td bgcolor="{$cell_color}" class="default_white">{t}From{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}To{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Date{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Subject{/t}</td>
        </tr>
        {foreach from=$data.email item=row}
        {cycle values=$cycle assign="row_color"}
        <tr>
          <td align="center" bgcolor="{$row_color}" NOWRAP align="center">
            {include file="expandable_cell/buttons.tpl.html" ec_id="email" list_id=$row.composite_id}
          </td>
          <td class="default" bgcolor="{$row.sta_color}" align="right">
            <a target="_blank" href="{$rel_url}view.php?id={$row.sup_iss_id}" class="link" title="{$row.iss_summary|htmlspecialchars}">{$row.sup_iss_id}</a>
          </td>
          {if $has_customer_integration}
          <td class="default" bgcolor="{$row_color}">{$row.customer}</td>
          {/if}
          <td class="default" bgcolor="{$row_color}">{$row.sup_from|escape:"html"}</td>
          <td class="default" bgcolor="{$row_color}">
            {if $row.sup_to == ""}
              <i>{t}sent to notification list{/t}</i>
            {else}
              {$row.sup_to|escape:"html"}
            {/if}
          </td>
          <td class="default" bgcolor="{$row_color}" nowrap>{$row.date}</td>
          <td class="default" bgcolor="{$row_color}">{$row.sup_subject|nl2br}</td>
        </tr>
        {include file="expandable_cell/body.tpl.html" ec_id="email" list_id=$row.composite_id colspan=7 row_color=$row_color}
        {foreachelse}
        <tr>
            <td colspan="7" class="default" align="center" bgcolor="{$dark_color}"><i>{t}No Emails Found{/t}</i></td>
        </tr>
        {/foreach}
      </table>
    </td>
  </tr>
</table>
<br />
{/if}

{if $data.draft != ''}
<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td bgcolor="{$cell_color}" colspan="{if $has_customer_integration}8{else}7{/if}" class="default_white">
            <b>{t}Recent Drafts{/t}</b>
          </td>
        </tr>
        <tr>
          <td bgcolor="{$cell_color}" class="default_white" NOWRAP>{include file="expandable_cell/buttons.tpl.html" remote_func="getDraft" ec_id="draft"}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Issue ID{/t}</td>
          {if $has_customer_integration}
          <td bgcolor="{$cell_color}" class="default_white">{t}Customer{/t}</td>
          {/if}
          <td bgcolor="{$cell_color}" class="default_white">{t}Status{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}From{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}To{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Date{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Subject{/t}</td>
        </tr>
        {foreach from=$data.draft item=row}
        {cycle values=$cycle assign="row_color"}
        <tr {if $row.emd_status != 'pending'}style="text-decoration: line-through;"{/if}>
          <td class="default" NOWRAP bgcolor="{$row_color}">{include file="expandable_cell/buttons.tpl.html" ec_id="draft" list_id=$row.emd_id}</td>
          <td class="default" bgcolor="{$row.sta_color}" align="right">
            <a target="_blank" href="{$rel_url}view.php?id={$row.emd_iss_id}" class="link">{$row.emd_iss_id}</a>
          </td>
          {if $has_customer_integration}
          <td class="default" bgcolor="{$row_color}">{$row.customer}</td>
          {/if}
          <td class="default" bgcolor="{$row_color}">{$row.emd_status}</td>
          <td class="default" bgcolor="{$row_color}">{$row.from|escape:"html"}</td>
          <td class="default" bgcolor="{$row_color}">{$row.to|escape:"html"}</td>
          </td>
          <td class="default" bgcolor="{$row_color}" nowrap>{$row.date}</td>
          <td class="default" bgcolor="{$row_color}">{$row.emd_subject|nl2br}</td>
        </tr>
        {include file="expandable_cell/body.tpl.html" ec_id="draft" list_id=$row.emd_id colspan=8}
        {foreachelse}
        <tr>
            <td colspan="8" class="default" align="center" bgcolor="{$dark_color}"><i>{t}No Drafts Found{/t}</i></td>
        </tr>
        {/foreach}
      </table>
    </td>
  </tr>
</table>
<br />
{/if}

{if $data.time != ''}
<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td bgcolor="{$cell_color}" colspan="{if $has_customer_integration}7{else}6{/if}" class="default_white">
            <b>{t}Recent Time Entries{/t}</b>
          </td>
        </tr>
        <tr>
          <td bgcolor="{$cell_color}" class="default_white">{t}Issue ID{/t}</td>
          {if $has_customer_integration}
          <td bgcolor="{$cell_color}" class="default_white">{t}Customer{/t}</td>
          {/if}
          <td bgcolor="{$cell_color}" class="default_white">{t}Date of Work{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}User{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Time Spent{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Category{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Summary{/t}</td>
        </tr>
        {foreach from=$data.time item=row}
        {cycle values=$cycle assign="row_color"}
        <tr>
          <td class="default" bgcolor="{$row.sta_color}" align="right">
            <a target="_blank" href="{$rel_url}view.php?id={$row.ttr_iss_id}" class="link" title="{$row.iss_summary|htmlspecialchars}">{$row.ttr_iss_id}</a>
          </td>
          {if $has_customer_integration}
          <td class="default" bgcolor="{$row_color}">{$row.customer}</td>
          {/if}
          <td class="default" bgcolor="{$row_color}" nowrap>{$row.date}</td>
          <td class="default" bgcolor="{$row_color}">{$row.usr_full_name}</td>
          <td class="default" bgcolor="{$row_color}">{$row.time_spent}</td>
          <td class="default" bgcolor="{$row_color}">{$row.ttc_title}</td>
          <td class="default" bgcolor="{$row_color}">{$row.ttr_summary|nl2br}</td>
        </tr>
        {foreachelse}
        <tr>
            <td colspan="7" class="default" align="center" bgcolor="{$dark_color}"><i>{t}No Time Entries Found{/t}</i></td>
        </tr>
        {/foreach}
      </table>
    </td>
  </tr>
</table>
<br />
{/if}

{if $data.reminder != ''}
<table bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td bgcolor="{$cell_color}" colspan="{if $has_customer_integration}4{else}3{/if}" class="default_white">
            <b>{t}Recent Reminder Actions{/t}</b>
          </td>
        </tr>
        <tr>
          <td bgcolor="{$cell_color}" class="default_white">{t}Issue ID{/t}</td>
          {if $has_customer_integration}
          <td bgcolor="{$cell_color}" class="default_white">{t}Customer{/t}</td>
          {/if}
          <td bgcolor="{$cell_color}" class="default_white">{t}Date Triggered{/t}</td>
          <td bgcolor="{$cell_color}" class="default_white">{t}Title{/t}</td>
        </tr>
        {foreach from=$data.reminder item=row}
        {cycle values=$cycle assign="row_color"}
        <tr>
          <td class="default" bgcolor="{$row.sta_color}" align="right">
            <a target="_blank" href="{$rel_url}view.php?id={$row.rmh_iss_id}" class="link">{$row.rmh_iss_id}</a>
          </td>
          {if $has_customer_integration}
          <td class="default" bgcolor="{$row_color}">{$row.customer}</td>
          {/if}
          <td class="default" bgcolor="{$row_color}" nowrap>{$row.date}</td>
          <td class="default" bgcolor="{$row_color}">{$row.rma_title}</td>
        {foreachelse}
        <tr>
            <td colspan="7" class="default" align="center" bgcolor="{$dark_color}"><i>{t}No Reminder Entries Found{/t}</i></td>
        </tr>
        {/foreach}
      </table>
    </td>
  </tr>
</table>
<br />
{/if}
{/if}
<br />
{include file="footer.tpl.html"}