No available units

Created on 18 December 2023, 7 months ago
Updated 30 December 2023, 6 months ago

Maybe i'm doing something wrong, but now i can only booking in the rooms that has the same unit id, but not in the others. This unit id seems to has defined in the node settings. For example in my config/sync i have this config in my node type:

  bee:
    bee:
      bookable: 1
      bookable_type: hourly
      availability: available
      payment: 0
      payment_default_value: 0
      type_id: '8'

I've tried to remove the type_id and make a config import, but doesn't work neither.

This is because this code in getAvailableUnits() in bee/src/Form/AddReservationForm.php

    $bee_settings = $node_type->getThirdPartySetting('bee', 'bee');

    $units_ids = [];
    foreach ($node->get('field_availability_' . $bee_settings['bookable_type']) as $unit) {
      if ($unit->entity) {
        $units_ids[] = $unit->entity->id();
      }
    }

    if ($bee_settings['bookable_type'] == 'daily') {
      $start_date = new \DateTime($start_date);
      $end_date = new \DateTime($end_date);
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_daily_available'], [$bee_settings['type_id']], 'availability_daily');
    }
    else {
      $start_date = new \DateTime($start_date->format('Y-m-d H:i'));
      $end_date = new \DateTime($end_date->format('Y-m-d H:i'));
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_hourly_available'], [$bee_settings['type_id']], 'availability_hourly');
    }

For some reason i don't know this get a config from the node with the type id. But in every room can be a diferent type id.

I've made this changes to support this:

    $bee_settings = $node_type->getThirdPartySetting('bee', 'bee');

    $units_ids = [];
    $type_ids = [];
    foreach ($node->get('field_availability_' . $bee_settings['bookable_type']) as $unit) {
      if ($unit->entity) {
        $units_ids[] = $unit->entity->id();
        $type_ids[] = $unit->entity->unit_type_id->target_id;
      }
    }

    if ($bee_settings['bookable_type'] == 'daily') {
      $start_date = new \DateTime($start_date);
      $end_date = new \DateTime($end_date);
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_daily_available'], $type_ids, 'availability_daily');
    }
    else {
      $start_date = new \DateTime($start_date->format('Y-m-d H:i'));
      $end_date = new \DateTime($end_date->format('Y-m-d H:i'));
      $end_date->sub(new \DateInterval('PT1M'));

      $available_units_ids = bat_event_get_matching_units($start_date, $end_date, ['bee_hourly_available'], $type_ids, 'availability_hourly');
    }
🐛 Bug report
Status

Postponed: needs info

Version

3.0

Component

Code

Created by

🇪🇸Spain Carlitus

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Carlitus
  • 🇮🇹Italy afagioli Rome

    What is the question/issue exactly?

  • 🇮🇹Italy afagioli Rome

    Reading about "Room", seems to be moved inside the "BEE Hotel" queue
    https://www.drupal.org/project/bee_hotel

  • Status changed to Postponed: needs info 7 months ago
  • 🇪🇸Spain Carlitus

    We don't use bee hotel, only bee, bat and bat_api. We use this for booking of meetings rooms.

    And there is no question, sorry, only that we need this patch so we can no longer book the meetings room that the type_id inf config/sync are different.

  • 🇮🇹Italy afagioli Rome

    Ah.. right.. it's about "meeting rooms".

  • 🇮🇹Italy afagioli Rome

    There was some change in the BAT configuration data. Will look at this.

    And further detail, or even better a shorter synthesis of your experience here would surely help
    Thanks so far

  • 🇪🇸Spain Carlitus

    I have several groups of meetings rooms

    Each group have diferent meeting rooms:

    Without this MR:
    I only can book in meetings room of one group, the one defined in the yml of my content type.

    With the MR:
    I can book in all the meetings rooms, because i don't look the configuration of the content type for the type_id

  • 🇮🇹Italy afagioli Rome

    Very interesting indeed!

    Your approach should work if you want a multi-unit search, even if units are different one each-other. So, cool!

    From my personal experience, BEE units are clones. This is important especially when you integrate the commerce module.

    It's true also there no groups search inside BAT not BEE today (we started the bat_group in current dev), so - waiting for a more appropriate solutions - your approach is good when you using BEE for no-commerce units (at least).

    As written above, BEE Hotel implemented a specific multi unit search. It's essentially a different call to the "bat unit availability" function for more units involved with similar conditions. You can take a look at that if interested in more approaches.

    Even if your MR will not be part of future BEE, it will surely contribute to improve the overall community experience.

    Thanks!

  • 🇮🇹Italy afagioli Rome

    Very interesting also how/if more projects would implement code in MR

Production build 0.69.0 2024