function customerStatus($status) { if (k_is_ambassador($status)) { $result = 'Ambassador'; } elseif (k_is_bp($status)) { $result = 'Business Partner'; } else { switch ($status) { case 'P': $result = 'Press'; break; case 'D': $result = 'J&G Designer'; break; default: $result = 'J&G Friends'; } } return $result; }
$prototal += $p['qty']; $subtotal += $p['qty'] * $p['price']; } $shipping_text = isset($order_create['info']['shipping_text']) ? $order_create['info']['shipping_text'] : 'Versandkosten:'; if (!isset($order_create['info']['shipping_cost'])) { $free_shipping_query = tep_db_query("SELECT configuration_key, configuration_value FROM configuration c WHERE configuration_key LIKE 'MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING%'"); while ($row = tep_db_fetch_array($free_shipping_query)) { define($row['configuration_key'], $row['configuration_value']); } $shipping_cost = MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING == 'true' && $subtotal > MODULE_ORDER_TOTAL_SHIPPING_FREE_SHIPPING_OVER ? 0 : 3.9; } else { $shipping_cost = $order_create['info']['shipping_cost']; } $payment_method = isset($order_create['info']['payment_method']) ? $order_create['info']['payment_method'] : PAYMENT_METHOD_BANK_TRANSFER; $payment_options = array(PAYMENT_METHOD_BANK_TRANSFER); if (k_is_bp($customer['status'])) { $payment_options[] = PAYMENT_METHOD_INVOICE; } $banktransfer_query = tep_db_query("SELECT b.* FROM banktransfer b INNER JOIN orders o ON o.orders_id=b.orders_id AND o.customers_id={$customer['id']} ORDER BY o.customers_order_count DESC LIMIT 1"); $banktransfer_name = PAYMENT_METHOD_DIRECT_DEBIT; $banktransfer_info = ''; if (tep_db_num_rows($banktransfer_query) == 1) { $payment_options[] = $banktransfer_name; $banktransfer = tep_db_fetch_array($banktransfer_query); $bt_ao = $banktransfer['banktransfer_owner']; $bt_an = $banktransfer['banktransfer_number']; $bt_bn = $banktransfer['banktransfer_bankname']; $bt_bc = $banktransfer['banktransfer_blz']; $display = $payment_method == $banktransfer_name ? '' : 'display:none;'; $banktransfer_info .= '<div id="banktransfer_info" class="ui-widget-content ui-corner-all padding" style="' . $display . 'margin-top:10px;">'; $banktransfer_info .= '<h3><strong>Account Info</strong> <small>(retrieved from last order)</small></h3>';
$pquery = "SELECT p.products_id AS id, p.products_model AS model, pd.products_name AS name, {$pqty} AS qty, p.products_price AS price FROM products p"; $pquery .= " LEFT JOIN products_description pd ON pd.products_id=p.products_id AND pd.language_id={$lid}"; $pquery .= " WHERE p.{$pfilter}='{$pdata}'"; $presult = tep_db_query($pquery); if (tep_db_num_rows($presult) == 1) { if (!isset($order_create['products'])) { $order_create['products'] = array(); } $product = tep_db_fetch_array($presult); $pid = $product['id']; if (isset($order_create['products'][$pid])) { $order_create['products'][$pid]['qty'] += $pqty; } else { //CHECK CUSTOMER STATUS FOR DISCOUNT CALCULATION $is_ambassador = k_is_ambassador($order_create['customer']['status']); $is_bp = k_is_bp($order_create['customer']['status']); //PROCESS DISCOUNT if ($is_ambassador) { $product['price'] = k_calculate_ambassador_price($product['price'], $product['model']); } elseif ($is_bp) { $product['price'] = k_calculate_bp_price($product['price'], $product['model']); } $order_create['products'][$pid] = $product; } $_SESSION['order-create'] = serialize($order_create); } else { $messagebox->add("<strong>{$pfieldtype} {$pdata}</strong> is not found / not specific enough"); } } elseif ($_POST['me_action'] == 'CREATEORDERUPDATEQTY') { foreach ($_POST['pqty'] as $key => $quantity) { $pid = tep_db_prepare_input($key);
$(this).remove(); $("input[name=Cancel]:visible").each(function() { $(this).click(); }); }); }); '; if (isset($_GET['opid']) && $_GET['opid'] != '') { $opid = tep_db_prepare_input($_GET['opid']); $javascript .= ' $("#pi-' . $opid . '").parents("tr:eq(0)").find("td").addClass("red bold"); '; } if (isset($openspeciallistdetail) && $openspeciallistdetail === true) { $javascript .= ' $("#btn_csl_detail").click(); '; } if (k_is_bp($order['customers_status'])) { $title = $order_sl_icon . 'J&G BP Order ' . $order['orders_no'] . $order_sl_type; } else { $title = $order_sl_icon . 'J&G Order ' . $order['orders_no'] . $order_sl_type; } $title .= ' ⋅ <a href="?open=customer-care-order-detail&source=JG&id=' . $order_id . '" target="_blank">Open New Order Detail »</a>'; } else { $content = '<div style="color:#f00"><strong>BAD ORDER ID</strong>, NO RELATED DATA FOUND</div>'; $content .= '<div> </div>'; $content .= $idform; $title = 'J&G Order Detail'; } }
$year = date('Y'); $order_no_query = tep_db_query("SELECT orders_id FROM orders_random_no WHERE year='{$year}' AND status='0' ORDER BY RAND() LIMIT 1"); $order_no = tep_db_fetch_array($order_no_query); //GET CUSTOMER ORDER COUNT $order_count_query = tep_db_query("SELECT COUNT(orders_id) AS total_orders FROM orders WHERE customers_id={$customer['id']}"); $order_count_fetch = tep_db_fetch_array($order_count_query); $order_count = $order_count_fetch['total_orders'] + 1; //INSERT ORDER DATA TO DB $order_DA = array('customers_id' => $customer['id'], 'customers_name' => $customer['name'], 'customers_company' => $customer['entry_company'], 'customers_street_address' => $customer['entry_street_address'], 'customers_suburb' => $customer['entry_suburb'], 'customers_city' => $customer['entry_city'], 'customers_postcode' => $customer['entry_postcode'], 'customers_state' => $customer['entry_state'], 'customers_country' => $customer['countries_name'], 'customers_telephone' => $customer['customers_telephone'], 'customers_email_address' => $customer['email'], 'customers_address_format_id' => $customer['address_format_id'], 'delivery_name' => "{$shipping['entry_firstname']} {$shipping['entry_lastname']}", 'delivery_company' => $shipping['entry_company'], 'delivery_street_address' => $shipping['entry_street_address'], 'delivery_suburb' => $shipping['entry_suburb'], 'delivery_city' => $shipping['entry_city'], 'delivery_postcode' => $shipping['entry_postcode'], 'delivery_state' => $shipping['entry_state'], 'delivery_country' => $shipping['countries_name'], 'delivery_address_format_id' => $shipping['address_format_id'], 'billing_name' => "{$billing['entry_firstname']} {$billing['entry_lastname']}", 'billing_company' => $billing['entry_company'], 'billing_street_address' => $billing['entry_street_address'], 'billing_suburb' => $billing['entry_suburb'], 'billing_city' => $billing['entry_city'], 'billing_postcode' => $billing['entry_postcode'], 'billing_state' => $billing['entry_state'], 'billing_country' => $billing['countries_name'], 'billing_address_format_id' => $billing['address_format_id'], 'payment_method' => $order_create['info']['payment_method'], 'cc_type' => '', 'cc_owner' => '', 'cc_number' => '', 'cc_expires' => '', 'date_purchased' => date("Y-m-d H:i:s"), 'orders_status' => $new_order_status, 'currency' => $currency, 'currency_value' => $currency_value, 'customers_status' => $customer['status'], 'orders_no' => $order_no['orders_id'], 'customers_order_count' => $order_count); tep_db_perform('orders', $order_DA); $order_id = tep_db_insert_id(); tep_db_query("UPDATE orders_random_no SET status='1' WHERE orders_id='{$order_no['orders_id']}'"); $order_status_DA = array('orders_id' => $order_id, 'orders_status_id' => $new_order_status, 'date_added' => date("Y-m-d H:i:s"), 'customer_notified' => '0', 'comments' => $order_create['info']['comment']); tep_db_perform('orders_status_history', $order_status_DA); $product_tax = 0; $is_bp = k_is_bp($customer['status']); $subtotal = 0; $products_total = count($order_create['products']); $products_count = 0; $exp_delivery_date = date('Y-m-d', strtotime("+9")); foreach ($order_create['products'] as $pid => $p) { $products_count++; $product_query = tep_db_query("SELECT p.products_price FROM products p WHERE p.products_id={$pid}"); $product = tep_db_fetch_array($product_query); if ($is_bp) { $p['final_price'] = k_calculate_bp_price($product['products_price'], $p['model'], true); } else { $p['final_price'] = $p['price']; } $p['price'] = $product['products_price']; $order_products_DA = array('orders_id' => $order_id, 'products_id' => $p['id'], 'products_model' => $p['model'], 'products_name' => $p['name'], 'products_price' => $p['price'], 'final_price' => $p['final_price'], 'products_tax' => $product_tax, 'products_quantity' => $p['qty'], 'order_item_count' => $products_count, 'order_item_total' => $products_total, 'status' => '1', 'expected_delivery_date' => $exp_delivery_date);