<!DOCTYPE html>
<html lang="<?php echo e(str_replace('_', '-', app()->getLocale())); ?>">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0">
    <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">

    <title><?php echo e(config('app.name', 'Laravel')); ?></title>

    <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap">
    <link rel="stylesheet" href="<?php echo e(asset('css/app.css')); ?>">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.4/tiny-slider.css">
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">

    <script src="https://kit.fontawesome.com/b5101eab7c.js" crossorigin="anonymous"></script>
    <script src="<?php echo e(asset('js/app.js')); ?>" defer></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/tiny-slider/2.9.2/min/tiny-slider.js"></script>
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
</head>
<body id=dashboard onload="alertDashboard('<?php echo e($alert); ?>')">
    <div id="page">
        <div id="myModal" class="modal">
            <div class="modal-content">
                <div class="modal-header">
                    <span class="close">&times;</span>
                    <h1>OPERATEUR</h1>
                </div>
                <div class="modal-body">
                    <p id="email"></p>
                    <p id="tel"></p>
                </div>
            </div>
        </div>
        <div id="myModal-alert" class="modal-alert">
            <div class="modal-content-alert">
                <div class="modal-header-alert">
                    <span class="close">&times;</span>
                    <h1>PVO DOWN</h1>
                </div>
                <div class="modal-body-alert">
                    <p>Envoie SMS telephone / EMAIL vers un e-mail dédié qui doit être configurable dans le .env</p>
                </div>
                <div>
                    <form action="" method=POST>
                        <?php echo csrf_field(); ?>
                        <button>Envoyer</button>
                    </form>
                </div>
            </div>
        </div>
        <section>

            <?php if($B2L == true): ?>
                <span style="font-size: 44px"><?php echo e($bee2link_not_sent); ?> (B2L)&ensp;<i
                        class="fa-solid fa-triangle-exclamation" style="color: orange"></i></span><br>
            <?php endif; ?>
            <?php if($PVO == true): ?>
                <span style="font-size: 44px"><?php echo e($pvo_not_sent); ?> (PVO)&ensp;<i class="fa-solid fa-triangle-exclamation"
                        style="color: orange"></i></span><br>
            <?php endif; ?>
            <?php if($B2L == true): ?>
                <span style="font-size: 34px">Dernier véhicule B2L : X</span><br>
            <?php endif; ?>
            <?php if($PVO == true): ?>
                <span style="font-size: 34px">Dernier véhicule PVO :
                    <?php echo e(date('d-m-Y', strtotime($last_vehicle[0]->pvo_sent_at))); ?> - <?php echo e(date('H:i:s', strtotime($last_vehicle[0]->pvo_sent_at))); ?></span><br>
            <?php endif; ?>
            <br>
            <br>
            <span style="font-size: 21px">Véhicules non remontés depuis le <?php echo e(date('d-m-Y - H:i:s', strtotime($date_prise_en_compte))); ?></span>
            <span id="info-vehicle" style="display: none"><i class="fa-solid fa-triangle-exclamation" id="warning-pvo" style="color: orange; font-size: 22px"></i>&ensp;Dernier véhicule non remonté chez PVO : <strong><?php echo e($lastVehicleNotSendToPvo->name); ?></strong></span>
            <table id="dashboard-vehicules" class="searchlist">
                <tr class="header">
                    <th>Origine</th>
                    <th>Immatriculation</th>
                    <?php if($DASHBOARD_DEBUG == true): ?>
                        <th>Manager_ID</th>
                    <?php endif; ?>
                    <th>Entreprise</th>
                    <th>Concession</th>
                    
                    <?php if($B2L == true): ?>
                        <?php if($DASHBOARD_DEBUG == true): ?>
                            <th>id_client_bee2link</th>
                        <?php endif; ?>
                        <th>Etat envoi Bee2link</th>
                    <?php endif; ?>
                    <?php if($PVO == true): ?>
                        <?php if($DASHBOARD_DEBUG == true): ?>
                            <th>id_client_pvo</th>
                        <?php endif; ?>
                        <th>Etat envoi PVO</th>
                    <?php endif; ?>
                    <th>Date de mise à jour</th>
                    <th>Date de création</th>
                    <th>Opérateur Contacté</th>
                    <th>Détails</th>
                </tr>
                <?php $__currentLoopData = $vehicles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $vehicle): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr class="header">
                        <?php
                            $pattern_immat_1 = '/^[A-Z]{2}[0-9]{3}[A-Z]{2}$/i';
                            $pattern_immat_2 = '/^[A-Z]{2}[-][0-9]{3}[-][A-Z]{2}$/i';
                            $pattern_immat_3 = '/^[A-Z]{2}[ ][0-9]{3}[ ][A-Z]{2}$/i';
                            $pattern_chassis = '/^[0-9ABCDEFGHJKLMNPRSTUVWXYZ]{17}$/i';
                            $string_matching = $vehicle->name;
                        ?>

                        <?php if(preg_match($pattern_immat_1, $string_matching) || preg_match($pattern_immat_2, $string_matching) || preg_match($pattern_immat_3, $string_matching) || preg_match($pattern_chassis, $string_matching)): ?>
                            <td><img class="flag" src="<?php echo e(asset("assets/images/flags/Flag_of_Europe.svg.png")); ?>"></td>
                        <?php else: ?>
                            <td class="td-rouge">Invalide</td>
                        <?php endif; ?>

                        <td><a href='https://mycarlab.fr/clients/<?php echo e($vehicle->client_id); ?>/vehicule/<?php echo e($vehicle->id); ?>' target="_blank"><?php echo e($vehicle->name); ?></td>
                            <?php if($DASHBOARD_DEBUG == true): ?>
                                <?php if($vehicle->manager_id): ?>
                                    <td><?php echo e($vehicle->manager_id); ?></td>
                                <?php else: ?>
                                    <td>Inconnu</td>
                                <?php endif; ?>
                            <?php endif; ?>
                        <?php if(isset($vehicle->manager_id)): ?>

                            <?php for($i = 0; $i < count($users); $i++): ?>
                                <?php if($users[$i]->id === $vehicle->manager_id): ?>
                                    <?php if(isset($users[$i]->entreprise)): ?>
                                        <td><?php echo e($users[$i]->entreprise); ?></td>
                                    <?php else: ?>
                                        <td><?php echo e($users[$i]->name); ?></td>
                                    <?php endif; ?>
                                <?php endif; ?>
                            <?php endfor; ?>

                        <?php else: ?>
                            <td>Inconnu</td>
                        <?php endif; ?>

                        <?php for($i = 0; $i < count($users); $i++): ?>
                            <?php if($users[$i]->id === $vehicle->client_id): ?>
                                <?php if(isset($users[$i]->name)): ?>
                                    <td><?php echo e($users[$i]->name); ?></td>
                                <?php else: ?>
                                    <td>No Name</td>
                                <?php endif; ?>
                            <?php endif; ?>
                        <?php endfor; ?>
                        
                        <?php if($B2L === true): ?>
                            <?php if($vehicle->bee2link_sent === null && ($vehicle->id_bee2link === null && $vehicle->id_client_bee2link === null)): ?>
                                <?php if($DASHBOARD_DEBUG == true): ?>
                                    <td class="td-gris"> Pas de compte </td>
                                <?php endif; ?>
                                <td class="td-gris"> Pas de compte B2L </td>
                            <?php endif; ?>
                            <?php if($vehicle->bee2link_sent === null && ($vehicle->id_bee2link != null || $vehicle->id_client_bee2link != null)): ?>
                                <?php if($DASHBOARD_DEBUG == true): ?>
                                    <td class="td-rouge"> Active </td>
                                <?php endif; ?>
                                <td class="td-rouge"> Véhicule non remonté </td>
                            <?php endif; ?>
                            <?php if($vehicle->bee2link_sent === 1 && ($vehicle->id_bee2link != null || $vehicle->id_client_bee2link != null)): ?>
                                <?php if($DASHBOARD_DEBUG == true): ?>
                                    <td class="td-vert"> Active </td>
                                <?php endif; ?>
                                <td class="td-vert"> OK </td>
                            <?php endif; ?>
                        <?php endif; ?>
                        <?php if($PVO === true): ?>
                            <?php if($vehicle->pvo_sent === null && ($vehicle->id_pvo === null && $vehicle->id_client_pvo === null)): ?>
                                <?php if($DASHBOARD_DEBUG == true): ?>
                                    <td class="td-gris"> Pas de compte </td>
                                <?php endif; ?>
                                <td class="td-gris"> Pas de compte PVO </td>
                            <?php endif; ?>
                            <?php if($vehicle->pvo_sent === null && ($vehicle->id_pvo != null || $vehicle->id_client_pvo != null)): ?>
                                <?php if($DASHBOARD_DEBUG == true): ?>
                                    <td class="td-rouge"> Active </td>
                                <?php endif; ?>
                                <td class="td-rouge"> Véhicule non remonté </td>
                            <?php endif; ?>
                            <?php if($vehicle->pvo_sent === 1 && ($vehicle->id_pvo != null || $vehicle->id_client_pvo != null)): ?>
                                <?php if($DASHBOARD_DEBUG == true): ?>
                                    <td class="td-vert"> Active </td>
                                <?php endif; ?>
                                <td class="td-vert"> OK </td>
                            <?php endif; ?>
                        <?php endif; ?>
                        <td><?php echo e(date('d-m-Y H:i:s', strtotime($vehicle->updated_at))); ?></td>
                        <td><?php echo e(date('d-m-Y H:i:s', strtotime($vehicle->created_at))); ?></td>

                        <?php switch($vehicle->mail_sent_operator):
                            case (null): ?>
                                <td class="td-rouge">Non</td>
                            <?php break; ?>

                            <?php case (1): ?>
                                <td class="td-vert">1 fois</td>
                            <?php break; ?>

                            <?php case (2): ?>
                                <td class="td-orange">2 fois</td>
                            <?php break; ?>

                            <?php case (3): ?>
                                <td class="td-rouge">3 fois</td>
                            <?php break; ?>

                            <?php default: ?>
                        <?php endswitch; ?>

                        <?php for($i = 0; $i < count($users); $i++): ?>
                            <?php if($users[$i]->id === $vehicle->operator_id): ?>
                                <?php if(isset($users[$i]->email) && isset($users[$i]->tel1)): ?>
                                    <?php
                                        $email = $users[$i]->email;
                                        $tel = $users[$i]->tel1;
                                    ?>
                                    <td onclick="modalOperator('<?php echo e($email); ?>', '<?php echo e($tel); ?>')">
                                        <i class="fa-solid fa-eye"></i>
                                    </td>
                                <?php else: ?>
                                    <td>Email Non renseigné</td>
                                <?php endif; ?>
                            <?php endif; ?>
                        <?php endfor; ?>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </table>
        </section>
        <div>
            <?php echo e($vehicles->links('vendor.pagination.custom')); ?>

        </div>
        <?php
            header('Refresh:60');
        ?>
    </div>
</body>
</html>
<?php /**PATH /var/www/html/dashboard-vehicules/dashboard-vehicules/resources/views/dashboardVehicles.blade.php ENDPATH**/ ?>