<?php
$path="../../";
include("../../map.php");
?>
<?php if($_GET["durum"]=="hok"){?>
	<div class="alert alert-success no-margin">
		<?php echo $sdil[212]; //islem Basariyla Gerçeklestirilmistir !?>
	</div>
<?php }?>
	<div style="float:right; margin-bottom:5px;">
			<div class="fr mmr10 mr10 filter_form" style="margin-top:-5px; display:none;">
				<form id="form1"  action="?#&tab-hrs" method="get">
					<input type="hidden" name="ne" value="<?php echo $_GET["ne"]?>">
					<input type="hidden" name="islem" value="<?php echo $_GET["islem"]?>">
					<input type="hidden" name="id" value="<?php echo $_GET["id"]?>">
					<select id="hwhen" class="">
						<option ts1="<?php echo date('Y-m-d', strtotime(date("Y-m-d"). ' -30 days'))?>"><?php echo translate("Son 30 Gün")?></option>
						<option ts1="<?php echo $yilbasi?>"><?php echo translate("Bu Yıl")?></option>
						<option ts1="<?php echo $aybasi?>"><?php echo translate("Bu Ay")?></option>
						<option ts1="<?php echo $haftabasi?>"><?php echo translate("Bu Hafta")?></option>
						<option ts1="<?php echo date("Y-m-d")?>"><?php echo translate("Bugün")?></option>
					</select>
					<input type="date" name="ts1" id="fhts1" value="<?php if($_GET["ts1"]<>""){echo $_GET["ts1"];}?>">
					<input type="date" name="ts2" id="fhts2" value="<?php if($_GET["ts2"]<>""){echo $_GET["ts2"];}?>">
					<button type="submit" style="display:none;"></button>
					<button type="button" onclick="document.getElementById('form1').submit();" class="btn btn-xs btn-warning"><i class="fa fa-filter"></i></button>
				</form>
				<script>
				jQuery('#hwhen').on('change',function(){
					var w = jQuery("#hwhen option:selected" ).attr("ts1");
					jQuery('#fhts1').val(w);
					jQuery('#fhts2').val('<?php echo date("Y-m-d")?>');
				});
				jQuery('#fhts1').on('change',function(){
					jQuery('#fhts2').val('<?php echo date("Y-m-d")?>');
				});
				</script>
			</div>
			<a class="fr mmr10 mr10 btn btn-warning filter_btn"  onclick="toggle('.filter_form');toggle('.filter_btn');" style="padding: 1px 6px;"><i class="fa fa-filter cw" aria-hidden="true"></i></a>
		</div>
<form method="post" action="modules/clients/ajax_client_hrs.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&durum=yhrs" name="aform">
<table class="table table-no-more table-bordered table-striped mb-0">
	<thead>
		<tr>
			<th scope="col"> <?php echo translate('Açıklama')?></th>
			<th class="w14"><?php echo $sdil[168]; //Tip?></th>
			<th class="w10"><?php echo translate('Başlangıç')?></th>
			<th class="w10"><?php echo translate('Bitiş')?></th>
			<th class="w8"><?php echo $sdil[213]; //İşlemler?></th>
		</tr>
	</thead>
	<tbody id="nservice">
			<tr class="addtr" data-id="0" data-cke="0"  data-action="modules/clients/ajax_client_hrs.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&durum=yhrs" data-url="modules/clients/ajax_client_hrs.php" data-did="#ihrs">
				<td style="position:relative;">
					<div style="position:absolute; margin-top:-17px; right:10px; display:none;" id="bildirim0">
						<input title="Sms" type="checkbox" name="s4" style="height: 20px;width:20px;" value="1" <?php if($rsh["s4"]==1){?>Checked<?php }?> />
					</div>
					<input  onclick="toggle('#bildirim0');" type="text" name="sn1" class="form-control" title="Hizmet (n1)" placeholder="<?php echo translate('Açıklama')?>"></td>
					<td align="center">
						<input type="text" list="nsl" name="st1" class="form-control with-tip" title="<?php echo $sdil[168]; //Tip?> (t1)" placeholder="<?php echo $sdil[168]; //Tip?>" value="<?php echo $tipx["t1"]?>">
						<datalist id="nsl" style="">
							<?php $sqlt=mysqli_query($conn, "select Distinct t1 from t4 where ne='hrs'"); while($tip=mysqli_fetch_assoc($sqlt)){?>
								<option value="<?php echo $tip["t1"]?>"><?php echo $tip["t1"]?></option>
							<?php }?>
						</datalist>
					</td>
					<td class="dfx">
						<input type="date" name="ts1" class="form-control" value="<?php echo date("Y-m-d")?>" id="add_ts1">
					</td>
					<td class="dfx">
						<input type="date" name="ts2" class="form-control" value="<?php echo date("Y-m-d")?>" id="add_ts2">
					</td>
					<td>
						<a class="btn btn-warning btn-update-row mbtn" style="cursor:pointer; line-height:0px; padding:5px; " <?php if($_SESSION["kim"]=="yonetici"){?>Disabled<?php }?>><i class="fa fa-plus cw"></i><span class="ddn"> <?php echo $sdil[201]; //ekle?></span></a>
					</td>
				</tr>
		</table>
