I did not found any way to make Booking Time Slots working with one calendar, but not acting on others

Thanks for directions

Comments

kenorb’s picture

You can change the name of template file.
Go to your calendar view, Day display and click on: Theme Information
You'll see available template names.
If your calendar view name is: booking_calendar
Copy/rename calendar-day.tpl.php to calendar-day--booking-calendar.tpl.php, etc.

kenorb’s picture

Issue summary: View changes
Status: Active » Fixed
emi_bcn’s picture

Hi again,
Same error at 7 version (from GitHub), but the workaround renaming template files does not work. Maybe adding a Booking TS admin setting for enabling/disabling?

Thanks!

kenorb’s picture

Version: 6.x-1.x-dev » 7.x-1.x-dev
Category: Support request » Feature request
Status: Fixed » Active
emi_bcn’s picture

Hello again,
I've managed to use templated files only for the booking view, naming the templates to calendar-day--bt-schedule.tpl.php and similars. But still some errors when viewing the other calendar (not the booking one):

Warning: include([...]/drupal/sites/all/modules/booking_timeslots/templates/calendar-month.tpl.php): failed to open stream: No such file or directory in theme_render_template()

Also, in this calendar appears the filters from Booking TS, and finally no days visible (the page ends just after the filters section).

Thanks a lot,
emi

kenorb’s picture

@emi_bcn The path to templates/ is overriden in booking_timeslots_theme_registry_alter()

  $hooks = array('opening_hours_admin', 'calendar_week', 'calendar_day', 'calendar_month');

  foreach ($hooks as $h) {
    $items[$h]['path']       = $mod_path . '/templates';
    $items[$h]['theme path'] = $mod_path;
  }

So you can either place your file as suggested by the error, or if you want to use theme folder, probably you can, but I'm not sure why it's failing.

emi_bcn’s picture

Hi again,
I think the problem is that the other calendar (the one not associated with booking) is trying to use the booking templates.

I've managed to make it work linking original templates from Calendar module directly to booking module:
ln -s ../../calendar/theme/calendar-{day,week,month}.tpl.php .

But still showing booking filters on non-booking calendar. And there is a critical error when viewing non-booking day-view calendar, which comes from SQL at booking_timeslots_get_daily_settings() :

PDOException: SQLSTATE[22P02]: Invalid text representation: 7 ERROR: invalid input syntax for integer: "2015-04-17" LINE 16: CASE WHEN H.nid = '2015-04-17' THEN '1' WHEN H.nid IN ... ^: SELECT H.instance_id, H.nid, H.date, H.start_time, H.end_time, H.notice, H.repeat_rule, H.repeat_end_date, H.original_instance_id, H.customised, H.slot_length, CASE WHEN H.nid = :tertiary_id THEN C.field_bt_xmp_capacity_value ELSE H.capacity END AS capacity, DATEDIFF('mi', H.date, :time_start) AS day, CASE WHEN H.nid = :primary_id THEN '1' WHEN H.nid IN ( :secondary_id ) THEN '2' WHEN H.nid = :tertiary_id THEN '3' ELSE '0' END AS type FROM {opening_hours} H LEFT JOIN field_data_field_bt_xmp_capacity C ON C.entity_id = H.nid WHERE (nid = :primary_id OR nid IN (:secondary_id) OR nid = :tertiary_id) AND ( (H.repeat_end_date IS NULL AND H.date BETWEEN :time_start AND :time_end) OR (H.repeat_end_date IS NOT NULL AND ( CONCAT(H.date, ' ', H.start_time) BETWEEN :time_start AND :time_end ) ) ) ORDER BY nid = :primary_id DESC, nid IN ( :secondary_id ) DESC, nid = :tertiary_id DESC, H.repeat_end_date DESC, H.date ASC ; Array ( [:primary_id] => 2015-04-17 [:secondary_id] => [:tertiary_id] => [:time_start] => 2015-04-17 00:00:00 [:time_end] => 2015-04-17 23:59:59 ) a booking_timeslots_get_daily_settings() (línia 1315 de [...]/drupal/sites/all/modules/booking_timeslots/booking_timeslots.module)

Which is trying to use calendar argument (day: '2015-04-17') as a nid for primary_id. I suppose many errors will disappear when deactivating booking module for non-booking calendars (I don't know at all how it can be done, yet).

Thanks,
emi

kenorb’s picture

@emi_bcn

You can temporary comment out 'preprocess functions' lines in booking_timeslots_theme_registry_alter() [file: booking_timeslots.module], either all or for specific calendar view (either day or month), then probably clear cache is needed. Then see if that works, but probably the booking calendar it-self will stop working.

Or maybe better way, comment out template_preprocess_booking_timeslots_month_overlap() in template_preprocess_booking_timeslots_month() and see if that would work.

I think we probably need to do some extra conditions in template_preprocess_booking_timeslots_month() or in template_preprocess_booking_timeslots_month_overlap() [in booking_timeslots.theme.inc file] to make sure (but checking somewhere in $vars['view']) if we're dealing with our booking view. Just a guess looking at the code.

emi_bcn’s picture

Hi again,
I've managed to disable BTS on non-BTS enabled calendars. I've just added an initial condition to:

  • booking_timeslots.module: booking_timeslots_form_views_exposed_form_alter()
  • booking_timeslots.theme.inc: template_preprocess_booking_timeslots_{day,week,month}()

The condition I've just added is for testing, but it works (my BTS enabled view is the one with $vid = 31):

  • booking_timeslots.module:
      if($form_state['view']->vid != 31) {
         return;
      }
    
  • booking_timeslots.theme.inc:
      if($vars['view']->vid == 31) {
        template_preprocess_booking_timeslots_{day,week,month}_overlap($vars);
      }
    

I think it's a good idea to add a multiselect list option (checkbox) to BTS admin page, where one can select the BTS enabled calendar views (the list must be done only with calendar enabled views). Then, use a helper function with $vid as a parameter and the enabled BTS calendar views as a static/cached variable on these 4 functions I've posted on the example.

Do you think it's a good idea? If so, do you want me to do a patch for it?

Thanks a lot. See you soon,
emi

emi_bcn’s picture

Hi again,
I've found that modifying booking_timeslots.module: booking_timeslots_form_views_exposed_form_alter is enough, and no template preprocess function modifications is needed. So, the only additions are the admin option and the condition in booking_timeslots_form_views_exposed_form_alter . And add the instructions for TPL renaming and linking (or another solution suggested?):

cd [...]/modules/booking_timeslots/templates
mv calendar-week.tpl.php calendar-week--bt-schedule.tpl.php
mv calendar-day.tpl.php calendar-day--bt-schedule.tpl.php     
mv calendar-month.tpl.php calendar-month--bt-schedule.tpl.php   
ln -s ../../calendar/theme/calendar-{month,week,day}.tpl.php .
kenorb’s picture

@emi_bcn Yes, add patch file whenever you can or include lines to change, so vid == 31 needs to be translated into non-hardcoded condition. Unfortunately I won't have time to fix it.

Yes, I think it would be a good idea to rename the templates for more specific conventions.