If the events don’t display correctly, you should check the id of the resources (resources[].id
) and the resource of events (event.list[].resource
). Events are only displayed in a row if these value match exactly, including their type. Note that 1 !== "1"
(number vs string). In PHP, some DB drivers convert number values to strings.
In order to display a flat list of resources (without parents), you should modify the backend_resources.php
script to return a flat array without children. In the HTML5 Scheduler tutorial, this script returns a JSON array that looks like this:
[
{"id":"group_1","name":"People","expanded":true,"children":
[
{"id":"1","name":"Person 1"},
{"id":"2","name":"Person 2"},
{"id":"3","name":"Person 3"},
{"id":"4","name":"Person 4"}
]
},
{"id":"group_2","name":"Tools","expanded":true,"children":
[
{"id":"5","name":"Tool 1"},
{"id":"6","name":"Tool 2"},
{"id":"7","name":"Tool 3"},
{"id":"8","name":"Tool 4"}
]
}
]
You need to modify the script to return only the items from the resources
table:
<?php
require_once '_db.php';
class Resource {}
$resources = array();
$stmt = $db->prepare('SELECT * FROM resources ORDER BY name');
$stmt->execute();
$scheduler_resources = $stmt->fetchAll();
foreach($scheduler_resources as $resource) {
$r = new Resource();
$r->id = $resource['id'];
$r->name = $resource['name'];
$resources[] = $r;
}
header('Content-Type: application/json');
echo json_encode($resources);