<h2>{i18n}Saved searches{/i18n}</h2>

<p class="descriptiveText">{i18n}Saved searches are searches which are particular to your location
For example, you could define a search which returns all documents in a particular workflow state,
or all documents which are considered "common" within your organisation (leave policy,
newsletters, etc.) based on a category or fieldset value.{/i18n}</p>

<form action="{$smarty.server.PHP_SELF}" method="POST">
<fieldset>
<legend>{i18n}Create a new saved search{/i18n}</legend>
<div>
<input type="hidden" name="action" value="new" />
<input type="submit" name="submit" value="{i18n}New{/i18n}" />
</div>
</fieldset>
</form>

{if $saved_searches}
<h2>{i18n}Existing Searches{/i18n}</h2>

<table class="listing">
<thead>
    <tr>
        <th>{i18n}Search Name{/i18n}</th>
        <th>{i18n}User{/i18n}</th>
        <th>{i18n}Edit{/i18n}</th>
        <th>{i18n}Delete{/i18n}</th>
        <th>{i18n}View Results{/i18n}</th>
    </tr>
</thead>
<tbody>
{foreach item=oSearch from=$saved_searches}
    <tr>
        <td>{$oSearch->getName()|sanitize}</td>
	{capture assign=iUserId}{$oSearch->getUserId()}{/capture}
	<td>{if ($iUserId === '')}Global{else}{$context->_getUserName($iUserId)}{/if}</td>
        <td><a href="{addQS}action=edit&fSavedSearchId={$oSearch->getId()}{/addQS}" class="ktAction ktEdit">{i18n}Edit{/i18n}</a></td>
        <td><a href="{addQS}action=delete&fSavedSearchId={$oSearch->getId()}{/addQS}" class="ktAction ktDelete">{i18n}Delete{/i18n}</a></td>
        <td><a href="{"booleanSearch"|generateControllerUrl}&qs[action]=performSearch&qs[fSavedSearchId]={$oSearch->getId()}">{i18n}Run Search{/i18n}</a></td>
    </tr>
{/foreach}
</tbody>
</table>
{else}
<div class="ktInfoMessage"><span>{i18n}No Saved Searches have been defined.{/i18n}</span></div>
{/if}
