views:

17

answers:

0

I have been trying for awhile now to get the my view to accept a date argument. This is my code:

<?php

function bookable_views_handlers(){ return array( 'info' => array( 'path' => drupal_get_path('module', 'bookable') . '/includes', ), 'handlers' => array( 'views_handler_field_date' => array( 'parent' => 'views_handler_field', ), ), 'handlers' => array( 'views_handler_argument_date' => array( 'parent' => 'views_handler_argument_formula', ), ),

);

} function bookable_views_data(){

$data['bookable']['table']['group'] = t('Bookable Table');

$data['bookable']['table']['base'] = array(
    'field' => 'bid',
    'title' => t('Bookable Table'),
    'help' => t('This table contains booking information'),
    'weight' => -10,
);

$data['bookable']['table']['join'] = array(
    'node' => array(
        'left_field' => 'nid',
        'field' => 'nid',
    ),
);

//NID - FK
$data['bookable']['nid'] = array(
    'title' => t('Booking Node ID'),
    'help' => t('Node id of the node being booked'), 
    'relationship' => array(
        'base' => 'node',
        'field' => 'nid',
        'handler' => 'views_handler_relationship',
        'label' => t('Booking Node'),
    ),


);

//Room
$data['bookable']['room'] = array(
    'title' => t('Room'),

    'help' => t('Room the node will be used in'), 

    'field' => array(
        'handler' => 'views_handler_field',
        'click sortable' => TRUE,
        ),

    'sort' => array(
        'handler' => 'views_handler_sort',
        ),

    'filter' => array(
        'handler' => 'views_handler_filter_string', 
        ),

    /*'argument' => array(
        'handler' => 'views_handler_argument_string',
        ),*/
    );

//UID
$data['bookable']['uid'] = array(
    'title' => t('User ID'), 
    'help' => t('The ID of the user booking the resource'),
    'field' => array(
        'handler' => 'views_handler_field_numeric',
        'click sortable' => TRUE, 
    ),
    'filter' => array(
        'handler' => 'views_handler_filter_numeric',
    ),

    'sort' => array(
        'handler' => 'views_handler_sort',
    ),
    'argument' => array(
        'handler' => 'views_handler_argument_numeric',
        ),


);

//BID
$data['bookable']['bid'] = array(
    'title' => t('Booking ID'), 
    'help' => t('ID of booking '),
    'field' => array(
        'handler' => 'views_handler_field_numeric',
        'click sortable' => TRUE, 
    ),
    'filter' => array(
        'handler' => 'views_handler_filter_numeric',
    ),

    'sort' => array(
        'handler' => 'views_handler_sort',
    ),

);
//FROMDATE
$data['bookable']['from_date'] = array(
    'title' => t('From Date of booking '), 
    'help' => t('The From Date of the booking '),
    'field' => array(
        'handler' => 'views_handler_field_date',
        'click sortable' => TRUE, 
    ),                                                          
    'filter' => array(
        'handler' => 'views_handler_filter_date',
    ),

    'sort' => array(
        'handler' => 'views_handler_sort',
    ),
    'argument' => array(
        'handler' => 'views_handler_argument_date',
        ),

);
//TODATE
$data['bookable']['to_date'] = array(
    'title' => t('To Date of booking '), 
    'help' => t('The To Date of the booking '),
    'field' => array(
        'handler' => 'views_handler_field_date',
        'click sortable' => TRUE, 
    ),
    'filter' => array(
        'handler' => 'views_handler_filter_date',
    ),

    'sort' => array(
        'handler' => 'views_handler_sort',
    ),

);

return $data;
}

And this is sql query generated by the view: SELECT bookable.bid AS bid, bookable.from_date AS bookable_from_date, bookable.to_date AS bookable_to_date, bookable.room AS bookable_room, bookable.uid AS bookable_uid FROM bookable bookable WHERE = '2010-06-21'

I am confused why the appropriate field isn't coming up in the where clause and why does bookable appear twice after the FROM. The configurations have been done using the views UI.