function submit_order($values) { if (!(isset($values['user_id']) && isset($values['token']))) { throw new Exception('user_id and token required'); } if (FALSE === VerifyToken($values['token'], $values['user_id'], NULL)) { throw new Exception('Your session has expired. Please log in again.'); } //set up all data to be passed to add_order() $userInfo = get_users(array('id' => $values['user_id'])); $email = isset($values['email']) ? $values['email'] : $userInfo['email']; $dbh = new PDOConnection(); $order = get_cart_information($dbh, $values); //TODO : customer_id $billing_addresses = get_addresses(array('user_id' => $values['user_id'], 'customer_id' => -1, 'type' => ADDRESS_TYPE_BILL)); $order['billing_address_id'] = isset($billing_addresses[0]['address_id']) ? $billing_addresses[0]['address_id'] : $order['shipping_address_id']; $orderInfo = add_order($order); order_confirmation_email(array_merge($orderInfo, array('email' => $email))); //delete cart delete_cart_by_user_id($dbh, $values['user_id']); return $orderInfo; }
} //удаление из корзины if (isset($_GET['delete'])) { //то есть кнопка была нажата $id = abs((int) $_GET['delete']); //получаем id товара, кот нужно удалить if ($id) { //проверка что этот id существует, и он не равен символам и тд,что число delete_from_card($id); } redirect(); } //координата кнопки, если она есть, значит был клик if ($_POST['order_x']) { //координата кнопки, если она есть, значит был клик add_order(); redirect(); } break; case 'reg': //регистрация break; case 'search': //поиск $result_search = search(); //постраничная навигация, параметры $perpage = 9; //кол-во товаров на страницу //получаем номер текущей стр if (isset($_GET['page'])) { $page = (int) $_GET['page'];
$order = array(); $order['customerID'] = 1; $order['locationID'] = 1; $order['pickupType'] = 'D'; $order['orderComment'] = 'Salty'; $order['shippingStreet'] = '1246 W PRATT BLVD APT 212'; $order['shippingCity'] = 'Chicago'; $order['shippingState'] = 'IL'; $order['shippingZipCode'] = '60626'; $orderLines = array(); $orderLine1 = array(); $orderLine1['itemID'] = 1; $orderLine1['unitPrice'] = 7.5; $orderLine1['quantity'] = 2; $orderLines[0] = $orderLine1; $orderLine2 = array(); $orderLine2['itemID'] = 6; $orderLine2['unitPrice'] = 4.0; $orderLine2['quantity'] = 2; $orderLines[1] = $orderLine2; $orderLine3 = array(); $orderLine3['itemID'] = 16; $orderLine3['unitPrice'] = 2.0; $orderLine3['quantity'] = 2; $orderLines[2] = $orderLine3; add_order($order, $orderLines); $success_notification = 'Test data successfully inserted'; } catch (Exception $e) { $error_notification = $e->getMessage(); } require_once '../../util/notification.php';
if ($response['status'] == 1) { break; } } if ($response['status'] == 1) { break; } $db->begin(); $status = 1; $response['order_status'] = 1; if ($cart['total_amount'] == 0) { $status = 4; $response['order_status'] = 4; } $business_account = $cart['business_account']; $order_sn = add_order($cart['total_integral'], $cart['total_product_amount'], $cart['total_delivery_fee'], $cart['delivery_id'], $business_account, $cart['total_integral_given'], $payment_id, $address_id, $cart['total_reward'], $_SESSION['account'], $cart['integral_paid'], $cart['reward_paid'], $cart['balance_paid'], $status, 0, $cart['remark']); if ($order_sn) { if ($status == 4) { $order_data = array('pay_time' => time()); $db->autoUpdate('order', $order_data, '`order_sn`=\'' . $order_sn . '\''); add_order_log($order_sn, $_SESSION['account'], 4, "使用余额/佣金/积分支付"); } if ($cart['balance_paid'] || $cart['reward_paid'] || $cart['integral_paid']) { add_memeber_exchange_log($_SESSION['account'], -1 * $cart['balance_paid'], -1 * $cart['reward_paid'], -1 * $cart['integral_paid'], 0, 0, $_SESSION['account'], "抵扣订单金额"); } $flag = true; foreach ($cart['products'] as $od) { if (!add_order_detail($od['product_sn'], $od['product_name'], $od['product_attributes'], $od['attributes'], $od['product_price'], $od['integral'], $od['integral_given'], $od['reward'], $od['count'], $business_account, $order_sn, $od['is_virtual'])) { $flag = false; } else { if ($status == 4) {
} $setmeal = get_setmeal_one($_POST['setmealid']); if ($setmeal && $setmeal['apply'] == "1") { $payment_name = empty($_POST['payment_name']) ? showmsg("请选择付款方式!", 1) : $_POST['payment_name']; $paymenttpye = get_payment_info($payment_name); if (empty($paymenttpye)) { showmsg("支付方式错误!", 0); } $fee = number_format($setmeal['expense'] / 100 * $paymenttpye['fee'], 1, '.', ''); //手续费 $order['oid'] = strtoupper(substr($paymenttpye['typename'], 0, 1)) . "-" . date('ymd', time()) . "-" . date('His', time()); //订单号 $order['v_url'] = $_CFG['site_domain'] . $_CFG['site_dir'] . "include/payment/respond_" . $paymenttpye['typename'] . ".php"; $order['v_amount'] = $setmeal['expense'] + $fee; //金额 $order_id = add_order($_SESSION['uid'], $order['oid'], $setmeal['expense'], $payment_name, "开通服务:" . $setmeal['setmeal_name'], $timestamp, "", $setmeal['id'], 3, 1); if ($order_id) { if ($order['v_amount'] == 0) { if (order_paid($order['oid'])) { $link[0]['text'] = "查看订单"; $link[0]['href'] = '?act=order_list'; $link[1]['text'] = "会员中心首页"; $link[1]['href'] = 'hunter_index.php?act='; showmsg("操作成功,系统已您开通了服务!", 2, $link); } } header("Location:?act=payment&order_id=" . $order_id . ""); //付款页面 } else { showmsg("添加订单失败!", 0); }
if ($card_cvv == null) { $cc_ccv_message = 'Required.'; } elseif (!is_valid_card_cvv($card_cvv, $card_type)) { $cc_ccv_message = 'Invalid.'; } $cc_expiration_message = ''; if ($card_expires == null) { $cc_expiration_message = 'Required.'; } elseif (!is_valid_card_expires($card_expires)) { $cc_expiration_message = 'Invalid.'; } // If error messages are not empty, // redisplay Checkout page and exit controller if (!empty($cc_number_message) || !empty($cc_ccv_message) || !empty($cc_expiration_message)) { include 'checkout/checkout_payment.php'; break; } $order_id = add_order($card_type, $card_number, $card_cvv, $card_expires); foreach ($cart as $product_id => $item) { $item_price = $item['list_price']; $discount = $item['discount_amount']; $quantity = $item['quantity']; add_order_item($order_id, $product_id, $item_price, $discount, $quantity); } clear_cart(); redirect('../account?action=view_order&order_id=' . $order_id); break; default: display_error('Unknown cart action: ' . $action); break; }
function live_crsi_buy($date, $portfolioID, $enterCRSI, $enterRange, $enterLimit, $orderBy) { global $max_num_holdings; global $max_risk; global $risk_factor; global $stop_loss_multiplier; global $portfolio_tbl; global $showOutput; global $commission; global $tranHistArray; global $portfolio_table; global $live_daily_buy_list; global $quote_table; global $liveportfolio; echo "date: ", $date, " id: ", $portfolioID, " order by: ", $orderBy, PHP_EOL; $breakOutStockArray = live_getBuyList($date, $portfolioID, $orderBy); #var_dump ($breakOutStockArray); $len_array = count($breakOutStockArray); //$risk_factor = 1 / $max_num_holdings; $portfolio_value = 0; $current_pos = 0; $next_buy_point = 100000; $stop_loss = 0; $num_shares = 0; $current_N = 0; $risk_value = 0; $purchase_value = 0; $sim_start_day = 55; $pyramid_mode = 0; $stop_loss = 0; $current_trade_date_id = 0; $workingArray = $breakOutStockArray; $adxArray = ""; $adxCount = 1; $len_array = count($breakOutStockArray); $portfolio_value = live_get_portfolio_value($date, $portfolioID); $query = "select shares from {$liveportfolio} where symbol = 'CASH' and portfolio_id = " . $portfolioID; $result = queryMysql($query); while ($data = mysql_fetch_row($result)) { $cash = $data[0]; } $buyingpower = 0; $pendingcash = 0; $query = "select sum(a.shares * b.close) from {$order_queue} a, {$quote_table} b where portfolio_id = {$portfolioID} and a.symbol = b.symbol and a.order_type like '%SELL%'"; $result = queryMysql($query); while ($data = mysql_fetch_row($result)) { $pendingcash = $data[0]; } $buyingpower = $cash + $pendingcash; #$current_risk = get_portfolio_risk($date, $portfolioID); $current_risk = live_get_portfolio_risk($date, $portfolioID); $buy_array = array(); for ($x = 0; $x < $len_array; $x++) { ### get portfolio value #$portfolio_value = get_historical_turtle_portfolio_value($date, $portfolioID); ### get current available cash #$query = "select shares from turtle_portfolio where symbol = 'CASH' and portfolio_id = ".$portfolioID; #$result = queryMysql($query); #while ($data = mysql_fetch_row($result)) { # $cash = $data[0]; #} $risk_value = $portfolio_value * $risk_factor / 100; $current_N = $breakOutStockArray[$x]['ATR']; if ($current_N > 0) { $num_shares = floor($risk_value / ($stop_loss_multiplier * $current_N)); } $purchase_price = $breakOutStockArray[$x]['close']; $purchase_value = $num_shares * $purchase_price + $commission; $stop_loss = $purchase_price - $stop_loss_multiplier * $current_N; $stop_buy = $purchase_price + $current_N; echo "buying power: ", $buyingpower, "cash: ", $cash, " purchase value: ", $purchase_value, " current risk: ", $current_risk, " max risk: {$max_risk} ", " current N: ", $current_N, " num shares: ", $num_shares, PHP_EOL; #if (($cash > $purchase_value) && ($current_risk < $max_risk)) { if ($buyingpower > $purchase_value && $current_risk < $max_risk) { #$cash = $cash - $purchase_value; $buyingpower = $buyingpower - $purchase_value; $risk_dollar = $num_shares * ($stop_loss_multiplier * $current_N); $risk_pct = $risk_dollar / $portfolio_value * 100; $current_risk += $risk_pct; $order_type = "BUY_OPEN"; $symbol = $breakOutStockArray[$x]['symbol']; #echo "date: $today symbol: $symbol num shares: $num_shares ", PHP_EOL; add_order($portfolioID, $order_type, $symbol, $num_shares); } else { #echo "trade date: $date ran out of money ", PHP_EOL; break; } } }
mysql_select_db($dbname) or die(mysql_error()); $order_queue = "order_queue"; $order_history_queue = "order_history_queue"; $portfolio = "liveportfolio"; $realtime_quote = "realtime_quote"; if ($_GET) { if ($_GET['action'] == 'execute') { $pid = 1; execute_order($pid); } elseif ($_GET['action'] == 'add') { $pid = $_GET['pid']; $pid = 1; $order_type = $_GET['order_type']; $symbol = $_GET['symbol']; $shares = $_GET['shares']; add_order($pid, $order_type, $symbol, $shares); } elseif ($_GET['action'] == 'delete') { $pid = 1; delete_order($pid, 'BUY', 'AAPL'); } elseif ($_GET['action'] == 'update') { $pid = 1; update_order($pid, 'BUY', 'AAPL', 500); } elseif ($_GET['action'] == 'get_order') { $pid = 1; get_open_order($pid); } elseif ($_GET['action'] == 'get_quote') { $pid = 1; get_yahoo_quote("AAPL+IBM+GS+BAC+FB+WYNN+SZYM+DANG+TSLA+JCP+BIDU+CMG+V+LVS"); } elseif ($_GET['action'] == 'refresh_realtime_quotes') { $pid = 1; refresh_realtime_quotes($a);
function new_order($values) { $user = get_user_by_uid($values['client']); unset($values['transfers']); unset($values['recipient']); unset($values['client']); unset($values['sub']); $values['reader'] = intval($values['reader']); $debit = 0.0; if ($user) { $swipe = add_swipe($values['reader'], $user['uid'], 1, 1); foreach ($values as $snack_id => $quantity) { if ($quantity > 0) { $snack = get_snack_by_id(intval(str_replace('snack_', '', $snack_id))); add_order($swipe, $snack['id'], $quantity); $debit += $quantity * floatval($snack['price']); } } if ($debit > 0) { debit_account($user['uid'], $debit); } } }
} } // check form $_SESSION["zf_work_tema"] = substr($_SESSION["zf_work_tema"], 0, 200); $_SESSION["zf_work_pages"] = substr($_SESSION["zf_work_pages"], 0, 50); $_SESSION["zf_work_dopinfo"] = substr($_SESSION["zf_work_dopinfo"], 0, 1000); return true; } $error = ""; if (isset($_REQUEST["forma_zakaz"])) { if (check_order_form($error)) { $client_id = add_client_if_need(1); if (!$client_id) { ErrorLogger::add('iframe_order', 'Fail to add client', $error); } if (add_order($client_id, $error)) { ob_clean(); header("location: /frame/?type=form&ok"); die; } else { ErrorLogger::add('iframe_order', 'Fail to add order', $error); } } else { ErrorLogger::add('iframe_order', 'Fail to check order form', $error); } } else { clear_saved_form(); } ?> <!-- <div class="caption_txt" id="page_caption">Заказ работы</div> -->
<?php include_once './includes/init.php'; add_order($_GET['id']); header("location: home.php");
$_POST["display_form"] = "no"; } else { $output = "客戶資料刪除發生問題"; } } else { if (isset($_POST["send_order"]) && $_POST["send_order"] == "報價傳送") { /* ##### Check if customer exists. If not, insert a new record ##### */ $found = check_customer($data["tax_id"]); if (!$found) { $cid = add_customer($data); } else { $cid = $found; } /* ################################################################## */ /* ##### Insert Order Record ##### */ $status = add_order($oid, $cid, $data); if (!$status) { $output = "建立報價單發生問題<br />"; } else { $output = "報價單資料已儲存<br />"; } /* ############################### */ /* ##### Sending Sales Order ##### */ $sender = "*****@*****.**"; $receipient = $data["email"]; $status = send_email($sender, $receipient, $data); if ($status) { $output .= "報價單已發送給客戶"; } else { $output .= "報價單傳送發生錯誤"; }
} $amount = trim($_POST['amount']) . intval($_POST['amount']) ? trim($_POST['amount']) : showmsg('请填写充值金额!', 1); $amount < $_CFG['payment_min'] ? showmsg("单笔充值金额不能少于 " . $_CFG['payment_min'] . " 元!", 1) : ''; $payment_name = empty($_POST['payment_name']) ? showmsg("请选择付款方式!", 1) : $_POST['payment_name']; $paymenttpye = get_payment_info($payment_name); if (empty($paymenttpye)) { showmsg("支付方式错误!", 0); } $fee = number_format($amount / 100 * $paymenttpye['fee'], 1, '.', ''); //手续费 $order['oid'] = strtoupper(substr($paymenttpye['typename'], 0, 1)) . "-" . date('ymd', time()) . "-" . date('His', time()); //订单号 $order['v_url'] = $_CFG['site_domain'] . $_CFG['site_dir'] . "include/payment/respond_" . $paymenttpye['typename'] . ".php"; $order['v_amount'] = $amount + $fee; $points = $amount * $_CFG['payment_rate']; $order_id = add_order($_SESSION['uid'], 4, $order['oid'], $amount, $payment_name, "充值积分:" . $points, $timestamp, $points, '', 2); if ($order_id) { header("location:?act=payment&order_id=" . $order_id); } else { showmsg("添加订单失败!", 0); } } elseif ($act == 'payment') { $smarty->assign('payment', get_payment()); $order_id = intval($_GET['order_id']); $myorder = get_order_one($_SESSION['uid'], $order_id); $payment = get_payment_info($myorder['payment_name']); if (empty($payment)) { showmsg("支付方式错误!", 0); } $fee = number_format($myorder['amount'] / 100 * $payment['fee'], 1, '.', ''); //手续费
} else { if (!preg_match("/^[0-9]{5}\$/", $_POST['shippingZipCode'])) { $error_shippingZipCode = 'Shipping zip code must be valid'; $formValidation = false; } } $order['customerID'] = $_SESSION['customer']['customerID']; $order['orderComment'] = ''; if ($order['pickupType'] == 'D') { $order['shippingStreet'] = $_POST['shippingStreet']; $order['shippingCity'] = $_POST['shippingCity']; $order['shippingState'] = $_POST['shippingState']; $order['shippingZipCode'] = $_POST['shippingZipCode']; } if ($formValidation) { $orderID = add_order($order, $_SESSION['orderLines']); $payment = array(); $payment['orderID'] = $orderID; $payment['amount'] = $_SESSION['totalPrice']; $payment['cardTypeID'] = $_POST['cardTypeID']; $payment['cardNumber'] = $_POST['cardNumber']; $payment['cardExpMonth'] = $_POST['cardExpMonth']; $payment['cardExpYear'] = $_POST['cardExpYear']; add_payment($payment); } $customer['billingStreet'] = $_POST['billingStreet']; $customer['billingCity'] = $_POST['billingCity']; $customer['billingState'] = $_POST['billingState']; $customer['billingZipCode'] = $_POST['billingZipCode']; if ($order['pickupType'] == 'D') { $customer['shippingStreet'] = $_POST['shippingStreet'];
break; case 'delete_cart_detail': include_once __DIR__ . '/orders/delete_cart.php'; $responseArray['response'] = delete_cart_detail($values); $responseArray['status'] = 'success'; $responseArray['message'] = 'Successfully deleted cart line'; break; case 'submit_order': include_once __DIR__ . '/orders/submit_order.php'; $responseArray['response'] = submit_order($values); $responseArray['status'] = 'success'; $responseArray['message'] = 'Order successfully submited'; break; case 'add_order': include_once __DIR__ . '/orders/add_order.php'; $responseArray['response'] = add_order($values); $responseArray['status'] = 'success'; $responseArray['message'] = 'Added order'; break; case 'get_orders': include_once __DIR__ . '/orders/get_orders.php'; $responseArray['response'] = get_orders($values); $responseArray['status'] = 'success'; $responseArray['message'] = 'Orders successfully read'; break; case 'get_order_detail': include_once __DIR__ . '/orders/get_orders.php'; $responseArray['response'] = get_order_detail($values); $responseArray['status'] = 'success'; $responseArray['message'] = 'Order details successfully read'; break;
<?php require_once 'header.php'; ?> <div class="container theme-showcase" role="main"> <div class="jumbotron"> <h1>Cadastro de novos pedidos</h1> <p>Preencha o formulário para adicionar um novo pedido.</p> </div> <?php if ($_POST) { if (add_order($_POST['product'], $_POST['client'], $connection) == 'true') { echo '<div class="row"><div class="alert alert-success" role="alert"><strong>Sucesso! </strong>Seu pedido foi adicionado.</div></div>'; } else { echo '<div class="alert alert-danger" role="alert"><strong>Ops... </strong> Houve um erro, tente novamente.</div>'; } } ?> <div class="row"> <div class="col-md-8"> <form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?> " role="form"> <div class="form-group"> <label for="product">Produto:</label> <select class="form-control" id="product" name="product" required> <?php $products = get_list('produto', ' ', $connection); foreach ($products as $product) { echo '<option value="' . $product['id'] . '">' . $product['nome'] . '</option>';