<?php
include 'conn.php';
//Select data from database
include 'funciones.php';
date_default_timezone_set("America/Panama");

session_start();
$_SESSION['database'] = $_POST['database'];
$_SESSION['fecha'] = $_POST['fecha'];
$_SESSION['u_id'] = $_POST['u_id'];
$_SESSION['suc_id'] = $_POST['suc_id'];
$_SESSION['tipo_auditoria'] = $_POST['tipo_auditoria'];
$_SESSION['aud_ref'] = $_POST['aud_ref'];
$_SESSION['infoextra'] = $_POST['infoextra'];
$_SESSION['valor'] = $_POST['valor'];
$_SESSION['mesa'] = $_POST['mesa'];
$_SESSION["puesto"] = $_POST['puesto'];

$info = $_SESSION["newsession"];
/*session created*/
//echo $_SESSION["newsession"];

$hoynow = getdate();

$SQLupdate = "insert into  " . $_SESSION['database'] . ".auditoria (fecha, u_id, suc_id, tipo_auditoria, aud_ref, infoextra, valor, mesa, puesto)
                      VALUES ('" . $_SESSION['fecha'] . "','" . $_SESSION['u_id'] . "','" . $_SESSION['suc_id'] . "','" . $_SESSION['tipo_auditoria'] . "','" . $_SESSION['aud_ref'] . "','" . $_SESSION['infoextra'] . "','" . $_SESSION['valor'] . "','" . $_SESSION['mesa'] . "','" . $_SESSION['puesto'] . "')";

// echo "sql: " . $SQLupdate;

if ($connection->query($SQLupdate) === true) {
    $msg = array("success" => "true", "detalle" => "Detalle ejemplo");

} else {

    $msg = array("success" => "false", "detalle" => $conn);

    // echo "Error: " . $SQLupdate . "<br>" . $conn->error;
}

$jsonData[] = $msg;

header('content-type: application/json');
echo json_encode($jsonData);

@mysqli_close($connection);
