{include file="header.tpl.html" extra_title="Preferences"}
{include file="navigation.tpl.html"}

{literal}
<script language="JavaScript">
<!--
function validateName(f)
{
    if (isWhitespace(f.full_name.value)) {
        alert('{/literal}{t escape=js}Please enter your full name.{/t}{literal}');
        selectField(f, 'full_name');
        return false;
    }
    return true;
}
function validateEmail(f)
{
    if (!isEmail(f.email.value)) {
        alert('{/literal}{t escape=js}Please enter a valid email address.{/t}{literal}');
        selectField(f, 'email');
        return false;
    }
    return true;
}
function validatePassword(f)
{
    if ((isWhitespace(f.new_password.value)) || (f.new_password.value.length < 6)) {
        alert('{/literal}{t escape=js}Please enter your new password with at least 6 characters.{/t}{literal}');
        selectField(f, 'new_password');
        return false;
    }
    if (f.new_password.value != f.confirm_password.value) {
        alert('{/literal}{t escape=js}The two passwords do not match. Please review your information and try again.{/t}{literal}');
        selectField(f, 'confirm_password');
        return false;
    }
    return true;
}
function validateAccount(f)
{
    return true;
}
//-->
</script>
{/literal}
<table width="80%" 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 class="default">
            <b>{t}User Details{/t}</b>
          </td>
          <td align="right">
            {include file="help_link.tpl.html" topic="preferences"}
          </td>
        </tr>
        {if $current_role != $roles.customer}
        <form name="update_name_form" onSubmit="javascript:return validateName(this);" action="{$smarty.server.PHP_SELF}" method="post">
        <input type="hidden" name="cat" value="update_name">
        {if $update_name_result}
        <tr>
          <td colspan="2" class="error" bgcolor="{$cell_color}" align="center">
            {if $update_name_result == -1}
            <b>{t}An error occurred while trying to run your query.{/t}</b>
            {elseif $update_name_result == 1}
            <b>{t}Thank you, your full name was updated successfully.{/t}</b>
            {/if}
          </td>
        </tr>
        {/if}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Full Name{/t}:</b>
          </td>
          <td bgcolor="{$light_color}">
            <input type="text" name="full_name" size="40" class="default" value="{$current_full_name|escape:"html"}">
            {include file="error_icon.tpl.html" field="full_name"}
          </td>
        </tr>
        <tr>
          <td colspan="2" bgcolor="{$cell_color}" align="center">
            <input class="button" type="submit" value="{t}Update Full Name{/t}">
            <input class="button" type="reset" value="{t}Reset{/t}">
          </td>
        </tr>
        </form>
        <form name="update_email_form" onSubmit="javascript:return validateEmail(this);" action="{$smarty.server.PHP_SELF}" method="post">
        <input type="hidden" name="cat" value="update_email">
        {if $update_email_result}
        <tr>
          <td colspan="2" class="error" bgcolor="{$cell_color}" align="center">
            {if $update_email_result == -1}
            <b>{t}An error occurred while trying to run your query.{/t}</b>
            {elseif $update_email_result == 1}
            <b>{t}Thank you, your email address was updated successfully.{/t}</b>
            {/if}
          </td>
        </tr>
        {/if}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Login{/t} &amp; {t}Email Address{/t}:</b>
          </td>
          <td bgcolor="{$light_color}">
            <input type="text" name="email" size="40" class="default" value="{$current_email|escape:"html"}">
            {include file="error_icon.tpl.html" field="email"}
          </td>
        </tr>
        <tr>
          <td colspan="2" bgcolor="{$cell_color}" align="center">
            <input class="button" type="submit" value="{t}Update Email Address{/t}">
            <input class="button" type="reset" value="{t}Reset{/t}">
          </td>
        </tr>
        </form>
        {/if}
        <form name="update_password_form" onSubmit="javascript:return validatePassword(this);" action="{$smarty.server.PHP_SELF}" method="post">
        <input type="hidden" name="cat" value="update_password">
        {if $update_password_result}
        <tr>
          <td colspan="2" class="error" bgcolor="{$cell_color}" align="center">
            {if $update_password_result == -1}
            <b>{t}An error occurred while trying to run your query.{/t}</b>
            {elseif $update_password_result == 1}
            <b>{t}Thank you, your password was updated successfully.{/t}</b>
            {/if}
          </td>
        </tr>
        {/if}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Change Password{/t}:</b>
          </td>
          <td bgcolor="{$light_color}">
            <table>
              <tr>
                <td class="default" align="right">{t}New Password{/t}:</td>
                <td><input type="password" name="new_password" size="20" class="default"> {include file="error_icon.tpl.html" field="new_password"}</td>
              </tr>
              <tr>
                <td class="default" align="right">{t}Confirm New Password{/t}:</td>
                <td><input type="password" name="confirm_password" size="20" class="default"> {include file="error_icon.tpl.html" field="confirm_password"}</td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td colspan="2" bgcolor="{$cell_color}" align="center">
            <input class="button" type="submit" value="{t}Update Password{/t}">
            <input class="button" type="reset" value="{t}Reset{/t}">
          </td>
        </tr>
        </form>
      </table>
    </td>
  </tr>
