<?php include 'inc/header.php';?>
    <link href="assets/switch.css" rel="stylesheet"/>
<?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">Ürün Listesi</h4>
                                        <ol class="breadcrumb">
                                            <li class="breadcrumb-item"><a href="index.php">Anasayfa</a></li>
                                            <li class="breadcrumb-item"><a href="urun-ekle.php">Ürün Ekle</a></li>
                                            <li class="breadcrumb-item active">Ürün Listesi</li>
                                        </ol>
                                    </div><!--end col-->
                                    <div class="col-auto align-self-center">
                                    <a href="urun-ekle.php">
                                    <button type="button" class="btn btn-outline-primary waves-effect waves-light"> <i data-feather="plus-square"></i></i> Ürün 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">Ürün Listesi</h4>
                                    <p class="text-muted mb-0">Değerli kullanıcı, bu alandan projeleri düzenleyebilirsiniz. Çeşitli pratik özellikler ile işlemlerinizi kolaylıkla gerçekleştirebilirsiniz. Ek olarak ürün durumu satırından durumu pasif hale getirirseniz kullanıcıların bu ürüne erişmesini engelleyebilirsiniz.
                                    </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 style="width: 100px">Ürün Görseli</th>
                                            <th>Ürün Başlığı</th>
                                            <th>Ürün Kategorisi</th>
                                            <th>Ürün Fiyatı</th>
                                            <th>Ürün Durumu</th>
                                            <th>Tarih</th> 
                                            <th>İşlemler</th> 
                                        </tr>
                                        </thead>
    
    
                                        <tbody>
                                             <?php
                                            $ebultensorgu = $dbh->prepare("SELECT * FROM product ");
                                            $ebultensorgu->execute();

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

                                            $id = $ebultensonuc['id'];
                                            $product_name = $ebultensonuc['product_name']; 
                                            $parent = $ebultensonuc['parent'];
                                            $foto = $ebultensonuc['foto'];
                                            $product_price = $ebultensonuc['product_price']; 
                                            $date = $ebultensonuc['date'];
                                            $status = $ebultensonuc['status'];
                                            $phpdate = strtotime( $date );
                                            $mysqldate = date( 'd-m-Y ', $phpdate );
                                            $baslikseo=seo( $ebultensonuc['product_name']);

                                            $check = $dbh->query("SELECT * FROM product_categories WHERE id = '".$parent."' ", PDO::FETCH_ASSOC);
                                            if ($check->rowCount()) {
                                              foreach ($check as $check) {
                                                }

                                                $kategori = $check["categories_name"];
                                                }

                                            ?>
                                        <tr>
                                            <td style="width: 10px; height: 10px;"><?=$ebultensonuc['id'];?></td>
                                            <td><a href="../img/<?=$ebultensonuc['foto'];?>" target="_blank"> <img src="../img/<?=$ebultensonuc['foto'];?>" width= "100px" height="70px;"></a></td>
                                            <td><a href="../urun-<?=$baslikseo?>" target="_blank"><?=$ebultensonuc['product_name'];?></a><br><small><a href="../urun-<?=$baslikseo?>" target="_blank">+ Ürün Görüntüle</a></small></td>
                                            <td><?=$kategori?></td> 
                                            <td><?=$ebultensonuc['product_price'];?> TL</td>
                                             <td>
                                            <label class="switch"> 
                                                <input type="checkbox" id='<?php echo $ebultensonuc['id'] ?>' class="urunPasif" <?php echo $ebultensonuc['status']==1?'checked':'' ?>  />
                                                <span class="slider round"></span>
                                            </label>
                                        </td>
                                            <td ><?=$mysqldate?></td>
                                            <td style="width: 50px; height: 50px;">
                                        <a href="urun-duzenle.php?id=<?=$ebultensonuc['id'];?>"> <button type="button" class="btn btn-outline-primary btn-icon-circle-sm" data-toggle="tooltip" data-placement="top" title="Ürün Düzenler"><i class="ti-settings"></i></button></a>

                                        <a href="urun-galeri.php?id=<?=$ebultensonuc['id'];?>"><button type="button" class="btn btn-outline-warning btn-icon-circle-sm" data-toggle="tooltip" data-placement="top" title="Ürün Galerisi"><i class="ti-image"></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['product_name'];?></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=urun-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>     
                                    <h5 id="ebultensonuc"></h5>   
                                </div>
                            </div>
                        </div> <!-- end col -->
                    </div> <!-- end row -->
 

                     
                </div><!-- container -->
                <script src="assets/jquery.min.js"></script>
<script src="assets/uruncustom.js"></script>
<?php include 'inc/footer.php';?>