<?php 
  session_start();
  error_reporting(0);
  ?>
<head>
<title>Print Nota - Optik Minang Solok</title>
<style>
.input1 {
	height: 20px;
	font-size: 12px;
	padding-left: 5px;
	margin: 5px 0px 0px 5px;
	width: 97%;
	border: none;
	color: red;
}
table {
	border: 1px solid #cecece;
}
.td {
	border: 1px solid #cecece;
}
#kiri{
width:100%;
float:left;
}

#kanan{
width:50%;
float:right;
padding-top:20px;
margin-bottom:9px;
}
</style>
</head>

<body onload="window.print()">
<?php 
  include "../config/koneksi.php";
  include "../config/fungsi_indotgl.php";
  include "../config/class_paging.php";
  include "../config/library.php";
  include "../config/fungsi_rupiah.php";

  $tampil=mysql_query("SELECT * FROM rb_pemesan_temp where id_orders='$_GET[id]'");
  $pt=mysql_fetch_array($tampil);
  
echo "<center>
				<table style='border:none; width:80%'>
				<tr><td rowspan='4' style='width:92px'><img style='width:90px' src='../view/logo.jpg'></td></tr>
				<tr><td colspan=3><h2>OPTIK MINANG & CO</h2></td></tr>
				<tr>
					<td valign=top>Pusat </td><td width=10px> : </td><td> Jl.K.H. Ahmad Dahlan No 140 B Solok<br> Telp (0755) 21060</td>
				</tr>
				<tr>
					<td valign=top>Cabang </td><td> : </td><td> Padang - Bukit Tinggi - Batusangkar - Sei. Rumbai</td>
				</tr>
				</table></center><hr/>

			<h2 align=center>NOTA PESANAN</h2>	
		  <div id='kiri'>
		  	<span style='float:right'>Tgl. ................. 20.......</span>
		    <table style='border:none;' width=100%><br/>
			  <tr><td><b>No Ref</b></td>     <td>: &nbsp;$pt[no_ref]</td></tr>
			  <tr><td><b>Pemesan</b></td>     <td>: &nbsp;$pt[nama_pemesan]</td></tr>
			  <tr><td width='130px;'><b>Alamat</b></td>       <td>: &nbsp;$pt[alamat]</td></tr>
			</table>
		  </div>";

	echo " <br/><table cellpadding=2 width=100% border:1px>
          <tr bgcolor='#000' style='color:#fff'>
				<th>No</th>
				<th>Nama Produk</th>
				<th>Jumlah</th>
				</tr>";
	$no =1;
    $tampill = mysql_query("SELECT a.jumlah, a.diskon, b.nama_produk, b.harga  FROM  rb_orders_temp a left join rb_produk b on a.id_produk=b.id_produk where a.id_session='$_SESSION[namauser]'");
    while($s=mysql_fetch_array($tampill)){
    $subtotal_rp = format_rupiah(($s[harga] * $s[jumlah]) - $s[diskon]);
    $harga       = format_rupiah($s[harga]);
      echo "<tr bgcolor=$warna><td class='td'>$no</td>
                <td class='td'>$s[nama_produk]</td>
				<td class='td'>$s[jumlah] </td>
				<td class='td'></td>
				<td class='td'></td></tr>";
	$no++;			
	}
			$tot = mysql_fetch_array(mysql_query("SELECT a.id_session, sum((a.jumlah*b.harga) - a.diskon) as total FROM  rb_orders_temp a left join rb_produk b on a.id_produk=b.id_produk where a.id_session='$_SESSION[namauser]'"));
			$sqllo=mysql_query("SELECT * FROM rb_bayar_temp where id_orders='$_GET[id]'");
			$bc=mysql_fetch_array($sqllo);																		
			$hutang = ($bc[bayar_inst] + $bc[jml_bayar] + $bc[diskon]) - $tot[total];

	echo "<tr>
			<td class='td' colspan=4 align=right>Sub Total Rp.</td>
			<td class='td' colspan=5 align=right>".format_rupiah($tot[total]-$bc[diskon])."</td>
		  </tr>
		  <tr>
			<td class='td' colspan=4 align=right>Bayar Instansi Rp.</td>
			<td class='td' colspan=5 align=right>".format_rupiah($bc[bayar_inst])."</td>
		  </tr>
		  <tr>
			<td class='td' colspan=4 align=right>Jumlah Bayar Rp.</td>
			<td class='td' colspan=5 align=right>".format_rupiah($bc[jml_bayar])."</td>
		  </tr>
		  <tr>
			<td class='td' colspan=4 align=right>Sisa Rp.</td>
			<td class='td' colspan=5 align=right>".format_rupiah($hutang)."</td>
		  </tr>";
		  $user = mysql_fetch_array(mysql_query("SELECT b.nama_lengkap FROM rb"));
	    echo "</table>
	<tr><td><br/><span style='float:right; text-align:center;'> Optik Minang Solok, $tgl_sekarang <br/>
										Karyawan<br/></br></br>
								(.............................................)
								<br/>$_SESSION[namalengkap]</span></td></tr>";
?>