{layout @admin.html}
{block content}
<div class="column-group horizontal-gutters top-space">
  <div class="xlarge-75 large-75 medium-75 small-100 tiny-100">
    <h1>{_'templates'}</h1>
  </div>
  <div class="xlarge-25 large-25 medium-25 small-100 tiny-100 bottom-space">
    <a class="ink-button green" href="{=BASE_URL}template/add">{_'new_template'}</a>
  </div>
</div>
<div class="column-group horizontal-gutters">
  <div class="xlarge-75 large-75 medium-100 small-100 tiny-100">
    {if $templates}
    <table class="ink-table alternating hover medium">
      <thead>
	<th class="align-left">{_'name'}</th>
	<th class="align-left">{_'created_at'}</th>
	<th class="align-left">{_'updated_at'}</th>
	<th colspan="2"></th>
      </thead>
      <tbody>
	{foreach $templates as $template}
	<tr>
	  <td>{$template->name}</td>
	  <td>{$template->created_at|date:$mediumDate}</td>
	  <td>{$template->updated_at|date:$mediumDate}</td>
	  <td><a href="{=BASE_URL}template/update/{$template->template_id}"><img alt="{_'update'}" src="public/images/edit_24.png"></a></td>
	  {var $confirm = ('confirm_delete_template'|translate:$template->name)}
	  <td><a href="{=BASE_URL}template/delete/{$template->template_id}"><img src="public/images/delete_24.png" alt="{_'remove_template'}" title="{_'remove_template'}" onclick="return confirm('{$confirm|noescape}');"></a></td>
	</tr>
	{/foreach}
      </tbody>
    </table>
    {include 'pagination/ink.html', url: BASE_URL . 'template/list?page=%d'}
    {/if}
  </div>
  <div class="xlarge-25 large-25 medium-100 small-100 tiny-100">
    <div>
      <header>
	<h2 class="medium">{_}last_modified_templates{/_}</h2>
      </header>
      <hr>
      <div class="small">
	<ul>
	  {foreach models\Template::findLastModifiedTemplates() as $template}
	  <li>#{$template->template_id} <a href="{=BASE_URL}template/update/{$template->template_id}">{$template->name}</a> <span class="small-date">({$template->updated_at|date:$mediumDate})</span></li>
	  {/foreach}
	</ul>
      </div>
    </div>
    <div class="top-space">
      <header>
	<h2 class="medium">{_}last_created_templates{/_}</h2>
      </header>
      <hr>
      <div class="small">
	<ul>
	  {foreach models\Template::findLastCreatedTemplates() as $template}
	  <li>#{$template->template_id} <a href="{=BASE_URL}template/update/{$template->template_id}">{$template->name}</a> <span class="small-date">({$template->created_at|date:$mediumDate})</span></li>
	  {/foreach}
	</ul>
      </div>
    </div>
  </div>
</div>
{/block}
