@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> Pembelian</a></li>
			<li>Order Pembelian</li>
			<li class="active">Laporan 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">Laporan Order Pembelian 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_orderbeli" method="POST" action="{{ url('laporan_orderbeli/cetak_rekap_orderbeli') }}" 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 class="col-sm-12 col-md-12">
			  						<div class="input-group bootstrap-touchspin">
				  						<input class="form-control date_awal set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" required="" autocomplete="off">
				  						<span class="input-group-addon bootstrap-touchspin-postfix">s/d</span>
				  						<input class="form-control date_akhir set_datepicker" type="text" name="tanggal_akhir" value="{{ date('d/m/Y') }}" required="" autocomplete="off">
				  					</div>
			  					</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', 5=>'Tagihan Belum Dibuat'])
			    				@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" data-format="excel" class="btn btn-success cetak_rekap_orderbeli_print"><i class="fa fa-file-excel-o position-left"></i> Excel</button>
			    		<button type="button" data-format="pdf" class="btn btn-primary cetak_rekap_orderbeli_print"><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 Pembelian 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('laporan_orderbeli/cetak_detail') }}" 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="">
										@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 class="col-sm-12 col-md-12">
					  						<div class="input-group bootstrap-touchspin">
						  						<input class="form-control date_awal set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" required="" autocomplete="off">
						  						<span class="input-group-addon bootstrap-touchspin-postfix">s/d</span>
						  						<input class="form-control date_akhir set_datepicker" type="text" name="tanggal_akhir" value="{{ date('d/m/Y') }}" required="" autocomplete="off">
						  					</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">
									<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> -->
			    		<!-- <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 Pembelian Keseluruhan">Detail Pembelian Keseluruhan</a></li>
											<li><a type="submit" id="btn_cetakgroup" class="btn" data-toggle="tooltip" data-placement="top" title="Cetak Laporan Pembelian Keseluruhan">Rekapitulasi Pembelian 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" id="cetak_keseluruhan_excel" class="btn btn-success"><i class="fa fa-file-excel-o position-left"></i> Excel</button>
				    		<button type="button" id="cetak_keseluruhan_print" class="btn 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">Laporan Order Pembelian per Barang</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_barang" action="{{ url('laporan_orderbeli/cetak_kategori_barang') }}" 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-2">Barang</label>
				  			<div class="col-sm-10">
				  				<select class="form-control select-search" name="barang">

				  				</select>
				  			</div>
				  		</div>

				  		<div class="form-group">
				  			<label class="control-label col-sm-2">Tanggal Awal</label>
				  			<div class="col-sm-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="" autocomplete="off">
				  					</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="" autocomplete="off">
				  					</div> -->
				  					<div class="col-sm-12 col-md-12">
				  						<div class="input-group bootstrap-touchspin">
					  						<input class="form-control date_awal set_datepicker" type="text" name="tanggal_awal" value="{{ date('d/m/Y') }}" required="" autocomplete="off">
					  						<span class="input-group-addon bootstrap-touchspin-postfix">s/d</span>
					  						<input class="form-control date_akhir set_datepicker" type="text" name="tanggal_akhir" value="{{ date('d/m/Y') }}" required="" autocomplete="off">
					  					</div>
				  					</div>
				  				</div>
				  			</div>
				  		</div>

			    		<!-- <div class="col-sm-12">
				    		<div class="form-group pull-right">
				    			<button type="button" id="btn_cetak_lap_barang" class="btn btn-primary" data-toggle="tooltip" data-placement="top" title="Cetak Laporan Pembelian Per Barang"><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-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">Laporan Order Pembelian 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('laporan_orderbeli/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-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 Awal</label>
				  			<div class="col-sm-12 col-md-10">
				  				<div class="row">
				  					<!-- <div class="col-sm-6 col-md-6">
				  						<input class="form-control date_awal" type="text" name="tanggal_awal_penyedia" value="{{ date('d-m-Y') }}" readonly="" required="" autocomplete="off">
				  					</div>
				  					<div class="col-sm-6 col-md-6">
				  						<input class="form-control date_akhir" type="text" name="tanggal_akhir_penyedia" value="{{ date('d-m-Y') }}" readonly="" required="" autocomplete="off">
				  					</div> -->
				  					<div class="col-sm-12 col-md-12">
				  						<div class="input-group bootstrap-touchspin">
					  						<input class="form-control date_awal" type="text" name="tanggal_awal_penyedia" value="{{ date('d-m-Y') }}" required="" autocomplete="off">
					  						<span class="input-group-addon bootstrap-touchspin-postfix">s/d</span>
					  						<input class="form-control date_akhir" type="text" name="tanggal_akhir_penyedia" value="{{ date('d-m-Y') }}" required="" autocomplete="off">
					  					</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 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 class="col-sm-6 col-md-6">
		<div class="panel panel-flat">
			<div class="panel-heading">
				<h5 class="panel-title">Laporan Pembelian Per Kategori</h5>
			</div>

			<form class="form-horizontal" method="POST" action="{{ url('laporan_orderbeli/cetak_laporan_kategori') }}" id="form_laporan_kategori" 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">
						{{ Form::label("Kategori", "", ['class'=>'control-label col-sm-12 col-md-2']) }}
						<div class="col-sm-12 col-md-10">
							<select name="kategori" class="form-control set_selected" id="kategori" onchange="get_sub_kategori(this.options[this.selectedIndex].value)">
								<option value="0">--- Pilih Kategori ---</option>
								@foreach($kategori AS $key => $value)
								<option value="{{ $value->id_kb }}">{{ $value->nama }}</option>
								@endforeach
							</select>
						</div>
					</div>

					<div class="form-group">
						{{ Form::label("Sub Kategori", "", ['class'=>'control-label col-sm-12 col-md-2']) }}
						<div class="col-sm-12 col-md-10">
							<select name="sub_kategori" class="form-control set_selected" id="sub_kategori">
								<option value="0">&nbsp;</option>
							</select>
						</div>
					</div>

					<div class="form-group">
						{{ Form::label("Tanggal", "", ['class'=>'control-label col-sm-12 col-md-2']) }}
						<div class="col-sm-12 col-md-10" >
							<div class="row">
								<!-- <div class="col-sm-12 col-md-6">
									{{ Form::text("tanggal_awal", date("d/m/Y"), ['class'=>'form-control set_datepicker']) }}
								</div>
								<div class="col-sm-12 col-md-6">
									{{ Form::text("tanggal_akhir", date("d/m/Y"), ['class'=>'form-control set_datepicker']) }}
								</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') }}" required="" autocomplete="off">
				  						<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') }}" required="" autocomplete="off">
				  					</div>
			  					</div>
							</div>
						</div>
					</div>


				</div>
				<div class="panel-footer">
					<div class="col-sm-12 col-md-12 text-right">
						<button type="button" id="cetak_perkategori_excel" class="btn btn-success"><i class="fa fa-file-excel-o position-left"></i> Excel</button>
						<button type="button" id="cetak_perkategori_print" 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();
		$(".set_datepicker").datepicker({
			format : "dd/mm/yyyy",
			autoclose : true,
			zOfIndex : 9999,
		});
		// $("#form_laporan select[name=lokasi], #form_laporan_barang select[name=lokasi], #form_laporan_penyedia select[name=lokasi], #form_laporan_kategori select[name=lokasi], #form_laporan_rekap_orderbeli select[name=lokasi]").val('{{ $session_lokasi }}').trigger("change");

		get_barang();
		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('laporan_orderbeli/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('laporan_orderbeli/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('laporan_orderbeli/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_barang").click(function(){
	// 	var barang = $("#form_laporan_barang input[name=barang]").val();
	// 	var tanggal_awal = $("#form_laporan_barang input[name=tanggal_awal]").val();
	// 	var tanggal_akhir = $("#form_laporan_barang input[name=tanggal_akhir]").val();
	// 	if(tanggal_awal != '' && tanggal_akhir != ''){
	// 		var url = "{{ url('laporan_orderbeli/cetak_kategori_barang') }}";
	// 		$("#form_laporan_barang").attr('action', url);
	// 		$("#form_laporan_barang").attr('method', 'post');
	// 		$("#form_laporan_barang").attr('target', '_blank');
	// 		$("#form_laporan_barang").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('laporan_orderbeli/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_orderbeli_print").click(function(){
		var format = $(this).data("format");
		var url = "{{ url('laporan_orderbeli/cetak_rekap_orderbeli') }}?format="+format;
		$("#form_laporan_rekap_orderbeli").attr('action', url);
		$("#form_laporan_rekap_orderbeli").attr('method', 'post');
		$("#form_laporan_rekap_orderbeli").attr('target', '_blank');
		$("#form_laporan_rekap_orderbeli").submit();
	})

	$("#cetak_keseluruhan_excel").click(function(){
		var url = "{{ url('laporan_orderbeli/cetak_detail?page=excel') }}";
		$("#form_laporan").attr('action', url);
		$("#form_laporan").attr('method', 'post');
		$("#form_laporan").attr('target', '_blank');
		$("#form_laporan").submit();
	})

	$("#cetak_keseluruhan_print").click(function(){
		var url = "{{ url('laporan_orderbeli/cetak_detail?page=print') }}";
		$("#form_laporan").attr('action', url);
		$("#form_laporan").attr('method', 'post');
		$("#form_laporan").attr('target', '_blank');
		$("#form_laporan").submit();
	})

	$("#cetak_perkategori_excel").click(function(){
		var url = "{{ url('laporan_orderbeli/cetak_laporan_kategori?page=excel') }}";
		$("#form_laporan_kategori").attr('action', url);
		$("#form_laporan_kategori").attr('method', 'post');
		$("#form_laporan_kategori").attr('target', '_blank');
		$("#form_laporan_kategori").submit();
	})

	$("#cetak_perkategori_print").click(function(){
		var url = "{{ url('laporan_orderbeli/cetak_laporan_kategori?page=print') }}";
		$("#form_laporan_kategori").attr('action', url);
		$("#form_laporan_kategori").attr('method', 'post');
		$("#form_laporan_kategori").attr('target', '_blank');
		$("#form_laporan_kategori").submit();
	})

})

	function get_barang(){
		$.ajax({
			url: '{{ url('laporan_orderbeli/get_barang') }}',
			success: function(respon){
				$("[name=barang]").html('');
				if(respon.length > 0){
					for(i in respon){
						var set_text = respon[i].kode_barang+' - '+respon[i].kategori+' '+respon[i].nama_sub+' '+respon[i].nama_barang;
						if(respon[i].id_kelompok==4){
							set_text = respon[i].nama_barang;

						}

						$("[name=barang]").append('<option value="'+respon[i].id_barang+'" barang="'+respon[i].nama_barang+'" kode="'+respon[i].kode_barang+'" satuan="'+respon[i].satuan+'">'+set_text+'</option>');
					}
				}
			}
		})
	}

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

	function get_sub_kategori($id){
		$.ajax({
			url: "{{ url('laporan/getdataSK') }}"+'/'+$id,
			type: 'get',
			dataType: 'json',
			success: function(result){
				// alert('success');
				$("[name=sub_kategori]").html('');
				$("[name=sub_kategori]").append('<option value="0">Semua</option>');
				for(i in result.data){
					$("[name=sub_kategori]").append('<option value="'+result.data[i].id_kb+'" nama="'+result.data[i].nama+'">'+result.data[i].nama+'</option>');
				}

			}
		})
	}

</script>


@endsection