<!DOCTYPE html>
<html>
@extends('layouts.app')

<head><meta http-equiv="Content-Type" content="text/html; charset=utf-8">

	<!--
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
	<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
	
	<script type="text/javascript" src="/wawan/public/adminLTE/dist/css/sweetalert.min.js"></script>
	-->
	
	<style>
		    #tbl-adjust th,tr,td { border-bottom: 1px black solid;}
		    
			.tbl_stn {
			    position:absolute;
				top: 110px;
				left: 240px;
				width: 355px;
				height: 520px;
			    //border: 1px solid #543535;
			}				

			.tbl_kms {
			    position:absolute;
				top: 110px;
				right: 10px;
				width: 730px;
				height: 520px;
				//border: 1px solid #543535;
			}	
			
			.wrap {
			  width: 50%;
			  display: inline-block;
			  margin: 10px;
			}
			
		
			.tblheader {
				background: #2F4F4F;
				color: white;
				font-size: 15px;
				alignment: center;
			}

	</style>


</head>

@section('breadcrumb')
    @parent
    <li>data adjustment</li>
@endsection

<!------------------>

@section('content')
<div class="row">
    
<form class="form-horizontal" data-toggle="validator" method="post" id="form-adjust">
{{ csrf_field() }} {{ method_field('POST') }}
    
    <div class="container-fluid">
        <div class="card">
            <div class="card-block">
                
    <!--a onclick="sisastock()" class="btn btn-info btn-sm pull-right"><i class="fa fa-print"></i> Print Sisa Stock</a--> 

            
    <table class="table table-striped table-padding" id="tbl-adjust" width="100%">
        <thead>
            <tr class="tblheader">
                <th width="30">GDG</th>
                <th width="70">Tgl.Adj</th>
                <th width="30">KODE</th>
                <th>Nama Barang</th>
        	    <th width="100">QTY Adjust</th>                
                <th>Deskripsi</th>
                	  
         	</tr>
        </thead>
        
        <tbody></tbody>	 
    
    </table>
    
            </div>
        </div>
    </div>
</form>

</div>

@endsection


<!-------------------------------->

@section('script')

<script type="text/javascript">
var table,  save_method;
    
showData();    

function showData(){
    
	jQuery(document).ready(function($){
	table = $('#tbl-adjust').DataTable({
        "processing" : true,
        "lengthMenu": [[8, 25, 50, -1], [8, 25, 50, "All"]],
        "order": [[ '1', 'DESC']],
	    //"dom" : 'btfip',	 
        "ajax" : {
            "url" : "{{ DIR_APP }}stock/dataadjust",
            "type" : "GET"
            }
        });
    });
}


function printformopname(){
        
    var gdg = $('#gudang').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 }}stock/"+gdg+"/printform",
        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...");
        }
    });
}


function kartuStock(){
    
    var id=$('#idstock').val();
    var tgl1=$('#awal').val();
    var tgl2=$('#akhir').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 }}stock/"+id+"/"+tgl1+"/"+tgl2+"/kartustock",
        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...");
        }
    });    
}

function sisastock(){
    
    var gdg = $('#gudang').val();
    $('#form-stock').attr('action', "{{ DIR_APP }}stock/"+gdg+"/reportstock").submit();       //--> open new windows
    //location.reload();
}

</script>

@endsection
</html>