</form>
		<?php
		if ($_GET["stn"]<>"" and $_GET["order"]<>""){
			$stn=$_GET["stn"];
			$order=$_GET["order"];
		}else{
			$stn="ts2";
			$order="asc";
		}
		$sqlh=mysqli_query($conn, "select * from t4 where ne='hrs' and s1=".$_GET["id"]." order by ".$stn." ".$order.""); while($rsh=mysqli_fetch_assoc($sqlh)){
		if(($_GET["ts1"]=="" and $_GET["ts2"]=="") or ($_GET["ts1"]<>"" and $_GET["ts2"]<>"") and ($rsh["t4"]>=$_GET["ts1"] and $rsh["t4"]<=$_GET["ts2"])){
//-----------------------------------/Tarih Düzenle/---
			$itarih = explode('.',$rsh["t3"]);
			$starih = explode('.',$rsh["t4"]);
if(count($itarih)<>"1" or count($starih)<>"1"){
			$fd1="".$itarih[2]."-".i2a($itarih[1],2)."-".i2a($itarih[0],2).""; $fd2="".$starih[2]."-".i2a($starih[1],2)."-".i2a($starih[0],2)."";
			$Rs = mysqli_query($conn, "update t4 set t3='".$fd1."', t4='".$fd2."', t11='', t12='' Where id=".$rsh["id"]."");
}else{
			$fd1="".$rsh["t3"].""; $fd2="".$rsh["t4"]."";
}
//-----------------------------------/Tarih/---
			?>
			<form method="post" action="modules/clients/ajax_client_hrs.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&hid=<?php echo $rsh["id"]?>&durum=ghrs" name="aform" autocomplete="" id="eservice">
				<table class="table table-no-more table-bordered table-striped mb-0">
					<tr data-id="<?php echo $rsh["id"];?>" data-cke="0" data-href="modules/clients/ajax_client_hrs.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&hid=<?php echo $rsh["id"]?>" data-action="modules/clients/ajax_client_hrs.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&hid=<?php echo $rsh["id"]?>&durum=ghrs" data-url="modules/clients/ajax_client_hrs.php" data-did="#ihrs">
						<td style="position:relative;">
							<div style="position:absolute; margin-top:-17px; right:10px; display:none;" id="bildirim<?php echo $rsh["id"];?>">
								<input title="Sms" type="checkbox" name="s4" style="height: 20px;width:20px;" value="1" <?php if($rsh["s4"]==1){?>Checked<?php }?> />
							</div>
							<input onclick="toggle('#bildirim<?php echo $rsh["id"];?>')" type="text" name="sn1" value="<?php echo $rsh["n1"]?>" class="form-control">
						</td>
						<td class="w14">
							<input type="text" list="esl" name="st1" value="<?php echo $rsh["t1"]?>" class="form-control">
							<datalist id="esl" style="display:none;">
								<?php $sqlt=mysqli_query($conn, "select Distinct t1 from t4 where ne='hrs'"); while($tip=mysqli_fetch_assoc($sqlt)){?>
									<option value="<?php echo $tip["t1"]?>"><?php echo $tip["t1"]?></option>
								<?php }?>
							</datalist>
						</td>
						<td class="dfx w10">
						<input type="date" name="ts1" class="form-control" value="<?php echo $fd1?>" id="edit_ts1">
						</td>
					<td  class="dfx w10">
						<input type="date" name="ts2" class="form-control" value="<?php echo $fd2?>" id="edit_ts2">
					</td>
						<td  class="w8">
							<div style="margin-top:2px;">
								<a style="cursor:pointer;  line-height:0px; padding:5px; " class="btn btn-warning btn-update-row mbtn" <?php if($_SESSION["kim"]=="yonetici"){?>Disabled<?php }?>><i class="fa fa-refresh cw"></i><span class="ddn"> <?php echo $sdil[203]; //Güncelle?></span></a>
								<a style="cursor:pointer; line-height:0px; padding:5px; " class="btn btn-danger mbtn btn-delete-row" <?php if($_SESSION["kim"]=="yonetici"){?>Disabled<?php }?> data-href="modules/clients/ajax_client_hrs.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&hid=<?php echo $rsh["id"]?>&durum=shrs"><i class="fa fa-times cw" style=" padding:0px; "></i><span class="ddn"> <?php echo $sdil[204]; //Kaldır?></span></a>
								<a style="cursor:pointer; line-height:0px; padding:5px; " class="btn btn-info" title="<?php echo $sdil[207]; //Detay?>"><i class="fa fa-info-circle cw"  aria-hidden="true"></i></a>
							</div>
						</td>
					</tr>
				</tbody>
			</table>
		</form>
	<?php }}?>
