<?php 
    $data = array();
    $data['title'] = "Kargo Yönetimi | ".$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' => "Kargo Yönetimi",
        'href' => "/admin/shipping/list",
        'index' => 2
    );
    $shipping_agencies = $order->getShippingAgenciesList();
?>
<?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">Kargo Yönetimi</h5>
                        <a href="/admin/shipping/add" class="btn btn-primary btn-sm"><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:50px;">ID</th>
                                    <th>Görsel</th>
                                    <th>Durum</th>
                                    <th>Kargo Firması</th>
                                    <th>Varsayılan</th>
                                    <th>Sıralama</th>
                                    <th style="width:90px;"></th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                    if(count($shipping_agencies)>0) {
                                        foreach($shipping_agencies as $row) {
                                            $status = $row['status'] == 1 ? '<span class="badge bg-success">Aktif</span>' : '<span class="badge bg-danger">Pasif</span>';
                                            $is_default = $row['is_default'] == 1 ? '<span class="badge bg-primary">varsayılan</span>' : '';
                                            echo "<tr>
                                                        <td class=\"text-center\">".$row['id']."</td>
                                                        <td style=\"width: 60px;\" class=\"text-center\"><a href=\"/public/assets/images/shipping-agencies/".$row['image']."\" class=\"glightbox\"> <img src=\"/public/assets/images/shipping-agencies/".$row['image']."\"/> </a></td>
                                                        <td style=\"width: 100px;\" class=\"text-center\">".$status."</td>
                                                        <td>".$row['title']."</td>
                                                        <td>".$is_default."</td>
                                                        <td>".$row['sort_order']."</td>
                                                        <td style=\"width: 90px;vertical-align: middle;\" class=\"text-center\">
                                                            <a class=\"btn btn-sm btn-primary me-1\" href=\"/admin/shipping/edit?id=".$row['id']."\"><i class=\"bi bi-pencil-square\"></i></a>
                                                            <button class=\"btn btn-sm btn-danger\" data-delete data-href=\"/admin/shipping/delete?id=".$row['id']."\"><i class=\"bi bi-trash\"></i></button>
                                                        </td>
                                                    </tr>";
                                        }
                                    }else{
                                        echo "<tr class=\"text-center\"><td colspan=\"7\">Hiçbir kayıt bulunamadı!</td></tr>";
                                    }
                                ?>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </main>
<?php include DIR_VIEWS."parts/footer.php"; ?>