<?php 
/* APLIKASI PENJUALAN DPOS PRO
 *
 * Framework DPOS BISNIS berbasis PHP
 *
 * Developed by djavasoft.com
 * Copyright (c) 2018, Djavasoft Smart Technology
 *
 * @author	Mohamad Anton Arizal
 * @copyright	Copyright (c) 2008 Djavasoft. (https://djavasoft.com/)
 *
 *
*/

include'config.php';
function xdate($date){
	$date=explode('-',$date);	
	$date=$date[2].'-'.$date[1].'-'.$date[0];	
	return $date;
}

	$items=doTableArray("kasir_penjualan",array("kode_barang","nama_barang","harga","qty","total","faktur","satuan"),"WHERE status=2 AND faktur='".$_GET['faktur']."'");
	$faktur=doTableArray("faktur",array("date","pelanggan_id","total","pemasukan","diskon","voucher","dibayar","kembali","user_id","disc","pajak","pjk"),"where faktur='".$_GET['faktur']."'");
	$date= $faktur[0][0];
	$pelanggan_id= $faktur[0][1];
	$total= $faktur[0][2];
	$pemasukan= $faktur[0][3];
	$diskon= $faktur[0][4];
	$voucher= $faktur[0][5];
	$dibayar= $faktur[0][6];
	$kembali= $faktur[0][7];
	$userName= userName($faktur[0][8]);
	$disc= $faktur[0][9];
	$pajak= $faktur[0][10];
	$pjk= $faktur[0][11];

	if(intval($pelanggan_id) !='' || intval($pelanggan_id)!=0){
	$supplier=doTableArray("pelanggan",array("nama_pelanggan"),"where id='".intval($pelanggan_id)."'");
	$nama_pelanggan=$supplier[0][0];
	}else{
	$nama_pelanggan='-';
	}
	
	?>
	<html moznomarginboxes="" mozdisallowselectionprint=""><head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<title>	<?php echo getPengaturan('nama_toko');?> - Cetak Nota        </title>
	<style type="text/css">
	pre{
		font-weight:bold;
	}
	@media print {
	@page  { 
	margin: 0mm;
	font-size:8px;
	}
	}

	</style>
	</head>
	<body onload="window.print();" cz-shortcut-listen="true" >
