
      <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" border="0">
              {literal}
              <script language="JavaScript">
              <!--
              function validateForm(f)
              {
                  if (f.project.selectedIndex == 0) {
                      alert('{/literal}{t escape=js}Please choose the project to be associated with this email account.{/t}{literal}');
                      selectField(f, 'project');
                      return false;
                  }
                  if (f.type.selectedIndex == 0) {
                      alert('{/literal}{t escape=js}Please choose the type of email server to be associated with this email account.{/t}{literal}');
                      selectField(f, 'type');
                      return false;
                  }
                  if (isWhitespace(f.hostname.value)) {
                      alert('{/literal}{t escape=js}Please enter the hostname for this email account.{/t}{literal}');
                      selectField(f, 'hostname');
                      return false;
                  }
                  if (isWhitespace(f.port.value)) {
                      alert('{/literal}{t escape=js}Please enter the port number for this email account.{/t}{literal}');
                      selectField(f, 'port');
                      return false;
                  }
                  if (!isNumberOnly(f.port.value)) {
                      alert('{/literal}{t escape=js}Please enter a valid port number for this email account.{/t}{literal}');
                      selectField(f, 'port');
                      return false;
                  }
                  if (!isNumberOnly(f.port.value)) {
                      alert('{/literal}{t escape=js}Please enter the port number for this email account.{/t}{literal}');
                      selectField(f, 'port');
                      return false;
                  }
                  var server_type = getSelectedOption(f, 'type');
                  if ((server_type.indexOf('imap') != -1) && (isWhitespace(f.folder.value))) {
                      alert('{/literal}{t escape=js}Please enter the IMAP folder for this email account.{/t}{literal}');
                      selectField(f, 'folder');
                      return false;
                  }
                  if (isWhitespace(f.username.value)) {
                      alert('{/literal}{t escape=js}Please enter the username for this email account.{/t}{literal}');
                      selectField(f, 'username');
                      return false;
                  }
                  if (isWhitespace(f.password.value)) {
                      alert('{/literal}{t escape=js}Please enter the password for this email account.{/t}{literal}');
                      selectField(f, 'password');
                      return false;
                  }
                  return true;
              }
              function toggleFolderField(f)
              {
                  var element = getPageElement('imap_folder');
                  var option = getSelectedOption(f, 'type');
                  if (option.indexOf('imap') != -1) {
                      element.style.display = getDisplayStyle();
                      f.folder.disabled = false;
                  } else {
                      element.style.display = 'none';
                      f.folder.disabled = true;
                  }
              }
              function testSettings(f)
              {
                  var features = 'width=320,height=200,top=30,left=30,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
                  var popupWin = window.open('', '_testEmailSettings', features);
                  popupWin.focus();
                  var old_action = f.action;
                  f.action = 'check_email_settings.php';
                  f.target = '_testEmailSettings';
                  f.submit();
                  f.action = old_action;
                  f.target = '';
              }
              //-->
              </script>
              {/literal}
              <form name="email_account_form" onSubmit="javascript:return validateForm(this);" method="post" action="{$smarty.server.PHP_SELF}">
              {if $smarty.get.cat == 'edit'}
              <input type="hidden" name="cat" value="update">
              <input type="hidden" name="id" value="{$smarty.get.id}">
              {else}
              <input type="hidden" name="cat" value="new">
              {/if}
              <tr>
                <td colspan="2" class="default">
                  <b>{t}Manage Email Accounts{/t}</b>
                </td>
              </tr>
              {if $result != ""}
              <tr>
                <td colspan="2" bgcolor="{$cell_color}" align="center" class="error">
                  {if $smarty.post.cat == "new"}
                    {if $result == -1}
                      {t}An error occurred while trying to add the new account.{/t}
                    {elseif $result == 1}
                      {t}Thank you, the email account was added successfully.{/t}
                    {/if}
                  {elseif $smarty.post.cat == "update"}
                    {if $result == -1}
                      {t}An error occurred while trying to update the account information.{/t}
                    {elseif $result == 1}
                      {t}Thank you, the account was updated successfully.{/t}
                    {/if}
                  {/if}
                </td>
              </tr>
              {/if}
              <tr>
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <nobr><b>{t}Associated Project:{/t}</b></nobr>
                </td>
                <td bgcolor="{$light_color}" width="80%">
                  <select name="project" class="default">
                    <option value="-1"></option>
                    {html_options options=$all_projects selected=$info.ema_prj_id}
                  </select>
                  {include file="error_icon.tpl.html" field="project"}
                </td>
              </tr>
              <tr>
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Type:{/t}</b>
                </td>
                <td bgcolor="{$light_color}" width="80%">
                  <select name="type" class="default" onChange="javascript:toggleFolderField(this.form);">
                    <option value="-1"></option>
                    <option value="imap" {if $info.ema_type == 'imap'}selected{/if}>{t}IMAP{/t}</option>
                    <option value="imap/ssl" {if $info.ema_type == 'imap/ssl'}selected{/if}>{t}IMAP over SSL{/t}</option>
                    <option value="imap/ssl/novalidate-cert" {if $info.ema_type == 'imap/ssl/novalidate-cert'}selected{/if}>{t}IMAP over SSL (self-signed){/t}</option>
                    <option value="imap/notls" {if $info.ema_type == 'imap/notls'}selected{/if}>{t}IMAP, no TLS{/t}</option>
                    <option value="imap/tls" {if $info.ema_type == 'imap/tls'}selected{/if}>{t}IMAP, with TLS{/t}</option>
                    <option value="imap/tls/novalidate-cert" {if $info.ema_type == 'imap/tls/novalidate-cert'}selected{/if}>{t}IMAP, with TLS (self-signed){/t}</option>
                    <option value="pop3" {if $info.ema_type == 'pop3'}selected{/if}>{t}POP3{/t}</option>
                    <option value="pop3/ssl" {if $info.ema_type == 'pop3/ssl'}selected{/if}>{t}POP3 over SSL{/t}</option>
                    <option value="pop3/ssl/novalidate-cert" {if $info.ema_type == 'pop3/ssl/novalidate-cert'}selected{/if}>{t}POP3 over SSL (self-signed){/t}</option>
                    <option value="pop3/notls" {if $info.ema_type == 'pop3/notls'}selected{/if}>{t}POP3, no TLS{/t}</option>
                    <option value="pop3/tls" {if $info.ema_type == 'pop3/tls'}selected{/if}>{t}POP3, with TLS{/t}</option>
                    <option value="pop3/tls/novalidate-cert" {if $info.ema_type == 'pop3/tls/novalidate-cert'}selected{/if}>{t}POP3, with TLS (self-signed){/t}</option>
                  </select>
                </td>
              </tr>
              <tr>
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Hostname:{/t}</b>
                </td>
                <td bgcolor="{$light_color}" width="80%">
                  <input type="text" class="default" name="hostname" size="30" value="{$info.ema_hostname|escape:"html"}">
                  {include file="error_icon.tpl.html" field="hostname"}
                </td>
              </tr>
              <tr>
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Port:{/t}</b>
                </td>
                <td bgcolor="{$light_color}" width="80%">
                  <input type="text" class="default" name="port" size="10" value="{$info.ema_port}"> <span class="default">{t}(Tip: port defaults are 110 for POP3 servers and 143 for IMAP ones){/t}</span>
                  {include file="error_icon.tpl.html" field="port"}
                </td>
              </tr>
              <tr id="imap_folder">
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}IMAP Folder:{/t}</b>
                </td>
                <td bgcolor="{$light_color}" width="80%">
                  <input type="text" class="default" name="folder" size="20" value="{if $info.ema_folder == ""}INBOX{else}{$info.ema_folder}{/if}"> <span class="default">{t}(default folder is INBOX){/t}</span>
                  {include file="error_icon.tpl.html" field="folder"}
                </td>
              </tr>
              <tr>
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Username:{/t}</b>
                </td>
                <td bgcolor="{$light_color}" width="80%">
                  <input type="text" class="default" name="username" size="20" value="{$info.ema_username|escape:"html"}">
                  {include file="error_icon.tpl.html" field="username"}
                </td>
              </tr>
              <tr>
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Password:{/t}</b>
                </td>
                <td bgcolor="{$light_color}" width="80%">
                  <input type="password" class="default" name="password" size="20" value="{$info.ema_password|escape:"html"}">
                  {include file="error_icon.tpl.html" field="password"}
                </td>
              </tr>
              <tr>
                <td width="100" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Advanced Options:{/t}</b>
                </td>
                <td bgcolor="{$light_color}" width="80%" class="default">
                  <input type="checkbox" name="get_only_new" value="1" {if $info.ema_get_only_new}checked{/if}>
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('email_account_form', 'get_only_new', 0);">{t}Only Download Unread Messages{/t}</a><br />
                  <input type="checkbox" name="leave_copy" value="1" {if $smarty.get.cat == 'edit'}{if $info.ema_leave_copy}checked{/if}{else}checked{/if}>
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('email_account_form', 'leave_copy', 0);">{t}Leave Copy of Messages On Server{/t}</a><br />
                  <input type="checkbox" name="use_routing" value="1" {if $info.ema_use_routing}checked{/if}>
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('email_account_form', 'use_routing', 0);">{t escape="none"}Use account for non-subject based email/note/draft routing.
                    <b> Note: </b>If you check this, you cannot leave a copy of messages on the server.</a>{/t}
                </td>
              </tr>
              <tr>
                <td colspan="2" bgcolor="{$cell_color}" align="center">
                  <input class="button" type="button" value="{t}Test Settings{/t}" onClick="javascript:testSettings(this.form);">
                  {if $smarty.get.cat == 'edit'}
                  <input class="button" type="submit" value="{t}Update Account{/t}">
                  {else}
                  <input class="button" type="submit" value="{t}Create Account{/t}">
                  {/if}
                  <input class="button" type="reset" value="{t}Reset{/t}">
                </td>
              </tr>
              </form>
              <tr>
                <td colspan="2" class="default">
                  <b>{t}Existing Accounts:{/t}</b>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  {literal}
                  <script language="JavaScript">
                  <!--
                  function checkDelete(f)
                  {
                      if (!hasOneChecked(f, 'items[]')) {
                          alert('{/literal}{t escape=js}Please select at least one of the accounts.{/t}{literal}');
                          return false;
                      }
                      if (!confirm('{/literal}{t escape=js}This action will remove the selected entries.{/t}{literal}')) {
                          return false;
                      } else {
                          return true;
                      }
                  }
                  //-->
                  </script>
                  {/literal}
                  <table border="0" width="100%" cellpadding="1" cellspacing="1">
                    <form onSubmit="javascript:return checkDelete(this);" method="post" action="{$smarty.server.PHP_SELF}">
                    <input type="hidden" name="cat" value="delete">
                    <tr>
                      <td width="4" bgcolor="{$cell_color}" nowrap><input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'items[]');"></td>
                      <td bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Associated Project{/t}</b></td>
                      <td bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Hostname{/t}</b></td>
                      <td bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Type{/t}</b></td>
                      <td bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Port{/t}</b></td>
                      <td bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Username{/t}</b></td>
                      <td bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Mailbox{/t}</b></td>
                      <td bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Auto-Creation of Issues{/t}</b></td>
                    </tr>
                    {section name="i" loop=$list}
                    {cycle values=$cycle assign="row_color"}
                    <tr>
                      <td width="4" align="center" nowrap bgcolor="{$row_color}"><input type="checkbox" name="items[]" value="{$list[i].ema_id}"></td>
                      <td bgcolor="{$row_color}" class="default">&nbsp;{$list[i].prj_title}</td>
                      <td width="30%"bgcolor="{$row_color}" class="default">
                        &nbsp;<a class="link" href="{$smarty.server.PHP_SELF}?cat=edit&id={$list[i].ema_id}" title="{t}update this entry{/t}">{$list[i].ema_hostname|escape:"html"}</a></td>
                      <td bgcolor="{$row_color}" class="default">&nbsp;{$list[i].ema_type}</td>
                      <td bgcolor="{$row_color}" class="default">&nbsp;{$list[i].ema_port}</td>
                      <td bgcolor="{$row_color}" class="default">&nbsp;{$list[i].ema_username|escape:"html"}</td>
                      <td bgcolor="{$row_color}" class="default">&nbsp;{$list[i].ema_folder}</td>
                      <td bgcolor="{$row_color}" class="default">&nbsp;<a href="issue_auto_creation.php?ema_id={$list[i].ema_id}" class="link">{$list[i].ema_issue_auto_creation|ucfirst}</a></td>
                    </tr>
                    {sectionelse}
                    <tr>
                      <td colspan="8" bgcolor="{$light_color}" align="center" class="default">
                        <i>{t}No email accounts could be found.{/t}</i>
                      </td>
                    </tr>
                    {/section}
                    <tr bgcolor="{$cell_color}">
                      <td width="4" align="center">
                        <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'items[]');">
                      </td>
                      <td colspan="7" align="center">
                        <input type="submit" value="{t}Delete{/t}" class="button">
                      </td>
                    </tr>
                    </form>
                  </table>
                </td>
              </tr>
            </table>
          </td>
        </tr>
      </table>
      {literal}
      <script language="JavaScript">
      <!--
      window.onload = setFolderField;
      function setFolderField()
      {
          var f = getForm('email_account_form');
          toggleFolderField(f);
      }
      //-->
      </script>
      {/literal}

