<h2>{i18n}Document Types{/i18n}</h2>

<form method="POST">

<fieldset>
<legend>{i18n}Create a new document type{/i18n}</legend>

<p class="descriptiveText">{i18n}To start the process of creating a new document type,
please enter a name for the type below.{/i18n}</p>

{foreach item=oWidget from=$add_fields}
  {$oWidget->render()}
{/foreach}

<div class="form_actions">
<input type="hidden" name="action" value="new">
<input type="submit" name="submit" value="{i18n}Create{/i18n}">
</div>
</fieldset>

</form>

<fieldset>
<legend>{i18n}Existing document types{/i18n}</legend>

<p class="descriptiveText">{i18n}Select a document type from the list below to change
its details, or use the enable/disable buttons to change its availability state.{/i18n}</p>

<table class="kt_collection narrow" cellspacing="0" cellpadding="5">

  <thead>
    <tr>
      <th>{i18n}Document Type{/i18n}</th>
      <th>{i18n}Associated Fieldsets{/i18n}</th>
      <th>{i18n}Edit{/i18n}</th>
      <th>{i18n}Disable/Enable{/i18n}</th>
      <th>{i18n}Delete{/i18n}</th>
    </tr>
  </thead>
  
  <tbody>

{foreach from=$document_types item=oDocumentType}
<tr>

<td>
    { $oDocumentType->getName() }
</td>

      <td>
{assign var="aFieldsets" value=$oDocumentType->getFieldsets()}
{if $aFieldsets}

{foreach from=$aFieldsets item=oFieldset name=fieldsets}

    {capture assign=fsid}{$oFieldset->getId()}{/capture}
<a title="{i18n}Edit fieldset.{/i18n}"
href="{ktLink base="admin.php" subpath="/documents/fieldmanagement2" query="action=edit&fFieldsetId=`$fsid`"}">{$oFieldset->getName()}</a>{if (!$smarty.foreach.fieldsets.last)}, {/if} 

{/foreach}

{else}
&mdash;
{/if}
      </td>


<td style="text-align:center">
    <a title="{i18n}Edit document type.{/i18n}" 
    class="ktAction ktEdit" href="{addQS}action=edit&fDocumentTypeId={$oDocumentType->getId()}{/addQS}">{i18n}Edit{/i18n}</a>
</td>

<td style="text-align:center">
{if $oDocumentType->getDisabled()}
    <a title="{i18n}Enable document type.{/i18n}" 
    class="ktAction ktAdd" href="{addQS}action=enable&fDocumentTypeId={$oDocumentType->getId()}{/addQS}">{i18n}Enable{/i18n}</a>
{else}
    <a title="{i18n}Disable document type.{/i18n}"class="ktAction ktDelete" 
    kt:deleteMessage="{i18n}Are you sure you wish to disable this document type?{/i18n}" 
    href="{addQS}action=disable&fDocumentTypeId={$oDocumentType->getId()}{/addQS}">{i18n}Disable{/i18n}</a>
{/if}
</td>

<td style="text-align:center">
    {if $oDocumentType->checkDelete($associated_types, $oDocumentType->getId())}
        <a title="{i18n}Delete document type.{/i18n}" class="ktAction ktDelete" 
        kt:deleteMessage="{i18n}Are you sure you wish to delete this document type? It will be permanently removed from the system.{/i18n}" 
        href="{addQS}action=delete&fDocumentTypeId={$oDocumentType->getId()}{/addQS}">{i18n}Delete{/i18n}</a>
    {else}
        <span title="{i18n}Document type cannot be deleted{/i18n}" class="ktAction ktDenied"></span> 
    {/if}
</td>

</tr>
  </tbody>
{/foreach}
</table>
</fieldset>
