@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">Transfer Antar Gudang</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Form Transfer Antar Gudang</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_gudang" value="{{ $data['data']->id_transfergudang}}">

	    		<table class="table table-stripped">
	    			<tr>
	    				<td width="20%">Label CV</td>
	    				<td width="5%">:</td>
	    				<td>{{ ($data['data']->is_cv == '1') ? 'Ya':'Tidak' }}</td>

	    				<td width="20%">Gudang Awal</td>
	    				<td width="5%">:</td>
	    				<td>{{ $data['data']->gudang_awal }}</td>
	    			</tr>
	    			<tr>
	    				<td width="20%">Tanggal Permintaan</td>
	    				<td width="5%">:</td>
	    				<td>{{ tgl_full($data['data']->tanggal_minta, '') }}</td>

	    				<td width="20%">Gudang Tujuan</td>
	    				<td width="5%">:</td>
	    				<td>{{ $data['data']->gudang_tujuan }}</td>
	    			</tr>
	    			<tr>
	    				<td width="20%">Nomor Permintaan</td>
	    				<td width="5%">:</td>
	    				<td>{{ $data['data']->nomor_minta }}</td>

	    				<td colspan="3"></td>
	    			</tr>
	    			<tr>
	    				<td width="20%">Tanggal</td>
	    				<td width="5%">:</td>
	    				<td>{{ tgl_full($data['data']->tanggal, '') }}</td>

	    				<td colspan="3"></td>
	    			</tr>
	    			<tr>
	    				<td width="20%">Nomof Faktur</td>
	    				<td width="5%">:</td>
	    				<td>{{ $data['data']->no_faktur.$data['data']->faktur }}</td>

	    				<td colspan="3"></td>
	    			</tr>
	    			
	    		</table>
	    		
	    		<div class="col-sm-12">
	    			<div class="panel panel-primary">
                
                	</div>
	    			<div class="table-responsive">
		            <table class="table datatable-basic table-stripped" id="table_barang">
			    	<thead>
						<tr>
								<th>No</th>
								{{-- <th>No. Spk</th> --}}
								<th>No. Order</th>
								<th>Kode Barang</th>
								<th>Nama Barang</th>
								<th>Proses</th>
								<th>Warna</th>
								<th>Gudang</th>
								<th>Jumlah</th>
								<th>Satuan</th>
								<th>Satuan Konversi</th>
								<th>Satuan</th>
								<th>Kualitas Proses</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>
								<th>Keterangan</th>
						</tr>
					</thead>
					<tbody>
						
					</tbody>
			    </table>
			</div>
	    		</div>
	    		<div class="col-md-6"></div>
	    		<div class="col-sm-6">
	    		</div>
	    	<div class="col-sm-12">
	    		<a href="{{url('transfergudang')}}" class="btn bg-warning-400">Kembali</a>
	    		<div class="form-group pull-right">
             </div>
         </div>
	    	</form>
	    	
	    		</div>
	    </div>

	</div>
</div>


<!----Modal---->
<script type="text/javascript">
	$("#btn_tambah_item").click(function(){
		$("[name=popup_id]").val('');
		$("[name=popup_kode]").val(null).trigger('change');
		$("[name=popup_jumlah]").val('');
		$("[name=popup_stok]").text('');

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

		
		id = '{{ $data['data']->id_transfergudang }}';
		if(id != ''){
			get_edit(id);
		}

		get_jum();

		var id_gudang = '{{ $data['data']->gudang_awal }}';
		if(id_gudang != ''){
			$("[name=gudang_awal]").val(id_gudang).trigger('change');
		}
	})


	function get_jum(){
		var jum = parseInt(0);
		$('div[id^="list_jumlah"]').each(function() {
              // alert($(this).val());
              var val = ($(this).text());
              jum += parseInt(val);
              
            });
		$("#td_total").text(jum);
		$("[name=total]").val(jum);
	}

	function get_edit(id){
		$.ajax({
			url: "{{ url('transfergudang/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){
						table_barang.row.add(['<div><center></center></div>',
							// '<div id="list_spk'+respon[i].id+'">'+respon[i].no_spk+'</div>',
							'<div id="list_workorder'+respon[i].id+'">'+respon[i].no_workorder+'</div>',
							'<div id="list_kode'+respon[i].id+'">'+respon[i].kode_barang+'</div>',
							'<div id="list_nama'+respon[i].id+'">'+respon[i].nama_barang+'</div>',
							'<div id="list_proses'+respon[i].id+'">'+respon[i].nama_proses+'</div>',
							'<div id="list_warna'+respon[i].id+'">'+respon[i].nama_komposisi+'</div>',
							'<div id="list_gudang'+respon[i].id+'">'+respon[i].nama_gudang+'</div>',
							'<div id="list_jumlah'+respon[i].id+'">'+respon[i].jumlah+'</div>',
							'<div id="list_satuan'+respon[i].id+'">'+respon[i].nama_satuan+'</div>',
							'<div id="list_rencanajumlah'+respon[i].id+'">'+respon[i].jumlah_rencana+'</div>',
							'<div id="list_namajumlah'+respon[i].id+'">'+respon[i].nama_perubahansatuan+'</div>',
							'<div id="list_kualitas_proses'+respon[i].id+'">'+respon[i].nama_kualitas_proses+'</div>',
							'<div id="list_corak'+respon[i].id+'">'+respon[i].nama_corak+'</div>',
							'<div id="list_motif'+respon[i].id+'">'+respon[i].nama_motif+'</div>',
							'<div id="list_kualitas'+respon[i].id+'">'+respon[i].nama_kualitas+'</div>',
							'<div id="list_dudulan'+respon[i].id+'">'+respon[i].nama_dudul+'</div>',
							'<div id="list_kualitas_periksa'+respon[i].id+'">'+respon[i].nama_kualitas_periksa+'</div>',
							'<div id="list_label'+respon[i].id+'">'+respon[i].nama_label+'</div>',
							'<div id="list_cap'+respon[i].id+'">'+respon[i].nama_cap+'</div>',
							'<div id="list_kemasan'+respon[i].id+'">'+respon[i].nama_kemasan+'</div>',
							'<div id="list_kemasansatuan'+respon[i].id+'">'+respon[i].nama_kemasansatuan+'</div>',
							'<div id="list_kemasansepuluh'+respon[i].id+'">'+respon[i].nama_kemasansepuluh+'</div>',
							'<div id="list_kemasanseratus'+respon[i].id+'">'+respon[i].nama_kemasanseratus+'</div>',
							'<div>'+respon[i].keterangan+'</div>'
							]).draw(false);
					}

					get_jum();
				}
			

			}
		})
	}




	
</script>
@endsection