<!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>GATRATANI | 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">
        <!-- title row -->
        
        <!-- info row -->
        <div class="row invoice-info">
			<div class="col-xs-12">
			  <h2 class="page-header">
				<i class="fa fa-shopping-cart" ></i> SALE INVOICE
			  </h2>
			</div><!-- /.col -->
			
			 <div class="col-sm-12 ">
			<?php
			  $inv = $_GET['id'];
			  $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 telp from customer where id = $custid"),0);
			  $billdate = tgl_ind(mysql_result(mysql_query("select billdate from jualcs where billno = $inv"),0));
				
				
				echo"
				<div class='row'><div class='col-sm-2 '> Tanggal </div> 	<div class='col-sm-10'>	: 13-Okt-2018</div></div> 
				<div class='row'><div class='col-sm-2 '> Nomor </div> 	<div class='col-sm-10'>	: 13-Okt-2018</div></div> 
				<div class='row'><div class='col-sm-2 '> Kepada Yth </div> 	<div class='col-sm-10'>	: 13-Okt-2018</div></div> 
				
				";
				
				echo"
				<table class='table table-striped'>
					<tr>
						<td width='20%'>Tanggal</td>
						<td width='3%'>:</td>
						<td width='70%'>$billdate</td>
					</tr>
					<tr>
						<td>Nomor</td>
						<td>:</td>
						<td>18100001</td>
					</tr>
					<tr>
						<td>Kepada Yth<br>&nbsp;</td>
						<td>:<br>&nbsp;</td>
						<td>CV Sana SINI<br>alamat disini</td>
					</tr>
				  </table>";
			  ?>
            </div><!-- /.col -->
        </div><!-- /.row -->

        <!-- Table row -->
        <div class="row">
          <div class="col-xs-12 table-responsive">
            <table class="table table-striped">
              <thead>
                <tr>
                    <th>No</th>
                    <th>Product</th>
					<th>Qty</th>
                    <th>Harga@</th>
					<th>Disc(%)</th>
                    <th>Jumlah</th>
                </tr>
              </thead>
             <tbody>
				<?php
				$i = 0;
				$cek = mysql_query("Select * from jualcsdetail where billno = $inv order by billno desc,id asc");
				while ($r=mysql_fetch_array($cek)){	
					$i = $i + 1;
					$produk = mysql_result(mysql_query("select produk from produk where id = $r[produk]"),0);
					$uprice = format_rupiah($r[harga]);
					$qty = format_rupiah($r[qty]);
					$disc = format_rupiah($r[disc]);
					$tot = format_rupiah(($r[qty] * ($r[harga] -($r[harga] * $r[disc] / 100))));
					echo"
					  <tr>
						<td>$i</td>
						<td>$produk</td>
						<td>$qty</td>
						<td>$uprice</td>
						<td>$disc</td>
						<td>$tot</td>
					  </tr>";
				}
				?>
             </tbody>
            </table>
          </div><!-- /.col -->
        </div><!-- /.row -->

        <div class="row">
          <!-- accepted payments column -->
          <div class="col-xs-6">
			<div class="table-responsive">
                <table class="table">
                  <tr>
                    <th style="width:50%">Tanda Terima<br><br><br>______________</th>
					<th style="width:50%">Hormat Kami<br><br><br>GATRATANI</th>
                  </tr>

				 
                </table>
            </div>
          </div><!-- /.col -->
          <div class="col-xs-6">
            <div class="table-responsive">
                <table class="table">
                  <tr>
                    <th style="width:50%">Subtotal:</th>
					<?php
						$grand = format_rupiah(mysql_result(mysql_query("select sum(qty*(harga - (harga * disc / 100))) from jualcsdetail where billno = $inv"),0));
						echo"<td>$grand</td>";
					?>
                  </tr>
				 
                </table>
            </div>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </section><!-- /.content -->
    </div><!-- ./wrapper -->

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