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

@extends('layouts.print')

@section('title')
    Jurnal Harian &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>jurnal transaksi</li>
@endsection

@section('content')

<center>
	<h4>Jurnal Transaksi</h4>
	<h4>{{ tanggal_indonesia( $tgl, false) }}</h4>
</center>

@if($adainv>0)
    <table cellspacing="5" cellpadding="5"  style="width:100%;" id="tblisi">
<hr>        
    <h4>PEMBELIAN</h4>
    <tr border="1">
    	<th width="300">DESKRIPSI</th>
    	<th width="150" class="text-left">No.Dokumen</th>
    	<th width="100" class="text-center">J.Tempo</th>
    	<th width="100" class="text-right">Nominal</th>
    	<th width="10"></th>
    	<th width="100" class="text-left">Notes</th>
    </tr>
    
    @foreach ($inv as $list)
    	<tr>
    	   	<td width="300">Pembelian {{ $list->get_supplier->sup_nama }}</td>
        	<td>{{ $list->inv_no }}</td>
        	<td align="center">{{ tanggal_indonesia($list->inv_jt, false) }}</td>
        	<td align="right">{{ format_uang($list->inv_netto) }}</td>
        	<td></td>
        	<td></td>
        </tr>
    @endforeach
    </table>
@endif

@if($adasale>0)
    <table cellspacing="5" cellpadding="5"  style="width:100%;" id="tblisi">
<hr>        
    <h4>PENJUALAN</h4>
    <tr border="1">
    	<th width="300">OUTLET</th>
    	<th width="120" class="text-left">No.Faktur</th>
    	<th width="100" class="text-center">J.Tempo</th>
    	<th width="100" class="text-right">Nominal</th>
    	<th width="5"></th>
    	<th width="80">Sales</th>
    	<th width="80" class="text-left">Notes</th>
    </tr>    
    
    @foreach ($sale as $list)
    	
    	<tr>
    	   	<td width="300">{{ $list->get_customer->cus_name }}</td>
        	<td>{{ $list->sale_no }}</td>
        	<td align="center">{{ tanggal_indonesia($list->sale_jt, false) }}</td>
        	<td align="right">{{ format_uang($list->sale_netto) }}</td>
        	<td></td>    	
        	<td>{{ $list->get_sales->sales_name }}</td>
        	@if($list->is_batal==1)
        	    <td>Batal</td>
        	@else
        	    <td></td>
            @endif    	
        </tr>
    	
    @endforeach
    </table>
@endif


@if($adartr>0)
    <table cellspacing="5" cellpadding="5"  style="width:100%;" id="tblisi">
<hr>        
    <h4>RETUR PENJUALAN</h4>
    <tr border="1">
    	<th width="300">OUTLET</th>
    	<th width="120" class="text-left">No.Faktur</th>
    	<th width="100" class="text-right">Nominal</th>
    	<th width="10"></th>
    	<th width="80" class="text-left">Notes</th>
    </tr>    
    
    @foreach ($rtr as $list)
    	
    	<tr>
    	   	<td width="300">{{ $list->get_customer->cus_name }}</td>
        	<td>{{ $list->rtr_no }}</td>
        	<td align="right">{{ format_uang($list->rtr_netto) }}</td>
        	<td></td> 
        	<td></td>
        </tr>
    	
    @endforeach
</table>
@endif

@if($adamts>0)
    <table cellspacing="5" cellpadding="5"  style="width:100%;" id="tblisi">
<hr>        
    <h4>MUTASI STOCK</h4>
    <tr border="1">
    	<th width="150">GUDANG ASAL</th>
    	<th width="120" class="text-left">No.Faktur</th>
    	<th width="150" class="text-left">GUDANG TUJUAN</th>
    	<th width="10"></th>
    	<th width="80" class="text-left">Notes</th>
    </tr>    
    
    @foreach ($mts as $list)
    	<tr>
    	   	<td>{{ $list->get_gudangasal->nama }}</td>
        	<td>{{ $list->mts_no }}</td>
        	<td>{{ $list->get_gudangtuju->nama }}</td>
        	<td></td> 
        	<td></td>
        </tr>
    @endforeach
</table>
@endif




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

</script>
