function update($request) { $order = Orders::find($request['id']); if ($order) { $order = $this->setProperties($order, $request); $order->save(); return $order; } }
public function actionSearch($term) { $model = Clients::find()->where(['like', 'name', $term])->limit(10)->all(); foreach ($model as $key => $data) { $orders = Orders::find()->where(['clientId' => $data->id])->count(); $array[$key]['id'] = $data->id; $array[$key]['label'] = $data->name . ' ' . $orders . ' Заказа(ов)'; } echo json_encode($array); }
public function search($params) { $query = Orders::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['exp_delivery_dt' => SORT_DESC]], 'pagination' => ['pageSize' => 100]]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'qty' => $this->qty, 'price_per_unit' => $this->price_per_unit, 'wine_id' => $this->wine_id, 'user_id' => $this->user_id, 'order_dt' => $this->order_dt, 'exp_delivery_dt' => $this->exp_delivery_dt]); $query->andFilterWhere(['like', 'ordered_from', $this->ordered_from])->andFilterWhere(['like', 'futures_flg', $this->futures_flg])->andFilterWhere(['like', 'delivery_location', $this->delivery_location]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'quantity' => $this->quantity]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'uid' => $this->uid]); $query->andFilterWhere(['like', 'gordernumber', $this->gordernumber])->andFilterWhere(['like', 'gototal', $this->gototal])->andFilterWhere(['like', 'gostatus', $this->gostatus])->andFilterWhere(['like', 'address', $this->address])->andFilterWhere(['like', 'create_time', $this->create_time]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['ID' => $this->ID, 'price' => $this->price, 'time_begin' => $this->time_begin, 'time_total' => $this->time_total]); $query->andFilterWhere(['like', 'work_dir', $this->work_dir])->andFilterWhere(['like', 'link', $this->link]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'price' => $this->price, 'status' => $this->status, 'type' => $this->type, 'level_id' => $this->level_id, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'product', $this->product])->andFilterWhere(['like', 'create_user', $this->create_user])->andFilterWhere(['like', 'update_user', $this->update_user]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'order_id' => $this->order_id, 'statusID' => $this->statusID, 'delivery_time' => $this->delivery_time]); $query->andFilterWhere(['like', 'spi', $this->spi])->andFilterWhere(['like', 'fio', $this->fio])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'amount', $this->amount])->andFilterWhere(['like', 'shop_status', $this->shop_status])->andFilterWhere(['like', 'delivery_status', $this->delivery_status])->andFilterWhere(['like', 'sms_status', $this->sms_status])->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['order_id' => $this->order_id, 'qty' => $this->qty, 'price_per_unit' => $this->price_per_unit, 'wine_id' => $this->wine_id, 'user_id' => $this->user_id, 'order_dt' => $this->order_dt, 'exp_delivery_dt' => $this->exp_delivery_dt]); $query->andFilterWhere(['like', 'ordered_from', $this->ordered_from])->andFilterWhere(['like', 'futures_flg', $this->futures_flg])->andFilterWhere(['like', 'delivery_location', $this->delivery_location]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Orders::find(); // add conditions that should always apply here $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'tour_id' => $this->tour_id, 'created' => $this->created, 'user_id' => $this->user_id]); return $dataProvider; }
public function search($params, $date) { if ($date == "") { $query = Orders::find()->joinWith('clients'); } else { $query = Orders::find()->where(['date' => $date])->joinWith('clients'); } $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['date' => SORT_DESC, 'id' => SORT_DESC]], 'pagination' => ['pageSize' => 30]]); // load the search form data and validate if (!($this->load($params) && $this->validate())) { return $dataProvider; } // adjust the query by adding the filters $query->andFilterWhere(['orderNum' => $this->orderNum])->andFilterWhere(['like', 'declaration', $this->declaration])->andFilterWhere(['like', 'clients.name', $this->clientId])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'deliveryId', $this->deliveryId])->andFilterWhere(['like', 'payment', $this->payment])->andFilterWhere(['like', 'driverId', $this->driverId])->andFilterWhere(['like', 'statusS1', $this->statusS1])->andFilterWhere(['like', 'statusS3', $this->statusS3]); return $dataProvider; }
public function actionIndex() { $dataProvider = new ActiveDataProvider(['query' => Orders::find()]); return $this->render('index', ['dataProvider' => $dataProvider]); }
public function bitcoincharts($currency = 'USD', $filename = null) { if ($filename == "") { return $this->render(array('json' => array('success' => 0, 'now' => time(), 'error' => "No method specified."))); } if ($filename == "trades.json") { if ($date == null) { $StartDate = new MongoDate(strtotime(gmdate('Y-m-d', mktime(0, 0, 0, gmdate('m', time()), gmdate('d', time()), gmdate('Y', time()))))); $EndDate = new MongoDate(strtotime(gmdate('Y-m-d', mktime(0, 0, 0, gmdate('m', time()), gmdate('d', time()), gmdate('Y', time())) + 24 * 60 * 60))); } else { $StartDate = new MongoDate(strtotime($date)); $EndDate = new MongoDate(strtotime($date) + 24 * 60 * 60); } $orders = Orders::find('all', array('conditions' => array('DateTime' => array('$gte' => $StartDate, '$lt' => $EndDate), 'FirstCurrency' => 'BTC', 'SecondCurrency' => $currency, 'Completed' => 'Y'), 'order' => array('DateTime' => -1))); $i = 0; $result = array(); foreach ($orders as $or) { $result[$i]['date'] = $or['DateTime']->sec; $result[$i]['price'] = $or['PerPrice']; $result[$i]['amount'] = $or['Amount']; // $result[$i]['tid1'] = $or['_id']->getInc() ; // $result[$i]['tid2'] = $or['_id']->getHostname() ; $result[$i]['tid'] = $or['_id']->getPID(); $i++; } return $this->render(array('json' => $result)); } //[{"date":1306148860,"price":6.87,"amount":1,"tid":"82771"},{"date":1306149340,"price":6.86001,"amount":1,"tid":"82772"}] if ($filename == "orderbook.json") { $i = 0; $result = array(); $orderbids = array(); $orderask = array(); $orders = Orders::find('all', array('conditions' => array('FirstCurrency' => 'BTC', 'SecondCurrency' => $currency, 'Completed' => 'N'), 'order' => array('DateTime' => -1))); foreach ($orders as $or) { if ($or['Action'] == 'Sell') { array_push($orderbids, array($or['PerPrice'], $or['Amount'])); } if ($or['Action'] == 'Buy') { array_push($orderask, array($or['PerPrice'], $or['Amount'])); } $i++; } $result = array('ask' => $orderask, 'bids' => $orderbids); return $this->render(array('json' => $result)); } // {"asks":[[7.449,1],[7.4499,6.711]],"bids":[[7.40001,5],[7.3325,27.449]]} This will ask }
public function actionPrint($id) { $model = new Orders(); $this->layout = "//print"; return $this->render('print', ['orderInfo' => Orders::find()->where(["id" => $id])->with(["cityDetailsSzamla", "cityDetailsShip"])->asArray()->one(), 'products' => $model->calcPrice($id)]); }
public function ChangeCurrentOrder($order_id, $PO_id, $PO_Amount, $user) { $PO = Orders::find('first', array('conditions' => array('_id' => $PO_id))); $CO = Orders::find('first', array('conditions' => array('_id' => $order_id))); if ($CO['Action'] == "Buy") { $CurrCommAmount = round((double) $CO['CommissionPercent'] * (double) $PO_Amount / 100, 8); $NewCommAmount = round((double) $CO['CommissionPercent'] * ((double) $CO['Amount'] - (double) $PO_Amount) / 100, 8); } else { $CurrCommAmount = round((double) $CO['CommissionPercent'] * (double) $PO_Amount * (double) $CO['PrePrice'] / 100, 8); $NewCommAmount = round((double) $CO['CommissionPercent'] * ((double) $CO['Amount'] - (double) $PO_Amount) * (double) $CO['PrePrice'] / 100, 8); } $COData = array('Action' => $CO['Action'], 'FirstCurrency' => $CO['FirstCurrency'], 'SecondCurrency' => $CO['SecondCurrency'], 'CommissionPercent' => (double) $CO['CommissionPercent'], 'Commission.Amount' => (double) $CurrCommAmount, 'Commission.Currency' => $CO['Commission']['Currency'], 'Amount' => (double) $PO_Amount, 'PerPrice' => (double) $CO['PerPrice'], 'DateTime' => $CO['DateTime'], 'username' => $CO['username'], 'IP' => $CO['IP'], 'user_id' => $CO['user_id'], 'Completed' => 'Y', 'Transact.id' => $PO_id, 'Transact.username' => $PO['username'], 'Transact.user_id' => $PO['_id'], 'Transact.DateTime' => new \MongoDate(), 'Order' => 'P>C: Update Current Commission and Amount and Complete Order'); // print_r($COData) ; $data = array('Action' => $CO['Action'], 'FirstCurrency' => $CO['FirstCurrency'], 'SecondCurrency' => $CO['SecondCurrency'], 'CommissionPercent' => (double) $CO['CommissionPercent'], 'Commission.Amount' => (double) $NewCommAmount, 'Commission.Currency' => $CO['Commission']['Currency'], 'Amount' => (double) ($CO['Amount'] - $PO_Amount), 'PerPrice' => (double) $CO['PerPrice'], 'DateTime' => new \MongoDate(), 'Completed' => 'N', 'IP' => $_SERVER['REMOTE_ADDR'], 'username' => $user['username'], 'user_id' => $user['_id']); $CO = Orders::find('all', array('conditions' => array('_id' => $order_id)))->save($COData); // Create Order for the user if ((double) ($CO['Amount'] - $PO_Amount) > 0) { $orders = Orders::create(); $orders->save($data); $order_id = $orders->_id; $this->SendEmails($order_id, $user['_id']); return $order_id; } return false; }
public function sendemail($order_id) { $orderData = Orders::find($order_id); Mail::queue('emails.welcome', $orderData, function ($message) { $message->to('*****@*****.**', 'John Smith')->subject('Welcome!'); }); }
public function RemoveCompletedOrder($ID) { if ($this->__init() == false) { $this->redirect('ex::dashboard'); } $Orders = Orders::find('first', array('conditions' => array('_id' => new MongoID($ID)))); /* print_r($Orders['_id']); print_r("<br>"); print_r($Orders['Transact']['id']); print_r("<br>"); */ if ($Orders['Completed'] == 'Y') { $details = Details::find('first', array('conditions' => array('user_id' => (string) $Orders['user_id']))); if ($Orders['Action'] == 'Buy') { $balanceFirst = 'balance.' . $Orders['FirstCurrency']; $balanceSecond = 'balance.' . $Orders['SecondCurrency']; $data = array($balanceSecond => (double) ($details[$balanceSecond] + $Orders['PerPrice'] * $Orders['Amount'])); /* print_r($Orders['username']); print_r($details[$balanceSecond]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['user_id'], 'username' => $Orders['username'])))->save($data); $fromUser = Details::find('first', array('conditions' => array('user_id' => (string) $Orders['Transact']['user_id']))); $data = array($balanceFirst => (double) ($fromUser[$balanceFirst] + (double) $Orders['Amount'])); /* print_r($Orders['Transact']['username']); print_r($fromUser[$balanceFirst]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['Transact']['user_id'], 'username' => $Orders['Transact']['username'])))->save($data); } if ($Orders['Action'] == 'Sell') { $balanceFirst = 'balance.' . $Orders['FirstCurrency']; $balanceSecond = 'balance.' . $Orders['SecondCurrency']; $data = array($balanceFirst => (double) ($details[$balanceFirst] + (double) $Orders['Amount'])); /* print_r($Orders['username']); print_r($details[$balanceFirst]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['user_id'], 'username' => $Orders['username'])))->save($data); $fromUser = Details::find('first', array('conditions' => array('user_id' => (string) $Orders['Transact']['user_id']))); $data = array($balanceSecond => (double) ($fromUser[$balanceSecond] + $Orders['PerPrice'] * $Orders['Amount'])); /* print_r($Orders['Transact']['username']); print_r($fromUser[$balanceSecond]); print_r($data); */ $details = Details::find('all', array('conditions' => array('user_id' => $Orders['Transact']['user_id'], 'username' => $Orders['Transact']['username'])))->save($data); } $Remove = Orders::remove(array('_id' => $Orders['_id'])); $Remove = Orders::remove(array('_id' => $Orders['Transact']['id'])); $data = array('page.refresh' => true); Details::find('all')->save($data); } $this->redirect(array('controller' => 'Admin', 'action' => "orders")); }
public function YourOrders($FirstCurrency = "BTC", $SecondCurrency = "USD", $user_id = null) { $YourOrders = Orders::find('all', array('conditions' => array('user_id' => $user_id, 'Completed' => 'N', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency), 'order' => array('DateTime' => -1))); $YourCompleteOrders = Orders::find('all', array('conditions' => array('user_id' => $user_id, 'Completed' => 'Y', 'FirstCurrency' => $FirstCurrency, 'SecondCurrency' => $SecondCurrency), 'order' => array('DateTime' => -1))); $YourOrdersHTML = '<table class="table table-condensed table-bordered table-hover" style="font-size:11px"> <thead> <tr> <th style="text-align:center ">Exchange</th> <th style="text-align:center ">Price</th> <th style="text-align:center ">Amount</th> </tr> </thead> <tbody>'; foreach ($YourOrders as $YO) { $YourOrdersHTML = $YourOrdersHTML . '<tr> <td style="text-align:left "> <a href="/ex/RemoveOrder/' . String::hash($YO['_id']) . '/' . $YO['_id'] . '/' . strtolower($FirstCurrency) . '_' . strtolower($SecondCurrency) . '" title="Remove this order"> <i class="fa fa-times"></i></a> ' . $YO['Action'] . ' ' . $YO['FirstCurrency'] . '/' . $YO['SecondCurrency'] . '</td> <td style="text-align:right ">' . number_format($YO['PerPrice'], 3) . '...</td> <td style="text-align:right ">' . number_format($YO['Amount'], 3) . '...</td> </tr>'; } $YourOrdersHTML = $YourOrdersHTML . ' </tbody> </table>'; $YourCompleteOrdersHTML = '<table class="table table-condensed table-bordered table-hover" style="font-size:11px"> <thead> <tr> <th style="text-align:center ">Exchange</th> <th style="text-align:center ">Price</th> <th style="text-align:center ">Amount</th> </tr> </thead> <tbody>'; foreach ($YourCompleteOrders as $YO) { $YourCompleteOrdersHTML = $YourCompleteOrdersHTML . '<tr style="cursor:pointer" class=" tooltip-x" rel="tooltip-x" data-placement="top" title="' . $YO['Action'] . ' ' . number_format($YO['Amount'], 3) . ' at ' . number_format($YO['PerPrice'], 8) . ' on ' . gmdate('Y-m-d H:i:s', $YO['DateTime']->sec) . '"> <td style="text-align:left "> ' . $YO['Action'] . ' ' . $YO['FirstCurrency'] . '/' . $YO['SecondCurrency'] . '</td> <td style="text-align:right ">' . number_format($YO['PerPrice'], 3) . '...</td> <td style="text-align:right ">' . number_format($YO['Amount'], 3) . '...</td> </tr>'; } $YourCompleteOrdersHTML = $YourCompleteOrdersHTML . ' </tbody> </table>'; return $this->render(array('json' => array('YourCompleteOrdersHTML' => $YourCompleteOrdersHTML, 'YourOrdersHTML' => $YourOrdersHTML))); }
?> </table> </td> <td><?php echo $m->deliveryDate; ?> </td> <td class="price">$ <?php echo $price; ?> </td> <td> <?php $is_order = !empty(Orders::find()->where(['idBooking' => $m->id])->one()->id) ? true : false; $date_passed = strtotime($m->deliveryDate) < strtotime(date('Y-m-d')) ? true : false; $delivered = $is_order ? Orders::find()->where(['idBooking' => $m->id])->one()->delivered == 1 ? true : false : false; if ($is_order && $date_passed && !$delivered) { echo '<div class="order-error">Order Delivery Date Passed ! <span></span></div>'; } elseif (!$is_order && $date_passed) { echo '<div class="overdue">Overdue</div>'; } elseif (!$is_order && !$date_passed) { echo '<div class="booking-only">Booking Only</div>'; } elseif ($is_order && !$date_passed || $is_order && $date_passed && $delivered) { echo '<div class="order">Order</div>'; } ?> </td> </tr> <?php } ?>
public function actionStat() { $orders = Orders::find()->all(); return $this->render('stat', ['orders' => $orders]); }
public function actionIndex() { $orders = Orders::find()->all(); return $this->render('index', array('orders' => $orders)); }
/** * 添加物流单号 */ public function addShippingCode() { $code = Input::get('code'); $id = Input::get('orderid'); $printid = Input::get('printid'); $shippingName = Input::get('shippingName'); $msg = ''; if ($code && $id) { //$data = DB::update("update orders set shipping_code = :code where id = :id", ['code'=>$code, 'id'=>$id]); $item = DB::select("select id from item where order_id = '{$id}' order by id desc limit 1"); $itemId = $item[0]->id; $shippingName = '中通'; //$data = DB::update("insert into order_shipping(order_id,item_id,shipping_code,shipping_name,created_at) values('{$id}','{$itemId}','{$code}','{$shippingName}','".date('Y-m-d H:i:s')."')"); $orderShipping = new OrderShipping(); $orderShipping->order_id = $id; $orderShipping->item_id = $itemId; $orderShipping->shipping_code = $code; $orderShipping->shipping_name = $shippingName; // $orderShipping-> = $date('Y-m-d H:i:s'); $rs = $orderShipping->save(); if ($rs) { //修改状态 $orders = Orders::find($id); $orders->status = 12; $orders->save(); $msg = "{$code}物流单号提交成功"; } else { $msg = "{$code}物流单号提交失败"; } } else { return redirect()->route('order.barcode', ['printid' => $printid, 'err' => "错误的物流号或订单号"]); } return redirect()->route('order.barcode', ['printid' => $printid, 'msg' => $msg]); }
public static function updateOrders() { $query = Orders::find()->where(['status' => 'enabled'])->orderBy('id')->all(); $count = 0; foreach ($query as $model) { if ($model->send_sms_time > 0 && time() - strtotime($model->send_sms_time) > 60 * 60 * 24 * 6) { $statuses = Orders::OrderProcessing($model); //отправляем SMS $model->send_sms_time = $statuses['send_sms_time']; $model->sms_status = $statuses['sms_status']; $model->status = $statuses['status']; if ($model->save()) { $count++; } } } return $count; }
public function actionEvents() { if (\filter_input(INPUT_GET, 'q')) { $q = \filter_input(INPUT_GET, 'q'); $query = new Query(); $query->select("`b`.*")->from("bookings b, customers c, items i, bookingitems bi")->where("(" . "b.idCustomer=c.id AND " . "(" . "CONCAT(c.firstname, ' ', c.lastname) LIKE '{$q}' OR " . "c.firstname LIKE '{$q}' OR " . "c.lastname LIKE '{$q}' OR " . "CONCAT(c.lastname, ' ', c.firstname) LIKE '{$q}'" . ")" . ") OR (bi.idItem=i.id AND (i.name LIKE '{$q}' OR i.idItem LIKE '{$q}'))")->groupBy("b.id"); $bookings = $query->createCommand()->queryAll(); } else { $bookings = Bookings::find()->all(); } if (!empty($bookings)) { $status = 1; $events = array(); for ($i = 0; $i < sizeof($bookings); $i++) { $is_order = !empty(Orders::find()->where(['idBooking' => $bookings[$i]['id']])->one()->id) ? true : false; $date_passed = strtotime($bookings[$i]['deliveryDate']) < strtotime(date('Y-m-d')) ? true : false; $delivered = $is_order ? Orders::find()->where(['idBooking' => $bookings[$i]['id']])->one()->delivered == 1 ? true : false : false; if (!$is_order && $date_passed) { $status = 3; } elseif ($is_order && $date_passed && !$delivered) { $status = 4; } elseif ($is_order && !$date_passed) { $status = 2; } elseif ($is_order && $date_passed && $delivered) { $status = 5; } else { $status = 1; } $customer = Customers::find()->where(['id' => $bookings[$i]['idCustomer']])->one(); $Event = new \yii2fullcalendar\models\Event(); $Event->id = $bookings[$i]['id']; if (!empty($customer)) { $Event->title = $customer->firstname . " " . $customer->lastname; } $Event->start = $bookings[$i]['deliveryDate']; $Event->status = $status; $events[] = $Event; } if (!empty($events)) { return json_encode($events); } } }