<?php echo !defined("GUVENLIK") ? die("Erisim Engellendi!.") : null;?>
<?php 
$page = @intval($_GET['s']);
if(!$page) $page = 1;
$ttsorgu = $db->prepare("SELECT COUNT(*) FROM etkinlikler WHERE durum = ? AND dil = ?");
$ttsorgu->execute(array("1",$_SESSION['k_dil']));
$total = $ttsorgu->fetchColumn();
$limit= $limitayar['limit_sayfaetkinlik'];
$page_count = ceil($total/$limit);
if($page > $page_count) $page = 1;
$show = $page * $limit - $limit;
$BSorgu = $db->prepare("SELECT * FROM etkinlikler WHERE durum = ? AND dil = ? ORDER BY baslama_tarih ASC LIMIT $show,$limit");
$BSorgu->execute(array("1",$_SESSION['k_dil']));
$Bislem = $BSorgu->fetchALL(PDO::FETCH_ASSOC);
$menubul 	= $db->query("SELECT * FROM menu WHERE menu_url = '".$htc['etkinlikurl']."' OR link = '".$htc['etkinlikurl']."' AND dil = '{$_SESSION['k_dil']}'")->fetch(PDO::FETCH_ASSOC);
$menubas 	= $db->query("SELECT * FROM menu WHERE id = '{$menubul['menu_ust']}' AND dil = '{$_SESSION['k_dil']}'")->fetch(PDO::FETCH_ASSOC);
?>
<!-- Start main-content -->
<div class="main-content">
    <!-- Section: inner-header -->
     <section class="inner-header bg-lighter">
		<div class="container pt-10 pb-10">
			<!-- Section Content -->
			<div class="section-content">
				<div class="row d-ortala">
					<div class="col-md-11">
						<h3 class="font-30 mb-0 mt-10"><?=@$dil['txt98'];?></h3>
						<ol class="breadcrumb text-black mt-0 mb-10">
							<li><a href="<?php echo $htc['anaurl'];?><?php echo $html;?>"><?=@$dil['txt56'];?></a></li>
							<?php if($menubas['menu_isim'] != ""){?>
							<li><a href="<?php echo($menubas['menu_url'] == "0" ? $menubas['link'] : $menubas['menu_url'].$html);?>"><?php echo ilkbuyuk($menubas['menu_isim']);?></a></li>
							<?php }?>
							<li class="active text-theme-colored"><?=@$dil['txt98'];?></li>
						</ol>
					</div>
					<div class="col-md-1">
						<a href="javascript:history.back();" class="sayfa-geri"><span class="icon"><i class="fas fa-arrow-left"></i></span><?=@$dil['txt57'];?></a>
					</div>
				</div>
			</div>
		</div>
	</section>

    <!-- Section: event calendar -->
    <section>
        <div class="container pt-50 pb-50">
            <div class="row">
                <div class="col-md-12">
					<?php if($BSorgu->rowCount() != "0"){?>
					<?php foreach ( $Bislem as $BSonuc ){?>
					<?php 
					$tarihler = explode(" ",unixtarih($BSonuc['baslama_tarih'])); 
					$tarihler1 = $tarihler[1];
					$tarihler2 = $tarihler[0];
					$tarihler3 = explode("-",$tarihler2); 
					?>
                    <div class="upcoming-events bg-white-f3 mb-20">						
                        <div class="row">
                            <div class="col-sm-4 pr-0 pr-sm-15">
                                <div class="thumb p-15">
                                    <img class="img-fullwidth" src="<?php echo tema;?>/uploads/etkinlikler/<?php echo $BSonuc['resim']; ?>" alt="<?php echo $BSonuc['adi'];?>">
                                </div>
                            </div>
                            <div class="col-sm-4 pl-0 pl-sm-15">
                                <div class="event-details p-15 mt-20">
                                    <h4 class="mt-0 font-weight-500"><?php echo $BSonuc['adi'];?></h4>
                                    <p><?php echo kisa(strip_tags($BSonuc['aciklama']),300);?></p>
                                    <a href="<?php echo $htc['etkinlikdetayurl']; ?>/<?php echo $BSonuc['seo']; ?><?php echo $html;?>" class="btn btn-flat btn-dark btn-theme-colored btn-sm mt-10"><?=@$dil['txt99'];?> <i class="fa fa-angle-double-right"></i></a>
                                </div>
                            </div>
                            <div class="col-sm-4">
                                <div class="event-count p-15 mt-15">
                                    <ul class="event-date list-inline font-16 mt-10 mb-20">
                                        <li class="p-15 mr-5 bg-lightest"><?php echo tarih_yil(unixtarih($BSonuc['baslama_tarih']));?></li>
                                        <li class="p-15 pl-20 pr-20 mr-5 bg-lightest"> <?php echo tarih_ay(unixtarih($BSonuc['baslama_tarih']));?></li>
                                        <li class="p-15 bg-lightest"><?php echo tarih_gun(unixtarih($BSonuc['baslama_tarih']));?></li>
                                    </ul>
                                    <ul>
                                        <li class="mb-10"><i class="fa fa-clock-o mr-5"></i><?=@$dil['txt100'];?> <?php echo $tarihler1;?></li>
                                        <li class="mb-10"><i class="far fa-calendar-alt mr-5"></i><?=@$dil['txt94'];?> <?php echo unixtarih($BSonuc['bitis_tarih']);?></li>
                                        <li>
										<?php if($Sonuc['gmap']){?>
										<a target="_blank" href="<?php echo $Sonuc['gmap'];?>"><i class="fa fa-map-marker mr-5"></i> <?php echo $BSonuc['yer'];?></a>
										<?php }else{?>
										<i class="fa fa-map-marker mr-5"></i> <?php echo $BSonuc['yer'];?>
										<?php }?>
										</li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
					<?php }?>
					<?php }else{?>
					<div class="alert alert-warning text-left " style="width:100%;" role="alert">
						<p><strong><?=@$dil['txt59'];?></strong></p>
						<?=@$dil['txt60'];?></br>
						<?=@$dil['txt61'];?>
					</div>
					<?php }?>

                    <div class="row">
						<div class="col-sm-12">
							<p><?php echo $total;?> <?=@$dil['txt62'];?>  <?php echo $page;?> - <?php echo $limitayar['limit_sayfaetkinlik'];?> <?=@$dil['txt63'];?></p>
							<nav>
								<ul class="pagination theme-colored xs-pull-center m-0">
								<?php
								if($limitayar['limit_sayfaetkinlik'] < $total && $limitayar['limit_sayfaetkinlik'] > 0){
								$showing = 3;
								if($page > 1){?>
								<?php $previous = $page - 1;?>
								<li><a href="<?php echo $htc['etkinlikurl'];?>/<?php echo $previous;?><?php echo $html;?>" aria-label="Previous"> <span aria-hidden="true">«</span> </a> </li>
								<?php }
								for($i= $page - $showing; $i < $page + $showing + 1; $i++){
								if($i > 0 and $i <= $page_count){
								if($i == $page){?>
								<li class="active"><a href="javascript:void(0);"><?php echo $i; ?></a></li>
								<?php }else{?>
								<li><a href="<?php echo $htc['etkinlikurl'];?>/<?php echo $i; ?><?php echo $html;?>"><?php echo $i; ?></a></li>
								<?php }
								}
								}
								if($page != $page_count){?>
								<?php  $next = $page +1;?>
								<li> <a href="<?php echo $htc['etkinlikurl'];?>/<?php echo $next; ?><?php echo $html;?>" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li>
								<?php }} ?>	
								</ul>
							</nav>
						</div>
					</div>
                </div>
            </div>
        </div>
    </section>
</div>
<!-- end main-content -->