<nav class="large-3 medium-4 columns" id="actions-sidebar">
      <?= $this->element('admin_sidebar') ?>
</nav>

<div class="users index large-9 medium-8 columns content">
  <div class="col-md-1">   
   <h3><?= __('Users') ?></h3>
   </div>
    
 <div class="search-wrapper">  
  <div class="col-md-9">
	<div class="search-filter"><?= $this->Search->filterForm($searchFilters) ?></div></div>
	  <div class="col-md-2">
	<div class="btn-link"><?= $this->Html->link(__('Add User'), ['action' => 'add'], ['class'=>'green-btn', 'title' => 'Add New User', 'type' => 'button']) ?></div></div>
</div>
    <table class="tbl-wrapper" cellpadding="0" cellspacing="0">
        <thead>
            <tr>
               <th style="width:50px;" scope="col"><?= $this->Paginator->sort('Sr No') ?></th>
                <th scope="col"><?= $this->Paginator->sort('username') ?></th>
                <th scope="col"><?= $this->Paginator->sort('First Name') ?></th>
                <th scope="col"><?= $this->Paginator->sort('Last Name') ?></th>
                <th scope="col"><?= $this->Paginator->sort('group_id') ?></th>
                <th scope="col"><?= $this->Paginator->sort('created') ?></th>
                <th scope="col"><?= $this->Paginator->sort('modified') ?></th>
                <th scope="col" class="actions"><?= __('Actions') ?></th>
            </tr>
        </thead>
        <tbody>
            <?php $srlno = ($this->request->params['paging']['Users']['page']-1) * $this->request->params['paging']['Users']['perPage'];
            $j=1;
foreach ($users as $user): $srlno++; ?>
            <tr>
                <td><?=$srlno ?></td>
                <td><?= h($user->username) ?></td>
                <td><?= h($user->firstname) ?></td>
                <td><?= h($user->lastname) ?></td>                
                <td><?= $user->has('group') ? $this->Html->link($user->group->name, ['controller' => 'Groups', 'action' => 'view', $user->group->id]) : '' ?></td>
                <td><?php $created = explode(" ", $user->created);
                 echo $created[0];
                ?></td>
                <td><?php $created = explode(" ", $user->modified);
                 echo $created[0];
                ?></td>
                <td class="actions">
                    <?= $this->Html->link(__('View'), ['action' => 'view', $user->id], ['class' => 'view','title'=>__('View')]) ?>
                  
                    
<?php  if($this->request->session()->read('Auth.User.group_id')=='2'){ ?>  

                    <?= $this->Html->link(__('Edit'), ['action' => 'edit', $user->id], ['class' => 'edit','title'=>__('Edit')]) ?>
                    <?= $this->Form->postLink(__('Delete'), ['action' => 'delete', $user->id], ['class' => 'delete','title'=>__('Delete'),'confirm' => __('Are you sure you want to delete # {0}?', $user->id)]) ?>
<?php } ?>
<?php  if($this->request->session()->read('Auth.User.group_id')=='3'){ ?>  
 
                    <?= $this->Html->link(__('Edit'), ['action' => 'edit', $user->id], ['class' => 'edit','title'=>__('Edit')]) ?>
                    
<?php } ?>
                </td>
            </tr>
            <?php $j++; endforeach; ?>
        </tbody>
    </table>
<div class="btn-link"><input type="button" value="Back" onclick="window.history.back()" class="green-btn" /> </div>
    <div class="paginator">
        <ul class="pagination">
             <?= $this->Paginator->first(__('First', true), array('class' => 'disabled')); ?>
            <?= $this->Paginator->prev('< ' . __('previous',true), array('class' => 'disabled')) ?>
            <?= $this->Paginator->numbers() ?>
            <?= $this->Paginator->next(__('next' . ' >',true), array('class' => 'disabled')) ?>
		 <?=  $this->Paginator->last(__('Last', true), array('class' => 'disabled')); ?>
        </ul>
        <p><?= $this->Paginator->counter() ?></p>
    </div>
</div>
