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

            <!-- 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">Alerji Listesi</h4>
                                        <ol class="breadcrumb">
                                            <li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li>
                                            <li class="breadcrumb-item"><a href="alerji-ekle.php">Alerji Ekle</a></li>
                                            <li class="breadcrumb-item active">Alerji Listesi</li>
                                        </ol>
                                    </div><!--end col-->
                                    <div class="col-auto align-self-center">
                                    <a href="alerji-ekle.php">
                                    <button type="button" class="btn btn-outline-primary waves-effect waves-light"> <i data-feather="plus-square"></i></i> Alerji Ekle</button>  
                                    </a>
                                    </div><!--end col-->  
                                </div><!--end row-->                                                              
                            </div><!--end page-title-box-->
                        </div><!--end col-->
                    </div><!--end row-->
                    <!-- end page title end breadcrumb -->
  
                    <div class="row">
                        <div class="col-12">
                            <div class="card">
                                <div class="card-header">
                                    <h4 class="card-title">Alerji Listesi</h4>
                                    <p class="text-muted mb-0">Değerli kullanıcı, bu alandan alerji düzenleyebilirsiniz. Çeşitli pratik özellikler ile işlemlerinizi kolaylıkla gerçekleştirebilirsiniz.
                                    </p>
                                </div><!--end card-header-->
                                <style type="text/css">
                                    i { 
                                        font-size: 16px;
                                    }
                                </style>
                                <div class="card-body">  
                                    <table id="datatable-buttons" class="table table-striped table-bordered dt-responsive nowrap" style="border-collapse: collapse; border-spacing: 0; width: 100%;">
                                        <thead>
                                        <tr>
                                            <th>#</th> 
                                            <th>Alerji Adı</th> 
                                            <th>Tarih</th>
                                            <th>İşlemler</th> 
                                        </tr>
                                        </thead>
    
    
                                        <tbody>
                                             <?php
                                            $ebultensorgu = $dbh->prepare("SELECT * FROM allergy ");
                                            $ebultensorgu->execute();

                                            while ($ebultensonuc = $ebultensorgu->fetch()) {

                                            $id = $ebultensonuc['id'];
                                            $title = $ebultensonuc['title']; 
                                            $description = $ebultensonuc['description'];  
                                            $date = $ebultensonuc['date'];
                                            $phpdate = strtotime( $date );
                                            $mysqldate = date( 'd-m-Y ', $phpdate ); 
                                            ?>
                                        <tr>
                                            <td style="width: 10px; height: 10px;"><?=$ebultensonuc['id'];?></td> 
                                            <td><?=$ebultensonuc['title'];?></td>  
                                            <td ><?=$mysqldate?></td>
                                            <td style="width: 50px; height: 50px;">
                                        <a href="alerji-duzenle.php?id=<?=$ebultensonuc['id'];?>"> <button type="button" class="btn btn-outline-primary btn-icon-circle-sm" data-toggle="tooltip" data-placement="top" title="Alerji Düzenler"><i class="ti-settings"></i></button></a>
 
                                        <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>

                                        <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'];?>"><?=$ebultensonuc['title'];?></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=alerji-sil"><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-->
                                        <?php } ?> 
                                        </tbody>
                                    </table>        
                                </div>
                            </div>
                        </div> <!-- end col -->
                    </div> <!-- end row -->
 

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

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