<?php include 'inc/header.php';?>
<?php include 'inc/sidebar.php';?>
<?php include 'inc/navbar.php';?>

<div class="modal fade" id="exampleModalDanger" tabindex="-1" role="dialog" aria-labelledby="exampleModalDanger" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header bg-danger">
                <h6 class="modal-title m-0 text-white" id="exampleModalDanger">Toplu Silme İşlemi</h6>
                <button type="button" class="close " data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true"><i class="la la-times text-white"></i></span>
                </button>
            </div><!--end modal-header-->
            <div class="modal-body">
                <div class="row"> 
                    <div class="col-lg-12">
                        <h5>Ziyaretçi kayıtlarında yer alan tüm kayıtları silmek üzeresiniz bu işlemi yapmak istiyormusunuz ?</h5>

                        <ul class="mt-3 mb-0">
                            <li>Bu veri silinirse geri döndürülemez.</li> 
                        </ul>
                    </div><!--end col-->
                </div><!--end row-->                                                     
            </div><!--end modal-body-->
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Kapat</button>
                <a href="islem.php?islem=hesap-tsil"><button type="button" class="btn btn-danger btn-sm">Evet, Sil</button></a>
            </div><!--end modal-footer-->
        </div><!--end modal-content-->
    </div><!--end modal-dialog-->
</div><!--end modal-->


