function fn_gift_certificate_notification(&$gift_cert_data, $force_notification = array()) { static $notified = array(); if (!empty($notified[$gift_cert_data['gift_cert_id']])) { return true; } $status_params = fn_get_status_params($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE); $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false); if ($notify_user == true && $gift_cert_data['email'] && $gift_cert_data['send_via'] == 'E') { $notified[$gift_cert_data['gift_cert_id']] = true; $templates = fn_get_gift_certificate_templates(); $gift_cert_data['template'] = isset($templates[$gift_cert_data['template']]) ? $gift_cert_data['template'] : key($templates); Mailer::sendMail(array('to' => $gift_cert_data['email'], 'from' => 'company_orders_department', 'data' => array('gift_cert_data' => $gift_cert_data, 'certificate_status' => fn_get_status_data($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE, $gift_cert_data['gift_cert_id'])), 'tpl' => 'addons/gift_certificates/gift_certificate.tpl', 'company_id' => $gift_cert_data['company_id']), 'C'); return true; } return false; }
function fn_rma_change_order_status(&$status_to, &$status_from, &$order_info) { $status_data = fn_get_status_params($status_to, STATUSES_ORDER); if (!empty($status_data) && (!empty($status_data['allow_return']) && $status_data['allow_return'] == 'Y')) { $_data = array('order_id' => $order_info['order_id'], 'type' => ORDER_DATA_PRODUCTS_DELIVERY_DATE, 'data' => TIME); db_query("REPLACE INTO ?:order_data ?e", $_data); } else { db_query("DELETE FROM ?:order_data WHERE order_id = ?i AND type = ?s", $order_info['order_id'], ORDER_DATA_PRODUCTS_DELIVERY_DATE); } }
list($shipments) = fn_get_shipments_info(array('order_id' => $params['order_id'], 'advanced_info' => true)); $use_shipments = !fn_one_full_shipped($shipments); // Check for the shipment access // If current edition is FREE, we still need to check shipments accessibility (need to display promotion link) if (Settings::instance()->getValue('use_shipments', '', $order_info['company_id']) == 'Y') { if (!fn_check_user_access($auth['user_id'], 'edit_order')) { $order_info['need_shipment'] = false; } $use_shipments = true; } else { Registry::get('view')->assign('shipments', $shipments); } Registry::get('view')->assign('use_shipments', $use_shipments); Registry::get('view')->assign('carriers', fn_get_carriers()); Registry::get('view')->assign('order_info', $order_info); Registry::get('view')->assign('status_settings', fn_get_status_params($order_info['status'])); // Delete order_id from new_orders table db_query("DELETE FROM ?:new_orders WHERE order_id = ?i AND user_id = ?i", $_REQUEST['order_id'], $auth['user_id']); // Check if customer's email is changed if (!empty($order_info['user_id'])) { $current_email = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $order_info['user_id']); if (!empty($current_email) && $current_email != $order_info['email']) { Registry::get('view')->assign('email_changed', true); } } } elseif ($mode == 'picker') { $_REQUEST['skip_view'] = 'Y'; list($orders, $search) = fn_get_orders($_REQUEST, Registry::get('settings.Appearance.admin_orders_per_page')); Registry::get('view')->assign('orders', $orders); Registry::get('view')->assign('search', $search); Registry::get('view')->display('pickers/orders/picker_contents.tpl');
function fn_print_order_invoices($order_ids, $pdf = false, $area = AREA, $lang_code = CART_LANGUAGE) { $view = Registry::get('view'); $html = array(); $view->assign('order_status_descr', fn_get_simple_statuses(STATUSES_ORDER, true, true)); $view->assign('profile_fields', fn_get_profile_fields('I')); if (!is_array($order_ids)) { $order_ids = array($order_ids); } foreach ($order_ids as $order_id) { $order_info = fn_get_order_info($order_id, false, true, false, true); if (empty($order_info)) { continue; } if (fn_allowed_for('MULTIVENDOR')) { $view->assign('take_surcharge_from_vendor', fn_take_payment_surcharge_from_vendor($order_info['products'])); } list($shipments) = fn_get_shipments_info(array('order_id' => $order_info['order_id'], 'advanced_info' => true)); $use_shipments = !fn_one_full_shipped($shipments); $view->assign('order_info', $order_info); $view->assign('shipments', $shipments); $view->assign('use_shipments', $use_shipments); $view->assign('payment_method', fn_get_payment_data(!empty($order_info['payment_method']['payment_id']) ? $order_info['payment_method']['payment_id'] : 0, $order_info['order_id'], $lang_code)); $view->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $lang_code, $order_info['company_id'])); $view->assign('status_settings', fn_get_status_params($order_info['status'])); $view->assign('company_data', fn_get_company_placement_info($order_info['company_id'], $lang_code)); if ($pdf == true) { fn_disable_live_editor_mode(); $html[] = $view->displayMail('orders/print_invoice.tpl', false, $area, $order_info['company_id'], $lang_code); } else { $view->displayMail('orders/print_invoice.tpl', true, $area, $order_info['company_id'], $lang_code); if ($order_id != end($order_ids)) { echo "<div style='page-break-before: always;'> </div>"; } } } if ($pdf == true) { Pdf::render($html, __('invoices') . '-' . implode('-', $order_ids)); } return true; }
function fn_qwintry_save_order_invoice($order_id, $area = AREA, $lang_code = CART_LANGUAGE) { $view = Tygh::$app['view']; $html = array(); $view->assign('order_status_descr', fn_get_simple_statuses(STATUSES_ORDER, true, true)); $view->assign('profile_fields', fn_get_profile_fields('I')); $order_info = fn_get_order_info($order_id, false, true, false, true); if (empty($order_info)) { return; } if (fn_allowed_for('MULTIVENDOR')) { $view->assign('take_surcharge_from_vendor', fn_take_payment_surcharge_from_vendor($order_info['products'])); } list($shipments) = fn_get_shipments_info(array('order_id' => $order_info['order_id'], 'advanced_info' => true)); $use_shipments = !fn_one_full_shipped($shipments); $view->assign('order_info', $order_info); $view->assign('shipments', $shipments); $view->assign('use_shipments', $use_shipments); $view->assign('payment_method', fn_get_payment_data(!empty($order_info['payment_method']['payment_id']) ? $order_info['payment_method']['payment_id'] : 0, $order_info['order_id'], $lang_code)); $view->assign('order_status', fn_get_status_data($order_info['status'], STATUSES_ORDER, $order_info['order_id'], $lang_code, $order_info['company_id'])); $view->assign('status_settings', fn_get_status_params($order_info['status'])); $view->assign('company_data', fn_get_company_placement_info($order_info['company_id'], $lang_code)); fn_disable_live_editor_mode(); $html[] = $view->displayMail('orders/print_invoice.tpl', false, $area, $order_info['company_id'], $lang_code); $filename = QWINTRY_DIR_INVOICES . $order_id . '.pdf'; if (Pdf::render($html, $filename, true)) { return $filename; } return false; }
list($shipments) = fn_get_shipments_info(array('order_id' => $params['order_id'], 'advanced_info' => true)); $use_shipments = !fn_one_full_shipped($shipments); // Check for the shipment access // If current edition is FREE, we still need to check shipments accessibility (need to display promotion link) if (Settings::instance()->getValue('use_shipments', '', $order_info['company_id']) == 'Y') { if (!fn_check_user_access($auth['user_id'], 'edit_order')) { $order_info['need_shipment'] = false; } $use_shipments = true; } else { Tygh::$app['view']->assign('shipments', $shipments); } Tygh::$app['view']->assign('use_shipments', $use_shipments); Tygh::$app['view']->assign('carriers', fn_get_carriers()); Tygh::$app['view']->assign('order_info', $order_info); Tygh::$app['view']->assign('status_settings', fn_get_status_params($order_info['status'])); // Delete order_id from new_orders table db_query("DELETE FROM ?:new_orders WHERE order_id = ?i AND user_id = ?i", $_REQUEST['order_id'], $auth['user_id']); // Check if customer's email is changed if (!empty($order_info['user_id'])) { $current_email = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $order_info['user_id']); if (!empty($current_email) && $current_email != $order_info['email']) { Tygh::$app['view']->assign('email_changed', true); } } } elseif ($mode == 'picker') { $_REQUEST['skip_view'] = 'Y'; list($orders, $search) = fn_get_orders($_REQUEST, Registry::get('settings.Appearance.admin_orders_per_page')); Tygh::$app['view']->assign('orders', $orders); Tygh::$app['view']->assign('search', $search); Tygh::$app['view']->display('pickers/orders/picker_contents.tpl');
function fn_get_statuses($type = STATUSES_ORDER, $simple = false, $additional_statuses = false, $exclude_parent = false, $lang_code = CART_LANGUAGE) { if ($simple) { $statuses = db_get_hash_single_array("SELECT a.status, b.description FROM ?:statuses as a LEFT JOIN ?:status_descriptions as b ON b.status = a.status AND b.type = a.type AND b.lang_code = ?s WHERE a.type = ?s ORDER BY b.description", array('status', 'description'), $lang_code, $type); if ($type == STATUSES_ORDER && !empty($additional_statuses)) { $statuses['N'] = fn_get_lang_var('incompleted', $lang_code); if (empty($exclude_parent)) { $statuses['T'] = fn_get_lang_var('parent_order', $lang_code); } } } else { $statuses = db_get_hash_array("SELECT a.status, b.description FROM ?:statuses as a LEFT JOIN ?:status_descriptions as b ON b.status = a.status AND b.type = a.type AND b.lang_code = ?s WHERE a.type = ?s ORDER BY b.description", 'status', $lang_code, $type); foreach ($statuses as $status => $data) { $statuses[$status] = fn_array_merge($statuses[$status], fn_get_status_params($status, $type)); } if ($type == STATUSES_ORDER && !empty($additional_statuses)) { $statuses[STATUS_INCOMPLETED_ORDER] = array('status' => STATUS_INCOMPLETED_ORDER, 'description' => fn_get_lang_var('incompleted', $lang_code), 'inventory' => 'I', 'type' => STATUSES_ORDER); if (empty($exclude_parent)) { $statuses[STATUS_PARENT_ORDER] = array('status' => STATUS_PARENT_ORDER, 'description' => fn_get_lang_var('parent_order', $lang_code), 'inventory' => 'I', 'type' => STATUSES_ORDER); } } } return $statuses; }
Registry::set('navigation.tabs.downloads', array('title' => fn_get_lang_var('downloads'), 'js' => true)); $view->assign('downloads_exist', true); break; } } if (!empty($order_info['promotions'])) { Registry::set('navigation.tabs.promotions', array('title' => fn_get_lang_var('promotions'), 'js' => true)); } // Check for the shipment access if (Registry::get('settings.General.use_shipments') == 'Y') { if (!fn_check_user_access($auth['user_id'], 'edit_order')) { $order_info['need_shipment'] = false; } } $view->assign('order_info', $order_info); $view->assign('status_settings', fn_get_status_params($order_info['status'])); // Delete order_id from new_orders table db_query("DELETE FROM ?:new_orders WHERE order_id = ?i AND user_id = ?i", $_REQUEST['order_id'], $auth['user_id']); fn_add_breadcrumb(fn_get_lang_var('orders'), "orders.manage.reset_view"); fn_add_breadcrumb(fn_get_lang_var('search_results'), "orders.manage.last_view"); // Check if customer's email is changed if (!empty($order_info['user_id'])) { $current_email = db_get_field("SELECT email FROM ?:users WHERE user_id = ?i", $order_info['user_id']); if (!empty($current_email) && $current_email != $order_info['email']) { $view->assign('email_changed', true); } } } elseif ($mode == 'picker') { $_REQUEST['skip_view'] = 'Y'; list($orders, $search) = fn_get_orders($_REQUEST, Registry::get('settings.Appearance.admin_orders_per_page')); $view->assign('orders', $orders);
function fn_gift_certificate_notification(&$gift_cert_data, $force_notification = array()) { static $notified = array(); if (!empty($notified[$gift_cert_data['gift_cert_id']])) { return true; } $status_params = fn_get_status_params($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE); $notify_user = isset($force_notification['C']) ? $force_notification['C'] : (!empty($status_params['notify']) && $status_params['notify'] == 'Y' ? true : false); if ($notify_user == true && $gift_cert_data['email'] && $gift_cert_data['send_via'] == 'E') { $notified[$gift_cert_data['gift_cert_id']] = true; $templates = fn_get_gift_certificate_templates(); $gift_cert_data['template'] = isset($templates[$gift_cert_data['template']]) ? $gift_cert_data['template'] : key($templates); Registry::get('view_mail')->assign('gift_cert_data', $gift_cert_data); Registry::get('view_mail')->assign('certificate_status', fn_get_status_data($gift_cert_data['status'], STATUSES_GIFT_CERTIFICATE, $gift_cert_data['gift_cert_id'])); fn_send_mail($gift_cert_data['email'], Registry::get('settings.Company.company_orders_department'), 'addons/gift_certificates/gift_certificate_subj.tpl', 'addons/gift_certificates/gift_certificate.tpl'); return true; } return false; }