Fix for Fix for UC_Views

  1. <?PHP //within uc.views.module
  2.  
  3. /**
  4.  * Implementation of hook_date_api_fields().
  5.  * on behalf of core fields.
  6.  *
  7.  * All modules that create custom fields that use the
  8.  * 'views_handler_field_date' handler can provide
  9.  * additional information here about the type of
  10.  * date they create so the date can be used by
  11.  * the Date API views date argument and date filter.
  12.  *
  13.  * Thank you justindodge for this!
  14.  */
  15. function uc_views_date_api_fields($field) {
  16.   $values = array(
  17.     // The type of date: DATE_UNIX, DATE_ISO, DATE_DATETIME.
  18.     'sql_type' => DATE_UNIX,
  19.     // Timezone handling options: 'none', 'site', 'date', 'utc'.
  20.     'tz_handling' => 'site',
  21.     // Needed only for dates that use 'date' tz_handling.
  22.     'timezone_field' => '',
  23.     // Needed only for dates that use 'date' tz_handling.
  24.     'offset_field' => '',
  25.     // Array of "table.field" values for related fields that should be
  26.     // loaded automatically in the Views SQL.
  27.     'related_fields' => array(),
  28.     // Granularity of this date field's db data.
  29.     'granularity' => array('year', 'month', 'day', 'hour', 'minute', 'second'),
  30.   );
  31.   return $values;
  32. }
  33. ?>
  34.  
  35. <?PHP //within uc_views.views.inc
  36.   // Add shipping details to uc_views
  37.   $data['uc_shipments']['table']['group'] = t('Ubercart shipment');
  38.   $data['uc_shipments']['table']['join']['uc_orders'] = array(
  39.     'left_field' => 'order_id',
  40.     'field' => 'order_id',
  41.   );
  42.   $data['uc_shipments']['carrier'] = array(
  43.     'title' => t('Shipping Carrier Title'),
  44.     'help' => t('The shipping carrier used.'),
  45.     'field' => array(
  46.       'handler' => 'views_handler_field',
  47.       'click sortable' => TRUE,
  48.     ),
  49.   );
  50.   $data['uc_shipments']['cost'] = array(
  51.     'title' => t('Shipping Cost Amount'),
  52.     'help' => t('The shipping actual cost.'),
  53.     'field' => array(
  54.       'handler' => 'uc_views_handler_field_money_amount',
  55.       'click sortable' => TRUE,
  56.     ),
  57.   );
  58.   $data['uc_shipments']['ship_date'] = array(
  59.     'title' => t('Order Ship Date'),
  60.     'help' => t('The shipment date.'),
  61.     'field' => array(
  62.       'handler' => 'views_handler_field_date',
  63.       'click sortable' => TRUE,
  64.     ),
  65.      'sort' => array(
  66.       'handler' => 'views_handler_sort_date',
  67.     ),
  68.     'filter' => array(
  69.       'handler' => 'views_handler_filter_date',
  70.     ),
  71.   );
  72.   //if the sexy date module is installed use that for filtering
  73.   if(module_exists('date_api')) {
  74.     $data['uc_shipments']['ship_date']['filter']['handler'] = 'date_api_filter_handler';
  75.   }
  76. ?>

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.