<?php
	header('Content-Type: text/html; charset=utf-8');
	error_reporting(0);
	$path="../../";
	include("../../map.php");
	include("../../scripts.php");
	include("../../secure.php");
	//findDirectoryPath("deppo")
//-------------------/Fatura Düzenle/-------
if($_GET["id"]<>""){
	$sqlf=mysqli_query($conn, "select * from t4 where id=".$_GET["id"].""); $rsf=mysqli_fetch_assoc($sqlf); $jsi = json_decode($rsf["n17"], true); $jsm = json_decode($rsf["m1"], true);
	$ftarih=$rsf["t9"]; $fno=$rsf["t1"]; $t4=$rsf["t4"];
	$sqlm=mysqli_query($conn, "select * from t5 where id=".$rsf["s1"].""); $rs5=mysqli_fetch_assoc($sqlm);
	$fcariID=$rsf["s1"]; $fcariName=$rs5["t1"]; $fcariEmail=v3d($rs5["t2"]);
	include("accounting_calc.php");
}

$sqls=mysqli_query($conn, "select * from genel where ne='sablon' and t2='invoice'"); $rss=mysqli_fetch_assoc($sqls);
	if(mysqli_num_rows($sqls)>0){ $pinvoice="print_sinvoice"; }else{ $pinvoice="print_iinvoice"; }
