'unauthorized'])); } $user = unserialize($_SESSION['user']); // check method try { if ($_SERVER['REQUEST_METHOD'] === 'GET') { $data = $db->query( 'SELECT * FROM AVISO', [ ':facultad_id' => $user->facultad['facultad_id'], ':fecha_inicio' => $_GET['fecha'] ?? $_GET['fecha_inicio'] ?? null, ':fecha_fin' => $_GET['fecha'] ?? $_GET['fecha_fin'] ?? null, ] ); $last_query = [ 'query' => $db->getLastQuery(), ]; echo json_encode($data, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); } else { http_response_code(405); echo json_encode(['error' => 'method not allowed']); exit; } } catch (PDOException $th) { http_response_code(500); echo json_encode([ 'error' => $th->getMessage(), 'query' => $db->getLastQuery(), ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_PARTIAL_OUTPUT_ON_ERROR); exit; } catch (Exception $th) { http_response_code(500); echo json_encode([ 'error' => $th->getMessage(), ], JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); exit; }