<?php
//$this->load->view('admin/components/htmlheader');
$opened = $this->session->userdata('opened');
$this->session->unset_userdata('opened');
?>

<body class="layout-h public-frontend">
<div class="wrapper frontend-wrapper">
    <!-- top navbar-->
    <?php $this->load->view('frontend/components/header'); ?>
    <!-- Main section-->
    <section class="frontend-content-section">
        <!-- Page content-->
        <div class="content-wrapper frontend-content-wrapper">

            <div class="row">
                <div class="col-lg-12">
                    <?php echo $subview ?>
                </div>
            </div>
        </div>
    </section>
    <!-- Page footer-->
    <style>
        .frontend-footer {
            display: flex;
            align-items: center;
            justify-content: space-between;
            gap: 12px;
            padding: 18px max(16px, calc((100vw - 1180px) / 2));
            border-top: 1px solid #dbe3ee;
            background: #ffffff;
            color: #475569;
            font-size: 13px;
            line-height: 1.2;
        }

        .frontend-footer a {
            color: #0f172a;
            font-weight: 800;
            text-decoration: none;
        }

        .frontend-footer a:hover {
            text-decoration: underline;
        }

        .frontend-footer-right {
            white-space: nowrap;
            color: #64748b;
        }

        body.frontend-dark .frontend-footer {
            border-top-color: #263244;
            background: #111827;
            color: #94a3b8;
        }

        body.frontend-dark .frontend-footer a {
            color: #e5edf8;
        }

        body.frontend-dark .frontend-footer-right {
            color: #94a3b8;
        }

        .public-frontend {
            background: #f6f8fb;
        }

        .frontend-wrapper {
            min-height: 100vh;
            background: #f6f8fb;
        }

        body.frontend-dark.public-frontend,
        body.frontend-dark .frontend-wrapper {
            background: #0b1120;
        }

        .frontend-content-section,
        .frontend-content-wrapper {
            background: transparent;
        }

        .frontend-content-wrapper {
            padding: 20px 15px 0;
        }

        @media (max-width: 767px) {
            .frontend-footer {
                flex-direction: column-reverse;
                align-items: flex-start;
                font-size: 13px;
            }
        }
    </style>

    <footer class="frontend-footer">
        <div class="frontend-footer-left">
            &copy; <a href="<?= config_item('copyright_url') ?>"><?= config_item('copyright_name') ?></a>. All rights reserved.
        </div>
        <div class="frontend-footer-right">
            <strong><?= lang('version') ?></strong> <?= config_item('version') ?>
        </div>
    </footer>
</div>
<script type="text/javascript">

    $(document).ready(function () {
        $('.complete input[type="checkbox"]').change(function () {
            var task_id = $(this).data().id;
            var task_complete = $(this).is(":checked");

            var formData = {
                'task_id': task_id,
                'task_progress': 100,
                'task_status': 'completed'
            };
            $.ajax({
                type: 'POST', // define the type of HTTP verb we want to use (POST for our form)
                url: '<?= base_url()?>admin/tasks/completed_tasks/' + task_id, // the url where we want to POST
                data: formData, // our data object
                dataType: 'json', // what type of data do we expect back from the server
                encode: true,
                success: function (res) {
                    console.log(res);
                    if (res) {
                        location.reload();
                    } else {
                        alert(<?= json_encode(lang('ajax_problem')) ?>);
                    }
                }
            })

        });

    })
    ;
</script>
<script type="text/javascript">
    $(document).ready(function () {
        $('#permission_user').hide();
        $("div.action_1").hide();
        $("input[name$='permission']").on("click", function(){
            $("#permission_user").removeClass('show');
            if ($(this).attr("value") == "custom_permission") {
                $("#permission_user").show();
            } else {
                $("#permission_user").hide();
            }
        });
        $("input[name$='assigned_to[]']").on("click", function(){
            var user_id = $(this).val();
            $("#action_1" + user_id).removeClass('show');
            if (this.checked) {
                $("#action_1" + user_id).show();
            } else {
                $("#action_1" + user_id).hide();
            }

        });
    });

</script>
