<?php 

    $mgetvalue = filter_input(INPUT_GET, 'm') ?? null; 
    $cgetvalue = filter_input(INPUT_GET, 'c') ?? null; 
if($mgetvalue) {?>
    <form action="#" class="mb-2 pb-2 pl-2 needs-validation" novalidate>
        <div class="position-relative w-75 row pl-3">
            <label for="search" class="d-none"></label>
            <i class="fas fa-search fa-lg text-papel-cero position-absolute" style="z-index: 5; top: 12px; left:28px;"></i>
            <div class="col-12 list-group position-relative" id="parent">
                <input type="text" class="form-control pl-5 rounded-pill mb-3" id="search" autocomplete="off" name="search" placeholder="<?php echo $buscar_contacto_lg; ?>">
            </div>
        </div>
    </form>
<?php } ?>

<div id="content">
    <div id="person-box" class="bg-white shadow border rounded-lg p-3 mb-5">
        <div class="d-flex justify-content-start pb-2 mb-3 border-bottom ">
            <h5 class="mr-3"><?php echo $datos_cliente_lg; ?></h5>
            <?php
                if($mgetvalue) {
                    $html_rgpd = '<h6 id="rgpd" class="text-danger mt-1 c-default">';
                        $html_rgpd .= '<i class="fas fa-exclamation-triangle mr-2"></i>';
                        $html_rgpd .= '<span>' . $contacto_sin_rgpd_lg . '</span>';
                        $html_rgpd .= '<span class="border-bottom border-danger ml-1 c-pointer" id="rgpd-press" data-toggle="modal" data-target="#rgpdModal">' . strtolower($aqui_lg) .'</span>';
                    $html_rgpd .= '</h6>';
                    echo $html_rgpd;
                }
            ?>
            
        </div>
        <form action="#" class="needs-validation p-form" novalidate method="get">
            <div class="form-row">
                <div class="form-group col-12 col-md-3">
                    <label for="nombre"><?php echo $nombre_lg; ?>*</label>
                    <input type="text" class="form-control" id="name" placeholder="<?php echo $nombre_lg; ?>" value="<?= !empty($cgetvalue) ? $row['NOMBRE'] : false ;?>" required>
                    <div class="invalid-feedback"><?php echo $campo_obligatorio_lg; ?></div>
                </div>
                <div class="form-group col-12 col-md-3">
                    <label for="apellido"><?php echo $apellido_1_lg; ?>*</label>
                    <input type="text" class="form-control" id="lastName" placeholder="<?php echo $apellido_1_lg; ?>" value="<?= !empty($cgetvalue) ? $row['APELLIDO1'] : false ;?>"  required>
                    <div class="invalid-feedback"><?php echo $campo_obligatorio_lg; ?></div>
                </div>
                <div class="form-group col-12 col-md-3">
                    <label for="apellido2"><?php echo $apellido_2_lg; ?></label>
                    <input type="text" class="form-control" id="secondLastName" placeholder="<?php echo $apellido_2_lg; ?>" value="<?= !empty($cgetvalue) ? $row['APELLIDO2'] : false ;?>" >
                </div>
                <div class="form-group col-12 col-md-3">
                    <label for="nif"><?php echo $nif_cif_lg; ?></label>
                    <input type="text" class="form-control" id="cardId" placeholder="<?php echo $nif_cif_lg; ?>" value="<?= !empty($cgetvalue) ? $row['NIF'] : false ;?>" >
                </div>
                <div class="form-group col-12 col-md-3">
                    <label for="email"><?php echo $email_lg; ?>*</label>
                    <input type="email" class="form-control" id="email" placeholder="<?php echo $email_lg; ?>" value="<?= !empty($cgetvalue) ? $row['EMAIL1'] : FALSE ;?>"  required>
                    <div class="invalid-feedback"><?php echo $campo_obligatorio_lg; ?></div>
                </div>
                <div class="form-group col-12 col-md-3">
                    <label for="telefono"><?php echo $telefono_lg; ?>*</label>
                    <input type="number" class="form-control" id="phone" placeholder="<?php echo $telefono_lg; ?>" value="<?= !empty($cgetvalue) ? $row['TLFNO1'] : FALSE ;?>"  required>
                    <div class="invalid-feedback"><?php echo $campo_obligatorio_lg; ?></div>
                </div>
                <div class="form-group col-12 col-md-6">
                    <label for="direccion"><?php echo $direccion_lg; ?></label>
                    <input type="text" class="form-control" id="address" placeholder="<?php echo $direccion_lg; ?>" value="<?= !empty($cgetvalue) ? $row['DIRECCION_PER'] : FALSE ;?>" >
                </div>
                <div id="new-rgpd" class="d-none col-12"><?php echo $rgpd->getRGPD(); ?></div>
                <div id="btn-append" class="col-12 mt-3"></div>
            </div>
        </form>
    </div>

    <div class="bg-white shadow border rounded-lg p-3" id="car-box">
        <div class="d-flex justify-content-start pb-2 mb-3 border-bottom">
            <h5 class="mr-3"><?php echo $datos_vehiculos_lg; ?></h5>
        </div>
        <form action="php_o/tasacion-crear.php" id="car-form" method="post" class="needs-validation" novalidate>
            <div class="form-row">
                <?php 
                    $html = '';
                    $html .= $MotherCar->marca_modelo('col-md-3 mb-3', $marca_lg, $modelo_lg, $icono = FALSE, $required = TRUE, !empty($cgetvalue) ? $row['MARCA'] : FALSE, !empty($cgetvalue) ? $row['MODELO'] : FALSE); 
                    PuzzleHTML::setInputStyle('col-12 col-md-6 mb-3');
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['VERSION'] : FALSE);
                    $html .= PuzzleHTML::Input('version', 'text', $version_lg);
                    PuzzleHTML::setInputStyle('col-12 col-md-3 mb-4');
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['MOTOR'] : FALSE);
                    $html .= PuzzleHTML::Input('motor_cc', 'text', $motor_cc_lg);
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['POTENCIA'] : FALSE);
                    $html .= PuzzleHTML::Input('potencia', 'text', $potencia_lg);
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['MATRICULA'] : $mgetvalue);
                    $html .= PuzzleHTML::Input('matricula', 'text', $matricula_lg . '*', TRUE);
                    PuzzleHTML::setInputValue(!empty($cgetvalue)  ? $row['BASTIDOR'] : FALSE);
                    $html .= PuzzleHTML::Input('bastidor', 'text', $bastidor_lg);
                    PuzzleHTML::setInputValue(!empty($cgetvalue)  ? $row['MATRICULACION'] : FALSE);
                    $html .= PuzzleHTML::Input('fecha_matriculacion', 'date', $ano_matriculacion_lg);
                    PuzzleHTML::setInputValue(!empty($cgetvalue)  ? $row['ITV_PROXIMA'] : FALSE);
                    $html .= PuzzleHTML::Input('itv_proxima', 'date', $itv_proxima_lg);
                    $html .= '<div class="col-12 col-md-3 mb-3">' . $MotherCar->selectLiterales ('combustible', $combustible_lg, 'TIP_COM', !empty($cgetvalue) ? $row['COMBUSTIBLE'] : FALSE, TRUE) . '</div>';
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['KM'] : FALSE);
                    $html .= PuzzleHTML::Input('km', 'number', $kilometros_lg);
                    $html .= '<div class="col-12 col-md-3 mb-3">' . $MotherCar->selectLiterales ('color', $color_lg, 'COL_PRI', !empty($cgetvalue) ? $row['COLOR_PRINCIPAL'] : FALSE) . '</div>';
                    $html .= '<div class="col-12 col-md-3 mb-3">' . $MotherCar->selectLiterales ('cajacambio', $cambio_lg, 'TIP_CAJ', !empty($cgetvalue) ? $row['CAJACAMBIOS'] : FALSE, TRUE) . '</div>';
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['VELOCIDADES'] : FALSE);
                    $html .= PuzzleHTML::Input('velocidades', 'number', $velocidades_lg);
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['LLAVES'] : FALSE);
                    $html .= PuzzleHTML::Input('llaves', 'number', $llaves_lg);
                    $html .= '<div class="col-12 col-md-3 mb-3">' . $MotherCar-> selectLiterales ('procedencia', $procedencia_lg, 'TIP_PRO', !empty($cgetvalue) ? $row['PROCEDENCIA'] : FALSE, $required = FALSE) . '</div>';
                    $html .= PuzzleHTML::select_si_no('manual', $manual_lg . '*', !empty($cgetvalue) ? $row['MANUAL'] : FALSE, $required = TRUE);
                    $html .= PuzzleHTML::select_si_no('libro', $libro_mantenimiento_lg . '*', !empty($cgetvalue) ? $row['LIBRO_MANT'] : FALSE, $required = TRUE);
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['ULT_MANT'] : FALSE);
                    $html .= PuzzleHTML::Input('ultimo_mant', 'date', $ultimo_mantenimiento_lg);
                    $html .= '<div class="col-12 col-md-3 mb-3">' . $MotherCar->selectLiterales ('tipo_seguro', $tipo_seguro_lg, 'TIP_SEG', !empty($cgetvalue) ? $row['TIPO_SEGURO'] : FALSE, TRUE) . '</div>';
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['FRANQUICIA'] : FALSE);
                    $html .= PuzzleHTML::Input('franquicia', 'number', $franquicia_lg);
                    $html .= '<div class="col-12 col-md-3 mb-3">' .  $Agenda->select_aseguradora(!empty($cgetvalue) ? $row['ASEGURADORA'] : FALSE) . '</div>';
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['NUM_PARTES'] : FALSE);
                    $html .= PuzzleHTML::Input('nro_partes', 'number', $numero_partes_lg);
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['CODIGO_RAD'] : FALSE);
                    $html .= PuzzleHTML::Input('codigo_radio', 'number', $codigo_radar_lg);
                    PuzzleHTML::setInputValue(!empty($cgetvalue) ? $row['CODIGO_NAV'] : FALSE);
                    $html .= PuzzleHTML::Input('codigo_nav', 'number', $codigo_navegador_lg);
                    $html .= PuzzleHTML::select_si_no('importacion', $importacion_lg, !empty($cgetvalue) ? $row['IMPORTACION'] : FALSE, $required = FALSE);
                    $codigo_contacto_tas =  !empty($cgetvalue) ? $row['CODIGO_CONTACTO'] : FALSE;
                    $html .= '<input type="hidden" name="contacto_tasacion" value="' . $codigo_contacto_tas . '" id="contacto_tasacion">';
                    echo $html;
                ?>
            </div>
            <div class="d-flex justify-content-end"><button type="submit" name="control_tasacion" value="<?= !empty($cgetvalue) ? $TAS : FALSE ?>" class="btn btn-papel-cero rounded-pill"><?php echo $continuar_lg; ?></button></div>
        </form>
    </div>
</div>