//-------------------/Fatura Düzenle/-------
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo $rs["t1"];?></title>
</head>
<body>
    <div class="qmodal">
        <div class="qmodal-content">
            <!-- Header with Action Buttons -->
            <div class="qmodal-header">
				<div class="header-title">
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="?"><i class="fa fa-home"></i></a></li>
                            <li class="breadcrumb-item"><a href="#"><?php echo $sdil[23]; //Muhasebe?></a></li>
                            <li class="breadcrumb-item"><a href="#"><?php echo $sdil[24]; //Faturalar?></a></li>
                            <li class="breadcrumb-item active" aria-current="page"><?php if($_GET["islem"]=="afatura"){?><?php echo $sdil[149]; //Faturalar?> <?php echo $sdil[24]; //Faturalar?><?php }elseif($_GET["islem"]=="sfatura"){?><?php echo $sdil[148]; //Faturalar?> <?php echo $sdil[24]; //Faturalar?><?php }elseif($_GET["islem"]=="ifatura"){?><?php echo $sdil[139]; //Faturalar?> <?php echo $sdil[24]; //Faturalar?><?php }?></li>
                        </ol>
                    </nav>
                </div>
                <button type="button" class="btn btn-warning" onclick="<?php if($_GET["id"]<>""){?>AjaxKaydet('','');<?php }else{?>jQuery('#asave').submit();<?php }?>"><i class="fas fa-save"></i> Kaydet</button>
				<button tabindex="-1" data-toggle="dropdown" class="btn btn-warning" style="margin-left: 2px;" type="button" aria-expanded="false">
					<span class="mdn"><?php echo $sdil[24]; //Faturalar?></span> <i class="fa fa-plus"></i>
				</button>
				<div class="dropdown-menu" role="menu">
					<a class="btn btn-warning dropdown-item text-1 mt2 " href="?ne=<?php echo $_GET["ne"]?>&islem=sfatura"><i class="fa fa-plus "></i> <?php echo $sdil[148]; //Alış?> <?php echo $sdil[24]; //Faturalar?></a>
					<a class="btn btn-success dropdown-item text-1 mt2 " href="?ne=<?php echo $_GET["ne"]?>&islem=afatura"><i class="fa fa-plus "></i> <?php echo $sdil[149]; //satış?> <?php echo $sdil[24]; //Faturalar?></a>
					<a class="btn btn-danger dropdown-item text-1 mt2 " href="?ne=<?php echo $_GET["ne"]?>&islem=ifatura"><i class="fa fa-plus "></i> <?php echo $sdil[139]; //İptal?> <?php echo $sdil[24]; //Faturalar?></a>
				</div>
				<?php //include("modules/public/filter.php");?>
				<?php if($_GET["id"]<>"" and $_GET["islem"]=="sfatura"){?><button  type="button" class="btn btn-default printbtn" onclick="window.open('../print/<?=$pinvoice?>.php?id=<?php echo $_GET["id"]?>&islem=<?php echo $_GET["islem"]?>')"><i class="fa fa-print"></i></button><?php }?>
				<?php if($_GET["id"]<>"" and $_GET["islem"]=="sfatura"){?><button  type="button" class="btn btn-xs btn-default" onclick="location.href='?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>&s1=<?php echo $rsf["s1"]?>&durum=pdf'"><i class="fa fa-share-alt"></i></button><?php }?>
				<?php if(substr($rsf["t1"],0,3)=="VBT"){?>
					<button  type="button" class="btn btn-success" title="" onclick="alert('Bu İşlem Gib e Gönderilmiştir, Fatura Numarası : <?php echo $rsf["t1"]?>')">E-Fatura</button>
				<?php }else{?>
					<?php if($_GET["id"]<>"" and $_GET["islem"]=="sfatura"){?><button  type="button" class="btn btn-warning mfrm" data-toggle="modal" data-title="E-Fatura {GiB}" data-target="#myModal" data-url="../accounting/accounting_invoice_send.php?ne=fatura&type=efatura&id=<?php echo $_GET["id"]?>">E-Fatura</button><?php }?>
				<?php }?>
            </div>
					<form class="form" id="asave" name="rall" method="post" action="?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"];?><?php if($_GET["id"]<>""){?>&durum=kaydet&id=<?php echo $_GET["id"]?><?php }else{?>&durum=yfatura<?php }?>">
					<div class="alert alert-warning" id="sts_bar" style="display:none;">
						<i class="fa fa-exclamation-triangle text-danger" aria-hidden="true"></i> <span id="sts_txt"></span>
					</div>
            <!-- Left Tab Menu -->
            <div class="v8-columns">
							<div class="v8-col200pxL-left">
								<ul class="v8-side-tabs v8-js-tabs v8-same-height">
									<li><a href="#tab-detay"><i class="fa fa-bookmark"></i><span> <?php echo $sdil[207]; //Detay?></span></a></li>
									<?php if($rsf["t2"]=="Taksit"){?>
										<li><a href="?ne=muhasebe&islem=senet&id=<?php echo $rsf["id"]?>&uid=<?php echo $rsf["s1"]?>" target="_blank"><i class="fa fa-list-ul" aria-hidden="true"></i><span> <?php echo $sdil[227]; //Taksit?></span></a></li>
									<?php }?>
									<li class="ddn"><a href="#" onclick="show('switchs');window.scrollTo(0, 0);"><i class="fa fa-chevron-right" aria-hidden="true"></i></a></li>
								</ul>
								<div id="switchs">
									<div class="v3-alert v3-alert-warning ddn">
										<i class="fas fa-arrow-right" onclick="hide('switchs')"></i>
									</div>
									<fieldset class="side-by-side">
										<legend><?php echo translate("Durum")?> <span style="font-size:8px; color:#ccc;">(t4)</span></legend>
										<select name="t4" data-placeholder="Seçiniz" style="" class="form-control" tabindex="8">
											<option value="fatura" <?php if ($rsf["t4"]=="fatura"){?>Selected<?php }?>><?php echo translate("Fatura")?></option>
											<option value="praforma" <?php if ($rsf["t4"]=="praforma"){?>Selected<?php }?>><?php echo translate("Praforma")?></option>
										</select>
									</fieldset>
									<fieldset class="side-by-side msa">
										<legend><?php echo translate("İşlem Sorumlusu")?> <span style="font-size:8px; color:#ccc;">(s19)</span></legend>
										<select name="s19" data-placeholder="Seçiniz" style="" class="form-control chosen-select" data-plugin-selecttwo="" tabindex="8">
											<option value="0">Admin</option>
											<?php $sql=mysqli_query($conn, "select * from t5 where (s9=1 or s1=1) $luye"); while($rsm=mysqli_fetch_assoc($sql)){?>
												<option value="<?php echo $rsm["id"];?>" title="<?php echo $rsm["t1"];?>" alt="<?php echo $rsm["t1"];?>" style="color:#6699FF" <?php if (($rsf["s19"]=="" and $rsm["id"]==$_SESSION["user_id"]) or ($rsm["id"]==$rsf["s19"])) {?>Selected<?php }?>><?php echo $rsm["t1"];?></option>
											<?php }?>
										</select>
									</fieldset>
									<!--
										<fieldset class="side-by-side">
											<legend>Praforma <span style="font-size:8px; color:#ccc;">(t7)</span></legend>
											<input type="text" value="<?php echo $rsf["t7"]?>" name="t7">
										</fieldset>
									-->
								</div>
							</div>
							<div class="v8-col200pxL-right" ts1="<?php echo dtarih($rsf["ts1"],"gg.ka.yy time");?>" ts2="<?php echo dtarih($rsf["ts2"],"gg.ka.yy time");?>" ts3="<?php echo dtarih($rsf["ts3"],"gg.ka.yy time");?>">
								<div id="tab-detay" class="v8-tabs-content" style="display: flow-root;">
									<div class="v3-row">
										<div class="v3-col-md-<?php if($_GET["id"]<>""){?>8<?php }else{?>12<?php }?>" style="padding:0px; ">
											<fieldset class="v3-col-md-<?php if($_GET["id"]<>""){?>6<?php }else{?>12<?php }?>">
												<legend><?php echo $sdil[24]; //Fatura No:?> Açıklama <span style="font-size:8px; color:#ccc;">(n2)</span></legend>
												<input type="text" name="n2" class="form-control"  value="<?php echo $rsf["n2"];?>" placeholder="<?php echo $sdil[24]; //Fatura No:?> Açıklama">
											</fieldset>
											<fieldset class="v3-col-md-6">
												<legend><b><?php echo $t25; //Cari?> </b> <span style="font-size:8px; color:#ccc;">(s1)</span></legend>
												<?php if($fcariID<>""){?>
													<div style="position:absolute;right: 0px; top: -20px;">
														<i class="cp btn btn-info fa fa-eye fr p8 mp8 " onclick="window.open('?islem=duye&ne=uye&id=<?php echo $fcariID;?>&s2=&key=&sayfa=')"></i>
														<i class="cp btn btn-info fa fa-whatsapp fr p8 mp8 mr5 " onclick="window.open('https://api.whatsapp.com/send?phone=90<?php echo telefon($fcariGsm)?>')"></i>
													</div>
												<?php }?>
												<select name="s1" data-placeholder="Seçiniz" class="form-control chosen-select" data-plugin-selecttwo="" tabindex="8" id="chooseClient">
													<option value="0">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"];?>" title="<?php echo $rs5["m1"];?>" style="color:#6699FF" <?php if($rs5["id"]==$fcariID){?>Selected<?php }?>><?php echo $rs5["t1"];?></option>
													<?php }?>
												</select>
												<?php if($fcariID==""){?>
													<a class="cp btn btn-warning fa fa-plus fr p5 mp5" style="position:absolute;right: 0px; top: -25px; z-index: 99;" onclick="toggle('#addClient');toggle('#chooseClient')"></a>
													<div id="addClient" style="display:none;position: absolute; margin-top: -30px; background: white; width: 98%;">
														<div class="row">
															<div class="col-md-4">
																<input type="text" name="ut1" class="form-control"  value="" placeholder="Ad Soyad">
															</div>
															<div class="col-md-4">
																<input type="text" name="ut2" class="form-control"  value="" placeholder="Email">
															</div>
															<div class="col-md-4">
																<input type="text" name="ut4" class="form-control"  value="" placeholder="Gsm" data-plugin-masked-input="" data-input-mask="<?php echo $module["pmask"];?>">
															</div>
														</div>
													</div>
												<?php }?>
											</fieldset>
											<fieldset class="v3-col-md-<?php if($_GET["id"]<>""){?>6<?php }else{?>3<?php }?>">
												<legend><?php echo $sdil[115]; //Tarih/Saat?> <span style="font-size:8px; color:#ccc;">(t9)</span></legend>
												<input type="date" name="ts1" id="simple-calendar" class="form-control datepicker" value="<?php if($rsf["t9"]==""){ echo date('Y-m-d'); }else{ echo $rsf["t9"]; }?>" placeholder="<?php echo $sdil[115]; //Tarih/Saat?>">
											</fieldset>
											<fieldset class="v3-col-md-<?php if($_GET["id"]<>""){?>6<?php }else{?>3<?php }?>">
												<div style="position:absolute;right: 0px; top: -20px;">
													<a class="btn btn-warning btn-xs cp " onclick="setval('#ts6','<?php echo date("Y-m-d");?>')">Yok</a>
													<a class="btn btn-warning btn-xs cp " onclick="setval('#ts6','<?php echo date("Y-m-d",strtotime("+1 month"));?>')">30</a>
													<a class="btn btn-warning btn-xs cp " onclick="setval('#ts6','<?php echo date("Y-m-d",strtotime("+2 month"));?>')">60</a>
													<a class="btn btn-warning btn-xs cp " onclick="setval('#ts6','<?php echo date("Y-m-d",strtotime("+3 month"));?>')">90</a>
													<a class="btn btn-warning btn-xs cp " onclick="setval('#ts6','<?php echo date("Y-m-d",strtotime("+4 month"));?>')">120</a>
												</div>
												<legend><?php echo translate("Vade Tarihi")?> <span style="font-size:8px; color:#ccc;">(t6)</span></legend>
												<input type="date" name="t6" id="ts6" class="form-control datepicker" value="<?php echo $rsf["t6"];?>" placeholder="<?php echo $sdil[115]; //Tarih/Saat?>">
											</fieldset>
											<fieldset class="v3-col-md-6">
												<legend>Kurlar <span style="font-size:8px; color:#ccc;">(t3)</span></legend>
												<?php $rarr =  array ('usd' => $usd, 'eur' => $eur, 'gpb' => $gbp); $rate=json_encode($rarr);?>
												<input type="text" name="t3" class="form-control" style="width:100%;" value='<?php if($rsf["t3"]<>""){echo $rsf["t3"];}else{echo $rate;}?>' placeholder="Kur">
											</fieldset>
											<fieldset class="v3-col-md-6">
												<legend><?php echo $sdil[24]; //Fatura No:?> No <span style="font-size:8px; color:#ccc;">(t1)</span></legend>
												<input type="text" name="t1" class="form-control"  value='<?php if($fno<>""){echo $fno;}else{echo date(YmdHis);}?>' placeholder="<?php echo $sdil[24]; //Fatura No:?> No">
											</fieldset>
										</div>
										<?php if($_GET["id"]<>""){?>
											<fieldset class="v3-col-md-4" style="height:327px !important;padding-top: 6px;">
												<legend><?php echo $sdil[176]; //Toplam?></legend>
												<script type="text/JavaScript" language="JavaScript">
													jQuery(document).ready(function () {
														loadFunction('../accounting/accounting_calc.php?show_total=yes&id=<?php echo $_GET["id"]?>','#show_total', ''); });
													document.write("<div id=\"show_total\"></div>");
												</script>
											</fieldset>
											<fieldset id="PMethod" class="dn">
												<img src="assets/img/loading.gif">
											</fieldset>
										<?php }?>
										<script type='text/javascript'>
