<?php
include 'conn.php';
//Select data from database

include 'funciones.php';

session_start();
$_SESSION['database'] = $_POST["database"];
$_SESSION['suc_id'] = $_POST["suc_id"];
$_SESSION['est_id'] = $_POST["est_id"];
$_SESSION['sql_response'] ="'". $_POST["sql_response"]."'";




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

$hoynow = getdate();

// $SQLupdate="update ".$_SESSION['database'].".sucursales set exec_verop=0 where suc_id=".$_SESSION['suc_id']  ."  limit 1 ";

$SQLupdate = "update " . $_SESSION['database'] . ".estaciones_cmd set sql_exec=0,sql_request='',sql_response=".$_SESSION['sql_response']." where sql_suc_id=" . $_SESSION['suc_id'] . "  and sql_e_id=" . $_SESSION['est_id'] . "   limit 1 ";

//echo $SQLupdate;

logs($SQLupdate);

if ($connection->query($SQLupdate) === true) {
    //  echo "update op";
    $msg = array("exec" => "0");

} else {
    $msg = array("exec" => "1");

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

$json = $msg;

// $json = (object)$msg;

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

@mysqli_close($connection);
?>
