Index: in-commerce/units/orders/orders_event_handler.php =================================================================== --- in-commerce/units/orders/orders_event_handler.php (revision 13268) +++ in-commerce/units/orders/orders_event_handler.php (working copy) @@ -3825,11 +3825,13 @@ $user_groups = explode(',', $this->Application->RecallVar('UserGroups')); $default_group = $this->Application->ConfigValue('User_LoggedInGroup'); if (!in_array($default_group, $user_groups)){ - $user_groups[]=$default_group; + $user_groups[] = $default_group; } - $fields['PaymentType']['options_sql'] .= ' AND '; - $fields['PaymentType']['options_sql'] .= ' (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%")'; - + $fields['PaymentType']['options_sql'] = str_replace( + 'ORDER BY ', + 'AND (PortalGroups LIKE "%%,'.implode(',%%" OR PortalGroups LIKE "%%,', $user_groups).',%%") ORDER BY ', + $fields['PaymentType']['options_sql'] + ); } $this->Application->setUnitOption($event->Prefix, 'Fields', $fields); Index: in-commerce/units/orders/orders_config.php =================================================================== --- in-commerce/units/orders/orders_config.php (revision 13268) +++ in-commerce/units/orders/orders_config.php (working copy) @@ -22,97 +22,97 @@ 'AutoLoad' => true, 'Hooks' => Array ( - Array ( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'ord', - 'HookToSpecial' => '', - 'HookToEvent' => Array ( 'OnPreSave' ), - 'DoPrefix' => '', - 'DoSpecial' => '', - 'DoEvent' => 'OnRecalculateItems', - ), + Array ( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'ord', + 'HookToSpecial' => '', + 'HookToEvent' => Array ( 'OnPreSave' ), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnRecalculateItems', + ), - /* OnApplyCoupon is called as hook for OnUpdateCart/OnCheckout, which calls OnRecalcualate themself - Array ( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'coup', - 'HookToSpecial' => '', - 'HookToEvent' => Array ( 'OnApplyCoupon' ), - 'DoPrefix' => '', - 'DoSpecial' => '', - 'DoEvent' => 'OnRecalculateItems', - ),*/ + /* OnApplyCoupon is called as hook for OnUpdateCart/OnCheckout, which calls OnRecalcualate themself + Array ( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'coup', + 'HookToSpecial' => '', + 'HookToEvent' => Array ( 'OnApplyCoupon' ), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnRecalculateItems', + ),*/ - Array ( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'u', - 'HookToSpecial' => '', - 'HookToEvent' => Array ( 'OnCreate' ), - 'DoPrefix' => '', - 'DoSpecial' => '', - 'DoEvent' => 'OnUserCreate', - ), + Array ( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'u', + 'HookToSpecial' => '', + 'HookToEvent' => Array ( 'OnCreate' ), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnUserCreate', + ), - Array ( - 'Mode' => hBEFORE, - 'Conditional' => false, - 'HookToPrefix' => 'u', - 'HookToSpecial' => '', - 'HookToEvent' => Array ('OnCheckExpiredMembership'), - 'DoPrefix' => '', - 'DoSpecial' => '', - 'DoEvent' => 'OnCheckRecurringOrders', - ), + Array ( + 'Mode' => hBEFORE, + 'Conditional' => false, + 'HookToPrefix' => 'u', + 'HookToSpecial' => '', + 'HookToEvent' => Array ('OnCheckExpiredMembership'), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnCheckRecurringOrders', + ), - Array ( - 'Mode' => hAFTER, - 'Conditional' => false, - 'HookToPrefix' => 'u', - 'HookToSpecial' => '', - 'HookToEvent' => Array ( 'OnLogin' ), - 'DoPrefix' => '', - 'DoSpecial' => '', - 'DoEvent' => 'OnUserLogin', - ), + Array ( + 'Mode' => hAFTER, + 'Conditional' => false, + 'HookToPrefix' => 'u', + 'HookToSpecial' => '', + 'HookToEvent' => Array ( 'OnLogin' ), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnUserLogin', + ), - Array ( - 'Mode' => hBEFORE, // before because OnInpLogin is called after real in-portal login and uses data from hooks - 'Conditional' => false, - 'HookToPrefix' => 'u', - 'HookToSpecial' => '', - 'HookToEvent' => Array ( 'OnInpLogin' ), - 'DoPrefix' => '', - 'DoSpecial' => '', - 'DoEvent' => 'OnUserLogin', - ), - ), + Array ( + 'Mode' => hBEFORE, // before because OnInpLogin is called after real in-portal login and uses data from hooks + 'Conditional' => false, + 'HookToPrefix' => 'u', + 'HookToSpecial' => '', + 'HookToEvent' => Array ( 'OnInpLogin' ), + 'DoPrefix' => '', + 'DoSpecial' => '', + 'DoEvent' => 'OnUserLogin', + ), + ), 'AggregateTags' => Array ( - Array ( - 'AggregateTo' => 'orditems', - 'AggregatedTagName' => 'LinkRemoveFromCart', - 'LocalTagName' => 'Orditems_LinkRemoveFromCart', - ), - Array ( - 'AggregateTo' => 'orditems', - 'AggregatedTagName' => 'ProductLink', - 'LocalTagName' => 'Orderitems_ProductLink', - ), - Array ( - 'AggregateTo' => 'orditems', - 'AggregatedTagName' => 'ProductExists', - 'LocalTagName' => 'Orderitems_ProductExists', - ), - ), + Array ( + 'AggregateTo' => 'orditems', + 'AggregatedTagName' => 'LinkRemoveFromCart', + 'LocalTagName' => 'Orditems_LinkRemoveFromCart', + ), + Array ( + 'AggregateTo' => 'orditems', + 'AggregatedTagName' => 'ProductLink', + 'LocalTagName' => 'Orderitems_ProductLink', + ), + Array ( + 'AggregateTo' => 'orditems', + 'AggregatedTagName' => 'ProductExists', + 'LocalTagName' => 'Orderitems_ProductExists', + ), + ), 'QueryString' => Array ( - 1 => 'id', - 2 => 'Page', - 3 => 'event', - 4 => 'mode', - ), + 1 => 'id', + 2 => 'Page', + 3 => 'event', + 4 => 'mode', + ), 'IDField' => 'OrderId', 'StatusField' => Array ('Status'), // field, that is affected by Approve/Decline events @@ -121,66 +121,67 @@ 'TitleField' => 'OrderNumber', 'TitlePresets' => Array ( - 'default' => Array ( 'new_status_labels' => Array ('ord' => '!la_title_Adding_Order!'), - 'edit_status_labels' => Array ('ord' => '!la_title_Editing_Order!'), - 'new_titlefield' => Array ('ord' => '!la_title_New_Order!'), - ), + 'default' => Array ( + 'new_status_labels' => Array ('ord' => '!la_title_Adding_Order!'), + 'edit_status_labels' => Array ('ord' => '!la_title_Editing_Order!'), + 'new_titlefield' => Array ('ord' => '!la_title_New_Order!'), + ), - 'orders_incomplete' => Array ( 'prefixes' => Array ('ord.incomplete_List'), - 'format' => "!la_title_IncompleteOrders!", - ), + 'orders_incomplete' => Array ( 'prefixes' => Array ('ord.incomplete_List'), + 'format' => "!la_title_IncompleteOrders!", + ), - 'orders_pending' => Array ( 'prefixes' => Array ('ord.pending_List'), - 'format' => "!la_title_PendingOrders!", - ), + 'orders_pending' => Array ( 'prefixes' => Array ('ord.pending_List'), + 'format' => "!la_title_PendingOrders!", + ), - 'orders_backorders' => Array ( 'prefixes' => Array ('ord.backorders_List'), - 'format' => "!la_title_BackOrders!", - ), + 'orders_backorders' => Array ( 'prefixes' => Array ('ord.backorders_List'), + 'format' => "!la_title_BackOrders!", + ), - 'orders_toship' => Array ( 'prefixes' => Array ('ord.toship_List'), - 'format' => "!la_title_OrdersToShip!", - ), + 'orders_toship' => Array ( 'prefixes' => Array ('ord.toship_List'), + 'format' => "!la_title_OrdersToShip!", + ), - 'orders_processed' => Array ( 'prefixes' => Array ('ord.processed_List'), - 'format' => "!la_title_OrdersProcessed!", - ), + 'orders_processed' => Array ( 'prefixes' => Array ('ord.processed_List'), + 'format' => "!la_title_OrdersProcessed!", + ), - 'orders_returns' => Array ( 'prefixes' => Array ('ord.returns_List'), - 'format' => "!la_title_OrdersReturns!", - ), + 'orders_returns' => Array ( 'prefixes' => Array ('ord.returns_List'), + 'format' => "!la_title_OrdersReturns!", + ), - 'orders_denied' => Array ( 'prefixes' => Array ('ord.denied_List'), - 'format' => "!la_title_OrdersDenied!", - ), - 'orders_archived' => Array ( 'prefixes' => Array ('ord.archived_List'), - 'format' => "!la_title_OrdersArchived!", - ), + 'orders_denied' => Array ( 'prefixes' => Array ('ord.denied_List'), + 'format' => "!la_title_OrdersDenied!", + ), + 'orders_archived' => Array ( 'prefixes' => Array ('ord.archived_List'), + 'format' => "!la_title_OrdersArchived!", + ), - 'orders_search' => Array ( 'prefixes' => Array ('ord.search_List'), - 'format' => "!la_title_OrdersSearch!", - ), + 'orders_search' => Array ( 'prefixes' => Array ('ord.search_List'), + 'format' => "!la_title_OrdersSearch!", + ), - 'orders_edit_general' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_General!"), - 'orders_edit_billing' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderBilling!"), - 'orders_edit_shipping' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderShipping!"), - 'orders_edit_items' => Array ('prefixes' => Array ('ord', 'orditems_List'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderItems!"), - 'orders_edit_preview' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderPreview!"), + 'orders_edit_general' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_General!"), + 'orders_edit_billing' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderBilling!"), + 'orders_edit_shipping' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderShipping!"), + 'orders_edit_items' => Array ('prefixes' => Array ('ord', 'orditems_List'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderItems!"), + 'orders_edit_preview' => Array ('prefixes' => Array ('ord'), 'format' => "#ord_status# '#ord_titlefield#' - !la_title_OrderPreview!"), - 'orders_gw_result' => Array ('prefixes' => Array ('ord'), 'format' => "!la_title_OrderGWResult!"), + 'orders_gw_result' => Array ('prefixes' => Array ('ord'), 'format' => "!la_title_OrderGWResult!"), - 'order_items_edit' => Array ( 'prefixes' => Array ('ord', 'orditems'), - 'new_status_labels' => Array ('orditems' => '!la_title_Adding_Order_Item!'), - 'edit_status_labels' => Array ('orditems' => '!la_title_Editing_Order_Item!'), - 'new_titlefield' => Array ('orditems' => '!la_title_New_Order_Item!'), - 'format' => "#ord_status# '#ord_titlefield#' - #orditems_status# '#orditems_titlefield#'", - ), + 'order_items_edit' => Array ( 'prefixes' => Array ('ord', 'orditems'), + 'new_status_labels' => Array ('orditems' => '!la_title_Adding_Order_Item!'), + 'edit_status_labels' => Array ('orditems' => '!la_title_Editing_Order_Item!'), + 'new_titlefield' => Array ('orditems' => '!la_title_New_Order_Item!'), + 'format' => "#ord_status# '#ord_titlefield#' - #orditems_status# '#orditems_titlefield#'", + ), - 'orders_export' => Array ('format' => '!la_title_OrdersExport!'), + 'orders_export' => Array ('format' => '!la_title_OrdersExport!'), - 'orders_product_edit' => Array ('format' => '!la_title_Editing_Order_Item!'), + 'orders_product_edit' => Array ('format' => '!la_title_Editing_Order_Item!'), - ), + ), 'EditTabPresets' => Array ( 'Default' => Array ( @@ -227,20 +228,20 @@ 'TableName' => TABLE_PREFIX.'Orders', 'FilterMenu' => Array ( - 'Groups' => Array ( - Array ('mode' => 'AND', 'filters' => Array (0,1,2,3,4,5,6), 'type' => WHERE_FILTER), - ), + 'Groups' => Array ( + Array ('mode' => 'AND', 'filters' => Array (0,1,2,3,4,5,6), 'type' => WHERE_FILTER), + ), - 'Filters' => Array ( - 0 => Array ('label' => 'la_Incomplete', 'on_sql' => '', 'off_sql' => '%1$s.Status != 0' ), - 1 => Array ('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => '%1$s.Status != 1' ), - 2 => Array ('label' => 'la_BackOrders', 'on_sql' => '', 'off_sql' => '%1$s.Status != 2' ), - 3 => Array ('label' => 'la_ToShip', 'on_sql' => '', 'off_sql' => '%1$s.Status != 3' ), - 4 => Array ('label' => 'la_Processed', 'on_sql' => '', 'off_sql' => '%1$s.Status != 4' ), - 5 => Array ('label' => 'la_Denied', 'on_sql' => '', 'off_sql' => '%1$s.Status != 5' ), - 6 => Array ('label' => 'la_Archived', 'on_sql' => '', 'off_sql' => '%1$s.Status != 6' ), - ) - ), + 'Filters' => Array ( + 0 => Array ('label' => 'la_Incomplete', 'on_sql' => '', 'off_sql' => '%1$s.Status != 0' ), + 1 => Array ('label' => 'la_Pending', 'on_sql' => '', 'off_sql' => '%1$s.Status != 1' ), + 2 => Array ('label' => 'la_BackOrders', 'on_sql' => '', 'off_sql' => '%1$s.Status != 2' ), + 3 => Array ('label' => 'la_ToShip', 'on_sql' => '', 'off_sql' => '%1$s.Status != 3' ), + 4 => Array ('label' => 'la_Processed', 'on_sql' => '', 'off_sql' => '%1$s.Status != 4' ), + 5 => Array ('label' => 'la_Denied', 'on_sql' => '', 'off_sql' => '%1$s.Status != 5' ), + 6 => Array ('label' => 'la_Archived', 'on_sql' => '', 'off_sql' => '%1$s.Status != 6' ), + ) + ), 'CalculatedFields' => Array ( '' => Array ( @@ -354,7 +355,17 @@ ), 'VAT' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'not_null' =>1, 'default' => '0', 'format' => '%01.2f'), 'VATPercent' => Array ('type' => 'float', 'formatter' => 'kFormatter', 'not_null' =>1, 'default' => '0', 'format' => '%01.3f'), - 'PaymentType' => Array ('type' => 'int', 'formatter' => 'kOptionsFormatter', 'options_sql' => 'SELECT %s FROM '.TABLE_PREFIX.'PaymentTypes WHERE Status = 1', 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Description', 'not_null' => 1, 'default' => 0), + 'PaymentType' => Array ( + 'type' => 'int', + 'formatter' => 'kOptionsFormatter', + 'options_sql' => 'SELECT %s + FROM ' . TABLE_PREFIX . 'PaymentTypes + WHERE Status = 1 + ORDER BY Priority DESC, Name ASC', + 'option_key_field' => 'PaymentTypeId', 'option_title_field' => 'Description', + 'not_null' => 1, 'default' => 0 + ), + 'PaymentAccount' => Array ('type' => 'string', 'not_null' => 1, 'cardtype_field' => 'PaymentCardType', 'default' => '', 'filter_type' => 'like'), 'PaymentNameOnCard' => Array ('type' => 'string', 'not_null' => 1, 'default' => ''), 'PaymentCCExpDate' => Array ('type' => 'string', 'formatter' => 'kCCDateFormatter', 'month_field' => 'PaymentCCExpMonth', 'year_field' => 'PaymentCCExpYear', 'not_null' => 1, 'default' => ''),