<?php $__env->startSection('content'); ?>
<div class="content-wrapper">
	<section class="content-header">
		<h1>
		<?php echo e(trans('general.incidences')); ?> 
		</h1>
	</section>

	<section class="content">
		<div class="row">
			<div class="col-md-12">
				<?php echo $__env->make('alert.success', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
				<?php if(Auth::user()->role->role_permission('create_incidence')): ?>
				<a href="<?php echo e(asset('/incidences/create')); ?>" type="button" class="btn btn-success btn-flat margin">	<?php echo e(trans('general.nuevo')); ?>  <?php echo e(trans('general.incidences')); ?> </a>
				<?php endif; ?>
				<div class="box box-success">
					<div class="box-header">
						<h3 class="box-title"><?php echo e(trans('general.lista')); ?>  <?php echo e(trans('general.incidences')); ?> </h3>
						<div class="box-tools">
							<?php echo Form::open(['url' => '/events/search', 'method' => 'get']); ?>

							<div class="input-group input-group-sm" style="width: 150px;">
							<?php echo 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>
							<?php echo Form::close(); ?>

						</div>
					</div>
					<div class="box-body table-responsive no-padding">
						<table class="table table-hover">
							<tr>
								<th>ID</th>
								<th><?php echo e(trans('general.subject')); ?> </th>
								<?php if(Auth::user()->role->layout == 1): ?>
								<th><?php echo e(trans('general.usuario')); ?></th>
								<?php endif; ?>
								<th><?php echo e(trans('general.fecha')); ?></th>
								
								<?php if(Auth::user()->role->role_permission('edit_incidence') || Auth::user()->role->role_permission('delete_incidence')): ?>
								<th><?php echo e(trans('general.accion')); ?></th>
								<?php endif; ?>
							</tr>
							<?php foreach($incidences as $incidence): ?>
							<tr>
								<td><?php echo e($incidence->id); ?></td>
								<?php if($incidence->read == 0): ?>
								<td><strong><?php echo e($incidence->subject); ?></strong></td>
								<?php else: ?>
								<td><?php echo e($incidence->subject); ?></td>
								<?php endif; ?>
								<?php if(Auth::user()->role->layout == 1): ?>
								<td><a href="<?php echo e(asset('/users/'.$incidence->user_id)); ?>"><?php echo e($incidence->user->first_name . ' ' . $incidence->user->last_name); ?></a></td>
								<?php endif; ?>
								<td><?php echo e(date('d/m/Y', strtotime($incidence->date))); ?></td>
								
								<?php if(Auth::user()->role->role_permission('edit_incidence') || Auth::user()->role->role_permission('delete_incidence')): ?>
								<td>
									<div class="btn-group">
										<?php if(Auth::user()->role->role_permission('edit_incidence')): ?>
										<a href="<?php echo e(asset('incidences/'.$incidence->id.'/edit')); ?>" title="Edit" class="btn btn-default btn-flat btn-sm"><i class="fa fa-pencil"></i></a>
										<a href="<?php echo e(asset('incidences/markasread/'.$incidence->id)); ?>" title="Marcar como leído" class="btn btn-default btn-flat btn-sm"><i class="fa fa-eye"></i></a>
										<?php endif; ?>
										<?php if(Auth::user()->role->role_permission('delete_incidence')): ?>
										<a type="button" class="btn btn-default btn-flat btn-sm" title="Delete" data-toggle="modal" data-target="#deleteModal<?php echo e($incidence->id); ?>"><i class="fa fa-trash"></i></a>
										<div id="deleteModal<?php echo e($incidence->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"><?php echo e(trans('general.deleteconfirm')); ?></h4>
											</div>
											<div class="modal-body">
											<p><?php echo e(trans('general.delete')); ?></p>
											</div>
											<div class="modal-footer">
											<button type="button" class="btn btn-default btn-flat pull-left" data-dismiss="modal"><?php echo e(trans('general.cancel')); ?></button>
											<?php echo Form::open(['url' => ['incidences/'.$incidence->id], 'method' => 'delete']); ?>

											<?php echo Form::submit(trans('general.si'), ['class' => 'btn btn-success btn-flat']); ?>

											<?php echo Form::close(); ?>

											</div>
											</div>
											</div>
										</div>
										<?php endif; ?>
									</div>
								</td>
								<?php endif; ?>
							</tr>
							<?php endforeach; ?>
						</table>
					</div>
					<div class="box-footer clearfix">
						<div class="row">
							<div class="col-xs-12">
								<?php echo e(trans('general.mostrando')); ?> <?php echo e($incidences->firstItem()); ?> <?php echo e(trans('general.de')); ?> <?php echo e($incidences->lastItem()); ?> <?php echo e(trans('general.de')); ?> <?php echo e($incidences->total()); ?> <?php echo e(trans('general.registros')); ?>

								<div class="pull-right">
								<?php echo $incidences->links(); ?>

								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</section>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make(Auth::check() && Auth::user()->role->layout == 1 ? 'layouts.admin' : 'layouts.employee', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>