<?php $__env->startSection('title'); ?> <?php echo e(Config::get('document.title')); ?> <?php $__env->stopSection(); ?>
<?php $__env->startSection('body'); ?>

<div class="row">
	<div class="col-md-3">
		<div class="form-group">
			<label class="control-label">Invoice Created Date From</label>
			<input type="text" class="form-control fromDate">
		</div>
	</div>
	<div class="col-md-3">
		<div class="form-group">
			<label class="control-label">To</label>
			<input type="text" class="form-control toDate">
		</div>
	</div>
	<div class="col-md-2">
		<button class="btn btn-primary btnFilter" style="margin-top: 25px;">Filter</button>
	</div>
</div>
<div class="row">
	<div class="col-md-12">
		<div class="table-responsive">
			<table class="table table-bordered table-condensed documentsTable">
				<thead>
					<tr>
						<th>#</th>
						<th>Trip</th>
						<th>Invoice #</th>
						<th>Transporter</th>
						<th>Created Date</th>
						<th>Dispatchd</th>
						<th>Docs Received</th>
					</tr>
				</thead>
				<tbody>
					
				</tbody>
			</table>
		</div>
	</div>
</div>

<?php $__env->stopSection(); ?>
<?php $__env->startSection('script'); ?>
<script>
	$(function(){
		var _token = $('meta[name="_token"]').attr('content');
		
		$(document).ajaxStart(function() {
			$('button').data('loading-text', '...');
			$('button').button('loading');
		}).ajaxStop(function(){
			$('button').button('reset');
		});

		$('.fromDate').datepicker({
			dateFormat: "yy-mm-dd",
			onSelect: function(){
				$(".toDate").datepicker( "option", "minDate", new Date($('.fromDate').val()) );
			}
		});
		$(".toDate").datepicker({
			dateFormat: "yy-mm-dd",
			onSelect: function(){
				$(".fromDate").datepicker( "option", "maxDate", new Date($('.toDate').val()) );
			}
		});

		$(".btnFilter").click(function(){
			documentsTable();
		});

		function throwError(e, callback) {
			if (e != undefined && e != null && e != '') {
				if (e.hasOwnProperty('errors')) {
					$.each(e.errors, function (k, msg) {
						$.notify.error('<b>' + msg + '</b>');
						return false;
					});
				} else {
					if (e.hasOwnProperty('ok') && e.hasOwnProperty('msg') && e.ok == 0) {
						$.notify.error('<b>' + e.msg + '</b>');
					} else {
						if(callback != undefined && typeof(callback) == "function"){
							callback(e);
						}
					}
				}
			}
		}

		function documentsTable(){
			var data = {
				fromDate: $('.fromDate').val(),
				toDate: $('.toDate').val(),
			};
			$.post("<?php echo e(url('/document/documentsTable')); ?>", {_token: _token, data: data}, function(e){
				throwError(e, function(){
					
				});
			}, 'json');
		}
	});
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>