It wasn't very easy to find documentation or examples of how to handle bookings, so I thought I'd post an example here. Maybe other people can benefit!

This is the module I created to help me process my bookings. It does:

  • Validate if the dates are indeed avaible before submitting a webform
  • After the webform has been submitted, the selected dates are converted to 'provisionally booked'
  • Add a custom action to webform submission. This lets the site's maintainer convert a booking from 'provisionally booked' to 'fully booked'

I'm a themer, so the code won't be perfect. For example some items are hardcoded, like the webform id and the status id's, but I hope it will be helpfull!

<?php
/**
* @file
* A module that processes availability bookings
*/
function rgs_general_init() {
  module_load_include('inc', 'availability_calendar', 'availability_calendar');
}

/**
 * Implements hook_menu().
 */
function rgs_general_menu() {
  // a menu callback for confirming bookings...
  $items = array();
  $items['node/%webform_menu/submission/%webform_menu_submission/confirm'] = array(
    'title' => 'Confirm booking',
    'load arguments' => array(1),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('rgs_general_booking_confirm',1,3),
    'access callback' => 'webform_results_access',
    'access arguments' => array(1),
    'type' => MENU_CALLBACK,
  );
  return $items;
}

/**
 * Menu callback -- ask for confirmation of booking...
 */
function rgs_general_booking_confirm($form, &$form_state, $node, $submission) {
  $form['#submission'] = $submission;
  $form['#node'] = $node;
  return confirm_form($form,
    t('Confirm this booking?'),
    'node/23', //the path to go to when the user cancels...
    t('This action cannot be undone.'),
    t('Confirm booking'),
    t('Cancel')
  );
}

/**
 * Execute node deletion
 */
function rgs_general_booking_confirm_submit($form, &$form_state) {
  if ($form_state['values']['confirm']) {
    $submission = $form['#submission'];
    $node = $form['#node'];
   
     // map the fields of the submission to names:
    $mapping = _rgs_general_webform_component_mapping($node);
    
    // get the fields we need.
    $name = $submission->data[$mapping['name']]['value'][0];
    $arrival_date = $submission->data[$mapping['arrival_date']]['value'][0];
    $departure_date = $submission->data[$mapping['departure_date']]['value'][0];
    $cid = $submission->data[$mapping['cid']]['value'][0]; 
    $from = new DateTime($arrival_date);
    $to = new DateTime($departure_date);
    
    // change the state to 'Provisionally booked';
    $sid = 3; // state for booking confirmed;   
    availability_calendar_update_availability($cid, $sid, $from, $to);

    drupal_set_message('Booking is confirmed...');
  }
  $form_state['redirect'] = '<front>';
}
/*
 * hook_webform_submission_actions
 * Add a confirm booking action to webform results
 * 
 */
function rgs_general_webform_submission_actions($node, $submission) {
  if (webform_results_access($node)) {
    $actions['confirm_booking'] = array(
      'title' => t('Confirm booking'),
      'href' => 'node/' . $node->nid . '/submission/' . $submission->sid . '/confirm',
      'query' => drupal_get_destination(),
    );
  }
  return $actions;
}
/*
 * hook_webform_submission_insert
 * when dates are booked, update the calender to 'Provisionally booked'.
 */
function rgs_general_webform_submission_insert($node, $submission){
  // @todo: only check the webform we want, instead of all...

  // map the fields of the submission to names:
  $mapping = _rgs_general_webform_component_mapping($node);
  
  // get the fields we need.
  $name = $submission->data[$mapping['name']]['value'][0];
  $arrival_date = $submission->data[$mapping['arrival_date']]['value'][0];
  $departure_date = $submission->data[$mapping['departure_date']]['value'][0];
  $cid = $submission->data[$mapping['cid']]['value'][0];
  // change the state to 'Provisionally booked';
  // @todo: make configurable...
  $sid = 4;
  
  $from = new DateTime($arrival_date);
  $to = new DateTime($departure_date);
  /*$from = new DateTime('04-05-2012');
  $to = new DateTime('05-05-2012');*/
  
  // check if all are available
  $dates_are_available =  _rgs_general_check_availability_range($cid, $arrival_date, $departure_date);

  // make the booking if date are available, otherwise inform the visitor
  if ($dates_are_available){
    availability_calendar_update_availability($cid, $sid, $from, $to);
  }
  else {
    drupal_set_message("Deze datums zijn helaas niet beschikbaar,");
  };
}

