예제 #1
1
 public function makeOrder(DeliveryRequest $request)
 {
     $this->validate($request);
     $orders = new Order();
     $orders->address = $request->input('address');
     $orders->contact = $request->input('contact');
     $orders->phone = $request->input('phone');
     $orders->email = $request->input('email');
     $orders->sendwhen = null;
     $orders->created = date('Y-m-d H:i:s');
     $orders->additional = $request->input('additional');
     $orders->status = Order::STATUS['NEW'];
     $orders->totalprice = \App\Components\Cart::getInstance()->getTotalPrice();
     $orders->save();
     $request->except('_token');
     $inserted = Order::find($orders->id);
     $inserted->products()->saveMany(Orderproducts::reFormatCartList());
     Cart::getInstance()->clearAll();
     return redirect('categories/all');
 }
예제 #2
0
 public function createPayment(Request $request)
 {
     Auth::user();
     $order_id = session('order_id');
     $order = Order::find($order_id);
     if ($order) {
         $user = $order->id;
         $sum = $order->sum;
         $mrh_login = env('ROBOKASSA_LOGIN');
         $mrh_pass1 = env('ROBOKASSA_PASSWORD');
         $invoice_id = mt_rand();
         $inv_desc = 'Пополнение баланса';
         $crc = md5($mrh_login . ":" . $sum . ":" . $invoice_id . ":" . $mrh_pass1);
         if ($sum != 0) {
             try {
                 DB::beginTransaction();
                 $payment = new Payment();
                 $payment->uid = $invoice_id;
                 $payment->user_id = $user;
                 $payment->balance = $sum;
                 $payment->description = $inv_desc;
                 $payment->operation = '+';
                 $payment->save();
                 DB::commit();
             } catch (\PDOException $e) {
                 print $e->getMessage();
                 DB::connection()->getPdo()->rollBack();
             }
         }
         echo 'ok';
         return 1;
         header("Location: https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin={$mrh_login}&OutSum={$sum}&InvId={$invoice_id}&Desc={$inv_desc}&SignatureValue={$crc}");
     }
 }
예제 #3
0
 /**
  * Put an order from finished to unfinished
  *
  * @param $id
  * @return mixed
  */
 public function unFinishOrder($id)
 {
     $order = Order::find($id);
     $order->finished = null;
     $order->save();
     return $order;
 }
예제 #4
0
 private function create_payment($order_id)
 {
     $order = Order::find($order_id);
     if ($order) {
         $user = $order->user_id;
         $sum = $order->sum;
         $mrh_login = env('ROBOKASSA_LOGIN');
         $mrh_pass1 = env('ROBOKASSA_PASSWORD');
         $invoice_id = mt_rand();
         $inv_desc = 'Пополнение баланса';
         $crc = md5($mrh_login . ":" . $sum . ":" . $invoice_id . ":" . $mrh_pass1);
         if ($sum != 0) {
             try {
                 DB::beginTransaction();
                 $payment = new Payment();
                 $payment->uid = $invoice_id;
                 $payment->order_id = $order_id;
                 $payment->user_id = $user;
                 $payment->sum = $sum;
                 $payment->description = $inv_desc;
                 $payment->operation = '+';
                 $payment->payment_type = $order->payment_type;
                 $payment->save();
                 DB::commit();
             } catch (\PDOException $e) {
                 print $e->getMessage();
                 DB::connection()->getPdo()->rollBack();
             }
         }
         $redirect_url = "https://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin={$mrh_login}&OutSum={$sum}&InvId={$invoice_id}&Desc={$inv_desc}&SignatureValue={$crc}&IsTest=1";
         return $redirect_url;
     }
     return Redirect::to('/')->with('message', 'Ошибка');
 }
예제 #5
0
 public function testStore()
 {
     $this->post(route('api.admin.order.product.index', [$this->order]), json_encode(['product_id' => 1, 'sku' => 'iphone616-gold', 'quantity' => 2]));
     $order = Order::find($this->order->id);
     $this->assertNotEquals($this->order->subtotal_product, $order->subtotal_product, $this->response->getContent());
     $this->assertNotEquals($this->order->subtotal_logistics, $order->subtotal_logistics, $this->response->getContent());
     $this->assertResponseStatus(201);
 }
