You are here

README.txt in Availability Calendars 7.4

Same filename in this branch
  1. 7.4 README.txt
  2. 7.4 booking_formlet/README.txt
Same filename and directory in other branches
  1. 7.5 booking_formlet/README.txt
  2. 7.3 booking_formlet/README.txt
/**
 * README for Availability Calendar Booking Formlet module.
 *
 * @author Erwin Derksen (fietserwin: http://drupal.org/user/750928)
 */

The availability calendar booking formlet module defines a booking formlet
field that cooperates with Availability Calendar fields. It offers a small form
that can receive an arrival and departure date by reacting to click events on
Availability Calendar fields. If both dates are filled in, the submit button is
enabled and the user can continue to the real booking form.

This form is called a formlet as it is a small minimal form that only receives
the arrival and departure dates. The full booking form, where the visitor can
enter his/her name and other details is to defined separately. Think off an "Add
to cart" form where one can enter the quantity and click on "add to cart" which
brings you to the full cart form.


Dependencies
------------
This sub-module depends on the Availability Calendar module.
Also the form will typically be posted to a webform. So installing the webform
module is recommended.


Limitations
-----------
This module will not:
- Change the calendar. When clicking on the departure date the calendar will be
  updated visually, but this change will not be stored on the server. You can
  define a hook for that. See e.g. the webform documentation to find out which
  (submission) hooks best fit your needs.
- Define the webform. This depends to much on your specific situation.
- Offer payment integration.


Installing
----------
As usual.


Configuring
-----------
After enabling the module:
1) Define the date formats you want to use on admin/config/regional/date-time.
   You can localize these formats in admin/config/regional/date-time/locale.
2) Add a webform to post the form to. See the details below.
3) Add an "Availability Calendar Booking formlet" field to the entity type that
   also has an "Availability Calendar" field. Fill the "URL to continue the
   booking" field with the URL of the webform created in step 2.
4) Set the display settings on the "Manage display" page.
5) Style the form as you like. Note that this module only contains some basic
   styling for the formlet.

Basically this is it. Additionally you may want to define some webform
submission processing. This will be explained further on.


Views integration
-----------------
Suppose you have defined a view that searches on availability. The results page
shows the teasers of the entities that are available during the defined period.
Why not present just the "book now" button and allow the visitor to directly
go to the complete reservation form?

This is possible. You can define default values for the begin and date that can
come from some contextual variable. The results page of the search will probably
have a URL that looks like
search-availability?available[arrival][date]=2012-07-01&available[duration]=2
You can tell the formlet to take the begin date from $_GET, more specifically
the entry available[arrival][date] and that the end date should be based on a
duration (in days) given by the available[duration] entry of $_GET.

You can define this in the display settings for a given display mode. So, the
settings can differ for the full view, where visitors will still have to click
on the calendar before they can proceed to the complete reservation form, and
the teaser, where visitors can directly click on "book now".


How it works
------------
There seems to be quite some confusion about the why and how of this module. So,
following is a bit more in-depth explanation of the ideas behind this module.

Normally the page with the calendar is quite stuffed with all sorts of
information. Thus adding the complete booking form is not desirable. Therefore,
just a small form (aka 'formlet') is rendered that only contains the most basic
fields to allow it to interact with the calendar. Once this information is
completed by the visitor, it can be forwarded to the complete booking form.

Step by step:
- A visitor arrives at your site and, hopefully, eventually at the page with the
  Availability Calendar.
- The Availability Calendar module renders the calendar and defines the
  javascript that allows the visitor to click on available dates.
- This module adds the 'formlet' to that page including some javascript to
  handle the date click events and place the selected dates on the formlet.
- When the user clicks on "Book this resource ..." all information is POSTed to
  another page. This page is defined in the field settings and normally points
  to a webform with the real booking form.
- Together with the arrival and departure dates, a lot of hidden fields are
  submitted. These hidden fields contain information about the calendar field
  and the entity the calendar is attached to. (Note that calendar fields may be
  synchronized between translations and thus the calendar at its own, does not
  necessarily uniquely define the entity that was being shown.)
- The visitor fills in the remaining information and submits the complete
  booking form.
