# On branch 7.x-3.x # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: uc_order/uc_order.info # modified: uc_order/views/uc_order.views.inc # new file: uc_order/views/uc_order_handler_field_money_total.inc # new file: uc_order/views/uc_order_handler_field_weight_total.inc # new file: uc_order/views/uc_order_handler_filter_total.inc # new file: uc_order/views/uc_order_handler_sort_total.inc diff --git a/uc_order/uc_order.info b/uc_order/uc_order.info index 28c5b1b..2e15993 100644 --- a/uc_order/uc_order.info +++ b/uc_order/uc_order.info @@ -13,6 +13,8 @@ files[] = tests/uc_order.test ; Views handlers files[] = views/uc_order_handler_field_money_amount.inc +files[] = views/uc_order_handler_field_money_total.inc +files[] = views/uc_order_handler_field_weight_total.inc files[] = views/uc_order_handler_field_order_actions.inc files[] = views/uc_order_handler_field_order_cc_data.inc files[] = views/uc_order_handler_field_order_cost.inc @@ -24,6 +26,8 @@ files[] = views/uc_order_handler_filter_country.inc files[] = views/uc_order_handler_filter_order_status.inc files[] = views/uc_order_handler_filter_payment_method.inc files[] = views/uc_order_handler_filter_zone.inc +files[] = views/uc_order_handler_filter_total.inc +files[] = views/uc_order_handler_sort_total.inc files[] = views/uc_order_plugin_argument_validate_user_perm.inc files[] = views/uc_order_plugin_row_invoice_view.inc diff --git a/uc_order/views/uc_order.views.inc b/uc_order/views/uc_order.views.inc index e1bcf5d..4b909c0 100644 --- a/uc_order/views/uc_order.views.inc +++ b/uc_order/views/uc_order.views.inc @@ -511,6 +511,23 @@ function uc_order_views_data() { ), ); + $data['uc_order_products']['price_total'] = array( + 'title' => t('Total price'), + 'help' => t('The price paid for all the products (price * quantity).'), + 'real field' => 'price', + 'field' => array( + 'handler' => 'uc_order_handler_field_money_total', + 'click sortable' => TRUE, + 'float' => TRUE, + ), + 'sort' => array( + 'handler' => 'uc_order_handler_sort_total', + ), + 'filter' => array( + 'handler' => 'uc_order_handler_filter_total', + ), + ); + $data['uc_order_products']['cost'] = array( 'title' => t('Cost'), 'help' => t('The cost to the store for one product.'), @@ -527,6 +544,23 @@ function uc_order_views_data() { ), ); + $data['uc_order_products']['total_cost'] = array( + 'title' => t('Total cost'), + 'help' => t('The cost to the store for all the products (cost * quantity).'), + 'real field' => 'cost', + 'field' => array( + 'handler' => 'uc_order_handler_field_money_total', + 'click sortable' => TRUE, + 'float' => TRUE, + ), + 'sort' => array( + 'handler' => 'uc_order_handler_sort_total', + ), + 'filter' => array( + 'handler' => 'uc_order_handler_filter_total', + ), + ); + $data['uc_order_products']['weight'] = array( 'title' => t('Weight'), 'help' => t('The physical weight of one product.'), @@ -541,6 +575,21 @@ function uc_order_views_data() { ), ); + $data['uc_order_products']['total_weight'] = array( + 'title' => t('Total weight'), + 'help' => t('The physical weight of all the products (weight * quantity).'), + 'real field' => 'weight', + 'field' => array( + 'additional fields' => array( + 'weight_units' => array( + 'field' => 'weight_units', + ), + ), + 'handler' => 'uc_order_handler_field_weight_total', + 'float' => TRUE, + ), + ); + $data['uc_order_products']['title'] = array( 'title' => t('Title'), 'help' => t('The title of the product.'), diff --git a/uc_order/views/uc_order_handler_field_money_total.inc b/uc_order/views/uc_order_handler_field_money_total.inc new file mode 100644 index 0000000..3f1cf62 --- /dev/null +++ b/uc_order/views/uc_order_handler_field_money_total.inc @@ -0,0 +1,25 @@ +ensure_my_table(); + + $table = $this->table_alias; + $field = $this->real_field; + $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); + $this->field_alias = $this->query->add_field(NULL, "$table.$field * $table.qty", $this->table . '_' . $this->field, $params); + } + +} diff --git a/uc_order/views/uc_order_handler_field_weight_total.inc b/uc_order/views/uc_order_handler_field_weight_total.inc new file mode 100644 index 0000000..7ee248f --- /dev/null +++ b/uc_order/views/uc_order_handler_field_weight_total.inc @@ -0,0 +1,27 @@ +ensure_my_table(); + + $table = $this->table_alias; + $field = $this->real_field; + $params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array(); + $this->field_alias = $this->query->add_field(NULL, "$table.$field * $table.qty", $this->table . '_' . $this->field, $params); + + $this->add_additional_fields(); + } + +} diff --git a/uc_order/views/uc_order_handler_filter_total.inc b/uc_order/views/uc_order_handler_filter_total.inc new file mode 100644 index 0000000..9513aa7 --- /dev/null +++ b/uc_order/views/uc_order_handler_filter_total.inc @@ -0,0 +1,31 @@ +ensure_my_table(); + $field = $this->table . '_' . $this->field; + + $info = $this->operators(); + if (!empty($info[$this->operator]['method'])) { + $this->{$info[$this->operator]['method']}($field); + } + } +} diff --git a/uc_order/views/uc_order_handler_sort_total.inc b/uc_order/views/uc_order_handler_sort_total.inc new file mode 100644 index 0000000..554e542 --- /dev/null +++ b/uc_order/views/uc_order_handler_sort_total.inc @@ -0,0 +1,24 @@ +ensure_my_table(); + // Add the field. + $this->query->add_orderby(NULL, NULL, $this->options['order'], $this->table . '_' . $this->field); + } +}