<?php
$path="../../";
include("../../map.php");
include("../../scripts.php");
$sqlu=mysqli_query($conn, "select * from ".$_SESSION["lang"]." where id=".$_GET["id"]." order by id desc"); $rs=mysqli_fetch_assoc($sqlu);
?>
<div class="alert alert-warning" id="err" style="display:none;"><?php echo $sdil[212]; //islem Basariyla Gerçeklestirilmistir !?></div>
<form method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&rb=ekle" style="">
	<table class="table" style="width:98%;">
		<tr class="" style="height: 34px;">
			<th>
				<?php echo ctranslate("Bileşen")?>
			</th>
			<th class="" style="width:12%;">
				<?php echo ctranslate("Miktar")?>
			</th>
			<th class="tar" style="width:12%;">
				<?php echo ctranslate("Fiyat")?>
			</th>
			<th class="tar" style="width:8%;">
				<?php echo ctranslate("İşlem")?>
			</th>
		</tr>
		<tr class="addtr">
			<td>
				<input type="text" name="vt1" title="<?php echo ctranslate("Yeni Ekle")?>" class="form-control with-tip" placeholder="<?php echo ctranslate("Bileşen")?>">
			</td>
			<td class="">
				<div class="input-group">
					<input type="number" name="vt2" class="form-control tar" style="" value="" title="<?php echo ctranslate("Miktar")?>" class="form-control with-tip">
					<span class="input-group-addon" id="basic-addon2" style="padding:0px;width: 50px;">
						<select size=1 name="vt10" class="form-control sna mfs12">
							<?php if(!empty($t28)){$sbirim = explode(',',$t28); foreach($sbirim as $sbrm) {$s++; if($s > 20) {$s = 1;}?>
							<option value="<?php echo $sbrm;?>"><?php echo $sbrm;?></option>
						<?php }}?>
					</select>
				</span>
			</div>
		</td>
			<td>
				<input type="text" name="vpb1" value="0" class="form-control with-tip" placeholder="<?php echo ctranslate("Fiyat")?>" style="text-align:right">
			</td>
		<td class="tar">
			<button type="submit" class="btn btn-warning"  style="padding: 4px 7px;"><i class="fa fa-plus"></i></button>
		</td>
	</tr>
</form>
<?php $vrysyn=mysqli_query($conn, "select * from genel where ne='recipe' and s1=".$_GET["id"].""); while($recipe=mysqli_fetch_assoc($vrysyn)){ ?>
	<form method="POST" action="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&rb=duzenle&rb_id=<?php echo $recipe["id"];?>" style="margin-bottom:5px;" id="xf<?php echo $recipe["id"];?>" name="f<?php echo $recipe["id"];?>">	
		<tr data-id="<?php echo $recipe["id"];?>" class="edittr btr">
			<td>
				<input type="text" name="vt1" value="<?php echo $recipe["t1"];?>" class="form-control with-tip" placeholder="<?php echo ctranslate("Bileşen")?>">
			</td>
			<td>
				<div class="input-group">
					<input type="number" name="vt2" class="form-control tar" style="" value="<?php echo $recipe["t2"];?>" title="" class="form-control with-tip">
					<span class="input-group-addon" id="basic-addon2" style="padding:0px;width: 50px;">
						<select size=1 name="vt10" class="form-control sna mfs12">
							<?php if(!empty($t28)){$sbirim = explode(',',$t28); foreach($sbirim as $sbrm) {$s++; if($s > 20) {$s = 1;}?>
							<option value="<?php echo $sbrm;?>" <?php if($recipe["t10"]==$sbrm) {?>Selected<?php }?>><?php echo $sbrm;?></option>
						<?php }}?>
					</select>
				</span>
			</div>
		</td>
		<td>
			<input type="text" name="vpb1" value="<?php echo $recipe["pb1"];?>" class="form-control with-tip" placeholder="<?php echo ctranslate("Fiyat")?>" style="text-align:right">
		</td>
		<td class="tar">
			<button type="button" onclick="Ajaxs('<?php echo $recipe["id"];?>','#err','AjaxPost');" class="btn btn-warning" style="padding: 4px 7px;"><i class="fa fa-refresh"></i></button>
			<button type="button" class="btn btn-danger btn-delete-row" data-href="?ne=<?php echo $_GET["ne"];?>&islem=<?php echo $_GET["islem"];?>&id=<?php echo $_GET["id"];?>&rb=sil&rb_id=<?php echo $recipe["id"];?>&rs5=<?php echo $recipe["s5"];?>"><i class="fa fa-times"></i></button>		
		</td>
	</tr>
</form>
<?php $toplam=$recipe["pb1"]+$toplam;}?>
	<tr>
		<td></td>
		<td style="text-align:right;">Maliyet (<?php echo $kpb?>):</td>
		<td>
			<input type="text" value="<?php echo wprice($toplam);?>" class="form-control with-tip" style="text-align:right">
		</td>
		<td></td>
	</tr>
</table>
<?php
if($_GET["rb"] == "duzenle"){
	$Rsvu = mysqli_query($conn, "update genel set t1='".$_POST["vt1"]."', t2='".$_POST["vt2"]."', pb1='".sprice($_POST["vpb1"])."', t10='".$_POST["vt10"]."', s1='".$_GET["id"]."' where id=".$_GET["rb_id"]."");
	go("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&nedir=ok");
}elseif($_GET["rb"] == "sil"){
	$Rs = mysqli_query($conn, "delete from genel where id=".$_GET["rb_id"]);
	go("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&nedir=ok");
}elseif($_GET["rb"] == "ekle"){
	$sql = $conn->query("insert into genel(ne,t1,t2,pb1,t10,s1,ts1) values ('recipe','".$_POST["vt1"]."', '".$_POST["vt2"]."', '".sprice($_POST["vpb1"])."', '".$_POST["vt10"]."', '".$_GET["id"]."', now())");
	go("?ne=".$_GET["ne"]."&islem=".$_GET["islem"]."&id=".$_GET["id"]."&nedir=ok");
}
?>