<?php
$query = $db->query("SELECT * FROM hikaye ORDER BY id DESC", PDO::FETCH_ASSOC);
if($query->rowCount()){
?>
  <div class="container-fluid" id="hikate-dis">
      <div class="container mt-10 mb-10">
          <div class="col-md-12">
            <section class="hikaye slider">
              <?php
                  foreach($query as $row){
                    echo '<div><a href="javascript:void(0)" data-buyuk-img="'.$row['buyuk_img'].'" data-link="'.$row['link'].'"><img src="upload/'.$row['kucuk_img'].'"></a></div>';
                  }
              ?>
            </section>
          </div>
      </div>
    </div>
  </div>
<?php } ?>

<div class="container-fluid" id="banner-dis">
  <div class="row">
      <div class="container">
        <div class="row">
          <div id="banner" class="owl-carousel">

            <?php
              $img = ''; 
              $query = $db->query("SELECT * FROM slider ORDER BY id DESC", PDO::FETCH_ASSOC);
              if($query->rowCount()){
                foreach($query as $row){
                  echo '<div class="item" data-renk="'.$row['arka_plan_rengi'].'">
                    <div class="col-md-4">
                      <span class="baslik">'.$row['baslik'].'</span>
                      <span class="aciklama">'.$row['aciklama'].'</span>
                      
                      <a href="'.$row['link'].'" class="link btn" style="background:'.$row['arka_plan_rengi'].';color:#fff">Detaylı İncele</a>
                    </div>
                    <div class="col-md-8">
                      <img src="upload/'.$row['img'].'">
                    </div>
                  </div>';
                  $img .= $row['img'].'|';
                }
              }
            ?>

         </div>
        </div>
      </div>
      <div class="container" style="background: none;">
        <div class="row hidden-xs">
          <div id="banner_kucuk" class="owl-carousel mb-10">
             <?php
              foreach (explode('|', $img) as $i) {
                if(!empty($i)){
                  echo '<div class="item">
                        <img src="upload/'.$i.'" class="img-fluid img-center">
                     </div>';
                }
              }
             ?>
          </div>
        </div>
      </div>
  </div>
</div> 






<div class="container mt-20 mb-20" id="tanitim">
  <div class="row mb-20">
    <div class="col-md-12">
      <div class="div-baslik text-center"><h4>Kampanyalar</h4></div>
    </div>
  </div>
  <div class="row">
    <?php
    $query = $db->query("SELECT * FROM slider_alti_resimler ORDER BY id DESC", PDO::FETCH_ASSOC);
    if($query->rowCount()){
      foreach($query as $row){
        echo '<div class="col-md-3 col-xs-6 mb-10"><a href="'.$row['link'].'"><img src="upload/'.$row['img'].'" class="img-responsive"></a></div>';
      }
    }
    ?>
  </div>
</div>

<?php
$query = $db->query("SELECT * FROM vitrin ORDER BY sira ASC", PDO::FETCH_ASSOC);
if($query->rowCount()){
  foreach($query as $row){
?>
 <div class="container mb-20">
  <div class="row mb-20">
    <div class="col-md-12">
      <div class="div-baslik text-center"><h4><?php echo $row['baslik']; ?></h4></div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <div class="owl-carousel urun-slider owl-theme">
        <?php
        $query1 = $db->query("SELECT * FROM vitrin_urun WHERE vitrin_id = '{$row['id']}' ORDER BY sira ASC", PDO::FETCH_ASSOC);
        if($query1->rowCount()){
          foreach($query1 as $row1){
            $urun = $db->query("SELECT * FROM urun WHERE id = '{$row1['urun_id']}' LIMIT 1")->fetch(PDO::FETCH_ASSOC);
            $img1 = $db->query("SELECT * FROM urun_img WHERE urun_id = '{$row1['urun_id']}' LIMIT 0,1")->fetch(PDO::FETCH_ASSOC);
            $img2 = $db->query("SELECT * FROM urun_img WHERE urun_id = '{$row1['urun_id']}' LIMIT 1,1")->fetch(PDO::FETCH_ASSOC);
            if(!$img2){
              $img2['img'] = $img1['img'];
            }
        ?>
        <div class="item">
          <a href="urun/<?php echo $urun['sef']; ?>" title="<?php echo $urun['baslik']; ?>" class="urun">
            <img src="upload/<?php echo $img1['img']; ?>" alt="<?php echo $urun['baslik']; ?>" class="img-responsive img1">
            <img src="upload/<?php echo $img2['img']; ?>" alt="<?php echo $urun['baslik']; ?>" class="img-responsive img2">
            <b><?php echo $urun['baslik']; ?></b>
            <div>
                <span><?php echo $urun['fiyat']; ?> TL</span>
                <span><?php echo !empty($urun['eski_fiyat']) ? $urun['eski_fiyat'].' TL' : ''; ?></span>
            </div>
          </a>
        </div>
        <?php } } ?>
      </div>
    </div>
  </div>
 </div>
 <?php } } ?>


<?php
$query = $db->query("SELECT * FROM blog ORDER BY id desc", PDO::FETCH_ASSOC);
if($query->rowCount()){
?>
 <div class="container mb-20">
  <div class="row mb-20">
    <div class="col-md-12">
      <div class="div-baslik text-center"><h4>Blog Haberleri</h4></div>
    </div>
  </div>
  <div class="row">
    <div class="col-md-12">
      <div class="owl-carousel blog-haber owl-theme">
        <?php foreach($query as $row){ ?>
        <div class="item">
          <a href="blog/<?php echo $row['sef']; ?>" title="<?php echo $row['baslik']; ?>" class="blog">
            <img src="upload/<?php echo $row['img']; ?>" alt="<?php echo $row['baslik']; ?>" class="img-responsive">
            <b><?php echo $row['baslik']; ?></b>
          </a>
        </div>
        <?php } ?>
      </div>
    </div>
  </div>
 </div>
<?php } ?>


<div class="modal fade" id="hikaye-popup" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
  <div class="modal-dialog" role="document" style="width: fit-content;">
    <div class="modal-content">
      <div id="saniye" style="width: 0px;height: 10px;background: #f12870;float: left;"></div>
      <div class="modal-body" style="padding: 0px">
        <div class="row">
          <div class="col-md-12" id="icerik"></div>
        </div>
      </div>
    </div>
  </div>
</div>