<!DOCTYPE html>
<?php 
	session_start();
	@ob_start();
	include "../../config/koneksi.php";
	include "../../config/fungsi_rupiah.php";
	include "../../config/fungsi_indotgl.php";

?>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>OUZEN MART | Invoice</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body onload="window.print();">
    <div class="wrapper">
      <!-- Main content -->
     <section class="invoice">
     
          <!-- Table row -->
		<?php
		$hit = 0;
		$cek = mysql_query("Select * from deliverydetail where delivery = $_GET[id] order by jualcs asc");
		while ($r=mysql_fetch_array($cek)){	
			  $hit = $hit + 1;
			  $inv = $r['jualcs'];
			  $noinv = str_pad($inv, 4, "0", STR_PAD_LEFT);
			  $custid 	=  mysql_result(mysql_query("select cust from jualcs where billno = $inv"),0);
			  $cust 	=  mysql_result(mysql_query("select nama from customer where id = $custid"),0);
			  $alamat	=  mysql_result(mysql_query("select alamat from customer where id = $custid"),0);
			  $telp		=  mysql_result(mysql_query("select hp from customer where id = $custid"),0);
			  echo"
            <div class='col-xs-6 table-responsive'>
              <table width = '100%' frame='box'>
                  <tr>
					  <td colspan =3>
					   <br><br>&nbsp;&nbsp;&nbsp;<b>Terima Kasih Sudah Berbelanja</b><br>
					  </td>
                  </tr>
				  <tr>
					<td width ='15%'>&nbsp;&nbsp;&nbsp;Nama</td>
					<td width ='2%'>:</td>
					<td width ='55%'>$cust</td>
					<td width ='2%'>&nbsp;</td>
					<td width ='26%'>Jenis <br>Pengiriman</td>
				  </tr>
				  <tr>
					<td>&nbsp;&nbsp;&nbsp;Alamat</td>
					<td>:</td>
					<td>$alamat</td>
					<td>&nbsp;</td>
					<td>J&T</td>
				  </tr>
				  <tr>
					<td>&nbsp;&nbsp;&nbsp;Telpon</td>
					<td>:</td>
					<td> $telp</td>
					<td>&nbsp;</td>
					<td>Pengirim</td>
				  </tr>
				  <tr>
					<td>&nbsp;&nbsp;&nbsp;Pesanan</td>
					<td>:</td>
					<td>";
					
					$cek2 = mysql_query("Select produk,sum(qty) as qty from jualcsdetail where billno = $inv  group by produk order by billno desc");
					$i=0;
					while ($r2=mysql_fetch_array($cek2)){	
						$i = $i + 1;
						$produk = mysql_result(mysql_query("select produk from produk where id = $r2[produk]"),0);
						$uprice = format_rupiah($r2[harga]);
						$qty = format_rupiah($r2[qty]);
						$tot = format_rupiah($r2[qty] * $r2[harga]);
						if ($i == 1){
							echo"$qty x $produk";
						}else{
							echo"<br>$qty x $produk";
						}
					}
			
					echo"
					</td>
					<td>&nbsp;</td>
					<td><img src = 'pengirim.png'></img>&nbsp;&nbsp;</td>
				  </tr>
				  <tr>
					<td colspan =5>
					   <br>	<p align = 'right'>#$noinv &nbsp;&nbsp;</p>
					  </td>
				  </tr>

				
              </table>
            </div>";	
			
			if ($hit % 2 == 0){
				echo"<div class='col-xs-12 table-responsive'> <h2> </h2> </div>";
			}

		}
		?>
		  
 
        </section><!-- /.content -->
    </div><!-- ./wrapper -->

    <!-- AdminLTE App -->
    <script src="../../dist/js/app.min.js"></script>
  </body>
</html>
