<?php echo !defined("GUVENLIK") ? die("Vaoww! Bu ne cesaret?") : null;?><?php
$productsayar = $db->prepare("select * from urunmodul_ayar where id='1'");
$productsayar->execute();
$prodayar = $productsayar->fetch(PDO::FETCH_ASSOC);
$tablimit = $prodayar["tab_limit"];
$gruplimit = $prodayar["urun_grup_limit"];
$urunlimit = $prodayar["tab_urun_limit"];
?>
<?php
$productcat = $db->prepare("select * from urun_cat where dil='$_SESSION[dil]' and anasayfa='1' and ust_id='0' and durum='1' order by sira asc limit $tablimit");
$productcat ->execute();

$productcat2 = $db->prepare("select * from urun_cat where dil='$_SESSION[dil]' and anasayfa='1' and ust_id='0' and durum='1' order by sira asc limit $tablimit");
$productcat2 ->execute();
?>
<?php
$product_list_new = $db->prepare("select * from urun where durum='1' and dil='$_SESSION[dil]' order by id desc limit $urunlimit");
$product_list_new ->execute();

$product_list_populer = $db->prepare("select * from urun where durum='1' and dil='$_SESSION[dil]' order by hit desc limit $urunlimit");
$product_list_populer ->execute();
?>
<style>
    .products-home-main-div{width:<?php if($prodayar[width]==1){?> 90%; <?php }else {?> 100% <?php }?> ; height: auto; overflow: hidden; background-color: #<?php echo $prodayar[back_color] ?>; padding: <?php echo $prodayar[padding] ?>px 0 <?php echo $prodayar[padding] ?>px 0; }

    .product-main-box-img .buttons .text{background-color: #<?php echo $prodayar[incele_button_back] ?>; }


    .product_tabs {  width: 100%; height: auto; margin: 0 auto; text-align: center; overflow: hidden; padding: 0; padding: 5px 0 35px 0; }
    .product_tabs li { display: inline-block;  height: auto;  }
    .product_tabs li a {
        outline: none; font-size: <?php echo $prodayar[tab_font_size] ?>; font-family: 'Open Sans', Arial; font-weight: 500;
        padding: 5px 15px 5px 15px;
        text-decoration: none;
        border:1px solid #<?php echo $prodayar[back_color] ?>;
        border-radius:<?php echo $prodayar[tab_border_radius] ?>px ;
        background: #<?php echo $prodayar[back_color] ?>;
        color: #<?php echo $prodayar[tab_text_color] ?>;
    }
    .product_tabs li .active { position: relative;  }
    .product_tabs li a.active { font-weight: bold;  border:1px solid #<?php echo $prodayar[tab_border_color] ?>;  background: #<?php echo $prodayar[tab_back_color] ?>; color: #<?php echo $prodayar[tab_act_text_color] ?>;}

    .product_tabs_content{width: 100%; margin: 0 auto; display: none}


</style>

<div class="products-home-main-div">
    <div class="section-head text-center modules-header-main-head" style="background:url(images/<?php echo $prodayar[divider] ?>.png) no-repeat center bottom;">
        <h2 class="modules-header-main-baslik font-open-sans font-<?php echo $prodayar[font_weight] ?> font-spacing" style="color:#<?php echo $prodayar[baslik_color] ?>">
                <?php echo $diller['urunlerimiz']?></h2>
        <p class="modules-header-main-spot font-raleway font-light" style="color:#<?php echo $prodayar[spot_color] ?>; letter-spacing: 0.07em; ">
                <?php echo $diller['urunlerimiz-aciklamasi']?></p>
    </div>


    <div class="products-home-main-div-inside">

        <div id="tab-container" >


            <ul class='product_tabs'>
                <?php
                if($prodayar[yeni] == 1) {
                ?>
                <li><a href="#yeni"><?php echo $diller['yeni'] ?></a></li>
                <?php }?>

                <?php
                if($prodayar[populer] == 1) {
                    ?>
                    <!-- Popüler Aktif -->
                    <li><a href="#populer"><?php echo $diller['populer'] ?></a></li>
                    <!-- Popüler Aktif -->
                <?php } ?>



                <?php foreach ($productcat as $procats) {   ?>
                    <!-- Ürün Kategori Tabs !-->
                    <li><a href="#<?php echo $procats[id] ?>"><?php echo $procats[baslik] ?></a></li>
                    <!-- Ürün Kategori Tabs !-->
                <?php     }?>

            </ul>



            <?php
            if($prodayar[yeni] == 1) {
            ?>

                <?php if($product_list_new->rowCount() > 0) { ?>
                <!-- Yeni Ürünler Aktif -->
            <div id="yeni" class="product_tabs_content" >

                <?php foreach ($product_list_new as $pronew) {

                $pro_list_cat = $db->prepare("select * from urun_cat where id='$pronew[kat_id]' and durum='1' and dil='$_SESSION[dil]' order by id desc limit 1 ");
                $pro_list_cat->execute();
                $pro_cat = $pro_list_cat->fetch(PDO::FETCH_ASSOC);

                ?>

                <?php
                if($pronew[stok] > 0) {
                ?>

                <div class="product-main-box">
                    <div class="product-main-box-in">
                        <div class="product-main-box-img">

                            <img src="images/product/<?php echo $pronew[gorsel] ?>" alt="<?php echo $pronew[baslik] ?>">
                            <a href="urun/<?php echo $pronew[id] ?>/<?php echo seo($pronew[baslik]) ?>"><div class="ovrly"></div></a>
                            <div class="buttons">
                                <a href="urun/<?php echo $pronew[id] ?>/<?php echo seo($pronew[baslik]) ?>" class="text" style="color:#<?php echo $prodayar[incele_button_color]?>;"><i class="fa fa-search" style="color:#<?php echo $prodayar[incele_button_color]?>"></i> <?php echo $diller['incele'] ?></a>
                            </div>

                        </div>
                        <div class="product-main-box-baslik">
                            <div class="product-main-box-baslik-in">
                                <a href="urun/<?php echo $pronew[id] ?>/<?php echo seo($pronew[baslik]) ?>"><?php echo $pronew[baslik] ?></a>
                            </div>
                        </div>
                        <div class="product-main-box-category">
                            <?php echo $pro_cat[baslik] ?>
                        </div>
                      
                    </div>
                </div>

                <?php }?>
                <?php } ?>

            </div>
                <!-- Yeni Ürünler Aktif -->
                    <?php } else { ?>

            <div id="yeni" class="product_tabs_content font-15 font-open-sans font-bold" style="background: #EBEBEB; padding: 20px 0 20px 0" >
                YENİ BİR ÜRÜN BULUNAMADI <br>
                <span class="font-14 font-small font-open-sans">Yeni bir ürün ekleyiniz</span>
            </div>

                    <?php }?>
            <?php }?>




            <?php
            if($prodayar[populer] == 1) {
                ?>

            <?php if($product_list_populer->rowCount() > 0) { ?>
                <!-- Popüler Aktif -->
                <div id="populer" class="product_tabs_content" >


                    <?php foreach ($product_list_populer as $prohit) {

                        $pro_list_cat = $db->prepare("select * from urun_cat where id='$prohit[kat_id]' and durum='1' and dil='$_SESSION[dil]' order by id desc limit 1 ");
                        $pro_list_cat->execute();
                        $pro_cat = $pro_list_cat->fetch(PDO::FETCH_ASSOC);

                        ?>

                        <?php
                        if($prohit[stok] > 0) {
                            ?>
                            <div class="product-main-box">
                                <div class="product-main-box-in">
                                    <div class="product-main-box-img">

                                        <img src="images/product/<?php echo $prohit[gorsel] ?>" alt="<?php echo $prohit[baslik] ?>">
                                        <a href="urun/<?php echo $prohit[id] ?>/<?php echo seo($prohit[baslik]) ?>"><div class="ovrly"></div></a>
                                        <div class="buttons">
                                            <a href="urun/<?php echo $prohit[id] ?>/<?php echo seo($prohit[baslik]) ?>" class="text" style="color:#<?php echo $prodayar[incele_button_color]?>;"><i class="fa fa-search" style="color:#<?php echo $prodayar[incele_button_color]?>"></i> <?php echo $diller['incele'] ?></a>
                                        </div>

                                    </div>
                                    <div class="product-main-box-baslik">
                                        <div class="product-main-box-baslik-in">
                                            <a href="urun/<?php echo $prohit[id] ?>/<?php echo seo($prohit[baslik]) ?>"><?php echo $prohit[baslik] ?></a>
                                        </div>
                                    </div>
                                    <div class="product-main-box-category">
                                        <?php echo $pro_cat[baslik] ?>
                                    </div>
                                </div>
                            </div>
                        <?php }?>
                    <?php } ?>



                </div>
                <!-- Popüler Aktif -->
                <?php } else { ?>

                    <div id="populer" class="product_tabs_content font-15 font-open-sans font-bold" style="background: #EBEBEB; padding: 20px 0 20px 0" >
                        POPÜLER ÜRÜN BULUNAMADI <br>
                        <span class="font-14 font-small font-open-sans">Yeni bir ürün ekleyiniz</span>
                    </div>

                <?php }?>
            <?php } ?>
            <?php foreach ($productcat2 as $procats2) {
            $cat_ids = $procats2[id]; ?>
            <div id="<?php echo $procats2[id] ?>"  class="product_tabs_content" >
                <?php
                $newcatlisturun = $db->prepare("SELECT * FROM urun WHERE durum='1' and dil='$_SESSION[dil]' and kat_id IN (
                                                          SELECT id FROM urun_cat  WHERE id = $cat_ids OR ust_id = $cat_ids) order by id desc limit $urunlimit");
                $newcatlisturun ->execute();
                while($urunrow = $newcatlisturun->fetch(PDO::FETCH_ASSOC)){

                    $kat_list_son = $db->prepare("select * from urun_cat where id='$urunrow[kat_id]' and durum='1' and dil='$_SESSION[dil]' order by id desc limit 1 ");
                    $kat_list_son->execute();
                    $row_kat = $kat_list_son->fetch(PDO::FETCH_ASSOC); ?>
                    <?php
                    if($urunrow[stok] > 0) {
                        ?>
                        <div class="product-main-box">
                            <div class="product-main-box-in">
                                <div class="product-main-box-img">

                                    <img src="images/product/<?php echo $urunrow[gorsel] ?>" alt="<?php echo $urunrow[baslik] ?>">
                                    <a href="urun/<?php echo $urunrow[id] ?>/<?php echo seo($urunrow[baslik]) ?>"><div class="ovrly"></div></a>
                                    <div class="buttons">
                                        <a href="urun/<?php echo $urunrow[id] ?>/<?php echo seo($urunrow[baslik]) ?>" class="text" style="color:#<?php echo $prodayar[incele_button_color]?>;"><i class="fa fa-search" style="color:#<?php echo $prodayar[incele_button_color]?>"></i> <?php echo $diller['incele'] ?></a>
                                    </div>

                                </div>
                                <div class="product-main-box-baslik">
                                    <div class="product-main-box-baslik-in">
                                        <a href="urun/<?php echo $urunrow[id] ?>/<?php echo seo($urunrow[baslik]) ?>"><?php echo $urunrow[baslik] ?></a>
                                    </div>
                                </div>
                                <div class="product-main-box-category">
                                    <?php echo $row_kat[baslik] ?>
                                </div>
                            </div>
                        </div>
                    <?php }?>
                <?php }?>
                <?php
                $taburunsayisi = $db->prepare("SELECT * FROM urun WHERE durum='1' and dil='$_SESSION[dil]' and kat_id IN (
                                                          SELECT id FROM urun_cat  WHERE id = $cat_ids OR ust_id = $cat_ids) order by id desc limit $urunlimit");
                $taburunsayisi ->execute(); ?>
                <?php if($taburunsayisi->rowCount() <= 0)  { ?>
                    <div  class="font-15 font-open-sans font-bold" style="background: #EBEBEB; padding: 20px 0 20px 0" >
                        Bu kategoride ürün bulunamamıştır<br>
                    </div>
                <?php }?>
            </div>
            <?php }?>
        </div>
    </div>
    <?php
    if($prodayar[urun_grup] == 1) { ?>
        <?php
        if($ayar[ticaret_text_home] == 0) { ?>
            <div style="margin-bottom: 50px; width: 100px;  overflow: hidden;"></div>
        <?php } ?>
        <div class="products-home-main-div-inside">
            <div class="modules-header-main-product-group">
                <div class="modules-header-main-head" style="background:url(images/<?php echo $prodayar[divider] ?>.png) no-repeat center bottom;">
                    <div class="modules-header-main-baslik font-open-sans font-<?php echo $prodayar[font_weight] ?> font-spacing" style="color:#<?php echo $prodayar[baslik_color] ?>">
                        <?php echo $diller['urun-gruplari']?>
                    </div>
                </div>
            </div>
            <div class="product-group-main">
                <?php $sql_urungrup = $db->prepare("select * from urun_cat where durum='1' and dil='$_SESSION[dil]' and anasayfa_grup='1' order by grup_sira asc limit $gruplimit");
                $sql_urungrup->execute();
                while($gruprow=$sql_urungrup->fetch(PDO::FETCH_ASSOC))
                {
                    ?><div class="product-group-box" style="border:1px solid #<?php echo $prodayar[urun_grup_border] ?>">
                    <a href="urun-kategori/<?php echo $gruprow[id]?>/<?php echo seo($gruprow[baslik]) ?>">
                        <div class="product-group-box-text">
                            <div class="product-group-box-text-head font-open-sans font-16 font-bold " style="color:#<?php echo $prodayar[urun_grup_textcolor] ?>; background-color: #<?php echo $prodayar[urun_grup_back] ?>">
                                <?php echo $gruprow[baslik] ?>
                            </div>
                            <div class="product-group-box-clear"></div>
                            <div class="product-group-box-text-browse font-open-sans font-13 font-exlight" style="color:#<?php echo $prodayar[urun_grup_incelecolor] ?>; background-color: #<?php echo $prodayar[urun_grup_incele_back] ?>;">

                                <?php echo $diller['urunlere-git'] ?> <i class="fa fa-angle-right" style="margin-left:10px"></i>
                            </div>
                        </div>
                        <img src="images/product-category/<?php echo $gruprow[gorsel]?>" alt="<?php echo $gruprow[baslik]?>">
                    </a>
                    </div>
                <?php } ?>
                <?php
                if($sql_urungrup->rowCount() <= 0) { ?>
                    <div class="product-group-box" style="border:1px solid #333; background: #EBEBEB;">
                        <div class="product-group-box-text-head font-open-sans font-16 font-bold " style="color:#FFF; background-color: #000">
                            ÜRÜN GRUBU EKLENMEMİŞ YADA ANASAYFA SEÇİLİ DEĞİL!
                        </div>
                        <i class="fa fa-exclamation-circle" style="font-size:35px; margin-top: 10px;"></i>
                    </div>
                <?php } ?>
            </div>
        </div>
    <?php } ?>
</div>


