<?php echo message_box('success'); ?>
<?php echo message_box('error');
$created = can_action('143', 'created');
$edited = can_action('143', 'edited');
$deleted = can_action('143', 'deleted');
?>
<div class="space-y-4">
    <div class="rounded-2xl border border-border bg-card shadow-sm">

        <div class="p-5">
            <table class="table table-striped DataTables" id="DataTables" cellspacing="0" width="100%">
                <thead>
                    <tr>
                        <th><?= lang('title') ?></th>
                        <th><?= lang('categories') ?></th>
                        <th class="col-sm-1"><?= lang('total') . ' ' . lang('view') ?></th>
                        <th class="col-sm-1"><?= lang('active') ?></th>
                        <th><?= lang('action') ?></th>
                    </tr>
                </thead>
                <tbody>
                    <script>
                    $(document).on("change", ".change_kb input[type='checkbox']", function() {
                        var kb_id = $(this).data().id;
                        var status = $(this).is(":checked");
                        if (status == true) {
                            status = 1;
                        } else {
                            status = 2;
                        }
                        $.ajax({
                            type: 'POST',
                            url: '<?= base_url() ?>admin/knowledgebase/change_kb_status/' + status + '/' + kb_id,
                            dataType: 'json',
                            encode: true,
                            success: function(res) {
                                if (res) {
                                    toastr[res.status](res.message);
                                } else {
                                    alert(<?= json_encode(lang('ajax_problem')) ?>);
                                }
                            }
                        });
                    });
                    </script>
                    <script type="text/javascript">
                    list = base_url + "admin/knowledgebase/articlesList";
                    </script>
                </tbody>
            </table>
        </div>
    </div>
</div>