/*
									jQuery(function() {
										jQuery("#ptype").change(function(){
											var ptype = jQuery(this).val();
											//show("PMethod");
											//jQuery("#PMethod").load('../services/payment-type.php?type=' + ptype + '');
										});									
										jQuery("#total").keyup(function(){
											var old_total = $(this).attr("total");
											var new_total = $(this).val();
											var number0 = Number(old_total.replace(/[^0-9.-]+/g,""));
											var number1 = Number(new_total.replace(/[^0-9.-]+/g,""));
											var stotal = number0-number1;
											var gtotal = stotal/<?php echo ($s12+100)/100?>;	
											$("#discount").val(gtotal.toFixed(2));
										});
										jQuery("#discount").keyup(function(){
											var old_total = $(this).attr("total");
											var discount = $(this).val();
											var number0 = Number(old_total.replace(/[^0-9.-]+/g,""));
											var number1 = Number(discount.replace(/[^0-9.-]+/g,""));
											var stotal = number0-number1;
											var gtotal = stotal*<?php echo ($s12+100)/100?>;	
											$("#total").val(gtotal.toFixed(2));
										});
									});
									*/
										</script>
										<div style="clear:both;"></div>
										<fieldset class="collapsed" style="min-height:auto !important;">
											<legend style="width:100px;" class="cp"><a style="float: left;"><?php echo $sdil[207]; //Detay?></a> <span style="font-size:8px; color:#ccc; float:right">(n1)</span></legend>
											<textarea name="n1" class="rte" id="rte" style="width:100%; height:auto;" placeholder="<?php echo $t36s[0]?> Detay"><?php echo $rsf["n1"]?></textarea>
										</fieldset>
									</form>
									<?php if($_GET["id"]<>""){?>
										<script type="text/JavaScript" language="JavaScript">
											jQuery(document).ready(function () {
												loadFunction('../public/products.php?ne=<?php echo $_GET["ne"]?>&islem=<?php echo $_GET["islem"]?>&id=<?php echo $_GET["id"]?>','#products'); });
											document.write("<div id=\"products\" style=\"overflow:auto;\"></div>");
										</script>
									<?php }?>
								</div>
							</div>
						</div>
                 </div>
            </div>
