<head>
    <style>
        #tblisi th { border-bottom:1px black solid; }
    </style>
</head>

@extends('layouts.print')

@section('title')
    Stock Opname &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 stock opname</li>
@endsection

@section('content')

<center>
	<h4>Stock Opname</h4>
</center>


<table style="width:98%" id='tblheader'>
	<tr><td width="600"><b>{{ $gdg->nama." - [".$gdg->kode."]" }}</b></td><td width="350"></td></tr>
	<tr><td>Tgl.Opname: {{ tanggal_indonesia($opn->opn_tgl, false) }}</td><td></td></tr>
</table>
<br>

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

<tr border="1">
	<th width="250">DESKRIPSI</th>
	<th width="50" class="text-right">QTY OPN</th>
	<th width="50" class="text-right">STOCK</th>
	<th width="50" class="text-right"> +/-</th>
	<th width="100" class="text-right">Keterangan</th>
</tr>

@foreach ($dt as $list)
	
	<tr>
    	<td>{{ $list->product_name }}</td>
    	<td align="right">{{ number_format($list->opn_qty) }}</td>
    	<td align="right">{{ number_format($list->sisa_stock) }}</td>
    	<td align="right">{{ number_format($list->opn_qty - $list->sisa_stock) }}</td>
    	<td></td>
    </tr>
	
@endforeach
<tr><td></td>
	<td></td>
	<td></td>

</tr>

</table>

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


<table style="width:80%">
    <tr>
        <td width="50"></td><td>Checker</td>
		<td width="250"></td><td>Mengetahui</td>
	</tr>
	<tr>
		<td>&nbsp;</td><td></td>
	    <td>&nbsp;</td><td></td>	
	</tr>
	<tr>
		<td>&nbsp;</td><td></td>
	    <td>&nbsp;</td><td></td>	
	</tr>

</table>

<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");
                	};                    
                }
                    
                //ocation.reload();
        
            },
            error : function(){
                alert("error print...");
            }
        });
    }

</script>
