
	
	<?php 
if (!empty($_GET["sipariskodu"])) 
{ 
  $sipariskodu=$VT->filter($_GET["sipariskodu"]);
  
  $siparisler=$VT->VeriGetir("siparisler","WHERE sipariskodu=?",array($sipariskodu),"ORDER BY ID ASC",1);
  if ($siparisler!=false) 
  {
    $uyebilgisi=$VT->VeriGetir("uyeler","WHERE ID=? AND durum=?",array($siparisler[0]["uyeID"],1),"ORDER BY ID ASC",1);
    if ($uyebilgisi!=false) 
    {
    } 
    else
    {
      ?>
      <meta http-equiv="refresh" content="10;url=<?=SITE?>siparis-list">
      <?php
      exit(); 
    }
  } 
  else 
  {
    ?>
    <meta http-equiv="refresh" content="10;url=<?=SITE?>siparis-list">
    <?php
    exit();
  }

  ?>
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <section class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1>Fatura</h1>
          </div>
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
              <li class="breadcrumb-item"><a href="#">Anasayfa</a></li>
              <li class="breadcrumb-item active">Fatura</li>
            </ol>
          </div>
        </div>
      </div><!-- /.container-fluid -->
    </section>

    <section class="content">
      <div class="container-fluid">
        <form action="#" method="post">
          <div class="row">

            <div class="col-12">
              <div class="callout callout-info">
                <h5><i class="fas fa-info"></i> Note:</h5>
                This page has been enhanced for printing. Click the print button at the bottom of the invoice to test.
              </div>


              <!-- Main content -->
              <div class="invoice p-3 mb-3">
                <!-- title row -->
                <div class="row">
                  <div class="col-12">
                    <h4>
                      <i class="fas fa-globe"></i> Firma Adı
                      <small class="float-right">Tarih: <?=date("d.m.Y",strtotime($siparisler[0]["tarih"]))?></small>
                    </h4>
                  </div>
                  <!-- /.col -->
                </div>
                <!-- info row -->
                <div class="row invoice-info">
                  <div class="col-sm-4 invoice-col">
                    From
                    <address>
                      <strong>Admin, Inc.</strong><br>
                      795 Folsom Ave, Suite 600<br>
                      San Francisco, CA 94107<br>
                      Phone: (804) 123-5432<br>
                      Email: info@almasaeedstudio.com
                    </address>
                  </div>
                  <!-- /.col -->
                  <div class="col-sm-4 invoice-col">
                    Müşteri Bilgileri
                    <address>
                      <strong>
                        <?php 
                        if ($uyebilgisi[0]["tipi"]==1) 
                        {
                          echo stripcslashes($uyebilgisi[0]["ad"]." ".$uyebilgisi[0]["soyad"]);
                        }
                        else
                        {
                          echo stripcslashes($uyebilgisi[0]["firmaadi"]);
                        }
                        ?>
                      </strong>
                      <br>
                      Adres: 
                      <?php 
                      $ilBilgi=$VT->VeriGetir("il","WHERE ID=?",array($uyebilgisi[0]["ilID"]),"ORDER BY ID ASC",1);
                      echo stripcslashes($uyebilgisi[0]["adres"]." ".$uyebilgisi[0]["ilce"]);
                      if($ilBilgi!=false)
                      {
                       echo "/".mb_convert_case($ilBilgi[0]["ADI"],MB_CASE_UPPER,"UTF-8");
                     }
                     ?>
                     <br>
                     Telefon: <?=$uyebilgisi[0]["telefon"]?>
                     <br>
                     E-Mail: <?=$uyebilgisi[0]["mail"]?>
                   </address>
                 </div>
                 <!-- /.col -->
                 <div class="col-sm-4 invoice-col">
                  <b>Fatura #<?=$siparisler[0]["ID"]?></b><br>
                  <br> 
                  <b>Sipariş Tarih:</b> <?=date("d.m.Y",strtotime($siparisler[0]["tarih"]))?><br>
                  <b>Ürün Kodu :</b> <?=$siparisler[0]["sipariskodu"]?>
                </div>
                <!-- /.col -->
              </div>
              <!-- /.row -->

              <!-- Table row -->
              <div class="row">
                <div class="col-12 table-responsive">
                  <table class="table table-striped">
                    <thead>
                      <tr>
                       <th>ÜRÜN KODU</th>
                       <th>RESMİ</th>
                       <th>ÜRÜN ADI</th>
                       <th>FİYAT</th>
                       <th>ADET</th>
                       <th>TOPLAM TUTAR</th> 
                     </tr>
                   </thead>
                   <tbody>
                    <tr>
                     <?php 
                     $siparisurunler=$VT->VeriGetir("siparisurunler","WHERE siparisID=?",array($siparisler[0]["ID"]),"ORDER BY ID ASC");
                     if ($siparisurunler!=false) 
                     {
                      for ($i=0; $i <count($siparisurunler) ; $i++) { 
                        $urunler=$VT->VeriGetir("urunler","WHERE ID=?",array($siparisurunler[$i]["urunID"]),"ORDER BY ID ASC",1);
                        if ($urunler!=false) 
                        {
                          /*varyasyon Özeliklerini getir*/
                          $ozellikler="";
                          if (!empty($siparisurunler[$i]["varyasyonID"])) 
                          {
                            $varyasyonKonturol=$VT->VeriGetir("urunvaryasyonstoklari","WHERE ID=?",array($siparisurunler[$i]["varyasyonID"]),"ORDER BY ID ASC",1);
                            if ($varyasyonKonturol!=false) 
                            {
                              $varyasyonID=$varyasyonKonturol[0]["varyasyonID"];
                              $secenekID=$varyasyonKonturol[0]["secenekID"];
                              if (strpos($varyasyonID,"@")>0) 
                              {
                                $varyasyonDizi=explode("@",$varyasyonID);  
                                $secenekDizi=explode("@",$secenekID);
                                for ($x=0; $x <count($varyasyonDizi); $x++) 
                                {  
                                  $varyasyonBilgisi=$VT->VeriGetir("urunvaryasyonlari","WHERE ID=?",array($varyasyonDizi[$x]),"ORDER BY ID ASC",1);

                                  $secenekBilgisi=$VT->VeriGetir("urunvaryasyonsecenekleri","WHERE ID=?",array($secenekDizi[$x]),"ORDER BY ID ASC",1);

                                  if ($varyasyonBilgisi!=false && $secenekBilgisi!=false)
                                  {
                                    $ozellikler=$ozellikler.stripcslashes($secenekBilgisi[0]["baslik"])." ".stripcslashes($varyasyonBilgisi[0]["baslik"])." ";
                                  } 
                                }
                              }
                              else
                              {
                                $varyasyonBilgisi=$VT->VeriGetir("urunvaryasyonlari","WHERE ID=?",array($varyasyonID),"ORDER BY ID ASC",1);

                                $secenekBilgisi=$VT->VeriGetir("urunvaryasyonsecenekleri","WHERE ID=?",array($secenekID),"ORDER BY ID ASC",1);
                                if ($varyasyonBilgisi!=false && $secenekBilgisi!=false)
                                {
                                  $ozellikler=stripcslashes($secenekBilgisi[0]["baslik"])." ".stripcslashes($varyasyonBilgisi[0]["baslik"]);
                                } 
                              }
                            }
                          }
                          ?>
                          <td><?=$urunler[0]["urunkodu"]?></td>
                          <td>
                            <img src="<?=ANASITE?>images/urunler/<?=$urunler[0]["resim"]?>" style="height: 50px; width: auto; display: block;">
                          </td>
                          <td><?=stripslashes($urunler[0]["baslik"])?><br><small style="color: #009688; font-size: 13px"><?=$ozellikler?></small></td>
                          <td><?=number_format($siparisurunler[0]["uruntutar"],2,",",".")?> TL</td>
                          <td><?=$siparisurunler[$i]["adet"]?></td>
                          <td><?=number_format($siparisurunler[0]["toplamtutar"],2,",",".")?> TL</td> 
                        </tr> 
                        <?php
                      }
                    }
                  } 
                  ?> 
                </tbody>
              </table>
            </div>
            <!-- /.col -->
          </div>
          <!-- /.row -->

          <div class="row">
            <?php  

            if($siparisler[0]["odemetipi"]==1){$odemetipi="kredi Kartı";} 
            if($siparisler[0]["odemetipi"]==2){$odemetipi="Havale / EFT";} 
            if($siparisler[0]["odemetipi"]==3){$odemetipi="Kapıda Ödeme";} 
            ?>

            <!-- accepted payments column -->
            <div class="col-6">
              <p class="lead">Ödeme Yönetemi: <?=$odemetipi?></p> 
            </div>
            <!-- /.col -->
            <div class="col-6">  
              <div class="table-responsive">
                <table class="table">
                  <tr>
                    <th style="width:50%"><?=$odemetipi?></th>
                    <td>
                      <?php 
                      if ($siparisler[0]["durum"]==1) 
                      {
                        ?>
                        <strong style="color:#4caf50;">ÖDENDİ</strong>
                        <?php
                      }
                      else
                      {
                        ?>
                        <strong style="color:#ff9800;">ÖDEME BEKLİYOR</strong>
                        <?php
                      }
                      ?>
                    </td>
                  </tr>
                  <tr>
                    <th>Kdv Hariç Tutar:</th>
                    <td><?=number_format($siparisler[0]["kdvharictutar"],2,",",".")?></td>
                  </tr>
                  <tr>
                    <th>Kdv Tutar:</th>
                    <td><?=number_format($siparisler[0]["kdvtutar"],2,",",".")?> TL</td>
                  </tr>
                  <tr>
                    <th>Ödenicek Tutar:</th>
                    <td><?=number_format($siparisler[0]["odenentutar"],2,",",".")?> TL</td>
                  </tr>
                </table>
              </div>
            </div>
            <!-- /.col -->
          </div>
          <!-- /.row -->

          <!-- this row will not appear when printing -->
          <div class="row no-print">
            <div class="col-12">
              <a href="invoice-print.html" target="_blank" class="btn btn-default"><i class="fas fa-print"></i> Yazdır</a>

              <button type="button" class="btn btn-success float-right"><i class="far fa-credit-card"></i> Submit
                Payment
              </button>
              <button type="button" class="btn btn-primary float-right" style="margin-right: 5px;">
                <i class="fas fa-download"></i> Generate PDF
              </button>
            </div>
          </div>
        </div>
        <!-- /.invoice -->
      </div><!-- /.col -->

    </div><!-- /.row -->
  </form>
</div><!-- /.container-fluid -->
</section>
<!-- /.content -->
</div>
<script type="text/javascript"> 
  window.addEventListener("load", window.print());
</script>
<?php } ?>