<?php
	$path="../../";
	include("../../map.php");
	include("../../scripts.php");
	$sqlt=mysqli_query($conn, "select * from genel where ne='".$_REQUEST["print"]."'"); $rst=mysqli_fetch_assoc($sqlt);
	if(mysqli_num_rows($sqlt)==0 and $_REQUEST["print"]<>""){
		$sqli = $conn->query("insert into genel (ne) values ('".$_REQUEST["print"]."')");
	}
?>
<style>
@media print {
  .hidden-print {
	display: none !important;
  }
}
body {
	width:<?php echo $rst["t1"]?>;
	margin:0px;
	padding:0px;
}
.barcode{
	width:<?php echo $rst["t2"]?>;
	height:<?php echo $rst["t3"]?>;
	margin-top:<?php echo $rst["t4"]?>;
	margin-right:<?php echo $rst["t5"]?>;
	margin-bottom:<?php echo $rst["t6"]?>;
	margin-left:<?php echo $rst["t7"]?>;
	float:left;
	text-align:center;
	position: relative;
}
.point{
    position: absolute;
    margin-top: 14px;
    margin-left: 12px;
    font-size: 10px;
    width: 30px;
    height: 30px;
    text-align: center;
    color: white;
    padding-top: 3px;
}
</style>
<title>Print QR</title>
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<?php if($_GET["cmd"]==""){?>
<div class="container tac">
<div>
	<!-- Nav tabs -->
	<ul class="v3-nav v3-nav-tabs" role="tablist">
		<li role="presentation" class="nav-link active"><a href="#tb1" data-bs-target="#tb1" aria-controls="tb1" role="tab" data-toggle="tab"><?php echo $t24;?></a></li>
		<li role="presentation" class="nav-link"><a href="#tb2" data-bs-target="#tb2" aria-controls="tb2" role="tab" data-toggle="tab">Puan</a></li>
		<li role="presentation" class="nav-link"><a href="?">Reset</a></li>
	</ul>
	<!-- Tab panes -->
	<div class="v3-tab-content">
		<div role="tabpanel" class="v3-tab-pane active" id="tb1" style="padding:15px;">
			<form action="?ne=kayit&cmd=print" method="post" target="_blank">
<div class="col-md-8">
				<input id="qty" name="qty" class="form-control" type="text" placeholder="Adet" style="">
</div>
<div class="col-md-4">
				<button class="print btn btn-warning" type="submit" name="print" value="qr" style="">Qr</button>
				<button class="print btn btn-info" type="submit" name="print" value="ean" style="">Ean13</button>
</div>
		<table class="table">
		<?php
				$sql=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' and s13=1 order by s12 asc"); while($rsu=mysqli_fetch_assoc($sql)){
				$jsl = json_decode($rsu["n16"],true);
				$jsi = json_decode($rsu["n17"],true);
				$jsm = json_decode($rsu["m1"],true);
			?>
		<input type="hidden" name="KID[]" value="<?php echo $rsu["id"]?>" />
			<tr>
				<td><?php echo $rsu["t1"]?></td>
				<td><input class="qty" name="qty[]" type="text" placeholder="Adet"></td>
			</tr>
			<?php }?>
		</table>
		</form>
		</div>
		<div role="tabpanel" class="v3-tab-pane" id="tb2" style="padding:15px;">
			<form action="?ne=puan&cmd=print" method="post" target="_blank">
<div class="col-md-3">
				<input id="pqty" name="qty" class="form-control" type="text" placeholder="Adet" style="">
</div>
<div class="col-md-3">
				<input id="point" name="point" class="form-control" type="text" placeholder="Puan" style="">
</div>
<div class="col-md-3">
				<input id="desc" name="desc" class="form-control" type="text" placeholder="Açıklama" style="">
</div>
<div class="col-md-3">
				<button class="print btn btn-warning" type="submit" name="print" value="qr" style="">Qr</button>
</div>
<table class="table" id="tpoint"></table>
			<form>
		</div>
	</div>
