<?php echo !defined("GUVENLIK") ? die("Erisim Engellendi!.") : null;?>
<?php 
$page = @intval($_GET['s']);
if(!$page) $page = 1;
$ttsorgu = $db->prepare("SELECT COUNT(*) FROM dokumanlar WHERE durum = ? AND dil = ?");
$ttsorgu->execute(array("1",$_SESSION['k_dil']));
$total = $ttsorgu->fetchColumn();
$limit= $limitayar['limit_sayfadokuman'];
$page_count = ceil($total/$limit);
if($page > $page_count) $page = 1;
$show = $page * $limit - $limit;
$BSorgu = $db->prepare("SELECT * FROM dokumanlar WHERE durum = ? AND dil = ? ORDER BY sira 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['dokumanurl']."' OR link = '".$htc['dokumanurl']."' 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['txt81'];?></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['txt81'];?></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: Course gird -->
    <section id="dokuman">
        <div class="container pt-50 pb-50">
			<?php if(isset($_SESSION["veli_giris"])){?>
            <div class="row">
                <div class="col-md-12 blog-pull-right">
					<?php if($BSorgu->rowCount() != "0"){?>
                    <div class="row">						
                        <?php foreach ( $Bislem as $BSonuc ){?>

						<div class="col-lg-<?php echo $limitayar['limit_dokuman'];?> col-md-<?php echo $limitayar['limit_dokuman'];?> col-xs-6 workers-col">
							<div class="card card-active">
								<a target="_blank" href="<?php echo tema;?>/uploads/dokuman/dosya/<?php echo $BSonuc['dosya']; ?>">
									<div class="dosyapdf"><i class="<?php echo $BSonuc['icon']; ?> fa-5x"></i></div>
									<div class="baslik"><?php echo $BSonuc['adi']; ?></div>
								</a>
							</div>
						</div>

						<?php }?>						
                    </div>
					<?php }else{?>
					<div class="col-12">
						<div class="alert alert-warning text-left " style="width:100%;" role="alert">
							<p><strong><?=@$dil['txt59'];?></strong></p>
							<?=@$dil['txt60'];?></br>
							<?=@$dil['txt61'];?>
						</div>
					</div>
					<?php }?>
                </div>
            </div>
            <div class="row">
                <div class="col-sm-12">
					<p><?php echo $total;?> <?=@$dil['txt62'];?>  <?php echo $page;?> - <?php echo $limitayar['limit_sayfadokuman'];?> <?=@$dil['txt63'];?></p>
                    <nav>
                        <ul class="pagination theme-colored xs-pull-center m-0">
						<?php
						if($limitayar['limit_sayfadokuman'] < $total && $limitayar['limit_sayfadokuman'] > 0){
						$showing = 3;
						if($page > 1){?>
						<?php $previous = $page - 1;?>
						<li><a href="<?php echo $htc['dokumanurl'];?>/<?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['dokumanurl'];?>/<?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['dokumanurl'];?>/<?php echo $next; ?><?php echo $html;?>" aria-label="Next"> <span aria-hidden="true">»</span> </a> </li>
						<?php }} ?>	
                        </ul>
                    </nav>
                </div>
            </div>
			<?php }else{?>
			<div class="col-lg-12 col-md-12 text-center">
				<p><?=@$dil['txt82'];?></p>
				<a href="" data-remodal-target="login" class="btn btn-gray btn-theme-colored btn-circled btn-lg"><?=@$dil['txt83'];?></a>
			</div>
			<?php }?>
        </div>
    </section>
</div>
<!-- end main-content -->

<?php if(isset($_SESSION["veli_giris"]) == false){?>
<!-- end main-content -->
<script type="text/javascript">
$(window).load(function(){ 
	var inst = $.remodal.lookup[$('[data-remodal-id=login]').data('remodal')];
    inst.open();
}); 
</script>
<!--Giriş -->
<div class="remodal p-0 popupform" data-remodal-id="login" data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
    <a data-remodal-action="close" class="remodal-close bg-white"></a>
    <form action="_class/site_islem.php" class="form-column yorum-form mb-0" method="post" autocomplete="off">
        <div class="inner-column mt-0 rounded-0 text-left">
			<h5 class="text-white"><?=@$dil['txt84'];?></h5>
			<!--Default Form-->
			<div class="default-form">
				<div class="row clearfix">

					<div class="form-group col-md-12 col-sm-12 col-xs-12">
						<input type="password" name="veli_sifre" placeholder="<?=@$dil['txt85'];?>" required="">
					</div>
					
					<?php if(@$_SESSION['sifrebtn'] == 'no'){?>
					<div class="col-md-12 col-sm-12 col-xs-12">
					<p style="color:red;"><?=@$dil['txt86'];?></p>
					</div>
					<?php unset($_SESSION['sifrebtn']);?>
					<?php }?>

					<div class="form-group text-center btn-column col-md-12 col-sm-12 col-xs-12">
						<input type="hidden" name="kontrol" value="" id="kontrol">	
						<input type="hidden" name="sifreurl" value="<?php echo $sayfalink;?>" />
						<button type="submit" name="sifrebtn" class="btn btn-gray btn-theme-colored btn-circled btn-lg"><span class="txt"><?=@$dil['txt83'];?></span></button>
					</div>

				</div>
			</div>

		</div>
    </form>
</div>
<?php }?>