function fn_mve_place_order(&$order_id, &$action, &$__order_status, &$cart) { $order_info = fn_get_order_info($order_id); if ($order_info['is_parent_order'] != 'Y' && !empty($order_info['company_id'])) { // Check if the order already placed $payout_id = db_get_field('SELECT payout_id FROM ?:vendor_payouts WHERE order_id = ?i', $order_id); $company_data = fn_get_company_data($order_info['company_id']); $company_data['commission'] = $order_info['total'] > 0 ? $company_data['commission'] : 0; $company_data['commission_type'] = isset($company_data['commission_type']) ? $company_data['commission_type'] : ''; $commission_amount = 0; if ($company_data['commission_type'] == 'P') { //Calculate commission amount and check if we need to include shipping cost $commission_amount = ($order_info['total'] - (Registry::get('settings.Vendors.include_shipping') == 'N' ? $order_info['shipping_cost'] : 0)) * $company_data['commission'] / 100; } else { $commission_amount = $company_data['commission']; } //Check if we need to take payment surcharge from vendor if (Registry::get('settings.Vendors.include_payment_surcharge') == 'Y') { $commission_amount += $order_info['payment_surcharge']; } $_data = array('company_id' => $order_info['company_id'], 'order_id' => $order_id, 'payout_date' => TIME, 'start_date' => TIME, 'end_date' => TIME, 'commission' => $company_data['commission'], 'commission_type' => $company_data['commission_type'], 'order_amount' => $order_info['total'], 'commission_amount' => $commission_amount); fn_set_hook('mve_place_order', $order_info, $company_data, $action, $__order_status, $cart, $_data); if ($commission_amount > $order_info['total']) { $commission_amount = $order_info['total']; } if (empty($payout_id)) { db_query('INSERT INTO ?:vendor_payouts ?e', $_data); } else { db_query('UPDATE ?:vendor_payouts SET ?u WHERE payout_id = ?i', $_data, $payout_id); } } }
function fn_blocks_get_vendor_info() { $company_id = isset($_REQUEST['company_id']) ? $_REQUEST['company_id'] : null; $company_data = fn_get_company_data($company_id); $company_data['logos'] = fn_get_logos($company_id); return $company_data; }
function fn_vendor_data_premoderation_update_company_pre(&$company_data, &$company_id, &$lang_code) { if (fn_allowed_for('MULTIVENDOR') && Registry::get('runtime.company_id')) { $orig_company_data = fn_get_company_data($company_id, $lang_code); $vendor_profile_updates_approval = Registry::get('addons.vendor_data_premoderation.vendor_profile_updates_approval'); if ($orig_company_data['status'] == 'A' && ($vendor_profile_updates_approval == 'all' || $vendor_profile_updates_approval == 'custom' && !empty($orig_company_data['pre_moderation_edit_vendors']) && $orig_company_data['pre_moderation_edit_vendors'] == 'Y')) { $logotypes = fn_filter_uploaded_data('logotypes_image_icon'); // FIXME: dirty comparison // check that some data is changed if (array_diff_assoc($company_data, $orig_company_data) || !empty($logotypes)) { $company_data['status'] = 'P'; } } } }
function fn_companies_suppliers_order_notification($order_info, $order_statuses, $force_notification) { static $notification_sent = array(); if (!empty($notification_sent[$order_info['order_id']][$order_info['status']]) && $notification_sent[$order_info['order_id']][$order_info['status']] || $order_info['status'] == STATUS_INCOMPLETED_ORDER || $order_info['status'] == STATUS_PARENT_ORDER) { return true; } $status_params = $order_statuses[$order_info['status']]; $notify_supplier = isset($force_notification['S']) ? $force_notification['S'] : (!empty($status_params['notify_supplier']) && $status_params['notify_supplier'] == 'Y' ? true : false); if ($notify_supplier == true) { $notification_sent[$order_info['order_id']][$order_info['status']] = true; $suppliers = array(); foreach ($order_info['items'] as $k => $v) { if (isset($v['company_id'])) { $suppliers[$v['company_id']] = 0; } } if (!empty($suppliers)) { if (!empty($order_info['shipping'])) { foreach ($order_info['shipping'] as $shipping_id => $shipping) { foreach ((array) $shipping['rates'] as $supplier_id => $rate) { if (isset($suppliers[$supplier_id])) { $suppliers[$supplier_id] += $rate; } } } } Registry::get('view_mail')->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], Registry::get('settings.Appearance.admin_default_language'))); Registry::get('view_mail')->assign('order_info', $order_info); Registry::get('view_mail')->assign('status_inventory', $order_statuses[$order_info['status']]['inventory']); foreach ($suppliers as $supplier_id => $shipping_cost) { if ($supplier_id != 0) { Registry::get('view_mail')->assign('shipping_cost', $shipping_cost); Registry::get('view_mail')->assign('supplier_id', $supplier_id); $supplier = fn_get_company_data($supplier_id); fn_send_mail($supplier['email'], Registry::get('settings.Company.company_orders_department'), 'orders/supplier_notification_subj.tpl', 'orders/supplier_notification.tpl', '', Registry::get('settings.Appearance.admin_default_language')); } } return true; } } return false; }
Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); Tygh::$app['view']->display('pickers/companies/picker_contents.tpl'); exit; } if (fn_allowed_for('MULTIVENDOR')) { if ($mode == 'merge') { if (!isset(Tygh::$app['session']['auth']['is_root']) || Tygh::$app['session']['auth']['is_root'] != 'Y' || Registry::get('runtime.company_id')) { return array(CONTROLLER_STATUS_DENIED); } if (empty($_REQUEST['company_id'])) { return array(CONTROLLER_STATUS_NO_PAGE); } $company_id = $_REQUEST['company_id']; unset($_REQUEST['company_id']); $company_data = !empty($company_id) ? fn_get_company_data($company_id) : array(); if (empty($company_data)) { return array(CONTROLLER_STATUS_NO_PAGE); } $_REQUEST['exclude_company_id'] = $company_id; list($companies, $search) = fn_get_companies($_REQUEST, $auth, Registry::get('settings.Appearance.admin_elements_per_page')); Tygh::$app['view']->assign('company_id', $company_id); Tygh::$app['view']->assign('company_name', $company_data['company']); Tygh::$app['view']->assign('companies', $companies); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); } elseif ($mode == 'balance') { list($payouts, $search, $total) = fn_companies_get_payouts($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page')); Tygh::$app['view']->assign('payouts', $payouts); Tygh::$app['view']->assign('search', $search);
function fn_get_manifest($area, $lang_code = CART_LANGUAGE, $company_id = 0) { $manifest = parse_ini_file(DIR_SKINS . Registry::get('settings.skin_name_' . $area) . '/' . SKIN_MANIFEST, true); $exclude_key = array('description', 'admin', 'customer'); if (defined('COMPANY_ID')) { $company_id = COMPANY_ID; } if ($company_id) { $company_data = fn_get_company_data($company_id, $lang_code); $logos = !empty($company_data['logos']) ? unserialize($company_data['logos']) : array(); $manifest = array_merge($manifest, $logos); } $alts = db_get_hash_single_array("SELECT object_holder, description FROM ?:common_descriptions WHERE object_id = ?i AND lang_code = ?s", array('object_holder', 'description'), $company_id, $lang_code); foreach ($manifest as $key => $val) { if (!in_array($key, $exclude_key) && isset($alts[$key])) { $manifest[$key]['alt'] = $alts[$key]; } } return $manifest; }
/** * Prepare all settings, wich should be passed to js */ function fn_twg_get_all_settings() { $settings = fn_twg_get_boot_settings(); $addon_settings = TwigmoSettings::get(); $settings['access_id'] = $addon_settings['access_id']; $settings['currency'] = Registry::get('currencies.' . CART_SECONDARY_CURRENCY); $settings['primaryCurrency'] = Registry::get('currencies.' . CART_PRIMARY_CURRENCY); $settings['url_for_facebook'] = isset($addon_settings['url_for_facebook']) ? fn_twg_get_external_info_url($addon_settings['url_for_facebook']) : ''; $settings['url_for_twitter'] = isset($addon_settings['url_for_twitter']) ? fn_twg_get_external_info_url($addon_settings['url_for_twitter']) : ''; $settings['lang'] = array_merge(fn_twg_get_default_customer_langvars(), Lang::getCustomerLangVars()); // Countries/states list($countries) = fn_get_countries(array('only_avail' => true)); $settings = array_merge($settings, Api::getAsList('countries', $countries)); $settings['states'] = fn_twg_get_states(); // Info pages $pages_location = $addon_settings['home_page_content'] == 'tw_home_page_blocks' ? 'twigmo.post' : 'index.index'; $pages = TwigmoBlock::getBlocksForLocation($pages_location, array('pages')); $settings['info_pages'] = array(); foreach ($pages as $page) { $settings['info_pages'] = array_merge($settings['info_pages'], $page['pages']['page']); } // If page link begin with # then interpret this link as twigmo page foreach ($settings['info_pages'] as $k => $page) { if (preg_match('/^\\#.*$/', $page['link'])) { $settings['info_pages'][$k]['twigmo_page'] = substr($page['link'], 1); } } // Only required profile fields $only_required = isset($addon_settings['only_req_profile_fields']) ? $addon_settings['only_req_profile_fields'] : 'N'; $settings['profileFields'] = fn_twg_prepare_profile_fields(fn_get_profile_fields(), $only_required); $settings['profileFieldsCheckout'] = fn_twg_prepare_profile_fields(fn_get_profile_fields('O'), $only_required); $settings['show_product_code'] = isset($addon_settings['show_product_code']) ? $addon_settings['show_product_code'] : 'N'; $settings['titles'] = array(); $settings['profile'] = fn_twg_get_user_info($_SESSION['auth']['user_id']); $settings['cart'] = fn_twg_api_get_session_cart($_SESSION['cart']); $settings['sortings'] = fn_twg_get_sortings(); $settings['security_hash'] = fn_generate_security_hash(); $settings['productType'] = PRODUCT_EDITION; $settings['languages'] = array_values(Lang::getLanguages()); $settings['cart_language'] = CART_LANGUAGE; $settings['cart_prices_w_taxes'] = Registry::get('settings.Appearance.cart_prices_w_taxes'); $settings['show_prices_taxed_clean'] = Registry::get('settings.Appearance.show_prices_taxed_clean'); $settings['no_image_path'] = Registry::get('config.no_image_path'); // Suppliers $settings['suppliers_vendor'] = Registry::get('settings.Suppliers.apply_for_vendor'); $settings['display_supplier'] = Registry::get('settings.Suppliers.display_supplier') === 'Y' || Registry::get('settings.Vendors.display_vendor') === 'Y'; $settings['display_supplier'] = $settings['display_supplier'] ? 'Y' : 'N'; // General section $fields = array('use_email_as_login', 'min_order_amount', 'min_order_amount_type', 'allow_negative_amount', 'inventory_tracking', 'allow_anonymous_shopping', 'tax_calculation'); foreach ($fields as $field) { $settings[$field] = Registry::get('settings.General.' . $field); } $settings = array_merge($settings, fn_twg_get_checkout_settings()); if (version_compare(PRODUCT_VERSION, '4.0.2', '>=')) { $anonymous_shopping_settings_map = array('allow_shopping' => 'Y', 'hide_price_and_add_to_cart' => 'P', 'hide_add_to_cart' => 'B'); $settings['allow_anonymous_shopping'] = $anonymous_shopping_settings_map[$settings['allow_anonymous_shopping']]; } $settings['default_location'] = array('country' => Registry::get('settings.General.default_country'), 'state' => Registry::get('settings.General.default_state')); $settings['show_modifiers'] = Registry::get('settings.General.display_options_modifiers'); $settings['SEOEnabled'] = Registry::get('addons.seo.status') == 'A'; $settings['GATrackEcommerce'] = Registry::get('addons.google_analytics.status') == 'A' && Registry::get('addons.google_analytics.track_ecommerce') == 'Y' && file_exists(Registry::get('config.dir.addons') . 'google_analytics/controllers/frontend/checkout.post.php'); if (fn_allowed_for('MULTIVENDOR')) { $settings['company_data'] = !empty($_SESSION['auth']['company_id']) ? fn_get_company_data($_SESSION['auth']['company_id']) : array(); } else { $settings['company_data'] = array(); } $settings['checkout'] = Registry::get('settings.Checkout'); fn_set_hook('twg_get_all_settings', $settings); $settings['lang'] = fn_twg_process_langvars($settings['lang']); return $settings; }
function content_55ccf7c33c4939_75303952($_smarty_tpl) { if (!is_callable('smarty_block_hook')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/block.hook.php'; } if (!is_callable('smarty_modifier_unpuny')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/modifier.unpuny.php'; } fn_preload_lang_vars(array('previous_period', 'current_period', 'orders', 'sales', 'taxes', 'users_carts', 'order', 'by', 'no_data', 'recent_orders', 'statistics', 'active_products', 'out_of_stock_products', 'registered_customers', 'categories', 'vendors', 'web_pages', 'order_by_status', 'status', 'qty', 'shipping', 'recent_activity', 'order', 'dashboard', 'installer_complete_title', 'welcome_screen.administrator_info', 'admin_panel', 'welcome_screen.go_admin_panel', 'welcome_screen.go_settings_wizard', 'settings_wizard', 'welcome_screen.run_settings_wizard', 'storefront', 'welcome_screen.go_storefront', 'welcome_screen.learn_more_configuration', 'welcome_screen.knowledge_base', 'welcome_screen.thanks')); $_smarty_tpl->_capture_stack[0][] = array("mainbox", null, null); ob_start(); $_smarty_tpl->tpl_vars["show_latest_orders"] = new Smarty_variable(fn_check_permissions("orders", 'manage', 'admin'), null, 0); $_smarty_tpl->tpl_vars["show_orders"] = new Smarty_variable(fn_check_permissions("sales_reports", 'reports', 'admin'), null, 0); $_smarty_tpl->tpl_vars["show_inventory"] = new Smarty_variable(fn_check_permissions("products", 'manage', 'admin'), null, 0); $_smarty_tpl->tpl_vars["show_users"] = new Smarty_variable(fn_check_permissions("profiles", 'manage', 'admin'), null, 0); ?> <?php $_smarty_tpl->tpl_vars["user_can_view_orders"] = new Smarty_variable(fn_check_view_permissions("orders.manage", 'GET'), null, 0); ?> <script type="text/javascript"> (function(_, $) { _.drawChart = function(is_day) { if (typeof google == "undefined") { return false; } function get_data(div) { var id = $(div).attr('id'); var dataTable = new google.visualization.DataTable(); if (is_day) { dataTable.addColumn('timeofday', 'Date'); } else { dataTable.addColumn('date', 'Date'); } dataTable.addColumn('number', '<?php echo $_smarty_tpl->__("previous_period"); ?> '); dataTable.addColumn('number', '<?php echo $_smarty_tpl->__("current_period"); ?> '); dataTable.addRows(_.chart_data[id]); var dataView = new google.visualization.DataView(dataTable); dataView.setColumns([0, 1, 2]); return dataView; } var options = { chartArea: { left: 7, top: 10, width: 556, height: 208 }, colors: ['#f491a5','#8fd1ff'], tooltip: { showColorCode: true }, lineWidth: 4, hAxis: { baselineColor: '#e1e1e1', textStyle: { color: '#a1a1a1', fontSize: 11 }, gridlines: { count: 6 } }, legend: { position: 'none' }, pointSize: 10, vAxis: { minValue: 0, baselineColor: '#e1e1e1', textPosition: 'in', textStyle: { color: '#a1a1a1', fontSize: 11 }, gridlines: { count: 10 } } }; if (!is_day) { options.hAxis.format = 'MMM d'; } $('.dashboard-statistics-chart:visible').each(function(i, div) { var dataView = get_data(div); var chart = new google.visualization.AreaChart(div); chart.draw(dataView, options); }); $('#statistics_tabs .tabs li').on('click', function() { $('.dashboard-statistics-chart:visible').each(function(i, div) { var dataView = get_data(div); var chart = new google.visualization.AreaChart(div); chart.draw(dataView, options); }); }); } $(document).ready(function() { $.getScript('//www.google.com/jsapi', function() { setTimeout(function() { // do not remove it - otherwise it will be slow in ff google.load('visualization', '1.0', { packages: ['corechart'], callback: function() { _.drawChart(<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['is_day']->value, ENT_QUOTES, 'UTF-8'); ?> ); } }); }, 0); }); }); }(Tygh, Tygh.$)); </script> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:index")); $_block_repeat = true; echo smarty_block_hook(array('name' => "index:index"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); ?> <div class="dashboard" id="dashboard"> <table class="dashboard-card-table"> <tbody> <tr> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:finance_statistic")); $_block_repeat = true; echo smarty_block_hook(array('name' => "index:finance_statistic"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); ?> <?php if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['orders'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("orders"); ?> </div> <div class="dashboard-card-content"> <h3> <?php if ($_smarty_tpl->tpl_vars['user_can_view_orders']->value) { ?> <a href="<?php echo htmlspecialchars(fn_url("orders.manage?is_search=Y&period=C&time_from=" . (string) $_smarty_tpl->tpl_vars['time_from']->value . "&time_to=" . (string) $_smarty_tpl->tpl_vars['time_to']->value), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars(count($_smarty_tpl->tpl_vars['orders_stat']->value['orders']), ENT_QUOTES, 'UTF-8'); ?> </a> <?php } else { ?> <?php echo htmlspecialchars(count($_smarty_tpl->tpl_vars['orders_stat']->value['orders']), ENT_QUOTES, 'UTF-8'); ?> <?php } ?> </h3> <?php echo htmlspecialchars(count($_smarty_tpl->tpl_vars['orders_stat']->value['prev_orders']), ENT_QUOTES, 'UTF-8'); ?> , <?php if ($_smarty_tpl->tpl_vars['orders_stat']->value['diff']['orders_count'] > 0) { ?> +<?php } echo htmlspecialchars($_smarty_tpl->tpl_vars['orders_stat']->value['diff']['orders_count'], ENT_QUOTES, 'UTF-8'); ?> </div> </div> </td> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['orders_total'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("sales"); ?> </div> <div class="dashboard-card-content"> <h3><?php echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['orders_total']['totally_paid']), 0); ?> </h3><?php echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['prev_orders_total']['totally_paid']), 0); ?> , <?php if ($_smarty_tpl->tpl_vars['orders_stat']->value['orders_total']['totally_paid'] > $_smarty_tpl->tpl_vars['orders_stat']->value['prev_orders_total']['totally_paid']) { ?> +<?php } echo $_smarty_tpl->tpl_vars['orders_stat']->value['diff']['sales']; ?> % </div> </div> </td> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['taxes'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("taxes"); ?> </div> <div class="dashboard-card-content"> <h3><?php echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['subtotal']), 0); ?> </h3><?php echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['prev_subtotal']), 0); ?> , <?php if ($_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['subtotal'] > $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['prev_subtotal']) { ?> +<?php } echo $_smarty_tpl->tpl_vars['orders_stat']->value['taxes']['diff']; ?> % </div> </div> </td> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['orders_stat']->value['abandoned_cart_total'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("users_carts"); ?> </div> <div class="dashboard-card-content"> <h3><?php echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['orders_stat']->value['abandoned_cart_total']) === null || $tmp === '' ? 0 : $tmp, ENT_QUOTES, 'UTF-8'); ?> </h3><?php echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['orders_stat']->value['prev_abandoned_cart_total']) === null || $tmp === '' ? 0 : $tmp, ENT_QUOTES, 'UTF-8'); ?> , <?php if ($_smarty_tpl->tpl_vars['orders_stat']->value['abandoned_cart_total'] > $_smarty_tpl->tpl_vars['orders_stat']->value['prev_abandoned_cart_total']) { ?> +<?php } echo $_smarty_tpl->tpl_vars['orders_stat']->value['diff']['abandoned_carts']; ?> % </div> </div> </td> <?php } ?> <?php $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "index:finance_statistic"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> </tr> </tbody> </table> <?php if (!is_callable('smarty_modifier_date_format')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/modifier.date_format.php'; } if (!function_exists('smarty_template_function_get_orders')) { function smarty_template_function_get_orders($_smarty_tpl, $params) { $saved_tpl_vars = $_smarty_tpl->tpl_vars; foreach ($_smarty_tpl->smarty->template_functions['get_orders']['parameter'] as $key => $value) { $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value); } foreach ($params as $key => $value) { $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value); } ?> <?php $_smarty_tpl->tpl_vars['params'] = new Smarty_variable(array('status' => $_smarty_tpl->tpl_vars['status']->value, 'time_from' => $_smarty_tpl->tpl_vars['time_from']->value, 'time_to' => $_smarty_tpl->tpl_vars['time_to']->value, 'period' => 'C'), null, 0); ?> <?php $_smarty_tpl->tpl_vars['orders'] = new Smarty_variable(fn_get_orders($_smarty_tpl->tpl_vars['params']->value, $_smarty_tpl->tpl_vars['limit']->value), null, 0); ?> <table class="table table-middle table-last-td-align-right"> <tbody> <?php $_smarty_tpl->tpl_vars["order"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["order"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['orders']->value[0]; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars["order"]->key => $_smarty_tpl->tpl_vars["order"]->value) { $_smarty_tpl->tpl_vars["order"]->_loop = true; ?> <tr> <td> <span class="label btn-info o-status-<?php echo htmlspecialchars(mb_strtolower($_smarty_tpl->tpl_vars['order']->value['status'], 'UTF-8'), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['order_statuses']->value[$_smarty_tpl->tpl_vars['order']->value['status']]['description'], ENT_QUOTES, 'UTF-8'); ?> </span> </td> <td><a href="<?php echo htmlspecialchars(fn_url("orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['order']->value['order_id']), ENT_QUOTES, 'UTF-8'); ?> "><?php echo $_smarty_tpl->__("order"); ?> #<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['order']->value['order_id'], ENT_QUOTES, 'UTF-8'); ?> </a> <?php echo $_smarty_tpl->__("by"); ?> <?php if ($_smarty_tpl->tpl_vars['order']->value['user_id']) { ?> <a href="<?php echo htmlspecialchars(fn_url("profiles.update?user_id=" . (string) $_smarty_tpl->tpl_vars['order']->value['user_id']), ENT_QUOTES, 'UTF-8'); ?> "><?php } echo htmlspecialchars($_smarty_tpl->tpl_vars['order']->value['lastname'], ENT_QUOTES, 'UTF-8'); ?> <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['order']->value['firstname'], ENT_QUOTES, 'UTF-8'); if ($_smarty_tpl->tpl_vars['order']->value['user_id']) { ?> </a><?php } ?> </td> <td><span class="date"><?php echo htmlspecialchars(smarty_modifier_date_format($_smarty_tpl->tpl_vars['order']->value['timestamp'], (string) $_smarty_tpl->tpl_vars['settings']->value['Appearance']['date_format'] . ", " . (string) $_smarty_tpl->tpl_vars['settings']->value['Appearance']['time_format']), ENT_QUOTES, 'UTF-8'); ?> </span></td> <td><h4><?php echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['order']->value['total']), 0); ?> </h4></td> </tr> <?php } if (!$_smarty_tpl->tpl_vars["order"]->_loop) { ?> <tr><td><?php echo $_smarty_tpl->__("no_data"); ?> </td></tr> <?php } ?> </tbody> </table> <?php $_smarty_tpl->tpl_vars = $saved_tpl_vars; foreach (Smarty::$global_tpl_vars as $key => $value) { if (!isset($_smarty_tpl->tpl_vars[$key])) { $_smarty_tpl->tpl_vars[$key] = $value; } } } } ?> <div class="dashboard-row"> <?php if (!empty($_smarty_tpl->tpl_vars['order_statuses']->value)) { ?> <div class="dashboard-recent-orders cm-j-tabs tabs" data-ca-width="500"> <h4><?php echo $_smarty_tpl->__("recent_orders"); ?> </h4> <ul class="nav nav-pills"> <li id="tab_recent_all" class="active cm-js"><a href="#status_all" data-toggle="tab">All</a></li> <?php $_smarty_tpl->tpl_vars["status"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["status"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['order_statuses']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars["status"]->key => $_smarty_tpl->tpl_vars["status"]->value) { $_smarty_tpl->tpl_vars["status"]->_loop = true; ?> <li id="tab_recent_<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['status'], ENT_QUOTES, 'UTF-8'); ?> " class="cm-js"><a href="#status_<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['status'], ENT_QUOTES, 'UTF-8'); ?> " data-toggle="tab"><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['description'], ENT_QUOTES, 'UTF-8'); ?> </a></li> <?php } ?> </ul> <div class="tab-content cm-tabs-content"> <div class="tab-pane" id="content_tab_recent_all"> <?php smarty_template_function_get_orders($_smarty_tpl, array('status' => '')); ?> </div> <?php $_smarty_tpl->tpl_vars["status"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["status"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['order_statuses']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars["status"]->key => $_smarty_tpl->tpl_vars["status"]->value) { $_smarty_tpl->tpl_vars["status"]->_loop = true; ?> <div class="tab-pane" id="content_tab_recent_<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['status']->value['status'], ENT_QUOTES, 'UTF-8'); ?> "> <?php smarty_template_function_get_orders($_smarty_tpl, array('status' => $_smarty_tpl->tpl_vars['status']->value['status'])); ?> </div> <?php } ?> </div> </div> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['graphs']->value)) { ?> <div class="dashboard-statistics"> <h4> <?php echo $_smarty_tpl->__("statistics"); ?> </h4> <?php $_smarty_tpl->_capture_stack[0][] = array("chart_tabs", null, null); ob_start(); ?> <div id="content_sales_chart"> <div id="dashboard_statistics_sales_chart" class="dashboard-statistics-chart spinner"> </div> </div> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:chart_statistic")); $_block_repeat = true; echo smarty_block_hook(array('name' => "index:chart_statistic"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); ?> <?php $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "index:chart_statistic"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]); if (!empty($_capture_buffer)) { if (isset($_capture_assign)) { $_smarty_tpl->assign($_capture_assign, ob_get_contents()); } if (isset($_capture_append)) { $_smarty_tpl->append($_capture_append, ob_get_contents()); } Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean(); } else { $_smarty_tpl->capture_error(); } ?> <div id="statistics_tabs"> <?php echo $_smarty_tpl->getSubTemplate("common/tabsbox.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('content' => Smarty::$_smarty_vars['capture']['chart_tabs']), 0); ?> <script> Tygh.chart_data = { <?php $_smarty_tpl->tpl_vars["graph"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["graph"]->_loop = false; $_smarty_tpl->tpl_vars["chart"] = new Smarty_Variable(); $_from = $_smarty_tpl->tpl_vars['graphs']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } $_smarty_tpl->tpl_vars["graph"]->total = $_smarty_tpl->_count($_from); $_smarty_tpl->tpl_vars["graph"]->iteration = 0; foreach ($_from as $_smarty_tpl->tpl_vars["graph"]->key => $_smarty_tpl->tpl_vars["graph"]->value) { $_smarty_tpl->tpl_vars["graph"]->_loop = true; $_smarty_tpl->tpl_vars["chart"]->value = $_smarty_tpl->tpl_vars["graph"]->key; $_smarty_tpl->tpl_vars["graph"]->iteration++; $_smarty_tpl->tpl_vars["graph"]->last = $_smarty_tpl->tpl_vars["graph"]->iteration === $_smarty_tpl->tpl_vars["graph"]->total; $_smarty_tpl->tpl_vars['smarty']->value['foreach']["graphs"]['last'] = $_smarty_tpl->tpl_vars["graph"]->last; ?> '<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['chart']->value, ENT_QUOTES, 'UTF-8'); ?> ': [ <?php $_smarty_tpl->tpl_vars["data"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["data"]->_loop = false; $_smarty_tpl->tpl_vars["date"] = new Smarty_Variable(); $_from = $_smarty_tpl->tpl_vars['graph']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } $_smarty_tpl->tpl_vars["data"]->total = $_smarty_tpl->_count($_from); $_smarty_tpl->tpl_vars["data"]->iteration = 0; foreach ($_from as $_smarty_tpl->tpl_vars["data"]->key => $_smarty_tpl->tpl_vars["data"]->value) { $_smarty_tpl->tpl_vars["data"]->_loop = true; $_smarty_tpl->tpl_vars["date"]->value = $_smarty_tpl->tpl_vars["data"]->key; $_smarty_tpl->tpl_vars["data"]->iteration++; $_smarty_tpl->tpl_vars["data"]->last = $_smarty_tpl->tpl_vars["data"]->iteration === $_smarty_tpl->tpl_vars["data"]->total; $_smarty_tpl->tpl_vars['smarty']->value['foreach']["graph"]['last'] = $_smarty_tpl->tpl_vars["data"]->last; ?> [<?php if ($_smarty_tpl->tpl_vars['is_day']->value) { ?> [<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['date']->value, ENT_QUOTES, 'UTF-8'); ?> , 0, 0, 0]<?php } else { ?> new Date(<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['date']->value, ENT_QUOTES, 'UTF-8'); ?> )<?php } ?> , <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data']->value['prev'], ENT_QUOTES, 'UTF-8'); ?> , <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data']->value['cur'], ENT_QUOTES, 'UTF-8'); ?> ]<?php if (!$_smarty_tpl->getVariable('smarty')->value['foreach']['graph']['last']) { ?> ,<?php } ?> <?php } ?> ]<?php if (!$_smarty_tpl->getVariable('smarty')->value['foreach']['graphs']['last']) { ?> ,<?php } ?> <?php } ?> }; Tygh.drawChart(<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['is_day']->value, ENT_QUOTES, 'UTF-8'); ?> ); </script> <!--statistics_tabs--></div> </div> <?php } ?> </div> <div class="dashboard-row-bottom"> <div class="dashboard-tables"> <table class="dashboard-card-table dashboard-card-table-center nowrap"> <tbody> <tr> <?php if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['products'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("active_products"); ?> </div> <div class="dashboard-card-content"> <h3><a href="<?php echo htmlspecialchars(fn_url("products.manage?status=A"), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['products']['total_products']), ENT_QUOTES, 'UTF-8'); ?> </a></h3> </div> </div> </td> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("out_of_stock_products"); ?> </div> <div class="dashboard-card-content"> <h3><a href="<?php echo htmlspecialchars(fn_url("products.manage?amount_from=&amount_to=0&tracking[0]=B&tracking[1]=O"), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['products']['out_of_stock_products']), ENT_QUOTES, 'UTF-8'); ?> </a></h3> </div> </div> </td> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['customers'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("registered_customers"); ?> </div> <div class="dashboard-card-content"> <h3><a href="<?php echo htmlspecialchars(fn_url("profiles.manage?user_type=C"), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['customers']['registered_customers']), ENT_QUOTES, 'UTF-8'); ?> </a></h3> </div> </div> </td> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['categories'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("categories"); ?> </div> <div class="dashboard-card-content"> <h3><a href="<?php echo htmlspecialchars(fn_url("categories.manage"), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['categories']['total_categories']), ENT_QUOTES, 'UTF-8'); ?> </a></h3> </div> </div> </td> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['companies'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("vendors"); ?> </div> <div class="dashboard-card-content"> <h3><a href="<?php echo htmlspecialchars(fn_url("companies.manage"), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['companies']['total_companies']), ENT_QUOTES, 'UTF-8'); ?> </a></h3> </div> </div> </td> <?php } ?> <?php if (!empty($_smarty_tpl->tpl_vars['general_stats']->value['pages'])) { ?> <td> <div class="dashboard-card"> <div class="dashboard-card-title"><?php echo $_smarty_tpl->__("web_pages"); ?> </div> <div class="dashboard-card-content"> <h3><a href="<?php echo htmlspecialchars(fn_url("pages.manage"), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars(number_format($_smarty_tpl->tpl_vars['general_stats']->value['pages']['total_pages']), ENT_QUOTES, 'UTF-8'); ?> </a></h3> </div> </div> </td> <?php } ?> </tr> </tbody> </table> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:order_statistic")); $_block_repeat = true; echo smarty_block_hook(array('name' => "index:order_statistic"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); ?> <?php $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "index:order_statistic"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php if ($_smarty_tpl->tpl_vars['user_can_view_orders']->value) { ?> <div class="dashboard-table dashboard-table-order-by-statuses"> <h4><?php echo $_smarty_tpl->__("order_by_status"); ?> </h4> <div class="table-wrap" id="dashboard_order_by_status"> <table class="table"> <thead> <tr> <th width="25%"><?php echo $_smarty_tpl->__("status"); ?> </th> <th width="25%"><?php echo $_smarty_tpl->__("qty"); ?> </th> <th width="25%"><?php echo $_smarty_tpl->__('total'); ?> </th> <th width="25%"><?php echo $_smarty_tpl->__("shipping"); ?> </th> </tr> </thead> </table> <div class="scrollable-table"> <table class="table table-striped"> <tbody> <?php $_smarty_tpl->tpl_vars["order_status"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["order_status"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['order_by_statuses']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars["order_status"]->key => $_smarty_tpl->tpl_vars["order_status"]->value) { $_smarty_tpl->tpl_vars["order_status"]->_loop = true; ?> <?php $_smarty_tpl->tpl_vars['url'] = new Smarty_variable(fn_url("orders.manage?is_search=Y&period=C&time_from=" . (string) $_smarty_tpl->tpl_vars['time_from']->value . "&time_to=" . (string) $_smarty_tpl->tpl_vars['time_to']->value . "&status[]=" . (string) $_smarty_tpl->tpl_vars['order_status']->value['status']), null, 0); ?> <tr> <td width="25%"><a href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['url']->value, ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['order_status']->value['status_name'], ENT_QUOTES, 'UTF-8'); ?> </a></td> <td width="25%"><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['order_status']->value['count'], ENT_QUOTES, 'UTF-8'); ?> </td> <td width="25%"><?php echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['order_status']->value['total']), 0); ?> </td> <td width="25%"><?php echo $_smarty_tpl->getSubTemplate("common/price.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('value' => $_smarty_tpl->tpl_vars['order_status']->value['shipping']), 0); ?> </td> </tr> <?php } ?> </tbody> </table> </div> <!--dashboard_order_by_status--></div> </div> <?php } ?> </div> <?php if (fn_check_view_permissions("logs.manage", "GET")) { ?> <div class="dashboard-activity"> <div class="pull-right"><a href="<?php echo htmlspecialchars(fn_url("logs.manage"), ENT_QUOTES, 'UTF-8'); ?> "><?php echo $_smarty_tpl->__('show_all'); ?> </a></div> <h4><?php echo $_smarty_tpl->__("recent_activity"); ?> </h4> <?php if (!is_callable('smarty_block_hook')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/block.hook.php'; } if (!is_callable('smarty_modifier_date_format')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/modifier.date_format.php'; } if (!function_exists('smarty_template_function_show_log_row')) { function smarty_template_function_show_log_row($_smarty_tpl, $params) { $saved_tpl_vars = $_smarty_tpl->tpl_vars; foreach ($_smarty_tpl->smarty->template_functions['show_log_row']['parameter'] as $key => $value) { $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value); } foreach ($params as $key => $value) { $_smarty_tpl->tpl_vars[$key] = new Smarty_variable($value); } ?> <?php if ($_smarty_tpl->tpl_vars['item']->value) { ?> <div class="item"> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:recent_activity")); $_block_repeat = true; echo smarty_block_hook(array('name' => "index:recent_activity"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); ?> <?php $_smarty_tpl->tpl_vars['_type'] = new Smarty_variable("log_type_" . (string) $_smarty_tpl->tpl_vars['item']->value['type'], null, 0); ?> <?php $_smarty_tpl->tpl_vars['_action'] = new Smarty_variable("log_action_" . (string) $_smarty_tpl->tpl_vars['item']->value['action'], null, 0); ?> <?php echo $_smarty_tpl->__($_smarty_tpl->tpl_vars['_type']->value); if ($_smarty_tpl->tpl_vars['item']->value['action']) { ?> (<?php echo $_smarty_tpl->__($_smarty_tpl->tpl_vars['_action']->value); ?> )<?php } ?> : <?php if ($_smarty_tpl->tpl_vars['item']->value['type'] == "users" && fn_check_view_permissions(fn_url("profiles.update?user_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) { ?> <?php if ($_smarty_tpl->tpl_vars['item']->value['content']['id']) { ?> <a href="<?php echo htmlspecialchars(fn_url("profiles.update?user_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8'); ?> "><?php } echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['user'], ENT_QUOTES, 'UTF-8'); if ($_smarty_tpl->tpl_vars['item']->value['content']['id']) { ?> </a><?php } ?> <br> <?php } elseif ($_smarty_tpl->tpl_vars['item']->value['type'] == "orders" && fn_check_view_permissions(fn_url("orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) { ?> <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['status'], ENT_QUOTES, 'UTF-8'); ?> <br> <a href="<?php echo htmlspecialchars(fn_url("orders.details?order_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8'); ?> "><?php echo $_smarty_tpl->__("order"); ?> <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['order'], ENT_QUOTES, 'UTF-8'); ?> </a><br> <?php } elseif ($_smarty_tpl->tpl_vars['item']->value['type'] == "products" && fn_check_view_permissions(fn_url("products.update?product_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) { ?> <a href="<?php echo htmlspecialchars(fn_url("products.update?product_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['product'], ENT_QUOTES, 'UTF-8'); ?> </a><br> <?php } elseif ($_smarty_tpl->tpl_vars['item']->value['type'] == "categories" && fn_check_view_permissions(fn_url("categories.update?category_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), "GET")) { ?> <a href="<?php echo htmlspecialchars(fn_url("categories.update?category_id=" . (string) $_smarty_tpl->tpl_vars['item']->value['content']['id']), ENT_QUOTES, 'UTF-8'); ?> "><?php echo htmlspecialchars($_smarty_tpl->tpl_vars['item']->value['content']['category'], ENT_QUOTES, 'UTF-8'); ?> </a><br> <?php } ?> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:recent_activity_item")); $_block_repeat = true; echo smarty_block_hook(array('name' => "index:recent_activity_item"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "index:recent_activity_item"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <span class="date"><?php echo htmlspecialchars(smarty_modifier_date_format($_smarty_tpl->tpl_vars['item']->value['timestamp'], (string) $_smarty_tpl->tpl_vars['settings']->value['Appearance']['date_format'] . ", " . (string) $_smarty_tpl->tpl_vars['settings']->value['Appearance']['time_format']), ENT_QUOTES, 'UTF-8'); ?> </span> <?php $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "index:recent_activity"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> </div> <?php } ?> <?php $_smarty_tpl->tpl_vars = $saved_tpl_vars; foreach (Smarty::$global_tpl_vars as $key => $value) { if (!isset($_smarty_tpl->tpl_vars[$key])) { $_smarty_tpl->tpl_vars[$key] = $value; } } } } ?> <div class="dashboard-activity-list"> <?php $_smarty_tpl->tpl_vars["item"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["item"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['logs']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars["item"]->key => $_smarty_tpl->tpl_vars["item"]->value) { $_smarty_tpl->tpl_vars["item"]->_loop = true; ?> <?php smarty_template_function_show_log_row($_smarty_tpl, array('item' => $_smarty_tpl->tpl_vars['item']->value)); ?> <?php } ?> </div> </div> <?php } ?> </div> <!--dashboard--></div> <?php $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "index:index"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php $_smarty_tpl->_capture_stack[0][] = array("buttons", null, null); ob_start(); ?> <?php echo $_smarty_tpl->getSubTemplate("common/daterange_picker.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('id' => "dashboard_date_picker", 'extra_class' => "pull-right offset1", 'data_url' => fn_url("index.index"), 'result_ids' => "dashboard", 'start_date' => $_smarty_tpl->tpl_vars['time_from']->value, 'end_date' => $_smarty_tpl->tpl_vars['time_to']->value), 0); ?> <?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]); if (!empty($_capture_buffer)) { if (isset($_capture_assign)) { $_smarty_tpl->assign($_capture_assign, ob_get_contents()); } if (isset($_capture_append)) { $_smarty_tpl->append($_capture_append, ob_get_contents()); } Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean(); } else { $_smarty_tpl->capture_error(); } list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]); if (!empty($_capture_buffer)) { if (isset($_capture_assign)) { $_smarty_tpl->assign($_capture_assign, ob_get_contents()); } if (isset($_capture_append)) { $_smarty_tpl->append($_capture_append, ob_get_contents()); } Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean(); } else { $_smarty_tpl->capture_error(); } ?> <?php echo $_smarty_tpl->getSubTemplate("common/mainbox.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('buttons' => Smarty::$_smarty_vars['capture']['buttons'], 'no_sidebar' => true, 'title' => __("dashboard"), 'content' => Smarty::$_smarty_vars['capture']['mainbox'], 'tools' => Smarty::$_smarty_vars['capture']['tools']), 0); ?> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "index:welcome_dialog")); $_block_repeat = true; echo smarty_block_hook(array('name' => "index:welcome_dialog"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); ?> <?php if ($_smarty_tpl->tpl_vars['show_welcome']->value) { ?> <div class="hidden cm-dialog-auto-open cm-dialog-auto-size" title="<?php echo $_smarty_tpl->__("installer_complete_title"); ?> " id="after_install_dialog" data-ca-dialog-class="welcome-screen-dialog"> <?php $_smarty_tpl->tpl_vars["company"] = new Smarty_variable(fn_get_company_data("1"), null, 0); ?> <?php if (fn_allowed_for("ULTIMATE")) { ?> <?php ob_start(); echo htmlspecialchars(smarty_modifier_unpuny($_smarty_tpl->tpl_vars['company']->value['storefront']), ENT_QUOTES, 'UTF-8'); $_tmp1 = ob_get_clean(); $_smarty_tpl->tpl_vars['link_storefront'] = new Smarty_variable("http://" . $_tmp1, null, 0); ?> <?php } else { ?> <?php ob_start(); echo htmlspecialchars(fn_url($_smarty_tpl->tpl_vars['config']->value['http_location']), ENT_QUOTES, 'UTF-8'); $_tmp2 = ob_get_clean(); $_smarty_tpl->tpl_vars['link_storefront'] = new Smarty_variable($_tmp2, null, 0); ?> <?php } ?> <div class="welcome-screen"> <p> <?php $_smarty_tpl->tpl_vars['user_data'] = new Smarty_variable(fn_get_user_info($_smarty_tpl->tpl_vars['auth']->value['user_id']), null, 0); ?> <?php echo $_smarty_tpl->__("welcome_screen.administrator_info", array('[email]' => $_smarty_tpl->tpl_vars['user_data']->value['email'])); ?> </p> <div class="welcome-location-wrapper clearfix"> <div class="welcome-location-block pull-left center"> <h4 class="install-title"><?php echo $_smarty_tpl->__("admin_panel"); ?> </h4> <div class="welcome-screen-location welcome-screen-admin"> <div class="welcome-screen-overlay"> <a class="btn cm-dialog-closer welcome-screen-overlink"><?php echo $_smarty_tpl->__("welcome_screen.go_admin_panel"); ?> </a> </div> </div> <div class="welcome-screen-arrow"></div> <p> <?php echo $_smarty_tpl->__("welcome_screen.go_settings_wizard"); ?> </p> <?php $_smarty_tpl->tpl_vars['c_url'] = new Smarty_variable(rawurlencode($_smarty_tpl->tpl_vars['config']->value['current_url']), null, 0); ?> <a class="cm-dialog-opener cm-ajax btn btn-primary strong" data-ca-target-id="content_settings_wizard" title="<?php echo $_smarty_tpl->__("settings_wizard"); ?> " href="<?php echo htmlspecialchars(fn_url("settings_wizard.view?return_url=" . (string) $_smarty_tpl->tpl_vars['c_url']->value), ENT_QUOTES, 'UTF-8'); ?> " target="_blank"><?php echo $_smarty_tpl->__("welcome_screen.run_settings_wizard"); ?> </a> </div> <div class="welcome-location-block pull-right center"> <h4 class="install-title"><?php echo $_smarty_tpl->__("storefront"); ?> </h4> <div class="welcome-screen-location welcome-screen-store"> <div class="welcome-screen-overlay"> <a class="btn welcome-screen-overlink" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['link_storefront']->value, ENT_QUOTES, 'UTF-8'); ?> " target="_blank"><?php echo $_smarty_tpl->__("welcome_screen.go_storefront"); ?> </a> </div> </div> <div class="welcome-screen-arrow"></div> <p> <?php echo $_smarty_tpl->__("welcome_screen.learn_more_configuration"); ?> </p> <a class="kbase-link" href="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['config']->value['resources']['knowledge_base'], ENT_QUOTES, 'UTF-8'); ?> " target="_blank"><?php echo $_smarty_tpl->__("welcome_screen.knowledge_base"); ?> </a> </div> </div> <div class="welcome-screen-social center"> <p> <?php echo $_smarty_tpl->__("welcome_screen.thanks", array("[product]" => @constant('PRODUCT_NAME'))); ?> </p> <?php echo $_smarty_tpl->getSubTemplate("common/share.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array(), 0); ?> </div> </div> </div> <?php } $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "index:welcome_dialog"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <?php }
$lang_code = $_REQUEST['language']; } } $mode = Registry::get('runtime.mode'); $meta = fn_twg_init_api_meta($response); $is_cache_request = isset($_GET['get_cache_js']) && in_array($meta['action'], array('get', 'details')); if (($_SERVER['REQUEST_METHOD'] == 'POST' || $is_cache_request) && $mode == 'post') { if ($meta['action'] == 'login') { $login = !empty($_REQUEST['login']) ? $_REQUEST['login'] : ''; $password = !empty($_REQUEST['password']) ? $_REQUEST['password'] : ''; if (!($user_data = fn_twg_api_customer_login($login, $password))) { $response->addError('ERROR_CUSTOMER_LOGIN_FAIL', __('error_incorrect_login')); } $profile = fn_twg_get_user_info($user_data['user_id']); if (fn_allowed_for('MULTIVENDOR')) { $profile['company_data'] = !empty($_SESSION['auth']['company_id']) ? fn_get_company_data($_SESSION['auth']['company_id']) : array(); } else { $profile['company_data'] = array(); } $_profile = array_merge($profile, array('cart' => fn_twg_api_get_session_cart($_SESSION['cart'], $lang_code))); $response->setData($_profile); } elseif ($meta['action'] == 'add_to_cart') { // add to cart $data = fn_twg_get_api_data($response, $format); Registry::set('runtime.controller', 'checkout', true); $ids = fn_twg_api_add_product_to_cart(array($data), $_SESSION['cart']); Registry::set('runtime.controller', 'twigmo'); $result = fn_twg_api_get_session_cart($_SESSION['cart'], $lang_code); $response->setData($result); if (!empty($ids)) { $ids = array_keys($ids);
db_query("DELETE FROM ?:product_subscriptions WHERE subscription_id = ?i", $_REQUEST['deleted_subscription_id']); } } if (empty($product_data)) { return array(CONTROLLER_STATUS_NO_PAGE); } list($product_features, $features_search) = fn_get_paginated_product_features(array('product_id' => $product_data['product_id']), $auth, $product_data, DESCR_SL); Tygh::$app['view']->assign('product_features', $product_features); Tygh::$app['view']->assign('features_search', $features_search); $taxes = fn_get_taxes(); arsort($product_data['category_ids']); if (fn_allowed_for('MULTIVENDOR')) { // reload form (refresh categories list if vendor was changed) if (defined('AJAX_REQUEST') && !empty($_REQUEST['reload_form'])) { $company_id = isset($_REQUEST['product_data']['company_id']) ? $_REQUEST['product_data']['company_id'] : 0; $company_data = fn_get_company_data($company_id); if (!empty($company_data['categories'])) { $params = array('simple' => false, 'company_ids' => $company_id); list($cat_ids, ) = fn_get_categories($params); $cat_ids = array_keys($cat_ids); //Assign available category ids to be displayed after admin changes product owner. $product_data['category_ids'] = array_intersect($product_data['category_ids'], $cat_ids); } //Assign received company_id to product data for the correct company categories to be displayed in the picker. $product_data['company_id'] = $company_id; Tygh::$app['view']->assign('product_data', $product_data); Tygh::$app['view']->display('views/products/update.tpl'); exit; } } Tygh::$app['view']->assign('product_data', $product_data);
$restored_company_data = fn_restore_post_data('company_data'); if ($restored_company_data) { Tygh::$app['view']->assign('company_data', $restored_company_data); } $restored_user_data = fn_restore_post_data('user_data'); if ($restored_user_data) { Tygh::$app['view']->assign('user_data', $restored_user_data); } $profile_fields = fn_get_profile_fields('A', array(), CART_LANGUAGE, array('get_custom' => true, 'get_profile_required' => true)); Tygh::$app['view']->assign('profile_fields', $profile_fields); Tygh::$app['view']->assign('countries', fn_get_simple_countries(true, CART_LANGUAGE)); Tygh::$app['view']->assign('states', fn_get_all_states()); fn_add_breadcrumb(__('apply_for_vendor_account')); $_SESSION['apply_for_vendor']['return_url'] = !empty($_REQUEST['return_previous_url']) ? $_REQUEST['return_previous_url'] : fn_url(''); } elseif ($mode == 'products') { $company_data = !empty($_REQUEST['company_id']) ? fn_get_company_data($_REQUEST['company_id']) : array(); if (empty($company_data)) { return array(CONTROLLER_STATUS_NO_PAGE); } $company_id = $company_data['company_id']; fn_add_breadcrumb(__('all_vendors'), 'companies.catalog'); $params = $_REQUEST; $params['company_id'] = $company_id; $params['extend'] = array('description'); if (!empty($_REQUEST['category_id'])) { fn_add_breadcrumb($company_data['company'], 'companies.products?company_id=' . $company_id); $category_id = $_REQUEST['category_id']; // Get full data for current category $category_data = fn_get_category_data($category_id); if (!empty($category_data)) { $params['cid'] = $category_id;
public function update($id, $params) { $data = array(); $valid_params = true; $status = Response::STATUS_BAD_REQUEST; unset($params['company_id']); $company_data = fn_get_company_data($id); if (empty($company_data)) { $message = __('api_need_correct_company_id'); $valid_params = false; } else { list($valid_params, $message) = $this->checkRequiredParams($params); } if ($valid_params) { if (!empty($this->auth['company_id']) && $this->auth['company_id'] != $id) { $status = Response::STATUS_FORBIDDEN; $data = array(); } else { $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE); $company_id = fn_update_company($params, $id, $lang_code); if ($company_id) { $this->updateCompanySettings($params, $id); $status = Response::STATUS_OK; $data['store_id'] = $company_id; } } } if (!empty($message)) { $data['message'] = $message; } return array('status' => $status, 'data' => $data); }
/** * Gets categories tree beginning from category identifier defined in params or root category * @param array $params Categories search params * category_id - Root category identifier * visible - Flag that defines if only visible categories should be included * current_category_id - Identifier of current node for visible categories * simple - Flag that defines if category path should be getted as set of category IDs * plain - Flag that defines if continues list of categories should be returned * -------------------------------------- * Examples: * Gets whole categories tree: * fn_get_categories() * -------------------------------------- * Gets subcategories tree of the category: * fn_get_categories(array( * 'category_id' => 123 * )) * -------------------------------------- * Gets all first-level nodes of the category * fn_get_categories(array( * 'category_id' => 123, * 'visible' => true * )) * -------------------------------------- * Gets all visible nodes of the category, start from the root * fn_get_categories(array( * 'category_id' => 0, * 'current_category_id' => 234, * 'visible' => true * )) * @param string $lang_code 2-letters language code * @return array Categories tree */ function fn_get_categories($params = array(), $lang_code = CART_LANGUAGE) { /** * Changes params for the categories search * * @param array $params Categories search params * @param string $lang_code 2-letters language code */ fn_set_hook('get_categories_pre', $params, $lang_code); $default_params = array('category_id' => 0, 'visible' => false, 'current_category_id' => 0, 'simple' => true, 'plain' => false, 'limit' => 0, 'item_ids' => '', 'group_by_level' => true, 'get_images' => false, 'category_delimiter' => '/', 'get_frontend_urls' => false); $params = array_merge($default_params, $params); $sortings = array('timestamp' => '?:categories.timestamp', 'name' => '?:category_descriptions.category', 'position' => array('?:categories.position', '?:category_descriptions.category')); $auth =& $_SESSION['auth']; $fields = array('?:categories.category_id', '?:categories.parent_id', '?:categories.id_path', '?:category_descriptions.category', '?:categories.position', '?:categories.status'); if ($params['simple'] == false) { $fields[] = '?:categories.product_count'; } if (empty($params['current_category_id']) && !empty($params['product_category_id'])) { $params['current_category_id'] = $params['product_category_id']; } $condition = ''; if (fn_allowed_for('MULTIVENDOR')) { if (Registry::get('runtime.company_id')) { $company_id = Registry::get('runtime.company_id'); } elseif (!empty($params['company_ids'])) { $company_id = (int) $params['company_ids']; } if (!empty($company_id)) { $company_data = fn_get_company_data($company_id); if (!empty($company_data['category_ids'])) { $company_condition = db_quote(' AND ?:categories.category_id IN (?n)', $company_data['category_ids']); $condition .= $company_condition; } } } if (AREA == 'C') { $_statuses = array('A'); // Show enabled products/categories $condition .= fn_get_localizations_condition('?:categories.localization', true); $condition .= " AND (" . fn_find_array_in_set($auth['usergroup_ids'], '?:categories.usergroup_ids', true) . ")"; $condition .= db_quote(" AND ?:categories.status IN (?a)", $_statuses); } if (!empty($params['status'])) { $condition .= db_quote(" AND ?:categories.status IN (?a)", $params['status']); } if (isset($params['parent_category_id'])) { // set parent id, that was set in block properties $params['category_id'] = $params['parent_category_id']; } if ($params['visible'] == true && empty($params['b_id'])) { if (!empty($params['current_category_id'])) { $cur_id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $params['current_category_id']); if (!empty($cur_id_path)) { $parent_categories_ids = explode('/', $cur_id_path); } } if (!empty($params['category_id']) || empty($parent_categories_ids)) { $parent_categories_ids[] = $params['category_id']; } $parents_condition = db_quote(" AND ?:categories.parent_id IN (?n)", $parent_categories_ids); } // if we have company_condtion, skip $parents_condition, it will be processed later by PHP if (!empty($parents_condition) && empty($company_condition)) { $condition .= $parents_condition; } if (!empty($params['category_id'])) { $from_id_path = db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $params['category_id']); $condition .= db_quote(" AND ?:categories.id_path LIKE ?l", "{$from_id_path}/%"); } if (!empty($params['item_ids'])) { $condition .= db_quote(' AND ?:categories.category_id IN (?n)', explode(',', $params['item_ids'])); } if (!empty($params['except_id']) && (empty($params['item_ids']) || !empty($params['item_ids']) && !in_array($params['except_id'], explode(',', $params['item_ids'])))) { $condition .= db_quote(' AND ?:categories.category_id != ?i AND ?:categories.parent_id != ?i', $params['except_id'], $params['except_id']); } if (!empty($params['period']) && $params['period'] != 'A') { list($params['time_from'], $params['time_to']) = fn_create_periods($params); $condition .= db_quote(" AND (?:categories.timestamp >= ?i AND ?:categories.timestamp <= ?i)", $params['time_from'], $params['time_to']); } $limit = $join = $group_by = ''; /** * Changes SQL params for the categories search * * @param array $params Categories search params * @param string $join Join parametrs * @param string $condition Request condition * @param array $fields Selectable fields * @param string $group_by Group by parameters * @param array $sortings Sorting fields * @param string $lang_code Language code */ fn_set_hook('get_categories', $params, $join, $condition, $fields, $group_by, $sortings, $lang_code); if (!empty($params['limit'])) { $limit = db_quote(' LIMIT 0, ?i', $params['limit']); } $sorting = db_sort($params, $sortings, 'position', 'asc'); if (!empty($params['get_conditions'])) { return array($fields, $join, $condition, $group_by, $sorting, $limit); } $categories = db_get_hash_array('SELECT ' . implode(',', $fields) . " FROM ?:categories LEFT JOIN ?:category_descriptions ON ?:categories.category_id = ?:category_descriptions.category_id AND ?:category_descriptions.lang_code = ?s {$join} WHERE 1 ?p {$group_by} {$sorting} ?p", 'category_id', $lang_code, $condition, $limit); /** * Process categories list after getting it * @param array $categories Categories list * @param array $params Categories search params */ fn_set_hook('get_categories_after_sql', $categories, $params); if (empty($categories)) { return array(array()); } if (fn_allowed_for('ULTIMATE')) { // we can't build the correct tree for vendors if there are not available parent categories if (!empty($company_condition)) { $selected_ids = array_keys($categories); $parent_ids = array(); // so get skipped parent categories ids foreach ($categories as $v) { if ($v['parent_id'] && !in_array($v['parent_id'], $selected_ids)) { $parent_ids = array_merge($parent_ids, explode('/', $v['id_path'])); } } if (!empty($parent_ids)) { // and retrieve its data if (Registry::get('runtime.company_id') && !empty($company_condition)) { $condition = str_replace($company_condition, '', $condition); } $condition .= db_quote(' AND ?:categories.category_id IN (?a)', $parent_ids); $fields[] = '1 as disabled'; //mark such categories as disabled $parent_categories = db_get_hash_array('SELECT ' . implode(',', $fields) . " FROM ?:categories LEFT JOIN ?:category_descriptions ON ?:categories.category_id = ?:category_descriptions.category_id AND ?:category_descriptions.lang_code = ?s {$join} WHERE 1 ?p {$group_by} {$sorting} ?p", 'category_id', $lang_code, $condition, $limit); $categories = $categories + $parent_categories; } // process parents_condition if it was skipped if (!empty($parent_categories_ids)) { foreach ($categories as $k => $v) { if (!in_array($v['parent_id'], $parent_categories_ids)) { unset($categories[$k]); } } } } } if (!empty($params['active_category_id']) && !empty($categories[$params['active_category_id']])) { $categories[$params['active_category_id']]['active'] = true; Registry::set('runtime.active_category_ids', explode('/', $categories[$params['active_category_id']]['id_path'])); } $categories_list = array(); if ($params['simple'] == true || $params['group_by_level'] == true) { $child_for = array_keys($categories); $where_condition = !empty($params['except_id']) ? db_quote(' AND category_id != ?i', $params['except_id']) : ''; $has_children = db_get_hash_array("SELECT category_id, parent_id FROM ?:categories WHERE parent_id IN(?n) ?p", 'parent_id', $child_for, $where_condition); } // Group categories by the level (simple) if ($params['simple'] == true) { foreach ($categories as $k => $v) { $v['level'] = substr_count($v['id_path'], '/'); if ((!empty($params['current_category_id']) || $v['level'] == 0) && isset($has_children[$k])) { $v['has_children'] = $has_children[$k]['category_id']; } $categories_list[$v['level']][$v['category_id']] = $v; if ($params['get_images'] == true) { $categories_list[$v['level']][$v['category_id']]['main_pair'] = fn_get_image_pairs($v['category_id'], 'category', 'M', true, true, $lang_code); } } } elseif ($params['group_by_level'] == true) { // Group categories by the level (simple) and literalize path foreach ($categories as $k => $v) { $path = explode('/', $v['id_path']); $category_path = array(); foreach ($path as $__k => $__v) { $category_path[$__v] = @$categories[$__v]['category']; } $v['category_path'] = implode($params['category_delimiter'], $category_path); $v['level'] = substr_count($v['id_path'], "/"); if ((!empty($params['current_category_id']) || $v['level'] == 0) && isset($has_children[$k])) { $v['has_children'] = $has_children[$k]['category_id']; } $categories_list[$v['level']][$v['category_id']] = $v; if ($params['get_images'] == true) { $categories_list[$v['level']][$v['category_id']]['main_pair'] = fn_get_image_pairs($v['category_id'], 'category', 'M', true, true, $lang_code); } } } else { $categories_list = $categories; if ($params['get_images'] == true) { foreach ($categories_list as $k => $v) { if ($params['get_images'] == true) { $categories_list[$k]['main_pair'] = fn_get_image_pairs($v['category_id'], 'category', 'M', true, true, $lang_code); } } } } ksort($categories_list, SORT_NUMERIC); $categories_list = array_reverse($categories_list); foreach ($categories_list as $level => $v) { foreach ($v as $k => $data) { if (isset($data['parent_id']) && isset($categories_list[$level + 1][$data['parent_id']])) { $categories_list[$level + 1][$data['parent_id']]['subcategories'][] = $categories_list[$level][$k]; unset($categories_list[$level][$k]); } } } if (!empty($params['get_frontend_urls'])) { foreach ($categories_list as &$category) { $category['url'] = fn_url('categories.view?category_id=' . $category['category_id'], 'C'); } } if ($params['group_by_level'] == true) { $categories_list = array_pop($categories_list); } if ($params['plain'] == true) { $categories_list = fn_multi_level_to_plain($categories_list, 'subcategories'); } if (!empty($params['item_ids'])) { $categories_list = fn_sort_by_ids($categories_list, explode(',', $params['item_ids']), 'category_id'); } if (!empty($params['add_root'])) { array_unshift($categories_list, array('category_id' => 0, 'category' => $params['add_root'])); } /** * Process categories list before cutting second and fird levels * * @param array $categories_list Categories list * @param array $params Categories search params */ fn_set_hook('get_categories_before_cut_levels', $categories_list, $params); fn_dropdown_appearance_cut_second_third_levels($categories_list, 'subcategories', $params); /** * Process final category list * * @param array $categories_list Categories list * @param array $params Categories search params * @param string $lang_code Language code */ fn_set_hook('get_categories_post', $categories_list, $params, $lang_code); // process search results if (!empty($params['save_view_results'])) { $request = $params; $request['page'] = 1; $categories_res = $params['plain'] == true ? $categories_list : fn_multi_level_to_plain($categories_list, 'subcategories'); foreach ($categories_res as $key => $item) { if (empty($item['category_id'])) { unset($categories_res[$key]); } } $request['total_items'] = $request['items_per_page'] = count($categories_res); LastView::instance()->processResults('categories', $categories_res, $request); } return array($categories_list, $params); }
/** * Init company data * Company data array will be saved in the registry runtime.company_data * * @param array $params request parameters * @return array with init data (init status, redirect url in case of redirect) */ function fn_init_company_data($params) { $company_data = array('company' => __('all_vendors')); $company_id = Registry::get('runtime.company_id'); if ($company_id) { $company_data = fn_get_company_data($company_id); } fn_set_hook('init_company_data', $params, $company_id, $company_data); Registry::set('runtime.company_data', $company_data); return array(INIT_STATUS_OK); }
/** * Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled) * * @param int $company_id * @param string $status_to A or D * @param string $reason The reason of the change * @param string $status_from Previous status * @param boolean $skip_query By default false. Update query might be skipped if status is already changed. * @return boolean True on success or false on failure */ function fn_change_company_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true) { /** * Actions before change company status * * @param int $company_id Company ID * @param string $status_to Status to letter * @param string $reason Reason text * @param string $status_from Status from letter * @param bool $skip_query Skip query flag * @param bool $notify Notify flag */ fn_set_hook('change_company_status_pre', $company_id, $status_to, $reason, $status_from, $skip_query, $notify); if (empty($status_from)) { $status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id); } if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) { return false; } $result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id); if (!$result) { return false; } $company_data = fn_get_company_data($company_id); $account = $username = ''; if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) { if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') { if (!empty($company_data['request_user_id'])) { $password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']); $_set = ''; if (empty($password_change_timestamp)) { $_set = ", password_change_timestamp = 1 "; } db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']); $username = fn_get_user_name($company_data['request_user_id']); $account = 'updated'; $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>'; fn_set_notification('N', __('notice'), $msg, 'K'); } else { $_company_data = $company_data + unserialize($company_data['request_account_data']); $_company_data['status'] = 'A'; if (!empty($_company_data['request_account_name'])) { $_company_data['admin_username'] = $_company_data['request_account_name']; } $user_data = fn_create_company_admin($_company_data, $_company_data['fields'], false); if (!empty($user_data['user_id'])) { $username = $user_data['user_login']; $account = 'new'; } } } } if (empty($user_data)) { $user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id); $user_data = fn_get_user_info($user_id); } /** * Actions between change company status and send mail * * @param int $company_id Company ID * @param string $status_to Status to letter * @param string $reason Reason text * @param string $status_from Status from letter * @param bool $skip_query Skip query flag * @param bool $notify Notify flag * @param array $company_data Company data * @param array $user_data User data * @param bool $result Updated flag */ fn_set_hook('change_company_status_before_mail', $company_id, $status_to, $reason, $status_from, $skip_query, $notify, $company_data, $user_data, $result); if ($notify && !empty($company_data['email'])) { $e_username = ''; $e_account = ''; $e_password = ''; if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) { $e_username = $username; $e_account = $account; if ($account == 'new') { $e_password = $user_data['password1']; } } $mail_template = fn_strtolower($status_from . '_' . $status_to); Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A'); } return $result; }
/** * Get origination data * * @param array $company_id Company ID * @return array Origination data */ private static function _getOriginationData($company_id) { $data = array(); if (empty($company_id) || fn_allowed_for('ULTIMATE')) { $data = array('name' => Registry::get('settings.Company.company_name'), 'address' => Registry::get('settings.Company.company_address'), 'city' => Registry::get('settings.Company.company_city'), 'country' => Registry::get('settings.Company.company_country'), 'state' => Registry::get('settings.Company.company_state'), 'zipcode' => Registry::get('settings.Company.company_zipcode'), 'phone' => Registry::get('settings.Company.company_phone'), 'fax' => Registry::get('settings.Company.company_fax')); } else { $company_data = fn_get_company_data($company_id); $data = array('name' => $company_data['company'], 'address' => $company_data['address'], 'city' => $company_data['city'], 'country' => $company_data['country'], 'state' => $company_data['state'], 'zipcode' => $company_data['zipcode'], 'phone' => $company_data['phone'], 'fax' => $company_data['fax']); } return $data; }
/** * Fucntion changes company status. Allowed statuses are A(ctive) and D(isabled) * * @param int $company_id * @param string $status_to A or D * @param string $reason The reason of the change * @param string $status_from Previous status * @param boolean $skip_query By default false. Update query might be skipped if status is already changed. * @return boolean True on success or false on failure */ function fn_companies_change_status($company_id, $status_to, $reason = '', &$status_from = '', $skip_query = false, $notify = true) { if (empty($status_from)) { $status_from = db_get_field("SELECT status FROM ?:companies WHERE company_id = ?i", $company_id); } if (!in_array($status_to, array('A', 'P', 'D')) || $status_from == $status_to) { return false; } $result = $skip_query ? true : db_query("UPDATE ?:companies SET status = ?s WHERE company_id = ?i", $status_to, $company_id); if (!$result) { return false; } $company_data = fn_get_company_data($company_id); $account = $username = ''; if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) { if (Registry::get('settings.Vendors.create_vendor_administrator_account') == 'Y') { if (!empty($company_data['request_user_id'])) { $password_change_timestamp = db_get_field("SELECT password_change_timestamp FROM ?:users WHERE user_id = ?i", $company_data['request_user_id']); $_set = ''; if (empty($password_change_timestamp)) { $_set = ", password_change_timestamp = 1 "; } db_query("UPDATE ?:users SET company_id = ?i, user_type = 'V'{$_set} WHERE user_id = ?i", $company_id, $company_data['request_user_id']); $username = fn_get_user_name($company_data['request_user_id']); $account = 'updated'; $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $company_data['request_user_id']) . '">' . __('you_can_edit_account_details') . '</a>'; fn_set_notification('N', __('notice'), $msg, 'K'); } else { $user_data = array(); if (!empty($company_data['request_account_name'])) { $user_data['user_login'] = $company_data['request_account_name']; } else { $user_data['user_login'] = $company_data['email']; } $request_account_data = unserialize($company_data['request_account_data']); $user_data['fields'] = $request_account_data['fields']; $user_data['firstname'] = $user_data['b_firstname'] = $user_data['s_firstname'] = $request_account_data['admin_firstname']; $user_data['lastname'] = $user_data['b_lastname'] = $user_data['s_lastname'] = $request_account_data['admin_lastname']; $user_data['user_type'] = 'V'; $user_data['password1'] = fn_generate_password(); $user_data['password2'] = $user_data['password1']; $user_data['status'] = 'A'; $user_data['company_id'] = $company_id; $user_data['email'] = $company_data['email']; $user_data['company'] = $company_data['company']; $user_data['last_login'] = 0; $user_data['lang_code'] = $company_data['lang_code']; $user_data['password_change_timestamp'] = 0; // Copy vendor admin billing and shipping addresses from the company's credentials $user_data['b_address'] = $user_data['s_address'] = $company_data['address']; $user_data['b_city'] = $user_data['s_city'] = $company_data['city']; $user_data['b_country'] = $user_data['s_country'] = $company_data['country']; $user_data['b_state'] = $user_data['s_state'] = $company_data['state']; $user_data['b_zipcode'] = $user_data['s_zipcode'] = $company_data['zipcode']; list($added_user_id, $null) = fn_update_user(0, $user_data, $null, false, false); if ($added_user_id) { $msg = __('new_administrator_account_created') . '<a href="' . fn_url('profiles.update?user_id=' . $added_user_id) . '">' . __('you_can_edit_account_details') . '</a>'; fn_set_notification('N', __('notice'), $msg, 'K'); $username = $user_data['user_login']; $account = 'new'; } } } } if (empty($user_data)) { $user_id = db_get_field("SELECT user_id FROM ?:users WHERE company_id = ?i AND is_root = 'Y' AND user_type = 'V'", $company_id); $user_data = fn_get_user_info($user_id); } if ($notify && !empty($company_data['email'])) { $e_username = ''; $e_account = ''; $e_password = ''; if ($status_from == 'N' && ($status_to == 'A' || $status_to == 'P')) { $e_username = $username; $e_account = $account; if ($account == 'new') { $e_password = $user_data['password1']; } } $mail_template = fn_strtolower($status_from . '_' . $status_to); Mailer::sendMail(array('to' => $company_data['email'], 'from' => 'default_company_support_department', 'data' => array('user_data' => $user_data, 'reason' => $reason, 'status' => __($status_to == 'A' ? 'active' : 'disabled'), 'e_username' => $e_username, 'e_account' => $e_account, 'e_password' => $e_password), 'company_id' => $company_id, 'tpl' => 'companies/status_' . $mail_template . '_notification.tpl'), 'A'); } return $result; }
function fn_ult_init_company_data(&$params, &$company_id, &$company_data) { if (Registry::get('runtime.forced_company_id')) { $company_data = fn_get_company_data(Registry::get('runtime.forced_company_id')); } }
function fn_is_accessible_discussion($data, &$auth) { $access = false; if ($data['object_type'] == 'P') { //product $access = fn_get_product_data($data['object_id'], $auth, CART_LANGUAGE, $field_list = '?:products.product_id', false, false, false); } elseif ($data['object_type'] == 'C') { //category $access = fn_get_category_data($data['object_id'], '', $field_list = '?:categories.category_id', false); } elseif ($data['object_type'] == 'M') { //company $access = fn_get_company_data($data['object_id']); } elseif ($data['object_type'] == 'O') { //order if (!empty($auth['user_id'])) { $access = db_get_field("SELECT order_id FROM ?:orders WHERE order_id = ?i AND user_id = ?i", $data['object_id'], $auth['user_id']); } elseif (!empty($auth['order_ids'])) { $access = in_array($data['object_id'], $auth['order_ids']); } } elseif ($data['object_type'] == 'A') { // page $access = fn_get_page_data($data['object_id'], CART_LANGUAGE); } elseif ($data['object_type'] == 'E') { // testimonials $access = true; } fn_set_hook('is_accessible_discussion', $data, $auth, $access); return !empty($access); }
function fn_yml_get_storefront_url($price_list) { static $storefront_url = null; if (!isset($storefront_url)) { $storefront_url = Registry::get('config.current_location'); if (fn_allowed_for('ULTIMATE')) { if (!empty($price_list['company_id'])) { $company_data = fn_get_company_data($price_list['company_id']); $storefront_url = 'http://' . $company_data['storefront']; } elseif (Registry::get('runtime.company_id') || Registry::get('runtime.simple_ultimate')) { $company = Registry::get('runtime.company_data'); $storefront_url = 'http://' . $company['storefront']; } else { $storefront_url = ''; } } } return $storefront_url; }
* * * This is commercial software, only users who have purchased a valid * * license and accept to the terms of the License Agreement can install * * and use this program. * * * **************************************************************************** * PLEASE READ THE FULL TEXT OF THE SOFTWARE LICENSE AGREEMENT IN THE * * "copyright.txt" FILE PROVIDED WITH THIS DISTRIBUTION PACKAGE. * ****************************************************************************/ use Tygh\Registry; if (!defined('BOOTSTRAP')) { die('Access denied'); } if ($_SERVER['REQUEST_METHOD'] == 'POST') { if (($mode == 'add' || $mode == 'update') && !empty($_REQUEST['company_data'])) { if (Registry::get('runtime.company_id')) { unset($_REQUEST['company_data']['pre_moderation'], $_POST['company_data']['pre_moderation']); unset($_REQUEST['company_data']['pre_moderation_edit'], $_POST['company_data']['pre_moderation_edit']); unset($_REQUEST['company_data']['pre_moderation_edit_vendors'], $_POST['company_data']['pre_moderation_edit_vendors']); } } } if ($mode == 'update') { if (Registry::get('runtime.company_id')) { $company_data = fn_get_company_data(Registry::get('runtime.company_id')); $vendor_profile_updates_approval = Registry::get('addons.vendor_data_premoderation.vendor_profile_updates_approval'); if ($company_data['status'] == 'A' && ($vendor_profile_updates_approval == 'all' || $vendor_profile_updates_approval == 'custom' && !empty($company_data['pre_moderation_edit_vendors']) && $company_data['pre_moderation_edit_vendors'] == 'Y')) { Tygh::$app['view']->assign('vendor_pre', 'Y'); } } }
function fn_prepare_package_info(&$cart, &$cart_products) { $package_infos = array(); $groupped_products = array(); foreach ($cart['products'] as $k => $v) { if (!isset($v['company_id'])) { // for old saved carts $cart['products'][$k]['company_id'] = $v['company_id'] = $cart_products[$k]['company_id'] = 0; } $groupped_products[$v['company_id']][$k] = $cart_products[$k]; } foreach ($groupped_products as $_cid => $products) { $package_infos[$_cid]['C'] = fn_get_products_cost($cart, $products); $package_infos[$_cid]['W'] = fn_get_products_weight($cart, $products); $package_infos[$_cid]['I'] = fn_get_products_amount($cart, $products); if (empty($package_infos[$_cid]['origination'])) { if (!$_cid) { $package_infos[$_cid]['origination'] = array('name' => Registry::get('settings.Company.company_name'), 'address' => Registry::get('settings.Company.company_address'), 'city' => Registry::get('settings.Company.company_city'), 'country' => Registry::get('settings.Company.company_country'), 'state' => Registry::get('settings.Company.company_state'), 'zipcode' => Registry::get('settings.Company.company_zipcode'), 'phone' => Registry::get('settings.Company.company_phone'), 'fax' => Registry::get('settings.Company.company_fax')); } else { $supplier_data = fn_get_company_data($_cid); $package_infos[$_cid]['origination'] = array('name' => !empty($supplier_data['company']) ? $supplier_data['company'] : '', 'phone' => !empty($supplier_data['phone']) ? $supplier_data['phone'] : '', 'fax' => !empty($supplier_data['fax']) ? $supplier_data['fax'] : '', 'country' => !empty($supplier_data['country']) ? $supplier_data['country'] : '', 'state' => !empty($supplier_data['state']) ? $supplier_data['state'] : '', 'zipcode' => !empty($supplier_data['zipcode']) ? $supplier_data['zipcode'] : '', 'city' => !empty($supplier_data['city']) ? $supplier_data['city'] : '', 'address' => !empty($supplier_data['address']) ? $supplier_data['address'] : ''); } } } fn_set_hook('prepare_package_info', $cart, $cart_products, $package_infos); return $package_infos; }