예제 #6
0
 /**
  * order details.
  *
  * @return Response
  */
 public function show($id)
 {
     $order = Order::find($id);
     if (!$order) {
         \App::abort(404);
     }
     return view('themes/kudos/orders/show', ['order' => $order]);
 }
예제 #7
0
 public function index($cat = null, $id = null)
 {
     if (!$cat) {
         $resource = \App\Models\Kingdom::select('kingdom.kingdom_name as name', 'kingdom.kingdom_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/kingdom/', kingdom.kingdom_id) AS url"));
         $resourceData = $resource->join('phylum', 'kingdom.kingdom_id', '=', 'phylum.kingdom_id', 'left outer')->join('class', 'phylum.phylum_id', '=', 'class.phylum_id', 'left outer')->join('order', 'class.class_id', '=', 'order.class_id', 'left outer')->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('kingdom.kingdom_id', 'kingdom.kingdom_name')->paginate(20);
     } else {
         switch ($cat) {
             case 'kingdom':
                 $resource = \App\Models\Kingdom::find($id);
                 $resourceData = $resource->phylums()->select('phylum.phylum_name as name', 'phylum.phylum_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/phylum/', phylum.phylum_id) AS url"))->join('class', 'phylum.phylum_id', '=', 'class.phylum_id', 'left outer')->join('order', 'class.class_id', '=', 'order.class_id', 'left outer')->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('phylum.phylum_id', 'phylum.phylum_name')->paginate(20);
                 array_unshift($this->breadcrumbs, array('name' => $resource->kingdom_name));
                 break;
             case 'phylum':
                 $resource = \App\Models\Phylum::find($id);
                 $resourceData = $resource->classes()->select('class.class_name as name', 'class.class_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/class/', class.class_id) AS url"))->join('order', 'class.class_id', '=', 'order.class_id', 'left outer')->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('class.class_id', 'class.class_name')->paginate(20);
                 array_unshift($this->breadcrumbs, array('name' => $resource->phylum_name));
                 array_unshift($this->breadcrumbs, array('name' => $resource->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->kingdom->kingdom_id));
                 break;
             case 'class':
                 $resource = \App\Models\Classes::find($id);
                 $resourceData = $resource->orders()->select('order.order_name as name', 'order.order_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/order/', order.order_id) AS url"))->join('family', 'order.order_id', '=', 'family.order_id', 'left outer')->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('order.order_id', 'order.order_name')->paginate(20);
                 array_unshift($this->breadcrumbs, array('name' => $resource->class_name));
                 array_unshift($this->breadcrumbs, array('name' => $resource->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->phylum->phylum_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->phylum->kingdom->kingdom_id));
                 break;
             case 'order':
                 $resource = \App\Models\Order::find($id);
                 $resourceData = $resource->families()->select('family.family_name as name', 'family.family_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/family/', family.family_id) AS url"))->join('genus', 'family.family_id', '=', 'genus.family_id', 'left outer')->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->groupBy('family.family_id', 'family.family_name')->paginate(20);
                 array_unshift($this->breadcrumbs, array('name' => $resource->order_name));
                 array_unshift($this->breadcrumbs, array('name' => $resource->classes->class_name, 'url' => '/dnabarcode/class/' . $resource->classes->class_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->classes->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->classes->phylum->phylum_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->classes->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->classes->phylum->kingdom->kingdom_id));
                 break;
             case 'family':
                 $resource = \App\Models\Family::find($id);
                 $resourceData = $resource->genus()->select('genus.genus_name as name', 'genus.genus_id as id', DB::raw('count(barcode.barcode_id) as count'), DB::raw("CONCAT('/dnabarcode/genus/', genus.genus_id) AS url"))->join('species', 'genus.genus_id', '=', 'species.genus_id', 'left outer')->groupBy('genus.genus_id', 'genus.genus_name')->join('barcode', 'barcode.species', '=', 'species.species_id', 'left outer')->paginate(20);
                 array_unshift($this->breadcrumbs, array('name' => $resource->family_name));
                 array_unshift($this->breadcrumbs, array('name' => $resource->order->order_name, 'url' => '/dnabarcode/order/' . $resource->order->order_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->order->classes->class_name, 'url' => '/dnabarcode/class/' . $resource->order->classes->class_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->order->classes->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->order->classes->phylum->phylum_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->order->classes->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->order->classes->phylum->kingdom->kingdom_id));
                 break;
             case 'genus':
                 $resource = \App\Models\Genus::find($id);
                 $resourceData = $resource->species()->select('species.species_name as name', DB::raw("CONCAT('/viewbarcode?id=' , barcode_id) AS url"))->join('barcode', 'barcode.species', '=', 'species.species_id')->where('barcode.status', 1)->paginate(20);
                 array_unshift($this->breadcrumbs, array('name' => $resource->genus_name));
                 array_unshift($this->breadcrumbs, array('name' => $resource->family->family_name, 'url' => '/dnabarcode/family/' . $resource->family->order_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->family->order->order_name, 'url' => '/dnabarcode/order/' . $resource->family->order->order_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->family->order->classes->class_name, 'url' => '/dnabarcode/class/' . $resource->family->order->classes->class_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->family->order->classes->phylum->phylum_name, 'url' => '/dnabarcode/phylum/' . $resource->family->order->classes->phylum->phylum_id));
                 array_unshift($this->breadcrumbs, array('name' => $resource->family->order->classes->phylum->kingdom->kingdom_name, 'url' => '/dnabarcode/kingdom/' . $resource->family->order->classes->phylum->kingdom->kingdom_id));
                 break;
         }
     }
     array_unshift($this->breadcrumbs, array('name' => 'DNA Barcode', 'url' => '/dnabarcode'));
     $viewData = array('resource' => $resourceData, 'breadcrumbs' => $this->breadcrumbs, 'cat' => $cat);
     return view('list')->with($viewData);
 }
