Comments

developer-x’s picture

StatusFileSize
new11.11 KB
developer-x’s picture

Allow me to add more detail. Specifically, eventbookings provides the following functionality off of the bookingsap (none of this functionality is currently provided)i:

1. Book resources directly from an Event - aka date enabled Nodes.
2. Allow either multiple or exclusive booking of resources.
3. Add view definitions to allow a user to create views which join an "Event" with a booked resource
4. Provide "out of the box" calendar views of bookable resources
5. Provide ajax functionality that refreshes available resources when date values change on an Event edit page
6. Provide links to conflicting events.
7. Provide security permissions to allow/restrict users from booking resources.

This module works very nicely with publicbookings - syncing event dates and booking records. But doesn't require publicbookings or conflict with publicbookings.

I updated an issue with the maintainer of thge bookingsapi and publicbookings module: http://drupal.org/node/630874

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, pointing out what needs to be changed.

developer-x’s picture

StatusFileSize
new11.07 KB

Here is another version - review this one - coder gives it a clean bill of health.

developer-x’s picture

Hi - what is the status of this? I see a link "CVS edit link for developer-x" - but when I click on it, I get an "Access denied" msg. I don't know if that is working as expected or is a bug.

Anyhow, thanks in advance!

avpaderno’s picture

I apologize if the application review is taking more time than it would need. Users who review applications are few, and that makes the reviews longer than you would expect.

About the link on the top of the page, I think that is only for users with the right permission. Once your account gets approved, it's probable the same link works for you too (I cannot test it, so I cannot report you something that is 100% true).

developer-x’s picture

No problem - I appreciate everyone who is volunteering - it's great to have a thorough process that ensures quality. I was just confused by the link.

dogboy72’s picture

Category: task » bug

Hello, I am getting this error:

# user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT enr.nid FROM eventbookings_node_record enr WHERE enr.record_id in() in C:\xampp\htdocs\kco2\sites\all\modules\eventbookings\eventbookings.module on line 360.
# Sorry, unable to find the resource with id=

Bookings API 6.x-3.x-dev
Public Bookings 6.x-3.x-dev
Drupal 6.17

Thanks.

avpaderno’s picture

Category: bug » task

The category for these applications is always Task.

developer-x’s picture

StatusFileSize
new13.29 KB

Hi,

I'm unable to reproduce this - can you provide a few details:

1. How does this happen? Did you try to create an Event and it appeared when the add screen was shown?
2. Does it happen on an Edit of an Event?
3. Does it happen when the Event was submitted?
4. Were any resources defined (Bookings API resources)
5. Have you been able to book any resources or is the entire thing broken?

Also, I've attached a new version which fixes a number of bugs - you may want to try installing this.

dogboy72’s picture

Hello,

This happened upon installation. I had bookings.api installed but not public bookings. That may be the reason-didn't realize Public Bookings was required. I've got it working somewhat now, but to be honest, am having a hard time understanding how this interacts with Public Bookings. Let me play around with it and get back to you with questions and any bugs.

Thanks!

developer-x’s picture

Hi,

It doesn't require publicbookings - it actually replaces publicbookings. However, you can have both installed. If you modify bookings via eventbookings, the changes will show up in publicbookings and vis-a-versa.

If you can - please run with the latest tar ball - it is more polished and fixes a couple of critical bugs. Also, there is still one change I have pending - I'm going to move the per-content type settings from the eventbookings settings page to content type based settings. So I may provide yet another update fairly soon.

Just in case this wasn't clear, after installing, you will need to goto the eventbookings settings page and enable eventbookings for the date enabled nodes - it won't enable these nodes by default when installing.

Regarding the bug, did this happen as soon as you enabled the module or was there a follow on action? I want to resolve this before making it widely available.

Thanks for testing this!

dogboy72’s picture

The error happened upon installation. When I installed public bookings it went away. With the new tar ball no errors.

