function fn_rma_print_packing_slips($return_ids, $auth, $area = AREA) { $view = Registry::get('view'); $passed = false; if (!is_array($return_ids)) { $return_ids = array($return_ids); } $view->assign('reasons', fn_get_rma_properties(RMA_REASON)); $view->assign('actions', fn_get_rma_properties(RMA_ACTION)); $view->assign('order_status_descr', fn_get_simple_statuses(STATUSES_RETURN)); foreach ($return_ids as $return_id) { $return_info = fn_get_return_info($return_id); if (empty($return_info) || $area == 'C' && $return_info['user_id'] != $auth['user_id']) { continue; } $order_info = fn_get_order_info($return_info['order_id']); if (empty($order_info)) { continue; } $passed = true; $view->assign('return_info', $return_info); $view->assign('order_info', $order_info); $view->assign('company_data', fn_get_company_placement_info($order_info['company_id'])); $view->displayMail('addons/rma/print_slip.tpl', true, $area, $order_info['company_id']); if ($return_id != end($return_ids)) { echo "<div style='page-break-before: always;'> </div>"; } } return $passed; }
$order_id = intval($_REQUEST['order_id']); // [Breadcrumbs] fn_add_breadcrumb(fn_get_lang_var('order') . ' #' . $order_id, "orders.details?order_id={$order_id}"); if (AREA != 'A') { fn_add_breadcrumb(fn_get_lang_var('return_registration')); } // [/Breadcrumbs] $order_info = fn_get_order_info($order_id); $order_returnable_products = fn_get_order_returnable_products($order_info['items'], $order_info['products_delivery_date']); $order_info['items'] = $order_returnable_products['items']; if (!isset($order_info['allow_return'])) { return array(CONTROLLER_STATUS_DENIED); } $view->assign('order_info', $order_info); $view->assign('reasons', fn_get_rma_properties(RMA_REASON)); $view->assign('actions', fn_get_rma_properties(RMA_ACTION)); } function fn_get_rma_returns($params) { // Init filter $params = fn_init_view('rma', $params); // Set default values to input params $params['page'] = empty($params['page']) ? 1 : $params['page']; // Define fields that should be retrieved $fields = array('DISTINCT ?:rma_returns.return_id', '?:rma_returns.order_id', '?:rma_returns.timestamp', '?:rma_returns.status', '?:rma_returns.total_amount', '?:rma_property_descriptions.property AS action', '?:users.firstname', '?:users.lastname'); // Define sort fields $sortings = array('return_id' => "?:rma_returns.return_id", 'timestamp' => "?:rma_returns.timestamp", 'order_id' => "?:rma_returns.order_id", 'status' => "?:rma_returns.status", 'amount' => "?:rma_returns.total_amount", 'action' => "?:rma_returns.action", 'customer' => "?:users.lastname"); $directions = array('asc' => 'asc', 'desc' => 'desc'); if (empty($params['sort_order']) || empty($directions[$params['sort_order']])) { $params['sort_order'] = 'desc'; }
$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); // Define fields that should be retrieved $fields = array('DISTINCT ?:rma_returns.return_id', '?:rma_returns.order_id', '?:rma_returns.timestamp', '?:rma_returns.status', '?:rma_returns.total_amount', '?:rma_property_descriptions.property AS action', '?:users.firstname', '?:users.lastname'); // Define sort fields $sortings = array('return_id' => "?:rma_returns.return_id", 'timestamp' => "?:rma_returns.timestamp", 'order_id' => "?:rma_returns.order_id", 'status' => "?:rma_returns.status", 'amount' => "?:rma_returns.total_amount", 'action' => "?:rma_returns.action", 'customer' => "?:users.lastname"); $sorting = db_sort($params, $sortings, 'timestamp', 'desc'); $join = $condition = $group = ''; if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
} if ($mode == 'delete' && !empty($_REQUEST['return_id'])) { fn_delete_return($_REQUEST['return_id']); $suffix = '.returns'; } if ($mode == 'delete_property') { if (!empty($_REQUEST['property_id'])) { fn_rma_delete_property($_REQUEST['property_id']); } $suffix = '.properties?property_type=' . $_REQUEST['property_type']; } return array(CONTROLLER_STATUS_OK, 'rma' . $suffix); } if ($mode == 'properties') { $property_type = !empty($_REQUEST['property_type']) ? $_REQUEST['property_type'] : RMA_REASON; fn_rma_generate_sections($property_type == RMA_REASON ? 'reasons' : 'actions'); Tygh::$app['view']->assign('properties', fn_get_rma_properties($property_type, DESCR_SL)); } elseif ($mode == 'confirmation') { $change_return_status = $_SESSION['change_return_status']; unset($_SESSION['change_return_status']); if ($change_return_status['recalculate_order'] == 'R') { $additional_data = db_get_hash_single_array("SELECT type,data FROM ?:order_data WHERE order_id = ?i", array('type', 'data'), $change_return_status['order_id']); $shipping_info = @unserialize($additional_data['L']); Tygh::$app['view']->assign('shipping_info', $shipping_info); } else { $total = db_get_field("SELECT SUM(amount*price) FROM ?:rma_return_products WHERE return_id = ?i AND type = ?s", $change_return_status['return_id'], RETURN_PRODUCT_ACCEPTED); $change_return_status['total'] = $change_return_status['inventory_to'] == 'I' && !($change_return_status['inventory_from'] == 'I' && $change_return_status['status_to'] == RMA_DEFAULT_STATUS) ? -$total : $total; } Tygh::$app['view']->assign('change_return_status', $change_return_status); Tygh::$app['view']->assign('status_descr', fn_get_simple_statuses(STATUSES_RETURN)); }
function fn_send_return_mail(&$return_info, &$order_info, $force_notification = array()) { $return_statuses = fn_get_statuses(STATUSES_RETURN); $status_params = $return_statuses[$return_info['status']]; $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false); $notify_department = isset($force_notification['A']) ? $force_notification['A'] : (!empty($status_params['notify_department']) && $status_params['notify_department'] == 'Y' ? true : false); if ($notify_user == true || $notify_department == true) { Registry::get('view_mail')->assign('order_info', $order_info); Registry::get('view_mail')->assign('return_info', $return_info); Registry::get('view_mail')->assign('reasons', fn_get_rma_properties(RMA_REASON)); Registry::get('view_mail')->assign('actions', fn_get_rma_properties(RMA_ACTION)); Registry::get('view_mail')->assign('return_status', fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], $order_info['lang_code'])); // Notify customer if ($notify_user == true) { fn_send_mail($order_info['email'], Registry::get('settings.Company.company_orders_department'), 'addons/rma/slip_notification_subj.tpl', 'addons/rma/slip_notification.tpl', '', $order_info['lang_code']); } // Notify administrator (only if the changes performed from customer area) if (AREA == 'C' || $notify_department == true) { // Translate descriptions to admin language Registry::get('view_mail')->assign('return_status', fn_get_status_data($return_info['status'], STATUSES_RETURN, $return_info['return_id'], Registry::get('settings.Appearance.admin_default_language'))); fn_send_mail(Registry::get('settings.Company.company_orders_department'), Registry::get('settings.Company.company_orders_department'), 'addons/rma/slip_notification_subj.tpl', 'addons/rma/slip_notification.tpl', '', Registry::get('settings.Appearance.admin_default_language'), $order_info['email']); } } }
// update order detail data $order_details_data = array('extra' => serialize($extra)); db_query("UPDATE ?:order_details SET ?u WHERE item_id = ?i AND order_id = ?i", $order_details_data, $item_id, $change_return_status['order_id']); unset($order_details_data); } } db_query('UPDATE ?:rma_returns SET ?u WHERE return_id = ?i', array('total_amount' => $_REQUEST['total_amount'] + $accept_amount), $change_return_status['return_id']); } $suffix = ".details?return_id={$change_return_status['return_id']}"; } return array(CONTROLLER_STATUS_OK, "rma{$suffix}"); } if ($mode == 'properties') { $property_type = !empty($_REQUEST['property_type']) ? $_REQUEST['property_type'] : RMA_REASON; fn_rma_generate_sections($property_type == RMA_REASON ? 'reasons' : 'actions'); Registry::get('view')->assign('properties', fn_get_rma_properties($property_type, DESCR_SL)); } elseif ($mode == 'delete' && !empty($_REQUEST['return_id'])) { fn_delete_return($_REQUEST['return_id']); return array(CONTROLLER_STATUS_REDIRECT, "rma.returns"); } elseif ($mode == 'confirmation') { $change_return_status = $_SESSION['change_return_status']; unset($_SESSION['change_return_status']); if ($change_return_status['recalculate_order'] == 'R') { $additional_data = db_get_hash_single_array("SELECT type,data FROM ?:order_data WHERE order_id = ?i", array('type', 'data'), $change_return_status['order_id']); $shipping_info = @unserialize($additional_data['L']); Registry::get('view')->assign('shipping_info', $shipping_info); } else { $total = db_get_field("SELECT SUM(amount*price) FROM ?:rma_return_products WHERE return_id = ?i AND type = ?s", $change_return_status['return_id'], RETURN_PRODUCT_ACCEPTED); $change_return_status['total'] = $change_return_status['inventory_to'] == 'I' && !($change_return_status['inventory_from'] == 'I' && $change_return_status['status_to'] == RMA_DEFAULT_STATUS) ? -$total : $total; } Registry::get('view')->assign('change_return_status', $change_return_status);
$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); } Registry::get('view')->assign('order_info', $order_info); Registry::get('view')->assign('reasons', fn_get_rma_properties(RMA_REASON)); Registry::get('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); // Define fields that should be retrieved $fields = array('DISTINCT ?:rma_returns.return_id', '?:rma_returns.order_id', '?:rma_returns.timestamp', '?:rma_returns.status', '?:rma_returns.total_amount', '?:rma_property_descriptions.property AS action', '?:users.firstname', '?:users.lastname'); // Define sort fields $sortings = array('return_id' => "?:rma_returns.return_id", 'timestamp' => "?:rma_returns.timestamp", 'order_id' => "?:rma_returns.order_id", 'status' => "?:rma_returns.status", 'amount' => "?:rma_returns.total_amount", 'action' => "?:rma_returns.action", 'customer' => "?:users.lastname"); $sorting = db_sort($params, $sortings, 'timestamp', 'desc'); $join = $condition = $group = ''; if (isset($params['cname']) && fn_string_not_empty($params['cname'])) {
// update order detail data $order_details_data = array('extra' => serialize($extra)); db_query("UPDATE ?:order_details SET ?u WHERE item_id = ?i AND order_id = ?i", $order_details_data, $item_id, $change_return_status['order_id']); unset($order_details_data); } } db_query('UPDATE ?:rma_returns SET ?u WHERE return_id = ?i', array('total_amount' => $_REQUEST['total_amount'] + $accept_amount), $change_return_status['return_id']); } $suffix = ".details?return_id={$change_return_status['return_id']}"; } return array(CONTROLLER_STATUS_OK, "rma{$suffix}"); } if ($mode == 'properties') { $property_type = !empty($_REQUEST['property_type']) ? $_REQUEST['property_type'] : RMA_REASON; fn_rma_generate_sections($property_type == RMA_REASON ? 'reasons' : 'actions'); $view->assign('properties', fn_get_rma_properties($property_type, DESCR_SL)); } elseif ($mode == 'delete' && !empty($_REQUEST['return_id'])) { fn_delete_return($_REQUEST['return_id']); return array(CONTROLLER_STATUS_REDIRECT, "rma.returns"); } elseif ($mode == 'confirmation') { // [Breadcrumbs] fn_add_breadcrumb(fn_get_lang_var('return_requests'), "rma.returns"); // [/Breadcrumbs] $change_return_status = $_SESSION['change_return_status']; unset($_SESSION['change_return_status']); if ($change_return_status['recalculate_order'] == 'R') { $additional_data = db_get_hash_single_array("SELECT type,data FROM ?:order_data WHERE order_id = ?i", array('type', 'data'), $change_return_status['order_id']); $shipping_info = @unserialize($additional_data['L']); $view->assign('shipping_info', $shipping_info); } else { $total = db_get_field("SELECT SUM(amount*price) FROM ?:rma_return_products WHERE return_id = ?i AND type = ?s", $change_return_status['return_id'], RETURN_PRODUCT_ACCEPTED);