FINAL suepr merge step : added all modules to this super repos
This commit is contained in:
@@ -0,0 +1,468 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views 2 hooks and callback registries.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_data().
|
||||
*/
|
||||
function uc_coupon_views_data() {
|
||||
$data['uc_coupons']['table']['group'] = t('Coupon');
|
||||
|
||||
$data['uc_coupons']['table']['base'] = array(
|
||||
'field' => 'cid',
|
||||
'title' => t('Coupon'),
|
||||
'help' => t("Ubercart discount coupons."),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['cid'] = array(
|
||||
'title' => t('ID'),
|
||||
'help' => t('The unique ID of the coupon.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['name'] = array(
|
||||
'title' => t('Name'),
|
||||
'help' => t('The name of the coupon.'),
|
||||
'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',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['code'] = array(
|
||||
'title' => t('Code'),
|
||||
'help' => t('The coupon code, or prefix for bulk coupons.'),
|
||||
'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',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['bulk_codes'] = array(
|
||||
'title' => t('Codes'),
|
||||
'help' => t('All codes associated with this coupon.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_codes',
|
||||
'field' => 'cid',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['bulk'] = array(
|
||||
'title' => t('Bulk'),
|
||||
'help' => t('Whether the coupon is a bulk coupon with multiple suffixes.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_boolean',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_boolean_operator',
|
||||
'label' => t('Is a bulk coupon'),
|
||||
'type' => 'yes-no',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['created'] = array(
|
||||
'title' => t('Creation date'),
|
||||
'help' => t('The date the coupon was created.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['valid_from'] = array(
|
||||
'title' => t('Valid from'),
|
||||
'help' => t('The date the coupon becomes valid.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['valid_until'] = array(
|
||||
'title' => t('Valid until'),
|
||||
'help' => t('The date the coupon expires.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_date',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort_date',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_date',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['status'] = array(
|
||||
'title' => 'Active',
|
||||
'help' => t('Whether the coupon is available to use.'),
|
||||
'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_coupons']['type'] = array(
|
||||
'title' => 'Type',
|
||||
'help' => t('The discount type of the coupon.'),
|
||||
'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',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['value'] = array(
|
||||
'title' => t('Value'),
|
||||
'help' => t('The value of the coupon.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_value',
|
||||
'click sortable' => TRUE,
|
||||
'float' => TRUE,
|
||||
'additional fields' => array(
|
||||
'type' => 'type',
|
||||
),
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['minimum_order'] = array(
|
||||
'title' => t('Minimum order total'),
|
||||
'help' => t('The minimum order total that applies to the coupon.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field_numeric',
|
||||
'click sortable' => TRUE,
|
||||
'float' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['max_uses'] = array(
|
||||
'title' => t('Max uses per code'),
|
||||
'help' => t('The maximum number of times this coupon can be redeemed.'),
|
||||
'field' => array(
|
||||
'handler' => 'views_handler_field',
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_numeric',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_numeric',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['actions'] = array(
|
||||
'title' => t('Actions'),
|
||||
'help' => t('A set of actions the current user can perform on the coupon.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_actions',
|
||||
'field' => 'cid',
|
||||
'additional fields' => array(
|
||||
'name' => 'name',
|
||||
'bulk' => 'bulk',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['product_type'] = array(
|
||||
'title' => t('Product classes'),
|
||||
'help' => t('Product classes for which this coupon is valid.'),
|
||||
'field' => array(
|
||||
'field' => 'cid',
|
||||
'handler' => 'uc_coupon_handler_field_product_type',
|
||||
'label' => t('Product types'),
|
||||
'additional fields' => array(
|
||||
'data' => 'data',
|
||||
),
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'uc_coupon_handler_filter_product_type',
|
||||
'label' => 'Is a product type',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'uc_coupon_handler_argument_product_type',
|
||||
'label' => 'Is a product type',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['bulk_number'] = array(
|
||||
'title' => t('Bulk number'),
|
||||
'help' => t('Number of bulk codes based on this coupon.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_bulk_number',
|
||||
'field' => 'data',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['all_orders_count'] = array(
|
||||
'title' => t('All orders count'),
|
||||
'help' => t('The number of orders to which this coupon was applied.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_all_orders_count',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['table']['join']['uc_orders'] = array(
|
||||
'left_table' => 'uc_coupons_orders',
|
||||
'left_field' => 'oid',
|
||||
'field' => 'order_id',
|
||||
);
|
||||
|
||||
$data['uc_coupons']['all_orders_total'] = array(
|
||||
'title' => t('All orders total'),
|
||||
'help' => t('The total bottom-line for all orders to which this coupon was applied.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_all_orders_total',
|
||||
'float' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['all_orders_value'] = array(
|
||||
'title' => t('All orders total value'),
|
||||
'help' => t('The total value of this coupon for all orders to which it was applied.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_all_orders_value',
|
||||
'float' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons']['all_orders_gross'] = array(
|
||||
'title' => t('All orders gross total'),
|
||||
'help' => t('The pre-discount total for all orders to which this coupon was applied.'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_all_orders_gross',
|
||||
'float' => TRUE,
|
||||
),
|
||||
);
|
||||
|
||||
//
|
||||
// Table: uc_coupons_orders
|
||||
//
|
||||
$data['uc_coupons_orders']['table']['group'] = t('Coupon order');
|
||||
$data['uc_coupons_orders']['table']['join']['uc_coupons'] = array(
|
||||
'left_field' => 'cid',
|
||||
'field' => 'cid',
|
||||
);
|
||||
|
||||
// Join to the uc_orders table.
|
||||
$data['uc_coupons_orders']['table']['join']['uc_orders'] = array(
|
||||
'left_field' => 'order_id',
|
||||
'field' => 'oid',
|
||||
);
|
||||
|
||||
$data['uc_orders']['table']['join']['uc_coupons'] = array(
|
||||
'left_table' => 'uc_coupons_orders',
|
||||
'left_field' => 'oid',
|
||||
'field' => 'order_id',
|
||||
);
|
||||
|
||||
$data['uc_coupons_orders']['code'] = array(
|
||||
'title' => t('Code'),
|
||||
'help' => t('The coupon code used for this order'),
|
||||
'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',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons_orders']['value'] = array(
|
||||
'title' => t('Value'),
|
||||
'help' => t('The value of the coupon used for this order'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_order_handler_field_money_amount',
|
||||
'click sortable' => TRUE,
|
||||
'float' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'argument' => array(
|
||||
'handler' => 'views_handler_argument_string',
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons_orders']['gross'] = array(
|
||||
'title' => t('Gross'),
|
||||
'help' => t('The pre-discount bottom-line for this order'),
|
||||
'field' => array(
|
||||
'handler' => 'uc_coupon_handler_field_gross',
|
||||
'float' => TRUE,
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'uc_coupon_handler_filter_gross'
|
||||
),
|
||||
);
|
||||
|
||||
$data['uc_coupons_orders']['oid'] = array(
|
||||
'title' => t('Order ID'),
|
||||
'help' => t('The order ID of this coupon order'),
|
||||
'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',
|
||||
),
|
||||
);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_views_handlers().
|
||||
*/
|
||||
function uc_coupon_views_handlers() {
|
||||
return array(
|
||||
'info' => array(
|
||||
'path' => drupal_get_path('module', 'uc_coupon') . '/views',
|
||||
),
|
||||
'handlers' => array(
|
||||
'uc_coupon_handler_field_value' => array(
|
||||
'parent' => 'views_handler_field_numeric',
|
||||
),
|
||||
'uc_coupon_handler_field_actions' => array(
|
||||
'parent' => 'views_handler_field',
|
||||
),
|
||||
'uc_coupon_handler_field_bulk_number' => array(
|
||||
'parent' => 'views_handler_field_numeric',
|
||||
),
|
||||
'uc_coupon_handler_field_codes' => array(
|
||||
'parent' => 'views_handler_field_prerender_list',
|
||||
),
|
||||
'uc_coupon_handler_filter_product_type' => array(
|
||||
'parent' => 'views_handler_filter_in_operator',
|
||||
),
|
||||
'uc_coupon_handler_argument_product_type' => array(
|
||||
'parent' => 'views_handler_argument',
|
||||
),
|
||||
'uc_coupon_handler_field_product_type' => array(
|
||||
'parent' => 'views_handler_field_prerender_list',
|
||||
),
|
||||
'uc_coupon_handler_field_all_orders_count' => array(
|
||||
'parent' => 'views_handler_field_numeric',
|
||||
),
|
||||
'uc_coupon_handler_field_all_orders_total' => array(
|
||||
'parent' => 'uc_order_handler_field_money_amount',
|
||||
),
|
||||
'uc_coupon_handler_field_all_orders_value' => array(
|
||||
'parent' => 'uc_coupon_handler_field_all_orders_total',
|
||||
),
|
||||
'uc_coupon_handler_field_all_orders_gross' => array(
|
||||
'parent' => 'uc_coupon_handler_field_all_orders_total',
|
||||
),
|
||||
'uc_coupon_handler_field_gross' => array(
|
||||
'parent' => 'uc_order_handler_field_money_amount',
|
||||
),
|
||||
'uc_coupon_handler_filter_gross' => array(
|
||||
'parent' => 'views_handler_filter_numeric',
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
@@ -0,0 +1,281 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Default views for uc_coupon.
|
||||
*/
|
||||
/**
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function uc_coupon_views_default_views() {
|
||||
$view = new view;
|
||||
$view->name = 'uc_coupon';
|
||||
$view->description = 'Ubercart discount coupons.';
|
||||
$view->tag = 'Ubercart';
|
||||
$view->view_php = '';
|
||||
$view->base_table = 'uc_coupons';
|
||||
$view->is_cacheable = FALSE;
|
||||
$view->api_version = 2;
|
||||
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
|
||||
$handler = $view->new_display('default', 'Defaults', 'default');
|
||||
$handler->override_option('fields', array(
|
||||
'actions' => array(
|
||||
'label' => 'Actions',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 0,
|
||||
'path' => '',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'exclude' => 0,
|
||||
'id' => 'actions',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'actions',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'id' => 'name',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'name',
|
||||
),
|
||||
'code' => array(
|
||||
'id' => 'code',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'code',
|
||||
),
|
||||
'bulk' => array(
|
||||
'label' => 'Bulk',
|
||||
'alter' => array(
|
||||
'alter_text' => 0,
|
||||
'text' => '',
|
||||
'make_link' => 0,
|
||||
'path' => '',
|
||||
'link_class' => '',
|
||||
'alt' => '',
|
||||
'prefix' => '',
|
||||
'suffix' => '',
|
||||
'target' => '',
|
||||
'help' => '',
|
||||
'trim' => 0,
|
||||
'max_length' => '',
|
||||
'word_boundary' => 1,
|
||||
'ellipsis' => 1,
|
||||
'html' => 0,
|
||||
'strip_tags' => 0,
|
||||
),
|
||||
'empty' => '',
|
||||
'hide_empty' => 0,
|
||||
'empty_zero' => 0,
|
||||
'type' => 'yes-no',
|
||||
'not' => 0,
|
||||
'exclude' => 0,
|
||||
'id' => 'bulk',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'bulk',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'value' => array(
|
||||
'id' => 'value',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'value',
|
||||
),
|
||||
'created' => array(
|
||||
'id' => 'created',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'created',
|
||||
),
|
||||
'valid_from' => array(
|
||||
'id' => 'valid_from',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'valid_from',
|
||||
),
|
||||
'valid_until' => array(
|
||||
'id' => 'valid_until',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'valid_until',
|
||||
),
|
||||
));
|
||||
$handler->override_option('filters', array(
|
||||
'status' => array(
|
||||
'operator' => '=',
|
||||
'value' => '1',
|
||||
'group' => '0',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'operator' => '',
|
||||
'identifier' => 'status',
|
||||
'label' => 'Active',
|
||||
'optional' => 1,
|
||||
'remember' => 1,
|
||||
),
|
||||
'id' => 'status',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'status',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'bulk' => array(
|
||||
'operator' => '=',
|
||||
'value' => 'All',
|
||||
'group' => '0',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'operator' => '',
|
||||
'identifier' => 'bulk',
|
||||
'label' => 'Bulk',
|
||||
'optional' => 1,
|
||||
'remember' => 0,
|
||||
),
|
||||
'id' => 'bulk',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'bulk',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'code' => array(
|
||||
'operator' => '=',
|
||||
'value' => '',
|
||||
'group' => '0',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'use_operator' => 1,
|
||||
'operator' => 'code_op',
|
||||
'identifier' => 'code',
|
||||
'label' => 'Code',
|
||||
'optional' => 1,
|
||||
'remember' => 0,
|
||||
),
|
||||
'case' => 0,
|
||||
'id' => 'code',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'code',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'name' => array(
|
||||
'operator' => '=',
|
||||
'value' => '',
|
||||
'group' => '0',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'use_operator' => 1,
|
||||
'operator' => 'name_op',
|
||||
'identifier' => 'name',
|
||||
'label' => 'Name',
|
||||
'optional' => 1,
|
||||
'remember' => 0,
|
||||
),
|
||||
'case' => 1,
|
||||
'id' => 'name',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'name',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
'value' => array(
|
||||
'operator' => 'between',
|
||||
'value' => array(
|
||||
'value' => '',
|
||||
'min' => '',
|
||||
'max' => '',
|
||||
),
|
||||
'group' => '0',
|
||||
'exposed' => TRUE,
|
||||
'expose' => array(
|
||||
'use_operator' => 1,
|
||||
'operator' => 'coupon_value_op',
|
||||
'identifier' => 'coupon_value',
|
||||
'label' => 'Value',
|
||||
'optional' => 1,
|
||||
'remember' => 0,
|
||||
),
|
||||
'id' => 'value',
|
||||
'table' => 'uc_coupons',
|
||||
'field' => 'value',
|
||||
'relationship' => 'none',
|
||||
),
|
||||
));
|
||||
$handler->override_option('access', array(
|
||||
'type' => 'perm',
|
||||
'perm' => 'view store coupons',
|
||||
));
|
||||
$handler->override_option('cache', array(
|
||||
'type' => 'none',
|
||||
));
|
||||
$handler->override_option('title', 'Coupons');
|
||||
$handler->override_option('empty', 'No matching coupons found.');
|
||||
$handler->override_option('empty_format', '1');
|
||||
$handler->override_option('items_per_page', 20);
|
||||
$handler->override_option('use_pager', '1');
|
||||
$handler->override_option('style_plugin', 'table');
|
||||
$handler->override_option('style_options', array(
|
||||
'grouping' => '',
|
||||
'override' => 1,
|
||||
'sticky' => 0,
|
||||
'order' => 'asc',
|
||||
'columns' => array(
|
||||
'name' => 'name',
|
||||
'code' => 'code',
|
||||
'value' => 'value',
|
||||
'created' => 'created',
|
||||
'valid_from' => 'valid_from',
|
||||
'valid_until' => 'valid_until',
|
||||
),
|
||||
'info' => array(
|
||||
'name' => array(
|
||||
'sortable' => 0,
|
||||
'separator' => '',
|
||||
),
|
||||
'code' => array(
|
||||
'sortable' => 0,
|
||||
'separator' => '',
|
||||
),
|
||||
'value' => array(
|
||||
'sortable' => 0,
|
||||
'separator' => '',
|
||||
),
|
||||
'created' => array(
|
||||
'sortable' => 0,
|
||||
'separator' => '',
|
||||
),
|
||||
'valid_from' => array(
|
||||
'sortable' => 0,
|
||||
'separator' => '',
|
||||
),
|
||||
'valid_until' => array(
|
||||
'sortable' => 0,
|
||||
'separator' => '',
|
||||
),
|
||||
),
|
||||
'default' => 'code',
|
||||
));
|
||||
$handler = $view->new_display('page', 'Page', 'page_1');
|
||||
$handler->override_option('path', 'coupons');
|
||||
$handler->override_option('menu', array(
|
||||
'type' => 'none',
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
'weight' => 0,
|
||||
'name' => 'navigation',
|
||||
));
|
||||
$handler->override_option('tab_options', array(
|
||||
'type' => 'none',
|
||||
'title' => '',
|
||||
'description' => '',
|
||||
'weight' => 0,
|
||||
'name' => 'navigation',
|
||||
));
|
||||
$views[$view->name] = $view;
|
||||
|
||||
return $views;
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Views handler: Coupon filter on "product-type".
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filter coupons based on what product types they apply to
|
||||
*/
|
||||
class uc_coupon_handler_argument_product_type extends views_handler_argument {
|
||||
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$this->query->add_field('uc_coupons', 'data');
|
||||
if (!empty($this->argument)) {
|
||||
$regexp = '.*product_types.*{[^}]*(' . $this->argument . ').*}';
|
||||
$this->query->add_where_expression(0,
|
||||
'uc_coupons.data ' . 'REGEXP :re',
|
||||
array(':re' => $regexp)
|
||||
);
|
||||
}
|
||||
//. ($this->options['operator'] !== 'in' ? "NOT " : "")
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views handler: Coupon actions field.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return a coupon value as price or percentage.
|
||||
*/
|
||||
class uc_coupon_handler_field_actions extends views_handler_field {
|
||||
function render($values) {
|
||||
$coupon = new stdClass;
|
||||
$coupon->cid = $values->{$this->field_alias};
|
||||
$coupon->name = $values->{$this->aliases['name']};
|
||||
$coupon->bulk = $values->{$this->aliases['bulk']};
|
||||
|
||||
return theme('uc_coupon_actions', array('coupon' => $coupon));
|
||||
}
|
||||
}
|
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Coupon order total field handler
|
||||
*/
|
||||
class uc_coupon_handler_field_all_orders_count extends views_handler_field_numeric {
|
||||
|
||||
/**
|
||||
* Add the 'cid' field
|
||||
*/
|
||||
function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['cid'] = 'cid';
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default value for order_status option.
|
||||
*/
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['statuses'] = array('default' => array());
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create order status option.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$statuses = array();
|
||||
foreach (uc_order_status_list() as $status) {
|
||||
$statuses[$status['id']] = $status['title'];
|
||||
}
|
||||
|
||||
$form['statuses'] = array(
|
||||
'#title' => t('Order statuses'),
|
||||
'#type' => 'select',
|
||||
'#description' => t('Only orders with selected statuses will be counted.
|
||||
If you do not select any statuses, then all orders will be counted.')
|
||||
. '<br />' . t('Hold Ctrl + click to select multiple statuses.'),
|
||||
'#options' => $statuses,
|
||||
'#default_value' => $this->options['statuses'],
|
||||
'#multiple' => TRUE,
|
||||
'#size' => 5,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Here we create the aggregate field that will count the orders.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$uco = $this->query->ensure_table('uc_coupons_orders');
|
||||
$uo = $this->query->ensure_table('uc_orders');
|
||||
$this->add_additional_fields();
|
||||
if (empty($this->options['statuses'])) {
|
||||
// If no status specified, then we show all.
|
||||
$in_status = "1";
|
||||
}
|
||||
else {
|
||||
// An array of statuses was specified.
|
||||
$in_status = "$uo.order_status IN('" . implode("', '", $this->options['statuses']) . "')";
|
||||
}
|
||||
$this->field_alias = $this->query->add_field(
|
||||
NULL,
|
||||
"CASE WHEN $in_status THEN 1 ELSE 0 END",
|
||||
$this->table_alias . '_' . $this->field . '_' . implode('_', $this->options['statuses']),
|
||||
array('function' => 'sum')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Coupon order total field handler
|
||||
*/
|
||||
class uc_coupon_handler_field_all_orders_gross extends uc_coupon_handler_field_all_orders_total {
|
||||
/**
|
||||
* Add the aggregate field that will sum total+value
|
||||
*
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$uco = $this->query->ensure_table('uc_coupons_orders');
|
||||
$uo = $this->query->ensure_table('uc_orders');
|
||||
$this->add_additional_fields();
|
||||
if (empty($this->options['statuses'])) {
|
||||
// If no status specified, then we show all.
|
||||
$in_status = "1";
|
||||
}
|
||||
else {
|
||||
// An array of statuses was specified.
|
||||
$in_status = "$uo.order_status IN('" . implode("', '", $this->options['statuses']) . "')";
|
||||
}
|
||||
$this->field_alias = $this->query->add_field(
|
||||
NULL,
|
||||
"CASE WHEN $in_status THEN ($uo.order_total+$uco.value) ELSE 0 END",
|
||||
$this->table_alias . '_' . $this->field . '_' . implode('_', $this->options['statuses']),
|
||||
array('function' => 'sum')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Coupon order total field handler
|
||||
*/
|
||||
class uc_coupon_handler_field_all_orders_total extends uc_order_handler_field_money_amount {
|
||||
/**
|
||||
* Add 'cid' field.
|
||||
*/
|
||||
function construct() {
|
||||
parent::construct();
|
||||
$this->additional_fields['cid'] = 'cid';
|
||||
}
|
||||
|
||||
/**
|
||||
* Define option default values.
|
||||
*/
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
$options['statuses'] = array('default' => array());
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add option for order status.
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$statuses = array();
|
||||
foreach (uc_order_status_list() as $status) {
|
||||
$statuses[$status['id']] = $status['title'];
|
||||
}
|
||||
|
||||
$form['statuses'] = array(
|
||||
'#title' => t('Order statuses'),
|
||||
'#type' => 'select',
|
||||
'#description' => t('Only orders with selected statuses will be counted.
|
||||
If you do not select any statuses, then all orders will be counted.')
|
||||
. '<br />' . t('Hold Ctrl + click to select multiple statuses.'),
|
||||
'#options' => $statuses,
|
||||
'#default_value' => $this->options['statuses'],
|
||||
'#multiple' => TRUE,
|
||||
'#size' => 8,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Here we add the aggregate field that will sum the orders.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$uco = $this->query->ensure_table('uc_coupons_orders');
|
||||
$uo = $this->query->ensure_table('uc_orders');
|
||||
$this->add_additional_fields();
|
||||
if (empty($this->options['statuses'])) {
|
||||
// If no status specified, then we show all.
|
||||
$in_status = "1";
|
||||
}
|
||||
else {
|
||||
// An array of statuses was specified.
|
||||
$in_status = "$uo.order_status IN('" . implode("', '", $this->options['statuses']) . "')";
|
||||
}
|
||||
|
||||
$this->field_alias = $this->query->add_field(
|
||||
NULL,
|
||||
"CASE WHEN $in_status THEN $uo.order_total ELSE 0 END",
|
||||
$this->table_alias . '_' . $this->field . '_' . implode('_', $this->options['statuses']),
|
||||
array('function' => 'sum')
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Coupon order total field handler
|
||||
*/
|
||||
class uc_coupon_handler_field_all_orders_value extends uc_coupon_handler_field_all_orders_total {
|
||||
/**
|
||||
* Here we add the aggregate field that will sum the value.
|
||||
*/
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$uco = $this->query->ensure_table('uc_coupons_orders');
|
||||
$uo = $this->query->ensure_table('uc_orders');
|
||||
$this->add_additional_fields();
|
||||
if (empty($this->options['statuses'])) {
|
||||
// If no status specified, then we show all.
|
||||
$in_status = "1";
|
||||
}
|
||||
else {
|
||||
// An array of statuses was specified.
|
||||
$in_status = "$uo.order_status IN('" . implode("', '", $this->options['statuses']) . "')";
|
||||
}
|
||||
$this->field_alias = $this->query->add_field(
|
||||
NULL,
|
||||
"CASE WHEN $in_status THEN $uco.value ELSE 0 END",
|
||||
$this->table_alias . '_' . $this->field . '_' . implode('_', $this->options['statuses']),
|
||||
array('function' => 'sum')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views handler: Coupon bulk number.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return number of bulk codes based on this field
|
||||
*/
|
||||
class uc_coupon_handler_field_bulk_number extends views_handler_field_numeric {
|
||||
function render($values) {
|
||||
$data = unserialize($values->{$this->field_alias});
|
||||
return $data['bulk_number'];
|
||||
}
|
||||
}
|
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Views handler for a list of bulk codes based on a coupon
|
||||
*/
|
||||
|
||||
/**
|
||||
* Generate a list of the codes associated with this coupon
|
||||
*/
|
||||
class uc_coupon_handler_field_codes extends views_handler_field_prerender_list {
|
||||
|
||||
/**
|
||||
* Define option default values.
|
||||
*/
|
||||
function option_definition() {
|
||||
$options = parent::option_definition();
|
||||
|
||||
$options['max_num'] = array('default' => 0);
|
||||
$options['scope'] = array('default' => 'all');
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provide options to limit number of codes, and to limit to coupons which still have uses remaining (or which don't)
|
||||
*/
|
||||
function options_form(&$form, &$form_state) {
|
||||
parent::options_form($form, $form_state);
|
||||
|
||||
$form['max_num'] = array(
|
||||
'#title' => t('Maximum number of codes to list (or 0 for unlimited)'),
|
||||
'#type' => 'textfield',
|
||||
'#default_value' => $this->options['max_num'],
|
||||
);
|
||||
|
||||
$form['scope'] = array(
|
||||
'#type' => 'radios',
|
||||
'#title' => t('Codes to display'),
|
||||
'#options' => array(
|
||||
'all' => t('All'),
|
||||
'avail' => t('Available codes'),
|
||||
'used' => t('Unavailable codes'),
|
||||
),
|
||||
'#default_value' => $this->options['scope'],
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Expand the coupon codes for each coupon in the result set.
|
||||
*
|
||||
* @see views_handler_field::pre_render()
|
||||
*/
|
||||
function pre_render($values) {
|
||||
foreach ($values as $value) {
|
||||
$cid = $value->{$this->field_alias};
|
||||
$coupon = uc_coupon_load($cid);
|
||||
|
||||
// Find the maximum number of codes to display.
|
||||
$limit = $coupon->bulk ? $coupon->data['bulk_number'] : 1;
|
||||
if ($this->options['max_num'] && $this->options['max_num'] < $limit) {
|
||||
$limit = $this->options['max_num'];
|
||||
}
|
||||
|
||||
$coupon->usage = uc_coupon_count_usage($cid);
|
||||
|
||||
// List selected coupons.
|
||||
for ($i = 0; $i < $limit; $i++) {
|
||||
$icoupon = $limit > 1 ? clone $coupon : $coupon;
|
||||
if ($coupon->bulk) {
|
||||
$icoupon->code = uc_coupon_get_bulk_code($coupon, $i);
|
||||
}
|
||||
|
||||
if ($this->include_coupon($icoupon)) {
|
||||
$this->items[$cid][] = array('coupon' => $icoupon);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function include_coupon($coupon) {
|
||||
if ($this->options['scope'] == 'all') {
|
||||
return TRUE;
|
||||
}
|
||||
else {
|
||||
$uses = $coupon->usage['codes'][$coupon->code];
|
||||
$unused = $coupon->max_uses == 0 || $coupon->max_uses > $uses;
|
||||
return $unused xor $this->options['scope'] == 'used';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a single coupon code.
|
||||
*/
|
||||
function render_item($count, $item) {
|
||||
return theme('uc_coupon_code', array('coupon' => $item['coupon']));
|
||||
}
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Coupon order total field handler
|
||||
*/
|
||||
class uc_coupon_handler_field_gross extends uc_views_handler_field_money_amount {
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$this->query->ensure_table('uc_orders');
|
||||
$this->field_alias = $this->query->add_field(NULL, '(uc_orders.order_total + uc_coupons_orders.value)',
|
||||
$this->table_alias .'_'. $this->field
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Views handler for coupon applicable product type
|
||||
*/
|
||||
|
||||
/**
|
||||
* List the product types applicable to this coupon
|
||||
*/
|
||||
class uc_coupon_handler_field_product_type extends views_handler_field_prerender_list {
|
||||
function pre_render($values) {
|
||||
$this->items = array();
|
||||
foreach ($values as $value) {
|
||||
$cid = $value->{$this->field_alias};
|
||||
$data = unserialize($value->{$this->aliases['data']});
|
||||
if (isset($data['product_types'])) {
|
||||
$this->items[$cid] = $data['product_types'];
|
||||
}
|
||||
else {
|
||||
$this->items[$cid] = array(t('Any'));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views handler: Coupon value field.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Return a coupon value as price or percentage.
|
||||
*/
|
||||
class uc_coupon_handler_field_value extends views_handler_field_numeric {
|
||||
function render($values) {
|
||||
$coupon = new stdClass;
|
||||
$coupon->value = $values->{$this->field_alias};
|
||||
$coupon->type = $values->{$this->aliases['type']};
|
||||
return theme('uc_coupon_discount', array('coupon' => $coupon));
|
||||
}
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
// $Id$
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Filter based on coupon order gross (total+value)
|
||||
*/
|
||||
class uc_coupon_handler_filter_gross extends views_handler_filter_numeric {
|
||||
|
||||
function query() {
|
||||
$this->ensure_my_table();
|
||||
$uco = $this->query->ensure_table('uc_orders');
|
||||
$uc = $this->table_alias;
|
||||
$field = "($uco.order_total + $uc.value)";
|
||||
|
||||
$info = $this->operators();
|
||||
if (!empty($info[$this->operator]['method'])) {
|
||||
$this->{$info[$this->operator]['method']}($field);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Views handler: Coupon filter on "product-type".
|
||||
*/
|
||||
|
||||
/**
|
||||
* Filter coupons based on what product types they apply to
|
||||
*/
|
||||
class uc_coupon_handler_filter_product_type extends views_handler_filter_in_operator {
|
||||
|
||||
function get_value_options() {
|
||||
$this->value_options = array();
|
||||
foreach (module_invoke_all('uc_product_types') as $type) {
|
||||
$this->value_options[$type] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
function query() {
|
||||
$this->query->add_field('uc_coupons', 'data');
|
||||
if (is_array($this->value) && count($this->value)) {
|
||||
$search = implode("|", $this->value);
|
||||
$regexp = ".*product_types.*{[^}]*($search).*}";
|
||||
$this->query->add_where_expression($this->options['group'],
|
||||
"uc_coupons.data " . ($this->options['operator'] !== 'in' ? "NOT " : "") . "REGEXP :re",
|
||||
array(':re' => $regexp)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user