You are here

function uc_stock_views_data in Ubercart 6.2

Same name and namespace in other branches
  1. 8.4 uc_stock/uc_stock.views.inc \uc_stock_views_data()
  2. 7.3 uc_stock/views/uc_stock.views.inc \uc_stock_views_data()

Implements hook_views_data().

File

uc_stock/views/uc_stock.views.inc, line 11
Views 2 hooks and callback registries.

Code

function uc_stock_views_data() {
  $data['uc_product_stock']['table']['group'] = t('Stock');
  $data['uc_product_stock']['table']['join'] = array(
    'node' => array(
      'left_field' => 'nid',
      'field' => 'nid',
    ),
  );
  $data['uc_product_stock']['sku'] = array(
    'title' => t('SKU'),
    'help' => t('The model or SKU of the stock level'),
    'field' => array(
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_string',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
    'argument' => array(
      'handler' => 'views_handler_argument_string',
    ),
  );
  $data['uc_product_stock']['active'] = array(
    'title' => t('Active'),
    'help' => t('Whether or not the stock level is currently being tracked'),
    'field' => array(
      'handler' => 'views_handler_field_boolean',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_boolean_operator',
      'label' => t('Active'),
      'type' => 'yes-no',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['uc_product_stock']['stock'] = array(
    'title' => t('Stock Level'),
    'help' => t('The current stock level'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['uc_product_stock']['threshold'] = array(
    'title' => t('Threshold'),
    'help' => t('The threshold or warning limit of the stock level'),
    'field' => array(
      'handler' => 'views_handler_field_numeric',
      'click sortable' => TRUE,
    ),
    'filter' => array(
      'handler' => 'views_handler_filter_numeric',
    ),
    'sort' => array(
      'handler' => 'views_handler_sort',
    ),
  );
  $data['uc_product_stock']['below_threshold'] = array(
    'title' => t('Is Below Threshold'),
    'help' => t('Filter the node based on whether its stock level is below the threshold for the SKU.'),
    'filter' => array(
      'handler' => 'uc_stock_views_handler_filter_below_threshold',
      'label' => t('Is Below Threshold'),
      'type' => 'yes-no',
    ),
  );
  return $data;
}