/**
  * input user data
  * @param $id_tour
  * @param $id_booking
  * @return string
  */
 public function actionRegistration($id_tour, $id_booking)
 {
     $model = new Orders();
     if (Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->post());
         $model->id_tour = $id_tour;
         $model->id_booking = $id_booking;
         if ($model->save()) {
             $this->redirect('/site/success');
         }
     }
     return $this->render('registration', compact('model'));
 }
Example #2
0
 public function actionAddOrders()
 {
     $order = new ModelOrders();
     $order->part = $_POST['part'];
     $order->article = $_POST['article'];
     $order->OE = $_POST['oe'];
     $order->provider = $_POST['provider'];
     $order->quantity = $_POST['quantity'];
     $order->price = $_POST['price'];
     $order->cars_id = $_POST['cars_id_hidden'];
     $order->data_a = date('Y-m-d H:i:s');
     $order->insert();
     header("Location: http://" . $_SERVER['SERVER_NAME'] . "/orders/AllShowOrders?id=" . $_POST['cars_id_hidden']);
 }
Example #3
0
 public function actionAddnew()
 {
     $orderNow = orders::find()->where(['active' => 1])->one();
     if ($orderNow == null) {
         $post_order = Yii::$app->request->post()['Orders'];
         $order = new Orders($post_order);
         $order->time_begin = date("Y-m-d H:i:s");
         $order->active = 1;
         $order->save();
         $resultAdd = 3;
     } else {
         $resultAdd = 2;
     }
     Yii::$app->response->redirect(array('site/index', 'resultAdd' => $resultAdd));
 }
Example #4
0
 public function actionPopover($id, $attr)
 {
     $model = Orders::findOne($id);
     if ($model->status == Orders::STATUS_REGISTERED && Yii::$app->user->identity->role != 10) {
         if ($model->status == Orders::STATUS_REGISTERED && Yii::$app->user->identity->role == 0) {
             $model->scenario = 'registered';
             $scenario = $model->scenarios();
             if (!in_array($attr, $scenario['registered'])) {
                 throw new \yii\web\HttpException(403, 'У вас нет доступа для редактирования');
             }
         } else {
             throw new \yii\web\HttpException(403, 'У вас нет доступа для редактирования');
         }
     }
     if (Yii::$app->request->post('popup')) {
         $post = Yii::$app->request->post();
         $model = Orders::findOne($post['id']);
         return $this->renderAjax('popover', ['attr' => $post['attr'], 'model' => $model]);
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->editTimestamp = date('Y-m-d H:i:s');
         $model->editName = Yii::$app->user->identity->full_name;
         $model->history .= $model->history($model);
         $model->save();
     }
 }
 public function actionOrder()
 {
     if (Yii::$app->session->get('ids')) {
         $model = new OrderForm();
         if ($model->load(Yii::$app->request->post()) && $model->validate()) {
             $order = new Orders();
             $order->delivery = $model->delivery;
             $ids = Yii::$app->session->get('ids');
             $id_count = Yii::$app->session->get('id_count');
             $s = "";
             for ($i = 0; $i < count($ids); $i++) {
                 $s .= "({$ids[$i]} [{$id_count[$i]}]), ";
             }
             $order->product_ids = $s;
             $order->price = Yii::$app->session->get('price');
             $order->email = Html::encode($model->email);
             $order->adress = Html::encode($model->adress);
             $order->notice = Html::encode($model->notice);
             $order->name = Html::encode($model->name);
             $order->phone = Html::encode($model->phone);
             $order->date_order = date("Y-m-d H:i:s");
             Yii::$app->mailer->compose()->setFrom('*****@*****.**')->setTo($model->email)->setSubject('Заказ товаров на mobzp.ua')->setTextBody('<article id="articles">
                             	<h2>Вы успешно заказали наушники</h2>
                             	<p>С вами свяжется наш оператор в течении полу часа и уточнит данные для отправки или место передачи товара.</p>
                             	<p>После отправки по новой почте, вам придет смс, что товар отправлен и вы сможете его получить в вашем отделении через несколько дней.</p>
                             	<p>Спасибо, что воспользовались услугами нашего магазина! Мы всегда рады положительным отзывам на страничке товара.</p>
                             </article>')->send();
             $order->save();
             return $this->render('ordersuccess');
         }
         return $this->render('order', ['model' => $model]);
     } else {
         return $this->redirect(Yii::$app->request->referrer);
     }
 }
 public function down()
 {
     $this->dropTable($this->tableName);
     $this->addColumn(Orders::tableName(), 'quantity', $this->integer(5)->notNull()->defaultValue(0));
     $this->addColumn(Orders::tableName(), 'product_id', $this->integer(5)->notNull());
     $this->addColumn(Orders::tableName(), 'type', $this->string(255)->notNull());
 }
Example #7
0
 public function actionAllShowOrders()
 {
     //связь таблиц cars и orders по id(cars) и cars_id(orders)
     $id = $_GET['id'];
     $field = 'cars_id';
     $this->view->items = Model::findAllUserId($id, $field);
     $this->view->display('order_car');
 }
Example #8
0
 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);
 }
Example #9
0
 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;
 }
