<?php 
    $data = array();
    $data['title'] = "Yardım Kategorileri | ".$config->get('site_title');
    $data['links'] = [];
    $data['styles'] = [];
    $data['header']['scripts'] = [];
    $data['version'] = $config->get('version');
    $data['csrf_token'] = $csrf_generator->create();
    $data['sidebar_menu'] = $menu->get(array('position'=>'sidebar'));
    $data['sidebar_active_menu'] = $menu->getActiveMenuItemId(trim($_SERVER['REQUEST_URI']));
    $data['footer']['scripts'] = [];
    $menu_items = $menu->get(array('position'=>'footer'));
    foreach($menu_items as $item){
        if($item['col'] == "1"){
            $data['menu']['footer']["1"][] = $item;
        }
        if($item['col'] == "2"){
            $data['menu']['footer']["2"][] = $item;
        }
        if($item['col'] == "3"){
            $data['menu']['footer']["3"][] = $item;
        }
        if($item['col'] == "4"){
            $data['menu']['footer']["4"][] = $item;
        }
    }

    $data['breadcrumbs'] = array();
    $data['breadcrumbs'][] = array(
        'text' => "Pano",
        'href' => "/admin",
        'index' => 1
    );
    $data['breadcrumbs'][] = array(
        'text' => "Yardım Kategorileri",
        'href' => "/admin/faq/categories/list",
        'index' => 2
    );
    
    $categories        = $faq->getCategories();
?>
<?php include DIR_VIEWS."parts/header.php"; ?>
        <main class="content">
            <div class="container-fluid">
                <div class="card">
                    <div class="card-header">
                        <h5 class="card-title">Yardım Kategorileri</h5>
                        <a href="/admin/faq/categories/add" class="btn btn-primary btn-sm me-2"><i class="bi bi-plus-circle-dotted"></i> Yeni</a>
                    </div>
                    <div class="table-responsive">
                        <table class="table table-striped table-hover table-bordered table-sortable mb-0">
                            <thead>
                                <tr>
                                    <th style="width:60px;">ID</th>
                                    <th style="width:60px;">Görsel</th>
                                    <th style="width:100px;">Durum</th>
                                    <th>Başlık</th>
                                    <th style="width:120px;"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                    if(count($categories)>0) {
                                        foreach($categories as $row) {
                                            echo "<tr>
                                                        <td class=\"text-center\">".$row['id']."</td>
                                                        <td style=\"width: 60px;\" class=\"text-center\"><a href=\"/public/assets/images/faq/".$row['image']."\" class=\"glightbox\"> <img src=\"/public/assets/images/faq/".$row['image']."\"/> </a></td>
                                                        <td style=\"width: 100px;\" class=\"text-center\">".$row['status_text']."</td>
                                                        <td>".$row['title']."</td>
                                                        <td style=\"width: 180px;vertical-align: middle;\" class=\"text-center\">
                                                            <a class=\"btn btn-sm btn-primary me-1\" href=\"/admin/faq/categories/edit?id=".$row['id']."\"><i class=\"bi bi-pencil-square\"></i></a>
                                                            <a class=\"btn btn-sm btn-info text-white me-1\" href=\"/".$row['url']."\" target=\"_blank\"><i class=\"bi bi-send\"></i></a>
                                                            <button class=\"btn btn-sm btn-danger\" data-delete data-href=\"/admin/faq/categories/delete?id=".$row['id']."\"><i class=\"bi bi-trash\"></i></button>
                                                        </td>
                                                    </tr>";
                                        }
                                    }else{
                                        echo "<tr class=\"text-center\"><td colspan=\"5\">Hiçbir kayıt bulunamadı!</td></tr>";
                                    }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </main>
<?php include DIR_VIEWS."parts/footer.php"; ?>