<div class="col-xs-12"><!-- /.box -->
<div class="box">
<div class="box-header">
<h3 class="box-title">Sipariş Ürün Ekle</h3>
</div><!-- /.box-header -->
<div class="box-body table-responsive">
<?php
if($_POST){
$sipid=$_POST["sipid"];
$urunid=$_POST["urunid"];
$miktar=$_POST["miktar"];
$bfiyati=$_POST["bfiyati"];
$toplam=$_POST["toplam"];
include("../main/connect.php");
$Komut=mysql_query("insert into urunsiparis values('','$sipid','$urunid','$miktar','$bfiyati','$toplam')");
if($Komut){
echo "Kaydınız başarıyla eklenmiştir. Listeleme sayfasına yönlendiriliyorsunuz.";
header("refresh:2; url=siparis_urun_ekle.php");
}
else{
echo "Bir sorunla karşılaşıldı! Kayıt eklenemedi. Listeleme sayfasına yönlendiriliyorsunuz.";
header("refresh:2; url=index.php");
}}
?>
<!------------------------------------------->
<form name="form1" method="post" action="siparis_urun_ekle.php"
oninput="toplam.value = parseInt (miktar.value ) * parseInt (bfiyati.value)">
<table width="auto" border="0" cellpadding="3" cellspacing="3">
<tr>
<td width="9"></td>
<td width="188"><label for="exampleInputEmail1">Sipariş Kodu</label>
<?php
$Kisi=$_GET["Kisi"];
$sql2=mysql_query("select * from siparisler order by idsip desc limit 0, 1");
while($oku=mysql_fetch_array($sql2))
{
$idsip=$oku['idsip'];
}
?>
<input name="sipid" type="text" class="form-control" id="sipid" value ="<?=$idsip?>" />
</span></td>
<td width="8">
</td>
<td width="260"><label for="exampleInputEmail1">Ürün Seç</label>
<select name="urunid" id="urunid" class="form-control" onchange="">
<?
$sql3 = "SELECT * FROM urunler where id";
$sonuc = mysql_query($sql3);
while ($oku = mysql_fetch_row($sonuc))
{
?>
<option value="<?=$oku[0]?>"><?=$oku[2]?></option>
<?
}
?>
</select>
</td>
<td width="8"> </td>
<td width="213">
<label for="exampleInputEmail1">Ürün Kodu</label>
<input type="text" class="form-control" name="urunid_id" id="urunid_id" value="<?=$row['0']?>" /></td>
<td width="10"> </td>
<td width="344"><label for="exampleInputEmail1">Birim</label>
<input type="text" name="birim" class="form-control" id="birim" value="<?=$row['5']?>" /></td>
</tr>
<tr>
<td> </td>
<td></td>
<td> </td>
<td><label for="exampleInputEmail1">Birim Fiyatı</label>
<input type="text" name="bfiyati" id="bfiyati" class="form-control" value="<?=$row['6']?>" /></td>
<td></td>
<td><label for="exampleInputEmail1">Miktar</label>
<input name="miktar" type="text" class="form-control" id="miktar" /></td>
<td> </td>
<td><label for="exampleInputEmail1">Toplam</label>
<input type="text" name="toplam" id="toplam" class="form-control" value="" /></td>
</tr>
<tr>
<td> </td>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td>
</td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td></td>
<td> </td>
<td> </td>
<td> </td>
<td></td>
<td> </td>
<td><button type="submit" class="btn btn-primary">Siparişe Ürün Ekle</button></td>
</tr>
</table>
</form>
<form name="form1" method="post" action="siparis_urun_ekle.php">
<table id="example2" class="table table-bordered table-striped">
<thead>
<tr>
<td>No</td>
<td>Sipariş Kodu</td>
<td>Urun Adi</td>
<td>Miktar</td>
<td>Birim Fiyatı</td>
<td>Toplam</td>
<td>Sil</td>
</tr>
</thead>
<tbody>
<?php
$Kisi=$_GET["Kisi"];
echo $Kisi;
?>
<?php
$sql4=mysql_query("select * from siparisler ,urunler order by idsip desc limit 0, 1");
while($oku=mysql_fetch_array($sql4))
{
$idsip=$oku['idsip'];
}
$Kisi=$_GET["Kisi"];
$sql5=mysql_query("select * from urunsiparis,urunler Where sipid=$idsip and urunsiparis.urunid=urunler.id ");
while($oku2=mysql_fetch_array($sql5))
{
$id=$oku2['id'];
$sipid=$oku2['sipid'];
$urunadi=$oku2['urunadi'];
$miktar=$oku2['miktar'];
$bfiyati=$oku2['bfiyati'];
$toplam=$oku2['toplam'];
echo ' <tr>
<td><div style="font-size:16; font-weight:normal; width:30px; text-align:center;">'.$id.'</div></td>
<td><div style="font-size:16; font-weight:normal; width:150px; text-align:center;">'.$sipid.'</div></td>
<td><div style="font-size:16; font-weight:normal; width:300px; text-align:left;">'.$urunadi.'</div></td>
<td><div style="font-size:16; font-weight:normal; width:100px; text-align:center;">'.$miktar.'</div></td>
<td><div style="font-size:16; font-weight:normal; width:100px; text-align:center;">'.$bfiyati.' TL</div></td>
<td><div style="font-size:16; font-weight:bold; width:150px; text-align:right;">'.$toplam.' TL</div></td>
<td><a id="'.$oku2["sipid"].'" class="sil" href="#" onClick="window.location.reload()">Sil</a></td>
</tr>
';
}
?> </tbody>
</table>
</form>
<form method="post" action="siparis_urun_ekle_kayit.php">
<?php
require_once('../main/connect.php');
$Kisi=$idsip;
$sql=mysql_query("select * from siparisler order by idsip desc limit 0, 1");
while($oku=mysql_fetch_array($sql))
{
$sip_tutari=$oku['sip_tutari'];
$kdv=$oku['kdv'];
$toplam=$oku['toplam'];
?>
<table >
<tr>
<td></td>
<td></td>
<td></td>
<td><div style="width:800px;"></div></td>
<td>Ara Toplam</td>
<td><input name="sip_tutari" class="form-control" value="
<?php
$sql6=mysql_query("select * from siparisler ,urunler order by idsip desc limit 0, 1");
$oku=mysql_fetch_array($sql6);
$idsip=$oku['idsip'];
$query = mysql_query("SELECT SUM(toplam) FROM urunsiparis where sipid=$idsip");
$row = mysql_fetch_array($query);
echo $row['SUM(toplam)'];
?> "/></td>
<td>TL</td>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Kdv<td><input name="kdv" class="form-control" value="<?php
$sayi=$row['SUM(toplam)'];
$sayi2= 0.08;
$kdv=$sayi*$sayi2;
echo ''.$kdv.'';
?> "/></td>
<td>TL</td>
</tr>
</td>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td>Genel Toplam</td>
<td><input name="toplam" class="form-control" value="<?php
$toplam=$sayi+$kdv;
echo''.$toplam.'';
?>"/></td>
<td>TL</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td> </td>
<td> </td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td> </td>
<td><button type="submit" class="btn btn-primary">Siparişi Bitir</button></td>
<td></td>
</tr>
</table> <?php }?></form >
<!--------------------------------------------->
</div><!-- /.box-body -->
</div><!-- /.box -->