<?php
echo $this->Html->css('ionicons.min.css');
?>

<?= $this->element('page_top', array('title' => __('Letter Sent History'), 'permissions' => $user_permission)); ?>

<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-header">
                <div class="row">
                    <div class="col-md-12">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="row">
                                    <div class="col-md-6 ">
                                        <div class="row">
                                            <?= $this->Form->create(null, array('type' => 'get', 'id' => 'limitForm')); ?>
                                            <div class="col-md-2"><strong>Show</strong></div>
                                            <div class="col-md-5">
                                                <?php echo $this->element('pagination_dropdown');?>
                                            </div>
                                            <?= $this->Form->end(); ?>
                                        </div>
                                    </div>
                                </div>
                            </div><!-- /col-md-6 -->
                            <div class="col-md-6">

                                <div class="row">

                                    <div class="col-md-12">

                                        <div class="row">

                                            <div class="col-md-8 pull-right">
                                                <?= $this->Form->create(null, array('type' => 'get')); ?>

                                                <div class="box-tools">
                                                    <div class="input-group input-group-sm">

                                                        <?= $this->Form->input('', [ 'placeholder' => __('SEARCH'), 'class' => 'form-control', 'type' => 'text', 'name' => 'search', 'value' => $searchText, 'id' => 'search']); ?>

                                                        <div class="input-group-btn">
                                                            <?= $this->Form->submit(__('Search'), [ 'class' => 'btn btn-success btn-flat']); ?>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <?= $this->Form->end(); ?>
                                    </div>
                                    <div class="col-md-12">
                                        &nbsp;
                                    </div>

                                    <!-- /row -->
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- /.box-header -->
                <div class="box-body table-responsive index-table-section">
                    <table class="table table-bordered table-hover" id="index-table">

                        <thead>
                        <tr>

                            <th><?= $this->Paginator->sort('id', ['value' => __('Id')]) ?></th>
                            <th><?= $this->Paginator->sort('report_format_id', ['value' => __('Report Format')]) ?></th>
                            <th><?= $this->Paginator->sort('student_email', ['value' => __('Student Email')]) ?></th>
                            <th><?= $this->Paginator->sort('sent_date', ['value' => __('Send Date')]) ?></th>
                            <th><?= $this->Paginator->sort('created_at', ['value' => __('Created On')]) ?></th>
                            <th> Action </th>

                        </tr>
                        </thead>
                        <tbody>
                        <?php if(!empty($report_format_histories)){?>

                            <?php foreach ($report_format_histories as $report_format_history):?>

                                <tr>
                                    <td><?php echo $report_format_history['id'] ?></td>
                                    <td><?php echo $report_format_history->report_format['name'] ?></td>
                                    <td><?php echo $report_format_history['student_email'] ?></td>
                                    <td><?php echo $report_format_history['sent_date']->format('d-m-Y') ?></td>
                                    <td><?php echo $report_format_history['created_at'] ?></td>
                                    <td>
                                        <?= $this->Form->create(null, [
                                            'url' => ['controller' => 'LetterSentHistory', 'action' => 'resend', $report_format_history['id']],
                                            'style' => 'display:inline;'
                                        ]) ?>
                                        <?= $this->Form->button('<i class="fa fa-paper-plane" aria-hidden="true"></i>', [
                                            'escape' => false,
                                            'title' => 'Resend',
                                            'onclick' => "return confirm('Are you sure you want to resend this letter?');",
                                            'style' => 'background:none;border:none;color:#3c8dbc;padding-left:5px;font-size:18px;'
                                        ]) ?>
                                        <?= $this->Form->end() ?>
                                        <?= $this->Form->create(null, [
                                            'url' => ['controller' => 'LetterSentHistory', 'action' => 'download', $report_format_history['id']],
                                            'style' => 'display:inline;'
                                        ]) ?>
                                        <?= $this->Form->button('<i class="fa fa-download" aria-hidden="true"></i>', [
                                            'escape' => false,
                                            'title' => 'Download',
                                            'onclick' => "return confirm('Are you sure you want to download this letter?');",
                                            'style' => 'background:none;border:none;color:#3c8dbc;padding-left:5px;font-size:18px;'
                                        ]) ?>
                                        <?= $this->Form->end() ?>
                                        <a href="<?php echo $this->Url->build(["controller" => 'LetterSentHistory', "action" => "view", $report_format_history['id']]) ?>"  title="View">
                                                    <span style="color:#3c8dbc;padding-left:5px;font-size:18px;">
                                                        <i class="fa fa-eye" aria-hidden="true"></i>
                                                    </span>
                                        </a>
                                        <a   href="<?php echo $this->Url->build(["controller" => 'LetterSentHistory', "action" => "delete", $report_format_history['id']]) ?>" onclick="return confirm('Are you sure you want to delete?');"  title="Remove">
                                                    <span style="color:#8B0000;padding-left:5px;font-size:18px;">
                                                        <i class="fa fa-remove" aria-hidden="true"></i>
                                                    </span>
                                        </a>

                                    </td>
                                </tr>

                            <?php

                            endforeach;
                        }
                        ?>
                        </tbody>
                    </table>


                </div>
                <!-- /.box-body -->

                <?php echo $this->element('pagination') ?>
            </div>
            <!-- /.box -->


        </div>
    </div>




</div>




