
      <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">
              <!--
              var editing_option_id = -1;
              function validateForm(f)
              {
                  if (isWhitespace(f.title.value)) {
                      alert('{/literal}{t escape=js}Please enter the title of this custom field.{/t}{literal}');
                      selectField(f, 'title');
                      return false;
                  }
                  if (!hasOneSelected(f, 'projects[]')) {
                      alert('{/literal}{t escape=js}Please assign the appropriate projects for this custom field.{/t}{literal}');
                      selectField(f, 'projects[]');
                      return false;
                  }
                  // warn if they have de-selected a project
                  var selections = getSelectedItems(getFormElement(f, 'projects[]'));
                  var removed_projects = '';
                  for (var i=0; i < selected_projects.length; i++) {
                      var is_still_selected = false;
                      for (var j=0; j < selections.length; j++) {
                          if (selections[j].value == selected_projects[i].value) {
                              is_still_selected = true;
                          }
                      }
                      if (is_still_selected == false) {
                          if (removed_projects.length > 0) {
                              removed_projects += ', ';
                          }
                          removed_projects += "'" + selected_projects[i].text + "'";
                      }
                  }
                  if (removed_projects.length > 0) {
                      var answer = confirm('{/literal}{t escape=js}WARNING: You have removed project(s){/t}{literal} ' + removed_projects + ' {/literal}{t}from the list{/t}{literal} ' +
                         '{/literal}{t escape=js}of associated projects. This will remove all data for this field from the selected project(s).{/t}{literal} ' +
                         '{/literal}{t escape=js}Do you want to continue?{/t}{literal}');
                      if (answer == false) {
                          return false;
                      }
                  }
                  if ((f.field_type[2].checked) || (f.field_type[3].checked)) {
                      // select all of the options in the select box
                      selectAllOptions(f, 'field_options[]');
                  }
                  return true;
              }
              function addFieldOption(f)
              {
                  var value = f.new_value.value;
                  if (isWhitespace(value)) {
                      alert('{/literal}{t escape=js}Please enter the new value for the combo box.{/t}{literal}');
                      f.new_value.value = '';
                      f.new_value.focus();
                      return false;
                  }
                  var field = getFormElement(f, 'field_options[]');
                  var current_length = field.options.length;
                  if (current_length == 1) {
                      if (field.options[0].value == -1) {
                          removeFieldOption(f, true);
                      }
                  }
                  // check for an existing option with the same value
                  for (var i = 0; i < field.options.length; i++) {
                      if (field.options[i].text == value) {
                          alert('{/literal}{t escape=js}The specified value already exists in the list of options.{/t}{literal}');
                          f.new_value.focus();
                          return false;
                      }
                  }
                  current_length = field.options.length;
                  field.options[current_length] = new Option(value, 'new:' + value);
                  f.new_value.value = '';
                  f.new_value.focus();
              }
              function parseParameters(value)
              {
                  value = value.substring(value.indexOf(':')+1);
                  var id = value.substring(0, value.indexOf(':'));
                  var text = value.substring(value.indexOf(':')+1);
                  return new Option(text, id);
              }
              function updateFieldOption(f)
              {
                  if (isWhitespace(f.new_value.value)) {
                      alert('{/literal}{t escape=js}Please enter the updated value.{/t}{literal}');
                      f.new_value.value = '';
                      f.new_value.focus();
                      return false;
                  }
                  var field = getFormElement(f, 'field_options[]');
                  for (var i = 0; i < field.options.length; i++) {
                      if (field.options[i].value == editing_option_id) {
                          var params = parseParameters(field.options[i].value);
                          field.options[i].value = 'existing:' + params.value + ':' + f.new_value.value;
                          field.options[i].text = f.new_value.value;
                          f.new_value.value = '';
                          f.update_button.disabled = true;
                      }
                  }
              }
              function editFieldOption(f)
              {
                  var options = getSelectedItems(getFormElement(f, 'field_options[]'));
                  if (options.length == 0) {
                      alert('{/literal}{t escape=js}Please select an option from the list.{/t}{literal}');
                      return false;
                  }
                  editing_option_id = options[0].value;
                  f.new_value.value = options[0].text;
                  f.new_value.focus();
                  f.update_button.disabled = false;
              }
              function removeFieldOption(f, delete_first)
              {
                  if (delete_first != null) {
                      var remove = new Array('-1');
                  } else {
                      var options = getSelectedItems(getFormElement(f, 'field_options[]'));
                      if (options.length == 0) {
                          alert('{/literal}{t escape=js}Please select an option from the list.{/t}{literal}');
                          return false;
                      }
                      var remove = new Array();
                      for (var i = 0; i < options.length; i++) {
                          remove[remove.length] = options[i].value;
                      }
                  }
                  for (var i = 0; i < remove.length; i++) {
                      removeOptionByValue(f, 'field_options[]', remove[i]);
                  }
                  var field = getFormElement(f, 'field_options[]');
                  if ((delete_first == null) && (field.options.length == 0)) {
                      field.options[0] = new Option('{/literal}{t escape=js}enter a new option above{/t}{literal}', '-1');
                  }
              }
              function toggleCustomOptionsField(show_field)
              {
                  var f = getForm('custom_field_form');
                  f.new_value.disabled = show_field;
                  var field = getFormElement(f, 'field_options[]');
                  field.disabled = show_field;
                  f.add_button.disabled = show_field;
                  f.remove_button.disabled = show_field;
                  if (f.edit_button) {
                      f.edit_button.disabled = show_field;
                  }
                  return true;
              }
              function checkRequiredFields()
              {
                  var f = getForm('custom_field_form');
                  f.report_form_required.disabled = !(f.report_form.checked);
                  if (f.report_form_required.disabled) {
                      f.report_form_required.checked = false;
                  }
                  f.anon_form_required.disabled = !(f.anon_form.checked);
                  if (f.anon_form_required.disabled) {
                      f.anon_form_required.checked = false;
                  }
                  f.close_form_required.disabled = !(f.close_form.checked);
                  if (f.close_form_required.disabled) {
                      f.close_form_required.checked = false;
                  }
              }
              {/literal}
              var selected_projects = new Array();
              {foreach from=$info.projects item=prj_id}
              selected_projects[selected_projects.length] = new Option("{$project_list[$prj_id]}", {$prj_id});
              {/foreach}
              //-->
              </script>
              <form name="custom_field_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 Custom Fields{/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 custom field.{/t}
                    {elseif $result == 1}
                      {t}Thank you, the custom field was added successfully.{/t}
                    {/if}
                  {elseif $smarty.post.cat == "update"}
                    {if $result == -1}
                      {t}An error occurred while trying to update the custom field information.{/t}
                    {elseif $result == 1}
                      {t}Thank you, the custom field was updated successfully.{/t}
                    {/if}
                  {/if}
                </td>
              </tr>
              {/if}
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Title{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <input type="text" name="title" size="40" class="default" value="{$info.fld_title}">
                  {include file="error_icon.tpl.html" field="title"}
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Short Description{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <input type="text" name="description" size="30" class="default" value="{$info.fld_description}">
                  <span class="small_default">({t}it will show up by the side of the field{/t})</span>
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Assigned Projects{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <select name="projects[]" multiple size="3" class="default">
                  {html_options options=$project_list selected=$info.projects}
                  </select>
                  {include file="error_icon.tpl.html" field="projects[]"}
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Target Forms{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <span class="default">
                  <input type="checkbox" name="report_form" value="1" {if $info.fld_report_form == 1}checked{/if} onclick="checkRequiredFields();"> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('custom_field_form', 'report_form', 0);checkRequiredFields();">{t}Report Form{/t}</a><br />
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="report_form_required" value="1" {if $info.fld_report_form_required == 1}checked{/if}> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('custom_field_form', 'report_form_required', 0);">{t}Required Field{/t}</a><br />
                  <input type="checkbox" name="anon_form" value="1" {if $info.fld_anonymous_form == 1}checked{/if} onclick="checkRequiredFields();"> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('custom_field_form', 'anon_form', 0);checkRequiredFields();">{t}Anonymous Form{/t}</a><br />
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="anon_form_required" value="1" {if $info.fld_anonymous_form_required == 1}checked{/if}> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('custom_field_form', 'anon_form_required', 0);">{t}Required Field{/t}</a><br />
                  <input type="checkbox" name="close_form" value="1" {if $info.fld_close_form == 1}checked{/if} onclick="checkRequiredFields();"> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('custom_field_form', 'close_form', 0);checkRequiredFields();">{t}Close Form{/t}</a><br />
                  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="close_form_required" value="1" {if $info.fld_close_form_required == 1}checked{/if}> <a id="link" class="link" href="javascript:void(null);" onClick="javascript:toggleCheckbox('custom_field_form', 'close_form_required', 0);">{t}Required Field{/t}</a>
                  </span>
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Display on List Issues Page{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <span class="default">
                  <input type="radio" name="list_display" value="1" {if $info.fld_list_display == 1}checked{/if}>
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'list_display', 0);">{t}Yes{/t}</a>
                  <input type="radio" name="list_display" value="0" {if $info.fld_list_display != 1}checked{/if}>
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'list_display', 1);">{t}No{/t}</a>
                  </span>
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Field Type{/t}:</b>
                </td>
                <td bgcolor="{$light_color}" class="default">
                  <input type="radio" name="field_type" value="text" {if $info.fld_type == 'text'}checked{/if} onClick="javascript:toggleCustomOptionsField(true);">
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'field_type', 0);toggleCustomOptionsField(true);">{t}Text Input{/t}</a>&nbsp;<br />
                  <input type="radio" name="field_type" value="textarea" {if $info.fld_type == 'textarea'}checked{/if} onClick="javascript:toggleCustomOptionsField(true);">
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'field_type', 1);toggleCustomOptionsField(true);">{t}Textarea{/t}</a>&nbsp;<br />
                  <input type="radio" name="field_type" value="combo" {if $info.fld_type == 'combo'}checked{/if} onClick="javascript:toggleCustomOptionsField(false);">
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'field_type', 2);toggleCustomOptionsField(false);">{t}Combo Box{/t}</a>&nbsp;<br />
                  <input type="radio" name="field_type" value="multiple" {if $info.fld_type == 'multiple'}checked{/if} onClick="javascript:toggleCustomOptionsField(false);">
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'field_type', 3);toggleCustomOptionsField(false);">{t}Multiple Combo Box{/t}</a><br />
                  <input type="radio" name="field_type" value="date" {if $info.fld_type == 'date'}checked{/if} onClick="javascript:toggleCustomOptionsField(false);">
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'field_type', 4);toggleCustomOptionsField(true);">{t}Date{/t}</a><br />
                  <input type="radio" name="field_type" value="integer" {if $info.fld_type == 'integer'}checked{/if} onClick="javascript:toggleCustomOptionsField(false);">
                  <a id="link" class="link" href="javascript:void(null);" onClick="javascript:checkRadio('custom_field_form', 'field_type', 5);toggleCustomOptionsField(true);">{t}Integer{/t}</a><br /><br />
                  <b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{t}Warning{/t}: </b> {t}Changing field types can result in loss of data.{/t}<br /><br />
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Field Options{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <table bgcolor="{$dark_color}" cellspacing="0" cellpadding="0" border="0">
                    <tr>
                      <td rowspan="2"><img src="{$rel_url}images/blank.gif" width="30" height="1"></td>
                      <td valign="top">
                        <span class="default"><b>{t}Set available options{/t}:</b></span><br />
                        <input class="default" type="text" name="new_value" size="26"><input class="shortcut" name="add_button" type="button" value="{t}Add{/t}" onClick="javascript:addFieldOption(this.form);">{if $smarty.get.cat == 'edit'}<input class="shortcut" name="update_button" type="button" value="{t}Update Value{/t}" disabled onClick="javascript:updateFieldOption(this.form);">{/if}<br />
                      </td>
                      <td rowspan="3" class="default">
                        &nbsp;&nbsp;&nbsp;&nbsp;<b>{t}AND / OR{/t}</b>&nbsp;&nbsp;&nbsp;&nbsp;
                      </td>
                      <td valign="top">
                        <span class="default"><b>{t}Choose Custom Field Backend{/t}:</b></span><br />
                        <select name="custom_field_backend" class="default">
                          <option value="" label="{t}Please select a backend{/t}">{t}Please select a backend{/t}</option>
                          {html_options options=$backend_list selected=$info.fld_backend}
                        </select>
                      </td>
                      <td rowspan="3"><img src="{$rel_url}images/blank.gif" width="30" height="1"></td>
                    </tr>
                    <tr>
                      <td>
                        <table border="0" cellspacing="0" cellpadding="0">
                          <tr>
                            <td>
                              <select name="field_options[]" multiple size="3" class="default">
                              {if $info.field_options == ""}
                                <option value="-1">{t}enter a new option above{/t}</option>
                              {else}
                                {html_options options=$info.field_options}
                              {/if}
                              </select>
                            </td>
                            <td valign="top">
                              {if $smarty.get.cat == 'edit'}
                              <input class="shortcut" type="button" name="edit_button" value="{t}Edit Option{/t}" onClick="javascript:editFieldOption(this.form);"><br />
                              {/if}
                              <input class="shortcut" type="button" name="remove_button" value="{t}Remove{/t}" onClick="javascript:removeFieldOption(this.form);">
                            </td>
                          </tr>
                        </table>
                      </td>
                    </tr>
                  </table>
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Minimum Role{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <select name="min_role" class="default">
                    {html_options options=$user_roles selected=$info.fld_min_role}
                  </select>
                </td>
              </tr>
              <tr>
                <td width="120" bgcolor="{$cell_color}" class="default_white">
                  <b>{t}Rank{/t}:</b>
                </td>
                <td bgcolor="{$light_color}">
                  <input type="text" name="rank" value="{$info.fld_rank}" size="3" class="default">
                </td>
              </tr>
              <tr>
                <td colspan="2" bgcolor="{$cell_color}" align="center">
                  {if $smarty.get.cat == 'edit'}
                  <input class="button" type="submit" value="{t}Update Custom Field{/t}">
                  {else}
                  <input class="button" type="submit" value="{t}Create Custom Field{/t}">
                  {/if}
                  <input class="button" type="reset" value="{t}Reset{/t}">
                </td>
              </tr>
              </form>
              <tr>
                <td colspan="2" class="default">
                  <b>{t}Existing Custom Fields{/t}:</b>
                </td>
              </tr>
              <tr>
                <td colspan="2">
                  <script language="JavaScript">
                  <!--
                  {literal}
                  function checkDelete(f)
                  {
                      if (!hasOneChecked(f, 'items[]')) {
                          alert('{/literal}{t escape=js}Please select at least one of the custom fields.{/t}{literal}');
                          return false;
                      }
                      if (!confirm('{/literal}{t escape=js}This action will permanently remove the selected custom fields.{/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 nowrap bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Rank{/t}</b></td>
                      <td width="15%" bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Title{/t}</b></td>
                      <td width="20%" bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Assigned Projects{/t}</b></td>
                      <td width="10%" bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Min. Role{/t}</b></td>
                      <td width="5%" bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Type{/t}</b></td>
                      <td width="50%" bgcolor="{$cell_color}" class="default_white">&nbsp;<b>{t}Options{/t}</b></td>
                    </tr>
                    {section name="i" loop=$list}
                    {cycle values=$cycle assign="row_color"}
                    <tr>
                      <td width="4" nowrap bgcolor="{$row_color}" align="center">
                        <input type="checkbox" name="items[]" value="{$list[i].fld_id}" {if $smarty.section.i.total == 0}disabled{/if}>
                      </td>
                      <td bgcolor="{$row_color}" class="default" nowrap>
                        &nbsp;<a class="link" href="{$smarty.server.PHP_SELF}?cat=change_rank&id={$list[i].fld_id}&direction=1" title="{t}move field down{/t}"><img src="{$rel_url}images/desc.gif" border="0"></a> {$list[i].fld_rank}
                        <a class="link" href="{$smarty.server.PHP_SELF}?cat=change_rank&id={$list[i].fld_id}&direction=-1" title="{t}move field up{/t}"><img src="{$rel_url}images/asc.gif" border="0"></a>
                      </td>
                      <td width="15%" bgcolor="{$row_color}" class="default">
                        &nbsp;<a class="link" href="{$smarty.server.PHP_SELF}?cat=edit&id={$list[i].fld_id}" title="{t}update this entry{/t}">{$list[i].fld_title}</a>
                      </td>
                      <td width="20%" bgcolor="{$row_color}" class="default">
                        &nbsp;{$list[i].projects}
                      </td>
                      <td width="10%" bgcolor="{$row_color}" class="default">
                        &nbsp;{$list[i].min_role_name}
                      </td>
                      <td width="5%" bgcolor="{$row_color}" class="default">
                        <nobr>&nbsp;{if $list[i].fld_type == 'combo'}{t}Combo Box{/t}{elseif $list[i].fld_type == 'multiple'}{t}Multiple Combo Box{/t}{elseif $list[i].fld_type == 'textarea'}{t}Textarea{/t}{elseif $list[i].fld_type == 'date'}{t}Date{/t}{elseif $list[i].fld_type == 'integer'}{t}Integer{/t}{else}{t}Text Input{/t}{/if}</nobr>
                      </td>
                      <td width="50%" bgcolor="{$row_color}" class="default">
                        &nbsp;{$list[i].field_options}
                      </td>
                    </tr>
                    {sectionelse}
                    <tr>
                      <td colspan="7" bgcolor="{$light_color}" align="center" class="default">
                        <i>{t}No custom fields could be found.{/t}</i>
                      </td>
                    </tr>
                    {/section}
                    <tr>
                      <td width="4" align="center" bgcolor="{$cell_color}">
                        <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'items[]');">
                      </td>
                      <td colspan="6" bgcolor="{$cell_color}">
                        <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 = setCustomOptionsField;
      function setCustomOptionsField()
      {
          var f = getForm('custom_field_form');
          var field1 = getFormElement(f, 'field_type', 2);
          var field2 = getFormElement(f, 'field_type', 3);
          if (field1.checked || field2.checked) {
              toggleCustomOptionsField(false);
          } else {
              toggleCustomOptionsField(true);
          }
          checkRequiredFields();
      }
      //-->
      </script>
      {/literal}

