@extends('layout')


@section('content')

<div class="page-header page-header-default">
	<div class="breadcrumb-line">
		<ul class="breadcrumb">
			<li><a href="#"><i class="icon-home2 position-left"></i> Keuangan</a></li>
			<li class="active">Sales Contract</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="panel panel-flat">
		<div class="panel-heading">
			<h5 class="panel-title">Data Kontrak</h5>
			<div class="heading-elements">
				<ul class="icons-list">
		      		<li><a href="{{ url('sales_contract') }}" class="text-warning"><i class="icon-circle-left2 warning"></i> Kembali</a></li>
		      	</ul>
	       	</div>
	    </div>

	    <form class="form-horizontal" role="form" method="post" id="form-data-kontrak">

	    <div class="panel-body">
	    	
	    	<div class="col-sm-12 col-md-12">
	    		<div class="row col-sm-6 col-md-6">
		    		<div class="form-group">
		    			{{ Form::label("Lokasi", "", ['class'=>'control-label col-sm-4']) }}
		    			<div class="col-sm-8">
		    				<select name="lokasi" class="form-control select-search" disabled="">
		    					@foreach($lokasi AS $key => $value)
		    					<option value="{{ $value->id_lokasi }}" {{ ($value->id_lokasi==$kontrak->lokasi) ? "selected=''" : "" }}>{{ $value->nama_lokasi }}</option>
		    					@endforeach
		    				</select>
		    			</div>
		    		</div>
		    	</div>
	    	</div>

	    	<div class="col-sm-12 col-md-12">
	    		<div class="row col-sm-6 col-md-6">
		    		<div class="form-group">
		    			{{ Form::label("Label CV", "", ['class'=>'control-label col-sm-4']) }}
		    			<div class="col-sm-8">
		    				<div class="checkbox">
		    					<label>
			    					{{ Form::checkbox("cv", '1', ($kontrak->cv==1) ? true : false, ['class'=>'styled', 'disabled'=>'']) }}
		    					</label>
		    				</div>
		    			</div>
		    		</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">
        				<select class="form-control select-search" name="rekanan" required="" disabled="">
        					<option value="">--- Pilih Rekanan ---</option>
        					@foreach($rekanan AS $key=>$value)
        						<option value="{{ $value->id_kelompok }}" {{ ($value->id_kelompok==$kontrak->id_rekanan) ? "selected=''" : '' }}>{{ $value->nama }}</option>
        					@endforeach
        				</select>
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Tanggal Input</label>
        			<div class="col-sm-8">
        				<input class="form-control" type="text" name="tanggal" placeholder="Tanggal" value="{{ date_format(date_create($kontrak->tanggal), 'd/m/Y') }}" required="" readonly="" disabled="" />
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Tanggal Kontrak</label>
        			<div class="col-sm-8">
        				<input class="form-control" type="text" name="tanggal_kontrak" placeholder="Tanggal Kontrak" value="{{ date_format(date_create($kontrak->tanggal_kontrak), 'd/m/Y') }}" required="" disabled="">
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4 col-md-4">No. Kontrak</label>
        			<div class="col-sm-8 col-md-8">
        				{{ Form::text('no_kontrak', $kontrak->no_kontrak, ['class'=>'form-control', 'placeholder'=>'Nomor Kontrak', 'disabled'=>'']) }}
        			</div>
        		</div>
        		<div class="form-group">
        			<label class="control-label col-sm-4">Keterangan</label>
        			<div class="col-sm-8">
        				<textarea class="form-control" name="keterangan" rows="2" disabled="">{{ $kontrak->keterangan }}</textarea>
        			</div>
        		</div>
        		
        	</div>

        	<div class="col-sm-6">
    			<div class="form-group">
    				{{ Form::label("Jadwal Pengiriman", "", ['class'=>'control-label col-sm-4']) }}
    				<div class="col-sm-8">
    					{{ Form::text("tanggal_kirim", date_format(date_create($kontrak->tanggal_kirim), 'd/m/Y'), ['class'=>'form-control', 'disabled'=>'']) }}
    				</div>
    			</div>

        		<div class="form-group">
    				{{ Form::label("Syarat Pembayaran", "", ['class'=>'control-label col-sm-4']) }}
    				<div class="col-sm-8">
    					{{ Form::textarea("syarat_bayar", $kontrak->syarat_bayar, ['class'=>'form-control', 'rows'=>2, 'disabled'=>'']) }}
    				</div>
    			</div>

        	</div>

	    	<!-- Detail Barang -->
	    	<div class="col-sm-12 col-md-12">
	    		<h5 class="panel-title">Detail Barang</h5>

	    		<table class="table" id="tabel-detail-barang">
	    			<thead>
	    				<tr>
	    					<th>#</th>
	    					<th>Warna</th>
	    					<th>Barang</th>
	    					<th>Jml</th>
	    					<th>Satuan</th>
	    					<th>Harga Satuan</th>
	    					<th>Total</th>
	    					<th>Keterangan</th>
	    					<th>Pajak</th>
	    				</tr>
	    			</thead>
	    			<tbody>
	    				@foreach($kontrak_detail AS $key=>$value)
	    				@php
	    					$label_ppn = "";
	    					if($value->termasuk_pajak == 1){
	    						$label_ppn = "Termasuk PPN";
	    					}else if($value->termasuk_pajak == 0 && $value->pajak == 1){
	    						$label_ppn = "PPN";
	    					}
	    				@endphp
	    				<tr>
	    					<td>{{ ($key+1) }}</td>
	    					<td>{{ ($value->warna_komposisi." ( $value->inisial_komposisi )") }}</td>
	    					<td>{{ ($value->nama_barang) }}</td>
	    					<td align="right">{{ ($value->jumlah) }}</td>
	    					<td>{{ ($value->satuan) }}</td>
	    					<td align="right">{{ (rupiah2($value->harga_satuan, 2)) }}</td>
	    					<td align="right">{{ (rupiah2($value->jumlah*$value->harga_satuan, 2)) }}</td>
	    					<td>{{ ($value->keterangan) }}</td>
	    					<td>{{ ($label_ppn) }}</td>
	    				</tr>
	    				@endforeach
	    			</tbody>
	    			<tfoot>
	    			</tfoot>
	    		</table>
	    	</div>

	    </div>

	    <div class="panel-footer text-right">
    		<div class="col-sm-12 col-md-12">
    			<a href="{{ url('sales_contract') }}" class="btn btn-md btn-warning">Kembali</a>
    			<a href="{{ url('sales_contract/'.$kontrak->id.'/edit') }}" class="btn btn-md btn-default"><i class="fa fa-pencil"></i> Edit</a>
    		</div>
	    </div>

	    </form>
	    
	</div>
</div>

<script type="text/javascript">
	$(document).ready(function () {

	});
</script>

@endsection