The backend_events.php script should look like this:
<?php
require_once '_db.php';
$stmt = $db->prepare("SELECT * FROM leave_event WHERE NOT ((leave_end <= :start) OR (leave_start >= :end))");
$stmt->bindParam(':start', $_GET['start']);
$stmt->bindParam(':end', $_GET['end']);
$stmt->execute();
$result = $stmt->fetchAll();
class Event {}
$events = array();
foreach($result as $row) {
$e = new Event();
$e->id = $row['id'];
$e->text = "";
$e->start = $row['leave_start'];
$e->end = $row['leave_end'];
$e->resource = $row['person_id'];
$e->priority=$row['priority_leave'];
$events[] = $e;
}
header('Content-Type: application/json');
echo json_encode($events);
You correctly store the "priority_leave" field value in "priority" property of the event object. Remove the session-related code.
On the client side, set the bar color in onBeforeEventRender like this:
onBeforeEventRender: (args) => {
// ...
switch (args.data.priority) {
case "P1":
args.data.barColor = "red";
break;
case "P2":
args.data.barColor = "blue";
break;
default:
args.data.barColor = "yellow";
break;
}
},