@extends(Auth::check() && Auth::user()->role->layout == 1 ? 'layouts.admin' : 'layouts.employee')

@section('content')
<div class="content-wrapper">
	<section class="content-header">
		<h1>
		Clientes
		</h1>
	</section>

	<section class="content">
		<div class="row">
			<div class="col-md-12">
				@include('alert.success')
				@if(Auth::user()->role->role_permission('create_users'))
				<a href="{{ asset('/companies/create') }}" type="button" class="btn btn-success btn-flat margin">Nuevo cliente</a>
				@endif
				<div class="box box-success">
					<div class="box-header">
						<h3 class="box-title">Clientes</h3>
					</div>
					<div class="box-body table-responsive no-padding">
						<table class="table table-hover">
							<tr>
								<th>ID</th>
								<th>Cliente</th>
								@if(Auth::user()->role->role_permission('edit_users') || Auth::user()->role->role_permission('delete_users'))
								<th>{{trans('general.accion')}}</th>
								@endif
							</tr>
							@foreach($customers as $customer)
							<tr>
								<td>{{ $customer->id }}</td>
								<td>{{ $customer->fiscal_reason }}</td>
								@if(Auth::user()->role->role_permission('edit_users') || Auth::user()->role->role_permission('delete_users'))
								<td>
									<div class="btn-group">
										@if(Auth::user()->role->role_permission('edit_users'))
										<a href="{{ asset('companies/'.$customer->id.'/edit') }}" title="Edit" class="btn btn-default btn-flat btn-sm"><i class="fa fa-pencil"></i></a>
										<!-- a href="{{ asset('companies/'.$customer->id.'/assign') }}" title="Edit" class="btn btn-default btn-flat btn-sm"><i class="fa fa-user-plus"></i></a -->
										<a href="{{ asset('credits/'.$customer->id.'/listado') }}" title="Créditos" class="btn btn-default btn-flat btn-sm"><i class="fa  fa-dot-circle-o"></i></a>
									    	<a href="{{ asset('credits/'.$customer->id.'/assign') }}" title="Asignar salidas" class="btn btn-default btn-flat btn-sm"><i class="fa  fa-share-square-o"></i></a>
										@endif
										@if(Auth::user()->role->role_permission('delete_users') && $customer->id != 1)
										<a type="button" class="btn btn-default btn-flat btn-sm" title="Delete" data-toggle="modal" data-target="#deleteModal{{ $customer->id }}"><i class="fa fa-trash"></i></a>
										<div id="deleteModal{{ $customer->id }}" class="modal fade" role="dialog">
											<div class="modal-dialog">
											<div class="modal-content">
											<div class="modal-header">
											<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
											<h4 class="modal-title">{{trans('general.deleteconfirm')}} </h4>
											</div>
											<div class="modal-body">
											<p>{{trans('general.delete')}}</p>
											</div>
											<div class="modal-footer">
											<button type="button" class="btn btn-default btn-flat pull-left" data-dismiss="modal">{{trans('general.cancel')}}</button>
											{!! Form::open(['url' => ['companies/'.$customer->id], 'method' => 'delete']) !!}
											{!! Form::submit(trans('general.si'), ['class' => 'btn btn-success btn-flat']) !!}
											{!! Form::close() !!}
											</div>
											</div>
											</div>
										</div>
										@endif
									</div>
								</td>
								@endif
							</tr>
							@endforeach
						</table>
					</div>
					<div class="box-footer clearfix">
						<div class="row">
							<div class="col-xs-12">
								{{trans('general.mostrando')}} {{ $customers->firstItem() }} {{trans('general.de')}} {{ $customers->lastItem() }} {{trans('general.de')}} {{ $customers->total() }} {{trans('general.registros')}}
								<div class="pull-right">
								{!! $customers->links() !!}
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</div>
@endsection
