<!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 -->


    <!-- 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">
			  <h3 class="page-header">
				SURAT JALAN
			  </h3>
			</div><!-- /.col -->
			
			 <div class="col-sm-12 ">
			<?php
			  $inv = $_GET['id'];
			  $ucode  = $_GET['ucode'];
			  $tgl = mysql_result(mysql_query("select billdate from beli where billno = $inv "),0);
			  $noord = "AA".substr($tgl,2,2).substr($tgl,5,2).str_pad($inv, 4, "0", STR_PAD_LEFT);
			  $custid 	=  mysql_result(mysql_query("select cust from beli where billno = $inv"),0);
			  $cust 	=  mysql_result(mysql_query("select nama from supplier where id = $custid"),0);
			  $alamat	=  mysql_result(mysql_query("select alamat from supplier where id = $custid"),0);
			  $telp		=  mysql_result(mysql_query("select telp from supplier where id = $custid"),0);
			  $billdate = tgl_ind($tgl);
			  
				$hit = strlen($telp);
				if($hit > 2 ){
					$hp = "(".$telp.")";
				}else{
					$hp = "";
				}

				echo "<table style='width:100%'>
						<tr>
							<td width='15%'>Tanggal </td>
							<td width='2%'>: </td>
							<td width='83%'> $billdate</td>
						</tr>
						<tr>
							<td>Nomor </td>
							<td>: </td>
							<td> -</td>
						</tr>
						<tr>
							<td>Kepada Yth, </td>
							<td>&nbsp </td>
							<td>$cust $hp<br>$alamat</td>
						</tr>
					  </table>
				";
			
			  ?>
            </div><!-- /.col -->
        </div><!-- /.row -->

        <!-- Table row -->
        <div class="row">
          <div >
            <table style="width:100%">
              <thead>
                <tr>
                    <th height=20px>No</th>
                    <th align="left">Product</th>
					<th align="center">Qty</th>
                    <th align="center">Keterangan</th>
                </tr>
              </thead>
             <tbody>
				<?php
				$i = 0;
				$cek = mysql_query("Select * from belidetail where billno = $inv  order by billno desc");
				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] * -1);
					$disc = format_rupiah($r[disc]);
					$tot = format_rupiah((-1 * $r[qty] * ($r[harga] -($r[harga] * $r[disc] / 100))));
					echo"
					  <tr>
						<td height=20px width='5%' align = center>$i</td>
						<td height=20px; width='50%'>$produk</td>
						<td height=20px; width='10%' align = center>$qty</td>
						<td height=20px; width='35%'> &nbsp</td>
					  </tr>";
				}
				
				
				for ($j = $i + 1; $j <= 10; $j++) {
					echo"
					  <tr>
						<td height=20px> &nbsp </td>
						<td> </td>
						<td align='center'> &nbsp</td>
						<td align=right> &nbsp</td>
					  </tr>";
				} 
				?>
             </tbody>
            </table>
          </div><!-- /.col -->
        </div><!-- /.row -->
		<hr align="center" color="black">

        <div class="row">
          <!-- accepted payments column -->
          <div class="col-xs-8">
			<div class="table-responsive">
                <table style="width:100%">
                  <tr>
                    <td style="width:70%">Tanda Terima</td>
					<td style="width:30%">Hormat Kami</td>
                  </tr>

				 
                </table>
            </div>
          </div><!-- /.col -->
          <div class="col-xs-4">
            <div class="table-responsive">
                <table class="table">
                  <tr>
                    <td style="width:70%">&nbsp;</td>
					<?php
						$grand = format_rupiah(mysql_result(mysql_query("select sum(qty*(harga - (harga * disc / 100))) from belidetail where billno = $inv "),0));
						echo"<td align ='right'>&nbsp;</td>";
					?>
                  </tr>
				 
                </table>
            </div>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </section><!-- /.content -->
    </div><!-- ./wrapper -->

    <!-- AdminLTE App -->
	<style>

    body {
      font-family:Courier New;
	  font-weight: bold;
    }
	th {
		border-top: 1px solid black;
		border-bottom: 1px solid black;
	}
    </style>

  </body>
</html>
