<?php
    session_start();
    $usuarioSession = $_SESSION['USUARIO'];
    $grupo = $_SESSION['GRUPO'];
    $contacto = $_SESSION['CONTACTO'];
    $awa_session_id = $_SESSION['AWA_SESION_ID'];
    include('includes/conex.php');
    include('includes/eat.php');
    include('includes/esquemas.php');
    include('class/Static.php');
    include('class/Schema.php');
    include('class/PuzzleHTML.php');
    include('class/MotherCar.php');
    include('lg/config_vo.php');
    if(!isset($usuarioSession) or $awa_session_id != $awa_id)
    {
        eatCookies();
        header('Location:index.php');
    }
    if(isset($_COOKIE['usuario']) AND $_COOKIE['usuario'] != $staticUsu )
    {
        eatCookies();
        header('Loction:index.php');
    }
    if(isset($_COOKIE['idioma']))
    {
        include('lg/LG_' . $_COOKIE['idioma'] . '.php');
    }
    else
    {
        include('lg/LG_SP.php');
    }
    if(isset($_REQUEST['idCAR']))
    {
        $idCAR = Statics::SafeInput($con,$_REQUEST['idCAR']);
    }
    else
    {
        Statics::RedLight();
    }

?>
<!DOCTYPE html>
<html lang="es">

<head>
    <?php include('includes/head.php');?>
    <title><?php echo $favicon_title_lg?></title>
    <style>
        .div-sorting
        {
            width : 100%;
            height: 459px;
            margin-top: 25px;
            border: 1px solid #DEE2E6;
            background-color: white;
        }
        .img-sorting
        {
           width: 100%;
           height: 100%;
           object-fit: contain;
        }
        .no-img
        {
            dispaly: block;
            width: 100px;
            margin: 100px 300px;
        }
        .c-pointer
        {
            cursor: pointer;
        }
        @media (max-width: 992px) 
        {
            #carousel-hidden-overflow-img {
                height: 100%;
            }
            .h-img-fit
            {
                height: 100%;
            }
            .no-img
            {
                dispaly: block;
                width: 100px;
                margin: 50px 70px;
            }
        }
    </style>
</head>