Some notes:

  • I think it may be nice to include content types with datetime fields as well. I was confused briefly when I couldn't find my content type on the eventbookings admin page.
  • I was able to set up resources and bookings using Public Bookings, but couldn't find the UI for this in eventbookings.
  • The content type I enabled does show a Book available Resources field group, but on node creation the message was Booking Date: Not Set. This did not change even with the ajax refreshing or by clicking "refresh bookings". Once I saved the node and went back to edit it the message had changed to Booking Date: 2010-06-15 10:00:00 - 2010-06-15 10:00:00 . Notice both dates and time are the same. In the date widget I had the "to time" as 11:30:00.
  • I was able to make multiple appts in the same resource at the same time.
  • The calendar at resource_schedule/%d showed the calendar with the correct title identifying the resource (i.e.Resource Schedule: Ftting Room 1) but the bookings I made were not listed.

To be fair, I don't really understand how to set this up so I'm sure many of the errors are my fault. I need to spend some time with this to make sure I understand what I am doing.

I am going to set up a testing site just for this. The one I used has too many modules installed so resolving conflicts could be a hassle.

Finally, thank you for working on this module. A robust scheduling system is sorely lacking in Drupal. It amazes me that so few are taking on this challenge. I'll keep you posted as I work with this. Feel free to ask questions anytime.

developer-x’s picture

StatusFileSize
new43.02 KB
new42.78 KB
new138.42 KB
new83.13 KB
new13.58 KB

Ok - you're forcing me to write some proper documentation ;-)

One thing - bookings created by publicbookings will not appear in the resource calendar. What eventbookings does is add in the "missing link" between a booking and a node - so, without that link, the calendar doesn't have any nodes to display.

For the sake of testing - disable publicbookings - that will probably just confuse matters.

Also, I realize that I wasn't handling datestamps properly - I've enclosed another version that handles that field type. I should be handling datetime properly - so I'm wondering if the datetype you were having problems with was really a datestamp?

Here are the step by step instructions:

Installation

  • Enable the eventbookings module
  • Add a date, datestamp, or datetime field to the proper Content Types
  • Goto "Site Configuration > Event bookings"
  • Set the bookings status for a booking created by eventbookings
  • Don't change the Schedule url template:
  • Set the Per Content Type Settings
    • If you want to be able to book multiple resources, e.g. a room, a projector, sound equipment, etc..., select Allow mutiple booking of resources
    • Select which date, datestamp, or datetime field you want to use for bookings. The field must have to and from values
    • The weight determines the position of the table on the form
  • Goto "User Management > Permissions"
    • Enable administer bookable Node types for the proper roles
    • Enable book a resource from a bookable Node for the proper roles

Create Bookings API Resources

  • Goto "Content Management >Create Content > Bookings API Resource"
  • Fill out appropriate fields
  • Set the Default Availability to Available
  • Click save
  • Repeat for the rest of the bookable resources

Modify the Resource Schedule View

  • If the date field for the nodes is field_date you don't have to the change the view - it should be ok as-is.
  • Else, goto "Site building > Views"
  • Locate eventbookings_resource_schedule and click on Edit
  • Under Arguments, click on Date: Date (node)
  • Under Date field(s):, select the correct date field (use the from field)
  • Select Update
  • Under Fields, click on Broken/missing handler
  • Select Remove
  • Select + button in the Fields section
  • Select Content in the Groups: dropdown
  • Select the same date field as specified in the Arguments
  • Click Add
  • In the next screen, unselect Group multiple values if it's selected
  • Under Label:, select None
  • Click Update
  • Under Sort Criteria, click on the + button
  • Select Content in the Groups: dropdown
  • Select the same date field as specified in the Arguments
  • Click Add
  • In the next screen, select Descending
  • Click Update
  • Select Broken/missing handler asc
  • Select Remove
  • Select on the Save button in the lower left to save the changes to the view

Create a booking

  • Goto "Content management > Create content > <your_event_type>"
  • Add a title
  • Change the from and to field in the enabled date fieldset
  • As you change the values, the resource bookings table should automatically update reflecting the range and enabling/disabling resource selection based off of availability
  • Set the repeat rule if appropriate. This should update the resource booking table
  • Select which resources you want to book. If there are conflicts, they will be listed as links - you can click on the link to make changes. Just hit the Refresh Bookings button after making the changes.
  • If the bookings were created through Publicbookings, they will not appear as a link. You will need to goto Publicbookings to make any changes.
  • Click on the schedule link to see a calendar of the resource's bookings
  • Select Save to create the Event

I've enclosed a new tarball with the datestamp fix along with the screenshots showing how things should look if everything is working. Thanks!

developer-x’s picture

StatusFileSize
new41.02 KB

