if ($_POST['edit_customer']) { $values = $_POST; unset($values['edit_customer']); if (!edit_customer($values)) { $error_template = "Помилка збереження: " . mysql_error(); } } ?> <h2>Список замовлень</h2> <div class="table"> <div class="table-header"> </div> <?php $res = get_all_orders(); ?> <?php while ($row = mysql_fetch_array($res, MYSQL_BOTH)) { ?> <div class="description"> <form method="post"> <ul> <li> <select name="status"> <?php foreach (OrderStatus::get() as $k => $v) { ?> <option <?php
<?php if (!isset($_SESSION['user'])) { header('location: /'); exit; } import('pagination'); import('checkout'); $pagination = array(); $orders = get_all_orders($pagination); $template = set_template('test', 'orders'); $link = THEME . 'template2.php'; require_once $link;
echo json_encode($response); } elseif ('permissions' == $_GET['uri'] && isset($_GET['uid']) && isset($_GET['id'])) { send_headers(); $permission = get_permission($_GET['uid'], $_GET['id']); echo json_encode($permission); } elseif ('permissions' == $_GET['uri'] && isset($_GET['id'])) { send_headers(); $permissions = get_reader_permissions($_GET['id']); echo json_encode($permissions); } elseif ('orders' == $_GET['uri'] && isset($_GET['id'])) { send_headers(); $orders = get_all_orders_by_uid($_GET['id']); echo json_encode($orders); } elseif ('orders' == $_GET['uri']) { send_headers(); $orders = get_all_orders(); echo json_encode($orders); } elseif ('swipes' == $_GET['uri'] && isset($input['uid']) && isset($input['service']) && isset($_GET['id'])) { if ($input['service'] == 1 && is_payment_reader($_GET['id'])) { // This is a payment request $owner = get_tag_owner($input['uid']); if ($owner && $input['order']) { $user = get_user_by_uid($owner); $input['order']['client'] = $user['uid']; $input['order']['reader'] = $_GET['id']; new_order($input['order']); // get the new user balance $user = get_user_by_uid($user['uid']); send_headers(); $response = array("version" => $version, "response" => "OK", "uid" => $user['uid'], "balance" => floatval($user['balance'])); echo json_encode($response);
function list_orders_action($uid) { // needed to set the tab active $extras_active = true; $orders_active = true; if (user_is_admin($uid)) { // list all the orders $orders = get_all_orders(); require 'templates/orders.php'; } else { require 'templates/login.php'; } }
if ($return_code) { set_response_code_data($response, $api_response_code, 4); $response['data'] = 'The order was successfully placed'; } else { set_response_code_data($response, $api_response_code, 0); $response['data'] = "An unknown error occurred while creating the specified record"; } } else { set_response_code_data($response, $api_response_code, 2); $response['data'] = 'The order was not able to be processed, possibly due to missing values'; } } elseif ($_SERVER['REQUEST_METHOD'] === 'GET') { $response['type'] = array_key_exists('type', $_GET) ? $_GET['type'] : $DEFAULT_TYPE; $response['type'] = array_key_exists($response['type'], $supported_types) ? $response['type'] : $DEFAULT_TYPE; if (array_key_exists('scope', $_GET) && $_GET['scope'] == 'all') { get_all_orders($response); set_response_code_data($response, $api_response_code, 1); if (count($response['data']) < 1) { set_response_code_data($response, $api_response_code, 0); } } else { set_response_code_data($response, $api_response_code, 0); $response['data'] = 'The request was missing the scope key or the value was unsupported'; $response['wait-time'] = NULL; } } else { // why would this ever happen? unsupported methods perhaps 405 todo $response['type'] = $DEFAULT_TYPE; set_response_code_data($response, $api_response_code, 2); $response['data'] = 'Something really strange happened because this shouldn\'t ever be seen'; }
break; } // reached last index (avoid breaking the app :D) update_quantity($key, $quantity); } // clear the cart from invalid cart items with SORRY message (NOT IMPLEMENTED) } if (isset($_POST['checkout'])) { $total_price = calculate_total_price($cart_id); $user_credit = get_user_credit($_SESSION['id']); if ($total_price > $user_credit) { echo "Please Recharge , Credit not enough"; // error message (out of credit) } else { //get orders $results = get_all_orders($cart_id); //process each one //invalid item array $invalid_items = array(); while ($cart_item = mysqli_fetch_row($results)) { $item_id = $cart_item[3]; $item_quantity = (int) get_item($item_id)[3]; // quantity of item (IN STOCK) if ($item_quantity == 0) { // put them in array $invalid_items[] = $cart_item[0]; // cart_item id } else { $new_quantity = $item_quantity - $cart_item[2]; // new in stock quantity reduce_quantity($item_id, $new_quantity);
//已评价的订单 $sql = "SELECT COUNT(*) FROM " . $ecs->table('order_info') . " as oi inner join " . $ecs->table('comment') . " as c on oi.order_id=c.order_id WHERE oi.user_id = '{$user_id}'" . $all_order_list->where[$i]; $record_count = $db->getOne($sql); break; case 2: //待评价的订单 $record_count = $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " WHERE user_id = '{$user_id}'" . $all_order_list->where[$i]) - $db->getOne("SELECT COUNT(*) FROM " . $ecs->table('order_info') . " as oi inner join " . $ecs->table('comment') . " as c on oi.order_id=c.order_id WHERE oi.user_id = '{$user_id}'" . $all_order_list->where[$i]); break; } /* echo "<pre>"; print_r($all_order_list->pager); echo "</pre>"; */ $all_order_list->pager[$i] = get_pager('user.php', array('act' => $action), $record_count, $page, 10, "page{$i}=", "&ctl={$i}"); $all_order_list->orders[$i] = get_all_orders($user_id, $all_order_list->pager[$i]['size'], $all_order_list->pager[$i]['start'], $all_order_list->where[$i], $all_order_list->comment[$i]); } $smarty->assign("all_pages", $all_order_list->pager); $smarty->assign("all_orders", $all_order_list->orders); $smarty->assign("all_infos", $all_order_list->info); $smarty->display('user_clips.dwt'); } elseif ($action == 'order_detail') { include_once ROOT_PATH . 'includes/lib_transaction.php'; include_once ROOT_PATH . 'includes/lib_payment.php'; include_once ROOT_PATH . 'includes/lib_order.php'; include_once ROOT_PATH . 'includes/lib_clips.php'; $order_id = isset($_GET['order_id']) ? intval($_GET['order_id']) : 0; /* 订单详情 */ $order = get_order_detail($order_id, $user_id); if ($order === false) { $err->show($_LANG['back_home_lnk'], './');
function update_purchase_history($user_id, $cart_id) { $cart_items = get_all_orders($cart_id); $time = strftime("%H:%M:%S %d/%m/%Y", time()); while ($cart_item = mysqli_fetch_row($cart_items)) { $item = get_item($cart_item[3]); $item_name = $item[1]; $item_price = (double) $item[2]; $item_quantity = (int) $cart_item[2]; update_purchase_history_item($user_id, $item_name, $item_price, $item_quantity, $time); } }