<!-- Page Content-->
<div class="page-content">
    <div class="container-fluid">
        <!-- Page-Title -->
        <div class="row">
            <div class="col-sm-12">
                <div class="page-title-box">
                    <div class="row">
                        <div class="col">
                            <h4 class="page-title">Hesap Listesi</h4>
                            <ol class="breadcrumb">
                                <li class="breadcrumb-item"><a href="anasayfa">Anasayfa</a></li> 
                                <li class="breadcrumb-item active">Hesap Listesi</li>
                            </ol>
                        </div><!--end col--> 
                        <div class="col-auto align-self-center"> 
                            <button type="button" class="btn btn-outline-primary waves-effect waves-light" data-toggle="modal" data-target="#exampleModalDanger"> <i data-feather="alert-octagon"></i></i> Tümünü Sil</button>   
                        </div>
                    </div><!--end row-->                                                              
                </div><!--end page-title-box-->
            </div><!--end col-->
        </div><!--end row-->
        <!-- end page title end breadcrumb -->
        <style type="text/css">
            i { 
                font-size: 16px;
            }
        </style>
        <div class="row"> 
            <div class="col-lg-12">
                <div class="card">
                    <div class="card-header">
                        <h4 class="card-title">Hesap Listesi</h4>
                        <p class="text-muted mb-0">Değerli kullanıcı, bu alan sayesinde hesap taleplerini görebilirsiniz.
                        </p>
                    </div><!--end card-header-->
                    <div class="card-body">
                        <div class="table-responsive">
                            <table class="table table-bordered mb-0 table-centered">
                                <thead>
                                    <tr>
                                        <th>#</th>
                                        <th>Masa No</th>
                                        <th>İsim Soyisim</th>
                                        <th>Not</th>
                                        <th>Tarih</th> 
                                        <th>Okunma Durumu</th>
                                        <th>İşlemler</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                    $ebultensorgu  = $dbh->prepare("SELECT * FROM account ");
                                    $ebultensorgu-> execute(array());
                                    $ebultensorgu  = $ebultensorgu->fetchAll(PDO::FETCH_ASSOC);

                                    foreach ($ebultensorgu as $ebultensonuc) {

                                        $masa  = $dbh->prepare("SELECT * FROM masa_no where id=? ");
                                        $masa-> execute(array( $ebultensonuc['masa']));
                                        $masa  = $masa->fetch(PDO::FETCH_ASSOC);

                                        $id = $ebultensonuc['id'];
                                        $name = $ebultensonuc['name']; 
                                        $note = $ebultensonuc['note']; 
                                        $tarih = $ebultensonuc['tarih'];
                                        $phpdate = strtotime( $tarih );
                                        $mysqldate = date( 'd-m-Y / h:i ', $phpdate );  
                                        ?>
                                        <tr>
                                            <td style="width: 10px; height: 10px;">#<?=$ebultensonuc['id'];?></td>
                                            <td><?=$masa['masa_adi'];?></td>
                                            <td><?=$ebultensonuc['name'];?></td>
                                            <td><?=$ebultensonuc['note'];?></td>
                                            <td><?=$mysqldate?></td>
                                             <?php if($ebultensonuc['checking'] == 0){
                                                 echo '<td style="width: 150px;"><center><span class="badge badge-soft-danger">Okunmadı</span></center></td>';
                                                 }else if ($ebultensonuc['checking'] == 1) {
                                                 echo '<td style="width: 150px;"><center><span class="badge badge-soft-success">Okundu</span></center></td>';
                                                 } 
                                                 ?> 
                                            <td style="width: 150px; ">

                                                <button type="button" class="btn btn-outline-danger btn-icon-circle-sm" data-toggle="modal" data-target="#exampleModalDanger<?=$ebultensonuc['id'];?>" ><i class="ti-trash"></i></button> 

                                            </td> 
                                        </tr> 

                                        <!-- silme başlangıçı -->

                                        <div class="modal fade" id="exampleModalDanger<?=$ebultensonuc['id'];?>" tabindex="-1" role="dialog" aria-labelledby="exampleModalDanger<?=$ebultensonuc['id'];?>" aria-hidden="true">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                    <div class="modal-header bg-danger">
                                                        <h6 class="modal-title m-0 text-white" id="exampleModalDanger<?=$ebultensonuc['id'];?>">Talep Silme</h6>
                                                        <button type="button" class="close " data-dismiss="modal" aria-label="Close">
                                                            <span aria-hidden="true"><i class="la la-times text-white"></i></span>
                                                        </button>
                                                    </div><!--end modal-header-->
                                                    <div class="modal-body">
                                                        <div class="row"> 
                                                            <div class="col-lg-12">
                                                                <h5>Bu veriyi silmek istiyormusunuz ?</h5>
                                                                <span class="badge bg-soft-secondary">Eklenme Tarihi:</span>
                                                                <small class="text-muted ml-2"> <?=$mysqldate?></small>
                                                                <ul class="mt-3 mb-0">
                                                                    <li>Bu veri silinirse geri döndürülemez.</li> 
                                                                </ul>
                                                            </div><!--end col-->
                                                        </div><!--end row-->                                                     
                                                    </div><!--end modal-body-->
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-secondary btn-sm" data-dismiss="modal">Kapat</button>
                                                        <a href="islem.php?id=<?=$ebultensonuc['id']; ?>&islem=hesap-sil"><button type="button" class="btn btn-danger btn-sm">Evet, Sil</button></a>
                                                        <a href="islem.php?id=<?=$ebultensonuc['id']; ?>&islem=hesap-onay"><button type="button" class="btn btn-success btn-sm">Okundu Olarak İşaretle</button></a> 
                                                    </div><!--end modal-footer-->
                                                </div><!--end modal-content-->
                                            </div><!--end modal-dialog-->
                                        </div><!--end modal-->
                                    <?php } ?>
                                    <?php 
                                    if(count($ebultensorgu)==0){
                                        echo "<tr><td colspan='7'><center><br>Herhangi bir veri bulunamadı <br> <img src='assets/images/sad.png' width='30px;' ></center></td></tr>";
                                    }

                                    ?>

                                </tbody>
                            </table><!--end /table-->
                        </div><!--end /tableresponsive-->
                    </div><!--end card-body-->
                </div><!--end card-->
            </div> <!-- end col -->
        </div> <!-- end row -->



    </div><!-- container -->

    <?php include 'inc/footer.php';?>