/** * Places an order * * @param array $cart Array of the cart contents and user information necessary for purchase * @param array $auth Array of user authentication data (e.g. uid, usergroup_ids, etc.) * @param string $action Current action. Can be empty or "save" * @param int $issuer_id * @param int $parent_order_id * @return int order_id in case of success, otherwise False */ function fn_place_order(&$cart, &$auth, $action = '', $issuer_id = null, $parent_order_id = 0) { $allow = fn_allow_place_order($cart, $auth, $parent_order_id); fn_set_hook('pre_place_order', $cart, $allow, $cart['product_groups']); if ($allow === false) { fn_set_notification('E', __('error'), __('order_was_not_placed'), 'K', 'failed_order_message'); } if ($allow == true && !fn_cart_is_empty($cart)) { $cart['parent_order_id'] = $parent_order_id; // Remove unallowed chars from cc number if (!empty($cart['payment_info']['card_number'])) { $cart['payment_info']['card_number'] = str_replace(array(' ', '-'), '', $cart['payment_info']['card_number']); } if (empty($cart['order_id'])) { $cart['user_id'] = $auth['user_id']; $cart['tax_exempt'] = $auth['tax_exempt']; $cart['issuer_id'] = $issuer_id; // Create order list($order_id, $order_status) = fn_update_order($cart); } else { // Update order list($order_id, $order_status) = fn_update_order($cart, $cart['order_id']); } if (!empty($order_id)) { // If customer is not logged in, store order ids in the session if (empty($auth['user_id'])) { $auth['order_ids'][] = $order_id; } // If order total is zero, just save the order without any processing procedures if (floatval($cart['total']) == 0) { $action = 'save'; $order_status = 'P'; } fn_set_hook('place_order', $order_id, $action, $order_status, $cart, $auth); $is_processor_script = false; if ($action != 'save') { list($is_processor_script, ) = fn_check_processor_script($cart['payment_id'], true); } if (!$is_processor_script && $order_status == STATUS_INCOMPLETED_ORDER) { $order_status = 'O'; } $short_order_data = fn_get_order_short_info($order_id); // Set new order status fn_change_order_status($order_id, $order_status, $short_order_data['status'], $is_processor_script || $order_status == STATUS_PARENT_ORDER ? fn_get_notification_rules(array(), true) : fn_get_notification_rules(array()), true); $cart['processed_order_id'] = array(); $cart['processed_order_id'][] = $order_id; if (!$parent_order_id && count($cart['product_groups']) > 1) { $child_orders = fn_place_suborders($order_id, $cart, $auth, $action, $issuer_id); array_unshift($child_orders, $order_id); $cart['processed_order_id'] = $child_orders; } return array($order_id, $action != 'save'); } } return array(false, false); }
} if ($mode == 'products_range') { if (!empty($_REQUEST['order_ids'])) { unset($_REQUEST['redirect_url']); return array(CONTROLLER_STATUS_REDIRECT, 'products.manage?order_ids=' . implode(',', $_REQUEST['order_ids'])); } } if ($mode == 'delete') { fn_delete_order($_REQUEST['order_id']); return array(CONTROLLER_STATUS_REDIRECT); } if ($mode == 'update_status') { $order_info = fn_get_order_short_info($_REQUEST['id']); $old_status = $order_info['status']; if (fn_change_order_status($_REQUEST['id'], $_REQUEST['status'], '', fn_get_notification_rules($_REQUEST))) { $order_info = fn_get_order_short_info($_REQUEST['id']); fn_check_first_order($order_info); $new_status = $order_info['status']; if ($_REQUEST['status'] != $new_status) { Registry::get('ajax')->assign('return_status', $new_status); Registry::get('ajax')->assign('color', fn_get_status_param_value($new_status, 'color')); fn_set_notification('W', __('warning'), __('status_changed')); } else { fn_set_notification('N', __('notice'), __('status_changed')); } } else { fn_set_notification('E', __('error'), __('error_status_not_changed')); Registry::get('ajax')->assign('return_status', $old_status); Registry::get('ajax')->assign('color', fn_get_status_param_value($old_status, 'color')); } if (empty($_REQUEST['return_url'])) {
fn_clear_cart($cart, true); $customer_auth = fn_fill_auth(array(), array(), false, 'C'); return array(CONTROLLER_STATUS_REDIRECT, "order_management.add"); // // Update order page // } elseif ($mode == 'update' || $mode == 'add') { if ($mode == 'update' && empty($cart['order_id'])) { return array(CONTROLLER_STATUS_REDIRECT, "order_management.new"); } // // Prepare order status info // $get_additional_statuses = false; if (!empty($cart['order_id'])) { $order_info = fn_get_order_short_info($cart['order_id']); $cart['order_status'] = $order_info['status']; if ($cart['order_status'] == STATUS_INCOMPLETED_ORDER) { $get_additional_statuses = true; } if (!empty($order_info['issuer_id'])) { $cart['issuer_data'] = fn_get_user_short_info($order_info['issuer_id']); } } $order_statuses = fn_get_simple_statuses(STATUSES_ORDER, $get_additional_statuses, true); Registry::get('view')->assign('order_statuses', $order_statuses); // // Prepare customer info // $profile_fields = fn_get_profile_fields('O', $customer_auth); $cart['profile_id'] = empty($cart['profile_id']) ? 0 : $cart['profile_id'];
function fn_process_epayph_ipn($order_id, $data) { $order_info = fn_get_order_info($order_id); if (!empty($order_info) && !empty($data['txn_id']) && (empty($order_info['payment_info']['txn_id']) || $data['payment_status'] != 'Completed' || $data['payment_status'] == 'Completed' && $order_info['payment_info']['txn_id'] !== $data['txn_id'])) { //Can't check refund transactions. if (isset($data['txn_type']) && !fn_validate_epayph_order_info($data, $order_info)) { return false; } $pp_settings = fn_get_epayph_settings(); $data['payment_status'] = strtolower($data['payment_status']); fn_clear_cart($cart, true); $customer_auth = fn_fill_auth(array(), array(), false, 'C'); fn_form_cart($order_id, $cart, $customer_auth); if ($pp_settings['override_customer_info'] == 'Y') { $cart['user_data'] = fn_epayph_get_customer_info($data); } $cart['order_id'] = $order_id; $cart['payment_info'] = $order_info['payment_info']; $cart['payment_info']['protection_eligibility'] = !empty($data['protection_eligibility']) ? $data['protection_eligibility'] : ''; $cart['payment_id'] = $order_info['payment_id']; if (!empty($data['memo'])) { //Save customer notes $cart['notes'] = $data['memo']; } if ($data['payment_status'] == 'Completed') { //save uniq ipn id to avoid double ipn processing $cart['payment_info']['txn_id'] = $data['txn_id']; } fn_calculate_cart_content($cart, $customer_auth); list($order_id, ) = fn_update_order($cart, $order_id); if ($order_id) { $send_notification = $order_info['status'] == $pp_settings['pp_statuses'][$data['payment_status']] ? false : array(); $short_order_data = fn_get_order_short_info($order_id); fn_change_order_status($order_id, $pp_settings['pp_statuses'][$data['payment_status']], $short_order_data['status'], $send_notification); } return true; } }
} // ---------------------- GET routines --------------------------------------- if ($mode == 'view') { $subscription = fn_get_recurring_subscription_info($_REQUEST['subscription_id'], true, true); if (empty($subscription)) { return array(CONTROLLER_STATUS_NO_PAGE); } fn_add_breadcrumb(fn_get_lang_var('rb_subscriptions'), "subscriptions.search"); fn_add_breadcrumb(fn_get_lang_var('rb_subscription') . ' #' . $subscription['subscription_id']); Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'linked_products' => array('title' => fn_get_lang_var('products'), 'js' => true), 'paids' => array('title' => fn_get_lang_var('orders'), 'js' => true))); if ($subscription['order_id'] == $subscription['order_ids']) { $last_status = $subscription['order_info']['status']; $pay_order = $subscription['order_id']; } else { $pay_order = substr($subscription['order_ids'], strrpos($subscription['order_ids'], ',') + 1); $last_order = fn_get_order_short_info($pay_order); $last_status = $last_order['status']; } if (!fn_subscription_is_paid($last_status)) { $view->assign('subscription_pay_order_id', $pay_order); } $view->assign('subscription', $subscription); } elseif ($mode == 'search') { $additional_data = array('plan_options' => true); if (!empty($auth['user_id'])) { $additional_data['user_id'] = $auth['user_id']; } elseif (!empty($auth['order_ids'])) { $additional_data['order_ids'] = $auth['order_ids']; } else { return array(CONTROLLER_STATUS_REDIRECT, "auth.login_form?return_url=" . urlencode(Registry::get('config.current_url'))); }
function content_55ccecb501aab0_63276803($_smarty_tpl) { if (!is_callable('smarty_function_math')) { include '/home/coriolan/public_html/lead/app/lib/other/smarty/plugins/function.math.php'; } if (!is_callable('smarty_function_script')) { include '/home/coriolan/public_html/lead/app/functions/smarty_plugins/function.script.php'; } fn_preload_lang_vars(array('add_orders', 'clear', 'add_orders', 'id', 'status', 'customer', 'date', 'total')); echo smarty_function_math(array('equation' => "rand()", 'assign' => "rnd"), $_smarty_tpl); ?> <?php $_smarty_tpl->tpl_vars["data_id"] = new Smarty_variable((string) $_smarty_tpl->tpl_vars['data_id']->value . "_" . (string) $_smarty_tpl->tpl_vars['rnd']->value, null, 0); $_smarty_tpl->tpl_vars["view_mode"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['view_mode']->value) === null || $tmp === '' ? "mixed" : $tmp, null, 0); ?> <?php if ($_smarty_tpl->tpl_vars['view_mode']->value == "simple") { ?> <?php $_smarty_tpl->tpl_vars["display"] = new Smarty_variable("simple", null, 0); ?> <?php $_smarty_tpl->tpl_vars["max_displayed_qty"] = new Smarty_variable("50", null, 0); } ?> <?php echo smarty_function_script(array('src' => "js/tygh/picker.js"), $_smarty_tpl); ?> <?php if ($_smarty_tpl->tpl_vars['item_ids']->value && !is_array($_smarty_tpl->tpl_vars['item_ids']->value)) { ?> <?php $_smarty_tpl->tpl_vars["item_ids"] = new Smarty_variable(explode(",", $_smarty_tpl->tpl_vars['item_ids']->value), null, 0); } ?> <?php if ($_smarty_tpl->tpl_vars['view_mode']->value != "list") { ?> <div class="clearfix"> <?php if ($_smarty_tpl->tpl_vars['extra_var']->value) { ?> <?php $_smarty_tpl->tpl_vars["extra_var"] = new Smarty_variable(rawurlencode($_smarty_tpl->tpl_vars['extra_var']->value), null, 0); ?> <?php } ?> <?php if (!$_smarty_tpl->tpl_vars['no_container']->value) { ?> <div class="buttons-container pull-right"><?php } if ($_smarty_tpl->tpl_vars['picker_view']->value) { ?> [<?php } ?> <?php echo $_smarty_tpl->getSubTemplate("buttons/button.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_id' => "opener_picker_" . (string) $_smarty_tpl->tpl_vars['data_id']->value, 'but_href' => fn_url("orders.picker?display=" . (string) $_smarty_tpl->tpl_vars['display']->value . "&picker_for=" . (string) $_smarty_tpl->tpl_vars['picker_for']->value . "&extra=" . (string) $_smarty_tpl->tpl_vars['extra_var']->value . "&checkbox_name=" . (string) $_smarty_tpl->tpl_vars['checkbox_name']->value . "&aoc=" . (string) $_smarty_tpl->tpl_vars['aoc']->value . "&data_id=" . (string) $_smarty_tpl->tpl_vars['data_id']->value . "&max_displayed_qty=" . (string) $_smarty_tpl->tpl_vars['max_displayed_qty']->value), 'but_text' => ($tmp = @$_smarty_tpl->tpl_vars['but_text']->value) === null || $tmp === '' ? $_smarty_tpl->__("add_orders") : $tmp, 'but_role' => "add", 'but_target_id' => "content_" . (string) $_smarty_tpl->tpl_vars['data_id']->value, 'but_meta' => "btn cm-dialog-opener", 'but_icon' => "icon-plus"), 0); ?> <?php if ($_smarty_tpl->tpl_vars['view_mode']->value == "simple") { ?> <span id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _clear" class="reload-container<?php if (!$_smarty_tpl->tpl_vars['item_ids']->value) { ?> hidden<?php } ?> "> <?php ob_start(); echo htmlspecialchars(fn_url("orders.manage?order_id="), ENT_QUOTES, 'UTF-8'); $_tmp1 = ob_get_clean(); echo $_smarty_tpl->getSubTemplate("buttons/button.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_id' => "opener_picker_" . (string) $_smarty_tpl->tpl_vars['data_id']->value, 'but_onclick' => "Tygh." . "\$" . ".cePicker('delete_js_item', '" . (string) $_smarty_tpl->tpl_vars['data_id']->value . "', 'delete_all', 'o'); Tygh." . "\$" . ".cePicker('check_items_qty', '" . (string) $_smarty_tpl->tpl_vars['data_id']->value . "', '" . $_tmp1 . "', " . (string) $_smarty_tpl->tpl_vars['max_displayed_qty']->value . "); return false;", 'but_text' => ($tmp = @$_smarty_tpl->tpl_vars['but_text']->value) === null || $tmp === '' ? $_smarty_tpl->__("clear") : $tmp, 'but_role' => "action", 'but_icon' => "icon-repeat", 'but_target_id' => "content_" . (string) $_smarty_tpl->tpl_vars['data_id']->value), 0); ?> </span> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['picker_view']->value) { ?> ]<?php } if (!$_smarty_tpl->tpl_vars['no_container']->value) { ?> </div><?php } ?> <div class="hidden" id="content_<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> " title="<?php echo htmlspecialchars(($tmp = @$_smarty_tpl->tpl_vars['but_text']->value) === null || $tmp === '' ? $_smarty_tpl->__("add_orders") : $tmp, ENT_QUOTES, 'UTF-8'); ?> "> </div> </div> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['view_mode']->value == "simple") { ?> <input id="o<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _ids" type="hidden" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> " value="<?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { echo htmlspecialchars(implode(",", $_smarty_tpl->tpl_vars['item_ids']->value), ENT_QUOTES, 'UTF-8'); } ?> " /> <span id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> "<?php if (!$_smarty_tpl->tpl_vars['item_ids']->value) { ?> class="hidden"<?php } ?> > <?php echo $_smarty_tpl->getSubTemplate("pickers/orders/js.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('order_id' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "order_id" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'clone' => true), 0); ?> <?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { ?> <?php $_smarty_tpl->tpl_vars["o"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["o"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['item_ids']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } $_smarty_tpl->tpl_vars["o"]->index = -1; $_smarty_tpl->tpl_vars['smarty']->value['foreach']["items"]['iteration'] = 0; foreach ($_from as $_smarty_tpl->tpl_vars["o"]->key => $_smarty_tpl->tpl_vars["o"]->value) { $_smarty_tpl->tpl_vars["o"]->_loop = true; $_smarty_tpl->tpl_vars["o"]->index++; $_smarty_tpl->tpl_vars["o"]->first = $_smarty_tpl->tpl_vars["o"]->index === 0; $_smarty_tpl->tpl_vars['smarty']->value['foreach']["items"]['first'] = $_smarty_tpl->tpl_vars["o"]->first; $_smarty_tpl->tpl_vars['smarty']->value['foreach']["items"]['iteration']++; ?> <?php if ($_smarty_tpl->getVariable('smarty')->value['foreach']['items']['iteration'] <= $_smarty_tpl->tpl_vars['max_displayed_qty']->value) { ?> <?php echo $_smarty_tpl->getSubTemplate("pickers/orders/js.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('order_id' => $_smarty_tpl->tpl_vars['o']->value, 'first_item' => $_smarty_tpl->getVariable('smarty')->value['foreach']['items']['first'], 'holder' => $_smarty_tpl->tpl_vars['data_id']->value), 0); ?> <?php } else { ?> <?php echo $_smarty_tpl->getSubTemplate("pickers/orders/js.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('order_id' => $_smarty_tpl->tpl_vars['o']->value, 'first_item' => $_smarty_tpl->getVariable('smarty')->value['foreach']['items']['first'], 'holder' => $_smarty_tpl->tpl_vars['data_id']->value, 'hidden' => true), 0); ?> <?php } ?> <?php } ?> <?php } ?> </span> <span id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _details"<?php if (count($_smarty_tpl->tpl_vars['item_ids']->value) <= $_smarty_tpl->tpl_vars['max_displayed_qty']->value) { ?> class="hidden"<?php } ?> ><a href="<?php echo htmlspecialchars(fn_url("orders.manage?order_id="), ENT_QUOTES, 'UTF-8'); if ($_smarty_tpl->tpl_vars['item_ids']->value) { echo htmlspecialchars(implode(',', $_smarty_tpl->tpl_vars['item_ids']->value), ENT_QUOTES, 'UTF-8'); } ?> ">..</a></span> <span id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _no_item"<?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { ?> class="hidden"<?php } ?> ><?php echo $_smarty_tpl->tpl_vars['no_item_text']->value; ?> </span> <?php } elseif ($_smarty_tpl->tpl_vars['view_mode']->value != "button") { ?> <input id="o<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _ids" type="hidden" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> " value="<?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { echo htmlspecialchars(implode(",", $_smarty_tpl->tpl_vars['item_ids']->value), ENT_QUOTES, 'UTF-8'); } ?> " /> <table class="table table-middle"> <thead> <tr> <th width="10%"><?php echo $_smarty_tpl->__("id"); ?> </th> <th width="15%"><?php echo $_smarty_tpl->__("status"); ?> </th> <th width="25%"><?php echo $_smarty_tpl->__("customer"); ?> </th> <th width="25%"><?php echo $_smarty_tpl->__("date"); ?> </th> <th width="24%" class="right"><?php echo $_smarty_tpl->__("total"); ?> </th> <?php if (!$_smarty_tpl->tpl_vars['view_only']->value) { ?> <th> </th><?php } ?> </tr> </thead> <tbody id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> "<?php if (!$_smarty_tpl->tpl_vars['item_ids']->value) { ?> class="hidden"<?php } ?> > <?php echo $_smarty_tpl->getSubTemplate("pickers/orders/js.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('order_id' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "order_id" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'status' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "status" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'customer' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "customer" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'timestamp' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "timestamp" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'total' => (string) $_smarty_tpl->tpl_vars['ldelim']->value . "total" . (string) $_smarty_tpl->tpl_vars['rdelim']->value, 'holder' => $_smarty_tpl->tpl_vars['data_id']->value, 'clone' => true), 0); ?> <?php $_smarty_tpl->tpl_vars["o"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["o"]->_loop = false; $_from = $_smarty_tpl->tpl_vars['item_ids']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars["o"]->key => $_smarty_tpl->tpl_vars["o"]->value) { $_smarty_tpl->tpl_vars["o"]->_loop = true; ?> <?php $_smarty_tpl->tpl_vars["order_info"] = new Smarty_variable(fn_get_order_short_info($_smarty_tpl->tpl_vars['o']->value), null, 0); ?> <?php echo $_smarty_tpl->getSubTemplate("pickers/orders/js.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('order_id' => $_smarty_tpl->tpl_vars['o']->value, 'status' => $_smarty_tpl->tpl_vars['order_info']->value['status'], 'customer' => (string) $_smarty_tpl->tpl_vars['order_info']->value['firstname'] . " " . (string) $_smarty_tpl->tpl_vars['order_info']->value['lastname'], 'timestamp' => $_smarty_tpl->tpl_vars['order_info']->value['timestamp'], 'total' => $_smarty_tpl->tpl_vars['order_info']->value['total'], 'holder' => $_smarty_tpl->tpl_vars['data_id']->value), 0); ?> <?php } ?> <tr class="no-items <?php if ($_smarty_tpl->tpl_vars['item_ids']->value) { ?> hidden<?php } ?> " id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['data_id']->value, ENT_QUOTES, 'UTF-8'); ?> _no_item"> <td colspan="<?php if (!$_smarty_tpl->tpl_vars['view_only']->value) { ?> 6<?php } else { ?> 5<?php } ?> "><?php echo $_smarty_tpl->tpl_vars['no_item_text']->value; ?> </td> </tr> </tbody> </table> <?php } }