 <?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
}

error_reporting(E_ERROR | E_PARSE);

$_SESSION['database'] = $_GET['database'];

include 'conn.php';
include 'funciones.php';

$sql = "select uui.u_id, uui.ubic_id, uui.printer_name, ui.ubic_descripcion from " . $_SESSION['database'] . ".user_ubic_impre uui " .
    "join " . $_SESSION['database'] . ".ubicacion_impre ui on uui.ubic_id = ui.ubic_id";

if ($_SESSION['codigo'] == "99") {
    $json->datos = "false";
} else {
    $json->datos = "true";
}

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

//print_r($sqlOrden);

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

    //$op_num_corre = $rOrd['op_num_corre'];
    $jsonTempData1 = array();
    $jsonTempData1['u_id'] = $r['u_id'];
    $jsonTempData1['ubic_id'] = $r['ubic_id'];
    $jsonTempData1['printer_name'] = $r['printer_name'];
    $jsonTempData1['ubic_descripcion'] = $r['ubic_descripcion'];
    $jsonData1[] = $jsonTempData1;
    $json->imp = $jsonData1;
}

print_r(json_encode($json));

$qur=null;
@mysqli_close($connection);
?>