<?php
	header('Content-Type: text/html; charset=utf-8');
	error_reporting(0);
	$path="../../";
	include("../../map.php");
	include("../../scripts.php");
	include("../../secure.php");
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $sdil[163]; //Çekler?></title>
</head>
<body>
    <div class="qmodal">
        <div class="qmodal-content">
            <!-- Left Tab Menu -->
            <div class="v8-columns">
                <!-- Content Area -->
                <div class="" ts1="<?php echo dtarih($rs["ts1"],"gg ka yy time");?>" ts2="<?php echo dtarih($rs["ts2"],"gg ka yy time");?>" ts3="<?php echo dtarih($rs["ts3"],"gg ka yy time");?>">
						<table class="table">
							<thead>
								<tr>
									<th class="w6">ID</th>
									<th class=""><?php echo $sdil[213]; //İşlem Açıklama?></th>
									<th class="w8"><?php echo $sdil[161]; //Banka?></th>
									<th class="w6"><?php echo $sdil[163]; //Çekler?> No</th>
									<th class="w6">Tip</th>
									<th class="w6"><?php echo $sdil[144]; //Tutar?></th>
									<th class="w6"><?php echo translate("Vade Tarihi");?></th>
									<th class="w12"><?php echo $t25s[0];?></th>
									<th class="w8"><?php echo $sdil[213]; //Durum?></th>
								</tr>
							</thead>
							<tbody>
								<form id="simple_form" method="post" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=ekle">						
									<tr class="addtr" style="cursor:pointer;">
										<th scope="row" class="table-check-cell">.....</th>
										<td><input type="text" name="n1" id="cn1" list="cln1" class="form-control" style="" placeholder="<?php echo $sdil[40]; //İşlem Açıklama?>" autofocus></td>
										<td><input type="text" value="" name="t2" placeholder="<?php echo trim($sdil[161]); //Banka?>" class="small form-control"></td>
										<td><input type="text" value="" name="t11" placeholder="<?php echo trim($sdil[163]); //Çekler?> No" class="small form-control"></td>
										<td>
											<select name="t3" data-placeholder="Seçiniz" class="form-control small" tabindex="8">
												<option value="alinan"><?php echo $sdil[155]; //Alacak?></option>
												<option value="verilen"><?php echo $sdil[157]; //Borç?></option>
											</select>
										</td>
										<td style="position:relative;">
											<input type="text" value="" name="pb1" placeholder="<?php echo trim($sdil[144]); //Tutar?>" class="small form-control">
											<select name="t6" id="st2_<?php echo $rsh["id"];?>" class="sna sfa" title="Birim (t2)" style="position: absolute; right: 5px; top: 15px;">
												<option value="TRY">&#xf195;</option>
												<option value="USD">&#xf155;</option>
												<option value="EUR">&#xf153;</option>
												<option value="GBP">&#xf154;</option>
											</select>
										</td>
										<td><input type="date" value="" name="t4" placeholder="<?php echo trim($sdil[163]); //Çekler?> Tarihi" id="simple-calendar" class="form-control small datepicker"></td>
										<td>
											<select name="s1" class="ajax-select"><option><?php echo $sdil[221]; //Lütfen Seçiniz?></option></select>
										</td>
										<td class="table-actions"><button type="submit" class="btn btn-warning mbtn"><i class="fa fa-plus"></i></button></td>
									</tr>
								</form>
								<?php
									$sql=mysqli_query($conn, "select * from t4 where ne='cek' and (t1 LIKE '%".$_GET["type"]."%' or n1 LIKE '%".$_GET["q"]."%') $lacc order by id desc"); while($rs=mysqli_fetch_assoc($sql)){
									if(($_GET["ts1"]=="" and $_GET["ts2"]=="") or ($_GET["ts1"]<>"" and $_GET["ts2"]<>"") and ($rs["t4"]>=$_GET["ts1"] and $rs["t4"]<=$_GET["ts2"])){
								?>
									<form id="simple_form" method="post" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&durum=duzenle&id=<?php echo $rs["id"]?>">
										<tr style="cursor:pointer;">
											<th scope="row" class="table-check-cell"><?php echo i2a($rs["id"],7);?></th>
											<td><input type="text" name="n1" id="cn1" class="form-control" value="<?php echo $rs["n1"]?>" style="" placeholder="<?php echo $sdil[40]; //İşlem Açıklama?>"></td>
											<td><input type="text" value="<?php echo $rs["t2"]?>" name="t2" placeholder="Banka" class="small form-control"></td>
											<td><input type="text" value="<?php echo $rs["t11"]?>" name="t11" placeholder="Çek No" class="small form-control"></td>
											<td>
												<select name="t3" data-placeholder="Seçiniz" class="form-control small" tabindex="8">
												<option value="alinan" <?php if($rs["t3"]=="alinan"){?>Selected<?php }?>><?php echo $sdil[155]; //Alacak?></option>
												<option value="verilen" <?php if($rs["t3"]=="verilen"){?>Selected<?php }?>><?php echo $sdil[157]; //Borç?></option>
											</select>
										</td>
										<td style="position:relative;">
											<input type="text" value="<?php echo wprice($rs["pb1"])?>" name="pb1" placeholder="<?php echo trim($sdil[144]); //Tutar?>" class="small form-control">
											<select name="t6" class="sna sfa" title="Birim (t2)" style="position: absolute; right: 5px; top: 15px;">
												<option value="TRY" <?php if($rs["t6"]=="TL" or $rsh["t2"]=="TRY"){?>Selected<?php }?>>&#xf195;</option>
												<option value="EUR" <?php if($rs["t6"]=="EUR"){?>Selected<?php }?>>&#xf153;</option>
												<option value="USD" <?php if($rs["t6"]=="USD"){?>Selected<?php }?>>&#xf155;</option>
												<option value="GBP" <?php if($rs["t6"]=="GBP"){?>Selected<?php }?>>&#xf154;</option>
											</select>
										</td>
											<td><input type="date" value="<?php echo $rs["t4"]?>" name="t4" placeholder="Vade Tarihi" id="simple-calendar" class="form-control small datepicker"></td>
											<td>
												<select name="s1" class="ajax-select"><option value="<?php echo $rs["s1"];?>"><?php echo sabit($rs["s1"],"uye","t1");?></option></select>
											</td>
											<td class="table-actions">
												<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["y6"]==3)){?>
												<button type="button" class="btn btn-danger mbtn" onclick="location.href='?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $rs["id"]; ?>&durum=sil'"><i class="fa fa-times"></i></button>
											<?php }else{?>
												<button type="button" class="btn btn-default mbtn" disabled><i class="fa fa-cancel"></i></button>
											<?php }?>
												<button type="button" class="btn btn-<?php if($rs["s13"]=="1"){?>warning<?php }else{?>success<?php }?> mbtn" onclick="if(!confirm('Bildirimi iptal etmek istediğinize eminmisiniz?')) return false; location.href='?islem=<?php echo $_GET["islem"];?>&ne=<?php echo $_GET["ne"];?>&id=<?php echo $rs["id"];?>&s13=<?php if($rs["s13"]=="1"){?>0<?php }else{?>1<?php }?>'"><i class="fa-solid fa-bell<?php if($rs["s13"]=="1"){?>-slash<?php }?>"></i></button>
											</td>
										</tr>
									</form>
								<?php }}?>
							</tbody>
						</table>
                 </div>
            </div>
