@ -1,4 +1,5 @@
<?php
<?php
use Drupal\field\Entity\FieldConfig;
/**
/**
* @file
* @file
* Classes and general Room Reservations helper functions.
* Classes and general Room Reservations helper functions.
@ -21,7 +22,7 @@ function reserve_categories($ebundle = null) {
$entity_type = ebundle_split($ebundle, 'type');
$entity_type = ebundle_split($ebundle, 'type');
$bundle = ebundle_split($ebundle, 'bundle');
$bundle = ebundle_split($ebundle, 'bundle');
$field = reserve_category_fields($ebundle);
$field = reserve_category_fields($ebundle);
$fconfig = \Drupal\field\Entity\ FieldConfig::loadByName($entity_type, $bundle, $field)->getSettings();
$fconfig = FieldConfig::loadByName($entity_type, $bundle, $field)->getSettings();
$ids = array_filter($fconfig['categories']);
$ids = array_filter($fconfig['categories']);
}
}
else {
else {
@ -353,8 +354,8 @@ function reserve_facility_hours($date, $reset = FALSE) {
$year = substr($month, 0, 4);
$year = substr($month, 0, 4);
$mo_hours = reserve_default_monthly_hours($year, $m);
$mo_hours = reserve_default_monthly_hours($year, $m);
}
}
$start = ($day - 1) * 5;
$start = ($day - 1) * 5;
$first_shift_open = $mo_hours[$start + 1];
$first_shift_open = $mo_hours[$start + 1];
$first_shift_close = $mo_hours[$start + 2];
$first_shift_close = $mo_hours[$start + 2];
$second_shift_open = $mo_hours[$start + 3];
$second_shift_open = $mo_hours[$start + 3];
@ -696,7 +697,7 @@ function reserve_start_conflicts($room, $yyyy_mmdd, $time) {
)
)
";
";
$conflicts_found = FALSE;
$conflicts_found = FALSE;
$conflicts_found = db_ query($sql, array(
$conflicts_found = \Drupal::database()-> query($sql, array(
':room' => $room,
':room' => $room,
':date0' => $search_items[0]['date'], ':time0' => $search_items[0]['start_time'], ':length0' => $search_items[0]['length'],
':date0' => $search_items[0]['date'], ':time0' => $search_items[0]['start_time'], ':length0' => $search_items[0]['length'],
':date1' => $search_items[1]['date'], ':time1' => $search_items[1]['start_time'], ':length1' => $search_items[1]['length'],
':date1' => $search_items[1]['date'], ':time1' => $search_items[1]['start_time'], ':length1' => $search_items[1]['length'],
@ -705,8 +706,7 @@ function reserve_start_conflicts($room, $yyyy_mmdd, $time) {
':date4' => $search_items[4]['date'], ':time4' => $search_items[4]['start_time'], ':length4' => $search_items[4]['length'],
':date4' => $search_items[4]['date'], ':time4' => $search_items[4]['start_time'], ':length4' => $search_items[4]['length'],
':date5' => $search_items[5]['date'], ':time5' => $search_items[5]['start_time'], ':length5' => $search_items[5]['length'],
':date5' => $search_items[5]['date'], ':time5' => $search_items[5]['start_time'], ':length5' => $search_items[5]['length'],
':date6' => $search_items[6]['date'], ':time6' => $search_items[6]['start_time'], ':length6' => $search_items[6]['length'],
':date6' => $search_items[6]['date'], ':time6' => $search_items[6]['start_time'], ':length6' => $search_items[6]['length'],
':date7' => $search_items[7]['date'], ':time7' => $search_items[7]['start_time'], ':length7' => $search_items[7]['length'])
':date7' => $search_items[7]['date'], ':time7' => $search_items[7]['start_time'], ':length7' => $search_items[7]['length']))->rowCount();
)->rowCount();
return $conflicts_found;
return $conflicts_found;
}
}
@ -923,7 +923,7 @@ function reserve_valid_lengths($rid, $ebundle, $yyyy_mmdd, $time, $id = NULL, $a
* FALSE - the maximum has not been exceeded.
* FALSE - the maximum has not been exceeded.
*/
*/
function reserve_daily_max_exceeded($yyyy_mmdd) {
function reserve_daily_max_exceeded($yyyy_mmdd) {
$user = \Drupal::currentUser();
$user = \Drupal::currentUser();
$config = \Drupal::config('reserve.settings');
$config = \Drupal::config('reserve.settings');
$max = $config->get('reservations_per_day');
$max = $config->get('reservations_per_day');
if (!$max) {
if (!$max) {