@extends('layout')


@section('content')

<style type="text/css">
	.datepicker { 
	    z-index: 9999 !important;
	}
</style>

<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> Keuangan</a></li>
			<li>Hutang</li>
			<li class="active">Laporan Hutang Pembelian</li>
		</ul>
	</div>
</div>

<div class="content">
	<div class="row">
		<div class="col-sm-6 col-md-6">
			
			<div class="panel panel-flat">
				<div class="panel-heading">
					<h5 class="panel-title">Hutang Per-Penyedia</h5>
					<div class="heading-elements">
						<ul class="icons-list">
				      		<!-- <li><a data-action="collapse"></a></li> -->
				      	</ul>
			       	</div>
			    </div>
			    	<form class="form-horizontal" autocomplete="off" id="form_laporan" method="post" action="{{ url('hutang/laporan_hutang_pembelian/cetak_per_penyedia') }}" target="_blank">
			    		<input type="hidden" name="_token" value="{{ csrf_token() }}">
			    <div class="panel-body">

			    		<!-- <div class="col-sm-12 col-md-12"> -->
			    			<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Lokasi</label>
				    			<div class="col-sm-12 col-md-10">
					    			<select name="lokasi" class="form-control set_selected" required="">
					    					<option value="0">Semua</option>
					    				@foreach($lokasi_produksi AS $key => $value)
					    					<option value="{{ $value->id_lokasi }}">{{ $value->nama_lokasi }}</option>
					    				@endforeach
					    			</select>
					    		</div>
				    		</div>
				    		<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Label CV</label>
				    			<div class="col-sm-12 col-md-10">
					    			<select name="label" class="form-control set_selected" required="">
					    				@php($arr_opt = ["3"=>"Semua", "1"=>"CV", "0"=>"Non-CV"])
					    				@foreach($arr_opt AS $key => $value)
					    					<option value="{{ $key }}">{{ $value }}</option>
					    				@endforeach
					    			</select>
					    		</div>
				    		</div>

				    		<div class="form-group">
				    			<label class="control-label col-sm-2">Penyedia</label>
				    			<div class="col-sm-10">
				    				<select class="form-control select-search" name="penyedia">
				    					
				    				</select>
				    			</div>
				    		</div>
				    		
				    		<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Tanggal</label>
				    			<div class="col-sm-12 col-md-10">
				    				<div class="row">
				    					<!-- <div class="col-sm-12 col-md-6">
				    						<input class="form-control date_awal set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" readonly="" required="">
				    						
				    					</div>
				    					<div class="col-sm-12 col-md-6">
				    						<input class="form-control date_akhir set_datepicker" type="text" name="tanggal_akhir" value="{{ date('d/m/Y') }}" readonly="" required="">

				    					</div> -->
				    					<div class="col-sm-12 col-md-12">
					  						<div class="input-group bootstrap-touchspin">
						  						<input class="form-control set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" data-mask="99/99/9999" required="">
						  						<span class="input-group-addon bootstrap-touchspin-postfix">s/d</span>
						  						<input class="form-control set_datepicker" type="text" name="tanggal_akhir" value="{{ date('d/m/Y') }}" data-mask="99/99/9999" required="">
						  					</div>
					  					</div>
				    				</div>
				    			</div>
				    		</div>

			    </div>
			    <div class="panel-footer">
			    	<div class="col-sm-12 col-md-12 text-right">
				    	<button type="submit" class="btn btn-md btn-primary"><i class="icon-printer position-left"></i> Cetak</button>
				    </div>
			    </div>
			    	</form>
			</div>

		</div>

		<div class="col-sm-6 col-md-6">
			
			<div class="panel panel-flat">
				<div class="panel-heading">
					<h5 class="panel-title">Mutasi Hutang</h5>
					<div class="heading-elements">
						<ul class="icons-list">
				      		<!-- <li><a data-action="collapse"></a></li> -->
				      	</ul>
			       	</div>
			    </div>
			    	<form class="form-horizontal" autocomplete="off" id="form_laporan" method="post" action="{{ url('hutang/laporan_hutang_pembelian/cetak_mutasi_hutang') }}" target="_blank">
			    		<input type="hidden" name="_token" value="{{ csrf_token() }}">
			    <div class="panel-body">

			    		<!-- <div class="col-sm-12 col-md-12"> -->
			    			<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Lokasi</label>
				    			<div class="col-sm-12 col-md-10">
					    			<select name="lokasi" class="form-control set_selected" required="">
					    					<option value="0">Semua</option>
					    				@foreach($lokasi_produksi AS $key => $value)
					    					<option value="{{ $value->id_lokasi }}">{{ $value->nama_lokasi }}</option>
					    				@endforeach
					    			</select>
					    		</div>
				    		</div>
				    		<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Label CV</label>
				    			<div class="col-sm-12 col-md-10">
					    			<select name="label" class="form-control set_selected" required="">
					    				@php($arr_opt = ["3"=>"Semua", "1"=>"CV", "0"=>"Non-CV"])
					    				@foreach($arr_opt AS $key => $value)
					    					<option value="{{ $key }}">{{ $value }}</option>
					    				@endforeach
					    			</select>
					    		</div>
				    		</div>
				    		
				    		<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Tanggal</label>
				    			<div class="col-sm-12 col-md-10">
				    				<div class="row">
				    					<!-- <div class="col-sm-12 col-md-6">
				    						<input class="form-control date_awal set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" readonly="" required="">
				    						
				    					</div>
				    					<div class="col-sm-12 col-md-6">
				    						<input class="form-control date_akhir set_datepicker" type="text" name="tanggal_akhir" value="{{ date('d/m/Y') }}" readonly="" required="">

				    					</div> -->
				    					<div class="col-sm-12 col-md-12">
					  						<div class="input-group bootstrap-touchspin">
						  						<input class="form-control set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" data-mask="99/99/9999" required="">
						  						<span class="input-group-addon bootstrap-touchspin-postfix">s/d</span>
						  						<input class="form-control set_datepicker" type="text" name="tanggal_akhir" value="{{ date('d/m/Y') }}" data-mask="99/99/9999" required="">
						  					</div>
					  					</div>
				    				</div>
				    			</div>
				    		</div>
				    		
				    		<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">&nbsp;</label>
				    			<div class="col-sm-12 col-md-10">&nbsp;</div>
				    		</div>

			    </div>
			    <div class="panel-footer">
			    	<div class="col-sm-12 col-md-12 text-right">
				    	<button type="submit" class="btn btn-md btn-primary"><i class="icon-printer position-left"></i> Cetak</button>
				    </div>
			    </div>
			    	</form>
			</div>

		</div>
		
	</div> <!--- end : .row -->
	<div class="row">
		<div class="col-sm-6 col-md-6">
			
			<div class="panel panel-flat">
				<div class="panel-heading">
					<h5 class="panel-title">Usia Hutang</h5>
					<div class="heading-elements">
						<ul class="icons-list">
				      		<!-- <li><a data-action="collapse"></a></li> -->
				      	</ul>
			       	</div>
			    </div>
			    	<form class="form-horizontal" autocomplete="off" id="form_laporan" method="post" action="{{ url('hutang/laporan_hutang_pembelian/cetak_usia_hutang') }}" target="_blank">
			    		<input type="hidden" name="_token" value="{{ csrf_token() }}">
			    <div class="panel-body">

			    		<!-- <div class="col-sm-12 col-md-12"> -->
			    			<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Lokasi</label>
				    			<div class="col-sm-12 col-md-10">
					    			<select name="lokasi" class="form-control set_selected" required="">
					    					<option value="0">Semua</option>
					    				@foreach($lokasi_produksi AS $key => $value)
					    					<option value="{{ $value->id_lokasi }}">{{ $value->nama_lokasi }}</option>
					    				@endforeach
					    			</select>
					    		</div>
				    		</div>
				    		<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Label CV</label>
				    			<div class="col-sm-12 col-md-10">
					    			<select name="label" class="form-control set_selected" required="">
					    				@php($arr_opt = ["3"=>"Semua", "1"=>"CV", "0"=>"Non-CV"])
					    				@foreach($arr_opt AS $key => $value)
					    					<option value="{{ $key }}">{{ $value }}</option>
					    				@endforeach
					    			</select>
					    		</div>
				    		</div>
				    		
				    		<div class="form-group">
				    			<label class="control-label col-sm-12 col-md-2">Per Tanggal</label>
				    			<div class="col-sm-12 col-md-10">
				    				<div class="row">
				    					<div class="col-sm-12 col-md-6">
				    						<input class="form-control date_awal set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" readonly="" required="">
				    						
				    					</div>
				    				</div>
				    			</div>
				    		</div>

			    </div>
			    <div class="panel-footer">
			    	<div class="col-sm-12 col-md-12 text-right">
				    	<button type="submit" class="btn btn-md btn-primary"><i class="icon-printer position-left"></i> Cetak</button>
				    </div>
			    </div>
			    	</form>
			</div>

		</div>
		
	</div> <!-- end : row -->
</div>

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

	$(".set_selected").select2();
	$(".set_datepicker").datepicker({
		format : "dd/mm/yyyy",
		autoclose : true,
		zOfIndex : 9999999,
	});
	$("#form_laporan select[name=lokasi]").val(1).trigger("change");

	$(".month_datepicker").datepicker({
		format : "mm-yyyy",
		viewMode : 'months',
		minViewMode : 'months',
		autoclose : true,
		zOfIndex : 999999,
	})

})


function get_penyedia(){
	$.ajax({
		url: '{{ url('hutang/get_penyedia') }}',
		success: function(respon){
			$("[name=penyedia]").html('');
			if(respon.length > 0){
				for(i in respon){
					var set_nama_penyedia = respon[i].nama+' - '+respon[i].pic;
					if(respon[i].pic==""){
						set_nama_penyedia = respon[i].nama;
					}
					$("[name=penyedia]").append('<option value="'+respon[i].id_penyedia+'">'+set_nama_penyedia+'</option>');
				}
			}
		}
	})
}
</script>


@endsection