<!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>
            Invoice
			<?php
				$inv2 = $_GET[id];
				$noord = str_pad($inv2, 4, "0", STR_PAD_LEFT);
				echo"<small>#$noord</small>";
			?>
          </h1>
          <ol class="breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
            <li><a href="#">Penjualan CS</a></li>
            <li class="active">Invoice</li>
          </ol>
        </section>

        <div class="pad margin no-print">
          <div class="callout callout-info" style="margin-bottom: 0!important;">
            <h4><i class="fa fa-info"></i> Note:</h4>
            This page has been enhanced for printing. Click the print button at the bottom of the invoice to test.
          </div>
        </div>

        <!-- 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);
						$qty = format_rupiah($r2[qty]);
						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>";
			}

		}
		?>
		  

		
			


		  
		  

         <div class="row">
			<br>
         </div>

          <!-- this row will not appear when printing -->
          <div class="row no-print">
            <div class="col-xs-12">
			<?php
			  echo"
              <a href='invoice-print.php?id=$inv2' target='_blank' class='btn btn-default'><i class='fa fa-print'></i> Print</a>";
			?>
			  <!--
              <button class="btn btn-success pull-right"><i class="fa fa-credit-card"></i> Submit Payment</button>
              <button class="btn btn-primary pull-right" style="margin-right: 5px;"><i class="fa fa-download"></i> Generate PDF</button>
			  -->
            </div>
          </div>
		  
		  
		  
        </section><!-- /.content -->
        <div class="clearfix"></div>
      </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>

     
      <!-- 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>
    <!-- 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>
  </body>
</html>
<?php 
	}
?>