Drupal uc_hotel: Who's coming today?

Environment: Drupal 6x, Ubercart, uc_module

Use case: Give admin info about arrival per day basis.

We have our hotel website running on Drupal 6x with ubercart and uc_hotel .
We receive reservation and we have rooms with calendar exposing available day on green, reserved days on red, etc.
Here's what our calendar looks like:
uc_hotel Calendar without link to order
This is veryusefull, anyway we are not able to see who 's arrive next at out hotel.

If you want to run an hotel painless, you really can't do without knowing is next arrivals.
For this we are going to add a link to order inside reserved cells.

  • a). Paste this function inside your custom module, or theme template.php
    function customplace_who_is_coming_today ($node , $isodate ) {
    global $user ;
    $output ='';
    if ($user ->uid > 0 ) {
    $sql = "SELECT order_id FROM uc_order_products WHERE data LIKE '%". $isodate ."%' AND model = '". $node->model ."' ;";
    $result = db_query($sql);
    $order_id = '';
    while ($row = db_fetch_object($result)) {
    $order_id = $row->order_id;
    if ($order_id > 0) {
    $relative_order = l($order_id, '/admin/store/orders/' . $order_id, Array ( 'attributes' => Array ('title' => 'Ordine N. ' . $order_id )) ) ;
    $output = "
    [" . $relative_order . "]

    " ;
    return $output ;

  • b). Past this at the begin of your hotel_booking_calendar_cell.tpl.php
    $node = node_load ($nid);
    $who_is_coming_today = uc_bbsavoia_who_is_coming_today ($node, substr ($calendar_dt, 0, 10) );
  • c). paste this before "print $day;"
    print $who_is_coming_today ;

Can we now give a look at the calendar, where we will find a nice link to order received for each reserved day.
Much better, I'd say.
uc_hotel Calendar without link to order
Final notes

  • 1.) uc_hotel data structure does not clearly stores reference to order per day basis, that's way we don't have a better solution than search within the serialized data (not a best pratice of course).
  • 2.) Code on fagioli.biz is licensed under the GNU General Public License, version 2 or later. Inclusion in uc_hotel code module is welcome


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Overbooking Improvment

We can use

function mymodule_who_is_coming_today ($node , $isodate ) {
global $user ;

$output ='';
if ($user ->uid > 0 ) {
$sql = "SELECT uop.order_id , uo.order_s