<?php $__env->startSection('morecss'); ?>
<style>
.messages{font-size:small}
</style>
<?php $__env->stopSection(); ?>
<?php $__env->startSection('content'); ?>
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card">
                <div class="card-header"><h1>Demandes</h1></div>
 				<?php if(session('status')): ?>
                    <div class="alert alert-success" role="alert">
                        <?php echo e(session('status')); ?>

                    </div>
                <?php endif; ?>
                <?php if($errors->any()): ?>
    				<ul class="alert alert-warning">
    					<?php $__currentLoopData = $errors->all(); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $error): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
    					<li><?php echo e($error); ?></li> <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
    				</ul>
				<?php endif; ?> 
				<?php if(session()->has('message')): ?>
    				<div class="alert alertToolsBar alert-info alert-dismissible fade show }}"> 
                    <?php echo session('message'); ?>

                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                      </button>
                    </div>
    			<?php endif; ?>
                <div class="card-body">
                	<table class="table">
				        <thead>
				            <tr>
				               <th>Date</th>
				                <th>Titre</th>
				                <th>Statut</th>
				                <?php if(!Auth::user()->isClient()): ?>
				                <th>Auteur</th>
				                <?php endif; ?>
				                <th>messages</th>
				        </thead>
				        <tbody>
				        <?php $__currentLoopData = $demandes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $demande): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
				            <tr 
			                <?php if($demande->current_status_id=='PAYEE' && (\Carbon\Carbon::now()->diffInDays($demande->created_at_date_object)<7)): ?> class="table-warning"
			                <?php elseif($demande->current_status_id=='PAYEE'): ?> class="table-danger" 
			                	<?php endif; ?>>
			                	<td><?php echo e($demande->created_at_date); ?> à <?php echo e($demande->created_at_time); ?></td>
			                    <td class="text-primary">
			                    	<strong><a href="<?php echo e(route('demandes.show',$demande->id)); ?>"><?php echo e($demande->libelle); ?></a></strong>
			                    </td>
			                    <td><?php if($demande->current_status): ?> <?php echo e($demande->current_status->libelle); ?> <?php endif; ?></td>
			                    <?php if(!Auth::user()->isClient()): ?>
			                    <td><?php echo e($demande->user->fullname); ?></td>
			                    <?php endif; ?> 
                    			<td>
                    			<?php if(count($demande->messages)): ?> 
                    				<a class="dropdown-toggle" data-toggle="dropdown" href="#"><?php echo e(count($demande->messages)); ?> messages dont <?php echo e(count($demande->messages->where('lu','=',null))); ?> non lus
                    				<span class="caret"></span></a>
                            		<div class="dropdown-menu messages">
                                	<?php $__currentLoopData = $demande->messages->where('lu','=',null); $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $message): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
            							<a class="dropdown-item" href="<?php echo e(route('demandes.show',$demande->id)); ?>#<?php echo e($message->id); ?>">le <?php echo e($message->created_at_date); ?> à <?php echo e($message->created_at_time); ?> par <?php echo e($message->user->fullname); ?></a>
                                	<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                        	    	</div>
                            	
                            	<?php endif; ?>
                            			</td> 
        			                </tr>
        			            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
				        </tbody>
				    </table>
                	<?php echo e($demandes->links()); ?>

                

                	<?php if(Auth::user()->isClient()): ?>
                    <h2><a href="<?php echo e(route('demandes.create')); ?>" class="btn btn-warning btn-lg"><i class="fas fa-comment"></i> Faire une demande d'intervention</a></h2>
                    <?php endif; ?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH C:\xampp\htdocs\leprisme_travaux\resources\views/demandes/index.blade.php ENDPATH**/ ?>