<?php
    PuzzleHTML::setIcon('<i class="fas fa-file-import"></i>');
    PuzzleHTML::setTitleText($importacion_stock_lg);
    echo PuzzleHTML::Title();
?>

<div class="text-center">
  <div class="spinner-grow d-none mt-4" role="status">
    <span class="sr-only">Loading...</span>
  </div>
</div>
<form action="php_o/ajustes-excel.php" method="post" id="excel-stock" enctype="multipart/form-data" class="px-2 mb-5 display-none">

    <div class="custom-file mr-2">
        <input type="file"  name="excel" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" class="custom-file-input" id="excel" lang="es" required>
        <label class="custom-file-label" for="excel"><?php echo $selecciona_archivo_lg; ?></label>
        <div class="invalid-feedback"><?php echo $archivo_requerido_lg; ?></div>
    </div>
    <small id="exelhelp" class="form-text text-muted mb-3"><?php echo $archivos_excel_aceptados_lg; ?></small> 
    

    <button type="submit" class="btn btn-primary"><?php echo $subir_archivo_lg; ?></button>

</form>

<div class="table-responsive p-3 border rounded shadow bg-light display-none">
    <table class="table table-striped display">
        <thead>
            <tr>
                <th scope="col"><?php echo $vehiculo_lg; ?></th>
                <th scope="col"><?php echo $bastidor_lg; ?></th>
                <th scope="col"><?php echo $matricula_lg; ?></th>
            </tr>
        </thead>
        <tbody>
        <?php
            $html = '';
            $res = $Schema->executeQuery('SELECT V.MOSTRAR, V.BASTIDOR, V.MATRICULA 
            FROM VEHICULOS V
            WHERE IMPORTACION_EXCEL = ?', 'i', [1]);
            if($res->num_rows) {
                while($row = $res->fetch_array()) {
                    $html .= '<tr>';
                        $html .= '<td>' . $row['MOSTRAR'] . '</td>';
                        $html .= '<td>' . $row['BASTIDOR'] . '</td>';
                        $html .= '<td>' . $row['MATRICULA'] . '</td>';
                    $html .= '</tr>';
                }
            } 
            echo $html;
        ?>
        </tbody>
    </table>
</div>
<div class="mb-5 pb-5"></div>


<script>
    $('#excel-stock').on('submit', function() {
        $('.spinner-grow').removeClass('d-none');
        $('.display-none').fadeOut();
    })
</script>