<!DOCTYPE html>

<?php 
	session_start();
	@ob_start();
	include "../../config/koneksi.php";
	include "../../config/fungsi_rupiah.php";
	include "../../config/fungsi_indotgl.php";
	include "../head.php";

	
	if ($_SESSION['nama'] == ''){
		header('Location:index.php');
	}
	else{
?>
<html>

  <body class="hold-transition skin-blue sidebar-mini layout-boxed">
    <div class="wrapper">
		<?php include "../header.php";?>
      
		<?php include "../menu.php";?>
      

      <!-- Content Wrapper. Contains page content -->
      <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section class="content-header">
          <h1>
            DETAIL ORDERAN E-SHOPPING EMA
            <small>Detail Orderan E-Shopping</small>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="data.php">Transaksi</a></li>
            <li class="active"><a href="data.php"><u>Orderan E-Shopping</u></a></li>
          </ol>
        </section>

        <!-- Main content -->
        <section class="content">
          <div class="row">
            <div class="col-xs-12">
              
              <div class="box">
                <div class="box-header">
                  <h3 class="box-title">Detail Orderan E-Shopping</h3><br><br>
				  <?php
					$bill = $_GET[id];
					$order = "ULT".str_pad($_GET[id], 6, "0", STR_PAD_LEFT);
					$billdate = mysql_result(mysql_query("select billdate from temporder where ord = $_GET[id]"),0);
					$lacak = mysql_result(mysql_query("select lacak from ordercust where billno = $_GET[id]"),0);
					$cust = mysql_result(mysql_query("select customer from ordercust where billno = $_GET[id]"),0);
					$tot = mysql_result(mysql_query("select sum(qty*price) from temporder where ord = $_GET[id]"),0);
					$tot2 = format_rupiah($tot);
					echo"<h2>$order</h2>Customer : $cust<br><br> Status : $lacak<br><br> Total : Rp. $tot2<br><br> ";
					if($lacak == "Pending"){
						echo"
						<a href='aksisales.php?module=sales&act=proses&id=$_GET[id]' class='btn btn-sm btn-success btn-flat pull-left'>Process</a>";
					}
				  ?>
                </div><!-- /.box-header -->
                <div class="box-body">
                  <table id="example1" class="table table-bordered table-striped">
                    <thead>
                      <tr>
                        <th>Nama Product</th>
                        <th>Qty & Price</th>
                        <th>Total (Rp)</th>
						<th>St</th>
                      </tr>
                    </thead>
                    <tbody>
					<?php
						$user = $_SESSION['nama'];
						$cek = mysql_query("Select * from temporder where ord = $bill order by billno asc");
						while ($r=mysql_fetch_array($cek)){	
							$ord = $r['billno'];
							$tgl = tgl_ind($r['billdate']);

							$time = strtotime(date($r['billdate']));
							$jam = date("H:i",strtotime("+11 hours", $time));

							$noord = "ULT".str_pad($ord, 6, "0", STR_PAD_LEFT);

							$namaproduk = mysql_result(mysql_query("select barcode from products where code = $r[product]"),0);
							$qty = $r['qty'];
							$price = $r['price'];
							$price2 = format_rupiah($price);
							$tot = $r['price'] * $r['qty'];
							$tot2 = format_rupiah($tot);
							$warna = "class='label-success'";
							echo "<tr>
									<td $warna>$namaproduk</td>
									<td $warna>$qty  @  $price2</td>
									<td $warna>$tot2</td>
									<td $warna><i class='fa fa-check-square'></i></td>
								  </tr>";
						}
					?>
                        
                     
                    </tbody>

                  </table>
                </div><!-- /.box-body -->
              </div><!-- /.box -->
            </div><!-- /.col -->
          </div><!-- /.row -->
        </section><!-- /.content -->
      </div><!-- /.content-wrapper -->
		<?php include "../footer.php";?>
		

      <!-- Control Sidebar -->
      <aside class="control-sidebar control-sidebar-dark">

        <!-- Tab panes -->
        <div class="tab-content">
          <!-- Home tab content -->
          <div class="tab-pane" id="control-sidebar-home-tab">

          </div><!-- /.tab-pane -->

        </div>
      </aside><!-- /.control-sidebar -->
      <!-- Add the sidebar's background. This div must be placed
           immediately after the control sidebar -->
      <div class="control-sidebar-bg"></div>
    </div><!-- ./wrapper -->

    <!-- jQuery 2.1.4 -->
    <script src="../../plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="../../bootstrap/js/bootstrap.min.js"></script>
    <!-- DataTables -->
    <script src="../../plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="../../plugins/datatables/dataTables.bootstrap.min.js"></script>
    <!-- SlimScroll -->
    <script src="../../plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="../../plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="../../dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="../../dist/js/demo.js"></script>
    <!-- page script -->
    <script>
      $(function () {
        $("#example2").DataTable();
        $('#example1').DataTable({
          "paging": true,
          "lengthChange": true,
          "searching": true,
          "ordering": true,
		  "order": [[ 0, "desc" ]],
          "info": true,
          "autoWidth": false
        });
      });
    </script>
	
  </body>
</html>
<?php 
	}
?>