예제 #8
0
 public function detail($id)
 {
     $customer = \Helper::getCustomer();
     $order = Order::find($id);
     if (!$order || $order->customer_id != $customer->id) {
         abort(404);
     }
     return view('shop.order-details')->with(['json' => $order->queryForDetailPage()]);
 }
예제 #9
0
 public function getOrders($id = null)
 {
     if ($id) {
         //details
         return view('order.details', ['products' => OrderProduct::where('order_id', $id)->get(), 'order' => Order::find($id)]);
     } else {
         return view('order.index', ['orders' => Order::where('user_id', Auth::id())->get()]);
     }
 }
예제 #10
0
 /**
  * Delete an order.
  *
  * @param string $id
  *
  * @return Redirect
  */
 public function destroy(Request $request, string $id)
 {
     // delete
     $order = Order::find($id);
     $order->delete();
     // redirect
     $request->session()->flash('success', trans('orders.order') . ' ' . trans('crud.deleted'));
     return redirect('admin/orders');
 }
예제 #11
0
 public function actionOrders()
 {
     if (!is_null($user = $this->getLoggedUser())) {
         $data = new ActiveDataProvider(['query' => Order::find()->where(['user_id' => $user->id])->orderBy(['created' => SORT_DESC]), 'pagination' => ['pageSize' => 5]]);
         return $this->render('orders', ['data' => $data]);
     } else {
         return $this->redirect(['site/register']);
     }
 }
예제 #12
0
 public function actionAll()
 {
     if (Yii::$app->user->isGuest) {
         return $this->goHome();
     }
     $query = Order::find()->where(['id_owner' => Yii::$app->user->id]);
     $pagination = new Pagination(['defaultPageSize' => 15, 'totalCount' => $query->count()]);
     $orders = $query->orderBy('name')->offset($pagination->offset)->limit($pagination->limit)->all();
     return $this->render('allorder', ['orders' => $orders, 'pagination' => $pagination]);
 }
예제 #13
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $id)
 {
     $order = Order::find($id);
     $order->express_code = $request->express_code;
     if ($order->status == 1) {
         $order->status = 2;
     }
     $order->save();
     return back()->with('info', '订单号修改成功~');
 }
