<?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 }?>
<form method="post" action="modules/ajax/ajax_service.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&durum=yhizmet" name="aform">
	<table class="table table-no-more table-bordered table-striped mb-0">
		<thead>
			<tr>
				<th scope="col"><?php echo $sdil[167]; //Hizmet?> <?php echo $sdil[207]; //Detay?></th>
				<th class="w15"><?php echo $sdil[168]; //Tip?></th>
				<th class="w15"> <span class="column-sort"> <a href="?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&id=<?php echo $_GET["id"]?>&stn=ts1&order=asc#tab-hizmet" title="A-Z" class="sort-up"></a> <a href="?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&id=<?php echo $_GET["id"]?>&stn=ts1&order=desc#tab-hizmet" title="Z-A" class="sort-down"></a> </span> <i class="fa fa-play"></i> <?php echo $sdil[115]; //Tarih?></th>
				<th class="w15"> <span class="column-sort"> <a href="?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&id=<?php echo $_GET["id"]?>&stn=ts2&order=asc#tab-hizmet" title="A-Z" class="sort-up"></a> <a href="?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&id=<?php echo $_GET["id"]?>&stn=ts2&order=desc#tab-hizmet" title="Z-A" class="sort-down"></a> </span> <i class="fa fa-stop"></i> <?php echo $sdil[115]; //Bit.Tarih?>-2</th>
				<th class="w15"> <span class="column-sort"> <a href="?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&id=<?php echo $_GET["id"]?>&stn=pb1&order=asc#tab-hizmet" title="A-Z" class="sort-up"></a> <a href="?islem=<?php echo $_GET["islem"]?>&ne=<?php echo $_GET["ne"]?>&id=<?php echo $_GET["id"]?>&stn=pb1&order=desc#tab-hizmet" title="Z-A" class="sort-down"></a> </span> <?php echo $sdil[144]; //Tutar?></th>
				<th class="w10"><?php echo $sdil[213]; //İşlemler?></th>
			</tr>
		</thead>
		<tbody>
			<tr class="addtr" data-id="0" data-cke="0" data-action="modules/ajax/ajax_service.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&durum=yhizmet" data-url="modules/ajax/ajax_service.php" data-did="#ihizmet">
				<td>
<!--
						<div class="checkbox-custom checkbox-default" title="Email Gönder" style="position:absolute; margin-top:-17px; left:20%; cursor:pointer;"><input type="checkbox" name="s3" class="todo-check" value="1" /><label class="todo-label" for="todoListItem2"></label></div>
						<div class="checkbox-custom checkbox-default" title="Sms Gönder" style="position:absolute; margin-top:-17px; left:<?php if($mobile==""){?>22<?php }else{?>30<?php }?>%; cursor:pointer;"><input type="checkbox" class="todo-check" name="s4" value="1" /><label class="todo-label" for="todoListItem2"></label></div>
					-->
					<input type="text" name="sn1" class="form-control" title="Hizmet (n1)" placeholder="<?php echo $sdil[167] //Hizmet?>"></td>
					<td align="center"><input type="text" list="yhl" 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="yhl" style="display:none;">
							<?php $sqlt=mysqli_query($conn, "select Distinct t1 from t4 where ne='hizmet'"); while($tip=mysqli_fetch_assoc($sqlt)){?>
								<option value="<?php echo $tip["t1"]?>"><?php echo $tip["t1"]?></option>
							<?php }?>
						</datalist>
					</td>
					<td class="dfx">
						<select size="1" name="igun" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for($g=1; $g<=31; $g++){?>
								<option value="<?php echo $g;?>" <?php if(date("d")==$g){?>Selected<?php }?>><?php echo $g;?></option>
							<?php }?>
						</select>
						<select size="1" name="iay" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for($a=1; $a<=12; $a++){?>
								<option value="<?php echo $a;?>" <?php if(date("m")==$a){?>Selected<?php }?>><?php echo $a;?></option>
							<?php }?>
						</select>
						<select size="1" name="iyil" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for ($y=date("Y")-5; $y <= date("Y")+10; $y++) {?>
								<option value="<?php echo $y;?>" <?php if(date("Y")==$y){?>Selected<?php }?>><?php echo substr($y,-2);?></option>
							<?php }?>
						</select>
					</td>
					<td class="dfx">
						<select size="1" name="sgun" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for($g=1; $g<=31; $g++){?>
								<option value="<?php echo $g;?>" <?php if(date("d")==$g){?>Selected<?php }?>><?php echo $g;?></option>
							<?php }?>
						</select>
						<select size="1" name="say" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for($a=1; $a<=12; $a++){?>
								<option value="<?php echo $a;?>" <?php if(date("m")==$a){?>Selected<?php }?>><?php echo $a;?></option>
							<?php }?>
						</select>
						<select size="1" name="syil" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for ($y=date("Y")-5; $y <= date("Y")+10; $y++) {?>
								<option value="<?php echo $y;?>" <?php if(date("Y")+1==$y){?>Selected<?php }?>><?php echo substr($y,-2);?></option>
							<?php }?>
						</select>
					</td>
					<td class="dfx">
						<input type="text" name="spb1" value="0" style="width:45%; text-align:right; float:left" title="Tutar (pb1)" placeholder="Tutar" class="form-control">
						<select name="st2" class="form-control" title="Birim (t2)" style="width:45%; float:right">
							<option value="TRY" <?php if(trim($module["currency"])=="TRY"){echo "Selected";}?>>TRY</option>
							<option value="EUR" <?php if(trim($module["currency"])=="EUR"){echo "Selected";}?>>EUR</option>
							<option value="USD" <?php if(trim($module["currency"])=="USD"){echo "Selected";}?>>USD</option>
							<option value="GBP" <?php if(trim($module["currency"])=="GBP"){echo "Selected";}?>>GBP</option>
						</select>
					</td>
					<td>
						<a class="btn btn-warning btn-update-row mbtn" style="cursor:pointer; font-size:14px; padding: 0px 4px;" <?php if($_SESSION["kim"]=="yonetici"){?>Disabled<?php }?>><i class="fa fa-plus"></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='hizmet' and s1=".$_GET["id"]." order by ".$stn." ".$order.""); while($rsh=mysqli_fetch_assoc($sqlh)){
