
<?php $this->load->view('site/layout'); ?>
<link href="<?php echo base_url() ?>public/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />

<?php $this->load->view('site/navbar'); ?>


<div class="kt-content  kt-grid__item kt-grid__item--fluid kt-grid kt-grid--hor" id="kt_content">

    <!-- begin:: Content Head -->
    <div class="kt-subheader  kt-grid__item" id="kt_subheader">
        <div class="kt-container  kt-container--fluid ">
            <div class="kt-subheader__main">
                <h3 class="kt-subheader__title"><a href="<?php echo base_url() ?>Dashboard/"><?php echo $this->lang->line('dashboard'); ?></a></h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <h3 class="kt-subheader__title"><a href="<?php echo base_url() ?>quraan/sessions"><?php echo $this->lang->line('sessions'); ?></a></h3>
                <span class="kt-subheader__separator kt-subheader__separator--v"></span>
                <span class="kt-subheader__desc"><?php echo $this->lang->line('sessions_plans'); ?></span>
            </div>

        </div>
    </div>
</div>

<div class="kt-portlet kt-portlet--mobile">
    <div class="kt-portlet__head kt-portlet__head--lg">
        <div class="kt-portlet__head-label">
            <span class="kt-portlet__head-icon">
                <i class="kt-font-brand flaticon2-line-chart"></i>
            </span>
            <h3 class="kt-portlet__head-title">
                <?php echo $this->lang->line('sessions_plans'); ?>
            </h3>
        </div>
        <div class="kt-portlet__head-toolbar">
            <div class="kt-portlet__head-wrapper">
                <div class="kt-portlet__head-actions">

                    &nbsp;
                    <?php if (get_ap('qs_plans_add', $this->operator_id) == 1) { ?><a href="<?= base_url() ?>/quraan/sessions/add_session_plans/<?= $session_id ?>" class="btn btn-brand btn-elevate btn-icon-sm">
                            <i class="la la-plus"></i>
                            <?php echo $this->lang->line('add-a-plan') ?>
                        </a><?php } ?>
                </div>
            </div>
        </div>
    </div>
    <?php if ($this->session->flashdata('msg')): ?>
        <br />
        <div class="alert alert-success alert-dismissible">
            <button type="button" class="close" data-dismiss="alert"
                    aria-hidden="true">×</button>
            <h4>
                <i class="icon fa-warning"></i> Success!
            </h4>&nbsp;
            <?= $this->lang->line('op_success'); ?>
        </div>
    <?php endif; ?> 
    <div class="kt-portlet__body">
        <h2><?= $this->lang->line('quraan_session') . ' : ' . $session_name ?></h2>
        <br/>
        <!--begin: Datatable -->
        <table class="table table-striped- table-bordered table-hover table-checkable dataTable no-footer dir-inline" id="kt_table_1">
            <thead>
                <tr>
                    <th><?php echo $this->lang->line('sno') ?></th>
                    <th><?php echo $this->lang->line('student') ?></th>
                    <th><?= $this->lang->line('the_type') ?></th>
                    <th><?= $this->lang->line('start-date') ?></th>
                    <th><?= $this->lang->line('end-date') ?></th>
                    <th><?= $this->lang->line('sessions_count') ?></th>
                    <th><?= $this->lang->line('lines_count') ?></th>
                    <th><?= $this->lang->line('pages_count') ?></th>
                    <th><?= $this->lang->line('achievement_percentage') ?></th>
                    <th class="text-center"><?php echo $this->lang->line('action') ?></th>

                </tr>
            </thead>
            <tbody>
                <?php
                $count = 1;
                foreach ($plans as $row) {
                    if ($row->target_percentage == -1) {
                        $class = 'alert-warning';
                    } else if ($row->target_percentage < 100) {
                        $class = 'alert-danger';
                    } else {
                        $class = 'alert-success';
                    }
                    ?>
                    <tr class="<?= $class ?>">
                        <td><?php echo $count++; ?></td>
                        <td><?= $row->student_name; ?></td>
                        <?php
                        $type = '';
                        switch ($row->type) {
                            case 0:
                                $type = 'حفظ';
                                break;
                            case 1:
                                $type = 'مراجعة';
                                break;
                            case 2:
                                $type = 'سرد';
                                break;
                            case 3:
                                $type = 'تلاوة';
                                break;
                            case 4:
                                $type = 'تلقين';
                                break;
                            case 5:
                                $type = 'اختبار';
                                break;
                        }
                        ?>
                        <td><?= $type ?></td>
                        <td><?= $row->date_from ?></td>
                        <td><?= $row->date_to ?></td>
                        <td><?= $row->sessions_count ?></td>
                        <td><?= $row->expected_lines_count ?></td>
                        <td><?= $row->expected_page_count ?></td>
                        <td><?= $row->target_percentage == -1 ? '---' : $row->target_percentage . ' %' ?></td>
                        <td class="text-center">
                            <a href="<?= base_url('quraan/sessions/view_session_plan/' . $row->id) ?>" class="btn btn-icon btn-warning btn-sm">
                                <i class="fa fa-eye"></i>
                            </a>
                            <?php if (get_ap('qs_plans_edit', $this->operator_id) == 1) { ?>
                                <a href="<?= base_url('quraan/sessions/edit_session_plan/' . $row->id . '/' . $session_id) ?>" class="btn btn-icon btn-primary btn-sm">
                                    <i class="fa fa-edit"></i>
                                </a>
                            <?php } ?>
                            <?php if (get_ap('qs_plans_del', $this->operator_id) == 1) { ?>
                                <a onclick="alert_box(<?php echo $row->id ?>)" class="btn btn-icon btn-danger btn-sm">
                                    <i class="fa fa-trash"></i>
                                </a>
                            <?php } ?>

                        </td>

                    </tr>
                <?php } ?>
            </tbody>
        </table>

        <!--end: Datatable -->
    </div>
</div><!-- /.row -->
<!-- <?php $this->load->view('site/footer'); ?> -->

<script src="<?php echo base_url() ?>public/plugins/global/plugins.bundle.js" type="text/javascript"></script>
<script src="<?php echo base_url() ?>public/js/scripts.bundle.js" type="text/javascript"></script>

<!--end::Global Theme Bundle -->

<!--begin::Page Vendors(used by this page) -->
<!-- <script src="<?php echo base_url() ?>public/plugins/custom/datatables/datatables.bundle.js" type="text/javascript"></script> -->

<!--end::Page Vendors -->

<!--begin::Page Scripts(used by this page) -->
<script src="<?php echo base_url() ?>public/js/pages/crud/datatables/basic/basic.js" type="text/javascript"></script>

<script>function alert_box(id) {
                                var result = confirm("Are You Confirm!")
                                if (result) {
                                    window.location.href = "<?= base_url('quraan/sessions/delete_session_plan/') ?>" + id + "/<?= $session_id ?>";

                                }

                            }</script>