/**
* Implementation of hook_form_alter().
*/
function rgs_general_form_alter(&$form, &$form_state, $form_id) {
  // Add validation for a particular Webform node:
  if ($form_id == 'webform_client_form_3') {
    // Simply add the additional validate handler.
    $form['#validate'][] = '_rgs_validate_booking';
  }
}

/**
* Extra validation for the booking webform
*/
function _rgs_validate_booking($form, $form_state) {
  // check availablity of chosen dates
  $arrival_date = $form_state['values']['submitted']['arrival_date'];
  $departure_date = $form_state['values']['submitted']['departure_date'];
  $cid = $form_state['values']['submitted']['cid'];
  $available = _rgs_general_check_availability_range($cid, $arrival_date, $departure_date);

  if (!$available) {
    form_set_error('', t("We're sorry. One or more days within this period are not available."));
  }
}

/*
 * Helper functions
 */


function _rgs_general_webform_component_mapping($node) {
  $mapping = array();
  $components = $node->webform['components'];
  foreach ($components as $i => $component) {
    $key = $component['form_key'];
    $mapping[$key] = $i;
  }
  return $mapping;
}

function _rgs_general_check_availability_range($cid, $arrival_date, $departure_date) {
  // convert dates to the correct format, if needed
  $from = is_object($arrival_date) ? $arrival_date : new DateTime($arrival_date);
  $to = is_object($departure_date) ? $departure_date : new DateTime($departure_date);
  
    // get the calendar states
  $states = availability_calendar_get_states();
  
  // get the availablity for this date...
  $available = availability_calendar_get_availability($cid, $from, $to);

  // loop through the dates to check if all are available
  $dates_are_available = true;
  foreach ($available as $day){
    $state = $states[$day];
    $available_this_day =  availability_calendar_filter_available($state);
    if (!$available_this_day){
      // if we find a date that is not available, stop
      // checking because we can't make this booking anyway
      $dates_are_available = false;
      break;
    }
  }
  return $dates_are_available;
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

fietserwin’s picture

Version: 7.x-3.1 » 7.x-3.x-dev
Component: Documentation » Code
Assigned: Unassigned » fietserwin
Category: task » feature

Thanks for the code.

Regading the:
Validation.
The actual checking is done in the target of the booking formlet POST action which is outside the module. But I will add the function to the API of Availability Calendars, so custom code should only have to call this function.

Change dates to provisionally booked.
In the beginning I was a bit reluctant to add this. we had just implemented custom states, so we did not know the "meaning" of a state any more. But soon it became clear we had to add this kind of information back to the states anyway (think the option "Treat as available"). So, as we know the state to change it into (option "Change state to"), we could really do so. That is, if I can get from a webform submission to the correct field info... (theoretically, there can be more than 1 booking formlet field)

Add a custom action to webform submission.
I never used webform beyond sending e-mails out, so I was not aware of tying actions to submissions on the submission overview page. But I like this a lot and there seems to be a lot of demand for further integration of the bookings process. So, I will see if and how this can be added to the module itself. Currently the module has no knowledge of node or webform id's, you just enter the (internal) URL of the destination for the POST action. So we need to change some things there and we need to know the "fully booked" status, but I guess that this can be built-in.

K3vin_nl’s picture

I'm glad it is of some use!

The problem I am now having with webforms is that there is no decent way to show a list of bookings.
The default webform result pages are bit to generic for this. It would be nice to be able to displays all bookings after today and to be able to sort them by arrival date, email adres, etc...

So I'm considering building a custom page that can do that.

An alternative is to wait for better webform submission <-> views integration. Then we could build such a page with views. This seems promising: http://drupal.org/node/680386

Another option would be to create a node for each booking and use views to generate an overview page of booking nodes.

fietserwin’s picture

If you want your complete booking administration in Drupal, you might want to try Rooms.

ronajon’s picture

is this functionality changed in the new version 3.2 or do i still need to use the code above?

fietserwin’s picture

This code is not yet committed (therefore the status active). I hope to have some more time to do some module development as of half February and this will be one of the first things that I will pick up.

dericg’s picture

In which file, and where in that file, should this code be inserted?

fietserwin’s picture

If you need the code now, make it a custom module. The (naming of the functions in the ) example code from K3vin seems to come from a custom module. By doing so it will be easier to upgrade to a newer version of A.C. later, when this code has been integrated. And yes, I'm still planning to do so.

K3vin_nl’s picture

And one more addition: I ended up using Webform report to generate overviews of the bookings.
The module allows you to generate custom tables of webform submissions, which works really nice when using webforms to process the availability calendar bookings.

dericg’s picture

Anyone interested in helping me debug? I created the module, and changed the webform ID, but I'm not sure what other parameters need to be altered.

http://dericg.com/diamond/content/pa-1-test

The module does run, but it doesn't validate the availability or edit the dates to unavail after the form is submitted.

fietserwin’s picture

Check the hard coded values in the code above. node/23 is obvious, but less obvious are e.g. the names for the webform fields like 'arrival_date', 'departure_date' and 'cid'. $sid =3 is another one.

Furthermore your message is too general ("it doesn't validate"). Are there any messages, check messages in the log. Can you debug your code with a debugger? If so, place breakpoints in the fnctions you want to check. If not, add some statements to your functions to check if it gets there and with what values. I like the dpm function from the devel module and use it when I am to write a hook function and don't know what to expect in the param list:

  // code to find out what arguments we received in a hook
  $args= func_get_args();
  if (count($args) > 0) {
    foreach ($args as $key => $arg) {
      dpm($arg, $key);
    }
  }
  else {
    drupal_set_message('no arguments received in ' . __FUNCTION__ );
  }
dericg’s picture

One thing I should clarify, is this custom module written for the 7.x-3.x development release, or does it work with the 7.x-3.2 release?

fietserwin’s picture

Shouldn't matter: they are equal except for issue #1458118: Remove LICENSE.txt from Git repository

fietserwin’s picture

Assigned: fietserwin » Unassigned

K3vin, do you think you would be able to turn this into a patch based on the current dev version? If you manage to do so, you, your company or your client will be mentioned as sponsor on the project page (including a link).

The patch should integrate your code into the modules (part A.C and part A.C.B.F.), make the hard coded id's and states configurable and also allow to enable/disable the functionality.

There are quite some feature requests open now and I want to start on the next version that will incorporate a number of these requests, but am lacking enough time to do so.

K3vin_nl’s picture

Time is very limited now, but I will try to make a more friendly module.
Maybe I'll first make a version were all off the current hard coded values are declared in one place in the module. That way other developers can more easily adapt the module to their own use.

K3vin_nl’s picture

Just an update, it will take some time, but I started working on this.

sphankin’s picture

I've been looking for a module to do a simple calendar booking that user can change the status of like this for ages! Really looking forward to the more friendly release but it the mean time I might have a shot at implementing K3vin's code.

Any idea on the length of time it might take?

K3vin_nl’s picture

Just a few more tweaks to do before a first rough version. Should be no longer then a few days.

K3vin_nl’s picture

FileSize
4.76 KB

Ok, here is a first version.
I didn't create a patch (yet) and the module still needs a lot of cleanup, and needs to be renamed, but I think everything should be functional. Feedback would be appreciated!

You first need to have a webform that handles your bookings, after that the module settings can be configured
at '/admin/config/content/rgs_general'.
In the admin sections are some explanations about the fields the webform needs to have.

sphankin’s picture

Hi K3vin,

I've installed the module this morning and all is working great so far!

Just one question, after you've selected the fields in the module settings for the webform you have chosen, how do you link it back to the availability calendar? How have you got your version set up?

Do you select the date on the availability calendar, go to webform, submit webform and then it changes the availability calendar?

Thanks

EDIT: I'm actually getting an error when I try and submit the webform. I've got the availability calendar set up to link to the webform and when I've selected the dates and click 'submit' I get this error:

PDOException: SQLSTATE[HY000]: General error: 1366 Incorrect integer value: '' for column 'cid' at row 1: INSERT INTO {availability_calendar_availability} (cid, date, sid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2), (:db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5), (:db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => 2012-04-12 [:db_insert_placeholder_2] => 4 [:db_insert_placeholder_3] => [:db_insert_placeholder_4] => 2012-04-13 [:db_insert_placeholder_5] => 4 [:db_insert_placeholder_6] => [:db_insert_placeholder_7] => 2012-04-14 [:db_insert_placeholder_8] => 4 ) in availability_calendar_update_availability() (line 318 of C:\Domains\website.org.uk\wwwroot\sites\all\modules\availability_calendars\availability_calendar.inc).

Any ideas why i might be getting this error?

Thanks

K3vin_nl’s picture

I used the AC widget to pass the values to the webform. You can see it in action here:

http://www.reksteren-gamle-skulehuset.com/request-booking

Regarding your error, it looks like no valid calendar id (cid) is passed from the webform?

sphankin’s picture

Thanks for the reply. Could you explain what it supposed to happen when you say no cid is passed from the webform?

(By the way - I've been trying to create a calendar and booking system like this for months and I'm so happy this is making it work! Thank you!)

K3vin_nl’s picture

Availability calendar allows multiple calendars to exist simultaneously. Therefore if you want to change states of a calendar, you have to specify the id of the calendar (cid).
So your webform should also pass this cid to the handling module.
If you use the booking formlet to call your webform it will provide the cid for you in the '%post[cid]' value. I've attached a screenshot of my web form setup, maybe this will help?

gynekolog’s picture

FileSize
232.03 KB

I get this error:

Notice: Undefined index: od ve funkci _rgs_validate_booking() (řádek: 369 v souboru D:\zaloha\xampp\htdocs\lutova\sites\all\modules\rgs_general\rgs_general.module).
Notice: Undefined index: do ve funkci _rgs_validate_booking() (řádek: 370 v souboru D:\zaloha\xampp\htdocs\lutova\sites\all\modules\rgs_general\rgs_general.module).
Exception: DateTime::__construct() [datetime.--construct]: Failed to parse time string (--) at position 0 (-): Unexpected character ve funkci DateTime->__construct() (řádek: 371 v souboru D:\zaloha\xampp\htdocs\lutova\sites\all\modules\rgs_general\rgs_general.module).

AC - last dev

EDIT: I get this error after click on send button but form is not send either save.

EDIT 2: error in english:
Notice: Undefined index: od in _rgs_validate_booking() (line 369 of D:\zaloha\xampp\htdocs\lutova\sites\all\modules\rgs_general\rgs_general.module).
Notice: Undefined index: do in _rgs_validate_booking() (line 370 of D:\zaloha\xampp\htdocs\lutova\sites\all\modules\rgs_general\rgs_general.module).
Exception: DateTime::__construct() [datetime.--construct]: Failed to parse time string (--) at position 0 (-): Unexpected character in DateTime->__construct() (line 371 of D:\zaloha\xampp\htdocs\lutova\sites\all\modules\rgs_general\rgs_general.module).

K3vin_nl’s picture

gynekolog, your error is a little hard to read for me, but it looks like the module can't read the date(s) from the webform submission.
Did you configure the right fields at 'admin/config/content/rgs_general' ?
Are your date fields in the correct format?

gynekolog’s picture

FileSize
487.98 KB

My settings are in attachment. In node type "Room" i have a AC field (Edits the calendar in a viewport) and AC booking formlet.

K3vin_nl’s picture

gynekolog, your settings look ok. Only thing I can think of right now is that my code can't handle your fieldset (that contains arrival and departure dates). I'll try to see if this is the problem tonight.

sphankin’s picture

K3vin, you are amazing! Thank You for the module & the help! It works perfectly now.

Aux’s picture

Hi K3vin,

I'm getting a error like gynekolog but not on the index of the arrival/departure date but on the therm 'submitted' which is hardcode in your module.
(369: $from = $form_state['values']['submitted'][variable_get('rgs_general_arrival_date_field_name')];)

Notice: Undefined index: submitted in _rgs_validate_booking() (line 369 of /var/www/drupal/sites/all/modules/rgs_general/rgs_general.module).
Notice: Undefined index: submitted in _rgs_validate_booking() (line 370 of /var/www/drupal/sites/all/modules/rgs_general/rgs_general.module).
Exception: DateTime::__construct(): Failed to parse time string (--) at position 0 (-): Unexpected character in DateTime->__construct() (line 371 of /var/www/drupal/sites/all/modules/rgs_general/rgs_general.module).

any idea what I'm doing wrong?

@gynekolog, I notice in your screenshots that 'od' and 'do' on your webform starts white a uppercase letter and in the error are whit lowercase letters, could this be the cause of your error?

K3vin_nl’s picture

Aux, I'll look into it tonight.

I'm not 100% sure, but I think/thought 'submitted' in $form_state['values']['submitted'] is the default array that holds the submission data. It seems strange that this is not defined in your case. Maybe there is a better way to access the submitted data, I'll investigate.

gynekolog’s picture

I move arrival and departure field from fieldset and form has been send. But now i get same error when i want confirm booking.

Aux’s picture

Hi K3vin,

have been debugging further, I found the function _rgs_validate_booking is called twice. The first time is when you submit from the webform, here it works as expected and "submitted" exist. The second time is when "Confirm booking", here $form_state doesn't contain "submitted".
A other thing I noticed is that the button "Confirm booking" is renamed to "Submit this booking" like on the webform page.

I concluded that the _rgs_validate_booking handler also was added to the "Confirm booking" button. To stopt this from happening I added a if statement checking if the $form_id is not "rgs_general_booking_confirm" to the function rgs_general_form_alter and now it seems to work.

function rgs_general_form_alter(&$form, &$form_state, $form_id) {
  
  if($form_id != "rgs_general_booking_confirm"){
    // Add validation for a webform that has a calendar id (cid);
    // Assume that is only the case when we are posting a webform used
    // for availability calendars...
    if(isset($form['#node']) && $form['#node']->nid == variable_get('rgs_general_webform_id')) {
        // correct the redirect path depending on the language...
        /*if (module_exists('i18n')){
          $nodepath = $form['#node']->webform['redirect_url'];
          $languagepaths = translation_path_get_translations($nodepath);
          global $language;
          $path = $languagepaths[$language->language];
          $form['#node']->webform['redirect_url'] = $path;
        }*/		
	    
        // disable the 'status' selector because this can only be changed by admins..
        $form['submitted']['status']['#disabled'] = TRUE; 
    
        // Change the text on the button of the webform
        $form['actions']['submit']['#value'] = t('Submit this booking');

       // Simply add the additional validate handler.
       $form['#validate'][] = '_rgs_validate_booking';
      }
      if($form_id=='availability_calendar_booking_formlet_form') {
        // change the text on the submit button of the formlet...
        $form['actions']['submit']['#value'] = t('To the booking form');
      }
    }
}
K3vin_nl’s picture

Aux, thanks you found the bug!
gynekolog, this is probably the error you encountered too!

K3vin_nl’s picture

FileSize
6.1 KB

This version should fix the bug Aux found.
gynekolog, it took some head scratching but I think I found a solution where everything works, even if the components are in fieldsets.

gynekolog’s picture

Great work, my problems are solved.

kevinsiji’s picture

Bugged with an error:

Add Content > select any content type, you get this message ..

Notice: Undefined property: stdClass::$nid in rgs_general_form_alter()
(line 329 of /sites/all/modules/rgs_general/rgs_general.module).

I modified the code to check if $nid is set. Patch attached.

fietserwin’s picture

Assigned: Unassigned » fietserwin

I am currently doing some development for this module. I will incorporate this feature. I already added (but not committed) _rgs_general_check_availability_range() as an API function, though I had to modify it a bit because it ignores non-set days and the default state that is used for those days.

Stay tuned.

Hucaru’s picture

I am using Availability Calendar 7.x-3.2 along with this custom module and am having issues with if (!$available_this_day) in the _rgs_general_check_availability_range function. If I remove the '!' then the if statement works however not as intended obviously. I believe that my issues lies with:

Alternatively how would I go about making booked days and provisionally booked days unclickable just like - http://www.reksteren-gamle-skulehuset.com/request-booking

EDIT: A clean install of the module fixed the problem. However now when I select dates in the calendar the booklet form seems to add 1 day to the end date? Has anyone come across this issue before?

fietserwin’s picture

For your latest problem see issue #1661454: Better distinction between whole day and overnight rental, or: install the dev version.

willhowlett’s picture

This is great functionality. Many thanks for the hard work involved.

I'm getting the following error message, using the latest dev version on php 5.4, after submitting a form:

    Warning: Illegal string offset 'day' in _rgs_validate_booking() (line 377 of C:\xampp\htdocs\drupal_main\drupal_7\sites\site.com\modules\rgs_general\rgs_general.module).
    Warning: Illegal string offset 'month' in _rgs_validate_booking() (line 377 of C:\xampp\htdocs\drupal_main\drupal_7\sites\site.com\modules\rgs_general\rgs_general.module).
    Warning: Illegal string offset 'year' in _rgs_validate_booking() (line 377 of C:\xampp\htdocs\drupal_main\drupal_7\sites\site.com\modules\rgs_general\rgs_general.module).
    Warning: Illegal string offset 'day' in _rgs_validate_booking() (line 378 of C:\xampp\htdocs\drupal_main\drupal_7\sites\site.com\modules\rgs_general\rgs_general.module).
    Warning: Illegal string offset 'month' in _rgs_validate_booking() (line 378 of C:\xampp\htdocs\drupal_main\drupal_7\sites\site.com\modules\rgs_general\rgs_general.module).
    Warning: Illegal string offset 'year' in _rgs_validate_booking() (line 378 of C:\xampp\htdocs\drupal_main\drupal_7\sites\site.com\modules\rgs_general\rgs_general.module).

I also notice that when submitting a form for dates which are already booked, I get the "We're sorry. One or more days within this period are not available" message, but the submission still gets saved to the webform.
Is this expected behaviour? (I'm wondering whether it's a bug related to the above error message, as the $available variable check in _rgs_validate_booking relies on the $arrival_date and $departure_date variables, which may not be getting set correctly as a result of the error above)

fietserwin’s picture

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

Category: feature » support

Hi, I am getting the following error when I submit the webform:

Exception: DateTime::__construct() [datetime.--construct]: Failed to parse time string (T-T-T) at position 1 (-): Unexpected character in DateTime->__construct() (line 378 of /home/ab2597/public_html/rooms/sites/all/modules/availability_calendars/rgs_general/rgs_general.module).
The website encountered an unexpected error. Please try again later.

Any ideas?

fietserwin’s picture

Category: support » feature
Status: Active » Needs review

Setting to needs review. I assume that the current state of the request is
#33
+ #35 applied
- #36
+ test for #39 and #41

I hope to find some time to add it.

ominem’s picture

Help don't know how to use rgs_general.module.20120625.patch

ominem’s picture

sorry how can I use your patch?
thank you

willhowlett’s picture

firstlut’s picture

Gregorio@41: I was having the same problem! Turns out the module is set up to parse the date in a specific format: day-month-year. You set those at admin/config/regional/date-time. I set mine to "j-M-Y."

I may monkey with the code on that line to switch day and month; my users are likely to get discombobulated by that fancy Yurpeen date stuff. ;-)