The previous screenshot of the calendar has a bug - this one is correct.

dogboy72’s picture

Awesome. I'll test this tomorrow and give you my results. Thanks!

dogboy72’s picture

StatusFileSize
new47.43 KB
new49.86 KB

I was able to play around with this today. First of all, thanks for the instructions.

I've attached two screenshots that show some problems I'm having.

One is that the from and to times in the message on the create a booking page are the same.
The second is that there are never any conflicts. I only have one resource and I am book it more than once for the exact same time frame.

To be continued...

developer-x’s picture

I think the reason there isn't any conflicts is because the to and from are the same - thus every booking has a zero duration.

So, if I can fix the "to" problem - I think the other problem goes away.

I'll try to reproduce this - what datatype is your date field and which widget is it set to? Also, what version of the date module do you have?

dogboy72’s picture

The field is a "date" field. Version 6.x-2.4 of the Date Module.

Edit: Set to "Text field with pop up calendar"

developer-x’s picture

StatusFileSize
new13.71 KB

Found the bug - it had to do with user configurable timezones. I had it set to user configurable, so that is why I wasn't able to recreate it. Anyhow, I fixed it. Also, I made it so you can change the title of the bookings fieldset - you can change it to something like "Fitting Rooms".

Please deploy this and let me know if you start seeing conflicts (you still need to delete the old bookings - just rebook those events to fix them).

developer-x’s picture

Actually, the bug was purely cosmetic - it wasn't actually effecting the bookings dates. The actual reason I suspect that the bookings aren't showing as a conflict is that the setting for the initial booking state is pending. Change the initial state to be finalized in the Event bookings settings page. Then re-save each of the Events - that will change the booking state. The alternative is to use Public bookings to change the state of the booking.

dogboy72’s picture

I've done a quick test and everything is working well. Conflicts are showing up now.
Going forward I think the ability to change the booking state on a per node basis would be nice. Also the ability to see potential conflicts that are "pending"(without having to click the schedule link). It would be great to be able to schedule the resource similar to the Public Bookings mod. That is have "closed" hours and slots of availability.

I'm actively learning Drupal and hope to help extend this and/or Public Bookings. My needs are a little more specific than most.

I'm off for several days backpacking - I'll be back next week to further test this. Thanks!

developer-x’s picture

I'm glad everything is working. Regarding managing the bookings - my goal was to not duplicate functionality in publicbookings - but rather complement it - by adding the missing link to the event node. My suggestion is to use both eventbooking and publicbookings together. Create the initial booking via eventbookings. Then manage the workflow with publicbookings. My module "listens" to publicbookings - so if you change anything with publicbookings - my module will do the book keeping to keep the link to the event in sync, as well as any date changes.

The one gap is that my module doesn't create a corresponding event when a booking is created via publicbookings. Maybe I'll look into that.

The other thing I might do is add a link to the publicbookings page from the bookings table that would let you manage the booking.

Anyhow, thanks for doing some QA and enjoy the hiking!

developer-x’s picture

StatusFileSize
new16.26 KB

Ok, I've done a 180. The more I looked into your suggestions, the more I thought it made sense for eventbookings to handle the full range of functionality rather than splitting it with publicbookings. To that end, I have another release. The major highlights:

1. You can associate content types to either create availabilities or bookings.
2. You can specify whether pending bookings show as conflicts
3. If you have rights, you can set the status of a booking
4. New views to show availabilities and booked resources for an event.
5. Bug fixes

If you get a chance, install this version and see if it address your requests.

One suggestion, for availabilities, select "multiple bookings" in the configuration screen. Then you can associate an "Regular Business Hours" (or whatever) availability to many resources. This makes it easier to manage availabilities across resources.

dogboy72’s picture

Wow, you work quickly! I've done a preliminary test, and so far, so good. I'll keep testing.

developer-x’s picture

StatusFileSize
new17.09 KB

This version supports "all day" events. You can define which hours to book for an "all day" event.

BTW, how long does it take to get this reviewed? I understand the nature of the volunteer system - but wanted to have a sense of how long this usually takes. Thanks!

developer-x’s picture

StatusFileSize
new17.4 KB

This version is compatible with bookingsapi - 6.x-3.x-dev / 2010-Jul-09

developer-x’s picture

StatusFileSize
new17.43 KB

