<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">Questions
                            <?php 
                            if(@$userright_arr[0]->add_r  ):
                                echo $this->Html->link('<i class="feather icon-plus-square" ></i> Add Question',array('controller'=>'Questions','action'=>'add'), array('class' => 'btn btn-primary pull-right','escape'=>false),array());
                            endif;
                            if(@$userright_arr[0]->edit):  
                                echo $this->Html->link('<i class="fas fa-file-upload"></i> Bulk Upload',array('controller'=>'Questions','action'=>'bulkUpload'), array('class' => 'btn btn-success pull-right mr-2','escape'=>false),array());
                            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('question') ?>
                                    <div id="colum-rendr_filter" class="dataTables_filter">
                                        <label><input type="search" placeholder='Search by paper and question' name="search"  class="form-control"  aria-controls="questions"></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" class="w-25"><?= $this->Paginator->sort('question') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('correct_ans') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('paper_id') ?></th>
                                            <th scope="col"><?= $this->Paginator->sort('created') ?></th>
                                           
                                            <th scope="col" class="actions"><?= __('Actions') ?></th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                        <?php $i=1; foreach ($questions as $question): ?>
                                        <tr>
                                            <td><?= $i++ ?></td>
                                            <td><?= h($question->question) ?></td>
                                            <td><?= h($question->correct_ans) ?></td>
                                            <td><?= $question->has('paper') ? $this->Html->link($question->paper->subject, ['controller' => 'Papers', 'action' => 'view', $question->paper->id]) : '' ?></td>
                                            <td><?= date('d M,Y',strtotime($question->created))  ?></td>
                                           
                                            <td class="actions">
                                                <?php if(@$userright_arr[0]->details_r):
                                                echo $this->Html->link($this->Html->tag('i', '', array('class'=>"fas fa-eye btn btn-success")), array('action' => 'view', $question->id),array('escape'=>false)); 
                                                endif;
                                                if(@$userright_arr[0]->edit):
                                                echo $this->Html->link($this->Html->tag('i', '', array('class'=>"feather icon-edit btn btn-primary")), array('action' => 'edit', $question->id),array('escape'=>false)) ;
                                                endif;
                                                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', $question->id),
                                                    array('escape'=>false,'confirm' => __('Are you sure you want to delete # {0}?', $question->id))) ?>
                                                <?php endif; ?>
                                            </td>
                                        </tr>
                                        <?php endforeach; ?>
                                    </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>    
</div>
</section>