<head>
    <style>
        #tblisi th { border-bottom:1px black solid; }
        .pheader { font-size:23px; color:green; font-weight:bold; }
    </style>
</head>

@extends('layouts.print')

@section('title')
    Cetak PO &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

  	<a onclick="window.location='{{ route('home') }}'" class="btn btn-primary"><i class="fa fa-home"></i> Home </a>
	<a onclick="window.history.go(-1)" class="btn btn-warning"><i class="fa fa-undo"></i> Back </a> 
	<a onclick="myFunction()" class="btn btn-success"><i class="fa fa-print"></i>Print Dokumen</a>
    <!--a onclick="printmatrix()" class="btn btn-success"><i class="fa fa-print"></i>Print Faktur</a-->

    <script>
        function myFunction() {
          window.print();
        }
    </script>
@endsection

@section('breadcrumb')
   @parent
     <li>print PO</li>
@endsection

@section('content')

<input type="hidden" id="idpo" name="idpo" value="{{ $mpo->id }}">
<br>

<img src="{{ DIR_APP }}kwitansi.png" width="95px" />
<div style="margin-top:-100px">
    <center>
    <p class="pheader">PT. SUKSES WIJAYA ADIKARYA</p>
    <h4>Jl. Residen Abdul Rozak, Lrg Lebak Sebatok Kota Palembang</h4>
    <h4>Email: sukseswijayaadikaryapt2@gmail.com</h4>
    </center>
</div>
<hr>

<center>
    <h4><b>PURCHASE ORDER</b></h4>
    <h4><b>{{ $mpo->po_no }}</b></h4>
</center>

<div style="font-size:15px">
Palembang, {{ tanggal_indonesia($mpo->po_tgl, false) }}<br>
&nbsp;<br>
Kepada Yth:<br>
{{ $sup->sup_nama }}<br>
{{ $sup->sup_alamat.' '.$sup->get_city->city_name }}
</div>
<br>

<div style="font-size:15px">Bersama ini kami sampaikan pesanan barang:</div>

<table cellspacing="5" cellpadding="5"  style="width:98%;" id="tblisi">

<tr border="1">
    <th width="50">NO</th>
	<th width="200">DESKRIPSI</th>
	<th width="80" class="text-right">---QTY---</th>
	<th width="80" class="text-right">Harga</th>
	<th width="80" class="text-right">DISC</th>
	<th width="100" class="text-right">Jumlah</th>
</tr>

@foreach ($dt as $list)
	
	<tr>
	    <td>{{ $no++ }}</td>
    	<td>{{ $list->product_name }}</td>
    	<td align="right">{{ format_uang($list->qty).' '.$list->satuan }}</td>
    	<td align="right">{{ format_uang($list->harga) }}</td>
    	<td align="right">{{ format_uang($list->disc_1) }}</td>
    	<td align="right">{{ format_uang(($list->qty*$list->harga)-($list->qty*$list->harga*$list->disc_1/100)) }}</td>
    </tr>
	
@endforeach
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>	
	<td align="left">Sub Total</td>
	<td align="right"><b>{{ format_uang($sub) }}</b></td>
</tr>

<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>	
	<td align="left">Disc.{{ $mpo->po_disc.'%' }}</td>
	<td align="right"><b>{{ format_uang($dis) }}</b></td>
</tr>
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>	
	<td align="left">PPN  {{ $mpo->po_ppn.'%' }}</td>
	<td align="right"><b>{{ format_uang($ppn) }}</b></td>
</tr>
<tr>
	<td></td>
	<td></td>
	<td></td>
	<td></td>	
	<td align="left">Grand Total</td>
	<td align="right"><b>{{ format_uang($ttl) }}</b></td>
</tr>

</table>

<table style="margin-top:-50px;">
    <th width="20"></th><th width="450"></th>
    <tr><td>&nbsp;</td><td>Pesanan dikirim ke:</td><td></td></tr>
    <tr><td></td><td><li>{{ $gdg->nama }}</li></td></tr>
    <tr><td></td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{{ $gdg->alamat }}</td></tr>
    <tr><td></td><td><li>{{ $mpo->deskripsi }}</li></td></tr>
</table>

<hr>

<table>
    <th width="450"></th><th widt="350"></th>
    <tr><td>&nbsp;</td><td>Palembang, {{ tanggal_indonesia($mpo->po_tgl, false) }}</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td></tr>
    <tr><td>&nbsp;</td><td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Direktur</td></tr>
</table>

<!--style="width:96%; margin-top:5px; margin-bottom:5px; background-color: black; height: 1px; border:1;"-->

<p></p>
@endsection

<script type="text/javascript">
    
    function printmatrix(){
        
        var idinv = $('#idinv').val();
        
        var ua = navigator.userAgent.toLowerCase();
        var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
                	
        if(isAndroid) {
            var tpdevice='android';
        }else{
            var tpdevice='pclaptop';
        }
            
        $.ajax({
            url : "{{ DIR_APP }}invoice/"+idinv+"/printfaktur_matrix",
            type : "GET",
            dataType : "JSON",
            success : function(data){
                if(tpdevice=='android'){
                    window.location.href=data.data;
                }else{
                	var socket = new WebSocket("ws://127.0.0.1:40213/");        /* harus dijalankan dulu dari rawbt.bat */
                    socket.bufferType = "arraybuffer";
                    socket.onerror = function(error) {
                	    alert("Error");
                    };			
                	socket.onopen = function() {
                		socket.send(data.data);
                		socket.close(1000, "Work complete");
                	};                    
                }

            },
            error : function(){
                alert("error print...");
            }
        });
    }

</script>
