n<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">Essay Test
                                <?php //if(@$userright_arr[0]->add_r):
                                ?>
                                <?php //echo $this->Html->link('<i class="feather icon-plus-square" ></i> Add Essay', array('controller' => 'EssayTest', '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-md-6 col-xl-3">
                <div class="card bg-c-blue order-card">
                    <div class="card-body downlist">
                        <h6 class="text-white">Total Test</h6>
                        <h2 class="text-right text-white"><i class="feather icon-type float-left"></i>
                            <?= @$essayCount->total; ?></h2>

                    </div>
                </div>
            </div>
            <div class="col-md-6 col-xl-3">
                <div class="card bg-c-yellow order-card">
                    <div class="card-body downlist">
                        <h6 class="text-white">Pending Test</h6>
                        <h2 class="text-right text-white"><i class="feather icon-users float-left"></i>
                            <?= @$essayCount->pending; ?>
                        </h2>

                    </div>
                </div>
            </div>
            <div class="col-md-6 col-xl-3">
                <div class="card bg-c-green order-card">
                    <div class="card-body downlist">
                        <h6 class="text-white">Pass Test</h6>
                        <h2 class="text-right text-white"><i class="feather icon-user-check float-left"></i>
                            <?= @$essayCount->pass; ?>
                        </h2>

                    </div>
                </div>
            </div>
            <div class="col-md-6 col-xl-3">
                <div class="card bg-c-red order-card">
                    <div class="card-body downlist">
                        <h6 class="text-white">Fail Test</h6>
                        <h2 class="text-right text-white"><i class="feather icon-user-x float-left"></i>
                            <?= @$essayCount->fail; ?>
                        </h2>

                    </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">
                            <div class="row">
                                <div class="col-sm-12">
                                    <table class="table">
                                        <thead>
                                            <tr>
                                                <th scope="col"><?= $this->Paginator->sort('id') ?></th>
                                                <!-- <th scope="col"><?= $this->Paginator->sort('topic') ?></th> -->
                                                <!-- <th scope="col"><?= $this->Paginator->sort('g_mistakes') ?></th> -->
                                                <th scope="col"><?= $this->Paginator->sort('freelancer_id') ?></th>
                                                <th scope="col"><?= $this->Paginator->sort('category') ?></th>
                                                <th scope="col"><?= $this->Paginator->sort('result') ?></th>
                                                <th scope="col"><?= $this->Paginator->sort('created') ?></th>
                                                <th scope="col" class="actions"><?= __('Actions') ?></th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <tr>
                                                <?= $this->Form->create('essayTest', ['type' => 'get', 'id' => 'filter']) ?>
                                                <td>Filters</td>
                                                <td><label><input type="search" autocomplete="off" placeholder='Search name' name="freelancer" class="form-control" value="<?= @$this->request->query['freelancer'] ?>"></label></td>
                                                <td>
                                                    <label>
                                                        <select type="select" name="category" class="form-control">
                                                            <?php foreach ($category as $key => $cat) {
                                                            ?>
                                                                <option value="<?= $key ?>" <?= @$this->request->query['category'] == $key ? 'selected' : '' ?>><?= $cat ?></option>

                                                            <?php } ?>
                                                        </select>
                                                    </label>
                                                </td>


                                                <td>
                                                    <label>
                                                        <select type="select" name="exam_status" class="form-control">
                                                            <option>Select</option>
                                                            <option value="0" <?= @$this->request->query['exam_status'] === '0' ? 'selected' : '' ?>>Result Pending</option>
                                                            <option value="1" <?= @$this->request->query['exam_status'] == 1 ? 'selected' : '' ?>>Pass</option>
                                                            <option value="2" <?= @$this->request->query['exam_status'] == 2 ? 'selected' : '' ?>>Fail</option>

                                                        </select>
                                                    </label>
                                                </td>
                                                <td><label><input type="text" autocomplete="off" placeholder='Search By Date' name="datefilter" class="form-control" value="<?= @$this->request->query['datefilter'] ?>"></label></td>
                                                <td>
                                                    <?= $this->Form->button('<i class="fas fa-search"></i>', ['type' => 'submit', 'class' => 'btn btn-success'], ['escape' => false]) ?>
                                                    <?= $this->Form->button('<i class="fas fa-redo-alt"></i>', ['type' => 'reset', 'class' => 'btn btn-danger reset-btn', 'onclick' => 'clearFilter(`essay-test`)'], ['escape' => false]) ?>
                                                </td>
                                                <?= $this->Form->end() ?>
                                            </tr>
                                            <?php
                                            $i = 1;
                                            foreach ($essayTest as $k => $essayTest) : ?>
                                                <tr <?= $essayTest->view ? '' : 'style="background: aliceblue;"' ?>>
                                                    <td><?= $i; ?></td>
                                                    <!-- <td><?= $this->Number->format($essayTest->topic) ?></td>
                                                    <td><?= $this->Number->format($essayTest->g_mistakes) ?></td> -->
                                                    <td><?= $essayTest->has('freelancer') ? $this->Html->link($essayTest->freelancer->name, ['controller' => 'Freelancers', 'action' => 'view', $essayTest->freelancer->id]) : '' ?></td>
                                                    <td><?= !empty($essayTest->category_id) ?  $this->Custom->getCategoryName($essayTest->category_id) : '-'; ?></td>
                                                    <td><?php if ($essayTest->result == 1) {
                                                            echo '<i class="fas fa-check-circle" style="color:#2ed8b6"></i>';
                                                        } elseif ($essayTest->result == 2) {
                                                            echo '<i class="fas fa-times-circle" style="color:#ff5370"></i>';
                                                        } else {
                                                            echo '<i class="far fa-question-circle" style="color:#FF9966"></i>';
                                                        }
                                                        ?>
                                                    </td>
                                                    <td><?= date('d M,Y', strtotime($essayTest->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', $essayTest->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', $essayTest->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', $essayTest->id),
                                                                array(
                                                                    'escape' => false,
                                                                    'confirm' => __('Are you sure you want to delete # {0}?', $essayTest->id)
                                                                )
                                                            ) ?>
                                                        <?php endif; ?>
                                                    </td>
                                                </tr>
                                            <?php $i++;
                                            endforeach; ?>
                                        </tbody>
                                    </table>
                                    <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>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>