<?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/historial.php');
include('../includes/functions.php');
include('../includes/esquemas.php');
include('../class/Schema.php');
include('../class/MotherCar.php');
include('../class/Expediente.php');
include('../class/Bibliotecas.php');
include('../class/Static.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');
}
$MotherCar = new MotherCar($con);

$idcar = Statics::SafeInput($con, $_POST['idcar']);
$matricula = Statics::SafeInput($con, $_POST['matricula']);
$MotherCar->set_codigo_vehiculo_tabla_vehiculos($_SESSION['CODIGO_COCHE']);
$MotherCar->set_eurotax(Statics::SafeInput($con, $_POST['eurotax']));
$MotherCar->set_marca(Statics::SafeInput($con, $_POST['marca']));
$MotherCar->set_modelo(Statics::SafeInput($con, $_POST['modelo']));
$MotherCar->set_matricula($matricula);
$MotherCar->set_bastidor(Statics::SafeInput($con, $_POST['bastidor']));
$MotherCar->set_carroceria(Statics::SafeInput($con, $_POST['carroceria']));
$MotherCar->set_color_principal(Statics::SafeInput($con, $_POST['color']));
$MotherCar->set_color_principal_literal(Statics::SafeInput($con, $_POST['color_literal']));
$MotherCar->set_cajacambios(Statics::SafeInput($con, $_POST['cajacambio']));
$MotherCar->set_distintivo_ambiental(Statics::SafeInput($con, $_POST['dist_amb']));
$MotherCar->set_activo(1);
$MotherCar->set_km(Statics::SafeInput($con, $_POST['km']));
$MotherCar->set_combustible(Statics::SafeInput($con, $_POST['combustible']));
$MotherCar->set_estado('STK');
$MotherCar->set_version(Statics::SafeInput($con, $_POST['version']));
$MotherCar->set_matriculacion(Statics::SafeInput($con, $_POST['fecha_matriculacion']));
$MotherCar->set_ano_fabricacion(Statics::SafeInput($con, $_POST['anoFab']));
$MotherCar->set_garantia(Statics::SafeInput($con, $_POST['garantia']));
$MotherCar->set_estado(Statics::SafeInput($con, $_POST['estado']));
$MotherCar->set_stock(Statics::SafeInput($con, $_POST['stock']));
$MotherCar->set_mostrar($idcar . ' - ' . $MotherCar->nombre_vehiculo($_POST['marca'], $_POST['modelo']) . ' - ' . $matricula);
$MotherCar->update_vehiculo();

$_SESSION['MSG_INFO'] = 'PRINCIPAL';
Statics::add_trace_history($con, $usuarioSession, $_SESSION['CODIGO_COCHE'], 2, $datos_principales_lg);
header("Location:../resultados-editar.php");

?>