@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> Order Service</a></li>
			<li class="active">Laporan Order Service</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">Laporan Order Service Status Bayar</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_rekap_orderservice" method="POST" action="{{ url('order_service/laporan/cetak_rekap_orderservice') }}" target="_blank">
			    
			    <input type="hidden" name="_token" value="{{ csrf_token() }}">

			    <div class="panel-body">

			    	<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="">
			    				@if($lokasi_semua == 'show')
			    					<option value="0">Semua</option>
			    				@endif
			    				@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>
		    			</div>
		    		</div>

		    		<div class="form-group">
		    			<label class="control-label col-sm-12 col-md-2">Jenis</label>
		    			<div class="col-sm-12 col-md-10">
		    				<select name="jenis_laporan" class="form-control set_selected">
			    				@php($lap_opt=[0=>'Rekap', 1=>'Detail'])
			    				@foreach($lap_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">Status</label>
		    			<div class="col-sm-12 col-md-10">
		    				<select name="status_bayar" class="form-control set_selected">
			    				@php($lap_opt=[0=>'Semua', 1=>'Belum Bayar', 2=>'Proses Bayar', 3=>'Lunas', 4=>'Kelebihan Bayar'])
			    				@foreach($lap_opt AS $key=>$value)
			    					<option value="{{ $key }}">{{ $value }}</option>
			    				@endforeach
			    			</select>
		    			</div>
		    		</div>

			    </div>
			    <div class="panel-footer">
			    	<div class="col-sm-12 col-md-12 text-right">
			    		<button type="button" class="btn btn-success cetak_rekap_orderservice_print" data-format="excel"><i class="fa fa-file-excel-o position-left"></i> Excel</button>
			    		<button type="button" class="btn btn-primary cetak_rekap_orderservice_print" data-format="pdf"><i class="icon-printer position-left"></i> Cetak</button>
			    	</div>
			    </div>
			    	</form>
			</div>
	</div>
</div>
	<div class="row">
		<div class="col-sm-6 col-md-6">
			
			<div class="panel panel-flat">
				<div class="panel-heading">
					<h5 class="panel-title">Order Service Laporan Keseluruhan</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('order_service/laporan/cetak_detail') }}" target="_blank">
		    		<input type="hidden" name="_token" value="{{ csrf_token() }}">

			    <div class="panel-body">
			    	<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="">
			    				@if($lokasi_semua == 'show')
			    					<option value="0">Semua</option>
			    				@endif
			    				@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" 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" type="text" name="tanggal_akhir" value="{{ date('d-m-Y') }}" readonly="" required="">
		    					</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">
		    				<select name="jenis" class="form-control set_selected">
			    				@php($lap_opt=[0=>'Rekap', 1=>'Detail'])
			    				@foreach($lap_opt AS $key=>$value)
			    					<option value="{{ $key }}">{{ $value }}</option>
			    				@endforeach
			    			</select>
		    			</div>
		    		</div>

			    		<!--- <div class="col-sm-12">
				    		<div class="form-group pull-right">
				    			<div class="btn-group btn-group-fade">
									<button type="button" class="btn btn-primary"><i class="icon-printer position-left"></i> Cetak</button>
					                <button type="button" class="btn btn-primary dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>
					                    <ul class="dropdown-menu dropdown-menu-right">
											<li><a type="submit" id="btn_cetak" class="btn" data-toggle="tooltip" data-placement="top" title="Cetak Laporan Order Service Keseluruhan">Detail Order Service Keseluruhan</a></li>
											<li><a type="submit" id="btn_cetakgroup" class="btn" data-toggle="tooltip" data-placement="top" title="Cetak Laporan Order Service Keseluruhan">Rekapitulasi Order Service Keseluruhan</a></li>
										</ul>
								</div>
				    			
				    		</div>
			    		</div> -->

			    </div>
			    <div class="panel-footer">
			    	<div class="col-sm-12 col-md-12 text-right">
			    		<button type="button" class="btn btn-success cetak_keseluruhan" data-format="excel"><i class="fa fa-file-excel-o position-left"></i> Excel</button>
			    		<button type="button" class="btn btn-primary cetak_keseluruhan" data-format="pdf"><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">Laporan Order Service per Akun</h5>
					<div class="heading-elements">
						<!-- <ul class="icons-list">
				      		<li><a data-action="collapse"></a></li>
				      	</ul> -->
			       	</div>
			    </div>
		    	<form class="form-horizontal" method="post" autocomplete="off" id="form_laporan_akun" target="_blank" action="{{ url('order_service/laporan/cetak_akun_service') }}">
		    		<input type="hidden" name="_token" value="{{ csrf_token() }}">

			    <div class="panel-body">
			    	<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="">
			    				@if($lokasi_semua == 'show')
			    					<option value="0">Semua</option>
			    				@endif
			    				@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">Akun</label>
		    			<div class="col-sm-10">
		    				<select class="form-control select-search" name="id_akun">
		    					
		    				</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" 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" type="text" name="tanggal_akhir" value="{{ date('d-m-Y') }}" readonly="" required="">
		    					</div>
		    				</div>
				    	</div>
		    		</div>

			    		<!-- <div class="col-sm-12">
				    		<div class="form-group pull-right">
				    			<button type="button" id="btn_cetak_lap_orderservice" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="Cetak Laporan Order Service Per Akun"><i class="icon-printer position-left"></i>Cetak</button>
				    			
				    		</div>
			    		</div> -->
			    </div>
			    
			    <div class="panel-footer">
			    	<div class="col-sm-12 col-md-12 text-right">
			    		<button type="submit" class="btn btn-primary"><i class="icon-printer position-left"></i> Cetak</button>
			    	</div>
			    </div>

			    	</form>

			</div>

		</div>
	</div>

	<div class="row">
		<div class="col-sm-6 col-md-6">
			<div class="panel panel-flat">
				<div class="panel-heading">
					<h5 class="panel-title">Laporan Order Service 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_penyedia" method="post" action="{{ url('order_service/laporan/cetak_kategori_penyedia') }}" target="_blank">
		    		<input type="hidden" name="_token" value="{{ csrf_token() }}">

			    <div class="panel-body">
			    	<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="">
			    				@if($lokasi_semua == 'show')
			    					<option value="0">Semua</option>
			    				@endif
			    				@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">Penyedia</label>
		    			<div class="col-sm-12 col-md-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" 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" type="text" name="tanggal_akhir" value="{{ date('d-m-Y') }}" readonly="" required="">
		    					</div>
		    				</div>
				    	</div>
		    		</div>

			    		<!-- <div class="col-sm-12">
				    		<div class="form-group pull-right">
				    			<button type="button" id="btn_cetak_lap_penyedia" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="Cetak Laporan Per Penyedia"><i class="icon-printer position-left"></i>Cetak</button>
				    			
				    		</div>
			    		</div> -->
			    </div>
			    <div class="panel-footer">
			    	<div class="col-sm-12 col-md-12 text-right">
			    		<button type="submit" class="btn 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(){

	$(".set_selected").select2();

	$("#form_laporan select[name=lokasi], #form_laporan_akun select[name=lokasi], #form_laporan_penyedia select[name=lokasi], #form_laporan_rekap_orderservice select[name=lokasi]").val({{ $session_lokasi }}).trigger("change");

	get_akun();
	get_penyedia();

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

	/*
	$("#btn_cetak").click(function(){
		var tanggal_awal = $("#form_laporan input[name=tanggal_awal]").val();
		var tanggal_akhir = $("#form_laporan input[name=tanggal_akhir]").val();
		if(tanggal_awal != '' && tanggal_akhir != ''){
			var url = "{{ url('order_service/laporan/cetak_detail') }}";
			$("[name=jenis]").val(1);
			$("#form_laporan").attr('action', url);
			$("#form_laporan").attr('method', 'post');
			$("#form_laporan").attr('target', '_blank');
			$("#form_laporan").submit();
		}

	})

	$("#btn_cetakgroup").click(function(){
		var tanggal_awal = $("#form_laporan input[name=tanggal_awal]").val();
		var tanggal_akhir = $("#form_laporan input[name=tanggal_akhir]").val();
		if(tanggal_awal != '' && tanggal_akhir != ''){
			var url = "{{ url('order_service/laporan/cetak_detail') }}";
			$("[name=jenis]").val(2);
			$("#form_laporan").attr('action', url);
			$("#form_laporan").attr('method', 'post');
			$("#form_laporan").attr('target', '_blank');
			$("#form_laporan").submit();
		}
	})

	$("#btn_cetak_lap_tempo").click(function(){
		var tanggal_tempo = $("#form_laporan_jatuh_tempo input[name=tanggal_tempo]").val();
		if(tanggal_tempo != ''){
			var url = "{{ url('order_service/laporan/cetak_lap_jatuh_tempo') }}";
			$("#form_laporan_jatuh_tempo").attr('action', url);
			$("#form_laporan_jatuh_tempo").attr('method', 'post');
			$("#form_laporan_jatuh_tempo").attr('target', '_blank');
			$("#form_laporan_jatuh_tempo").submit();
		}
	})

	$("#btn_cetak_lap_orderservice").click(function(){
		var barang = $("#form_laporan_akun input[name=id_akun]").val();
		var tanggal_awal = $("#form_laporan_akun input[name=tanggal_awal]").val();
		var tanggal_akhir = $("#form_laporan_akun input[name=tanggal_akhir]").val();
		if(tanggal_awal != '' && tanggal_akhir != ''){
			var url = "{{ url('order_service/laporan/cetak_akun_service') }}";
			$("#form_laporan_akun").attr('action', url);
			$("#form_laporan_akun").attr('method', 'post');
			$("#form_laporan_akun").attr('target', '_blank');
			$("#form_laporan_akun").submit();
		}

	})

	$("#btn_cetak_lap_penyedia").click(function(){
		var penyedia = $("#form_laporan_penyedia input[name=penyedia]").val();
		var tanggal_awal = $("#form_laporan_penyedia input[name=tanggal_awal_penyedia]").val();
		var tanggal_akhir = $("#form_laporan_penyedia input[name=tanggal_akhir_penyedia]").val();
		if(tanggal_awal != '' && tanggal_akhir != ''){
			var url = "{{ url('order_service/laporan/cetak_kategori_penyedia') }}";
			$("[name=jenis]").val(1);
			$("#form_laporan_penyedia").attr('action', url);
			$("#form_laporan_penyedia").attr('method', 'post');
			$("#form_laporan_penyedia").attr('target', '_blank');
			$("#form_laporan_penyedia").submit();
		}

	})
	*/

	$(".cetak_rekap_orderservice_print").click(function(){
		var format = $(this).data("format");
		var url = "{{ url('order_service/laporan/cetak_rekap_orderservice') }}?format="+format;
		$("#form_laporan_rekap_orderservice").attr('action', url);
		$("#form_laporan_rekap_orderservice").attr('method', 'post');
		$("#form_laporan_rekap_orderservice").attr('target', '_blank');
		$("#form_laporan_rekap_orderservice").submit();
	})

	$(".cetak_keseluruhan").click(function(){
		var format = $(this).data("format");
		var url = "{{ url('order_service/laporan/cetak_detail') }}?format="+format;
		$("#form_laporan").attr("action", url);
		$("#form_laporan").submit();
	})

})

function get_akun(){
	$.ajax({
		url: '{{ url('order_service/laporan/get_akun') }}',
		success: function(respon){
			$("[name=id_akun]").html('');
			if(Object.keys(respon).length > 0){
				for(i in respon){
					$("[name=id_akun]").append('<option value="'+i+'">'+respon[i]+'</option>');
				}
			}
		}
	})
}

function get_penyedia(){
	$.ajax({
		url: '{{ url('order_service/laporan/get_penyedia') }}',
		success: function(respon){
			$("[name=penyedia]").html('');
			if(Object.keys(respon).length > 0){
				for(i in respon){
					$("[name=penyedia]").append('<option value="'+i+'">'+respon[i]+'</option>');
				}
			}
		}
	})
}

</script>


@endsection