예제 #14
0
 /**
  * Lists all Order models.
  * @return mixed
  */
 public function actionIndex()
 {
     if (User::isUserAdmin(Yii::$app->user->identity->username)) {
         $query = Order::find()->joinWith(['orderLocationName']);
     } else {
         $query = Order::find()->joinWith(['orderLocationName'])->where(['order_user_id' => Yii::$app->user->id]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }
예제 #15
0
 public function actionIndex()
 {
     // last orders
     $data['orders'] = Order::find()->orderBy(['id' => SORT_DESC])->limit(10)->all();
     // last registered users
     $data['users'] = User::find()->orderBy(['id' => SORT_DESC])->limit(10)->all();
     // top sellers
     $sql = "select product_id, sum(quantity) as cant from order_products left join simplestore.order on order.id=order_products.order_id where order.status=:approved group by product_id order by cant desc limit :limit";
     $data['products'] = Yii::$app->db->createCommand($sql, [':approved' => Order::STATUS_APPROVED, ':limit' => 10])->queryAll();
     return $this->render('index', $data);
 }
예제 #16
0
 public function actionOrders()
 {
     $destination = $this->getDestinationAccount();
     $query = Order::find();
     $query->andFilterWhere(['status' => Order::STATUS_APPROVED]);
     $query->leftJoin('order_shipping', "order.id = order_shipping.order_id");
     $query->andFilterWhere(['order_shipping.shipping_email' => $destination->email]);
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 25], 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     return $this->render('orders', ['dataProvider' => $dataProvider]);
 }
 public function postResponse($id)
 {
     /*Job de trimitere mail catre client*/
     $res = \App\Models\Response::create(['order_id' => $id, 'price' => Input::get('price'), 'message' => Input::get('message')]);
     $request = Order::find($id);
     $request->response = '1';
     $request->save();
     $job = new RequestResponseEmail($res, $request);
     $this->dispatch($job);
     return view('comments.alert')->with(['message' => trans('strings.request_submit')])->render();
 }
예제 #18
0
 private function cart_exists()
 {
     if (is_null($this->order_id)) {
         return false;
     } else {
         if (!Order::find($this->order_id)->exists()) {
             return false;
         } else {
             return true;
         }
     }
 }
예제 #19
0
 public function actionSendorder()
 {
     $post = Yii::$app->request->post();
     $id = $post['id'];
     $order = Order::find()->where(['id' => $id])->one();
     //var_dump($order);
     $order->status = 2;
     if ($order->save()) {
         echo "0";
     } else {
         echo "-1";
     }
 }
예제 #20
0
 public function postUpdate()
 {
     $id = Input::get('id');
     $order = Order::find($id);
     if ($order) {
         $order->sum = Input::get('sum');
         $order->delivery_address = Input::get('delivery_address');
         $order->payment_type = Input::get('payment_type');
         $order->state = Input::get('state');
         $order->save();
         return Redirect::to("admin/orders/edit/{$id}")->with('message', "Заказ №  {$order->id} изменён");
     }
     return Redirect::to("admin/orders/edit/{$id}")->with('message', 'Ошибка сохранения')->withInput();
 }
예제 #21
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Order::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, 'user_id' => $this->user_id, 'restaurant_id' => $this->restaurant_id, 'status' => $this->status]);
     $query->andFilterWhere(['like', 'user_info', $this->user_info])->andFilterWhere(['like', 'order_info', $this->order_info])->andFilterWhere(['like', 'other_users', $this->other_users]);
     return $dataProvider;
 }
예제 #22
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Order::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, 'order_date' => $this->order_date, 'customer_id' => $this->customer_id, 'cart_id' => $this->cart_id, 'carrier_id' => $this->carrier_id, 'payment_channel_id' => $this->payment_channel_id, 'current_state' => $this->current_state, 'flag_gift' => $this->flag_gift, 'flag_free_delivery' => $this->flag_free_delivery, 'total_product_count' => $this->total_product_count, 'total_order' => $this->total_order, 'total_discount' => $this->total_discount, 'total_tax' => $this->total_tax, 'total_shipping_cost' => $this->total_shipping_cost, 'total_shipping_tax' => $this->total_shipping_tax, 'total_wrapping' => $this->total_wrapping, 'grand_total' => $this->grand_total, 'round_mode' => $this->round_mode, 'grand_total_rounded' => $this->grand_total_rounded, 'total_paid' => $this->total_paid, 'total_weight' => $this->total_weight, 'delivery_date' => $this->delivery_date, 'delivery_time_id' => $this->delivery_time_id, 'delivery_address_id' => $this->delivery_address_id, 'invoice_date' => $this->invoice_date, 'invoice_address_id' => $this->invoice_address_id, 'date_added' => $this->date_added, 'date_update' => $this->date_update]);
     $query->andFilterWhere(['like', 'order_no', $this->order_no])->andFilterWhere(['like', 'gift_message', $this->gift_message])->andFilterWhere(['like', 'delivery_no', $this->delivery_no])->andFilterWhere(['like', 'tracking_no', $this->tracking_no])->andFilterWhere(['like', 'invoice_no', $this->invoice_no]);
     return $dataProvider;
 }