//-----------------------------------/Tarih/---
			$itarih = explode('.',$rsh["t3"]);
			$starih = explode('.',$rsh["t4"]);
//-----------------------------------/Tarih/---
			$starih = explode('.',$rsh["t4"]);
			$xtarih = strtotime("".$starih[2]."-".$starih[1]."-".$starih[0]."  00:00:00");
			$ytarih = strtotime("".date('Y')."-".date('m')."-".date('d')."  00:00:00");
			$gun=($xtarih - $ytarih) / (60*60*24);
			?>
			<form method="post" action="modules/ajax/ajax_service.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&hid=<?php echo $rsh["id"]?>&durum=ghizmet" name="aform" autocomplete="">
				<table class="table table-no-more table-bordered table-striped mb-0">					
					<tr data-id="<?php echo $rsh["id"];?>" data-cke="0" data-action="modules/ajax/ajax_service.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&hid=<?php echo $rsh["id"]?>&durum=ghizmet" data-url="modules/ajax/ajax_service.php" data-did="#ihizmet">
						<td>
<!--
							<div class="with-tip" title="Email Gönder" style="position:absolute; margin-top:-17px; left:20%; cursor:pointer; "><input type="checkbox" name="s3" value="1" <?php if($rsh["s3"]==1){?>Checked<?php }?> /></div>
							<div class="with-tip" title="Sms Gönder" style="position:absolute; margin-top:-17px; left:<?php if($mobile==""){?>22<?php }else{?>30<?php }?>%; cursor:pointer;"><input type="checkbox" name="s4" value="1" <?php if($rsh["s4"]==1){?>Checked<?php }?>/></div>
						-->
						<input type="text" name="sn1" value="<?php echo $rsh["n1"]?>" class="form-control">
					</td>
					<td class="w15">
						<input type="text" list="khl" name="st1" value="<?php echo $rsh["t1"]?>" class="form-control">
						<datalist id="khl" style="display:none;">
							<?php $sqlt=mysqli_query($conn, "select Distinct t1 from t4 where ne='hizmet'"); while($tip=mysqli_fetch_assoc($sqlt)){?>
								<option value="<?php echo $tip["t1"]?>"><?php echo $tip["t1"]?></option>
							<?php }?>
						</datalist>
					</td>
					<td class="dfx w15">
						<select size="1" name="igun" style="width:31%; padding:1px; float:left;" class="form-control with-tip" title="Gün">
							<?php for($g=1; $g<=31; $g++){?>
								<option value="<?php echo $g;?>" <?php if($itarih[0]==$g){?>Selected<?php }?>><?php echo $g;?></option>
							<?php }?>
						</select>
						<select size="1" name="iay" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for($a=1; $a<=12; $a++){?>
								<option value="<?php echo $a;?>" <?php if($itarih[1]==$a){?>Selected<?php }?>><?php echo $a;?></option>
							<?php }?>
						</select>
						<select size="1" name="iyil" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for ($y=date("Y")-5; $y <= date("Y")+10; $y++) {?>
								<option value="<?php echo $y;?>" <?php if($itarih[2]==$y){?>Selected<?php }?>><?php echo substr($y,-2);?></option>
							<?php }?>
						</select>
					</td>
					<td class="dfx w15">
						<select size="1" name="sgun" style="width:31%; padding:1px; float:left;" class="form-control with-tip" title="Gün">
							<?php for($g=1; $g<=31; $g++){?>
								<option value="<?php echo $g;?>" <?php if($starih[0]==$g){?>Selected<?php }?>><?php echo $g;?></option>
							<?php }?>
						</select>
						<select size="1" name="say" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for($a=1; $a<=12; $a++){?>
								<option value="<?php echo $a;?>" <?php if($starih[1]==$a){?>Selected<?php }?>><?php echo $a;?></option>
							<?php }?>
						</select>
						<select size="1" name="syil" style="width:31%; padding:1px; float:left;" class="form-control">
							<?php for ($y=date("Y")-5; $y <= date("Y")+10; $y++) {?>
								<option value="<?php echo $y;?>" <?php if($starih[2]==$y){?>Selected<?php }?>><?php echo substr($y,-2);?></option>
							<?php }?>
						</select>
					</td>
					<td class="dfx w15">
						<input type="text" name="spb1" value="<?php echo para($rsh["pb1"]);?>" style="width:45%; text-align:right; float:left;" title="Tutar (pb1)" class="form-control">
						<select name="st2" class="form-control" title="Birim (t2)" style="width:45%; float:right;">
							<option value="TRY" <?php if($rsh["t2"]=="TL" or $rsh["t2"]=="TRY"){?>Selected<?php }?>>TRY</option>
							<option value="EUR" <?php if($rsh["t2"]=="EUR"){?>Selected<?php }?>>EUR</option>
							<option value="USD" <?php if($rsh["t2"]=="USD"){?>Selected<?php }?>>USD</option>
							<option value="GBP" <?php if($rsh["t2"]=="GBP"){?>Selected<?php }?>>GBP</option>
						</select>
					</td>
					<td  class="w10">
						<div style="margin-top:2px;">
							<a style="cursor:pointer; font-size:14px; padding: 1px 4px;" class="btn btn-warning btn-update-row mbtn" <?php if($_SESSION["kim"]=="yonetici"){?>Disabled<?php }?>><i class="fa fa-refresh"></i><span class="ddn"> <?php echo $sdil[203]; //Güncelle?></span></a>
							<a style="margin-left:3px; cursor:pointer;font-size:14px; padding: 1px 2px;" class="btn btn-danger mbtn btn-delete-row" <?php if($_SESSION["kim"]=="yonetici"){?>Disabled<?php }?> data-href="modules/ajax/ajax_service.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&hid=<?php echo $rsh["id"]?>&durum=shizmet"><i class="fa fa-times"></i><span class="ddn"> <?php echo $sdil[204]; //Kaldır?></span></a>
							<a style="margin-left:3px; cursor:pointer;font-size:14px; padding: 1px 6px;" class="btn btn-info" title="<?php echo $sdil[207]; //Detay?>"><i class="fa fa-info-circle" aria-hidden="true"></i></a>
						</div>
					</td>
				</tr>
			</tbody>
		</table>
	</form>