<body class="bg-light">
    <!-- //! Iincludes Top Bar & Menu & Datos Usuario 
    -->
    <?php
    $page = "";
    include("includes/datosUsuario.php"); 
    include('includes/menu-dashboard.php');
    include("includes/functions.php");
    include('includes/nav.php');
    ?>

    <section class="container py-5 my-3">
        <?php
            
            $_SESSION['CODIGO_COCHE'] = $idCAR;
            $Schema = new Schema($con);
            $MotherCar = new MotherCar($con);
            $rowCar = $MotherCar->getCarData($lg, $_SESSION['CODIGO_COCHE']);

            $titulo = $rowCar['MARCAS'] . " " . $rowCar['MODELOS'];
            $volver_link = 'resultados.php';
            
        ?>


        <div class="border-bottom pb-2">
            <?php
                if(isset($_SESSION['msg']))
                {
                    msgInfo(99,$vehiculo_lg,$reserva_rechazada_lg);
                    unset($_SESSION['msg']);
                } 
            ?>
            <div class="d-flex justify-content-between">
                <?php
                    $reservado_btn = '';
                    if(!empty($rowCar['RESERVA']))
                    {
                        $hasta = date('d/m/Y',strtotime($rowCar['RESERVA']));
                        $hoy = date('d/m/Y');
                        if($hasta == $hoy)
                        {
                            $sql = "UPDATE VEHICULOS SET RESERVA = '' WHERE CODIGO = ?";
                            $stmt = $con->prepare($sql);
                            $stmt->bind_param('i',$codigo);
                            $stmt->execute();
                        }
                        else
                        {
                            $reservado_btn = '
                            <span class="c-pointer bg-danger px-2 pb-1 text-white font-weight-normal mt-n1" data-toggle="modal" data-target="#modalReservado">
                                ' . strtoupper($reservado_lg) . '
                            </span>';
                            $titulo = $titulo . " " . $reservado_btn;
                        }
                    }
                    echo PuzzleHTML::MainTitle($titulo);
                    echo PuzzleHTML::Back($volver_link, $volver_lg);
                ?>
            </div>

            <span class="text-muted"><?php echo $rowCar['ID_CAR']?></span>
        </div>


        <div class="border p-4 mb-5 mt-3">
            <div class="col-12 d-flex justify-content-end">

                <?php
                    PuzzleHTML::ButtonModal($comprar_lg, 'shopping', 'fas fa-shopping-cart text-muted');
                    PuzzleHTML::ButtonModal($ver_historial_ofertas_lg, 'exampleModalLong', 'far fa-eye text-muted');
                    PuzzleHTML::ButtonModal($reservar_lg, 'reservarcoche', 'far fa-calendar-plus text-muted');
                    PuzzleHTML::ButtonModal($notas_destacadas_lg, 'notas_destacadas', 'far fa-sticky-note text-muted');
                ?>

                <!-- <span data-toggle="tooltip" data-placement="top" title="<?php echo $generar_oferta_nuevo_cliente_lg?>">
                    <a href="resultados-ficha.php?idCAR=<?php echo $idCAR;?>&c0n74c7=n0" style="cursor:pointer;">
                        <i class="fas fa-file-upload fa-lg text-muted mr-3"></i>
                    </a>
                </span> -->

                <?php if(permisos($con,1,$contacto)){?>
                    <a href="resultados-editar.php" data-toggle="tooltip" data-placement="top" title="<?php echo $gestionar_lg?>"><i class="fas fa-cogs fa-lg mr-3 text-muted"></i></a>
                <?php } ?>

            </div>
        


            <div class="row">
                <div class="col-12 col-lg-8">
                    <a data-toggle="modal" data-target="#bigBoySlider">
                        <?php
                            $esquema = get_esquemas_y_esquemas_estructuras($con)[0];
                            $grupoe = get_esquemas_y_esquemas_estructuras($con)[1];
                            echo $MotherCar->sliderCar($esquema, $grupoe, $idCAR, 'div-sorting');
                        ?>  
                    </a>

                    <div class="modal fade" id="bigBoySlider" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                        <div class="modal-dialog modal-xl">
                            <div class="modal-content">
                                <?php
                                    $esquema = get_esquemas_y_esquemas_estructuras($con)[0];
                                    $grupoe = get_esquemas_y_esquemas_estructuras($con)[1];
                                    echo $MotherCar->sliderCar($esquema, $grupoe, $idCAR, false, 2);
                                ?> 
                            </div>
                        </div>
                    </div>
                </div>

                <div class="col-md-12 col-lg-4 py-2">
                    <ul class="list-group mb-3 py-3" style='cursor:default'>
                        <li class="list-group-item d-flex justify-content-between lh-condensed bg-light">
                                <div class="d-flex justify-content-start w-100 mt-n1">
                                    <?php
                                        echo '<div class="c-pointer">
                                                <span data-toggle="tooltip" data-placement="top" title="' . $precio_profesional_lg .'">
                                                    <i class="fas fa-user-tie text-secondary" data-toggle="modal" data-target="#precio_pro"></i>
                                                </span>
                                            </div>';
                                    ?>
                                </div>
                                <div class="my-1 text-muted">
                                        <?php 
                                            echo "<h6>$precio_lg</h6>"; 
                                            echo $MotherCar->car_price($rowCar['VENTA_TOTAL'], $rowCar['VENTA_TOTALSINDTO'], 'h4#class="text-muted font-weight-light"');
                                        ?>
                                </div>

                                <div class="my-1 text-muted float-right">
                                        <?php 
                                            echo "<h6>$precio_financiado_lg</h6>"; 
                                            echo $MotherCar->car_price($rowCar['TOTAL_FINANCIADO'], $rowCar['TOTAL_SIN_DTO_FINANCIADO'], 'h4#class="text-muted font-weight-light"');
                                        ?>
                                </div>

                                

                                
                                    
                            
                        </li>

                        <?php
                            $MotherCar->listadoVehiculoFicha($combustible_lg, NULL, utf8_encode($rowCar['DESCRIPCION_LG1']), $cambio_lg, NULL, utf8_encode($rowCar['DESCRIPCION_LG2']));
                            $MotherCar->listadoVehiculoFicha($carroceria_lg, NULL, utf8_encode($rowCar['DESCRIPCION_LG3']));
                            $MotherCar->listadoVehiculoFicha($ano_fabricacion_lg, NULL, $rowCar['ANO_FAB'], $kilometros_lg, NULL, $rowCar['KM']);
                            $potencia = !empty($rowCar['POTENCIA']) ? utf8_encode($rowCar['POTENCIA']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($distintivos_ambientales_lg, NULL, $rowCar['DESCRIPCION_LG8'], $potencia_lg, NULL, $potencia);
                            
                        ?>
                    </ul>

                </div>


                <h4 class="col-12 mb-3 font-weight-normal" style='cursor:default'>
                    <span class="text-muted"><?php echo $datos_de_interes_lg?></span>
                </h4>
                <div class="col-md-4 mb-2">
                    <ul class="list-group mb-3" style='cursor:default'>
                        <?php
                            $motor_cc = !empty($rowCar['MOTOR']) ? utf8_encode($rowCar['MOTOR']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($motor_cc_lg, NULL, $motor_cc);

                            $nr_velocidades = !empty($rowCar['VELOCIDADES']) ? utf8_encode($rowCar['VELOCIDADES']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($velocidades_lg, NULL, $nr_velocidades);

                            $garantia = !empty($rowCar['GARANTIA']) ? utf8_encode($rowCar['GARANTIA']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($garantia_lg, NULL, $garantia);
                        ?>
                    </ul>  
                </div>

                <div class="col-md-4 mb-3">
                    <ul class="list-group mb-3" style='cursor:default'>
                        <?php
                            $version = !empty($rowCar['VERSION']) ? utf8_encode($rowCar['VERSION']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($version_lg, NULL, $version);

                            $fecha_matriculacion = !empty($rowCar['MATRICULACION']) ? utf8_encode($rowCar['MATRICULACION']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($ano_matriculacion_lg, NULL, $fecha_matriculacion);

                            $color_principal = !empty($rowCar['COLORPRI_LIT']) ? utf8_encode($rowCar['COLORPRI_LIT']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($color_lg, 'fill-drip ' . $rowCar['EXTRA1'], $color_principal);

                            
                        ?>
                    </ul>   
                </div>

                <div class="col-md-4 mb-3">
                    <ul class="list-group mb-3" style='cursor:default'>
                        <?php
                            $itv_info_title = $fecha_itv_lg . " / " . $itv_proxima_lg;
                            $itv_ultima = !empty($rowCar['ITV_ULTIMA']) ? date('d/m/Y',strtotime($rowCar['ITV_ULTIMA'])) : $sin_asignar_lg;
                            $itv_proxima = !empty($rowCar['ITV_PROXIMA']) ? date('d/m/Y',strtotime($rowCar['ITV_PROXIMA'])) : $sin_asignar_lg;
                            $itv_info_data = "$itv_ultima / $itv_proxima";
                            $MotherCar->listadoVehiculoFicha($itv_info_title, NULL, $itv_info_data);

                            $llaves = !empty($rowCar['LLAVES']) ? utf8_encode($rowCar['LLAVES']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($llaves_lg, NULL, $llaves);

                            $procedencia = !empty($rowCar['USO_ANTERIOR']) ? utf8_encode($rowCar['USO_ANTERIOR']) : $sin_asignar_lg;
                            $MotherCar->listadoVehiculoFicha($procedencia_lg, NULL, $procedencia);
                        ?>
                    </ul>   
                </div>


                <?php
                    $sql = "SELECT L.DESCRIPCION_$lg AS DESCRIPCION_LG
                    FROM VEHICULOS_LITERALES L
                    INNER JOIN VEHICULOS_OPCIONES O ON L.CODIGO = O.OPCION AND L.TIPO = ?
                    WHERE O.VEHICULO = ?";
                    $res = $Schema->executeQuery($sql, 'si', ['TIP_OPC', $_SESSION['CODIGO_COCHE']]);
                    if($res->num_rows)
                    {
                        echo '
                            <div class="col-12 mb-5">
                                    <h4 class="d-flex justify-content-between align-items-center mb-3" style="cursor:default">
                                    <span class="text-muted">' . $equipamiento_lg .'</span>
                                </h4>
                                <ul class="list-group">
                                        <li class="list-group-item d-flex justify-content-start">';
                                        while($rowEquipamiento = $res->fetch_array())
                                        {
                                            echo '<span class="text-muted p-2 border m-1 rounded c-default">' . utf8_encode($rowEquipamiento['DESCRIPCION_LG']) .'</span>';
                                        }
                                echo '</li>';
                            if(!empty($rowCar['OTRO_EQUIP'])) 
                            {
                                echo '
                                    <li class="list-group-item d-flex justify-content-start">
                                        <span class="text-muted p-2 border m-1 rounded c-default">' . utf8_encode($rowCar['OTRO_EQUIP']) .'</span>
                                    </li>';
                            }
                        echo '
                                </ul>
                            </div>';
                    }
                ?>


                <div class="col-12 mb-5">
                    <h4 class="mb-3" style='cursor:default'>
                        <span class="text-muted"><?php echo $ubicacion_lg; ?></span>
                    </h4>
                    <ul class="list-group">
                        <li class="list-group-item d-flex justify-content-between">
                            <p class="mt-2 text-muted">
                                <?php echo "Avn de America nº1337"; ?>
                            </p>
                            <a href="#" class="c-pointer"><i class="fas fa-map-marker-alt fa-lg text-danger"></i></a>
                        </li>
                    </ul>
                </div>




                <div class="col-12 mt-5">
                    <h4 class="mb-3 text-muted"><?php echo $generar_oferta_lg; ?></h4>
                    
                    <form action="resultados-ficha-pdf.php" id="form-cliente" method="post" class="needs-validation mt-4" novalidate="">
                        
                        <?php
                            
                            if(isset($_GET['codigo_cliente']))
                            {
                                $sql = "SELECT NOMBRE, APELLIDO1, APELLIDO2, EMAIL1, TLFNO1, NIF, NOTAS FROM CONTACTOS WHERE CODIGO = ?";
                                $res = $Schema->executeQuery($sql, 'i', [$_GET['codigo_cliente']]);
                                $rowCliente = $res->fetch_array();
                                $rgpdLINK = '<a class="btn btn-link" target="_blank" href="rgpd.php?contacto=' . $_GET['codigo_cliente'] . '"><i class="fas fa-gavel fa-lg"></i></a>';
                            }
                                
                            $firstName = isset($_GET['codigo_cliente']) ? $rowCliente['NOMBRE'] : '';
                            $lastName = isset($_GET['codigo_cliente']) ? $rowCliente['APELLIDO1'] : '';
                            $secondLastName = isset($_GET['codigo_cliente']) ? $rowCliente['APELLIDO2'] : '';
                            $emailCliente = isset($_GET['codigo_cliente']) ? $rowCliente['EMAIL1'] : '';
                            $telefonoCliente = isset($_GET['codigo_cliente']) ? $rowCliente['TLFNO1'] : '';
                            $nifCliente = isset($_GET['codigo_cliente']) ? $rowCliente['NIF'] : '';
                            $cliente = isset($_GET['codigo_cliente']) ? $rgpdLINK : NULL;

                            //Abrir el modal, el segundo argumento es el header(donde se debe volver) + ajax/buscar-contacto en el switch se debe asignar la ruta nueva si no existe;
                            PuzzleHTML::buscarContacto($buscar_lg, 'resultados-ficha.php', $cliente, $resultados_busqueda_lg);

                        ?>

                        <div class="row mt-5">

                            <?php 
                                //primer argumento es el name y el id, segundo el label y placeholder, el 3 tipo de input, 4 si es obligatorio + 5 el mensaje 
                                PuzzleHTML::inputsClientes('firstName', $nombre_cliente_lg, 'text', $firstName, 'required', $campo_obligatorio_lg); 
                                PuzzleHTML::inputsClientes('lastName', $primer_apellido_cliente_lg, 'text', $lastName, 'required', $campo_obligatorio_lg); 
                                PuzzleHTML::inputsClientes('secondLastName', $segundo_apellido_cliente_lg, 'text', $secondLastName); 
                                PuzzleHTML::inputsClientes('email', $email_lg, 'email', $emailCliente, 'required', $campo_obligatorio_lg); 
                                PuzzleHTML::inputsClientes('telefono', $telefono_lg, 'number', $telefonoCliente, 'required', $campo_obligatorio_lg); 
                                PuzzleHTML::inputsClientes('nif', $nif_cif_lg, 'text', $nifCliente); 
                                PuzzleHTML::inputsClientes('precio_oferta', $precio_oferta_lg, 'number', NULL, 'required', $importe_no_valido_lg); 
                                PuzzleHTML::inputsClientes('financiacion', $financiacion_meses_lg, 'number'); 
                                PuzzleHTML::inputsClientes('garantia', $garantia_meses_lg, 'number'); 
                                PuzzleHTML::TextArea('nota', $otra_especificaciones_lg); 
                            ?>


                            

                        </div>
                        


                    <button class="btn btn-primary btn-lg btn-block" id="jump" onclick="checkPrecio()" type="submit"><?php echo $siguiente_lg?></button>
                    </form>
                </div>
                    

            </div>



            



            <!-- Modal historial ofertas -->
            <div class="modal fade" id="exampleModalLong" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title text-muted" id="exampleModalLongTitle"><i class="fas fa-history mr-2"></i><?php echo $historial_ofertas_lg?></h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">
                            <table class="table table-sm table-hover" id="tableOfertas">
                                <thead class="thead-light">
                                    <tr class="text-center">
                                        <th scope="col">#</th>
                                        <th scope="col"><?php echo $usuario_lg?></th>
                                        <th scope="col"><?php echo $fecha_lg?></th>
                                        <th scope="col"><?php echo $email_lg?></th>
                                        <th scope="col"><?php echo $accion_lg?></th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <?php
                                        $nr = 1;
                                        $sqlHistorial = "SELECT VEHICULOS_HISTORIAL.*,VEHICULOS_LITERALES.*
                                                FROM VEHICULOS_HISTORIAL,VEHICULOS_LITERALES
                                                WHERE VEHICULOS_LITERALES.CODIGO = VEHICULOS_HISTORIAL.ACCION
                                                AND VEHICULOS_LITERALES.TIPO = ?
                                                AND VEHICULOS_HISTORIAL.VEHICULO = ?
                                                AND VEHICULOS_HISTORIAL.ACCION = ?
                                                ORDER BY VEHICULOS_HISTORIAL.FECHA DESC";
                                        $res = $Schema->executeQuery($sqlHistorial, 'sii', ['TIP_TRA', $idCAR, 4]);
                                        while($rowHistorial = $res->fetch_array())
                                        {
                                    ?>
                                    <tr class="text-center">
                                        <th scope="row"><?php echo $nr++;?></th>
                                        <td><?php echo utf8_encode($rowHistorial['USUARIO']);?></td>
                                        <td><?php echo date('H:i:s d/m/Y',strtotime($rowHistorial['FECHA']));?></td>
                                        <td><?php echo '<a href="#" class="text-decoration-none">' . $rowHistorial['DETALLE'] . '</a>';?></td>
                                        <td>
                                            <a href="php_o/resultados-download-pdf.php?doc=<?php echo $rowHistorial['DOCUMENTO']?>"><i class="fas fa-download fa-lg" data-toggle="tooltip" data-placement="top" title="<?php echo $descargar_lg?>"></i></a>
                                        </td>
                                    </tr>
                                    <?php } ?>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>




            <!-- Modal reservar coche -->
            <div class="modal fade" id="reservarcoche" tabindex="-1" role="dialog" aria-labelledby="reservarcoche" aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                    <div class="modal-header">
                        <h5 class="modal-title text-muted" id="exampleModalLabel"><i class="fas fa-calendar-plus mr-2"></i><?php echo $reservar_lg?></h5>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <form class="needs-validation" method="post" action="php_o/ficha-reservar.php" novalidate>
                        <div class="modal-body">
                            <div class="form-row">
                                <div class="col-md-6 mb-3">
                                    <label for="dni"><?php echo $cliente_de_reserva_lg?></label>
                                    <input type="text" name="dni" class="form-control" id="dni" placeholder="<?php echo $cliente_de_reserva_lg?>" required>
                                    <div class="invalid-tooltip">
                                        <?php echo $campo_obligatorio_lg?>
                                    </div>
                                </div>
                                <div class="col-md-6 mb-3">
                                    <label for="reserva"><?php echo $fecha_fin_de_reserva_lg?></label>
                                    <input type="date" name="fecha" class="form-control" id="reserva" placeholder="State" required>
                                    <div class="invalid-tooltip">
                                        <?php echo $guardar_reserva_lg?>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal-footer">
                            <button class="btn btn-primary btn-block" type="submit"><?php echo $guardar_reserva_lg?></button>
                        </div>
                    </form>
                    </div>
                </div>
            </div>



            <!-- Modal liberar oferta -->
            <div class="modal fade" id="modalReservado" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                    <?php 
                        $sqlReserva = "SELECT H.DETALLE, C.MOSTRAR, C.TLFNO1, C.EMAIL1
                        FROM VEHICULOS_HISTORIAL H
                        INNER JOIN CONTACTOS C ON C.CODIGO = H.CONTACTO
                        WHERE H.VEHICULO = ?";
                        $resReserva = $Schema->executeQuery($sqlReserva, 'i' , [$_SESSION['CODIGO_COCHE']]);
                        $rowReserva = $resReserva->fetch_array();
                    ?>
                        <div class="modal-header">
                            <h5 class="modal-title" id="exampleModalLabel"><?php echo $reservado_lg?></h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body">

                            <ul class="list-group mb-3">
                                <li class="list-group-item d-flex justify-content-between lh-condensed bg-light">
                                    <div>
                                        <small class="my-0"><i class="fas fa-user text-secondary mr-1"></i><?php echo $nombre_lg?></small>
                                        <h6 class="text-dark"><?php echo $rowReserva['MOSTRAR']?></h6>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between lh-condensed bg-light">
                                    <div>
                                        <small class="my-0"><i class="fas fa-envelope text-secondary mr-1"></i><?php echo $email_lg?></small>
                                        <h6 class="text-dark"><?php echo $rowReserva['EMAIL1']?></h6>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between lh-condensed bg-light">
                                    <div>
                                        <small class="my-0"><i class="fas fa-mobile text-secondary mr-1"></i><?php echo $telefono_lg?></small>
                                        <h6 class="text-dark"><?php echo $rowReserva['TLFNO1']?></h6>
                                    </div>
                                </li>
                                <li class="list-group-item d-flex justify-content-between lh-condensed bg-light">
                                    <div>
                                        <small class="my-0"><i class="fas fa-calendar-day text-secondary mr-1"></i><?php echo $fecha_hasta_lg?></small>
                                        <h6 class="text-dark"><?php echo date('d/m/Y',strtotime($rowCar['RESERVA']))?></h6>
                                    </div>
                                </li>
                            </ul>
                        </div>
                        <div class="modal-footer">
                            <button type="button" class="btn btn-secondary" data-dismiss="modal"><?php echo $cerrar_lg?></button>
                            <a href="php_o/liberar-reserva.php" type="button" class="btn btn-primary"><?php echo $liberar_reserva_lg?></a>
                        </div>
                    </div>
                </div>
            </div>



            <!-- Notas destacadas -->
            <div class="modal fade" id="notas_destacadas" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
                <div class="modal-dialog modal-lg" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title text-muted" id="exampleModalLongTitle"><i class="fas fa-sticky-note mr-2"></i><?php echo $notas_destacadas_lg?></h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body pb-3">
                            <?php echo PuzzleHTML::observaciones($con, $observaciones_lg, $codigo_tas = FALSE, 'NOTASDESTACADAS', $idCAR, $guardar_lg, $seccion_vacia_lg);  ?>
                        </div>
                    </div>
                </div>
            </div>



            <!-- Precio Pro -->
            <div class="modal fade" id="precio_pro" tabindex="-1" role="dialog" aria-labelledby="exampleModalLongTitle" aria-hidden="true">
                <div class="modal-dialog" role="document">
                    <div class="modal-content">
                        <div class="modal-header">
                            <h5 class="modal-title text-muted" id="exampleModalLongTitle"><i class="fas fa-user-tie mr-2"></i><?php echo $precio_profesional_lg?></h5>
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                            </button>
                        </div>
                        <div class="modal-body pb-3">
                            <div class="my-1 text-muted">
                                <?php  
                                    $precio_info = !empty($rowCar['TOTAL_PRO']) ? $MotherCar->car_price($rowCar['TOTAL_PRO'], $rowCar['TOTAL_SIN_DTO_PRO'], 'h4#class="text-muted font-weight-light"') : $sin_asignar_lg;
                                    $MotherCar->listado_vehiculo_lista_horizontal($precio_lg, $precio_info, 'bg-light');
                                ?>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

        </div>


       










    </section>
    <!-- //! Footer & Script Links 
    -->
    <?php 
        include('includes/footer.php');
        include('includes/footer-script.php');
    ?>
    <script>



    var minimo = <?php echo $rowCar['VENTA_MINIMO']; ?>;
    (function() {
    'use strict';
    window.addEventListener('load', function() {
        var forms = document.getElementsByClassName('needs-validation');
        var validation = Array.prototype.filter.call(forms, function(form) {
        form.addEventListener('submit', function(event) {
            if (form.checkValidity() === false) {
                event.preventDefault();
                event.stopPropagation();
            }
            form.classList.add('was-validated');
        }, false);
        });
    }, false);
    })();



    function checkPrecio()
    {
        var forms = document.getElementsByClassName('needs-validation');
        var precio_oferta = document.getElementById('precio_oferta');
        var minimo = <?php echo $rowCar['VENTA_MINIMO']; ?>;
        if(precio_oferta.value < minimo)
        {
            precio_oferta.classList.add('is-invalid');
            event.preventDefault();
            event.stopPropagation();
        }
        else
        {
            precio_oferta.classList.remove('is-invalid');
        }

    }





    $(function () {
        <?php if($lg == 'UK') { ?>
            $('#generarOferta').dataTable();
            <?php } else { ?>
                $("#generarOferta").dataTable({
                    "language": {
                    "lengthMenu": "_MENU_",
                    "zeroRecords": "No se encontraron resultados",
                    "info": "Registros del _START_ al _END_",
                    "infoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
                    "infoFiltered": "(filtrado de un total de _MAX_ registros)",
                    "sSearch": "",
                    "searchPlaceholder": "Buscar por los campos",
                    "oPaginate": {
                    "sFirst": "Primero",
                    "sLast": "Último",
                    "sNext": "Siguiente",
                    "sPrevious": "Anterior"
                    },
                    "sProcessing": "Procesando...",
                    }
                })
        <?php } ?> 
    }) 
    



    <?php if(isset($_GET['codigo_cliente'])){ ?>
        setTimeout(function(){
            document.getElementById('jump').scrollIntoView({
                behavior: 'smooth'
            })
        }, 1);
    <?php } ?>


    

    $(function () {
        <?php 
            if($lg == 'UK')
            {
            ?>
            $('#tableOfertas').dataTable();
            <?php } else { ?>
                $("#tableOfertas").dataTable({
                    "language": {
                    "lengthMenu": "_MENU_",
                    "zeroRecords": "No se encontraron resultados",
                    "info": "Registros del _START_ al _END_",
                    "infoEmpty": "Mostrando registros del 0 al 0 de un total de 0 registros",
                    "infoFiltered": "(filtrado de un total de _MAX_ registros)",
                    "sSearch": "",
                    "searchPlaceholder": "Buscar por los campos",
                    "oPaginate": {
                    "sFirst": "Primero",
                    "sLast": "Último",
                    "sNext": "Siguiente",
                    "sPrevious": "Anterior"
                    },
                    "sProcessing": "Procesando...",
                    }
                })
        <?php } ?>
        })
    

</script>
<?php $con->close(); ?>
</body>

</html>