예제 #23
0
파일: OrderSearch.php 프로젝트: arsik/xfit
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Order::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, 'clubID' => $this->clubID, 'managerID' => $this->managerID, 'payTime' => $this->payTime, 'deliveryTime' => $this->deliveryTime, 'createTime' => $this->createTime, 'fullCost' => $this->fullCost, 'sms' => $this->sms, 'senderPhone' => $this->senderPhone, 'geterPhone' => $this->geterPhone]);
     $query->andFilterWhere(['like', 'session', $this->session])->andFilterWhere(['like', 'fio', $this->fio]);
     return $dataProvider;
 }
예제 #24
0
 public function actionIndex()
 {
     //todo redis?
     $user = Yii::$app->session->get('user');
     if (empty($user)) {
         $this->goHome();
     }
     $user = User::findOne($user->id);
     if ($user->account < Yii::$app->params['auctionDeposit']) {
         $order = Order::find()->where(['type' => Order::TYPE_AUCTION, 'user_id' => $user->id, 'status' => Order::STATUS_CREATED])->one();
         if (empty($order)) {
             $order = new Order();
             $order->user_id = $user->id;
             $order->serial_no = Util::composeOrderNumber(Order::TYPE_AUCTION);
             $order->money = Yii::$app->params['auctionDeposit'];
             $auction = Auction::find()->where('end_time > NOW()')->orderBy('start_time, end_time')->limit(1)->one();
             $order->auction_id = $auction->id;
             $order->status = Order::STATUS_CREATED;
             $order->type = Order::TYPE_AUCTION;
             $order->save();
         }
         $this->redirect('/pay/index?order_id=' . $order->serial_no);
     }
     $auctions = Auction::find()->where('end_time > NOW()')->orderBy('start_time, type')->limit(3)->all();
     $auctionIds = [];
     foreach ($auctions as $auction) {
         array_push($auctionIds, $auction->id);
     }
     $topOffers = $this->getTopOfferHash($auctionIds);
     $myOffers = $this->getMyTopOfferHash($user->id, $auctionIds);
     foreach ($topOffers as $tmpId => $tmpOffer) {
         if (!array_key_exists($tmpId, $myOffers)) {
             $myTmpOffer = [];
             $myTmpOffer['auction_id'] = $tmpId;
             $myTmpOffer['top'] = 0;
             $myOffers[$tmpId] = $myTmpOffer;
         }
         list($myOffers[$tmpId]['rank'], $myOffers[$tmpId]['class'], $myOffers[$tmpId]['message']) = $this->composeRankInfo($tmpId, $myOffers[$tmpId]['top']);
     }
     $isInAuction = $this->isInAuction();
     $hasNextAuction = $this->hasNextAuction();
     $startTime = isset($auctions[0]) ? $auctions[0]->start_time : '';
     $endTime = isset($auctions[0]) ? $auctions[0]->end_time : '';
     $countDownTime = str_replace(' ', 'T', $isInAuction ? $endTime : $startTime);
     $priceStep = Yii::$app->params['auctionStep'];
     $lang = Util::getLanguage();
     $view = $lang == 'en' ? 'auction' : 'auction-cn';
     Util::setLanguage($lang);
     return $this->render($view, compact('auctions', 'topOffers', 'myOffers', 'startTime', 'endTime', 'isInAuction', 'hasNextAuction', 'countDownTime', 'priceStep'));
 }
예제 #25
0
파일: OrderSearch.php 프로젝트: fosker/dbm
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Order::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, 'profile_id' => $this->profile_id, 'date' => $this->date, 'isDone' => $this->isDone]);
     $query->andFilterWhere(['like', 'descr', $this->descr])->andFilterWhere(['like', 'picture', $this->picture]);
     return $dataProvider;
 }