</table>
<br />
<table width="80%" bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td>
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <form name="account_prefs_form" onSubmit="javascript:return validateAccount(this);" action="{$smarty.server.PHP_SELF}" method="post" enctype="multipart/form-data">
        <input type="hidden" name="cat" value="update_account">
        <tr>
          <td class="default">
            <b>{t}Account Preferences{/t}</b>
          </td>
          <td align="right" colspan="{$assigned_projects|@count}">
            {include file="help_link.tpl.html" topic="preferences"}
          </td>
        </tr>
        {if $update_account_result}
        <tr>
          <td colspan="{math equation="2 + x" x=$assigned_projects|@count}" class="error" bgcolor="{$cell_color}" align="center">
            {if $update_account_result == -1}
            <b>{t}An error occurred while trying to run your query.{/t}</b>
            {elseif $update_account_result == 1}
            <b>{t}Thank you, your account preferences were updated successfully.{/t}</b>
            {/if}
          </td>
        </tr>
        {/if}
        {if $avail_langs|@count > 1}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Available Languages{/t}:</b>
          </td>
          <td bgcolor="{$light_color}" colspan="{$assigned_projects|@count}">
            <select class="default" name="language">
			  <option value="en_US">English</option>
              {html_options options=$avail_langs selected=$current_locale}
            </select>
          </td>
        </tr>
        {/if}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Timezone{/t}:</b>
          </td>
          <td bgcolor="{$light_color}" colspan="{$assigned_projects|@count}">
            <select class="default" name="timezone">
              {html_options values=$zones output=$zones selected=$user_prefs.timezone}
            </select>
            {include file="lookup_field.tpl.html" lookup_field_name="search" lookup_field_target="timezone"}
          </td>
        </tr>
        {if $current_role != $roles.customer}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Automatically close confirmation popup windows ?{/t}</b>
          </td>
          <td bgcolor="{$light_color}" class="default" colspan="{$assigned_projects|@count}">
            <label><input type="radio" name="close_popup_windows" {if $user_prefs.close_popup_windows == "1"}checked{/if} value="1"> {t}Yes{/t}</label>&nbsp;&nbsp;
            <label><input type="radio" name="close_popup_windows" {if $user_prefs.close_popup_windows != "1"}checked{/if} value="0"> {t}No{/t}</label>
          </td>
        </tr>
        {/if}
        {if $current_role > $roles.customer}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            &nbsp;
          </td>
          {foreach from=$assigned_projects key=prj_id item=project_info}
          <td bgcolor="{$light_color}" class="default">
            &nbsp;<b>{$project_info.prj_title}</b>
          </td>
          {/foreach}
        </tr>
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Receive emails when all issues are created ?{/t}</b>
          </td>
          {foreach from=$assigned_projects key=prj_id item=project_info}
          <td bgcolor="{$light_color}" class="default">
            &nbsp;<input type="radio" name="receive_new_emails[{$prj_id}]" {if $user_prefs.receive_new_emails.$prj_id}checked{/if} value="1"> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('account_prefs_form', 'receive_new_emails[{$prj_id}]', 0);">{t}Yes{/t}</a>&nbsp;&nbsp;
            <input type="radio" name="receive_new_emails[{$prj_id}]" {if not $user_prefs.receive_new_emails.$prj_id}checked{/if} value="0"> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('account_prefs_form', 'receive_new_emails[{$prj_id}]', 1);">{t}No{/t}</a>
          </td>
          {/foreach}
        </tr>
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Receive emails when new issues are assigned to you ?{/t}</b>
          </td>
          {foreach from=$assigned_projects key=prj_id item=project_info}
          <td bgcolor="{$light_color}" class="default">
            &nbsp;<input type="radio" name="receive_assigned_emails[{$prj_id}]" {if $user_prefs.receive_assigned_emails.$prj_id}checked{/if} value="1"> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('account_prefs_form', 'receive_assigned_emails[{$prj_id}]', 0);">{t}Yes{/t}</a>&nbsp;&nbsp;
            <input type="radio" name="receive_assigned_emails[{$prj_id}]" {if not $user_prefs.receive_assigned_emails.$prj_id}checked{/if} value="0"> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('account_prefs_form', 'receive_assigned_emails[{$prj_id}]', 1);">{t}No{/t}</a>
          </td>
          {/foreach}
        </tr>
        {else}
        <input type="hidden" name="close_popup_windows" value="0">
        <input type="hidden" name="receive_assigned_emails" value="0">
        <input type="hidden" name="receive_new_emails" value="0">
        {/if}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Refresh Rate for Issue Listing Page{/t}:</b>
          </td>
          <td bgcolor="{$light_color}" colspan="{$assigned_projects|@count}">
            <input type="text" size="10" class="default" name="list_refresh_rate" value="{$user_prefs.list_refresh_rate|escape:"html"}">
            <span class="small_default"><i>({t}in minutes{/t})</i></span>
          </td>
        </tr>
        {if $current_role > $roles.customer}
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Refresh Rate for Email Listing Page{/t}:</b>
          </td>
          <td bgcolor="{$light_color}" colspan="{$assigned_projects|@count}">
            <input type="text" size="10" class="default" name="emails_refresh_rate" value="{$user_prefs.emails_refresh_rate|escape:"html"}">
            <span class="small_default"><i>({t}in minutes{/t})</i></span>
          </td>
        </tr>
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}Email Signature{/t}:</b>
          </td>
          <td bgcolor="{$light_color}" colspan="{$assigned_projects|@count}">
            <table border="0" width="100%">
              <tr>
                <td class="default" colspan="2">
                  {t}Edit Signature{/t}:<br />
                  <textarea name="signature" style="width: 97%" rows="10">{$user_prefs.email_signature}</textarea>
                </td>
              </tr>
              <tr>
                <td class="default" width="140" nowrap>{t}Upload New Signature{/t}:</td>
                <td><input size="40" type="file" name="file_signature" class="default"></td>
              </tr>
              <tr>
                <td class="default" colspan="2">
                  <input type="checkbox" name="auto_append_sig" value="yes" {if $user_prefs.auto_append_sig == 'yes'}checked{/if}>
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('account_prefs_form', 'auto_append_sig');">{t}Automatically append email signature when composing web based emails{/t}</a><br />
                  <input type="checkbox" name="auto_append_note_sig" value="yes" {if $user_prefs.auto_append_note_sig == 'yes'}checked{/if}>
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('account_prefs_form', 'auto_append_note_sig');">{t}Automatically append email signature when composing internal notes{/t}</a>
                </td>
              </tr>
            </table>
          </td>
        </tr>
        <tr>
          <td width="190" bgcolor="{$cell_color}" class="default_white">
            <b>{t}SMS Email Address{/t}:</b>
          </td>
          <td bgcolor="{$light_color}" colspan="{$assigned_projects|@count}">
            <input type="text" size="40" class="default" name="sms_email" value="{$user_prefs.sms_email|escape:"html"}">
            <span class="small_default"><i>({t}only used for automatic issue reminders{/t})</i></span>
          </td>
        </tr>
        {else}
        <input type="hidden" name="emails_refresh_rate" value="10">
        {/if}
        <tr>
          <td colspan="{math equation="2 + x" x=$assigned_projects|@count}" bgcolor="{$cell_color}" align="center">
            <input class="button" type="submit" value="{t}Update Preferences{/t}">
            <input class="button" type="reset" value="{t}Reset{/t}">
          </td>
        </tr>
        </form>
      </table>
    </td>
  </tr>
</table>

<br />

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