@extends('layout')


@section('content')

<div class="page-header page-header-default">
	<div class="breadcrumb-line">
		<ul class="breadcrumb">
			<li><a href="index.html"><i class="icon-home2 position-left"></i> Inventori</a></li>
			<li class="active">Stock Opname</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Form Stock Opname</h5>
			<div class="heading-elements">
				<ul class="icons-list">
		      		<li><a data-action="collapse"></a></li>
		      	</ul>
	       	</div>
	    </div>
	    <div class="panel-body">
	    	<form class="form-horizontal" action="#" method="post" autocomplete="off">
	    	<input type="hidden" name="_token" value="{{ csrf_token() }}">
	    	<input type="hidden" name="id_opname" value="{{$data['data']['id_opname']}}">
	    	<table class="table table-stripped">
	    		<tr>
	    			<td width="20%">Tanggal</td>
	    			<td width="5%">:</td>
	    			<td>{{ $data['data']['tanggal'] }}</td>
	    		</tr>
	    		<tr>
	    			<td width="20%">Gudang</td>
	    			<td width="5%">:</td>
	    			<td>{{ $data['data']['nama_gudang'] }}</td>
	    		</tr>
	    		<tr>
	    			<td width="20%">Keterangan</td>
	    			<td width="5%">:</td>
	    			<td>{{ $data['data']['keterangan'] }}</td>
	    		</tr>
	    	</table>
        	
        	<div class="col-sm-6">
				    		
        	</div>

        	
        	<div class="col-sm-12 form-group">
        	<h5 class="panel-title">Detail Barang</h5>
        	<div class="col-ms-12 table-responsive">
        	<table class="table table-stripped dataTable">
	    	<thead>
				<tr>
					<th>No</th>
					<th>Kode Barang</th>
					<th>Nama Barang</th>
					<th>Gudang</th>
					<th>Stok</th>
					<th>Fisik</th>	
					<th>Selisih</th>
					<th>Ket.</th>
					<th>Satuan Konversi</th>
								<th>Satuan</th>
								<th>Kualitas Proses</th>
								<th>Warna</th>
								<th>Corak</th>
								<th>Motif</th>
								<th>Kualitas</th>
								<th>Dudulan</th>
								<th>Kualitas Periksa</th>
								<th>Label</th>
								<th>Cap</th>
								<th>Kemasan</th>
								<th>Kemasan Satuan</th>
								<th>Kemasan 10 Potong</th>
								<th>Kemasan Dus Ball</th>		
				</tr>
			</thead>
			<tbody id="table_fisik_detail">
				
			</tbody>
	    </table>
        	</div>
        	
             <div class="col-md-6"></div>
             <br>
             <div class="col-md-12">
             	<a href="{{url('opname')}}" class="btn bg-warning-400">Kembali</a>
             <div class="form-group pull-right">
             </div>
         </div>
	    </div>
	    </form>
	</div>
</div>


<script type="text/javascript">
	$("#btn_tambah_item").click(function(){
		$("[name=popup_id]").val('');
		$("[name=popup_kode]").val(null).trigger('change');
		$("[name=popup_ddd_stok]").text('');
		$("[name=popup_stok]").val('');
		$("[name=popup_fisik]").val('');
		$("[name=popup_ddd_selisih]").text('');
		$("[name=popup_selisih]").val('');
		$("[name=popup_ket]").val('');

		$("#exampleModal").modal('show');
	})
	var table;
	var tb_no = parseInt(10000);
	$(document).ready(function(){
		table = $(".dataTable").DataTable();
		table.on( 'order.dt search.dt', function () {
            table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                cell.innerHTML = i+1;
            } );
        } ).draw();
        
        id = '{{ $data['data']['id_opname']}}';
		if(id != ''){
			get_edit(id);
		}
		

		// get_jum();
	})

	function get_edit(id){
		$.ajax({
			url: "{{ url('opname/get_edit')}} ",
			type: 'post',
			data: {id : id},
			headers : {
				'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
			},
			success: function(respon){

				if(respon.length > 0){
					for(i in respon){
						console.log(respon[i].id_opname_barang);
						table.row.add(['<div><center></center></div>',
							'<div id="list_kode'+respon[i].id_opname_barang+'">'+respon[i].kode_barang+'</div>',
							'<div id="list_nama'+respon[i].id_opname_barang+'">'+respon[i].nama_barang+'</div>',
							'<div id="list_gudang'+respon[i].id_opname_barang+'">'+respon[i].nama_gudang+'</div>',
							'<div id="list_stok'+respon[i].id_opname_barang+'">'+respon[i].jumlah_stok+'</div>',
							'<div id="list_fisik'+respon[i].id_opname_barang+'">'+respon[i].jumlah_opname+'</div>',
							'<div id="list_total'+respon[i].id_opname_barang+'">'+respon[i].jumlah_selisih+'</div>',
							'<div id="list_ket'+respon[i].id_opname_barang+'">'+respon[i].keterangan+'</div>',
							'<div id="list_rencanajumlah'+respon[i].id_opname_barang+'">'+respon[i].jumlah_rencana+'</div>',
							'<div id="list_namajumlah'+respon[i].id_opname_barang+'">'+respon[i].nama_perubahansatuan+'</div>',
							'<div id="list_kualitas_proses'+respon[i].id_opname_barang+'">'+respon[i].nama_kualitas_proses+'</div>',
							'<div id="list_warna'+respon[i].id_opname_barang+'">'+respon[i].nama_komposisi+'</div>',
							'<div id="list_corak'+respon[i].id_opname_barang+'">'+respon[i].nama_corak+'</div>',
							'<div id="list_motif'+respon[i].id_opname_barang+'">'+respon[i].nama_motif+'</div>',
							'<div id="list_kualitas'+respon[i].id_opname_barang+'">'+respon[i].nama_kualitas+'</div>',
							'<div id="list_dudulan'+respon[i].id_opname_barang+'">'+respon[i].kualitas_dudul+'</div>',
							'<div id="list_kualitas_periksa'+respon[i].id_opname_barang+'">'+respon[i].nama_kualitas_periksa+'</div>',
							'<div id="list_label'+respon[i].id_opname_barang+'">'+respon[i].nama_label+'</div>',
							'<div id="list_cap'+respon[i].id_opname_barang+'">'+respon[i].nama_cap+'</div>',
							'<div id="list_kemasan'+respon[i].id_opname_barang+'">'+respon[i].nama_kemasan+'</div>',
							'<div id="list_kemasansatuan'+respon[i].id_opname_barang+'">'+respon[i].nama_kemasansatuan+'</div>',
							'<div id="list_kemasansepuluh'+respon[i].id_opname_barang+'">'+respon[i].nama_kemasansepuluh+'</div>',
							'<div id="list_kemasanseratus'+respon[i].id_opname_barang+'">'+respon[i].nama_kemasanseratus+'</div>'
							]).draw(false);
					}

					
				}
				
			}
		})
	}
</script>

@endsection