Good day I need help with this function, I want the Scheduler just can delete appointments that are gone but after 24 hours.
That is, if a student requests an appointment, you should not book another unless 24 hours have passed, any suggestions on how to modify this function:
function scheduler_free_late_unused_slots($schedulerid, $now=0){
global $CFG, $DB;
if(!$now) {
$now = time();
}
$sql = '
SELECT DISTINCT
s.id
FROM
{scheduler_slots} s
LEFT JOIN
{scheduler_appointment} a
ON
s.id = a.slotid
WHERE
a.studentid IS NULL AND
s.schedulerid = ? AND
starttime < ?
';
$to_delete = $DB->get_records_sql($sql, array($schedulerid, $now));
if ($to_delete){
list($usql, $params) = $DB->get_in_or_equal(array_keys($to_delete));
$DB->delete_records_select('scheduler_slots', "id $usql", $params);
}
}