<?php
	$path="../../";
	include("../../map.php");
	if($_GET["form"]=="true"){
?>
	<form class="col card-body" action="?" method="get" style="display: flow-root; margin-bottom: 10px;">
		<input type="hidden" name="ne" value="<?php echo $_GET["ne"]?>">
		<input type="hidden" name="islem" value="<?php echo $_GET["islem"]?>">
		<!--<input type="hidden" name="durum" value="filtre">-->
		<input type="hidden" name="show" value="<?php echo $_GET["show"]?>">
		<input type="hidden" name="sayfa" value="<?php echo $_GET["sayfa"]?>">
		<input type="hidden" name="drm" value="<?php echo $_GET["drm"]?>">
		<input type="hidden" name="grupID" value="<?php echo $_GET["grupID"]?>">
		<input type="hidden" name="s13" value="<?php echo $_GET["s13"]?>">
		<input type="hidden" name="id" value="<?php echo $_GET["id"]?>">
		<div class="v3-col-md-12 v3-col-xs-12">
			<input type="text" class="form-control" name="key"  value="<?php echo $_GET["key"]?>" placeholder="Kelime">
		</div>
		<?php if($_GET["islem"]=="request" or $_GET["islem"]=="siparisler" or $_GET["islem"]=="tahsilat" or $_GET["islem"]=="service" or $_GET["islem"]=="gorev" or $_GET["islem"]=="yorum" or $_GET["islem"]=="fatura" or $_GET["islem"]=="kasa" or $_GET["islem"]=="cek" or $_GET["islem"]=="senet"){?>
		<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
			<input type="date" class="form-control" name="ts1" id="fts1" value="<?php echo isset($_GET["ts1"]) && $_GET["ts1"] <> "" ? $_GET["ts1"] : date('Y-m-d', strtotime('-7 days')); ?>">
		</div>
		<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
			<input type="date" class="form-control" name="ts2" id="fts2" value="<?php echo isset($_GET["ts2"]) && $_GET["ts2"] <> "" ? $_GET["ts2"] : date('Y-m-d'); ?>">
		</div>
		<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
			<select id="when" class="form-control sna">
				<option ts1="">Zaman Aralığı</option>
				<option ts1="<?php echo date('Y-m-d', strtotime(date("Y-m-d"). ' -30 days'))?>"><?php echo ctranslate("Son 30 Gün")?></option>
				<option ts1="<?php echo date("Y-m-d")?>"><?php echo ctranslate("Bugün")?></option>
				<option ts1="<?php echo $haftabasi?>"><?php echo ctranslate("Bu Hafta")?></option>
				<option ts1="<?php echo $aybasi?>"><?php echo ctranslate("Bu Ay")?></option>
				<option ts1="<?php echo $yilbasi?>"><?php echo ctranslate("Bu Yıl")?></option>
				<option ts1="<?php echo date('Y-m-d', strtotime($yilbasi. ' -1 years'))?>"><?php echo date('Y', strtotime(date("Y"). ' -1 years'))?></option>
				<option ts1="<?php echo date('Y-m-d', strtotime($yilbasi. ' -2 years'))?>"><?php echo date('Y', strtotime(date("Y"). ' -2 years'))?></option>
				<option ts1="<?php echo date('Y-m-d', strtotime($yilbasi. ' -3 years'))?>"><?php echo date('Y', strtotime(date("Y"). ' -3 years'))?></option>
			</select>
		</div>
		<?php }?>
		<?php if($_GET["islem"]=="request"){?>
			<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
				<select name="fID" class="small form-control">
					<option value=""><?php echo ctranslate("Tümü")?></option>
					<?php $sqlr = mysqli_query($conn, "select distinct t1,s1 from t2 where ne='request' $luye"); while($rsr=mysqli_fetch_assoc($sqlr)){?>
							<option value="<?php echo $rsr["s1"]?>" <?php if($_GET["fID"]==$rsr["s1"]){echo "Selected";}?>><?php echo $rsr["t1"]?></option>
						<?php }?>
				</select>
			</div>
		<?php }?>
		<?php if($_GET["islem"]=="siparisler"){?>
			<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
				<select name="t5" class="small form-control">
					<option value=""><?php echo ctranslate("Ödeme")?></option>
					<option value="PayTr"><?php echo translate("+#PayTr")?></option>
					<option value="Pos"><?php echo translate("+#Pos")?></option>
					<option value="Havale"><?php echo translate("+#Havale")?></option>
				</select>
			</div>
			<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
				<select name="s4" class="small form-control">
					<option value=""><?php echo ctranslate("Durum")?></option>
					<option data-bg="alert-warning" data-status="0" value="0"><i class="fa fa-pause" aria-hidden="true"></i> <?php echo translate("+#Onay Bekliyor")?></option>
					<option data-bg="alert-success" data-status="1" value="1" <?php if($_GET["s4"]==1){echo "Selected";}?>><i class="fa fa-check" aria-hidden="true"></i> <?php echo translate("+#Onaylandı")?></option>
					<?php if($f3>1){?>
					<option data-bg="alert-info" data-status="3" value="3" <?php if($_GET["s4"]==3){echo "Selected";}?>><i class="fa fa-truck" aria-hidden="true"></i> <?php echo translate("+#Sevkiyatta")?></option>
					<?php }?>
					<option data-bg="alert-default" data-status="4" value="4" <?php if($_GET["s4"]==4){echo "Selected";}?>><i class="fa fa-check" aria-hidden="true"></i> <?php echo translate("+#Teslim Edildi")?></option>
					<option data-bg="alert-danger" data-status="2" value="2" <?php if($_GET["s4"]==2){echo "Selected";}?>><i class="fa fa-ban" aria-hidden="true"></i> <?php echo translate("+#İptal")?></option>
					<?php if($module["order_return"]>1){?>
					<option data-bg="alert-danger" data-status="5" value="5" <?php if($_GET["s4"]==5){echo "Selected";}?>><i class="fa fa-ban" aria-hidden="true"></i> <?php echo translate("+#İade")?></option>
					<?php }?>
					<?php if(translate("+#order_extra")<>""){?>
					<option data-bg="alert-default" data-status="6" value="6" <?php if($_GET["s4"]==6){echo "Selected";}?>><i class="fa fa-life-ring" aria-hidden="true"></i> <?php echo translate("#order_extra")?></option>
					<?php }?>
				</select>
			</div>
		<?php }?>
		<?php if($_GET["islem"]=="kasa"){?>
			<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
				<select name="drm" class="small form-control">
					<option value="">...</option>
					<option value="gelir"><?php echo ctranslate("Gelir")?></option>
					<option value="gider"><?php echo ctranslate("Gider")?></option>
				</select>
			</div>
		<?php }?>
		<?php if($_GET["islem"]=="nakit_akis"){?>
			<div class="v3-col-md-4 v3-col-xs-6 mmt5" style="margin-top:5px;">
				<select name="drm" class="small form-control">
					<option value="">...</option>
					<option value="alacak"><?php echo ctranslate("Alacak")?></option>
					<option value="borc"><?php echo ctranslate("Borç")?></option>
				</select>
			</div>
		<?php }?>
		<?php if($_GET["islem"]=="kayitlar"){?>
			<div class="v3-col-md-4 v3-col-xs-6" style="margin-top:5px;">
				<select size=1 name="s13" class="form-control">
					<option value=""><?php echo ctranslate("Lütfen Seçiniz")?></option>
					<option value="0" >[0] <?php echo ctranslate("#Pasif")?></option>
					<option value="1" >[1] <?php echo ctranslate("#Aktif")?></option>
					<option value="3" >[3] <?php echo ctranslate("#Tedarik Edilemiyor")?></option>
				</select>
			</div>
			<div class="v3-col-md-4 v3-col-sm-6 v3-col-xs-12" style="margin-top:5px;">
				<select name="grupID" style=""  class="form-control" id="s1">
					<option value=""><?php echo ctranslate("Tüm Gruplar")?></option>
					<?php $sqlx=mysqli_query($conn, "select * from kategoriler where ne='ukategori' order by sira asc"); while($rsx=mysqli_fetch_assoc($sqlx)){?>
						<option value="<?php echo $rsx["Cat_ID"];?>">+ <?php echo $rsx["Cat_".$_SESSION['lang'].""];?></option>
						<?php $sqly=mysqli_query($conn, "select * from kategoriler where ne='ualt_kategori' and c1='".$rsx["Cat_ID"]."' order by sira asc"); while($rsy=mysqli_fetch_assoc($sqly)){?>
							<option value="<?php echo $rsy["Cat_ID"];?>">- <?php echo $rsy["Cat_".$_SESSION['lang'].""];?></option>
						<?php }?>
					<?php }?>
				</select>
			</div>
			<div class="v3-col-md-6 v3-col-sm-6 v3-col-xs-12" style="margin-top:5px;<?php if($e5<1){echo "display:none";}?>">
				<input name="min_pb1" style="width:45%; float:left;" class="form-control" placeholder="<?php echo ctranslate("Min Fiyat")?>">
				<input name="max_pb1" style="width:45%; float:right;" class="form-control" placeholder="<?php echo ctranslate("Max Fiyat")?>">
			</div>
			<div class="v3-col-md-6 v3-col-sm-6 v3-col-xs-12" style="margin-top:5px;<?php if($f7<1){echo "display:none";}?>">
				<input name="min_s5" style="width:45%; float:left;" class="form-control" placeholder="<?php echo ctranslate("Min Stok")?>">
				<input name="max_s5" style="width:45%; float:right;" class="form-control" placeholder="<?php echo ctranslate("Max Stok")?>">
			</div>
		<?php }?>
		<?php if($_GET["islem"]=="uyeler"){?>
			<div class="v3-col-md-4 v3-col-xs-6" style="margin-top:5px;">
				<select size=1 name="s13" class="form-control">
					<option value=""><?php echo ctranslate("Lütfen Seçiniz")?></option>
					<option value="0" >[0] <?php echo ctranslate("#Pasif")?></option>
					<option value="1" >[1] <?php echo ctranslate("#Aktif")?></option>
				</select>
			</div>
		<div class="v3-col-md-4 v3-col-sm-6 v3-col-xs-12">
			<select name="grupID" style=""  class="form-control" id="s1">
				<option value=""><?php echo ctranslate("Tüm Gruplar")?></option>
				<?php $sqlx=mysqli_query($conn, "select * from kategoriler where ne='kkategori' order by sira asc"); while($rsx=mysqli_fetch_assoc($sqlx)){?>
					<option value="<?php echo $rsx["Cat_ID"];?>">+ <?php echo $rsx["Cat_".$_SESSION['lang'].""];?></option>
				<?php }?>
			</select>
		</div>
		<?php }?>
		<div class="v3-col-md-12 v3-col-xs-12 tar" style="margin-top:15px;">
			<button type="submit" class="btn btn-warning"><i class="fas fa-arrow-circle-right"></i><span class="mdn"> Filtrele</span></button>
		</div>
	</form>
<?php }?>
<?php if($_GET["form"]==""){?>
	<a class="mb-1 mt-1 mr-1 btn btn-warning filter_btn majx" data-toggle="modal" data-target="#ajaxModal" data-width="50%" data-url="modules/public/filter.php?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=<?php echo $_GET["durum"];?>&show=<?php echo $_GET["show"];?>&grupID=<?php echo $_GET["grupID"];?>&s13=<?php echo $_GET["s13"];?>&form=true" data-title="Filtre"><i class="fa fa-filter" aria-hidden="true"></i></a>
<?php }?>
<script>
jQuery('#when').on('change',function(){
	var w = jQuery("#when option:selected" ).attr("ts1");
	jQuery('#fts1').val(w);
	jQuery('#fts2').val('<?php echo date("Y-m-d")?>');
});
jQuery('#fts1').on('change',function(){
	jQuery('#fts2').val('<?php echo date("Y-m-d")?>');
});
</script>