@ -1,4 +1,4 @@
<?php
<?php
/**
* Reservation CRUD for supporting Series
@ -39,7 +39,7 @@ function reserve_reserve_reservation_insert($entity) {
$ebundle = $rtype . '.' . \Drupal::entityTypeManager()
->getStorage($rtype)->load($rid)->bundle();
$day = date('l', strtotime($start));
$msg = '';
switch ($repeat_type) {
// every day until....
@ -48,7 +48,7 @@ function reserve_reserve_reservation_insert($entity) {
$back = '-1 day';
$msg = t('You have booked every day from %start until %end', array('%start' => $start_yyyy_mm_dd, '%end' => $end));
break;
// this day of the week until..
case 2:
$skip = '+7 day';
@ -70,7 +70,7 @@ function reserve_reserve_reservation_insert($entity) {
$failed = array();
while (strtotime($date) < = strtotime($back, strtotime($end))) {
$date = date('Y-m-d', strtotime($skip, strtotime($date)));
// must check to see if next booking is available
// the first one we don't check as we could not have picked it if it wasn't
if (reserve_is_slot_free($rid, $ebundle, $date, $time, $length)) {
@ -111,12 +111,12 @@ function reserve_reserve_reservation_update($entity) {
}
$sid = $entity->reservation_series_id->getString();
// if not part of a Series or special single only url -> do nothing
if (!$sid || isset($_GET['single'])) {
return;
}
// reservation details
$start = $entity->reservation_date->getString();
$time = $entity->reservation_time->getString();
@ -130,6 +130,7 @@ function reserve_reserve_reservation_update($entity) {
// grab all reservations in this series except the one being submitted
$ids = \Drupal::service('entity_type.manager')
->getStorage('reserve_reservation')->getQuery()
->accessCheck(TRUE)
->condition('status', TRUE)
->condition('reservation_series_id', $sid)
->condition('id', $entity->id(), '!=')
@ -162,7 +163,7 @@ function reserve_reserve_reservation_update($entity) {
if (count($failed)) {
$dates = Markup::create('< br > ' . implode('< br > ', $failed));
\Drupal::messenger()->addStatus(t('NOTE: The following dates did not have their length changed due to scheduling conflicts: %dates', array('%dates' => $dates)));
}
}
}
/**
@ -183,6 +184,7 @@ function _reserve_series_delete($entity) {
// grab all reservations in this series
$ids = \Drupal::service('entity_type.manager')
->getStorage('reserve_reservation')->getQuery()
->accessCheck(TRUE)
->condition('reservation_series_id', $sid)
->execute();
$results = \Drupal::entityTypeManager()->getStorage('reserve_reservation')->loadMultiple($ids);
@ -190,5 +192,5 @@ function _reserve_series_delete($entity) {
$result->delete();
}
$title = $entity->get('name')->getString();
\Drupal::messenger()->addStatus(t('The reservation series @title was deleted.', array('@title' => $title)));
\Drupal::messenger()->addStatus(t('The reservation series @title was deleted.', array('@title' => $title)));
}