<!--# borç(pb2) sonradan eklendi,-->
<div class="inner-wrapper">
	<section role="main" class="content-body">
		<header class="page-header">
			<h2><?php echo $sdil[165]; //Kasa Hareket?></h2>
			
			<div class="right-wrapper text-right">
				<ol class="breadcrumbs">
					<li>
						<a href=".">
							<i class="fa fa-home"></i>
						</a>
					</li>
					<li><span><?php echo $sdil[23]; //Muhasebe?></span></li>
					<li><span><?php echo $sdil[165]; //Kasa Hareket?></span></li>
				</ol>
				
				<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fa fa-chevron-left"></i></a>
			</div>
		</header>
		<?php if($_GET["durum"]=="ok"){?>
			<div class="alert alert-success">
				<?php echo $sdil[212]; //Islem Basariyla Gerçeklestirilmistir !?>
			</div>
		<?php }?>
		<div class="v3-row" id="process"></div>
		<div class="row">
			<div class="col">
				<section class="card">
					<header class="card-header">
						<div class="card-actions">
							<a class="mb-1 mt-1 mr-1 btn btn-warning mfrm" data-toggle="modal" data-target="#myModal" data-url="fonksiyon.php?islem=cdetail&drm=<?php echo $_GET["drm"]?>" data-title="<?php echo translate("Yeni Kasa İşlemi")?>" data-ref="?ne=muhasebe&islem=kasa&drm=<?php echo $_GET["drm"]?>"><i class="fa fa-plus " aria-hidden="true"></i></a>
							<?php include("modules/public/filter.php");?>
						</div>
						
						<h2 class="card-title"><?php echo $sdil[165]; //Kasa Hareket?></h2>
					</header>
					<div class="card-body w1600" style="width:100%;">
					<?php if($_GET["ts1"]=="" and $_GET["ts2"]==""){?>
							<div class="alert alert-warning">#<?php echo translate("Son 30 Gün Listeniyor.")?></div>
					<?php }?>
						<table class="table" style="">
							<thead>
								<tr class="mdn">
									<th class="w6 mw6" style="text-align:center;">ID</th>
									<th class="w25 mw25"><?php echo $t25s[0];?></th>
									<th class="w25 mw25"><?php echo $sdil[207]; //İşlem Açıklama?></th>
									<th class="dn w10 mw10"><?php echo $sdil[154]; //Ödeme Tipi?></th>
									<th class="w8 mw8"><?php echo $sdil[115]; //Tarih?></th>
									<th class="w12 mw12"><?php echo $sdil[213]; //İşlemler?></th>
									<th class="w8 mw8"><?php echo $sdil[144]; //Tutar?></th>
									<th class="w8 mw8"><?php echo $sdil[213]; //Durum?></th>
								</tr>
							</thead>
							<tbody>
								<form method="post" action="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&durum=ykasa" autocomplete="off">
									<input type="hidden" name="cs5" id="cs5" value="0">
									<tr class="addtr mdn">
										<td scope="row" class="table-check-cell">.....</td>
										<td class="mw25 p0">
											<select name="s1" data-placeholder="Seçiniz" style="" data-plugin-selecttwo="" class="form-control populate" tabindex="8">
												<option value="0"><?php echo $sdil[221]; //Lütfen Seçiniz?></option>
												<?php $sql5=mysqli_query($conn, "select * from t5 where t1 LIKE '%".$_GET["q"]."%' ".$luye." order by t1 asc"); while($rs5=mysqli_fetch_assoc($sql5)){?>
													<option value="<?php echo $rs5["id"]?>"><?php echo $rs5["t1"]?></option>
												<?php }?>
											</select>
										</td>
										<td>
										<input type="text" name="cn1" id="cn1" list="cln1" class="form-control" value="" style="width:90%" autocomplete="off" placeholder="<?php echo $sdil[207]; //İşlem Açıklama?>">
										<datalist id="cln1" style="display:none;">
											<?php $sqlt=mysqli_query($conn, "select * from t4 where (ne='sfatura' or ne='afatura' or ne='ifatura') ".$luye.""); while($tip=mysqli_fetch_assoc($sqlt)){?>
												<option value="<?php echo $tip["t1"]?> <?php echo translate("Nolu Fatura");?>" id="<?php echo $tip["id"]?>"><?php echo $tip["pb2"]?> <?php echo $kpb?></option>
											<?php }?>
											<?php $sql5=mysqli_query($conn, "select * from t5 where t1 LIKE '%".$_GET["q"]."%' ".$luye." order by t1 asc"); while($rs5=mysqli_fetch_assoc($sql5)){?>
												<option value="<?php echo $rs5["t1"]?>" id="<?php echo $rs5["id"]?>"><?php echo $rs5["t1"]?></option>
											<?php }?>
										</datalist>
										<script>
										jQuery( "#cn1" ).change(function() {
											var inputVal = jQuery(this).val();
											var id = jQuery("#cln1 option[value='"+inputVal+"']").attr("id");
											jQuery( "#cs5" ).val(id);
										});
										</script>
										</td>
										<td class="dn">
										<input type="text" list="est" name="ct11" class="form-control with-tip" title="<?php echo $sdil[168]; //Tip?> (t1)" placeholder="<?php echo $sdil[168]; //Tip?>" value="<?php echo $hcari["t11"]?>" autocomplete="off">
										<datalist id="est" style="display:none;">
											<?php $sqlt=mysqli_query($conn, "select Distinct t11 from t4 where ne='cari'"); while($tip=mysqli_fetch_assoc($sqlt)){?>
												<option value="<?php echo $tip["t11"]?>"><?php echo $tip["t11"]?></option>
											<?php }?>
										</datalist>
										</td>
										<td class="">
											<input type="date" name="ct4" class="form-control" style="text-align:right;" value="<?php echo date("Y-m-d");?>">
										</td>
										<td class="">
											<select name="t1" class="sna w33 fl mw33 mfl form-control" style=""><option value="Nakit"><?php echo $sdil[160]; //Nakit?></option><option value="Banka"><?php echo $sdil[161]; //Banka?></option><option value="Pos"><?php echo $sdil[162]; //Pos?></option><option value="Çek"><?php echo $sdil[163]; //Çek?></option><option value="Taksit"><?php echo $sdil[227]; //Taksit?></option></select>
											<select name="y" class="sna w33 fl mw33 mfl form-control" style=""><option value="Alınan" <?php if($_GET["drm"]=="gelir"){echo "selected";}?>><?php echo translate("Gelir")?></option><option value="Ödenen" <?php if($_GET["drm"]=="gider"){echo "selected";}?>><?php echo translate("Gider")?></option></select>
											<select name="ct6" class="sfa sna w10 form-control" style="float:left;">
												<option value="TRY" <?php if($kpb=="TL" or $kpb=="TRY"){?>Selected<?php }?>>&#xf195;</option>
												<option value="EUR" <?php if($kpb=="EUR"){?>Selected<?php }?>>&#xf153;</option>
												<option value="USD" <?php if($kpb=="USD"){?>Selected<?php }?>>&#xf155;</option>
												<option value="GBP" <?php if($kpb=="GBP"){?>Selected<?php }?>>&#xf154;</option>
											</select>
										</td>
										<td><input type="text" name="tutar" class="form-control" style="text-align:right;" value="0" onfocus="if(this.value == '0') { this.value = ''} "  onblur="if(this.value == '') { this.value='0'; }"></td>
										<td><button type="submit" class="btn btn-warning mbtn"><i class="fa fa-plus"></i></button></td>
									</tr>
								</tbody>
								<table>
								</form>
								<?php
								if($_GET["drm"]<>"" and $_GET["drm"]=="gelir"){$qry="and (pb3<>0 and t1 LIKE '%".$_GET["type"]."%' and n1 LIKE '%".$_GET["q"]."%')";}elseif($_GET["drm"]<>"" and $_GET["drm"]=="gider"){$qry="and (pb4<>0 and t1 LIKE '%".$_GET["type"]."%' and n1 LIKE '%".$_GET["q"]."%')";}else{$qry="and (pb3<>0 and t1 LIKE '%".$_GET["type"]."%' and n1 LIKE '%".$_GET["q"]."%') or (pb4<>0 and t1 LIKE '%".$_GET["type"]."%' and n1 LIKE '%".$_GET["q"]."%')";}
								$sql=mysqli_query($conn, "select * from t4 where ne='cari' $qry $lacc order by id desc"); while($hcari=mysqli_fetch_assoc($sql)){
									if(($_GET["ts1"]=="" and $_GET["ts2"]=="" and ($hcari["t4"] >= date('Y-m-d', strtotime(date("Y-m-d"). ' -30 days')) or $hcari["t4"]=="")) or ($_GET["ts1"]<>"" and $_GET["ts2"]<>"") and ($hcari["t4"]>=$_GET["ts1"] and $hcari["t4"]<=$_GET["ts2"])){
									$sql5=mysqli_query($conn, "select * from t5 where id=".$hcari["s1"]." order by id desc"); $rs5=mysqli_fetch_assoc($sql5);$jsi = json_decode($rs5["n17"],true);
									if($hcari["t2"]=="siparis"){
										$link="?ne=eticaret&islem=siparis&id=".$hcari["s5"]."";
									}elseif(substr($hcari["t2"],0,6)=="fatura"){
										$link="?ne=muhasebe&islem=".$hcari["t2"]."&id=".$hcari["s5"]."";
									}else{
										$link="#";
									}
									include("modules/clients/client_current_calc2.php");
								?>
									<form method="post" action="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $hcari["id"]?>&durum=dkasa">
										<input type="hidden" name="cs5" id="cs5_<?php echo $hcari["id"]?>" value="<?php echo $hcari["s5"]?>">
										<table class="table" style="">
											<tr class="<?php if($hcari["pb3"]<>"0"){echo "bg-success"; }elseif($hcari["pb4"]<>"0"){echo "bg-danger"; }?>" data-id="<?php echo $hcari["id"];?>">
												<td class="mdn w6 mw6"><?php echo i2a($hcari["id"],7);?></td>
											<?php if(mysqli_num_rows($sql5)>0) {?>
												<td class="mdn w25 mw25" style="cursor:pointer;" onclick="location.href='?islem=duye&ne=uye&id=<?php echo $rs5["id"]?>#&tab-cari'"><a><?php echo $rs5["t1"]?> <?php echo $jsi["ifirma"]?></a></td>
											<?php }else{?>
												<td class="mdn w25 mw25" style="cursor:pointer;"><a><?php echo $sdil[165]; //Kasa Hareket?></a></td>
											<?php }?>
												<td class="w25 mw25" title="<?php echo $hcari["n1"]?>">
													<input type="text" name="cn1" id="cn1_<?php echo $hcari["id"]?>" list="cln1_<?php echo $hcari["id"]?>" class="form-control fl" value="<?php echo $hcari["n1"]?>" onfocus="if(this.value == '<?php echo trim($sdil[207]); //İşlem Açıklama?>') { this.value = ''} "  onblur="if(this.value == '') { this.value='<?php echo trim($sdil[207]); //İşlem Açıklama?>'; }" style="width:90%" autocomplete="off">
													<datalist id="cln1_<?php echo $hcari["id"]?>" style="display:none;">
														<?php $sqlt=mysqli_query($conn, "select * from t4 where (ne='sfatura' or ne='afatura' or ne='ifatura') ".$luye.""); while($tip=mysqli_fetch_assoc($sqlt)){?>
															<option value="<?php echo $tip["t1"]?> <?php echo translate("Nolu Fatura");?>" id="<?php echo $tip["id"]?>"><?php echo $tip["pb2"]?> <?php echo $kpb?></option>
														<?php }?>
														<?php $sql5=mysqli_query($conn, "select * from t5 where t1 LIKE '%".$_GET["q"]."%' ".$luye." order by t1 asc"); while($rs5=mysqli_fetch_assoc($sql5)){?>
															<option value="<?php echo $rs5["t1"]?>" id="<?php echo $rs5["id"]?>"><?php echo $rs5["t1"]?></option>
														<?php }?>
													</datalist>
													<script>
														jQuery( "#cn1_<?php echo $hcari["id"]?>" ).change(function() {
															var inputVal = jQuery(this).val();
															var id = jQuery("#cln1_<?php echo $hcari["id"]?> option[value='"+inputVal+"']").attr("id");
															jQuery( "#cs5_<?php echo $hcari["id"]?>" ).val(id);
														});
													</script>
													<a href="<?php echo $link?>" class="fa fa-info-circle cp fr" data-container="body" data-toggle="popover" data-placement="top" data-content="<?php if($hcari["t5"]<>""){echo "( ".$hcari["t5"]." )"; }?>" style="margin-top: 10px;"></a>
													<script>
														jQuery( "#cn1" ).change(function() {
															var inputVal = jQuery(this).val();
															var id = jQuery("#cln1 option[value='"+inputVal+"']").attr("id");
															jQuery( "#cs5" ).val(id);
														});
													</script>
												</td>
												<td class="dn w10 mw10">
												<input type="text" list="nst" name="ct11" class="form-control with-tip" title="<?php echo $sdil[168]; //Tip?> (t11)" placeholder="<?php echo $sdil[168]; //Tip?>" value="<?php echo $hcari["t11"]?>" autocomplete="off">
												<datalist id="nst" style="display:none;">
													<?php $sqlt=mysqli_query($conn, "select Distinct t11 from t4 where ne='cari' and t1<>''"); while($tip=mysqli_fetch_assoc($sqlt)){?>
														<option value="<?php echo $tip["t11"]?>"><?php echo $tip["t11"]?></option>
													<?php }?>
												</datalist>
												</td>
												<td class="mdn w8 mw8">
													<input type="date" name="ct4" class="form-control" style="text-align:right;" value="<?php echo $hcari["t4"];?>">
												</td>
												<td class="mdn w12 mw12">
													<select name="x" class="sna w33 fl mw33 mfl form-control" style="">
														<option value="Nakit" <?php if($hcari["t1"]=="Nakit"){echo "Selected"; }?>><?php echo $sdil[160]; //Nakit?></option><option value="Banka" <?php if($hcari["t1"]=="Banka"){echo "Selected"; }?>><?php echo $sdil[161]; //Banka?></option><option  value="Pos" <?php if($hcari["t1"]=="Pos"){echo "Selected"; }?>><?php echo $sdil[162]; //Pos?></option><option value="Çek" <?php if($hcari["t1"]=="Çek"){echo "Selected"; }?>><?php echo $sdil[163]; //Çek?></option><option value="Taksit" <?php if($hcari["t1"]=="Taksit"){echo "Selected"; }?>><?php echo $sdil[227]; //Taksit?></option>
													</select>
													<select name="y" class="sna w33 fl mw33 mfl form-control" style="">
														<option value="Alınan" <?php if($hcari["pb2"]<>"0"){echo "Selected"; }?>><?php echo translate("Gelir")?></option><option value="Ödenen" <?php if($hcari["pb4"]<>"0"){echo "Selected"; }?>><?php echo translate("Gider")?></option>
													</select>
													<select name="ct6" class="sfa sna w10 form-control" style="float:left;">
														<option value="TRY" <?php if($hcari["t6"]=="TL" or $hcari["t6"]=="TRY"){?>Selected<?php }?>>&#xf195;</option>
														<option value="EUR" <?php if($hcari["t6"]=="EUR"){?>Selected<?php }?>>&#xf153;</option>
														<option value="USD" <?php if($hcari["t6"]=="USD"){?>Selected<?php }?>>&#xf155;</option>
														<option value="GBP" <?php if($hcari["t6"]=="GBP"){?>Selected<?php }?>>&#xf154;</option>
													</select>
												</td>
												<td class="w8 mw25" style="position:relative"><i class="ddn fa fa-<?php echo strtolower($hcari["t6"])?>" style="position: absolute; left: 15px; top: 12px;"></i><input type="text" name="tutar" class="form-control" style="text-align:right;" value="<?php if($hcari["pb3"]<>0){ echo wprice($hcari["pb3"]); }elseif($hcari["pb4"]<>0){ echo wprice($hcari["pb4"]); }?>"></td>
												<td class="mdn w8 mw8">
													<button type="submit" class="btn btn-warning mbtn"><i class="fa fa-refresh"></i></button>
													<?php if($_SESSION["kim"]=="Admin" or ($_SESSION["kim"]=="yonetici" and $_SESSION["y8"]==3)){?>
														<button type="button" class="btn btn-danger mbtn btn-delete-row" data-href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $hcari["id"]; ?>&durum=skasa"><i class="fas fa-times"></i></button>
													<?php }else{?>
														<button type="button" class="btn btn-default mbtn" disabled><i class="fa fa-ban"></i></button>
													<?php }?>
												</td>
											</tr>
										</table>
									</form>
								<?php }}?>
								<table class="table" style="">
									<tr style=" font-size:14px; font-weight:800;" class="">
										<td class="w26 mw26" colspan="3"  style="text-align:right; color:#ff3333;"></td>
										<td class="text-success tar"><a  href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&drm=gelir" class="v3-btn v3-btn-sm v3-btn-success mfr"><i class="fa fa-angle-double-down"></i> <?php echo wprice($cpb3)?> <?php echo $ikpb;?></a></td>
										<td class="w8 mw8 text-danger tal"><a  href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&drm=gider" class="v3-btn v3-btn-sm v3-btn-danger mfr"><i class="fa fa-angle-double-up"></i> <?php echo wprice($cpb4)?> <?php echo $ikpb;?></a></td>
										<td class="w8 mw8 text-warning tar"><a class="v3-btn v3-btn-sm v3-btn-info mfr"><i class="fa fa-balance-scale"></i> <?php echo wprice($cpb3-$cpb4)?> <?php echo $ikpb;?></a></td>
										<td class="w8 mw8" style="text-align:right; color:#ff3333;"></td>
									</tr>
								</table>
							</div>
						</section>
					</div>
				</div>
				<!-- end: page -->
			</section>
		</div>
		<aside id="sidebar-right" class="sidebar-right">
			<div class="nano">
				<div class="nano-content">
					<a href="#" class="mobile-close d-md-none">
						Collapse <i class="fa fa-chevron-right"></i>
					</a>
					<div class="sidebar-right-wrapper">
						...
					</div>
				</div>
			</div>
		</aside>
	</section>
	<?php
	if(!empty($_POST["s1"])){$cs1=$_POST["s1"];}else{$cs1=0;}
	if(!empty($_POST["s2"])){$cs2=$_POST["s2"];}else{$cs2=0;}
	if(!empty($_POST["s3"])){$cs3=$_POST["s3"];}else{$cs3=0;}
	if(!empty($_POST["s4"])){$cs4=$_POST["s4"];}else{$cs4=0;}
	if(!empty($_POST["cs5"])){$cs5=$_POST["cs5"];}else{$cs5=0;}
	if($_GET["durum"]=="ykasa"){
		if($_POST["y"]=="Alacak"){
			$kpb1=$_POST["tutar"];
			$kpb2=0; $kpb3=0; $kpb4=0;
		}elseif($_POST["y"]=="Alınan"){
			$kpb1=0; $kpb2=0;
			$kpb3=$_POST["tutar"];
			$kpb4=0;
		}elseif($_POST["y"]=="Borç"){
			$kpb2=$_POST["tutar"];
			$kpb1=0; $kpb3=0; $kpb4=0;
		}elseif($_POST["y"]=="Ödenen"){
			$kpb1=0; $kpb2=0; $kpb3=0;
			$kpb4=$_POST["tutar"];
		}
		$sql = $conn->query("insert into t4(t1,t2,t4,t11,ne,t6,pb1,pb2,pb3,pb4,ts1,n1,s1,s2,s3,s4,s5,s19) values ('".$_POST["t1"]."', 'kasa', '".$_POST["ct4"]."', '".$_POST["ct11"]."', 'cari', '".$_POST["t6"]."', '".sprice($kpb1)."', '".sprice($kpb2)."', '".sprice($kpb3)."', '".sprice($kpb4)."', now(), '".$_POST["cn1"]."', '".$cs1."', '".$cs2."', '".$cs3."', '".$cs4."', '".$cs5."','".$_SESSION["user_id"]."')");
		echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok",self,500,1);
	}elseif($_GET["durum"]=="skasa"){
		if($_POST["y"]=="Alacak"){
			$kpb1=$_POST["tutar"];
			$kpb2=0; $kpb3=0; $kpb4=0;
		}elseif($_POST["y"]=="Alınan"){
			$kpb1=0; $kpb2=0; $kpb4=0;
			$kpb3=$_POST["tutar"];
		}elseif($_POST["y"]=="Borç"){
			$kpb2=$_POST["tutar"];
			$kpb1=0; $kpb3=0; $kpb4=0;
		}elseif($_POST["y"]=="Ödenen"){
			$kpb1=0; $kpb2=0; $kpb3=0;
			$kpb4=$_POST["tutar"];
		}
		$sql = mysqli_query($conn, "delete from t4 where id=".$_GET["id"]);
		echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok",self,500,1);
	}elseif ($_GET["durum"]=="dkasa"){
		if($_POST["y"]=="Alacak"){
			$kpb1=$_POST["tutar"];
			$kpb2=0; $kpb3=0; $kpb4=0;
		}elseif($_POST["y"]=="Alınan"){
			$kpb1=0; $kpb2=0; $kpb4=0;
			$kpb3=$_POST["tutar"];
		}elseif($_POST["y"]=="Borç"){
			$kpb2=$_POST["tutar"];
			$kpb1=0; $kpb3=0; $kpb4=0;
		}elseif($_POST["y"]=="Ödenen"){
			$kpb1=0; $kpb2=0; $kpb3=0;
			$kpb4=$_POST["tutar"];
		}
		$Rs = mysqli_query($conn, "update t4 set t1='".$_POST["x"]."', t11='".$_POST["ct11"]."', n1='".$_POST["cn1"]."', t4='".$_POST["ct4"]."', t6='".$_POST["t6"]."', pb1='".sprice($kpb1)."', pb2='".sprice($kpb2)."', pb3='".sprice($kpb3)."', pb4='".sprice($kpb4)."', s2='".$cs2."', s3='".$cs3."', s4='".$cs4."', s5='".$cs5."' Where id=".$_GET["id"]."");
		echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok",self,500,1);
	}
	?>