 <?php echo !defined("GUVENLIK") ? die("Erisim Engellendi!.") : null;?>
<title><?php echo $ayar->site_title; ?> - SİPARİŞ DETAY</title>
<meta name="description" content="<?php echo $ayar->site_desc;?>"/>
<meta name="keywords" content="<?php echo $ayar->site_meta;?>"/>
<?php if(!isset($_SESSION["email"])){
	header("Location:giris.html");
}?>
<?php $siparisid = g('id');?>
<?php $Sip	   	= Sorgu("SELECT * FROM siparisler WHERE id = '{$siparisid}'");
if(!mysql_affected_rows()){?>
<?php }else{
while($Siparis = Sonuc($Sip)){?>
<?php $bilgilerim = Sonuc(Sorgu("SELECT * FROM uyeler WHERE durum = '1' AND id = '{$_SESSION['uyeid']}'"));?>
<link rel="stylesheet" type="text/css" href="web/css/style.css" />
	<link rel="stylesheet" type="text/css" href="web/lib/font-awesome/css/font-awesome.min.css" />
<!-- page wapper-->
<div class="columns-container">
    <div class="container" id="columns">
        <!-- row -->
        <div class="row">
            <!-- Left colunm -->
            <div class="column col-xs-12 col-sm-3" id="left_column">
				
            </div>
            <!-- ./left colunm -->
            <!-- Center colunm-->
            <div class="center_column col-xs-12 col-sm-9" id="center_column">
                <!-- page heading-->
                <h2 class="page-heading">
                    <span class="page-heading-title"><a href="hesabim.html">Hesabım </a> » #<?php echo $Siparis->sno;?> Nolu Sipariş Detayı</span>
                </h2>
                <!-- Content page -->
                <div class="content-text clearfix">
					<div class="row">
					<div class="col-sm-12">
						<div class="box-authentication">
							<div class="content-page" style="padding: 20px;margin-top:0px;">
								<div class="col-md-3" style="text-align:right"><strong>Sipariş Numarası :</strong></div>
								<div class="col-md-3">#<?php echo $Siparis->sno;?></div>
								<div class="col-md-3" style="text-align:right"><strong>Sipariş Tarihi :</strong></div>
								<div class="col-md-3"><?php echo $Siparis->tarih;?></div>
								<div class="clearfix"></div>
								<div class="col-md-3" style="text-align:right"><strong>Sipariş Durumu :</strong></div>
								<div class="col-md-3">


										<?php if($Siparis->durum == "0"){ ?>

										 <span class="label label-sm label-warning"> Onay Bekliyor </span>

										 <?php }else{ ?> 

										 <span class="label label-sm label-success"> Siparişiniz Onaylandı </span>

										 <?php } ?>


								</div>
								<div class="clearfix"></div>
								<div class="col-md-3" style="text-align:right"><strong>Ödeme Şekli :</strong></div>
								<div class="col-md-3"><?php echo $Siparis->odeme_sekli;?></div>
								<div class="clearfix"></div>
							</div>
							<br>
							<h2><span class="page-heading-title">Fatura ve Teslimat Bilgileri</span></h2>
							<div class="content-page" style="padding: 20px;">

								<div class="col-md-12">
									<div class="well">
										<strong>Kargo Teslim Adresiniz</strong>
										<br>
										<address>
										<?php $Sorgu = Sorgu("SELECT * FROM adres WHERE id = '$Siparis->adres'");
										while($Sonuc = Sonuc($Sorgu)){?>
										<?php $ilce = Sonuc(Sorgu("SELECT * FROM ilceler WHERE id = '$Sonuc->semt'"));?>
										<?php $il = Sonuc(Sorgu("SELECT * FROM iller WHERE id = '$Sonuc->sehir'"));?>
										<?php echo $Sonuc->adres;?><br><?php echo $ilce->baslik;?> - <?php echo $il->baslik;?> <?php echo $Sonuc->postakodu;?>
										<?php }?>
										</address>
									</div>
								</div>
								<div class="clearfix"></div>
							</div>
							<br>
							<h2><span class="page-heading-title">Ürün Bilgileri</span></h2>
							<div class="content-page" style="padding: 20px;">
								<table class="table table-hover table-bordered table-striped">
									<thead>
										<tr>
											<th>
												Ürün
											</th>
											<th>
												Ürün Kodu
											</th>
											<th>
												Birim Fiyatı
											</th>
											<th>
												Adet
											</th>
											<th>
												Toplam
											</th>
										</tr>
									</thead>
									<tbody>
									<?php 
									$aratoplam = 0;
									$kargoucret = 8;
									$bol = explode("//",$Siparis->urun);
									foreach ($bol as $b) {
										$b = explode("|",$b);
										$c = explode("|",$b);
										if(gettype($b) == "array"){
											$sorguu = mysql_query("SELECT * FROM urunler WHERE id='$b[0]'");
											if(isset($secenekler) && is_array($secenekler)) $secenekler = "";
											$secenek  = json_decode($Siparis->secenek, true);
											if(is_array($secenek[$b[0]]) && count($secenek[$b[0]]) > 0){
												$secenek[$b[0]]['id'] = explode("|",$secenek[$b[0]]['id']);
												for ($i=0; $i < count($secenek[$b[0]]['id']) ; $i++) {
													$y = isset($secenek[$b[0]]['id'][$i]) ? $secenek[$b[0]]['id'][$i] : "0";
													$secbak = mysql_fetch_array(mysql_query("SELECT * FROM secenek WHERE id='$y'"));
													if($secbak){
														$xx = $secbak['kategori'];
														$baslik =mysql_fetch_array(mysql_query("SELECT * FROM secenek_kategori WHERE id='$xx'"));
														if($baslik){
															$secenekler[] = array("adi" => $secbak['adi'],"baslik" => $baslik['kategori_adi']);
														}
													}
												}
												
											}
											if(mysql_num_rows($sorguu)>0) {?>
												<?php $uu = mysql_fetch_array($sorguu);?>
													<tr>
														<td>
															<?php echo $uu['adi'];?> </br><?php 
															if(isset($secenekler) && is_array($secenekler)){
															foreach ($secenekler as $k) {
															 	echo "<strong>".$k['baslik']." :".$k['adi']."</strong><br>";
															 }
															} ?>
														</td>
														<td> <?=$uu['urun_kodu'];?> </td>
														<td>
															<?php echo ($uu['indirim'] == "1" ? ''.number_format($uu['ifiyat'], 2, ',', '.').'' : ''.number_format($uu['fiyat'], 2, ',', '.').'');?>
														</td>
														<td>
															<?php echo $b[1];?>
														</td>
														<td>
															<?php echo($uu['indirim'] == "1" ? ''.number_format($uu['ifiyat']*$b[1], 2, ',', '.').'' : ''.number_format($uu['fiyat']*$b[1], 2, ',', '.').'');?>
														</td>
													</tr>
													<?php 
													if($uu['kargobeles'] == "1") $kargoucret = 0;
													if($uu['indirim'] == "1"){
														$aratoplam += $uu['ifiyat']*$b[1];
													}else{
														$aratoplam += $uu['fiyat']*$b[1];
													}?>
												<?php 
												if($aratoplam >= 75) $kargoucret = 0; }
											}	
										}
									?>
									</tbody>
								</table>
								<div class="clearfix"></div>
								<div class="col-md-10" style="text-align:right"><b>Ara Toplam :</b></div>
								<div class="col-md-2" style="text-align:right"><?php echo number_format($aratoplam, 2, ',', '.');?> TL</div>
									<div class="col-md-10" style="text-align:right"><b>K.D.V. Tutarı :</b></div>
								<div class="col-md-2" style="text-align:right"><?php echo number_format($aratoplam*$ayar->kdv/100, 2, ',', '.');?> TL</div>
								<div class="col-md-10" style="text-align:right"><b>Kargo Ücreti :</b></div>
								<div class="col-md-2" style="text-align:right"><?php echo number_format($ayar->kargo, 2, ',', '.');?> TL</div>
								<div class="col-md-10" style="text-align:right"><b>Genel Toplam :</b></div>
										<div class="col-md-2" style="text-align:right"><?php echo number_format($aratoplam*$ayar->kdv/100+$aratoplam+$ayar->kargo, 2, ',', '.');?> TL</div>
								<div class="col-md-10" style="text-align:left"></br></br></br><b>Not :</b> Eğer "Havale" ile ödeme yapıldıysa "Genel Toplam" üzerinden %5 indirim uygulanır.</div>
								<div class="clearfix"></div>
							</div>
						</div>
					</div>
				</div>
                </div>
                <!-- ./Content page -->
            </div>
            <!-- ./ Center colunm -->
        </div>
        <!-- ./row-->
    </div>
</div>
<!-- ./page wapper-->
<?php } }?>