function fn_rma_get_order_info(&$order, &$additional_data) { if (!empty($order)) { $status_data = fn_get_status_params($order['status'], STATUSES_ORDER); if (!empty($status_data) && (!empty($status_data['allow_return']) && $status_data['allow_return'] == 'Y') && isset($additional_data[ORDER_DATA_PRODUCTS_DELIVERY_DATE])) { $order_returnable_products = fn_get_order_returnable_products($order['products'], $additional_data[ORDER_DATA_PRODUCTS_DELIVERY_DATE]); if (!empty($order_returnable_products['items'])) { $order['allow_return'] = 'Y'; } if (!empty($order_returnable_products['item_returns_info'])) { foreach ($order_returnable_products['item_returns_info'] as $item_id => $returns_info) { $order['products'][$item_id]['returns_info'] = $returns_info; } } } if (!empty($additional_data[ORDER_DATA_PRODUCTS_DELIVERY_DATE])) { $order['products_delivery_date'] = $additional_data[ORDER_DATA_PRODUCTS_DELIVERY_DATE]; } if (!empty($additional_data[ORDER_DATA_RETURN])) { $order_return_info = @unserialize($additional_data[ORDER_DATA_RETURN]); $order['return'] = @$order_return_info['return']; $order['returned_products'] = @$order_return_info['returned_products']; foreach ((array) $order['returned_products'] as $k => $v) { $v['product'] = !empty($v['extra']['product']) ? $v['extra']['product'] : fn_get_product_name($v['product_id'], CART_LANGUAGE); if (empty($v['product'])) { $v['product'] = strtoupper(__('deleted_product')); } $v['discount'] = !empty($v['extra']['discount']) && floatval($v['extra']['discount']) ? $v['extra']['discount'] : 0; if (!empty($v['extra']['product_options_value'])) { $v['product_options'] = $v['extra']['product_options_value']; } $v['subtotal'] = $v['price'] * $v['amount'] - $v['discount']; $order['returned_products'][$k] = $v; } } if (0 < ($returns_count = db_get_field("SELECT COUNT(*) FROM ?:rma_returns WHERE order_id = ?i", $order['order_id']))) { $order['isset_returns'] = 'Y'; } } }
} list($return_requests, $search) = fn_get_rma_returns($params, Registry::get('settings.Appearance.' . (AREA == 'A' ? 'admin_' : '') . 'elements_per_page')); Tygh::$app['view']->assign('return_requests', $return_requests); Tygh::$app['view']->assign('search', $search); fn_rma_generate_sections('requests'); Tygh::$app['view']->assign('actions', fn_get_rma_properties(RMA_ACTION)); } elseif ($mode == 'create_return' && !empty($_REQUEST['order_id'])) { $order_id = intval($_REQUEST['order_id']); // [Breadcrumbs] if (AREA != 'A') { fn_add_breadcrumb(__('order') . ' #' . $order_id, "orders.details?order_id={$order_id}"); fn_add_breadcrumb(__('return_registration')); } // [/Breadcrumbs] $order_info = fn_get_order_info($order_id); $order_returnable_products = fn_get_order_returnable_products($order_info['products'], $order_info['products_delivery_date']); $order_info['products'] = $order_returnable_products['items']; if (!isset($order_info['allow_return'])) { return array(CONTROLLER_STATUS_DENIED); } Tygh::$app['view']->assign('order_info', $order_info); Tygh::$app['view']->assign('reasons', fn_get_rma_properties(RMA_REASON)); Tygh::$app['view']->assign('actions', fn_get_rma_properties(RMA_ACTION)); } function fn_get_rma_returns($params, $items_per_page = 0) { // Init filter $params = LastView::instance()->update('rma', $params); // Set default values to input params $default_params = array('page' => 1, 'items_per_page' => $items_per_page); $params = array_merge($default_params, $params);