if (count($return_requests) > 0) { foreach ($return_requests as $return_request) { if (in_array($return_request['status'], array('O'))) { array_push($aviable_return_requests, $return_request); } } } $aviable_return_requests_number = count($aviable_return_requests); Registry::get('view')->assign('orders_number', $orders_number); Registry::get('view')->assign('recent_order_status', $recent_order_status_text); Registry::get('view')->assign('shortlist_number', $shortlist_number); Registry::get('view')->assign('last_shortlist_product', $product); Registry::get('view')->assign('return_requests_number', $return_requests_number); Registry::get('view')->assign('aviable_return_requests_number', $aviable_return_requests_number); if (Registry::get('settings.General.user_multiple_profiles') == 'Y') { Registry::get('view')->assign('user_profiles', fn_get_user_profiles($auth['user_id'])); } } /** * Requests usergroup for customer * * @param int $user_id User identifier * @param int $usergroup_id Usergroup identifier * @param string $type Type of request (join|cancel) * @return bool True if request successfuly sent, false otherwise */ function fn_request_usergroup($user_id, $usergroup_id, $type) { $success = false; if (!empty($user_id)) { $_data = array('user_id' => $user_id, 'usergroup_id' => $usergroup_id);
} Tygh::$app['view']->assign('payment_methods', $payment_methods); $cart['payment_surcharge'] = 0; if (!empty($cart['payment_id']) && !empty($payment_info)) { fn_update_payment_surcharge($cart, $auth); } if (fn_allowed_for('MULTIVENDOR')) { Tygh::$app['view']->assign('take_surcharge_from_vendor', fn_take_payment_surcharge_from_vendor($cart['products'])); } Tygh::$app['view']->assign('usergroups', fn_get_usergroups(array('type' => 'C', 'status' => 'A'), CART_LANGUAGE)); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); $cart['ship_to_another'] = fn_check_shipping_billing($cart['user_data'], $profile_fields); Tygh::$app['view']->assign('profile_fields', $profile_fields); if (Registry::get('settings.General.user_multiple_profiles') == 'Y') { $user_profiles = fn_get_user_profiles($auth['user_id']); Tygh::$app['view']->assign('user_profiles', $user_profiles); } fn_checkout_summary($cart); Tygh::$app['view']->assign('use_ajax', 'true'); Tygh::$app['view']->assign('completed_steps', $completed_steps); Tygh::$app['view']->assign('location', 'checkout'); Tygh::$app['view']->assign('cart', $cart); Tygh::$app['view']->assign('cart_products', array_reverse($cart_products, true)); Tygh::$app['view']->assign('product_groups', $cart['product_groups']); if (!empty($cart['failed_order_id']) || !empty($cart['processed_order_id'])) { $_ids = !empty($cart['failed_order_id']) ? $cart['failed_order_id'] : $cart['processed_order_id']; $_order_id = reset($_ids); $_payment_info = db_get_field("SELECT data FROM ?:order_data WHERE order_id = ?i AND type = 'P'", $_order_id); $_payment_info = !empty($_payment_info) ? unserialize(fn_decrypt_text($_payment_info)) : array(); if (!empty($cart['failed_order_id'])) {
} else { $usergroups = array(); } } if (empty($user_data['api_key'])) { Tygh::$app['view']->assign('new_api_key', Api::generateKey()); } /** * Only admin can set the api key. */ if (fn_check_user_type_admin_area($user_data) && !empty($user_data['user_id']) && ($auth['user_type'] == 'A' || $user_data['api_key'])) { $navigation['api'] = array('title' => __('api_access'), 'js' => true); Tygh::$app['view']->assign('show_api_tab', true); if ($auth['user_type'] != 'A') { Tygh::$app['view']->assign('hide_api_checkbox', true); } } Registry::set('navigation.tabs', $navigation); Tygh::$app['view']->assign('usergroups', $usergroups); Tygh::$app['view']->assign('hide_inputs', !fn_check_editable_permissions($auth, $user_data)); $profile_fields = fn_get_profile_fields($user_type); Tygh::$app['view']->assign('user_type', $user_type); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('user_data', $user_data); Tygh::$app['view']->assign('ship_to_another', fn_check_shipping_billing($user_data, $profile_fields)); if (Registry::get('settings.General.user_multiple_profiles') == 'Y' && !empty($user_id)) { Tygh::$app['view']->assign('user_profiles', fn_get_user_profiles($user_id)); } Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); }
$get_additional_statuses = true; } if (!empty($order_info['issuer_id'])) { $cart['issuer_data'] = fn_get_user_short_info($order_info['issuer_id']); } } $order_statuses = fn_get_simple_statuses(STATUSES_ORDER, $get_additional_statuses, true); Registry::get('view')->assign('order_statuses', $order_statuses); // // Prepare customer info // $profile_fields = fn_get_profile_fields('O', $customer_auth); $cart['profile_id'] = empty($cart['profile_id']) ? 0 : $cart['profile_id']; Registry::get('view')->assign('profile_fields', $profile_fields); //Get user profiles $user_profiles = fn_get_user_profiles($customer_auth['user_id']); Registry::get('view')->assign('user_profiles', $user_profiles); //Get countries and states Registry::get('view')->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Registry::get('view')->assign('states', fn_get_all_states()); Registry::get('view')->assign('usergroups', fn_get_usergroups('C', DESCR_SL)); if (!empty($customer_auth['user_id']) && (empty($cart['user_data']) || !empty($_REQUEST['profile_id']) && $cart['profile_id'] != $_REQUEST['profile_id'])) { $cart['profile_id'] = !empty($_REQUEST['profile_id']) ? $_REQUEST['profile_id'] : 0; $cart['user_data'] = fn_get_user_info($customer_auth['user_id'], true, $cart['profile_id']); fn_filter_hidden_profile_fields($cart['user_data'], 'O'); } if (!empty($cart['user_data'])) { $cart['ship_to_another'] = fn_check_shipping_billing($cart['user_data'], $profile_fields); } // // Get products info
} /** * Only admin can set the api key. */ if (fn_check_user_type_admin_area($user_data) && !empty($user_data['user_id']) && ($auth['user_type'] == 'A' || $user_data['api_key'])) { $navigation['api'] = array('title' => __('api_access'), 'js' => true); Registry::get('view')->assign('show_api_tab', true); if ($auth['user_type'] != 'A') { Registry::get('view')->assign('hide_api_checkbox', true); } } Registry::set('navigation.tabs', $navigation); Registry::get('view')->assign('usergroups', $usergroups); $profile_fields = fn_get_profile_fields($user_type); Registry::get('view')->assign('user_type', $user_type); Registry::get('view')->assign('profile_fields', $profile_fields); Registry::get('view')->assign('user_data', $user_data); Registry::get('view')->assign('ship_to_another', fn_check_shipping_billing($user_data, $profile_fields)); if (Registry::get('settings.General.user_multiple_profiles') == 'Y' && !empty($user_id)) { Registry::get('view')->assign('user_profiles', fn_get_user_profiles($user_id)); } Registry::get('view')->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Registry::get('view')->assign('states', fn_get_all_states()); } elseif ($mode == 'delete_profile') { if (fn_is_restricted_admin($_REQUEST)) { return array(CONTROLLER_STATUS_DENIED); } $user_id = empty($_REQUEST['user_id']) ? $auth['user_id'] : $_REQUEST['user_id']; fn_delete_user_profile($user_id, $_REQUEST['profile_id']); return array(CONTROLLER_STATUS_OK, "profiles.update?user_id=" . $user_id); }
$view->assign('usergroups', $usergroups); $profile_fields = fn_get_profile_fields($user_type); //Do not show 'only for admin' field 21.01.2015 MLazarev if ($auth['area'] == 'C' && isset($profile_fields['C']['36'])) { unset($profile_fields['C']['36']); } $view->assign('user_type', $user_type); $view->assign('profile_fields', $profile_fields); $view->assign('user_data', $user_data); $view->assign('ship_to_another', fn_check_shipping_billing($user_data, $profile_fields)); $view->assign('titles', fn_get_static_data_section('T')); $view->assign('countries', fn_get_countries(CART_LANGUAGE, true)); $view->assign('states', fn_get_all_states()); $view->assign('uid', $uid); if (Registry::get('settings.General.user_multiple_profiles') == 'Y' && !empty($uid)) { $view->assign('user_profiles', fn_get_user_profiles($uid)); } // Delete profile } elseif ($mode == 'delete_profile') { if (AREA == 'A' && (fn_is_restricted_admin($_REQUEST) == true || defined('COMPANY_ID'))) { return array(CONTROLLER_STATUS_DENIED); } if (AREA == 'A') { $uid = empty($_REQUEST['user_id']) ? $auth['user_id'] : $_REQUEST['user_id']; } else { $uid = $auth['user_id']; } $can_delete = db_get_field("SELECT profile_id FROM ?:user_profiles WHERE user_id = ?i AND profile_id = ?i AND profile_type = 'S'", $uid, $_REQUEST['profile_id']); if (!empty($can_delete)) { db_query("DELETE FROM ?:user_profiles WHERE profile_id = ?i", $_REQUEST['profile_id']); }
} if ($show_usergroups) { $usergroups = fn_get_usergroups(array('type' => 'C', 'status' => 'A')); if (!empty($usergroups)) { Registry::set('navigation.tabs.usergroups', array('title' => __('usergroups'), 'js' => true)); Tygh::$app['view']->assign('usergroups', $usergroups); } } $profile_fields = fn_get_profile_fields(); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('user_data', $user_data); Tygh::$app['view']->assign('ship_to_another', fn_check_shipping_billing($user_data, $profile_fields)); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); if (Registry::get('settings.General.user_multiple_profiles') == 'Y') { Tygh::$app['view']->assign('user_profiles', fn_get_user_profiles($auth['user_id'])); } // Delete profile } elseif ($mode == 'delete_profile') { fn_delete_user_profile($auth['user_id'], $_REQUEST['profile_id']); return array(CONTROLLER_STATUS_OK, 'profiles.update'); } elseif ($mode == 'usergroups') { if (empty($auth['user_id']) || empty($_REQUEST['type']) || empty($_REQUEST['usergroup_id'])) { return array(CONTROLLER_STATUS_DENIED); } if (fn_request_usergroup($auth['user_id'], $_REQUEST['usergroup_id'], $_REQUEST['type'])) { $user_data = fn_get_user_info($auth['user_id']); $usergroups = fn_get_usergroups(array('type' => 'C', 'status' => 'A'), Registry::get('settings.Appearance.backend_default_language')); Mailer::sendMail(array('to' => 'default_company_users_department', 'from' => 'default_company_users_department', 'reply_to' => $user_data['email'], 'data' => array('user_data' => $user_data, 'usergroup' => !empty($usergroups[$_REQUEST['usergroup_id']]['usergroup']) ? $usergroups[$_REQUEST['usergroup_id']]['usergroup'] : null, 'usergroup_id' => $_REQUEST['usergroup_id']), 'tpl' => 'profiles/usergroup_request.tpl', 'company_id' => $user_data['company_id']), 'A', Registry::get('settings.Appearance.backend_default_language')); } return array(CONTROLLER_STATUS_OK, 'profiles.update');