</body>
<?php echo $footer?>
</html>
<?php
if($_POST["s1"]<>""){$s1=$_POST["s1"];}else{$s1=0;}
if($_GET["durum"]=="ekle"){
	$sqlc=mysqli_query($conn, "select * from t5 where id=".$_POST["s1"]." order by id desc"); $rsc=mysqli_fetch_assoc($sqlc);
	$sql = $conn->query("insert into t4 (t11, t2, t3, t4, t6, ne, n1, s1, s13, pb1, ts1, s19) values ('".$_POST["t11"]."', '".$_POST["t2"]."', '".$_POST["t3"]."', '".$_POST["t4"]."', '".$_POST["t6"]."', 'cek', '".$_POST["n1"]."', '".$s1."', '1', '".sprice($_POST["pb1"])."', now(), '".$_SESSION["user_id"]."')");
	if($_POST["t3"]=="alinan"){ $kpb1=$_POST["pb1"]; $kpb2=0; }else{ $kpb1=0; $kpb2=$_POST["pb1"]; }
	$sql = $conn->query("insert into t4(ne,t1,t2,t4,t12,t6,t11,pb1,pb2,pb3,pb4,s1,s5,n1,ts1) values ('cari', 'Çek', 'cari', '".date("Y-m-d")."', '".$_POST["t4"]."', '".$_POST["t6"]."', '".$_POST["t2"]."', '".sprice($kpb1)."', '".sprice($kpb2)."', '0', '0', '".$_POST["s1"]."', '".$conn->insert_id."', '".$_POST["n1"]."', now())");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
}elseif($_GET["durum"]=="duzenle"){
	if($_POST["t3"]=="alinan"){ $kpb1=$_POST["pb1"]; $kpb2=0; }else{ $kpb1=0; $kpb2=$_POST["pb1"]; }
	$Rs = mysqli_query($conn, "update t4 set t11='".$_POST["t11"]."', t2='".$_POST["t2"]."', t3='".$_POST["t3"]."', t4='".$_POST["t4"]."', t6='".$_POST["t6"]."', s1='".$s1."', n1='".$_POST["n1"]."', pb1='".sprice($_POST["pb1"])."', ts2=now() where id=".$_GET["id"]."");
	$Rs = mysqli_query($conn, "update t4 set pb1='".sprice($kpb1)."', pb2='".sprice($kpb2)."', t12='".$_POST["t4"]."' where s5=".$_GET["id"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
}elseif($_GET["s13"]<>""){
	$Rs = mysqli_query($conn, "update t4 set s13='".$_GET["s13"]."', ts2=now() where id=".$_GET["id"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
}elseif($_GET["durum"]=="sil"){
	$sql = mysqli_query($conn, "delete from t4 where id=".$_GET["id"]."");
	$sql = mysqli_query($conn, "delete from t4 where s5=".$_GET["id"]."");
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&durum=ok",self,500,1);
}
?>