<style type="text/css">
*{
font-family: Arial;
margin:0px;
padding:0px;
}
@page {
 margin-left:0.5cm 0.2cm 0.2cm 0.2cm;
}
table.grid{
width:7.5cm ;
font-size: 12px;
border-collapse:collapse;
}
table.grid th{
	padding:5px;
}
table.grid th{
background: #F0F0F0;
border-top: 0.2mm solid #000;
border-bottom: 0.2mm solid #000;
text-align:center;
border:0px solid #000;
}
table.grid tr td{
	padding:2px;
	border-bottom:0.2mm solid #000;
	border:0px solid #000;
}
h1{
font-size: 18px;
}
h2{
font-size: 14px;
}
h3{
font-size: 12px;
}
p {
font-size: 10px;
}
center {
	padding:8px;
}
.atas{
display: block;
width:7.5cm ;
margin:0px;
padding:0px;
}
.kanan tr td{
	font-size:12px;
}
.attr{
font-size:9pt;
width: 100%;
padding-top:2pt;
padding-bottom:2pt;
border-top: 0.2mm solid #000;
border-bottom: 0.2mm solid #000;
}
.pagebreak {
width:7.5cm ;
page-break-after: always;
margin-bottom:10px;
}
.akhir {
width:7.5cm ;
font-size:13px;
}
.page {
width:7.5cm ;
font-size:12px;
padding:10px;
}

</style>
<?php

$kiri = '<h2>'.$instansi.'</h2>';
$kiri .= '<p>'.$kop_struk.'</p>';
$ksr=$this->session->userdata('nama_lengkap');

$kanan = "<table class='kanan' width='100%'>
		 
		  <tr>
		  	<td >No</td>
			<td width='5'>:</td>
			<td><b>$kode_jual</b></td>
		  </tr>
		  <tr>
		  	<td>Tgl</td>
			<td width='5'>:</td>
			<td>$tgl_jual</td>
		  </tr>
		  <tr>
		  	<td>Cust</td>
			<td width='5'>:</td>
			<td>$customer</td>
		  </tr>
		  <tr>
		  	<td>Ksr</td>
			<td width='5'>:</td>
			<td>$ksr</td>
		  </tr>
		  </table>";

function myheader($kiri,$kanan,$judul){
?>
<div class="atas">
<table width="109%">
<tr>
	<td width="60%" align="center" valign="top" bgcolor="#F7F7F7">
   		<?php echo $kiri;?>
    </td>
</tr>
<tr>
	<td width="60%" valign="top" align="center">
   		<?php echo $kanan;?>
    </td>
</tr> 
   
</table>
<center><h2><?php echo $judul;?></h2></center>
</div>
<table class="grid" width="100%">
	<tr>
        <th width="150">Nama Barang</th>
        <th width="20">Jml</th>
        <th width="50">Hrg@</th>
        <th width="50">Subtot</th>
	</tr>        
<?php
}
function myfooter(){	
	echo "</table>";
}
	$g_total=0;
	$no=1;
	$page =1;
	foreach($data->result_array() as $r){
	$total = $r['jmljual']*$r['hargajual'];
	if(($no%25) == 1){
   	if($no > 1){
        myfooter();
        echo "<div class=\"pagebreak\" align='right'>
		<div class='page' align='center'>Hal - $page</div>
		</div>";
		$page++;
  	}
   	myheader($kiri,$kanan,$judul);
	}
	?>
    <tr>
        <td ><?php echo '# '.$r['kode_barang'].' / '.$r['nama_barang'];?></td>
        <td align="center"><?php echo $r['jmljual'];?></td>
        <td align="right"><?php echo number_format($r['hargajual']);?></td>
        <td align="right"><?php echo number_format($total);?></td>
    </tr>
    <?php
	$no++;
	$g_total = $g_total+$total;
	}
	echo "<tr>
			<td colspan='3' align='center'>Total</td>
			<td align='right'>".number_format($g_total)."</td>
		</tr>";
myfooter();	
	echo "</table>";
	echo "	<font size=2px><left>Semoga Lekas Sembuh.
			</br> Hati yang gembira adalah obat.</left></font>";
?>
	
