{extends file='ls:base_connected.tpl'}
{block name="content"}
<h1>{$pagetitle}</h1>
{include file='ls:LSview_actions.tpl'}

<table class='LStable objectAccessLogs'>
  <thead>
    <tr>
      <th>{tr msg="Date"}</th>
      <th>{tr msg="Author"}</th>
      <th>{tr msg="Operation"}</th>
      <th>{tr msg="Result"}</th>
      <th>{tr msg="Details"}</th>
    </tr>
  </thead>
  <tbody>
  {foreach $page.logs as $log}
    <tr>
      <td>{$log.start->format('Y/m/d H:i:s')}</td>
      <td class="center">{if $log.author_dn}<span title='{$log.author_dn|escape:quotes}' class='LStips'>{$log.author_rdn}</span>{/if}</td>
      <td class="center">{$log.type}</td>
      <td class="center">{$log.result}{if $log.message} <img class='LStips' src="{img name='help'}" alt="?" title='{$log.message|escape:quotes}'/>{/if}</td>
      <td>
        {if $log.mods}
        <table class="mods">
          <thead>
           <tr>
             <th class="col-op">{tr msg="Operation"}</th>
             <th class="col-attr">{tr msg="Attribute"}</th>
             <th class="col-value">{tr msg="Old value(s)"}</th>
             <th class="col-value">{tr msg="Value"}</th>
           </tr>
         </thead>
         <tbody>
           {foreach $log.mods as $attr => $info}
             {foreach $info.changes as $op => $new_values}
           <tr class="operation">
             <td class="col-op center">{$op|escape:htmlall}</td>
             <td class="col-attr center">{$attr}</td>
             <td class="col-value">
               {if $info.old_values}
               <div class="copyable copyable-no-btn">
                 {if count($info.old_values) == 1 && count($new_values) <= 1}
                   {$info.old_values[0]|escape:'htmlall'}
                 {else}
                   <ul>
                   {foreach $info.old_values as $old_value}
                     <li>{$old_value|escape:'htmlall'}</li>
                   {/foreach}
                   </ul>
                 {/if}
               </div>
               {/if}
             </td>
             <td class="col-value">
               {if $new_values}
               <div class="copyable copyable-no-btn">
                 {if count($new_values) == 1 && count($info.old_values) <= 1}
                   {$new_values[0]|escape:'htmlall'}
                 {else}
                   <ul>
                   {foreach $new_values as $new_value}
                     <li>{$new_value|escape:'htmlall'}</li>
                   {/foreach}
                   </ul>
                 {/if}
               </div>
               {/if}
             </td>
           </tr>
             {/foreach}
           {/foreach}
         </tbody>
        </table>
        {/if}
      </td>
    </tr>
  {foreachelse}
    <tr>
      <td class="center" colspan="4">{tr msg="No access log found for this object."}</td>
    </tr>
  {/foreach}
  </tbody>
</table>
<p style='text-align: right; padding: 1em;'>{count($page.logs)} {tr msg="event(s) found for this object."}</p>

{include file='ls:pagination.tpl'}
{/block}
