{capture assign=sCSS}{literal}

td.true { background-color: #aaffaa; text-align: centre }
td.false { background-color: #ffaaaa; text-align: centre }
.edit { display: none; }
.view { display: block; }

.tablebutton {
    margin: 0em;
    margin-right: 1em;
    border: 1px solid #cccccc;
}
.activebutton {
    background-color: #eeeeff;
}
.inactivebutton {
    background-color: #ffeeee;
}

{/literal}{/capture}
{$context->oPage->requireCSSStandalone($sCSS)}

<h2><img src="{if $config->get("ui/morphEnabled") == '1'}{$rootUrl}/skins/kts_{$config->get("ui/morphTo")}/title_bullet.png{else}{$rootUrl}/resources/graphics/title_bullet.png{/if}"/>{i18n}State{/i18n}:<br />{$oState->getName()|sanitize}</h2>

<p class="descriptiveText">{i18n}As documents move through their lifecycle, they
are placed in certain <strong>states</strong>.  For example, an invoice
which has been mailed might be in the "Pending" <strong>state</strong> after
the "sent" <strong>transition</strong> has been performed by a user.{/i18n}</p>

<form action="{$smarty.server.PHP_SELF}" method="POST">
<fieldset>
<legend>{i18n}Edit state properties{/i18n}</legend>
<input type="hidden" name="action" value="saveState" />
<input type="hidden" name="fWorkflowId" value="{$oWorkflow->getId()}" />
<input type="hidden" name="fStateId" value="{$oState->getId()}" />
{foreach item=oWidget from=$editForm}
  {$oWidget->render()}
{/foreach}
<div class="form_actions">
    <input type="submit" name="submit" value="{i18n}Save{/i18n}" />
</div>
</fieldset>
</form>


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

<fieldset>
<legend>{i18n}Inform Which Users?{/i18n}</legend>
<p class="descriptiveText">{i18n}Please select which roles or groups should be
informed when this state is reached.{/i18n}</p>


{if $aRoles}
<h3>{i18n}Roles{/i18n}</h3>
{entity_checkboxes entities=$aRoles name="fNotification[role]" multiple="true" selected=$aInformed.role assign=aBoxes}
{foreach from=$aBoxes item=sBox}
{$sBox}<br />
{/foreach}
{/if}

{if $aGroups}
<h3>{i18n}Groups{/i18n}</h3>
{entity_checkboxes entities=$aGroups name="fNotification[group]" multiple="true" selected=$aInformed.group assign=aBoxes}
{foreach from=$aBoxes item=sBox}
{$sBox}<br />
{/foreach}
{/if}

{if (empty($aGroups) && empty($aRoles))}
<div class="ktInfoMessage"><span>{i18n}No groups or roles are defined in the DMS.{/i18n}</span></div>
{else}
<div class="form_actions">
  <input type="submit" value="{i18n}Update users to inform{/i18n}" />
</div>
{/if}

</fieldset>
</form>

{*
<h3>{i18n}Assigned Permissions{/i18n}</h3>
<p class="descriptiveText">{i18n}While in this workflow state, additional permissions
may be given.  This is done either to expose the document to more users
or to allow a particular role to be fulfilled before a workflow
transition can be accomplished.{/i18n}</p>
*}


<fieldset>
<legend>{i18n}Transitions{/i18n}</legend>

<p class="descriptiveText">{i18n}Transitions are how documents move from one
state to another.  Typically, most transitions can only be performed by people
with a specific <strong>role</strong> (e.g. Manager) or part of a specific group
(e.g. Marketing Department).{/i18n}</p>

{if $aTransitionsTo}
<h3>{i18n}Transitions to this state{/i18n}</h3>
{if (!empty($aTransitionsTo))}
<ul>
{foreach from=$aTransitionsTo item=oTransition}
  <li><a
href="{addQS}action=editTransition&fWorkflowId={$oWorkflow->getId()}&fTransitionId={$oTransition->getId()}{/addQS}"
title="Transition
{$oTransition->getId()}">{$oTransition->getName()}</a></li>
{/foreach}
</ul>

{/if}
{else}
<div class="ktInfoMessage"><span>{i18n}No transitions lead to this state.{/i18n}</span></div>
{/if}

<h3>{i18n}Transitions from this state{/i18n}</h3>
<form action="{$smarty.server.PHP_SELF}" method="POST">
<input type="hidden" name="action" value="saveTransitions" />
<input type="hidden" name="fWorkflowId" value="{$oWorkflow->getId()}" />
<input type="hidden" name="fStateId" value="{$oState->getId()}" />

{if (!empty($aTransitions))}
{entity_checkboxes entities=$aTransitions name="fTransitionIds" multiple="true" selected=$aTransitionsSelected separator="<br />"}
<div class="form_actions">
<input type="submit" name="submit" value="{i18n}Save{/i18n}" />
</div>
{else}
<div class="ktInfoMessage"><span>{i18n}No transitions have been defined for this workflow.{/i18n}</span></div>
{/if}
</form>
</fieldset>

{if (!empty($aActions))}
<form action="{$smarty.server.PHP_SELF}" method="POST">
<fieldset>
<legend>{i18n}Actions allowed{/i18n}</legend>

<input type="hidden" name="action" value="setStateActions" />
<input type="hidden" name="fWorkflowId" value="{$oWorkflow->getId()}" />
<input type="hidden" name="fStateId" value="{$oState->getId()}" />

<ul>
{entity_checkboxes name="fActions" entities=$aActions idmethod="getName" method="getDisplayName" assign="aCheckboxes" selected="$aActionsSelected"}
{foreach from=$aCheckboxes item=sCheckbox}
<li>{$sCheckbox}</li>
{/foreach}
</ul>
<div class="form_actions">
  <input type="submit" name="submit" value="{i18n}Set allowed actions{/i18n}" />
</div>
</fieldset>
</form>
{else}
<div class="ktInfoMessage"><span>{i18n}No actions are controlled by this workflow, so all actions are available when
documents are in this state.{/i18n}</span></div>
{/if}


{if (!empty($permissions))}
<form action="{$smarty.server.PHP_SELF}" method="POST">
<fieldset>
<legend>{i18n}Controlled Permissions{/i18n}</legend>

<input type="hidden" name="action" value="setStatePermissions" />
<input type="hidden" name="fWorkflowId" value="{$oWorkflow->getId()}" />
<input type="hidden" name="fStateId" value="{$oState->getId()}" />

<ul>
{entity_checkboxes name="fPermissions" entities=$permissions idmethod="getName" method="getHumanName" assign="aCheckboxes" selected="$state_permissions"}
{foreach from=$aCheckboxes item=sCheckbox}
<li>{$sCheckbox}</li>
{/foreach}
</ul>
<div class="form_actions">
  <input type="submit" name="submit" value="{i18n}Set controlled permissions{/i18n}" />
</div>
</fieldset>
</form>

{if (!empty($state_permissions))}
<form action="{$smarty.server.PHP_SELF}" method="POST">

<input type="hidden" name="action" value="assignStatePermissions" />
<input type="hidden" name="fWorkflowId" value="{$oWorkflow->getId()}" />
<input type="hidden" name="fStateId" value="{$oState->getId()}" />

<table cellspacing="0" class="kt_collection">
<thead>
  <tr>
    <th>{i18n}Role or Group{/i18n}</th>
    {foreach from=$state_permissions item=sPermName}
    <th>{$permissions.$sPermName->getHumanName()}</th>
    {/foreach}
  </tr>
</thead>
<tbody>
{ foreach item=oRole from=$aRoles }
<tr>
    <td><span class="descriptiveText">{i18n}Role{/i18n}: </span>{$oRole->getName()}</td>
    { foreach from=$state_permissions item=sPermName }
    <td><input type="checkbox" name="fPermissions[{$sPermName}][role][]" value="{$oRole->getId()}" {if ($context->getRoleHasPermissionInState($oRole, $sPermName, $oState))}checked="true"{/if}/></td>
    { /foreach }
</tr>
{ /foreach }
{ foreach item=oGroup from=$aGroups }
<tr>
    <td><span class="descriptiveText">{i18n}Group{/i18n}: </span>{$oGroup->getName()}</td>
    { foreach from=$state_permissions item=sPermName }
    <td><input type="checkbox" name="fPermissions[{$sPermName}][group][]" value="{$oGroup->getId()}"{if ($context->getGroupHasPermissionInState($oGroup, $sPermName, $oState))}checked="true"{/if}/></td>
    { /foreach }
</tr>
{ /foreach }
</tbody>
</table>

<div class="form_actions">
<input type="submit" value="{i18n}Update Allocated Permissions{/i18n}"/>
</div>

</form>
{/if}

{else}
<div class="ktInfoMessage"><span>{i18n arg_appname="$appname"}No permissions have been created within #appname#.{/i18n}</span></div>
{/if}






