{include file="header.tpl.html" extra_title="Issue #$issue_id - Upload File"}
{if $current_role > $roles.viewer}
{if $upload_file_result != ''}
    <br />
    <center>
    <span class="default"><b>
    {if $upload_file_result == -1}
      {t}An error occurred while trying to process the uploaded file.{/t}
    {elseif $upload_file_result == -2}
      {t}The uploaded file is already attached to the current issue. Please rename the file and try again.{/t}
    {elseif $upload_file_result == 1}
      {t}Thank you, the uploaded file was associated with the issue below.{/t}
    {/if}
    </b></span>
    </center>
    <script language="JavaScript">
    <!--
    {if $current_user_prefs.close_popup_windows == '1' && $upload_file_result == 1}
    setTimeout('closeAndRefresh()', 2000);
    {/if}
    //-->
    </script>
    <br />
    {if not $current_user_prefs.close_popup_windows}
    <center>
      <span class="default"><a class="link" href="javascript:void(null);" onClick="javascript:closeAndRefresh();">{t}Continue{/t}</a></span>
    </center>
    {/if}
{else}
{literal}
<script language="JavaScript">
<!--
function validateUpload(f)
{
    var field1 = getFormElement(f, 'attachment[]', 0);
    var field2 = getFormElement(f, 'attachment[]', 1);
    var field3 = getFormElement(f, 'attachment[]', 2);
    if ((isWhitespace(field1.value)) && (isWhitespace(field2.value)) && (isWhitespace(field3.value))) {
        errors[errors.length] = new Option('Files', 'attachment[]');
        return false;
    }
    return true;
}
//-->
</script>
{/literal}
<table width="100%" bgcolor="{$cell_color}" border="0" cellspacing="0" cellpadding="1" align="center">
  <tr>
    <td width="100%">
      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
        <tr>
          <td colspan="2" class="default"><b>{t}Add New Files{/t}:</b></td>
        </tr>
        <form name="attachment_form" action="file_upload.php" method="post" enctype="multipart/form-data" onSubmit="javascript:return checkFormSubmission(this, 'validateUpload');">
        <input type="hidden" name="cat" value="upload_file">
        <input type="hidden" name="issue_id" value="{$issue_id}">
        <tr>
          <td colspan="2">
            <table width="100%" cellpadding="2" cellspacing="1">
              {if $current_role > $roles.customer}
              <tr>
                <td bgcolor="{$internal_color}" class="default_white" width="120" nowrap>
                  <b>{t}Status{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <select name="status" class="default">
                    <option value="public">{t}Public{/t} ({t}visible to all{/t})</option>
                    <option value="internal">{t}Private{/t} ({t}standard user and above only{/t})</option>
                  </select>
                </td>
              </tr>
              {else}
              <input type="hidden" name="status" value="public">
              {/if}
              <tr>
                <td bgcolor="{$cell_color}" class="default_white" width="120" nowrap>
                  <b>{t}Filenames{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <table width="100%" cellpadding="2" cellspacing="0" id="file_table">
                    <tr>
                      <td><input size="50" name="attachment[]" type="file" class="shortcut"></td>
                    </tr>
                    <tr>
                      <td><input size="50" name="attachment[]" type="file" class="shortcut"></td>
                    </tr>
                    <tr>
                      <td><input size="50" name="attachment[]" type="file" class="shortcut"></td>
                    </tr>
                    <tr>
                      <td class="small_default"><b>N{t}ote: The current maximum allowed upload file size is{/t} {$max_attachment_size}</b></td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr bgcolor="{$light_color}">
                <td bgcolor="{$cell_color}" class="default_white" width="120" nowrap>
                  <b>{t}Description{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <textarea name="file_description" rows="4" style="width: 97%"></textarea>
                </td>
              </tr>
              <tr bgcolor="{$cell_color}">
                <td colspan="2" align="center">
                  <input type="submit" class="button" value="{t}Upload File{/t}">
                </td>
              </tr>
            </table>
          </td>
        </tr>
        </form>
      </table>
    </td>
  </tr>
</table>
{/if}
{else}
<center><span class="default">{t}You do not have the correct role to access this page{/t}</span></center>
{/if}
{include file="footer.tpl.html"}