Example #10
0
 public function actionOrder()
 {
     $order = new Orders();
     /* @var $cart ShoppingCart */
     $cart = \Yii::$app->cart;
     /* @var $products Product[] */
     $products = $cart->getPositions();
     $total = $cart->getCost();
     if ($order->load(Yii::$app->request->post()) && $order->validate()) {
         $transaction = $order->getDb()->beginTransaction();
         $order->save(false);
         foreach ($products as $product) {
             $orderItem = new OrderItem();
             $orderItem->order_id = $order->order_id;
             $orderItem->item_id = $product->item_id;
             $orderItem->price = $product->getPrice();
             $orderItem->quantity = $product->getQuantity();
             if (!$orderItem->save(false)) {
                 $transaction->rollBack();
                 Yii::$app->session->addFlash('error', 'Cannot place your order. Please contact us.');
                 // TODO: may need to add Yii::t()
                 return $this->redirect('../');
                 // redirect to web root
             }
         }
         $transaction->commit();
         \Yii::$app->cart->removeAll();
         Yii::$app->session->addFlash('success', 'Thanks for your order. We\'ll contact you soon.');
         $order->sendEmail();
         return $this->redirect('../');
         // redirect to web root
     }
     return $this->render('order', ['order' => $order, 'products' => $products, 'total' => $total]);
 }
Example #11
0
 /**
  * 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, '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;
 }
Example #13
0
 /**
  * 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;
 }
Example #14
0
 /**
  * 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;
 }
Example #15
0
 /**
  * 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(['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;
 }
Example #17
0
 /**
  * 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;
 }
Example #18
0
 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;
 }
Example #19
0
 public function run()
 {
     Model::unguard();
     DB::statement('SET FOREIGN_KEY_CHECKS = 0');
     DB::table('orderitems')->truncate();
     $faker = Faker::create();
     $orders = \App\Models\Orders::all()->lists('id');
     $vendors = \App\Models\Vendors::all()->lists('id');
     $categories = \App\Models\Categories::all()->lists('id');
     foreach (range(1, 20) as $index) {
         $quantity = $faker->numberBetween(1, 20);
         $price = $faker->randomFloat(2, 1, 5000);
         $finalprice = $faker->randomFloat(2, 1, 5000);
         DB::table('orderitems')->insert(['name' => $faker->name, 'order_id' => $faker->randomElement($orders), 'category_id' => $faker->randomElement($categories), 'vendor_id' => $faker->randomElement($vendors), 'description' => $faker->text(), 'url' => $faker->url, 'quantity' => $quantity, 'estimatedprice' => $price, 'estimatedtotal' => $price * $quantity, 'fixedprice' => $finalprice, 'fixedtotal' => $finalprice * $quantity, 'status' => 0]);
     }
     DB::statement('SET FOREIGN_KEY_CHECKS = 1');
 }
Example #20
0
use app\models\Parameters;
use app\models\Pages;
use app\models\Orders;
use app\models\Trades;
use lithium\core\Environment;
use lithium\data\Connections;
$Comm = Parameters::find('first');
$howmany = 100;
$tradesV = Trades::find('first', array('conditions' => array('SecondType' => 'Virtual'), 'limit' => $howmany, 'order' => array('order' => 1)));
$first_currency = substr($tradesV['trade'], 0, 3);
$second_currency = substr($tradesV['trade'], 4, 3);
$tradesVF = Trades::find('all', array('conditions' => array('SecondType' => 'Fiat'), 'limit' => $howmany, 'order' => array('order' => -1)));
$trades = Trades::find('all', array('limit' => $howmany, 'order' => array('order' => 1)));
$mongodb = Connections::get('default')->connection;
$Rates = Orders::connection()->connection->command(array('aggregate' => 'orders', 'pipeline' => array(array('$project' => array('_id' => 0, 'Action' => '$Action', 'PerPrice' => '$PerPrice', 'Completed' => '$Completed', 'FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'TransactDateTime' => '$Transact.DateTime')), array('$match' => array('Completed' => 'Y')), array('$group' => array('_id' => array('FirstCurrency' => '$FirstCurrency', 'SecondCurrency' => '$SecondCurrency', 'year' => array('$year' => '$TransactDateTime'), 'month' => array('$month' => '$TransactDateTime'), 'day' => array('$dayOfMonth' => '$TransactDateTime')), 'min' => array('$min' => '$PerPrice'), 'avg' => array('$avg' => '$PerPrice'), 'max' => array('$max' => '$PerPrice'), 'last' => array('$last' => '$PerPrice'))), array('$sort' => array('_id.year' => -1, '_id.month' => -1, '_id.day' => -1, '_id.hour' => -1)), array('$limit' => count($trades)))));
?>
<p>&nbsp;</p>
<div class="container-fluid">
		<div class="row placeholders">
		<?php 
foreach ($tradesVF as $tradeVF) {
    if (substr($tradeVF['trade'], 0, 3) == $second_currency) {
        ?>
				<div class="col-xs-6 col-sm-6  placeholder" style="text-align:center">
						<h4><?php 
        echo $tradeVF['trade'];
        ?>
</h4>
						<?php 
        foreach ($Rates['result'] as $rate) {
 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
 }
Example #22
0
 public function getProfile()
 {
     $orders = \App\Models\Orders::where('user_id', '=', \Auth::user()->_id)->get();
     return view('auth.profile_page', ['orders' => $orders]);
 }
Example #23
0
 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;
 }
Example #24
0
 function getOrderByUserId($id)
 {
     //        \DB::enableQueryLog();
     $order = Order::where('user_id', $id)->get();
     return $order;
 }
Example #25
0
 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"));
 }
Example #26
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrder()
 {
     return $this->hasOne(Orders::className(), ['id' => 'order_id']);
 }
Example #27
0
 public function actionCronsms()
 {
     Orders::updateOrders();
     Orders::getNewShopOrders();
 }
Example #28
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getOrders()
 {
     return $this->hasMany(Orders::className(), ['prod_id' => 'id']);
 }
Example #29
0
 /**
  * Finds the Orders model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return Orders the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Orders::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Example #30
0
 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);
         }
     }
 }