<?php $this->load->view('site/layout'); ?>
<link href="<?php echo base_url() ?>public/plugins/custom/datatables/datatables.bundle.css" rel="stylesheet" type="text/css" />
<style>
    .btn i {
        padding-left: 0rem;
    }
</style>
<?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>
                <span class="kt-subheader__desc"><?php echo $this->lang->line('guides'); ?></span>
            </div>

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

<div class="kt-portlet kt-portlet--mobile">
    <?php if ($this->session->flashdata('success')) { ?>
        <div class="alert alert-success">
            <a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
            <?= $this->session->flashdata('success') ?>
        </div>
    <?php } ?>

    <?php if ($this->session->flashdata('error')) { ?>
        <div class="alert alert-danger">
            <a href="#" class="close" data-dismiss="alert" aria-label="close" title="close">×</a>
            <?= $this->session->flashdata('error') ?>
        </div>
    <?php } ?>

    <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('guides'); ?>
            </h3>
        </div>

        <div class="kt-portlet__head-toolbar">
            <div class="kt-portlet__head-wrapper">
                <div class="kt-portlet__head-actions">

                    <?php if (get_ap('kw_add_guide', $this->operator_id)) { ?>
                        <a href="<?= base_url() ?>knowledge_base/adddalel" class="btn btn-brand btn-elevate btn-icon-sm">
                            <i class="la la-plus"></i>
                            <?php echo $this->lang->line('add-a-guide') ?>
                        </a>
                    <?php } ?>
                </div>
            </div>
        </div>
    </div>
    <div class="kt-portlet__body">

        <table id="dataTable" class="table table-striped table-bordered table-hover">

            <thead>
                <tr>
                    <td>
                        #
                    </td>
                    <td>
                        <?= $this->lang->line('link_title') ?>
                    </td>
                    <td>
                        <?= $this->lang->line('guide_title') ?>
                    </td>

                    <td>
                        <?= $this->lang->line('protection_type') ?>
                    </td>


                    <td>
                        <?= $this->lang->line('action') ?>
                    </td>
                </tr>
            </thead>

            <tbody>



                <?php
                if (isset($dalel) && $dalel != null) {
                    for ($i = 0; $i < count($dalel); ++$i) {
                        //  $groups = $cont->getusergroups($users[$i]->userid);
                        ?>

                        <tr>
                            <td>
                                <?php echo $i + 1; ?>
                            </td>
                            <td>
                                <?php echo $dalel[$i]->name; ?>
                            </td>
                            <td>
                                <?php echo $dalel[$i]->title; ?>
                            </td>

                            <td>
                                <?php echo $dalel[$i]->privacy_type; ?>
                            </td>

                                                <!--                            <td>
                            <?php //echo $dalel[$i]->primary_dalel; ?>
                                                                            </td>-->


                            <td>
                                <?php if (get_ap('kw_delete_guide', $this->operator_id)) { ?>
                                    <a class="btn btn-danger btn-small" title="<?= $this->lang->line('delete') ?>" onclick="return confirm('are you sure?');" href="<?= base_url('knowledge_base/deletedalel/' . $dalel[$i]->id) ?>">
                                        <i class="fa fa-minus-circle"></i>
                                    </a>

                                <?php } if (get_ap('kw_edit_guide', $this->operator_id)) { ?>
                                    <a href="<?php echo base_url("knowledge_base/editdalel/") . $dalel[$i]->id; ?>" class="btn btn-small btn-primary" title="<?= $this->lang->line('edit') ?>">
                                        <i class="fa fa-edit"></i>
                                    </a>
                                <?php } ?>
                                <a href="<?php
                                if ($dalel[$i]->primary_dalel == 'نعم')
                                    echo base_url();
                                else
                                    echo base_url("dalel/index/") . $dalel[$i]->name;
                                ?>" target="_blank" class="btn btn-small btn-success" title="<?= $this->lang->line('guide_page') ?>">
                                    <i class="fas fa-external-link-alt"></i>
                                </a>


                                <!-- Categories -->
                                <?php if (get_ap('guide_categories', $this->operator_id)) { ?>
                                    <a href="<?php echo base_url("knowledge_base/categories/") . $dalel[$i]->id; ?>" class="btn btn-small btn-info" title="<?= $this->lang->line('guide_categories') ?>">
                                        <i class="fas fa-list-ul"></i>
                                    </a>
                                <?php } ?>
                                <!-- Articles -->
                                <?php if (get_ap('kw_articles', $this->operator_id)) { ?>
                                    <a href="<?php echo base_url("knowledge_base/articles/") . $dalel[$i]->id; ?>" class="btn btn-small btn-warning" title="<?= $this->lang->line('guide_article') ?>">
                                        <i class="far fa-file-alt"></i>
                                    </a>
                                <?php } ?>
                            </td>
                        </tr>
                        <?php
                    }
                }
                ?>

            </tbody>



        </table>

    </div>

</div>


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

<script src="<?php echo base_url() ?>public/js/pages/crud/datatables/basic/basic.js" type="text/javascript"></script>