rli’s picture

@K3vin Thanks for the great module.
As for the error in #39, I printed the $from and $to out, they were the string 'yyyy-mm-dd' already. So I guess just to simply pass them into DateTime _construct() will solve the problem.

jmary’s picture

FileSize
5.36 KB

I've tried this patch on version 7.x.5.1 -> It's very broken : WSOD.

(Running on on php 5.5)

  1. I post here an update of the module posted above. The last patch is already applied, so it doesn't need to be applied anymore
  2. Some modifs to make it work again are applied : basically changing the way DateTime is called and correcting some assumptions made in the precedent version.

  3. Is included a tiny module providing the fix described at https://www.drupal.org/node/1580700#comment-7567435

NB :: need to enable this module and also module webform_fix supplied inside.

rambletype’s picture

I really appreciate the work you guys have done on this. I'm having a problem, however. On submission, I'm getting the following error:

Notice: Undefined index: value in rgs_general_webform_submission_insert() (line 289 of /var/www/yournewstorefront.com/sites/all/modules/rgs_general/rgs_general.module).
Notice: Undefined index: value in rgs_general_webform_submission_insert() (line 290 of /var/www/yournewstorefront.com/sites/all/modules/rgs_general/rgs_general.module).
Notice: Undefined index: value in rgs_general_webform_submission_insert() (line 291 of /var/www/yournewstorefront.com/sites/all/modules/rgs_general/rgs_general.module).
Notice: Undefined index: value in rgs_general_webform_submission_insert() (line 303 of /var/www/yournewstorefront.com/sites/all/modules/rgs_general/rgs_general.module).
PDOException: SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'cid' cannot be null: INSERT INTO {availability_calendar_availability} (cid, date, sid) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2); Array ( [:db_insert_placeholder_0] => [:db_insert_placeholder_1] => 2014-08-15 [:db_insert_placeholder_2] => 4 ) in availability_calendar_update_availability() (line 583 of /var/www/XXXXX/sites/all/modules/availability_calendars/availability_calendar.inc).

