I have a website wich have multiple users and each user has its own availabilty calendar.
The admin has the ability to filter in these calendars for given free dates.
But I want him to be able to select eg. a month march, and then views would return every calendar wich has available dates in that given month...

Is this possible in some way?

thank you,
Lorenzo

Comments

fietserwin’s picture

This is not possible out of the box, but with a bit of programming it should not be too hard to get this functionality;

  1. Create a custom module (.module and .info).
  2. Create your own views_filter_handler by deriving your class from availability_calendar_handler_filter_availability.
  3. Register the class in your .info file:
    ; Views handlers
    files[] = availability_calendar_handler_filter_availability.inc
  4. Implement hook_views_api() in your .module.
  5. Adapt the filter handler to your own needs by overriding those methods you want to change, amongothers, probably operators() and value_form().
  6. Overide op_arrival_departure() and op_arrival_duration() by calling your own version of availability_calendar_query_available().
  7. Create a copy of availability_calendar_query_available() in your .module file
  8. Change the if ($default_state['is_available'] == 1) statement as follows.
  • If (default state is available) then count(not available days) < duration.
  • If (default state is not available) then exists(available days).

This should be possible by exchanging the code from the if and else branch and changing the operators/methods (notexists => exists; IN 0 => < duration)

Though, that very last part may give problems due to #1267508: Subselects don't work in DBTNG conditions, except when used as value for IN.

You may change this issue into a feature request, but that will be limited to change the query_available function to also search on partial availability.

fietserwin’s picture

Version: 7.x-3.2 » 7.x-3.x-dev
Component: Miscellaneous » Code
Assigned: Unassigned » fietserwin
Category: support » feature

Changing scope to: Let query_available function also search on partial availability. Assigning to myself as to create a todo list for 7.x-3.3.

fietserwin’s picture

Version: 7.x-3.x-dev » 7.x-4.x-dev
steffenr’s picture

HI i just stumbled across this issue - i also have the same problem and try to search for partial availability - could you give me any information about the progress on this issue?

Thx in advance.
SteffenR

fietserwin’s picture

Not given any attention so far. Patches are welcome. Start with a patch that changes the availability_calendar_is_available() function in the module's inc file by adding an additional parameter: minimum availability. I think it will be easy to search for partial availability, but difficult to search for partial consecutive availability which is what you probably want

fietserwin’s picture

I changed the API function availability_calendar_is_available() by adding a parameter minimum_days, but to do the same with availability_calendar_query_available(), #1267508: Subselects don't work in DBTNG conditions, except when used as value for IN needs to be solved first :(.