<?php 
    $data = array();
    $data['title'] = "PayTR | ".$config->get('site_title');
    $data['links'] = [];
    $data['styles'] = ['/admin/public/assets/css/jstable.css'];
    $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'] = [$config->get('site_url').'admin/public/assets/js/jquery-3.6.0.min.js', $config->get('site_url').'admin/public/assets/js/moment.min.js', $config->get('site_url').'admin/public/assets/js/daterangepicker.js', '/admin/public/assets/js/jstable.min.js','/admin/public/assets/js/pages/paytr.js'];
    $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' => "PayTR",
        'href' => "/admin/paytr",
        'index' => 2
    );

    $date_start         = isset($_GET['date_start']) ? htmlspecialchars($_GET['date_start'], ENT_QUOTES, 'UTF-8') : date('Y-m-d');
    $date_end           = isset($_GET['date_end']) ? htmlspecialchars($_GET['date_end'], ENT_QUOTES, 'UTF-8') : date('Y-m-d');
?>
<?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">PayTR</h5>
                        <button type="button" class="btn btn-light btn-sm" data-bs-toggle="collapse" data-bs-target="#filter-bar" aria-expanded="true" aria-controls="filter-bar">
                            <i class="bi bi-funnel"></i> Filtre
                        </button>
                    </div>
                    <div class="collapse show" id="filter-bar">
                        <div class="card p-3 mb-0 border-0">
                            <form action="" method="GET" id="filter-form">
                                <div class="row">
                                    <div class="col-md-2 text-md-start">
                                        <label for="date" class="col-form-label fw-bold">Tarih</label>
                                    </div>
                                    <div class="col-md-4 col-lg-2 text-md-start mb-2">
                                        <input type="text" id="date" class="form-control" value="<?php echo isset($_GET["date_start"]) && !empty($_GET["date_start"]) ? date('m-d-Y', strtotime($date_start))." - ".date('m-d-Y', strtotime($date_end)) : ""; ?>">
                                        <input type="hidden" name="date_start" id="date_start" value="<?php echo $date_start; ?>">
                                        <input type="hidden" name="date_end" id="date_end" value="<?php echo $date_end; ?>">
                                    </div>
                                    <div class="col-md-3 col-lg-2">
                                        <button type="submit" class="btn btn-primary w-100">Filtrele</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <hr>
                    <div class="card-body p-0">
                        <div class="table-responsive" id="table-wrapper">
                            <table class="table table-striped table-hover table-bordered mb-0" id="transactions-table">
                                <thead>
                                    <tr>
                                        <th>İşlem No</th>
                                        <th>Tarih</th>
                                        <th>Tür</th>
                                        <th>İşlem Tutarı</th>
                                        <th>Ödeme Tutarı</th>
                                        <th>Kesinti Tutarı</th>
                                        <th>Net Tutar</th>
                                        <th>Taksit</th>
                                        <th>Kart Türü</th>
                                        <th>Kart No</th>
                                        <th></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </main>

        <div class="modal" id="please-wait-modal" data-bs-backdrop="static" data-bs-keyboard="false" tabindex="-1" aria-labelledby="staticBackdropLabel" aria-hidden="true">
            <div class="modal-dialog modal-dialog-centered">
                <div class="modal-content">
                    <div class="modal-body">
                        <div class="d-flex justify-content-center">
                            <div class="spinner-border m-5" role="status" style="width: 3rem; height: 3rem;" role="status">
                                <span class="visually-hidden">Loading...</span>
                            </div>
                        </div>
                        <div class="text-center">
                        <h3>İşleminiz devam ediyor. Lütfen bekleyin.</h3>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <form action="" method="post" id="return-form">
            <div class="modal fade" id="return-modal" tabindex="-1" aria-labelledby="return-modal-label" aria-hidden="true">
                <div class="modal-dialog modal-dialog-centered">
                    <div class="modal-content">
                    <div class="modal-header">
                        <h1 class="modal-title fs-5" id="return-modal-label">İade Et</h1>
                        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
                    </div>
                    <div class="modal-body">
                        <div class="row mb-2">
                            <div class="col-12">
                                <label for="siparis_no" class="col-form-label fw-bold">İşlem No</label>
                                <input type="text" name="siparis_no" id="siparis_no" class="form-control" readonly>
                            </div>
                        </div>
                        <div class="row mb-2">
                            <div class="col-12">
                                <label for="islem_tarihi" class="col-form-label fw-bold">İşlem Tarihi</label>
                                <input type="text" name="islem_tarihi" id="islem_tarihi" class="form-control" readonly>
                            </div>
                        </div>
                        <div class="row mb-2">
                            <div class="col-12">
                                <label for="islem_tutari" class="col-form-label fw-bold">İşlem Tutarı</label>
                                <input type="number" name="islem_tutari" id="islem_tutari" class="form-control" readonly>
                            </div>
                        </div>
                        <div class="row mb-2">
                            <div class="col-12">
                                <label for="amount" class="col-form-label fw-bold">İade Tutar</label>
                                <input type="number" name="amount" id="amount" class="form-control" required>
                            </div>
                        </div>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Vazgeç</button>
                        <button type="submit" class="btn btn-primary" data-bs-dismiss="modal">Onayla</button>
                    </div>
                    </div>
                </div>
            </div>
        </form>
<?php include DIR_VIEWS."parts/footer.php"; ?>