예제 #26
0
 public function actionLeader()
 {
     $dataProvider = Null;
     $searchModel = new OrderSearch();
     $totalbales = 0;
     $query = new Query();
     $dataProvider = new ActivedataProvider(['query' => Order::find(), 'pagination' => ['pageSize' => 20]]);
     $totalProvider = new ActiveDataProvider(['query' => Order::find()]);
     $totalProvider->setPagination(False);
     $models = $totalProvider->getModels();
     foreach ($models as $item) {
         $totalbales += $item->number_bales;
     }
     return $this->render('leader', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'totalbales' => $totalbales]);
 }
예제 #27
0
 public function search($params)
 {
     $query = Order::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     var_dump($params);
     die;
     $this->load($params);
     if (!$this->validate()) {
         var_dump($query);
         die;
         // 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, 'scoutid' => [$this->scoutid], 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'subdivision', $this->subdivision])->andFilterWhere(['like', 'house_number', $this->house_number])->andFilterWhere(['like', 'street_name', $this->street_name])->andFilterWhere(['like', 'city', $this->city])->andFilterWhere(['like', 'zip', $this->zip])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'drop_location', $this->drop_location])->andFilterWhere(['like', 'payment_type', $this->payment_type])->andFilterWhere(['like', 'check_number', $this->check_number])->andFilterWhere(['like', 'number_bales', $this->number_bales])->andFilterWhere(['like', 'order_amount', $this->order_amount]);
     //$query->andFilterWhere(['scoutid' => $scoutidArray]);
     return $dataProvider;
 }
예제 #28
0
 public function actionIndex()
 {
     //一个顾客有多少订单
     $customer = Customer::find()->where(['id' => 1])->one();
     //$orders=$customer->hasMany('\app\models\Order',array('cid'=>'id'))->asArray()->all();
     //获取类的全路径
     echo Order::className();
     //降低耦合:存在的问题是:如果表字段更换,就得从新再修改控制器,所以把这部分业务放在model中处理,以后修改字段,修改model,
     //$orders=$customer->hasMany(Order::className(),array('cid'=>'id'))->asArray()->all();
     //调用model中的方法
     //$orders=$customer->getOrder();
     //调用类中的魔术方法__get,order属性不存在时,就调用getOrder方法
     $orders = $customer->order;
     var_dump($orders);
     //查看一个订单属于哪个顾客
     $order = Order::find()->where(['id' => 3])->one();
     $o = $order->hasOne(Customer::className(), array('id' => 'cid'))->asArray()->one();
     var_dump($o);
 }
예제 #29
0
 public function actionTable()
 {
     $id = Yii::$app->user->id;
     $res = array();
     $date = date("Y-m-d");
     for ($i = 30; $i > 0; $i--) {
         $time = strtotime($date) - 3600 * 24 * $i;
         $time = date('Y-m-d', $time);
         $res[$time] = 0;
     }
     $temp = Order::find()->select('b_time,price')->where(['s_id' => $id])->asArray()->all();
     foreach ($temp as $value) {
         $time = strtotime($value['b_time']);
         $time = date('Y-m-d', $time);
         if (array_key_exists($time, $res)) {
             $res[$time] += $value['price'] + 10;
         }
     }
     return $this->render("table", ['list' => $res]);
 }
예제 #30
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Order::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $query->joinWith('statusFk AS statusFk');
     $dataProvider->sort->attributes['statusFk.status'] = ['asc' => ['statusFk.status' => SORT_ASC], 'desc' => ['statusFk.status' => SORT_DESC]];
     $query->joinWith('customerFk AS customerFk');
     $dataProvider->sort->attributes['customerFk.username'] = ['asc' => ['customerFk.username' => SORT_ASC], 'desc' => ['customerFk.username' => SORT_DESC]];
     $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, 'customer_fk' => $this->customer_fk, 'staff_fk' => $this->staff_fk, 'build_fk' => $this->build_fk, 'status_fk' => $this->status_fk, 'date_of_order' => $this->date_of_order, 'last_update' => $this->last_update]);
     $query->andFilterWhere(['like', 'notes', $this->notes])->andFilterWhere(['like', 'staff_notes', $this->staff_notes]);
     $query->andFilterWhere(['like', 'statusFk.status', $this->getAttribute('statusFk.status')]);
     $query->andFilterWhere(['like', 'customerFk.username', $this->getAttribute('customerFk.username')]);
     return $dataProvider;
 }