<?php
$path="../../";
include("../../map.php");
include("../../secure.php");
?>
<script>
    jQuery(document).ready(function () {
        jQuery(".mfrm").on("click", function () {
            var target = jQuery(this).data("target"),
			theModal = jQuery(target),
			title = jQuery(this).data("title"),
			width = jQuery(this).data("width"),
			frmSRC = jQuery(this).data("url"),
			refSRC = jQuery(this).data("ref");
            theModal.fadeIn().addClass("in");
            theModal.find(".v3-modal-title").text(title);
            
            <?php if ($mobile == "") { ?>
                if (width !== undefined) { theModal.css("width", width); }
            <?php } ?>
            if (refSRC !== undefined) { theModal.find(".mcbtn").attr("onclick", "location.href='" + refSRC + "'"); }
            theModal.find("iframe").attr("src", frmSRC);
            theModal.find(".close").on("click", function () { theModal.find("iframe").attr("src", "about:blank"); });
        });
    });
</script>
<div class="alert alert-warning" id="err" style="display:none;"></div>
<?php if($b6 != "0"):
$sql = mysqli_query($conn, "SELECT * FROM medya WHERE ne='slide' AND (t2='All' OR t2='{$_SESSION["lang"]}') ORDER BY s1 ASC, id DESC"); while($rslt = mysqli_fetch_assoc($sql)):
    $syetki = (($e10 == 1 && in_array($_SESSION["user"], ["Master", "SuperAdmin"])) || $e10 != 1) ? 1 : 0;
    $imgPath = file_exists("../../../deppo/slide/{$rslt["n1"]}") ? "{$weburl}/deppo/slide/{$rslt["n1"]}" : "//sample.{$cdnurl}/1920x800";
    $aktif = $rslt["s13"] == 1 ? "success" : "danger";
    $siraInputID = "f{$rslt["id"]}";
?>
<div class="col-md-3 w24" data-id="<?= $rslt["id"] ?>" id="<?= $rslt["id"] ?>" style="position:relative; border:1px solid #ccc; border-radius:5px; margin:5px 10px 20px 0; padding:0;">
    <div style="height:100px; overflow:hidden; text-align:center; background:url('<?= $imgPath ?>') center / cover;">
		<?php if ($rslt["t3"] == "video"): ?>
            <!-- YouTube ikonu sağ üst köşe -->
            <i class="fab fa-youtube" title="Video" style="position:absolute; top:5px; right:5px; color:#f00; font-size:20px; background:rgba(255,255,255,0.8); border-radius:3px; padding:2px 4px;"></i>
        <?php endif; ?>
	</div>
    <div style="position:absolute; margin-top:-10px; margin-left:5px; width:150px;">
        <form id="<?= $siraInputID ?>" method="post" style="width:150px; margin:0; padding:0;">
			<input class="form-control form-control-sm s1 text-center d-flex justify-content-center" name="s1" type="text" value="<?= $rslt["s1"] ?>" title="Sıra" onfocus="if(this.value=='0'){this.value=''}" onblur="if(this.value==''){this.value='0'}" style="width: 24px; height: 24px !important; padding: 0 6px; font-size: 11px; margin-top: 0px; margin-right: 2px; float: left; background: white !important; border: 0px !important; border-radius: 5px !important;">
			<a class="btn btn-danger btn-sm d-flex <?= $syetki ? 'ssil' : '' ?>" title="Slide Sil" style="width:24px; height:24px; margin-bottom:4px; padding:4px" <?= $syetki ? "onclick=\"if(confirm('#Bu Kayıt Silinecektir ! Onaylıyor musunuz ?')) AjaxGet('../public/slider.php?sid={$rslt["id"]}&durum=ssil','#err','#err');\"" : '' ?>><i class="fa <?= $syetki ? 'fa-times' : 'fa-lock' ?>"></i></a>
			<a class="btn btn-warning btn-sm d-flex mfrm" data-width="90%" title="Slide Düzenle" data-toggle="modal" data-target="#myModal" data-ref="<?= trim($weburl) ?>/<?= $crmpath ?>/?ne=ayarlar&islem=ayarlar#&tab-slide" data-url="../upload/upload_slide.php?ne=<?= $_GET["ne"] ?>&islem=<?= $_GET["islem"] ?>&id=<?= $rslt["id"] ?>" style="width:24px; height:24px; margin-bottom:4px; padding:4px"><i class="fas fa-edit" style="font-size: 14px;"></i></a>
			<a class="btn btn-<?= $aktif ?> btn-sm d-flex sonoff" style="width:24px; height:24px; padding:4px" onclick="AjaxGet('../public/slider.php?sid=<?= $rslt["id"] ?>&durum=onay&s13=<?= ($rslt["s13"] != 0 ? 0 : 1) ?>','#err','#err'); jQuery('#sliders').load('../public/slider.php');" title="On/Off"><i class="fa fa-power-off" style="font-size:14px;"></i></a>
		</form>
    </div>
</div>
<script>
jQuery(document).ready(function(){
    jQuery("#<?= $siraInputID ?> .s1").on("keyup", function() {
        AjaxPost('../public/slider.php?durum=dslide&id=<?= $_GET["id"] ?>&sid=<?= $rslt["id"] ?>', '#<?= $siraInputID ?>', '#err');
        jQuery("#sliders").load("../public/slider.php");
    });
});
</script>
<?php endwhile; endif; ?>
	<script>
		jQuery(".sonay, .ssil").click(function() {
			jQuery("#sliders").load("../public/slider.php");
		});
	</script>
	<?php
	if($_GET["durum"]=="ssil"){
		$sql=mysqli_query($conn, "select * from medya where ne='slide' and id=".$_GET["sid"].""); $rs=mysqli_fetch_assoc($sql);
		$dosya="../../../deppo/slide/".$rs["n1"].""; unlink($dosya);
		$dosya2="../../../deppo/slide/".$rs["n2"].""; unlink($dosya2);
		$Rs = mysqli_query($conn, "delete from medya where ne='slide' and id=".$_GET["sid"]."");

	}elseif($_GET["durum"]=="dslide"){
		$Rsq = mysqli_query($conn, "update medya set s1='".$_POST["s1"]."' where ne='slide' and id=".$_GET["sid"]."");

	}elseif($_GET["durum"]=="onay"){
		$Rsq = mysqli_query($conn, "update medya set s13='".$_GET["s13"]."' where ne='slide' and id=".$_GET["sid"]."");
	}
	include("../public/log.php");
	echo $footer;
	?>