<?php

if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400'); // cache for 1 day
}

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

include 'funciones.php';

session_start();
$_SESSION['database'] = $_GET['database'];

$hoynow = getdate();

$montoesql = "select no_tomainv+1 as no_tomainv from " . $_SESSION['database'] . ".conf_sistema limit 1";

logs($montoesql);

$qur = $connection->query($montoesql);

$_SESSION['no_tomainv'] = 'false';

while ($r = mysqli_fetch_assoc($qur)) {

    $msg = array("no" => $r['no_tomainv']);
}
$json = $msg;

// $json = (object)$msg;

$SQLupdate1 = "update   " . $_SESSION['database'] . ".conf_sistema  set no_tomainv=no_tomainv+1";

logs($SQLupdate1);

if ($connection->query($SQLupdate1) === true) {

//    $result = (object) array(
    //    'success' => 'true',
    //    'registro' => 1,
    //    'msg'=>"Borrado correctamente"
    //);
}

print_r(json_encode($json));

@mysqli_close($connection);
?>
