<h2>{i18n}Manage Transitions{/i18n}</h2>

<p class="descriptiveText">{i18n}Transitions are what drive the workflow of documents.
Each step that needs to be followed in the document's lifecycle could
map to a transition, and can be allowed or denied by a combination
of roles, permissions and groups.{/i18n}</p>


<p class="descriptiveText">{i18n}<strong>Please Note:</strong> you can only delete states or transitions 
while the workflow has no documents or document-versions assigned to the workflow.{/i18n}</p>


<fieldset>
<legend>{i18n}Create a new transition{/i18n}</legend>

<a href="{addQS}action=createTransition&fWorkflowId={$oWorkflow->getId()}{/addQS}"
   class="ktAction ktAdd ktInline">{i18n}Create a new transition{/i18n}</a>
<a href="{addQS}action=createTransition&fWorkflowId={$oWorkflow->getId()}{/addQS}"
   >{i18n}Create a new transition{/i18n}</a>

</fieldset>

{if (empty($workflow_info.transitions))}
<div class="ktInfoMessage"><span>{i18n}This workflow does not define any transitions.  Use the "Create a new transition" link above
to add new transitions.{/i18n}</span></div>
{else}
<h3>{i18n}Transition Availability{/i18n}</h3>

<p class="descriptiveText">{i18n}Click on any transition below to edit it directly,
or use the checkboxes to assign which states the transition is available from.{/i18n}</p>

<form action="{$smarty.server.PHP_SELF}" method="POST">
<input type="hidden" name="action" value="setTransitionAvailability">
<input type="hidden" name="fWorkflowId" value="{$oWorkflow->getId()}" />

<table class="kt_collection" style="width: auto">
<thead>
  <tr>
    <th>
      &nbsp;
    </th>
    {foreach item=oState from=$workflow_info.states}
    <th>
      {$oState->getName()}
    </th>
    {/foreach}
  </tr>
</thead>
<tbody>
  {foreach item=oTransition from=$workflow_info.transitions}
  <tr class='{cycle values="odd,even"}'>
    <td>
      <a href="{addQS}action=editTransition&fWorkflowId={$oWorkflow->getId()}&fTransitionId={$oTransition->getId()}{/addQS}">{$oTransition->getName()}</a>
      {if ($workflow_info.can_delete)} | <span class="ktActionLink ktDelete"><a href="{addQS}action=deleteTransition&fTransitionId={$oTransition->getId()}&fWorkflowId={$oWorkflow->getId()}{/addQS}" >{i18n}Delete{/i18n}</a></span>{/if}
    </td>
    {foreach item=oState from=$workflow_info.states}
      <td>
        {if ($oState->getId() != $oTransition->getTargetStateId())}
        <input type="checkbox" name="fTransitionAvailability[{$oState->getId()}][{$oTransition->getId()}]" {if ($context->transitionAvailable($oTransition, $oState))}checked="true"{/if}>
        {else}&mdash;{/if}
      </td>
    {/foreach}
  </tr>
  {/foreach}
</tbody>
<table>

<div class="form_actions">
  <input type="submit" value="{i18n}Assign Transition Availability{/i18n}" />
</div>

</form>
{/if}