</body>
<?php echo $footer?>
</html>
<?php 
if($_GET["durum"]=="yfatura"){
	if($_POST["s1"]=="0"){
		$sql5k=mysqli_query($conn, "select * from t5 where t4='".$_POST["ut4"]."'"); $rs5k=mysqli_fetch_assoc($sql5k);
		if(mysqli_num_rows($sql5k)==0 and $_POST["ut4"]<>""){
			$sqli5 = $conn->query("insert into t5(t1, t2, ne, s1, s4, s5, s19, t3, t4, t9, ts1) values ('".$_POST["ut1"]."', '".base64_encode($_POST["ut2"])."', 'uye', '0', '1', '0', '".$_SESSION["user_id"]."', '".base64_encode(generatePassword(8))."', '".$_POST["ut4"]."', '".$_POST["ts1"]."', now())");	
			$sql5=mysqli_query($conn, "select * from t5 order by id desc"); $rs5=mysqli_fetch_assoc($sql5);
		}else{
			$sql5=mysqli_query($conn, "select * from t5 where t4='".$_POST["ut4"]."'"); $rs5=mysqli_fetch_assoc($sql5);
		}
	}else{
		$sql5=mysqli_query($conn, "select * from t5 where id='".$_POST["s1"]."'"); $rs5=mysqli_fetch_assoc($sql5);
	}
	if($_POST["t1"]==""){echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&hata4",self,500,1);}
	$sqlk = mysqli_query($conn, "select * from t4 where ne='".$_GET["islem"]."' and s1=".$rs5["id"]." and t1=".$_POST["t1"]." order by id desc"); $rsk=mysqli_fetch_assoc($sqlk);
	$ts1 = explode('-',$_POST["ts1"]);
	if(mysqli_num_rows($sqlk)>0){
		echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$rsk["id"]."",self,500,1);
	}else{
		$sql = $conn->query("insert into t4(t1,t3,t4,t8,t9,ne,ts1,s1,s2,s3,s4,s19,pb1,pb2,pb3,pb4) values ('".$_POST["t1"]."', '".$_POST["t3"]."', '".$_POST["t4"]."', '".$_POST["t8"]."', '".$_POST["t9"]."', '".$_GET["islem"]."', now(), '".$rs5["id"]."', '".$ts1[2]."', '".$ts1[1]."', '".$ts1[0]."', '".$_SESSION["user_id"]."', '0', '0', '0', '0')");
		$sql = mysqli_query($conn, "select * from t4 where ne='".$_GET["islem"]."' order by id desc"); $rs=mysqli_fetch_assoc($sql);
		echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$rs["id"]."&durum=ok",self,500,1);
	}
}elseif($_GET["durum"]=="kaydet"){
	$ts1 = explode('-',$_POST["ts1"]);
	$Rs = mysqli_query($conn, "update t4 set t1='".$_POST["t1"]."', t2='".$_POST["t2"]."', t3='".$_POST["t3"]."', t4='".$_POST["t4"]."', t5='".$_POST["t5"]."', t6='".$_POST["t6"]."', t7='".sprice($_POST["tahsilat"])."', t8='".$_POST["t8"]."', t9='".$_POST["t9"]."', n1='".addslashes(stripslashes($_POST["n1"]))."', n2='".addslashes(stripslashes($_POST["n2"]))."', t9='".$_POST["ts1"]."', pb1='".sprice($_POST["subtotal"])."', pb2='".sprice($_POST["total"])."', pb3='".sprice($_POST["tax"])."', pb4='".sprice($_POST["discount"])."', s1='".$_POST["s1"]."', s2='".$ts1[2]."', s3='".$ts1[1]."', s4='".$ts1[0]."', s19='".$_POST["s19"]."', ts2=now() where id=".$_GET["id"]."");
	//echo '<body onload="window.opener.location.reload();">';
//------------/Cari Kontrol ve Güncelle/---
	$sqlf = mysqli_query($conn, "select * from t4 where id='".$_GET["id"]."' order by id desc"); $rsf=mysqli_fetch_assoc($sqlf);
	if($rsf["pb2"]<>0){ //Tutar Boş Değilse
		if($rsf["ne"]=="sfatura"){
			$pb1=$rsf["pb2"];
			$pb2=0;
			if($rsf["t7"]<>0){
				$pb3=$rsf["t7"];
			}else{
				$pb3=0;
			}
			$pb4=0;
		}elseif($rsf["ne"]=="afatura" or $rsf["ne"]=="ifatura"){
			$pb1=0;
			$pb2=$rsf["pb2"];
			$pb3=0;
			$pb4=0;
		}
//------------/Cari Kaydet/---
		$sqlc = mysqli_query($conn, "select * from t4 where ne='cari' and s1=".$_POST["s1"]." and s5=".$_GET["id"]." and pb1>0 order by id asc"); $rsc=mysqli_fetch_assoc($sqlc);
		if(mysqli_num_rows($sqlc)==0){
			$sql = $conn->query("insert into t4(t1,t2,ne,t4,t5,t6,pb1,pb2,pb3,pb4,s1,s2,s3,s4,s5,n1,ts1) values ('".$rsf["t2"]."', '".$_GET["islem"]."', 'cari', '".$_POST["ts1"]."', '".$rsf["t1"]."', '".$kpb."', '".sprice($pb1)."', '".sprice($pb2)."', '".sprice($pb3)."', '".sprice($pb4)."', '".$rsf["s1"]."', '".$rsf["s2"]."', '".$rsf["s3"]."', '".$rsf["s4"]."', '".$_GET["id"]."', '".$rsf["t1"]." ".translate("Nolu Fatura")."', now())");	
		}else{
			$Rs = mysqli_query($conn, "update t4 set t1='".$rsf["t2"]."', t2='".$_GET["islem"]."', ne='cari', t5='".$rsf["t4"]."', t6='".$kpb."', pb1='".sprice($pb1)."', pb2='".sprice($pb2)."', pb3='".sprice($pb3)."', pb4='".sprice($pb4)."', s1='".$rsf["s1"]."', s2='".$rsf["s2"]."', s3='".$rsf["s3"]."', s4='".$rsf["s4"]."', n1='".$rsf["t1"]." ".translate("Nolu Fatura")."' where id=".$rsc["id"]."");
		}
//------------/Cari Kaydet/---
	}	//Tutar Boş Değilse
//------------/Cari Kontrol ve Güncelle/---
//------------/Stok Kontrol/---
	include("op.php");
//------------/Stok Kontrol/---
	echo $sdil[212];
//--/Fatura Tutar Güncelle/---
}elseif($_GET["durum"]=="smuhasebe"){
	$sql = mysqli_query($conn, "delete from t4 where id=".$_GET["id"]." or s5=".$_GET["id"]."");
	echo location("?ne=".$_GET["ne"]."&islem=fatura",self,500,1);
}elseif ($_GET["durum"]=="pdf"){
	$sql5=mysqli_query($conn, "select * from t5 where id='".$rsf["s1"]."'"); $rs5=mysqli_fetch_assoc($sql5);
	$url			= "".$weburl."/".$crmpath."/modules/print/account_iinvoice.php?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."";
	$pdfname	= "".translate("fatura")."_".$rsf["t1"].".pdf";
	$expath	= "../";
	if(!file_exists("../deppo/dosya/".$pdfname."")){
		$expdf=expdf($url,$pdfname,$expath);
	}
	$mesaj		.= "".translate("Sayın")." <b>".$rs5["t1"].";</b><br><br>".translate("fatura_mtext")."<br><br><br>";
	$mesaj		.= "<center>";
	$mesaj		.= " <a href=\"".$weburl."/deppo/dosya/".$expdf."\" target=\"_blank\" style=\"padding: 10px; border: 1px solid #ccc; margin-right:25px;\">".translate("Faturayı İncele")."</a>";
	if($bakiye>0){
		$mesaj		.= "<a href=\"".$weburl."/".number_format($bakiye,2)."\" target=\"_blank\" style=\"padding: 10px; border: 1px solid #ccc;\">".translate("Online Ödeme")."</a><br><br>";
	}
	$mesaj		.= "</center>";
	$malici		= base64_decode($rs5["t2"]);
	$konu		= "".translate("Fatura")."";
	$path		= "../";
	$mesaj		= $design_top.$mesaj.$design_bottom;
	emailgonder($malici,$konu,$cc,$mesaj);
	echo location("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&durum=ok_pdf",self,500,1);
}
?>