<?php }?>
<?php
if ($_GET["durum"]=="yhizmet"){
	$sql = $conn->query("insert into t4(ne,t1,t2,t3,t4,pb1,n1,s1,s3,s4) values ('hizmet', '".$_POST["st1"]."', '".$_POST["st2"]."', '".$_POST["igun"].".".$_POST["iay"].".".$_POST["iyil"]."', '".$_POST["sgun"].".".$_POST["say"].".".$_POST["syil"]."', '".$_POST["spb1"]."', '".$_POST["sn1"]."', '".$_GET["id"]."', '".$_POST["s3"]."', '".$_POST["s4"]."')");
	$sqlh=mysqli_query($conn, "select * from t4 where ne='hizmet' order by id desc"); $rsh=mysqli_fetch_assoc($sqlh);
	$sql = $conn->query("insert into genel(ne,t1,t2,s1,s2,s6,s7,s8) values ('not', '".$_POST["sn1"]." (".$_POST["st1"].")', '00:00', '".$_GET["id"]."', '".$rsh["id"]."', '".$_POST["sgun"]."', '".$_POST["say"]."', '".$_POST["syil"]."')");
	if($_POST["spb1"]<>0){
		$sql = $conn->query("insert into t4(ne,t2,t4,t6,pb1,pb2,pb3,pb4,s1,s2,s3,s4,s5,n1,ts1) values ('cari', 'hizmet', '".$rsh["id"]."', '".$_POST["st2"]."', '".$_POST["spb1"]."', '0', '0', '0', '".$_GET["id"]."', '".date('d')."', '".date('m')."', '".date('Y')."', '".$rsh["id"]."', '".$_POST["sn1"]." (".$_POST["st1"].")', now())");
	}
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=hok#&tab-hizmet",self,500,1);
}elseif ($_GET["durum"]=="ghizmet"){
	$Rs = mysqli_query($conn, "update t4 set t1='".$_POST["st1"]."', t2='".$_POST["st2"]."', t3='".$_POST["igun"].".".$_POST["iay"].".".$_POST["iyil"]."', t4='".$_POST["sgun"].".".$_POST["say"].".".$_POST["syil"]."', pb1='".$_POST["spb1"]."', n1='".$_POST["sn1"]."', s3='".$_POST["s3"]."', s4='".$_POST["s4"]."' Where id=".$_GET["hid"]."");
	$sqln=mysqli_query($conn, "select * from genel where ne='not' and s2='".$_GET["hid"]."'"); $rsn=mysqli_fetch_assoc($sqln);
	if(mysqli_num_rows($sqln)==0){
		$sql = $conn->query("insert into genel(t1,t2,ne,s1,s2,s6,s7,s8) values ('".$_POST["sn1"]." (".$_POST["st1"].")', '00:00', 'not', '".$_GET["id"]."', '".$_GET["hid"]."', '".$_POST["sgun"]."', '".$_POST["say"]."', '".$_POST["syil"]."')");
	}else{
		$Rs = mysqli_query($conn, "update genel set t1='".$_POST["sn1"]." (".$_POST["st1"].")', s6='".$_POST["sgun"]."', s7='".$_POST["say"]."', s8='".$_POST["syil"]."' Where s2=".$_GET["hid"]."");		
	}
	if($_POST["spb1"]<>0){
		$sqlc=mysqli_query($conn, "select * from t4 where ne='cari' and s5='".$_GET["hid"]."'"); $cari=mysqli_fetch_assoc($sqlc);
		if(mysqli_num_rows($sqlc)==0){
			$sql = $conn->query("insert into t4(t1,t2,ne,t4,t6,pb1,pb2,pb3,pb4,s1,s2,s3,s4,s5,n1,ts1) values ('Nakit', 'hizmet', 'cari', '".$_GET["hid"]."', '".$_POST["st2"]."', '".$_POST["spb1"]."', '0', '0', '0', '".$_GET["id"]."', '".date('d')."', '".date('m')."', '".date('Y')."', '".$_GET["hid"]."', '".$_POST["sn1"]." (".$_POST["st1"].")', now())");
		}else{
			$Rs = mysqli_query($conn, "update t4 set pb1='".$_POST["spb1"]."', n1='".$_POST["sn1"]." (".$_POST["st1"].")' Where s5=".$_GET["hid"]."");
		}
	}
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=hok#&tab-hizmet",self,500,1);
}elseif ($_GET["durum"]=="shizmet"){
	$sqlc = mysqli_query($conn, "delete from t4 where s5='".$_GET["hid"]."'");
	$sqln = mysqli_query($conn, "delete from genel where s2='".$_GET["hid"]."'");
	$sqlh = mysqli_query($conn, "delete from t4 where id='".$_GET["hid"]."'" );
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=hok#&tab-hizmet",self,500,1);	
}
?>