- Note: on webform submission, the values that the formlet originally POSTed
  will not be there anymore. So if you need them during the webform submission
  phase, you need to place them in webform components! (see below)
- The webform module handles the submission by e.g. e-mailing the submission to
  the website or accommodation owner.


Defining the 'complete booking form' webform
--------------------------------------------
This part assumes you are using the webform 3.x module. For webform 4.x please
be sure tho read the notes further on below as well.

- Define the webform components that the visitor should complete like name,
  e-mail, address, number of persons, etc.
- Define webform components for the dates that are already filled in:
  - Begin date (default value: %post[from_display]): the begin date.
  - End date (default value: %post[to_display]): the end date.
  - Duration (default value: %post[duration_display]): the number of days (or
    nights) between begin date and end date.
  or
  - Begin date (default value: %post[from_iso]): the begin date.
  - End date (default value: %post[to_iso]): the end date.
  - Duration (default value: %post[duration]): the number of days (or nights)
    between begin date and end date. For overnight calendars the end date is not
    inclusive in the duration, for full day rental calendars it is.
  These will typically be disabled text fields, the visitor can not change the
  dates anymore as the availability calendar is not visible on the webform.

  The difference between these 2 sets of dates are:
  - The dates in the latter set are in the ISO 8601 (yyyy-mm-dd) format, while
    the dates in the former set are in the format as presented to the visitor.
    You can define and localize this format via the Drupal admin interface at
    admin/config/regional/date-time(/locale).
    Note that this may lead to different date representations for the same date
    depending on the *visitor*, not the *recipient* of the webform!
  - For overnight calendar fields, the to_iso date is the last full day of the
    rental period, while the to_display date is the departure date.
  - The duration in the former set is a string that includes the word(s)
    night(s) and or day(s) and is translated in the language of the *visitor*,
    not the *recipient* of the webform! The duration in the latter is a number.
- As you will typically post to the same webform for all accommodations, you
  need to know from which accommodation the request was coming. To this end, you
  may want to define additional webform components that receive this information
  needed to process the booking:
  - cid (default value: %post[cid]): the calendar id.
  - calendar label (default value: %post[calendar_label]): title of the calendar
    (if set).
  - entity type (default value: %post[entity_type]): the entity type.
  - entity id (default value: %post[entity_id]): the ID of the entity.
  - entity label (default value: %post[entity_label]): the title of the entity.
  With the exception of entity label and/or calendar_label, these will typically
  be hidden fields as the visitor does not have to see this information.
  Note that in a multi-lingual site, a calendar may be synchronized over all
  translations of an entity. So there is not necessarily a 1-to-1 relationship
  between the calendar and the entity.
- Fields from the POST that you don't need, don't have to be defined as a
  webform component.
- You may also have fields from the POST that you only need for internal
  processing, but do not want to send in the e-mail. You should declare those
  fields as webform component and, subsequently, you can exclude them from the
  e-mail in the "Edit e-mail settings" page of the webform module.

Notes for webform 4.x:
- Enable the 'Use GET (instead of POST)' setting on the booking formlet field
  settings form.
- Use a syntax like [current-page:query:from_iso] as default value.


Hooks for custom processing
---------------------------
Depending on your situation, processing the webform may need some additional
programming from your side. Think of extracting the name of the accommodation
from the entity, or getting the e-mail address to send the request to. The
webform module and the mail system offer hooks for this.

1) The webform to complete the booking is used for multiple accommodations and
you want to change the e-mail address to which the webform submission is sent

2) On submission, you want to update the calendar and set the requested dates
to "Optionally booked".

ad 1)
See issue http://drupal.org/node/1470490

ad 2)
See issue http://drupal.org/node/1379384

File

