{include file="header.tpl.html"}

{if $result_msg != ''}
<br />
<center>
  <span class="default">
{if $result_msg == -1}
  <b>{t}An error occurred while trying to run your query{/t}</b>
{elseif $result_msg == 1}
  <b>{t}Thank you, the emails were {if $smarty.post.cat == 'remove'}removed{else}restored{/if} successfully{/t}</b>
{/if}
  </span>
</center>
<script language="JavaScript">
<!--
opener.location.href = opener.location;
setTimeout('window.close()', 2000);
//-->
</script>
{else}
<br />
<table width="100%" bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2">
        <tr>
          <td class="default">
            <b>{t}Removed Emails{/t}</b>
          </td>
        </tr>
        <tr>
          <td>
            {literal}
            <script language="">
            <!--
            function validateForm(f)
            {
                if (!hasOneChecked(f, 'item[]')) {
                    alert('{/literal}{t escape=js}Please choose which emails need to be restored.{/t}{literal}');
                    return false;
                }
                f.submit();
            }
            function removeEmails(f)
            {
                if (!hasOneChecked(f, 'item[]')) {
                    alert('{/literal}{t escape=js}Please choose which emails need to be permanently removed.{/t}{literal}');
                    return false;
                }
                if (!confirm('{/literal}{t escape=js}WARNING: This action will permanently remove the selected emails from your email account.{/t}{literal}')) {
                    return false;
                } else {
                    f.cat.value = 'remove';
                    f.submit();
                }
            }
            //-->
            </script>
            {/literal}
            <form method="post" action="{$smarty.server.PHP_SELF}">
            <input type="hidden" name="cat" value="restore">
            <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2">
              <tr>
                <td width="1%" bgcolor="{$cell_color}">
                  <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');">
                </td>
                <td bgcolor="{$cell_color}" class="default_white">{t}Date{/t}</td>
                <td bgcolor="{$cell_color}" width="20%" class="default_white">{t}From{/t}</td>
                <td bgcolor="{$cell_color}" width="50%" class="default_white">{t}Subject{/t}</td>
              </tr>
              {section name="i" loop=$list}
              {cycle values=$cycle assign="row_color"}
              <tr>
                <td width="1%" align="center" bgcolor="{$row_color}">
                  <input type="checkbox" name="item[]" value="{$list[i].sup_id}">
                </td>
                <td align="center" bgcolor="{$row_color}" class="default" nowrap>
                  {$list[i].sup_date}
                </td>
                <td bgcolor="{$row_color}" width="20%" class="default">
                  {$list[i].sup_from|escape:"html"}
                </td>
                <td bgcolor="{$row_color}" width="50%" class="default">
                  {$list[i].sup_subject|escape:"html"}
                </td>
              </tr>
              {sectionelse}
              <tr>
                <td colspan="4" bgcolor="{$light_color}" class="default" align="center">
                  <i>{t}No emails could be found.{/t}</i>
                </td>
              </tr>
              {/section}
              <tr>
                <td bgcolor="{$cell_color}" width="1%" align="center">
                  <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');">
                </td>
                <td colspan="3" bgcolor="{$cell_color}">
                  <input type="button" class="button" value="{t}Restore Emails{/t}" onClick="javascript:validateForm(this.form);">
                  <input type="button" class="button" value="{t}Close{/t}" onClick="javascript:window.close();">
                </td>
              </tr>
              <tr>
                <td colspan="4" bgcolor="{$dark_color}" align="left">
                  <input type="button" class="button" value="{t}Permanently Remove{/t}" onClick="javascript:removeEmails(this.form);">
                </td>
              </tr>
            </table>
            </form>
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<br />
{include file="app_info.tpl.html"}
{/if}

{include file="footer.tpl.html"}
