
<?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>
                <span class="kt-subheader__desc"><?php echo $this->lang->line('products'); ?></span>
            </div>

        </div>
    </div>
</div>
<!-- 
        <div class="row">
     <div class="col-md-12">
<div  style="float:right">
<?php if (get_ap('product_add', $this->operator_id) == 1) { ?>
                                                       <div  style="margin-left:10px"><a href="<?= base_url() ?>/<?= $this->thispage ?>/add/" class="btn btn-block btn-primary"  style="margin-bottom:5px"><i class="icon-pencil  icon-white"> </i><?php echo $this->lang->line('add-a-product') ?></a> 	</div>
<?php } ?>
        </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 } ?>



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

        <div class="kt-portlet__head-toolbar">
            <div class="kt-portlet__head-wrapper">
                <div class="kt-portlet__head-actions">
                    <!--  <div class="dropdown dropdown-inline">
                       <button type="button" class="btn btn-default btn-icon-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                         <i class="la la-download"></i> Export
                       </button>
                       <div class="dropdown-menu dropdown-menu-right">
                         <ul class="kt-nav">
                           <li class="kt-nav__section kt-nav__section--first">
                             <span class="kt-nav__section-text">Choose an option</span>
                           </li>
                           <li class="kt-nav__item">
                             <a href="#" class="kt-nav__link">
                               <i class="kt-nav__link-icon la la-print"></i>
                               <span class="kt-nav__link-text">Print</span>
                             </a>
                           </li>
                           <li class="kt-nav__item">
                             <a href="#" class="kt-nav__link">
                               <i class="kt-nav__link-icon la la-copy"></i>
                               <span class="kt-nav__link-text">Copy</span>
                             </a>
                           </li>
                           <li class="kt-nav__item">
                             <a href="#" class="kt-nav__link">
                               <i class="kt-nav__link-icon la la-file-excel-o"></i>
                               <span class="kt-nav__link-text">Excel</span>
                             </a>
                           </li>
                           <li class="kt-nav__item">
                             <a href="#" class="kt-nav__link">
                               <i class="kt-nav__link-icon la la-file-text-o"></i>
                               <span class="kt-nav__link-text">CSV</span>
                             </a>
                           </li>
                           <li class="kt-nav__item">
                             <a href="#" class="kt-nav__link">
                               <i class="kt-nav__link-icon la la-file-pdf-o"></i>
                               <span class="kt-nav__link-text">PDF</span>
                             </a>
                           </li>
                         </ul>
                       </div>
                     </div> -->
                    &nbsp;
                    <?php if (get_ap('categories', $this->operator_id) == 1) { ?><a href="<?= base_url() ?>/categories" class="btn btn-brand btn-elevate btn-icon-sm">
                            <i class="la la-plus"></i>
                            <?php echo $this->lang->line('categories') ?>
                        </a><?php } ?>
                    <?php if (get_ap('product_add', $this->operator_id) == 1) { ?><a href="<?= base_url() ?>/<?= $this->thispage ?>/add/" class="btn btn-brand btn-elevate btn-icon-sm">
                            <i class="la la-plus"></i>
                            <?php echo $this->lang->line('add-a-product') ?>
                        </a><?php } ?>
                </div>
            </div>
        </div>
    </div>
    <div class="kt-portlet__body">

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


        <!--begin: Datatable -->
        <table class="table table-striped table-bordered table-hover" id="kt_table_1">
            <thead>
                <tr>
                    <th><?php echo $this->lang->line('sno') ?></th>
                    <th><?= $this->lang->line('product_code') ?></th>
                    <th><?php echo $this->lang->line('the-name') ?></th>
                    <th><?= $this->lang->line('category') ?></th>
                    <th><?php echo $this->lang->line('price') ?></th>
                    <th><?php echo $this->lang->line('the_type') ?></th>
                    <th><?php echo $this->lang->line('status') ?></th>
                    <?php
                    if (get_license_per('attendance')) {
                        $controller_path = dirname(__DIR__, 3);
                        if (file_exists($controller_path . '/controllers/absent')) {
                            if (get_ap('attendance_module', $this->operator_id)) {
                                ?>
                                <th class='text-center'><?php echo $this->lang->line('attendance') ?></th>
                                <?php
                            }
                        }
                    }
                    ?>
                    <th class="text-center"><?php echo $this->lang->line('action') ?></th>
                </tr>
            </thead>
            <tbody>
                <?php
                $count = 1;
                foreach ($all_groups as $row) {
                    ?>
                    <tr>
                        <td><?php echo $count++; ?></td>
                        <td><img src="<?= base_url('misc/barcode/' . $row['code'] . '/' . $row['barcode_symbology'] . '/74/0'); ?>" alt="<?= $row['code']; ?>" class="bcimg" /></td>
                        <td><?= $row['name']; ?></td>
                        <td><?= $row['cat'] ?></td>
                        <td><?= $row['valuess']; ?></td>
                        <td><?php
                            if ($row['type'] == 1) {
                                echo $this->lang->line('product');
                            } else if ($row['type'] == 2) {
                                echo $this->lang->line('subscription');
                            }
                            ?></td>
                        <td><?php
                            if ($row['active'] == '2')
                                echo '<span class="btn btn-sm btn-danger" style="border-radius: 2rem;padding: 0.15rem 5px; color: #fff;!important">' . $this->lang->line('closed') . '</span>';
                            else
                                echo '<span class="btn btn-sm btn-success" style="border-radius: 2rem;padding: 0.15rem 5px ;color: #fff;!important" >' . $this->lang->line('open') . '</span>';
                            ?></td>
                        <!--<td><?//= $row['note']; ?> </td>-->
                        <?php
                        if (get_license_per('attendance')) {
                            if (file_exists($controller_path . '/controllers/absent')) {
                                if (get_ap('attendance_module', $this->operator_id)) {
                                    ?>
                                    <td class='text-center'>
                <!--                            <a href="<?= base_url('absent/add/' . $row['id']) ?>"  ><button class="btn btn-sm btn-info" style="border-radius: 2rem;padding: 0.15rem 0.75rem; color: #ffffff;
                                                                                                              background: #5578eb;"><i class="kt-menu__link-icon flaticon-plus"></i></button></a>-->
                                        <?php if (get_ap('product_attendance_add', $this->operator_id)) { ?>
                                            <a href="<?= base_url('Absent/add/' . $row['id']) ?>" title='<?= $this->lang->line('add') ?>' class="btn btn-icon btn-circle btn-facebook">
                                                <i class="fa fa-plus"></i>
                                            </a>
                                            &nbsp;&nbsp;
                                        <?php } ?>

                                        <?php if (get_ap('product_attendance_list', $this->operator_id)) { ?>
                                            <a href="<?= base_url('Absent/absent_summary/' . $row['id']) ?>" title='<?= $this->lang->line('show') ?>' class="btn btn-icon btn-circle btn-facebook">
                                                <i class="fa fa-eye"></i>
                                            </a>
                                        <?php } ?>

                                    </td>
                                    <?php
                                }
                            }
                        }
                        ?>
                        <td class="text-center"> 
    <!--                            <a href="<?= base_url('' . $this->thispage . '/show/' . $row['id']) ?>" class="btn btn-sm btn-clean btn-icon btn-icon-md" title="view details">
                                <i class="fa fa-eye"></i>
                            </a> -->
                            <?php if (get_ap('product', $this->operator_id)) { ?>
                                <a href="<?= base_url('' . $this->thispage . '/show/' . $row['id']) ?>" class="btn btn-icon btn-warning btn-sm">
                                    <i class="fa fa-eye"></i>
                                </a>
                            <?php } ?>
                            <?php //if (get_ap('product_additions', $this->operator_id)) { ?>
<!--                                <a href="<?//= base_url('' . $this->thispage . '/product_additions/' . $row['id']) ?>" class="btn btn-icon btn-success btn-sm" title="<?= $this->lang->line('product_additions') ?>">
                                    <i class="fa fa-plus"></i>
                                </a>-->
                            <?php //} ?>
                            <?php if (get_ap('product_edit', $this->operator_id)) { ?>
                                <a href="<?= base_url('' . $this->thispage . '/edit/' . $row['id']) ?>" class="btn btn-icon btn-primary btn-sm">
                                    <i class="fa fa-edit"></i>
                                </a>
                            <?php } ?>
                            <?php if (get_ap('product_del', $this->operator_id)) { ?>
                                <a href="" 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_2'); ?>


<!--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>function alert_box(id) {
        var result = confirm("Are You Confirm!")
        if (result) {
            window.location.href = "<?= base_url('' . $this->thispage . '/del/') ?>" + id;

        }

    }

    $("#kt_table_1").DataTable({dom: 'Bfrtip',
        destroy: true,
        "pageLength": 50,
        buttons: [
            {
                extend: 'excelHtml5',
                charset: 'UTF-16LE',
                fieldSeparator: '\t',
                bom: true
            },
            {
                extend: 'csvHtml5',
                charset: 'UTF-16LE',
                fieldSeparator: '\t',
                bom: true
            },
            {
                extend: 'pdfHtml5',
                charset: 'UTF-16LE',
                fieldSeparator: '\t',
                bom: true
            },
            {
                extend: 'print',
                autoPrint: false,
                footer: true
            }

        ]
    });

</script>