<?php
	if ($_GET["durum"]=="yhrs"){
		$ln2="".$_POST["sn1"]." [".$_POST["st1"]."]<br>".$igun.".".$iay.".".$iyil." / ".$sgun.".".$say.".".$syil."<br>Tutar : ".$_POST["spb1"]."";
		$sql = $conn->query("insert into t4(ne,t1,t2,t3,t4,pb1,n1,s1,s3,s4) values ('hrs', '".$_POST["st1"]."', '".$_POST["st2"]."', '".$_POST["ts1"]."', '".$_POST["ts2"]."', '".$_POST["spb1"]."', '".$_POST["sn1"]."', '".$_GET["id"]."', '".$_POST["s3"]."', '".$_POST["s4"]."')");
	}elseif ($_GET["durum"]=="ghrs"){
		$ln2="".$_POST["sn1"]." [".$_POST["st1"]."]<br>".$igun.".".$iay.".".$iyil." / ".$sgun.".".$say.".".$syil."<br>Tutar : ".$_POST["spb1"]."";
		$Rs = mysqli_query($conn, "update t4 set t1='".$_POST["st1"]."', t2='".$_POST["st2"]."', t3='".$_POST["ts1"]."', t4='".$_POST["ts2"]."', pb1='".$_POST["spb1"]."', n1='".$_POST["sn1"]."', s3='".$_POST["s3"]."', s4='".$_POST["s4"]."' Where id=".$_GET["hid"]."");
	}elseif ($_GET["durum"]=="shrs"){
		$dsql=mysqli_query($conn, "select * from t4 where id='".$_GET["hid"]."'"); $drs=mysqli_fetch_assoc($dsql); $lt1="#".$_GET["id"]." > #".$_GET["hid"]." > ".$drs["n1"]."";
		$ln2="".$drs["n1"]." [".$drs["t1"]."]<br>".$drs["t3"]." / ".$drs["t4"]."<br>Tutar : ".$drs["pb1"]."";
		$sqlh = mysqli_query($conn, "delete from t4 where id='".$_GET["hid"]."'" );
	}
	?>
	<?php include("../public/log.php");?>