<section class="pcoded-main-container">
<div class="pcoded-content">
    <div class="page-header">
        <div class="page-block"> 
            <div class="row align-items-center">
                <div class="col-md-12">
                    <div class="page-header-title">
                        <h5 class="m-b-10">Users
                        <?php if(@$userright_arr[0]->add_r):?>
                            <?php echo $this->Html->link('<i class="feather icon-plus-square" ></i> Add User',array('controller'=>'Users','action'=>'add'), array('class' => 'btn btn-primary pull-right','escape'=>false),array());?>
                        <?php endif;?>
                        </h5>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-xl-12 col-md-12">
            <div class="card">
                <div class="card-body table-border-style">
                    <div class="table-responsive dataTables_wrapper dt-bootstrap4" scroll="no" style="overflow: hidden">
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="pull-right">
                                <?= $this->Form->create('user') ?>
                                <div id="colum-rendr_filter" class="dataTables_filter">
                                    <label><input type="search" placeholder='Search by username, email and phone' name="search"  class="form-control"  aria-controls="users" value="<?= @$searchData['search']?>"></label>
                                     <?= $this->Form->button('<i class="fas fa-search"></i> Submit',['type' => 'submit','class'=>'btn btn-success'],['escape' =>false]) ?>
                                </div>
                                <?= $this->Form->end() ?>
                            </div>
                                <table class="table">
                                    <thead>
                                        <tr>
                                            <th scope="col">#</th>
                                            <th scope="col"><?= $this->Paginator->sort('username') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('display_name') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('status') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('email') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('phone_no') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('created') ?></th>
                                            <th scope="col" class="actions"><?= __('Actions') ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $i = 1; if(!empty($users)){ foreach ($users as $user): ?>
                                        <tr>
                                            <td><?= $i++     ?></td>
                                            <td><?= h($user->username) ?></td>
                                            <td><?= h($user->display_name) ?></td>
                                            <td class="actions"><?php
                                                if($user->status ==1){
                                                    echo "<span class=' btn btn-success' title='Allotted'>Active</span>";
                                                }else{
                                                    echo "<span class='btn btn-danger' title='Not allotted'>Not Active</span>";
                                                }
                                             ?></td>
                                            <td><?= h($user->email) ?></td>
                                            <td><?= h($user->mobile) ?></td>
                                            <td><?= date('d-M-y H:i A',strtotime($user->created))  ?></td>
                                            <td class="actions">
                                            <?php if(@$userright_arr[0]->details_r):?>
                                                <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"fas fa-eye btn btn-success")), array('action' => 'view', $user->id),array('escape'=>false)) ?>
                                                <?php endif;?>
                                                <?php if(@$userright_arr[0]->edit):?>
                                                <?= $this->Html->link($this->Html->tag('i', '', array('class'=>"feather icon-edit btn btn-primary")), array('action' => 'edit', $user->id),array('escape'=>false)) ?>
                                                <?php endif;?>
                                                <?php if(@$userright_arr[0]->delete_r):?>
                                                <?= $this->Form->postLink($this->Html->tag('i', '', array('class' => "feather icon-trash-2 btn btn-danger")),
                                                    array('action' => 'delete', $user->id),
                                                    array('escape'=>false,'confirm' => __('Are you sure you want to delete # {0}?', $user->id))) ?>
                                                <?php endif;?>
                                            </td>
                                        </tr>
                                        <?php endforeach; }else{ ?>
                                            <tr><td colspan="6">No Records Found!</td></tr>
                                        <?php } ?>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <?php if($filter == 0){ ?>
                        <div class="row">
                            <div class="col-sm-12 col-md-5">
                            <div class="dataTables_info" id="user-list-table_info" role="status" aria-live="polite"><?= $this->Paginator->counter(['format' => __('Page {{page}} of {{pages}}, showing {{current}} record(s) out of {{count}} total')]) ?></div>
                            </div>
                            <div class="col-sm-12 col-md-7">
                                <div class="dataTables_paginate paging_simple_numbers" id="user-list-table_paginate">
                                    <ul class="pagination">
                                       <?php 
                                        echo $this->Paginator->prev( '<<', array( 'class' => '', 'tag' => 'li' ), null, array( 'class' => 'dsisabled myclass', 'tag' => 'li' ) );
                                        echo $this->Paginator->numbers( array( 'tag' => 'li', 'separator' => '', 'currentClass' => 'disabled myclass' ) );
                                        echo $this->Paginator->next( '>>', array( 'class' => '', 'tag' => 'li' ), null, array( 'class' => 'disabled myclass', 'tag' => 'li' ) );
                                    ?>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    <?php } ?>
                    </div>
                </div> 
            </div>
         </div> 
    </div>  
</div>
</section>