@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.noticias')}} 
		</h1>
	</section>

	<section class="content">
		<div class="row">

		     @if(Auth::user()->role->layout != 1)
			<div class="col-md-12">
				@foreach($notices as $notice)
				<div class="box box-success">
					<div class="box-header">
						<h3 class="box-title">{{ $notice->title }}</h3>
					</div>
					<div class="box-body">
						{{ $notice->description }}
					</div>
				</div>
				@endforeach
			</div>

		     @else

			<div class="col-md-12">
				@include('alert.success')
				@if(Auth::user()->role->role_permission('create_notices'))
				<a href="{{ asset('/notices/create') }}" type="button" class="btn btn-success btn-flat margin">{{trans('general.nuevo')}}  {{trans('general.noticia')}} </a>
				@endif
				<div class="box box-success">
					<div class="box-header">
						<h3 class="box-title">{{trans('general.lista')}}  {{trans('general.noticias')}} </h3>
						<div class="box-tools">
							{!! Form::open(['url' => '/notices/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>Img</th>
								<th>{{trans('general.titulo')}} </th>
								<th>{{trans('general.descripcion')}} </th>
								<th>{{trans('general.estado')}} </th>
								@if(Auth::user()->role->role_permission('edit_notices') || Auth::user()->role->role_permission('delete_notices'))
								<th>{{trans('general.accion')}}</th>
								@endif
							</tr>
							@foreach($notices as $notice)
							<tr>
								<td>{{ $notice->id }}</td>
								<td>	<img src="{{ asset($notice->image) }}" alt="Product Image"></td>
								<td><a href="{{ asset('notices/'.$notice->id) }}">{{ $notice->title }}</a></td>
								<td>{{ $notice->description }}</td>
								<td>{!! $notice->published ? '<span class="label label-success">'.trans('general.visible').'</span>' : '<span class="label label-danger">'.trans('general.oculto').'</span>' !!}</td>
								@if(Auth::user()->role->role_permission('edit_notices') || Auth::user()->role->role_permission('delete_notices'))
								<td>
									<div class="btn-group">
										@if(Auth::user()->role->role_permission('edit_notices'))
										<a href="{{ asset('notices/'.$notice->id.'/edit') }}" title="Edit" class="btn btn-default btn-flat btn-sm"><i class="fa fa-pencil"></i></a>
										@endif
										@if(Auth::user()->role->role_permission('delete_notices'))
										<a type="button" class="btn btn-default btn-flat btn-sm" title="Delete" data-toggle="modal" data-target="#deleteModal{{ $notice->id }}"><i class="fa fa-trash"></i></a>
										<div id="deleteModal{{ $notice->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' => ['notices/'.$notice->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')}} {{ $notices->firstItem() }} {{trans('general.de')}} {{ $notices->lastItem() }} {{trans('general.de')}} {{ $notices->total() }} {{trans('general.registros')}}
								<div class="pull-right">
								{!! $notices->links() !!}
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		   @endif
		</div>
	</section>
</div>
@endsection
