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

<p class="descriptiveText">{i18n}Collections of fields are associated into fieldsets.  These represent a set of related information which can be associated with a document and thus comprise part of the document's metadata.{/i18n}</p>

{ if $fieldsets}
<h3>{i18n}Existing document fieldsets{/i18n}</h3>

<table class="kt_collection narrow" cellpadding="1.5em" cellspacing="0">
  <thead>
    <tr>
      <th>{i18n}Name{/i18n}</th>
      <th class="centered">{i18n}Generic{/i18n}</th>
      <th class="centered">{i18n}System{/i18n}</th>
      <th>{i18n}Fields{/i18n}</th>
      <th>{i18n}Document Types{/i18n}</th>
      <th>{i18n}Edit{/i18n}</th>
      <th>{i18n}Delete{/i18n}</th>
    </tr>
  </thead>
  <tbody>
{foreach from=$fieldsets item=oFieldset}
    <tr>
      <td>
         { $oFieldset->getName() }
        </a>
      </td>
      <td class="centered">
{if ($oFieldset->getIsGeneric())}
    <span>{i18n}Yes{/i18n}</span>
{else}
	<span>{i18n}No{/i18n}</span>
{/if}
      </td>
      <td class="centered">
{if ($oFieldset->getIsSystem())}
	<span>{i18n}Yes{/i18n}</span>
{else}
	<span>{i18n}No{/i18n}</span>
{/if}
      </td>	  
      <td>
{assign var="aFields" value=$oFieldset->getFields()}
{if $aFields}

{foreach from=$aFields item=oField name=fields}
{$oField->getName()}{if (!$smarty.foreach.fields.last)}<br/> {/if} 
{/foreach}

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

	  <td>
	     <span class="descriptiveText">{$context->getTypesForFieldset($oFieldset)}</span>
	  </td>

	  <td>
	     <a href="{addQS}action=edit&fFieldsetId={$oFieldset->getId()}{/addQS}" class="ktAction ktEdit">{i18n}Edit{/i18n}</a>
	  </td>
	  <td>
	     <a href="{addQS}action=delete&fFieldsetId={$oFieldset->getId()}{/addQS}" class="ktAction ktDelete">{i18n}Delete{/i18n}</a>
	  </td>
	  

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



<form method="POST" action="{$smarty.server.PHP_SELF}">
<fieldset><legend>{i18n}Create a new document fieldset{/i18n}</legend>


<input type="hidden" name="action" value="new" />

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

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

