@extends('yonetim.yonetim_master')

@section('cssler')
    <link rel="stylesheet" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.min.css">

@endsection

@section('main')
    <section class="section">
        <div class="section-body">
            <div class="row">
                <div class="col-12">
                    <div class="card">
                        <div class="card-header">
                            <h4>Sipariş Listesi</h4>

                        </div>
                        <div class="card-body">

                            <div class="table-responsive">
                                <table class="table table-striped" id="table-1">
                                    <thead>
                                    <tr>

                                        <th>Siparis İd</th>
                                        <th>Alan Kullanıcı</th>
                                        <th>Fiyat</th>
                                        <th>Sipariş Tarihi</th>
                                        <th>Durum</th>
                                        <th>İşlemler</th>
                                    </tr>
                                    </thead>
                                    <tbody>

                                    @foreach($veriler as $veri)
                                        <tr>

                                            <td>{{$veri->id}}</td>
                                            <td>
                                                @php

                                                @endphp
                                                <a href=" {{route('uyeler.uyedetay',$veri->kullanici_id)}}">
                                                    {{$veri->useradi->name}} {{$veri->useradi->surname}}

                                                </a>
                                            </td>

                                            <td>{{$veri->toplamsepetfiyat}}₺</td>
                                            <td>{{ \Carbon\Carbon::parse($veri->created_at)->format('d.m.Y H:i') }}</td>


                                            <td>@if($veri->siparisdurum==1)
                                                    <span class="badge badge-warning">Bekliyor</span>
                                                @elseif($veri->siparisdurum==2)

                                                    <span class="badge badge-success">Tamamlandı</span>

                                                @elseif($veri->siparisdurum==3)
                                                    <span class="badge badge-danger">İptal Edildi</span>

                                                @elseif($veri->siparisdurum==4)
                                                    <span class="badge badge-primary">İade İşlemi</span>

                                                @elseif($veri->siparisdurum==7)
                                                    <span class="badge badge-success p-2">Ödeme Başarılı</span>

                                                @elseif($veri->siparisdurum==8)
                                                    <span class="badge badge-danger p-2">Başarısız İşlem</span>


                                                @else
                                                    <span class="badge badge-warning">Tanımsız</span>

                                                @endif
                                            </td>




                                            <td>
                                                <a href="{{ route('siparis.veriupdate',$veri->id)}}" class="btn btn-warning"><i class="fa fa-edit"></i> Sipariş Detayı</a>
                                                <a onclick="return confirm('Silmek istediğinizden emin misiniz?')" href="{{ route('siparis.verisil',$veri->id)}}" class="btn btn-danger"><i class="fa fa-trash"></i> Sil</a>
                                            </td>
                                        </tr>
                                    @endforeach





                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>
    </section>
@endsection

@section('datatables')
    <script src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.min.js"></script>

    <script>
        $(document).ready( function () {
            $('#table-1').DataTable();
        } );


    </script>

    <script>
        $('#table-1').DataTable({
            "order": [[ 0, "desc" ]],
            language: {
                info: "_TOTAL_ kayıttan _START_ - _END_ kayıt gösteriliyor.",
                infoEmpty:      "Gösterilecek hiç kayıt yok.",
                loadingRecords: "Kayıtlar yükleniyor.",
                lengthMenu: "Sayfada _MENU_ kayıt göster",
                zeroRecords: "Tablo boş",
                search: "Arama:",
                infoFiltered:   "(toplam _MAX_ kayıttan filtrelenenler)",
                buttons: {
                    copyTitle: "Panoya kopyalandı.",
                    copySuccess:"Panoya %d satır kopyalandı",
                    copy: "Kopyala",
                    print: "Yazdır",
                },

                paginate: {
                    first: "İlk",
                    previous: "Önceki",
                    next: "Sonraki",
                    last: "Son"
                },
            }
        });
    </script>
@endsection

