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

@section('content')
<div class="content-wrapper">
	<section class="content-header">
		<h1>
		{{trans('general.boats')}}
		</h1>
	</section>

	<section class="content">
		<div class="row">
			<div class="col-md-12">
				@include('alert.success')
				@include('alert.errorlist')
				@if(Auth::user()->role->role_permission('create_boat'))
				<a href="{{ asset('/boats/create') }}" type="button" class="btn btn-success btn-flat margin">{{trans('general.nuevo')}} {{trans('general.boat')}}</a>
				@endif
				<a href="{{ asset('/boats/deleted') }}" type="button" class="btn btn-default btn-flat margin"> {{trans('general.boat')}} Eliminadas</a>
				<div class="box box-success">
					<div class="box-header">
						<h3 class="box-title">{{trans('general.lista')}} {{trans('general.boats')}}</h3>
						<div class="box-tools">
							{!! Form::open(['url' => '/boats/search', 'method' => 'get']) !!}
							<div class="input-group input-group-sm" style="width: 150px;">
							{!! Form::text('term', null, ['class' => 'form-control pull-right', 'placeholder' => 'Search']) !!}
							<div class="input-group-btn">
							<button type="submit" class="btn btn-default"><i class="fa fa-search"></i></button>
							</div>
							</div>
							{!! Form::close() !!}
						</div>
					</div>
					<div class="box-body table-responsive no-padding">
						<table class="table table-hover">
							<tr>
								<th>ID</th>
								<th>{{trans('general.boat')}}</th>
								<th>{{trans('general.boatnumber')}}</th>
								<th>{{trans('general.tipo')}}</th>
								<th>{{trans('general.port')}}</th>
								
								@if(Auth::user()->role->role_permission('edit_boat') || Auth::user()->role->role_permission('delete_boat'))
								<th>Action</th>
								@endif
							</tr>
							@foreach($boats as $boat)
							<tr>
								<td>{{ $boat->id }}</td>
								<td>{{ $boat->name}}</td>
								<td>{{ $boat->number }}</td>
								<td>{{ $boat->boattype->name }}</td>
								<td>{{ $boat->port ? $boat->port->name :'' }}</td>
								
								@if(Auth::user()->role->role_permission('edit_boat') || Auth::user()->role->role_permission('delete_boat'))
								<td>
									<div class="btn-group">
										@if(Auth::user()->role->role_permission('edit_boat'))
										<a href="{{ asset('boats/'.$boat->id.'/edit') }}" title="Edit" class="btn btn-default btn-flat btn-sm"><i class="fa fa-pencil"></i></a>										<a href="{{ url('/blocks/'.$boat->id.'/listado') }}" title="Bloqueos" class="btn btn-default btn-flat btn-sm"><i class="fa fa-times-circle"></i></a>
										@endif
										@if(Auth::user()->role->role_permission('delete_boat'))
										<a type="button" class="btn btn-default btn-flat btn-sm" title="Delete" data-toggle="modal" data-target="#deleteModal{{ $boat->id }}"><i class="fa fa-trash"></i></a>
										<div id="deleteModal{{ $boat->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' => ['boats/'.$boat->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-md-12">
								{{trans('general.mostrando')}}  {{ $boats->firstItem() }} {{trans('general.de')}}  {{ $boats->lastItem() }} {{trans('general.de')}}  {{ $boats->total() }} {{trans('general.registros')}} 
								<div class="pull-right">
								{!! $boats->links() !!}
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</div>
@endsection