Example #1
0
 /**
  * Show the application dashboard.
  *
  * @return Response
  */
 public function index()
 {
     $users = \DB::table('users')->join('orders', 'orders.manager', '=', 'users.id')->groupBy('orders.manager')->select('users.*', \DB::raw('count(manager) as total'))->get();
     $orders = new OrderRepository(new Order());
     $managers = $orders->findAllManager('success', 'monitor', ['*'], true);
     return view('home', compact('users', 'managers'));
 }
 /**
  * Finish or put an order back
  *
  * @param $id
  * @param Request $request
  * @return mixed
  */
 public function update($id, Request $request)
 {
     $done = $request->get('done');
     if ($done) {
         $order = $this->orderRepository->finishOrder($id);
     } else {
         $order = $this->orderRepository->unFinishOrder($id);
     }
     return $order;
 }
 /**
  * Handle the command.
  *
  * @param  SaveOrderCommand  $command
  * @return void
  */
 public function handle(SaveOrderCommand $command)
 {
     $this->orderRepository->save($command->input);
     $lastOrderId = $this->orderRepository->findLastSavedId();
     foreach ($command->orderItems as $id => $amount) {
         $orderItemName = $this->productRepository->findById($id)->name;
         $this->orderItemRepository->save($orderItemName, $amount, $lastOrderId);
     }
     $order = $this->orderRepository->findById($lastOrderId);
     Mail::send('emails.orderinfo', ['order' => $order], function ($m) use($order) {
         $m->to($order->email, $order->billing_name)->subject('Your Order Information');
     });
 }
Example #4
0
 public function importExcel()
 {
     $fileInfo = $this->uploadFile(request()->file('file'), 'import');
     $pathToFile = $fileInfo['path'] . '/' . $fileInfo['name'];
     Excel::selectSheets('Sheet1')->load($pathToFile, function ($reader) {
         $rows = $reader->get();
         foreach ($rows as $key => $value) {
             $order = $this->excelForOrder($value, 'monitor');
             // insert into order table
             $newOrder = new OrderRepository(new Order());
             $newOrder->create($order);
         }
     });
     return redirect()->back();
 }
Example #5
0
 /**
  * Remove the specified resource from storage.
  *
  * @param int    $order_id
  * @param string $type
  *
  * @return void
  */
 public function destroy($order_id, $type)
 {
     if ($this->order->belongToUser(auth()->user(), $order_id, $order) && $this->order->canBeDeleted($type)) {
         $order->details()->delete();
         $order->delete();
         Session::push('message', trans('store.wish_list_view.success_deleting_msg'));
     } else {
         Session::push('message', trans('store.wish_list_view.error_deleting_msg'));
     }
     return redirect()->back();
 }
Example #6
0
 public function importExcel()
 {
     $fileInfo = $this->uploadFile(request()->file('file'), 'import');
     $pathToFile = $fileInfo['path'] . '/' . $fileInfo['name'];
     Excel::selectSheets('Sheet1')->load($pathToFile, function ($reader) {
         $rows = $reader->get();
         foreach ($rows as $key => $value) {
             // b1: insert Order
             $order = $this->excelForOrder($value, 'xmctb');
             $newOrder = new OrderRepository(new Order());
             $t = $newOrder->create($order);
             // b2: insert ship from order
             foreach ($t->phones as $index => $phone) {
                 $input = $this->excelForShip($value, $phone->id);
                 $newShip = new ShipRepository(new Ship());
                 $newShip->create($input);
             }
         }
     });
     return redirect()->back();
 }
 public function destroy($id)
 {
     $this->orderRepository->findById($id)->delete();
     return redirect()->back();
 }
 public function orders(OrderRepository $orders, OrderItemRepository $orderItems)
 {
     return view('admin.main')->with('orders', $orders->all());
 }
Example #9
0
 public function exportExcel()
 {
     $date = request()->input('date');
     $arrayDate = str_split($date, 8);
     $startDate = $this->order->stringToDate($arrayDate[0]);
     $endDate = $this->order->stringToDate($arrayDate[1]);
     $orderRepo = new OrderRepository(new Order());
     if (request()->has('id')) {
         $unitId = request()->input('id');
         $monitor = $this->order->statisticsUnit($startDate, $endDate, $unitId, 'monitor');
         $orther = $this->order->statisticsUnit($startDate, $endDate, $unitId);
         $data = $monitor->merge($orther);
         $data = $data->groupBy('purpose.symbol');
         $view = 'statistics.output_unit';
     } else {
         $data = $orderRepo->statistics($startDate, $endDate);
         $view = 'statistics.output';
     }
     Excel::create($date, function ($excel) use($view, $data) {
         // var_dump($data);
         // Call them separately
         $excel->setDescription('File created by TNT');
         // Set top, right, bottom, left
         $excel->sheet('tnt', function ($sheet) use($view, $data) {
             $sheet->setPageMargin(array(0.25, 0, 0, 0.5));
             $sheet->setOrientation('landscape');
             // Font family
             $sheet->setFontFamily('Times New Roman');
             // Font size
             $sheet->setFontSize(14);
             $sheet->loadView($view, ['result' => $data]);
         });
     })->export('xlsx');
 }