uc_stock.views.inc 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. /**
  3. * @file
  4. * Views hooks and callback registries.
  5. */
  6. /**
  7. * Implements hook_views_data().
  8. */
  9. function uc_stock_views_data() {
  10. $data['uc_product_stock']['table']['group'] = t('Stock');
  11. // Attach stock data to nodes.
  12. $data['uc_product_stock']['table']['join']['node'] = array(
  13. 'left_field' => 'nid',
  14. 'field' => 'nid',
  15. );
  16. $data['uc_product_stock']['sku'] = array(
  17. 'title' => t('SKU'),
  18. 'help' => t('The model or SKU of the stock level.'),
  19. 'field' => array(
  20. 'click sortable' => TRUE,
  21. ),
  22. 'filter' => array(
  23. 'handler' => 'views_handler_filter_string',
  24. ),
  25. 'sort' => array(
  26. 'handler' => 'views_handler_sort',
  27. ),
  28. 'argument' => array(
  29. 'handler' => 'views_handler_argument_string',
  30. ),
  31. );
  32. $data['uc_product_stock']['active'] = array(
  33. 'title' => t('Active'),
  34. 'help' => t('Whether or not stock is currently being tracked.'),
  35. 'field' => array(
  36. 'handler' => 'views_handler_field_boolean',
  37. 'click sortable' => TRUE,
  38. ),
  39. 'filter' => array(
  40. 'handler' => 'views_handler_filter_boolean_operator',
  41. 'label' => t('Active'),
  42. 'type' => 'yes-no',
  43. ),
  44. 'sort' => array(
  45. 'handler' => 'views_handler_sort',
  46. ),
  47. );
  48. $data['uc_product_stock']['stock'] = array(
  49. 'title' => t('Level'),
  50. 'help' => t('The current stock level.'),
  51. 'field' => array(
  52. 'handler' => 'views_handler_field_numeric',
  53. 'click sortable' => TRUE,
  54. ),
  55. 'filter' => array(
  56. 'handler' => 'views_handler_filter_numeric',
  57. ),
  58. 'sort' => array(
  59. 'handler' => 'views_handler_sort',
  60. ),
  61. );
  62. $data['uc_product_stock']['threshold'] = array(
  63. 'title' => t('Threshold'),
  64. 'help' => t('The level at which a stock warning can be sent.'),
  65. 'field' => array(
  66. 'handler' => 'views_handler_field_numeric',
  67. 'click sortable' => TRUE,
  68. ),
  69. 'filter' => array(
  70. 'handler' => 'views_handler_filter_numeric',
  71. ),
  72. 'sort' => array(
  73. 'handler' => 'views_handler_sort',
  74. ),
  75. );
  76. $data['uc_product_stock']['below_threshold'] = array(
  77. 'title' => t('Is below threshold'),
  78. 'help' => t('Filter the node based on whether its stock level is below the threshold for the SKU.'),
  79. 'filter' => array(
  80. 'handler' => 'uc_stock_handler_filter_below_threshold',
  81. 'label' => t('Is below threshold'),
  82. 'type' => 'yes-no',
  83. ),
  84. );
  85. return $data;
  86. }