@extends('layouts.app')

@section('content')
<div class="main-card mb-3 card">
	<div class="card-body">
	<h5 class="card-title"></h5>
		<div class="row">
		<form id="frmfilter" class="form-inline">
		<div class="mb-2 mr-sm-2 mb-sm-0 position-relative form-group">
			<label for="date1" class="mr-sm-2">Tanggal</label>
			<input name="date1" id="date1"  type="text" class="form-control dtime" value="<?php echo date('Y-m-d', strtotime('-7 days')); ?>" readonly>
		</div>
		<div class="mb-2 mr-sm-2 mb-sm-0 position-relative form-group">
			<label for="date2" class="mr-sm-2">Sd</label>
			<input name="date2" id="date2"  type="text" class="form-control dtime" value="<?php echo date('Y-m-d'); ?>" readonly>
		</div>		
			<div class="mb-2 mr-sm-2 mb-sm-0 position-relative form-group">
			<select name="tenant" id="tenant" class="form-control">
				<option value="ALL"> -- Semua --</option>
				@foreach($tenant as $t)
					<option value="{{$t->company_id}}">{{$t->company_name}}</option>
				@endforeach
			</select>
		</div>
		
		
			<button type="button" class="btn btn-primary" onclick="submitForm()">SUBMIT</button>
			</form>
		</div>
		<br>
		<div class="main-card mb-3 card">
			<div class="card-header-tab card-header-tab-animation card-header">
				
			</div>
			<div class="card-body">
				<div class="row">
					<div id="dresponse"></div>
				</div>
			</div>
		</div>
		
		
	</div>
</div>
		

@endsection
@section('custom-script')
<script>
$('.dtime').datepicker({
    format: 'yyyy-mm-dd'
});

function submitForm(){
	$.ajaxSetup({
			headers: {
				'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
			}
		});
		$.ajax({
			type : "POST",
			url  : "{{url('penjualan/data')}}",
			data : $("#frmfilter").serialize(),
			beforeSend: function() {
					
			},
			success: function(data){
				$("#dresponse").empty(); 
				$('#dresponse').html(data);	
			}
		});
}



</script>
@endsection