@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> Produksi</a></li>
			<li class="active">Laporan Hasil</li>
		</ul>
	</div>
</div>

@php 
if($data['jenis'] == '1'){
    $submit = url('persetujuanmasuk/simpanmasuk');
    $input_id = "id_barangmasuk";
    $value = $data["data"]->id_barangmasuk;
    $detail_barang = 'id';
}else{
    $submit = url('persetujuanmasuk/simpanmasuk_kemasan');
    $input_id = "id_barangmasuk_kemasan";
    $value = $data["data"]->id_barangmasuk_kemasan;
    $detail_barang = 'id_barangmasuk_kb';
}
@endphp

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Form Laporan Hasil</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="{{ $submit }}" method="post" autocomplete="off">
	    	<input type="hidden" name="_token" value="{{ csrf_token() }}">
	    	<input type="hidden" name="{{ $input_id }}" value="{{ $value }}">
        	<div class="col-sm-6">
        		<div class="form-group">
                    <label class="control-label col-sm-4">Nomor</label>
                    <div class="col-sm-8"> 
                        <input type="text" name="nomor" value="{{ $data['data']->noAuto.$data['data']->noAuto_ext }}" class="form-control" readonly>
                    </div>
                </div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Tanggal</label>
        			<div class="col-sm-8">
        				<input class="form-control" type="text" name="tanggal" value="{{ date('d-m-Y', strtotime($data['data']->tanggal)) }}" readonly/>
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Tanggal Pengambilan</label>
        			<div class="col-sm-8">
        				<input class="form-control" type="text" name="tanggal" value="{{ date('d-m-Y', strtotime($data['data']->tanggal_pengambilan)) }}" readonly/>
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Tanggal Perkiraan Selesai</label>
        			<div class="col-sm-8">
        				<input class="form-control" type="text" name="tanggal_perkiraan" value="{{ date('d-m-Y', strtotime($data['data']->tanggal_perkiraan)) }}" readonly />
        			</div>
        		</div>
        		<div class="form-group">
					<label class="control-label col-sm-4">Status</label>
					<div class="col-sm-8"> @php $sta = $data['data']->status; @endphp
						<select class="form-control select-search" name="status">
							<option value="0" {{ ($sta == '0') ? "selected":"" }}>Belum Verifikasi</option>
							<option value="1" {{ ($sta == '1') ? "selected":"" }}>Verifikasi</option>
						</select>
					</div>
				</div> 
        	</div>
        	<div class="col-sm-6">
				<div class="form-group">
        			<label class="control-label col-sm-4">Rekanan</label>
        			<div class="col-sm-8">
        				<input type="text" name="tanggal" class="form-control" value="{{ $data['data']->nama_rekanan.' - '.$data['data']->nama_kelompok }}" readonly>
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Pegawai</label>
        			<div class="col-sm-8">
        				<input type="text" name="tanggal" class="form-control" value="{{ $data['data']->nama_pegawai }}" readonly>
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Mesin</label>
        			<div class="col-sm-8">
        				<input type="text" name="mesin" class="form-control" value="{{ $data['data']->nama_mesin }}" readonly>
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Proses Produksi</label>
        			<div class="col-sm-8">
        				<input type="text" name="proses" class="form-control" value="{{ $data['data']->nama_proses }}" readonly>
        			</div>
        		</div>       		
        	</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>Jumlah</th>
					<th>Warna</th>
					<th>Kualitas Produksi</th>
					<th>Corak</th>
					<th>Motif</th>
					<th>No. Order</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>
				@foreach($data['barang'] as $d) 
				<tr>
					<td></td>
					<td>{{ $d->kode_barang }}</td>
					<td>{{ $d->nama_barang }}</td>
					<td>{{ $d->nama_gudang }}</td>
					<td>{{ $d->jumlah }}</td>
					<td>{{ $d->nama_komposisi }}</td>
					<td>{{ $d->nama_kualitas_proses }}</td>
					<td>{{ $d->nama_corak }}</td>
					<td>{{ $d->nama_motif }}</td>
					<td>{{ $d->no_workorder_barang }}</td>
					<td>{{ $d->nama_kualitas }}</td>
					<td>{{ $d->kualitas_dudul }}</td>
					<td>{{ $d->nama_kualitas_periksa }}</td>
					<td>{{ $d->nama_label }}</td>
					<td>{{ $d->nama_cap }}</td>
					<td>{{ $d->nama_kemasan }}</td>
					<td>{{ $d->nama_kemasansatuan }}</td>
					<td>{{ $d->nama_kemasansepuluh }}</td>
					<td>{{ $d->nama_kemasanseratus }}</td>
				</tr>
				@endforeach
			</tbody>
	    </table>
        	</div>

        	<h5 class="panel-title">Detail Setor</h5>
        	<div class="col-ms-12 table-responsive">
        	<table class="table table-stripped dataTable_setor">
	    	<thead>
				<tr>
					<th>No</th>
					<th></th>
					<th>Kode Barang</th>
					<th>Nama Barang</th>
					<th>Warna</th>
					<th>Gudang</th>
					<th>Jumlah</th>
					<th>Kualitas Produksi</th>
					<th>Corak</th>
					<th>Motif</th>
					<th>No. Order</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>
				@foreach($data['setor'] as $d) 
				<tr>
					<input type="hidden" name="id[]" value="{{ $d->$detail_barang }}">
					<td></td>
					<td>@php echo status_approve($d->status)  @endphp</td>
					<td>{{ $d->kode_barang }}</td>
					<td>{{ $d->nama_barang }}</td>
					<td>{{ $d->nama_komposisi }}</td>
					<td>{{ $d->nama_gudang }}</td>
					<td>{{ $d->jumlah.' ('.$d->nama_satuan.')' }}</td>
					<td>{{ $d->nama_kualitas_proses }}</td>
					<td>{{ $d->nama_corak }}</td>
					<td>{{ $d->nama_motif }}</td>
					<td>{{ $d->no_workorder_barang }}</td>
					<td>{{ $d->nama_kualitas }}</td>
					<td>{{ $d->kualitas_dudul }}</td>
					<td>{{ $d->nama_kualitas_periksa }}</td>
					<td>{{ $d->nama_label }}</td>
					<td>{{ $d->nama_cap }}</td>
					<td>{{ $d->nama_kemasan }}</td>
					<td>{{ $d->nama_kemasansatuan }}</td>
					<td>{{ $d->nama_kemasansepuluh }}</td>
					<td>{{ $d->nama_kemasanseratus }}</td>
				</tr>
				@endforeach
			</tbody>
	    </table>
        	</div>
        	
        	
             <div class="col-md-6"></div>
             <br>
             <div class="col-md-12">
             	<a href="{{url('persetujuanmasuk')}}" class="btn bg-warning-400">Kembali</a>
             <div class="form-group pull-right">
             	@php if(in_array(0, $data['status'])) echo '<button class="btn btn-primary" type="submit">Simpan</button>';
             	@endphp
             	<!-- <button class="btn btn-primary" type="submit">Simpan</button> -->
             </div>
         </div>
	    </div>
	    </form>
	</div>
</div>

<script type="text/javascript">
	var table;
	var setor;
	var kembali;
	$(document).ready(function(){
		table = $(".dataTable").DataTable({
        scrollX:        true,
        scrollCollapse: true,
        fixedColumns:   true
		});
		
		table.on( 'order.dt search.dt', function () {
            table.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                cell.innerHTML = i+1;
            } );
        } ).draw();

		kembali = $(".kembali").DataTable();
        kembali.on( 'order.dt search.dt', function () {
            kembali.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                cell.innerHTML = i+1;
            } );
        } ).draw();
        
        setor = $(".dataTable_setor").DataTable();
		setor.on( 'order.dt search.dt', function () {
            setor.column(0, {search:'applied', order:'applied'}).nodes().each( function (cell, i) {
                cell.innerHTML = i+1;
            } );
        } ).draw();

	})
</script>

@endsection