<?php require_once ('model.php'); ?>
<div class="row">
    <div class="col-lg-12">
        <div class="card">
            <div class="card-header">
                <h4 class="card-title mb-0"><?=module_title($model)?> </h4>
            </div><!-- end card header -->

            <div class="card-body">
                <div class="listjs-table" id="customerList">
                    <div class="row g-4 mb-3">
                        <div class="col-sm-auto">
                            <div>
                                <a href="<?=ADMIN_URL?>/<?=$model?>/create" class="btn btn-success add-btn"><i class="ri-add-line align-bottom me-1"></i><?=lang('create')?></a>
                                <button class="btn btn-soft-danger deleted" data-link="<?=ADMIN_URL?>/<?=$model?>/delete/"
                                        data-title="<?=lang('remove_title')?>" data-question="<?=lang('remove_desc')?>" data-no="<?=lang('no')?>"  data-yes="<?=lang('yes')?>"
                                        onclick="deleteMultiple(this)"><i class="ri-delete-bin-2-line"></i></button>
                            </div>
                        </div>
                        <div class="col-sm">
                            <div class="d-flex justify-content-sm-end">
                                <div class="search-box ms-2">
                                    <input type="text" class="form-control search" placeholder="<?=lang('table_search')?>">
                                    <i class="ri-search-line search-icon"></i>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="table-responsive table-card mt-3 mb-1">
                        <?php   if (posts('total_count', $model, lang_is_default('lang_code')) != 0 ){ ?>
                        <table class="table align-middle table-nowrap" id="customerTable">
                            <thead class="table-light">
                            <tr>
                                <th scope="col" style="width: 50px;">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" id="checkAll" value="option">
                                    </div>
                                </th>
                                <th class="sort" data-sort="title"><?=lang('table_title')?></th>
                                <th class="sort"  data-sort="status" style="width: 130px"><?=lang('table_status')?></th>
                                <th title="Diller" style="width: 150px">
                                    <?php  foreach (languages('data') as  $language){   ?>
                                    <img src="<?=ADMIN_FOLDER?>/model/languages/flags/<?=$language['lang_code']?>.svg" title="<?=$language['lang_name']?>" class="flags" style="height: 16px" alt="<?=$language['lang_name']?>">
                                    <?php } ?>
                                <th data-sort="action" style="width: 130px;"><?=lang('table_actions')?></th>
                            </tr>
                            </thead>
                            <tbody class="list form-check-all">
                            <?php foreach (posts('data', $model, lang_is_default('lang_code')) as $post){ ?>
                            <tr>
                                <th scope="row">
                                    <div class="form-check">
                                        <input class="form-check-input" type="checkbox" name="chk_child" value="<?=$post['id']?>">
                                    </div>
                                </th>
                                <td class="title"><a href="<?=ADMIN_URL?>/<?=$model?>/edit/<?=$post['id']?>" class="fw-medium link-primary"><?=$post['title']?></a></td>
                                <td class="status"><?=m_status($post['status'])?></td>
                                <td class="lang lang_list">
                                    <?php foreach (posts_langs($post['lang_ref_id'], lang_is_default('lang_code')) as $posts_lang){ ?>
                                        <?php if (lang_is_default('lang_code')  == $posts_lang['lang']) {?>
                                            <a data-bs-toggle="tooltip" href="<?=ADMIN_URL?>/<?=$model?>/edit/<?=$posts_lang['id']?>" aria-label="<?=lang('table_lang_tooltip')?> <?=lang_name($posts_lang['lang'])?>" data-bs-original-title="<?=lang_name($posts_lang['lang'])?><?=lang('table_lang_tooltip')?> ">
                                                <i class="bx bx-check"></i>
                                            </a>
                                        <?php }else{ ?>
                                            <a data-bs-toggle="tooltip" href="<?=ADMIN_URL?>/<?=$model?>/edit/<?=$posts_lang['id']?>" aria-label="<?=lang('table_lang_tooltip')?>" data-bs-original-title="<?=lang_name($posts_lang['lang'])?><?=lang('table_lang_tooltip')?> ">
                                                <i class="bx bx-edit"></i>
                                            </a>
                                        <?php } ?>
                                    <?php } ?>
                                </td>
                                <td>
                                    <div class="d-flex gap-2">
                                        <div class="edit">
                                            <a href="<?=ADMIN_URL?>/<?=$model?>/edit/<?=$post['id']?>" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="<?=lang('edit')?>">
                                                <i class="bx bx-edit edit_icon" style=""></i>
                                            </a>
                                        </div>
                                        <div class="remove">
                                            <a href="<?=ADMIN_URL?>/<?=$model?>/delete/<?=$post['id']?>" class="delete" data-title="<?=lang('remove_title')?>" data-question="<?=lang('remove_desc')?>" data-no="<?=lang('no')?>"  data-yes="<?=lang('yes')?>" data-bs-toggle="tooltip" data-bs-placement="top" data-bs-original-title="<?=lang('remove')?>">
                                                <i class="bx bx-trash trash_icon" style=""></i>
                                            </a>
                                        </div>
                                    </div>
                                </td>
                            </tr>
                            <?php } ?>
                            </tbody>
                        </table>

                        <div class="noresult" style="display: none">
                            <div class="text-center">
                                <lord-icon src="https://cdn.lordicon.com/msoeawqm.json" trigger="loop" colors="primary:#121331,secondary:#08a88a" style="width:75px;height:75px"></lord-icon>
                                <h5 class="mt-2"><?=lang('table_noresult_title')?></h5>
                                <p class="text-muted mb-0"><?=lang('table_noresult_desc')?></p>
                            </div>
                        </div>
                            <?php
                        }else{
                            ?>
                            <div  style="display: block">
                                <div class="text-center">
                                    <lord-icon src="https://cdn.lordicon.com/msoeawqm.json" trigger="loop" colors="primary:#121331,secondary:#08a88a" style="width:75px;height:75px"></lord-icon>
                                    <h5 class="mt-2"><?=lang('table_noresult_title')?></h5>
                                    <p class="text-muted mb-0"><?=lang('table_noresult_desc')?></p>
                                </div>
                            </div>
                        <?php } ?>
                    </div>
                    <div class="d-flex justify-content-end">
                        <div class="pagination-wrap hstack gap-2">
                            <a class="page-item pagination-prev disabled" href="javascrpit:void(0);">
                                <?=lang('table_prev')?>
                            </a>
                            <ul class="pagination listjs-pagination mb-0"></ul>
                            <a class="page-item pagination-next" href="javascrpit:void(0);">
                                <?=lang('table_next')?>
                            </a>
                        </div>
                    </div>
                </div>
            </div><!-- end card -->
        </div>
        <!-- end col -->
    </div>
    <!-- end col -->
</div>
<!-- end row -->