booking_formlet/README.txt
View source
  1. /**
  2. * README for Availability Calendar Booking Formlet module.
  3. *
  4. * @author Erwin Derksen (fietserwin: http://drupal.org/user/750928)
  5. */
  6. The availability calendar booking formlet module defines a booking formlet
  7. field that cooperates with Availability Calendar fields. It offers a small form
  8. that can receive an arrival and departure date by reacting to click events on
  9. Availability Calendar fields. If both dates are filled in, the submit button is
  10. enabled and the user can continue to the real booking form.
  11. This form is called a formlet as it is a small minimal form that only receives
  12. the arrival and departure dates. The full booking form, where the visitor can
  13. enter his/her name and other details is to defined separately. Think off an "Add
  14. to cart" form where one can enter the quantity and click on "add to cart" which
  15. brings you to the full cart form.
  16. Dependencies
  17. ------------
  18. This sub-module depends on the Availability Calendar module.
  19. Also the form will typically be posted to a webform. So installing the webform
  20. module is recommended.
  21. Limitations
  22. -----------
  23. This module will not:
  24. - Change the calendar. When clicking on the departure date the calendar will be
  25. updated visually, but this change will not be stored on the server. You can
  26. define a hook for that. See e.g. the webform documentation to find out which
  27. (submission) hooks best fit your needs.
  28. - Define the webform. This depends to much on your specific situation.
  29. - Offer payment integration.
  30. Installing
  31. ----------
  32. As usual.
  33. Configuring
  34. -----------
  35. After enabling the module:
  36. 1) Define the date formats you want to use on admin/config/regional/date-time.
  37. You can localize these formats in admin/config/regional/date-time/locale.
  38. 2) Add a webform to post the form to. See the details below.
  39. 3) Add an "Availability Calendar Booking formlet" field to the entity type that
  40. also has an "Availability Calendar" field. Fill the "URL to continue the
  41. booking" field with the URL of the webform created in step 2.
  42. 4) Set the display settings on the "Manage display" page.
  43. 5) Style the form as you like. Note that this module only contains some basic
  44. styling for the formlet.
  45. Basically this is it. Additionally you may want to define some webform
  46. submission processing. This will be explained further on.
  47. Views integration
  48. -----------------
  49. Suppose you have defined a view that searches on availability. The results page
  50. shows the teasers of the entities that are available during the defined period.
  51. Why not present just the "book now" button and allow the visitor to directly
  52. go to the complete reservation form?
  53. This is possible. You can define default values for the begin and date that can
  54. come from some contextual variable. The results page of the search will probably
  55. have a URL that looks like
  56. search-availability?available[arrival][date]=2012-07-01&available[duration]=2
  57. You can tell the formlet to take the begin date from $_GET, more specifically
  58. the entry available[arrival][date] and that the end date should be based on a
  59. duration (in days) given by the available[duration] entry of $_GET.
  60. You can define this in the display settings for a given display mode. So, the
  61. settings can differ for the full view, where visitors will still have to click
  62. on the calendar before they can proceed to the complete reservation form, and
  63. the teaser, where visitors can directly click on "book now".
  64. How it works
  65. ------------
  66. There seems to be quite some confusion about the why and how of this module. So,
  67. following is a bit more in-depth explanation of the ideas behind this module.
  68. Normally the page with the calendar is quite stuffed with all sorts of
  69. information. Thus adding the complete booking form is not desirable. Therefore,
  70. just a small form (aka 'formlet') is rendered that only contains the most basic
  71. fields to allow it to interact with the calendar. Once this information is
  72. completed by the visitor, it can be forwarded to the complete booking form.
  73. Step by step:
  74. - A visitor arrives at your site and, hopefully, eventually at the page with the
  75. Availability Calendar.
  76. - The Availability Calendar module renders the calendar and defines the
  77. javascript that allows the visitor to click on available dates.
  78. - This module adds the 'formlet' to that page including some javascript to
  79. handle the date click events and place the selected dates on the formlet.
  80. - When the user clicks on "Book this resource ..." all information is POSTed to
  81. another page. This page is defined in the field settings and normally points
  82. to a webform with the real booking form.
  83. - Together with the arrival and departure dates, a lot of hidden fields are
  84. submitted. These hidden fields contain information about the calendar field
  85. and the entity the calendar is attached to. (Note that calendar fields may be
  86. synchronized between translations and thus the calendar at its own, does not
  87. necessarily uniquely define the entity that was being shown.)
  88. - The visitor fills in the remaining information and submits the complete
  89. booking form.
  90. - Note: on webform submission, the values that the formlet originally POSTed
  91. will not be there anymore. So if you need them during the webform submission
  92. phase, you need to place them in webform components! (see below)
  93. - The webform module handles the submission by e.g. e-mailing the submission to
  94. the website or accommodation owner.
  95. Defining the 'complete booking form' webform
  96. --------------------------------------------
  97. This part assumes you are using the webform 3.x module. For webform 4.x please
  98. be sure tho read the notes further on below as well.
  99. - Define the webform components that the visitor should complete like name,
  100. e-mail, address, number of persons, etc.
  101. - Define webform components for the dates that are already filled in:
  102. - Begin date (default value: %post[from_display]): the begin date.
  103. - End date (default value: %post[to_display]): the end date.
  104. - Duration (default value: %post[duration_display]): the number of days (or
  105. nights) between begin date and end date.
  106. or
  107. - Begin date (default value: %post[from_iso]): the begin date.
  108. - End date (default value: %post[to_iso]): the end date.
  109. - Duration (default value: %post[duration]): the number of days (or nights)
  110. between begin date and end date. For overnight calendars the end date is not
  111. inclusive in the duration, for full day rental calendars it is.
  112. These will typically be disabled text fields, the visitor can not change the
  113. dates anymore as the availability calendar is not visible on the webform.
  114. The difference between these 2 sets of dates are:
  115. - The dates in the latter set are in the ISO 8601 (yyyy-mm-dd) format, while
  116. the dates in the former set are in the format as presented to the visitor.
  117. You can define and localize this format via the Drupal admin interface at
  118. admin/config/regional/date-time(/locale).
  119. Note that this may lead to different date representations for the same date
  120. depending on the *visitor*, not the *recipient* of the webform!
  121. - For overnight calendar fields, the to_iso date is the last full day of the
  122. rental period, while the to_display date is the departure date.
  123. - The duration in the former set is a string that includes the word(s)
  124. night(s) and or day(s) and is translated in the language of the *visitor*,
  125. not the *recipient* of the webform! The duration in the latter is a number.
  126. - As you will typically post to the same webform for all accommodations, you
  127. need to know from which accommodation the request was coming. To this end, you
  128. may want to define additional webform components that receive this information
  129. needed to process the booking:
  130. - cid (default value: %post[cid]): the calendar id.
  131. - calendar label (default value: %post[calendar_label]): title of the calendar
  132. (if set).
  133. - entity type (default value: %post[entity_type]): the entity type.
  134. - entity id (default value: %post[entity_id]): the ID of the entity.
  135. - entity label (default value: %post[entity_label]): the title of the entity.
  136. With the exception of entity label and/or calendar_label, these will typically
  137. be hidden fields as the visitor does not have to see this information.
  138. Note that in a multi-lingual site, a calendar may be synchronized over all
  139. translations of an entity. So there is not necessarily a 1-to-1 relationship
  140. between the calendar and the entity.
  141. - Fields from the POST that you don't need, don't have to be defined as a
  142. webform component.
  143. - You may also have fields from the POST that you only need for internal
  144. processing, but do not want to send in the e-mail. You should declare those
  145. fields as webform component and, subsequently, you can exclude them from the
  146. e-mail in the "Edit e-mail settings" page of the webform module.
  147. Notes for webform 4.x:
  148. - Enable the 'Use GET (instead of POST)' setting on the booking formlet field
  149. settings form.
  150. - Use a syntax like [current-page:query:from_iso] as default value.
  151. Hooks for custom processing
  152. ---------------------------
  153. Depending on your situation, processing the webform may need some additional
  154. programming from your side. Think of extracting the name of the accommodation
  155. from the entity, or getting the e-mail address to send the request to. The
  156. webform module and the mail system offer hooks for this.
  157. 1) The webform to complete the booking is used for multiple accommodations and
  158. you want to change the e-mail address to which the webform submission is sent
  159. 2) On submission, you want to update the calendar and set the requested dates
  160. to "Optionally booked".
  161. ad 1)
  162. See issue http://drupal.org/node/1470490
  163. ad 2)
  164. See issue http://drupal.org/node/1379384