ie javascript fixes

avpaderno’s picture

Status: Needs review » Needs work

The points reported here are not ordered by importance / relevance. This is not a complete review; there could be code that needs to be changed that has not reported here.

  1.   drupal_install_schema('eventbookings');
      db_add_index($ret, 'eventbookings_node_record', 'nid_record_id', array('nid', 'record_id'));
      menu_rebuild();
    

    Indexes must be included in the schema.
    The menu is rebuild when a new module is installed, or when an update function is called; there should be just a case where menu_rebuild() should be called: when you change the menu callback definitions, and the module doesn't have an update function to execute.

  2. Schema descriptions are not passed to t().
  3.     variable_del(EVENTBOOKINGS_DATE_FIELD_PREFIX . $row['type']);
        variable_del(EVENTBOOKINGS_MULTIPLE_BOOKINGS_PREFIX . $row['type']);
        variable_del(EVENTBOOKINGS_WEIGHT_PREFIX . $row['type']);
    

    Those variables are not defined in the installation file; if the file is referring to variables defined in the module file, it is better to load it with drupal_load().

  4. /**
     * Implementation of hook_variable_init().
     */
    function eventbookings_variable_init() {
    }
    

    Why is that hook defined in the installation file? It doesn't seem a hook used by Drupal core module.

  5. See http://drupal.org/coding-standards to understand how a module should be written. In particular, see how functions, constants, global variables defined from the module should be named; see how the code should be formatted.
  6.     $date_field = variable_get(EVENTBOOKINGS_DATE_FIELD_PREFIX . $node->type, '');
      
        // TODO : Handle this better
        if ($date_field == '') {
          return $form; // shouldn't happen
        }
    

    When a module is installed, and its settings form has not been visited, the module doesn't have any Drupal variables saved in the database; the code I reported is causing the code to exit without doing anything, in such cases. variable_get() uses the second value as default value in the case the variable is not saved in the database; the code should use a better default value.

  7.       $result = db_query(    
            'DELETE FROM '.
              '{eventbookings_node_record} ' .
            'WHERE ' .
              'record_id=%d', $data['record_id']);
    

    There is no reason to write a string as concatenation of literal strings.

  8.   if ($start_date != NULL //...) {
        // ...
      }
    

    Drupal modules should not even cause a PHP warning; accessing a not initialized variable causes a PHP warning.

  9. function eventbookings_submit(&$form, &$form_state) {
      
      // Don't store if ahah - will cause memory leaks since this is freed in the
      // nodeapi hook
      if (!isset($form_state['#is_ahah']) || $form_state['#is_ahah'] != TRUE) {
        $form_state['values']['eventbookings_pending'] = array();
        $form_state['values']['eventbookings_pending']['form'] = $form;
        $form_state['values']['eventbookings_pending']['form_state'] = $form_state;
      }
    }
    
    function eventbookings_nodeapi(&$node, $op) {
     switch ($op) {
        case 'insert' :
        case 'update' :
          if (isset($node->eventbookings_pending)) {
            
            // Restore the form and form_state passed from the submit
            $form = $node->eventbookings_pending['form'];
            $form_state = $node->eventbookings_pending['form_state'];
    }
    

    The value of $form_state passed to a submission handler used by an implementation of hook_form_alter() doesn't end in $node->eventbookings_pending['form_state']. There is just a way, to add fields to a node.

  10. function eventbookings_bookings_by_nid($nid) {
      $result = db_query(
        'SELECT ' .
          'br.record_id, br.resource_id, br.type, br.status ' .
        'FROM ' .
          '{eventbookings_node_record} enr inner join '.
          '{bookings_records} br on br.record_id=enr.record_id '.
        'WHERE ' .
          'enr.nid=%d', $nid);
      return $result;
    }
    

    Reserved SQL words must be written in uppercase characters.

  11. function eventbookings_GMT_to_local($date) {
      return eventbookings_convert_timezone($date, 'UTC', date_default_timezone_name(FALSE));
    }
    

    function names used in Drupal don't use uppercase characters.

  12.     $prev_state = (isset($_POST['eventbookings_state'])) ? unserialize($_POST['eventbookings_state']) : array();
    

    Normally, functions don't need to use $_POST.

  13.           '#options' =>  ($is_availability) ? array(BOOKINGSAPI_UNAVAILABLE => 'Unavailable', BOOKINGSAPI_AVAILABLE => 'Available') : bookingsapi_record_status(),
    

    $is_available?

  14.   include_once 'modules/node/node.pages.inc';
    

    There is a Drupal function to call in these cases.

developer-x’s picture

Thank you - I'll review and submit another version with the needed changes

Chris Sloan’s picture

I can't figure out how to define a resource; I've looked everywhere.

developer-x’s picture

To create a bookable resource (like a meeting, projector, shared van, etc..), do the following:

  1. Content Management > Create Content > Bookings API Resource
  2. Leave "Parent:" as-is
  3. Give it a title, and Default Availability (if it's set to Unavailable, you won't be able to book this resource without defining a specific availability for this resource).
  4. Hit Save

Hope that helps

scoobie’s picture

The way this is implemented will leave a blank help line on the pages that have no help. Also a typo on closing p tag.


/**
 * Implementation of hook_help().
 */
function eventbookings_help($path, $arg) {
  $helptext = '<p>';
  switch ($path) {
    case 'admin/settings/eventbookings':
      $helptext .= t('Enable Content Types so that a User can book resources. ');
      break;
  }
  $helptext .= '<p>';
  return $helptext;
}

Suggest change to :
function eventbookings_help($path, $arg) {
  switch ($path) {
    case 'admin/settings/eventbookings':
      $helptext = '<p>' . t('Enable Content Types so that a User can book resources. ') . '</p>';
      break;
  }
  return $helptext;
}

developer-x’s picture

*blush* - good catch, thanks!

developer-x’s picture

StatusFileSize
new17.39 KB

Here is an updated version, I made most of the recommended changes. My comments are as follows :

1. The index is defined now as part of the schema and I've removed the call to menu_reguild
2. Removed the t() calls in the schema descriptions.
3. Add call to drupal_load to load the constant definitions
4. Removed call eventbookings_variable_init
5. I've tried to conform to the coding standards - the coder module indicates no problems - but this is my first module, so I might have missed something. If there is something specific - let me know - I appreciated the education :-)
6. Changed the default value to "_undefined_" - but the default value should never be returned - if it hasn't been set, then that leg of code will not driven.
7. I've seen concat of literal strings in various modules similar to mine, and in the documentation for SQL indention, http://drupal.org/node/2497, they concat literal strings. I'll change it, but doesn't seem like I'm violating any standard by doing so.
8. Those variables will always be initialized in the previous call to _eventbookings_parse_date_value - so calling isset seems unecesarry
9. I don't fully understand this comment - could you elaborate?
10. Fixed the lower case reserved words
11. Changed GMT to gmt
12. This value is only accessible by referencing $_POST since it isn't defined within the form structure.
13. $is_availability refers to whether the node defines an event or an "availability" record (that defines a period of availability for a resource)
14. This was taken from the drupal documentation - http://drupal.org/node/331941 - if this is an error, the documentation should be fixed. However, it appears that it isn't needed, so I removed it.

I also made the fixed as mentioned in #33

Thanks.

webchick’s picture

Status: Needs work » Fixed

I reviewed the code in #35 (didn't test it, since I don't use bookingsapi and the code seems like it was already tested pretty extensively by dogboy72 above), and can confirm that the majority of kiamlaluno's suggestions have been implemented. There are still some outstanding feedback items, and I also ran across some additional nit-picky things around comment/PHPDoc conformance and so on, but I see nothing here that can't be fixed via the normal route of filing minor bug reports from here out. This module is clearly useful and something we don't have already, or else several people wouldn't have seeked it out in the middle of a CVS application to test it.

IMO, developer-x has clearly shown due diligence here of taking feedback on his module seriously, both in responding promptly to requests for bug fixes / improvements and even writing an entire fricking tutorial for how to use his module (!) to aid in testing. I think he will make a great Drupal code contributor.

CVS account granted. Welcome to the team! :)

sun’s picture

Thanks, webchick, for taking the extra time to handle this application! We love you. :)

developer-x’s picture

Webchick,

You do indeed rock! Thanks so much for approving this!

- x

Status: Fixed » Closed (fixed)
Issue tags: -Module review

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Issue summary: View changes
avpaderno’s picture

Status: Closed (fixed) » Fixed

I am giving credits to the users who participated in this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.