예제 #1
0
 /**
  * show Statuses
  */
 public function getStatuses($paginateItems = 50)
 {
     app('veer')->loadedComponents['counted']['orders'] = \Veer\Models\Order::select(\DB::raw('count(*) as orders_count, status_id'))->groupBy('status_id')->lists('orders_count', 'status_id');
     app('veer')->loadedComponents['counted']['orders_history'] = \Veer\Models\OrderHistory::select(\DB::raw('count(*) as orders_count, status_id'))->groupBy('status_id')->lists('orders_count', 'status_id');
     app('veer')->loadedComponents['counted']['bills'] = \Veer\Models\OrderBill::select(\DB::raw('count(*) as orders_count, status_id'))->groupBy('status_id')->lists('orders_count', 'status_id');
     return \Veer\Models\OrderStatus::orderBy('manual_order', 'asc')->paginate($paginateItems);
 }
예제 #2
0
 /**
  * delete Status
  */
 public function delete($id)
 {
     \Veer\Models\Order::where('status_id', '=', $id)->update(['status_id' => 0]);
     \Veer\Models\OrderBill::where('status_id', '=', $id)->update(['status_id' => 0]);
     \Veer\Models\OrderHistory::where('status_id', '=', $id)->update(['status_id' => 0]);
     \Veer\Models\OrderStatus::destroy($id);
     event('veer.message.center', trans('veeradmin.status.delete') . " " . $this->restore_link('OrderStatus', $id));
     return $this;
 }
예제 #3
0
파일: Bill.php 프로젝트: artemsk/veer-core
 public function comment($params)
 {
     if (!empty($params['comments'])) {
         $sendEmail = array_pull($params, 'send_to_customer');
         array_set($params, 'name', \Veer\Models\OrderStatus::where('id', '=', array_get($params, 'status_id'))->pluck('name'));
         \Veer\Models\OrderHistory::create($params + ['order_cache' => '']);
         if (!empty($sendEmail)) {
             $this->sendEmailOrdersStatus(array_get($params, 'orders_id'), ["history" => $params]);
         }
     }
     return $this;
 }
예제 #4
0
 protected function deleteOrder($id)
 {
     $order = \Veer\Models\Order::find($id);
     if (is_object($order)) {
         \Veer\Models\OrderHistory::where('orders_id', '=', $id)->delete();
         $order->orderContent()->delete();
         $order->bills()->delete();
         $order->secrets()->delete();
         // communications skip
         $order->delete();
         return true;
     }
     return false;
 }
예제 #5
0
 /**
  * make Order
  */
 protected function makeOrder()
 {
     $cart = $this->showUser->getUserCart(app('veer')->siteId, \Auth::id(), app('session')->getId());
     // rules
     if (\Auth::id() <= 0 && \Input::get('email') == null || $cart->count() <= 0) {
         \Session::flash('errorMessage', \Lang::get('veershop.order.error'));
         return \Redirect::route('user.cart.show');
     }
     $grouped = app('veershop')->regroupShoppingCart($cart);
     $book = null;
     if (\Input::get('userbook_id') != null) {
         $book = \Veer\Models\UserBook::find(\Input::get('userbook_id'));
     }
     if (\Input::get('book.address') != null) {
         $book = app('veershop')->updateOrNewBook(\Input::get('book'));
     }
     list($order, $checkDiscount, $calculations) = app('veershop')->prepareOrder($grouped, $book, \Input::get('shipping_id'), \Input::get('payment_id'), false);
     $statusName = \Veer\Models\OrderStatus::where('id', '=', $order->status_id)->pluck('name');
     \Veer\Models\OrderHistory::create(array("orders_id" => $order->id, "status_id" => $order->status_id, "name" => !empty($statusName) ? $statusName : '', "comments" => ""));
     $order->save();
     if (isset($checkDiscount) && is_object($checkDiscount)) {
         app('veershop')->changeUserDiscountStatus($checkDiscount);
     }
     //app('veershop')->sendEmailOrderNew($order);
     // clear cart
     $this->showUser->getUserLists(app('veer')->siteId, \Auth::id(), app('session')->getId(), '[basket]', false)->delete();
     \Session::put('successfulOrder', $order->id);
     return \Redirect::route('order.success');
 }
예제 #6
0
파일: Order.php 프로젝트: artemsk/veer-core
 public function status($history)
 {
     array_set($history, 'orders_id', $this->id);
     array_set($history, 'name', \Veer\Models\OrderStatus::where('id', '=', array_get($history, 'status_id'))->pluck('name'));
     if (empty($history['name'])) {
         $history['name'] = '[?]';
     }
     $update = ['status_id' => array_get($history, 'status_id')];
     $progress = array_pull($history, 'progress');
     if (!empty($progress)) {
         $update['progress'] = $progress;
     }
     $sendEmail = array_pull($history, 'send_to_customer');
     \Veer\Models\OrderHistory::create($history);
     \Veer\Models\Order::where('id', '=', $this->id)->update($update);
     if (!empty($sendEmail)) {
         $this->sendEmailOrdersStatus($this->id, ['history' => $history]);
     }
     return $this;
 }