</div>
</div>
	<?php }else{?>
		<?php if($MSA<>1){?>
		<body onload="window.print()">
		<?php }?>
		<div class="msa">
		<i class="fas fa-cogs noprint" onclick="toggle('.set');" style="position:fixed; right:0px; top:10px; width:25px;"></i>
		<form class="noprint set" action="?id=<?php echo $_GET["id"]?>&islem=<?php echo $_GET["islem"]?>&durum=tkaydet&print=<?php echo $_REQUEST["print"]?>" method="post" style="display:none;position:fixed; right:0px; top:30px; width:100px;">
		   <input type="text" name="t1" value="<?php if($rst["t1"]<>""){echo $rst["t1"];}else{echo "210mm";}?>" Placeholder="Genislik" title="Genislik" style="width:100px">
		   <input type="text" name="t2" value="<?php if($rst["t1"]<>""){echo $rst["t2"];}else{echo "42mm";}?>" Placeholder="B.Genislik" title="B.Genislik" style="width:100px">
		   <input type="text" name="t3" value="<?php if($rst["t1"]<>""){echo $rst["t3"];}else{echo "42mm";}?>" Placeholder="B.Yukseklik" title="B.Yukseklik" style="width:100px">
		   <input type="text" name="t4" value="<?php if($rst["t1"]<>""){echo $rst["t4"];}else{echo "auto";}?>" Placeholder="Ust Bosuk" title="Ust Bosuk" style="width:100px">
		   <input type="text" name="t5" value="<?php if($rst["t1"]<>""){echo $rst["t5"];}else{echo "auto";}?>" Placeholder="Sag Bosluk" title="Sag Bosluk" style="width:100px">
		   <input type="text" name="t6" value="<?php if($rst["t1"]<>""){echo $rst["t6"];}else{echo "auto";}?>" Placeholder="Alt Bosluk" title="Alt Bosluk" style="width:100px">
		   <input type="text" name="t7" value="<?php if($rst["t1"]<>""){echo $rst["t7"];}else{echo "auto";}?>" Placeholder="Sol Bosluk" title="Sol Bosluk" style="width:100px">
		   <input type="text" name="t8" value="<?php if($rst["t1"]<>""){echo $rst["t8"];}else{echo "140";}?>" Placeholder="Qr Ebat" title="Qr Ebat" style="width:100px">
		   <input type="submit" name="" value="Kaydet" style="display:none;">
		</form>
		</div>
		<?php
			if($rst["t8"]==""){$t8="150";}else{$t8=$rst["t8"];}
			if($_GET["ne"]=="kayit"){
				$KID0 = implode(',',$_POST["KID"]); $KIDS = explode(',',$KID0);
				$q0 = implode(',',$_POST["qty"]); $qS = explode(',',$q0);
				$y=0;foreach($qS as $q) {$y++;
					$sql=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where ne='kayit' and s13=1 and id=".$KIDS[$y-1]." order by id desc"); $rsu=mysqli_fetch_assoc($sql);
					if($_REQUEST["print"]=="qr"){
						echo "<div class=\"barcode\"><img src='".qrCode($weburl.linked("d",$rsu["id"]), $t8)."' title=\"".$rsu["t1"]."\"></div>";
					}else	if($_REQUEST["print"]=="ean" and $rsu["t5"]<>""){
						echo "<div class=\"barcode\"><img src='../barcode/line/?f=svg&s=ean-128&d=".$rsu["t5"]."' title=\"".$rsu["t1"]."\"></div>";
					}
				}
			}else{
				$KID0 = implode(',',$_POST["KID"]); $KIDS = explode(',',$KID0);
				$DSC0 = implode(',',$_POST["DSC"]); $DSCS = explode(',',$DSC0);
				for ($y = 1; $y <= $_POST["qty"]; $y++){
					echo "<div class=\"barcode\"><img src='".qrCode($module["mobile_app_url"]."/qrp/".v3e(date('YmdHis')."".$y."/".$KIDS[$y-1]."/".$DSCS[$y-1]), $t8)."' title=\"".$KIDS[$y-1]."\"></div>";
				}
			}
	?>
<?php }?>
<script>
function toggle(id){
	jQuery(id).toggle("slow", function() {
		// Animation complete.
	});
}
jQuery('#qty').keyup(function() {
	var field = jQuery(this).val();
	jQuery('.qty').val(field);
});
jQuery('#pqty').keyup(function() {
	qty = jQuery('#pqty').val();
	jQuery('#tpoint').html('');
	for(i=0;i<qty; i++){
		jQuery('#tpoint').append('<tr><td class="w5 bg-warning tac">'+(i+1)+'</td><td class="w20"><input class="KID form-control" name="KID[]" type="text" placeholder="Puan"></td><td><input class="DSC form-control" name="DSC[]" type="text" placeholder="Açıklama"></td></tr>');
	}
});
jQuery('#point').keyup(function() {
	var field = jQuery(this).val();
	jQuery('.KID').val(field);
});
jQuery('#desc').keyup(function() {
	var field = jQuery(this).val();
	jQuery('.DSC').val(field);
});
</script>
<?php
echo $footer;
if($_GET["durum"]=="tkaydet"){
	$Rs = mysqli_query($conn, "update genel set t1='".$_POST["t1"]."', t2='".$_POST["t2"]."', t3='".$_POST["t3"]."', t4='".$_POST["t4"]."', t5='".$_POST["t5"]."', t6='".$_POST["t6"]."', t7='".$_POST["t7"]."', t8='".$_POST["t8"]."' where ne='".$_REQUEST["print"]."'");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&print=".$_REQUEST["print"]."",self,500,1);
}
?>