static function loadByPaymentTracker($paymentHash)
 {
     $orderObj = new Order();
     $orderObj->select($paymentHash, 'payment_hash');
     if (!$orderObj->ok()) {
         return false;
     }
     return $orderObj;
 }
Exemplo n.º 2
0
		<hr>
		<?php 
$db = Database::getInstance();
$sql = "SELECT DISTINCT {$summary} from orders ORDER BY {$summary} ";
if ($summary == 'date') {
    $sql .= "DESC";
} else {
    $sql .= "ASC";
}
$stmt = $db->handle->prepare($sql);
if ($stmt->execute()) {
    $all_rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if (!empty($all_rows)) {
        $i = 1;
        foreach ($all_rows as $row) {
            $orders = Order::select("SELECT id, menu_item_id, SUM(quantity) as quantity FROM orders WHERE {$summary} = '{$row[$summary]}' GROUP BY menu_item_id");
            $tot = 0;
            ?>
						<div class="panel-group" role="tablist">
							<div class="panel panel-success">
						      	<div class="panel-heading" role="tab" id="collapseListGroupHeading<?php 
            echo $i;
            ?>
">
							        <h4 class="panel-title">
							          	<a class="collapsed center-block" data-toggle="collapse" href="#collapseListGroup<?php 
            echo $i;
            ?>
" aria-expanded="true" aria-controls="collapseListGroup<?php 
            echo $i;
            ?>
Exemplo n.º 3
0
            $name_link = 'name-asc';
            $sql .= ' ORDER BY menu_item.name DESC';
            break;
        case 'quantity-asc':
            $quantity_link = 'quantity-desc';
            $sql .= ' ORDER BY quantity ASC';
            break;
        case 'quantity-desc':
            $quantity_link = 'quantity-asc';
            $sql .= ' ORDER BY quantity DESC';
            break;
    }
} else {
    redirect_to('index.php?by=name-asc');
}
$all_orders = Order::select($sql);
if ($all_orders != 0) {
    if (is_object($all_orders)) {
        $all_orders = array($all_orders);
    }
    ?>
				<div class="collapse in" id="orderTable" style="margin-bottom: 40px">
				<table class="table table-bordered">
					<tr>
						<th><a href="index.php?by=<?php 
    echo $name_link;
    ?>
" class="center-block">Item</a></th>
						<th><a href="index.php?by=<?php 
    echo $quantity_link;
    ?>
Exemplo n.º 4
0
 public function listSellOrders()
 {
     $token = Input::get('token', '');
     $u_id = Input::get('u_id', 0);
     $status = Input::get('status') ? Input::get('status') : '1,2';
     $key_word = Input::get('key', '');
     $finish = Input::get('finish', 0);
     $from = Input::get('from', '');
     $to = Input::get('to', '');
     $per_page = Input::get('per_page', 30);
     try {
         $user = User::chkUserByToken($token, $u_id);
         $booths = Booth::where('u_id', '=', $u_id)->lists('b_id');
         if (empty($booths)) {
             throw new Exception("您还没有任何店铺", 7001);
         }
         $query = Order::select('orders.*')->with(['carts'])->whereIn('carts.b_id', $booths)->leftJoin('carts', function ($j) {
             $j->on('orders.o_id', '=', 'carts.o_id');
         });
         if ($key_word) {
             $query = $query->where(function ($q) use($key_word) {
                 $q->where('carts.p_name', 'LIKE', '%' . $key_word . '%')->orWhere('orders.o_number', 'LIKE', '%' . $key_word . '%');
             });
         }
         if ($from) {
             $query = $query->where('orders.created_at', '>', $from);
         }
         if ($to) {
             $query = $query->where('orders.created_at', '<', $to);
         }
         $status = explode(',', $status);
         $query = $query->where(function ($q) use($status) {
             if (in_array(Order::$STATUS_UNFINISHED, $status)) {
                 $q = $q->orWhere(function ($qq) {
                     $qq->where('orders.o_shipping_status', '<>', 10)->orWhere('orders.o_status', '<>', 2);
                 });
             }
             if (in_array(Order::$STATUS_FINISHED, $status)) {
                 $q = $q->orWhere(function ($qq) {
                     $qq->orWhere('orders.o_shipping_status', '=', 10)->where('orders.o_status', '=', 2);
                 });
             }
             if (in_array(Order::$STATUS_PACKED, $status)) {
                 $q = $q->orWhere('orders.o_shipping_status', '=', 1);
             }
             if (in_array(Order::$STATUS_SHIPPED, $status)) {
                 $q = $q->orWhere('orders.o_shipping_status', '=', 5);
             }
             if (in_array(Order::$STATUS_ORDERED, $status)) {
                 $q = $q->orWhere('orders.o_status', '=', 1);
             }
             if (in_array(Order::$STATUS_PAIED, $status)) {
                 $q = $q->orWhere(function ($qq) {
                     $qq->where('orders.o_status', '=', 2)->where('orders.o_shipping_status', '<>', 10);
                 });
             }
         });
         // filter out invalide orders
         $query = $query->where('orders.o_status', '<>', 0)->where('orders.o_status', '<>', 3);
         $list = $query->groupBy('carts.o_id')->orderBy('orders.created_at', 'DESC')->paginate($per_page);
         $data = [];
         if (array_intersect($status, [Order::$STATUS_UNFINISHED, Order::$STATUS_FINISHED])) {
             $mask = 'all';
         } elseif (array_intersect($status, [Order::$STATUS_PACKED, Order::$STATUS_SHIPPED])) {
             $mask = 'shipping';
         } elseif (array_intersect($status, [Order::$STATUS_ORDERED, Order::$STATUS_PAIED])) {
             $mask = 'order';
         }
         foreach ($list as $key => $order) {
             $tmp = $order->showDetail(true);
             if ($status) {
                 $tmp['status'] = $order->mapOrderStatus($mask);
             }
             $data[] = $tmp;
         }
         $re = Tools::reTrue('获取订单成功', $data, $list);
     } catch (Exception $e) {
         $re = Tools::reFalse($e->getCode(), '获取订单失败:' . $e->getMessage());
     }
     return Response::json($re);
 }
Exemplo n.º 5
0
    if ($employee->update('user_id')) {
        $alert_array['success'] = 'The account was successfully updated!';
    } else {
        $alert_array['error'] = 'The account was not updated!';
    }
}
if (isset($_GET['id']) && is_int(intval($_GET['id']))) {
    $id = intval($_GET['id']);
    $user = User::select(array('id' => $id));
    $employee = Employee::select(array('user_id' => $id));
    if (!$user || !$employee) {
        redirect_to('account.view.php');
    }
    if (isset($_GET['clearBalance']) && $_GET['clearBalance'] == 'Continue') {
        if (isset($_GET['deleteOrders']) && $_GET['deleteOrders'] == 'on') {
            $orders = Order::select(array('user_id' => $user->id));
            if (is_object($orders)) {
                $orders = array($orders);
            }
            if (!$orders) {
                $alert_array['error'] = "The balance is already zero! ";
            } else {
                foreach ($orders as $order) {
                    $order->delete();
                }
            }
        }
        $employee->balance = 0;
        if ($employee->update('user_id') && !isset($alert_array['error'])) {
            $alert_array['success'] = 'The account was successfully updated!';
        } else {
Exemplo n.º 6
0
<?php

require 'includes/functions.php';
include 'templates/header.php';
$alertArray = array();
if (isset($_POST['submit'])) {
    // ADD THE TOTAL COST OF THE ORDER TO THE USER ACCOUNT BALANCE
    $total_cost = 0;
    foreach ($_POST as $key => $value) {
        if ($key != "submit") {
            if (!empty($value)) {
                $order = new Order();
                $order->menu_item_id = substr($key, 5);
                $order->quantity = $value;
                $order->user_id = $session->user_id;
                $old_order = Order::select(array('menu_item_id' => substr($key, 5), 'user_id' => $order->user_id, 'date' => today()));
                $menu_item = MenuItem::select(array('id' => $order->menu_item_id));
                // IF THE SAME ITEM HAS BEEN ORDERED TODAY, UPDATE THE ORDER
                if (is_object($old_order)) {
                    $old_order->quantity += $value;
                    //echo "<script>alert('update')</script>";
                    if ($old_order->update()) {
                        $alertArray['success'] = 'The order has been updated!';
                        // ADD THE COST TO TOTAL COST
                        $total_cost = $value * $menu_item->cost;
                    } else {
                        $alertArray['error'] = 'The items could not be ordered!';
                    }
                } else {
                    //echo "<script>alert('update')</script>";
                    if ($order->insert()) {
Exemplo n.º 7
0
$header = "orders";
include 'templates/sidebar.php';
?>
<div class="row" style="margin-right: 0">
	<div class="col-md-6 col-md-offset-3 page-wrapper">
		<h2>My Orders</h2>
		<hr>
		<?php 
$db = Database::getInstance();
$stmt = $db->handle->prepare("SELECT DISTINCT date from orders WHERE user_id=? ORDER BY date DESC");
if ($stmt->execute(array($session->user_id))) {
    $all_dates = $stmt->fetchAll(PDO::FETCH_ASSOC);
    if (!empty($all_dates)) {
        $i = 1;
        foreach ($all_dates as $row) {
            $orders = Order::select(array('date' => $row['date'], 'user_id' => $session->user_id));
            $tot = 0;
            ?>
						<div class="panel-group" role="tablist">
						    <div class="panel panel-success">
						      	<div class="panel-heading" role="tab" id="collapseListGroupHeading<?php 
            echo $i;
            ?>
">
							        <h4 class="panel-title">
							          	<a class="collapsed center-block" data-toggle="collapse" href="#collapseListGroup<?php 
            echo $i;
            ?>
" aria-expanded="true" aria-controls="collapseListGroup<?php 
            echo $i;
            ?>
Exemplo n.º 8
0
require 'includes/master.inc.php';
$post = trim(file_get_contents('php://input'));
$post = base64_decode($post);
$dict = json_decode($post);
$a = new Activation();
$a->app_id = $dict->app_id;
$a->name = $dict->email;
$a->serial_number = $dict->serial;
$a->dt = dater();
$a->ip = $_SERVER['REMOTE_ADDR'];
$a->insert();
$app = new Application($a->app_id);
if (!$app->ok()) {
    die('serial');
}
$o = new Order();
$o->select($a->serial_number, 'serial_number');
if (!$o->ok()) {
    die('serial');
}
// Because we die before the activation is updated with the found order id,
// this has the added benefit of highlighting the activation as "fraudulent"
// in the activations list. It's not fraudulent obviously, but it does let
// us quickly see if deactivated licenses are still being used.
if ($o->deactivated == 1) {
    die('serial');
}
$a->order_id = $o->id;
$a->update();
$o->downloadLicense();
Exemplo n.º 9
0
    public static function getOrders($arrData)
    {
        $arrReturn = ['status' => 'ok', 'data' => []];
        $arrData['fromDate'] = date('Y-m-d', strtotime($arrData['fromDate'])) . ' 00:00:00';
        $arrData['toDate'] = date('Y-m-d', strtotime($arrData['toDate'])) . ' 23:59:59';
        $orders = Order::select(DB::raw('DATE(created_at) as date, id, status, sum_amount'))->whereBetween('created_at', [$arrData['fromDate'], $arrData['toDate']]);
        if (!empty($arrData['status'])) {
            $orders->where('status', $arrData['status']);
        }
        $orders = $orders->orderBy('id', 'asc')->get();
        $data = [];
        if ($arrData['groupBy'] == 'day') {
            $dateRange = new DatePeriod(new DateTime($arrData['fromDate']), new DateInterval('P1D'), new DateTime($arrData['toDate']));
            foreach ($dateRange as $date) {
                $data[$date->format('m-d')] = [$date->format('M d'), 0, ''];
            }
        } else {
            if ($arrData['groupBy'] == 'month') {
                $dateRange = new DatePeriod(new DateTime($arrData['fromDate']), new DateInterval('P1M'), new DateTime($arrData['toDate']));
                foreach ($dateRange as $date) {
                    $data[$date->format('Y-m')] = [$date->format('M Y'), 0, ''];
                }
            } else {
                $dateRange = new DatePeriod(new DateTime($arrData['fromDate']), new DateInterval('P1Y'), new DateTime($arrData['toDate']));
                foreach ($dateRange as $date) {
                    $data[$date->format('Y')] = [$date->format('Y'), 0, ''];
                }
            }
        }
        if (!$orders->isEmpty()) {
            $label = ['New' => 'label-default', 'Submitted' => 'label-info', 'In production' => 'label-primary', 'Partly shipped' => 'label-warning', 'Completed' => 'label-success', 'Cancelled' => 'label-danger'];
            foreach ($orders as $order) {
                list($year, $m, $day) = explode('-', $order->date);
                $month = date('M', strtotime($order->date));
                if ($arrData['groupBy'] == 'day') {
                    $originKey = $m . '-' . $day;
                    $key = $month . ' ' . $day;
                } else {
                    if ($arrData['groupBy'] == 'month') {
                        $originKey = $year . '-' . $m;
                        $key = $month . ' ' . $year;
                    } else {
                        $originKey = $year;
                        $key = $year;
                    }
                }
                if (!empty($arrData['category'])) {
                    $categoryId = $arrData['category'];
                    $order->order_details = OrderDetail::select('sum_amount')->where('order_id', $order->id)->whereRaw('(SELECT COUNT(*)
											FROM `categories` INNER JOIN `products_categories`
												ON `categories`.`id` = `products_categories`.`category_id`
											WHERE `products_categories`.`product_id` = `order_details`.`product_id`
											AND `categories`.`id` = ' . $categoryId . ') >= 1')->get();
                    $amount = 0;
                    if (isset($order->order_details)) {
                        foreach ($order->order_details as $detail) {
                            $amount += $detail->sum_amount;
                        }
                    }
                    if (!$amount) {
                        continue;
                    }
                } else {
                    $amount = $order->sum_amount;
                }
                $order->status = '<span class="label ' . $label[$order->status] . '">' . $order->status . '</span>';
                if (!isset($data[$originKey])) {
                    $data[$originKey] = [$key, $amount, 'Order #' . $order->id . ' - ' . $order->status . ' $ ' . number_format($amount, 2)];
                } else {
                    $data[$originKey][1] += $amount;
                    $data[$originKey][2] .= '<br />Order #' . $order->id . ' - ' . $order->status . ' $ ' . number_format($amount, 2);
                }
            }
        }
        ksort($data);
        $arrReturn['data'] = array_values($data);
        return $arrReturn;
    }
Exemplo n.º 10
0
<?php

require 'includes/master.inc.php';
$o = new Order();
$o->select($_GET['tx'], 'txn_id');
if ($o->ok()) {
    $app = new Application($o->app_id);
    redirect($app->return_url . '?email=' . $o->payer_email . '&reg=' . $o->license);
} else {
    die("Thank you for your order. Your registration information will be emailed to you shortly. If you have any questions, feel free to contact <a href='mailto:support@clickontyler.com'>support@clickontyler.com</a>");
}
Exemplo n.º 11
0
 public function listOrders()
 {
     if (Auth::user()->check()) {
         $page = Input::has('page') ? Input::get('page') : 1;
         $take = Input::has('take') ? Input::get('take') : 10;
         $skip = ($page - 1) * $take;
         $data = Order::select('orders.id', 'orders.status', 'orders.sum_amount', 'orders.note', 'orders.created_at', 'orders.billing_address_id', 'orders.shipping_address_id')->with('orderDetails')->where('orders.user_id', Auth::user()->get()->id)->orderBy('orders.id', 'desc')->groupBy('orders.id');
         $total_order = $data->get()->count();
         $total_page = ceil($total_order / $take);
         $from = $page - 2 > 0 ? $page - 2 : 1;
         $to = $page + 2 <= $total_page ? $page + 2 : $total_page;
         $data = $data->skip($skip)->take($take)->get();
         $arr_orders = array();
         if ($data->count() > 0) {
             $i = 0;
             foreach ($data as $key => $value) {
                 $arr_orders[$i]['order_id'] = $value->id;
                 $arr_orders[$i]['status'] = $value->status;
                 $arr_orders[$i]['sum_amount'] = $value->sum_amount;
                 $arr_orders[$i]['note'] = $value->note;
                 $arr_orders[$i]['created_at'] = $value->created_at;
                 //Get billing address
                 $obj_address = Address::findOrFail($value->billing_address_id);
                 if ($obj_address) {
                     $billing_address = $obj_address->toHtml();
                     $arr_orders[$i]['billing_address'] = $billing_address;
                 }
                 //Get shipping address
                 $obj_address = Address::findOrFail($value->shipping_address_id);
                 if ($obj_address) {
                     $shipping_address = $obj_address->toHtml();
                     $arr_orders[$i]['shipping_address'] = $shipping_address;
                 }
                 //Order Details
                 $order_details = $value->order_details;
                 foreach ($order_details as $key1 => $value1) {
                     $viimage = VIImage::findOrFail($value1->image_id);
                     $options = new Product();
                     $options->path_thumb = '/pic/thumb/' . $viimage->short_name . '-' . $viimage->id . '.jpg';
                     $options->order_type = $value1->type;
                     $options->size = $value1->size;
                     $option = $value1->option;
                     $arr_option = [];
                     if ($option != null && $option != '') {
                         $arr_option_key = explode(",", $option);
                         foreach ($arr_option_key as $option_key) {
                             $data_option = ProductOption::select('options.name', 'options.key', DB::raw('option_groups.name as type'), DB::raw('option_groups.key as type_key'))->join('option_groups', 'options.option_group_id', '=', 'option_groups.id')->where('options.key', $option_key)->first();
                             $arr_option[] = ['type' => $data_option->type, 'type_key' => $data_option->type_key, 'key' => $data_option->key, 'value' => $data_option->name];
                         }
                     }
                     $options->options = $arr_option;
                     $value1->options = $options;
                     $value1->viimage = $viimage;
                     $value1->price = $value1->sell_price;
                     $value1->qty = $value1->quantity;
                     $value1->subtotal = $value1->sum_amount;
                     $value1->name = $viimage->name;
                     $value1->rowid = $viimage->id . '_' . $value1->id;
                     $order_details[$key1] = $value1;
                 }
                 // echo "<pre>";
                 // print_r($order_details[0]->options);
                 // echo "</pre>";
                 // exit;
                 $arr_orders[$i]['order_details'] = $order_details;
                 $i++;
             }
         }
         $this->layout->metaTitle = Auth::user()->get()->first_name . '\'s Orders';
         $this->layout->content = View::make('frontend.order.list-order', ['arr_orders' => $arr_orders, 'total_order' => $total_order, 'total_page' => $total_page, 'current' => $page, 'from' => $from, 'to' => $to]);
         return;
     }
     return Redirect::route('account-sign-in');
 }