<?php 
if($_GET['ukuran']=='58'){?>
<style type="text/css">
body{width: <?=$_GET['ukuran'];?>mm}
</style>
<b><?php echo getPengaturan('nama_toko');?></b><br><?php echo getPengaturan('alamat');?> <br>Telp. <?php echo getPengaturan('no_hp');?></b>
<pre>---------------------------------
<?php echo xDate($date);?>		<?php echo date("H:i:s");?><br><?php echo $_GET['faktur'];?>	<?php echo $userName;?>
<br>---------------------------------<br> Harga	Qty	Sat	Total<br>---------------------------------
<?php
$i=1;
foreach($items as $row){
echo ''.$row[1].'<br>';
echo ' '. currency($row[2]).'';
echo ' x ';
echo ''.$row[3].' '.$row[6].' ';
echo 'Rp.'. currency($row[4]).'<br>';
$i++; 	  
}   
?>
---------------------------------
<?php if(intval($diskon)!=0 OR intval($diskon)!=''){?>Harga	:	Rp.<?php echo currency($total);?><br>Diskon	:	Rp.<?php echo currency($diskon);?>(<?php echo $disc;?>%)<?php } ?><?php if(intval($voucher)!=0 OR intval($voucher)!=''){?><br>Voucher	:	Rp.<?php echo currency($voucher);?><?php } ?><?php if(intval($pjk)!=0 OR intval($pjk)!=''){?><br>Pajak	:	Rp.<?php echo currency($pajak);?>(<?php echo $pjk;?>%)<?php } ?><br>Total	:	Rp.<?php echo currency($pemasukan);?><br>Bayar	:	Rp.<?php echo currency($dibayar);?><br>	-------------------------<br>Kembali	:	Rp.<?php echo currency($kembali);?><br>=================================
	TERIMA KASIH
    ATAS KUNJUNGAN ANDA
<BR>
</pre>
<?php } elseif($_GET['ukuran']=='80'){
/////////////////////////////////////// UKURAN 80MM ////////////////////////////////////////////////////////
?>
<style type="text/css">
body{width: <?=$_GET['ukuran'];?>mm}
</style>
<b><?php echo getPengaturan('nama_toko');?></b><br><?php echo getPengaturan('alamat');?> <br>Telp/HP <?php echo getPengaturan('no_hp');?></b>
<pre>
--------------------------------------
<?php echo xDate($date);?>		<?php echo date("H:i:s");?><br><?php echo $_GET['faktur'];?>	<?php echo $userName;?>
<br>--------------------------------------<br> Harga	Qty	Sat	Total<br>--------------------------------------
<?php
$i=1;
foreach($items as $row){
echo ''.$row[1].'<br>';
echo ' '. currency($row[2]).'';
echo ' x ';
echo ''.$row[3].' '.$row[6].'	';
echo 'Rp.'. currency($row[4]).'<br>';
$i++; 	  
}   
?>
--------------------------------------
 <?php if(intval($diskon)!=0 OR intval($diskon)!=''){?>Harga		:	Rp.<?php echo currency($total);?><br> Diskon		:		Rp.<?php echo currency($diskon);?>(<?php echo $disc;?>%)<?php }?><?php if(intval($voucher)!=0 OR intval($voucher)!=''){?><br> Voucher		:		Rp.<?php echo currency($voucher);?><?php } ?><?php if(intval($pjk)!=0 OR intval($pjk)!=''){?><br> Pajak		:	Rp.<?php echo currency($pajak);?>(<?php echo $pjk;?>%)<?php } ?><br> Total		:	Rp.<?php echo currency($pemasukan);?><br> Bayar		:	Rp.<?php echo currency($dibayar);?><br>		----------------------<br> Kembali	:	Rp.<?php echo currency($kembali);?><br>======================================
	   TERIMA KASIH
	ATAS KUNJUNGAN ANDA
<BR>
</pre>

<?php }elseif($_GET['ukuran']=='A4'){ ?>
<link href="<?php echo $CORE_URL;?>/assets/adminLTE/css/bootstrap.min.css" rel="stylesheet">

<div class="title" style="margin-bottom:10px;text-align:left;margin-top:10px;margin-left:10px">
<b><?php echo getPengaturan('nama_toko');?></b>
<br>
<small><?php echo getPengaturan('alamat');?> Telp/HP <?php echo getPengaturan('no_hp');?></small>
</div>
<table class="table">
<tr>
<td style="width:150px">Tanggal</td><td style="width:30px">:</td><td><?php echo $date;?> <?php echo date('H:i:s');?> </td>
<td >Pelanggan</td><td style="width:30px">:</td><td><?php echo $nama_pelanggan;?></td>
</tr>
<tr>
<td style="width:150px">Faktur Penjualan</td><td>:</td><td><?php echo $_GET['faktur'];?></td>
<td style="width:150px"></td><td></td><td></td>
</tr>
</table>

<table class="table " id="dataPenjualan" cellspacing="0">
  <thead>
	<tr>
	  <th style="width:50px">No</th>
	  <th>Kode</th>
	  <th>Nama Barang</th>
	  <th>Harga</th>
	  <th>Qty</th>
	  <th >Total</th>
	</tr>
  </thead>
  <tbody >
  <?php
  $i=1;
	foreach($items as $row){
	  echo '<tr>';
	  echo '<td>'.$i.'</td>';
	  echo '<td>'.$row[0].'</td>';
	  echo '<td>'.$row[1].'</td>';
	  echo '<td>'. currency($row[2]).'</td>';
	  echo '<td>'.$row[3].'</td>';
	  echo '<td>'. currency($row[4]).'</td>';
	  echo '</tr>';
	  $i++; 	  
  }   
  ?>
<?php if(intval($voucher) != 0 || intval($voucher)!=''){?>  <tr><td colspan=3></td><td colspan=2><b>Voucher</td><td> : <?php echo currency(intval($voucher));?></td></tr><?php } ?>
<?php if(intval($ongkir) != 0 || intval($ongkir)!=''){?>  <tr><td colspan=3></td><td colspan=2><b>Ongkir</td><td> : <?php echo currency(intval($ongkir));?></td></tr><?php } ?>
<?php if(intval($diskon) != 0 || intval($diskon)!=''){?>  <tr><td colspan=3></td><td colspan=2><b>Diskon</td><td> : <?php echo currency(intval($diskon));?></td></tr><?php } ?>
  <tr><td colspan=3></td><td colspan=2><b>Total</b></td><td> : <?php echo currency($pemasukan);?></td></tr>
  <tr><td colspan=3></td><td colspan=2><b>Dibayar</b></td><td> : <?php echo  currency(intval ($dibayar));?></td></tr>
  <tr><td colspan=3></td><td colspan=2><b>Kembali</b></td><td> : <?php echo  currency(intval ($kembali));?></td></tr>
  </tbody>
  </table> 
<?php } ?>
	</body></html>
