From a9cd045626ec0b9721b6f4aab290d0ed6bea3d93 Mon Sep 17 00:00:00 2001 From: ppound Date: Mon, 23 Aug 2021 15:50:16 -0300 Subject: [PATCH] Only check the number of reservations allowed for new reserations --- reservation.inc | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/reservation.inc b/reservation.inc index 325d0df..6287f16 100644 --- a/reservation.inc +++ b/reservation.inc @@ -61,34 +61,35 @@ function reserve_form_reserve_reservation_form_alter(array &$form, FormStateInte $year = reserve_which_year($month, $day); $yyyymmdd = date('Y-m-d', strtotime($year . '-' . $month . '-' . $day)); $d = $yyyymmdd . ' 00:00:00'; - } - if(reserve_daily_max_exceeded($yyyymmdd)) { - $form = array(); - $form['message'] = [ + + if (reserve_daily_max_exceeded($yyyymmdd)) { + $form = array(); + $form['message'] = [ '#type' => 'markup', '#weight' => -25, '#markup' => '
', + 'You have exceeded the max number of daily bookings. Unable to add reservation' . + '', ]; - return; - } - $config = \Drupal::config('reserve.settings'); - $max_per_user = $config->get('reservations_per_user'); - if(count(reserve_user_reservations()) > $max_per_user){ - $form = array(); - $form['message'] = [ + return; + } + $config = \Drupal::config('reserve.settings'); + $max_per_user = $config->get('reservations_per_user'); + if (count(reserve_user_reservations()) > $max_per_user) { + $form = array(); + $form['message'] = [ '#type' => 'markup', '#weight' => -25, '#markup' => '
', + 'You have exceeded your max number of open bookings. Unable to add reservation' . + '', ]; - return; + return; + } } $entity = \Drupal::entityTypeManager()->getStorage($entity_type)->load($eid); $bundle = $entity->bundle();