@extends('layouts.app')

@section('title',"Ventas")

@section('content')
<div class="card">
	<div class="card-header header-elements-inline">
		<h5 class="card-title"><i class="icon-clipboard "></i> Ventas</h5>
		<div class="header-elements">
			<div class="list-icons">
        		<a class="list-icons-item" data-action="collapse"></a>
        		<a class="list-icons-item" data-action="reload"></a>
        		<a class="list-icons-item" data-action="remove"></a>
        	</div>
    	</div>
	</div>	
	<div class="card-body mt-2">
		<div class="row">
			<div class="col-6">
				@include('layouts.buttons.button-create',['buttons'=> array(
	                array(
	                  'modal'=>'no',
	                  'url'=>url('ventas/create'),
	                  'class'=>" btn btn-primary",
	                  'icon'=>"icon-database-add",
	                  'text' => "Agregar Venta"
	                )
            	)])					
			</div>
			<div class="col-6 text-right">
			 	<a class="btn btn-warning" href="{{ url('ventas/export/actually' ) }}" title="Excel" id="export"><i class="icon-file-excel"></i> Exportar </a>
			</div>
		</div>
		<div class="row justify-content-center">
			<div class="col-2 ">
				<label for=""><b>Fecha:</b></label>
				<input type="text" name="fecha" id="fecha" class="form-control" onchange="change_date(); return false" value="<?php echo date('m/Y'); ?>">
			</div>
		</div>
	</div>
	<table class="table table-bordered table-hover datatable">
		<thead>
			<tr>
				<th>Nº</th>
				<th>Documento </th>
				<th>Numero</th>
				<th>Emision</th>
				<th>Importe</th>
				<th>Mon</th>
				<th>Proveedor</th>
				<th>Acciones</th>
			</tr>
		</thead>
	</table>
</div>
	@section('scripts')
		<script>
			const url = 'ventas';
			const columns = [
			        {data: 'codigo_num'},
			        {data: 'documento'},
			        {data: 'numero_identidad'},
			        {data: 'fec_emision'},
			        {data: 'totales'},
			        {data: 'divisa'},
			        {data: 'nombre'},
			        {data: 'action', orderable: false, searchable: false},
			    ];
			$('#fecha').val(localStorage.getItem('fecha_contable'));
			function change_date(){
				search = $('#fecha').val();
				let  url_export = "{{ url('ventas/export' ) }}/"+search.replace("/","-");
				$('#export').attr('href',url_export);
				$('.datatable').DataTable().ajax.reload();
			}
		</script>
		<script>
			$.fn.datepicker.defaults.format = "mm/yyyy";
			$('#fecha').datepicker({
			    weekStart: 1,
			    daysOfWeekHighlighted: "6,0",
			    autoclose: true,
			    todayHighlight: true,
			    viewMode: "months", 
			    minViewMode: "months"
			});
		</script>
		<script src="{!! asset('assets/datatables/datatables_custom.js') !!}"></script>
	@endsection
@endsection