Is it possible I've not changed a hard-coded line in the code somewhere??

Thanks! -Chris

rambletype’s picture

So, I ended up using jmary's version, and that error message went away. But I'm now getting a new one: Fatal error: Call to a member function format() on a non-object in /var/www/XXXXXX/sites/all/modules/availability_calendars/availability_calendar.inc on line 562

Fernando Vesga’s picture

Hi!,

i'm having the same error as you rambletype. Any progress on this?

thanks

pikot’s picture

+1. I'm having the same error...

volvo760’s picture

Me too, same error.

MakcBlackAngel’s picture

$name = $submission->data[$mapping['name']]['value'][0];
$arrival_date = $submission->data[$mapping['arrival_date']]['value'][0];
$departure_date = $submission->data[$mapping['departure_date']]['value'][0];
$cid = $submission->data[$mapping['cid']]['value'][0];

Delete all ['value'] in rgs_general.module

$name = $submission->data[$mapping['name']][0];
$arrival_date = $submission->data[$mapping['arrival_date']][0];
$departure_date = $submission->data[$mapping['departure_date']][0];
$cid = $submission->data[$mapping['cid']][0];

It's work :)

Drupal ver. 7.37
Availability Calendars ver. 7.x-5.4
Webform ver. 7.x-4.8

pacome’s picture

Hello

Thank you for this new functionality, it's great !
However, i still have a problem : even with a proper Cid in my webform, i get this error :
Notice: Undefined index: cid in _rgs_validate_booking() (line 405 of /.../sites/all/modules/rgs_general/rgs_general.module).

And on console log i get this error message :
POST http://.../reservation?cid=6&calendar_label=HS63%27s+SE+room&en…&form_id=availability_calendar_booking_formlet_form&op=To+the+booking+form 500 (Internal Server Error)

The way i'm getting cid in a webform filed is to set its default value to [current-page:query:cid], and it looks correct.
I kept the option "Use GET instead of POST" checked-in, otherwise i don't have any more dates values filled in my Webform.. Could it be related to that ?

I'm using :
Drupal 7.38
Av Cal 7.x-5.4
Webform 7.x-4.9
[edit] : and i'm using the module posted in #48 :)

Thank you very much for any advice
Pacome

doorskey’s picture

Version: 7.x-4.x-dev » 7.x-5.4

I've deleted all ['value'] in rgs_general.module as MakcBlackAngel said, but still see this:

Fatal error: Call to a member function format() on a non-object in xxx\calendar\sites\all\modules\availability_calendars\availability_calendar.inc on line 575