search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Hotel Room

Asked by LUCA LATTANZIO
4 years ago.

Dear Support, I have already a predefined database, when I'm trying to load the event from my DB the scheduler is populated, but instead of the guest name I retrieve the guest name Id.
I tried to change the query on backend_event.php and make a join to customers tables to get the actual guest_neme but seams that is not working.
Thank you

Answer posted by Dan Letecky [DayPilot]
4 years ago.

It is important to keep the output JSON structure. The event data structure is described here:
https://api.daypilot.org/daypilot-event-data/

You need to respect these property names - the database structure is not fixed but you need to make sure that you load the correct fields.

This is the source of backend_event.php:

<?php
require_once '_db.php';

$start = isset($_POST['start']) ? $_POST['start'] : $_GET['start'];
$end = isset($_POST['end']) ? $_POST['end'] : $_GET['end'];

$stmt = $db->prepare("SELECT * FROM reservations WHERE NOT ((end <= :start) OR (start >= :end))");
$stmt->bindParam(':start', $start);
$stmt->bindParam(':end', $end);
$stmt->execute();
$result = $stmt->fetchAll();

class Event {}
$events = array();

date_default_timezone_set("UTC");
$now = new DateTime("now");
$today = $now->setTime(0, 0, 0);

foreach($result as $row) {
    $e = new Event();
    $e->id = $row['id'];
    $e->text = $row['name'];
    $e->start = $row['start'];
    $e->end = $row['end'];
    $e->resource = $row['room_id'];
    $e->bubbleHtml = "Reservation details: <br/>".$e->text;
    
    // additional properties
    $e->status = $row['status'];
    $e->paid = $row['paid'];
    $events[] = $e;

}

header('Content-Type: application/json');
echo json_encode($events);

This part is essential - you need to keep the $e structure:

    $e = new Event();
    $e->id = $row['id'];
    $e->text = $row['name'];
    $e->start = $row['start'];
    $e->end = $row['end'];
    $e->resource = $row['room_id'];
    $e->bubbleHtml = "Reservation details: <br/>".$e->text;
    
    // additional properties
    $e->status = $row['status'];
    $e->paid = $row['paid'];
    $events[] = $e;
This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.