/**
  * Display a listing of the resource.
  *
  * @param StatRequest $request
  * @return Response
  */
 public function index(StatRequest $request)
 {
     //////////////////* DAY *////////////////////
     if (is_null($request->day)) {
         $day = date('Y-m-d');
         $dDay = date('d/m/Y');
     } else {
         $day = $request->day;
         $dDay = (new \DateTime($request->day))->format('d/m/Y');
     }
     $dTotal = J2storeOrder::isValid()->whereBetween('created_date', [$day . ' 00:00:01', $day . ' 23:59:59'])->get();
     $dPaypal = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$day . ' 00:00:01', $day . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_paypal')->get()->sum('order_total'));
     $dCash = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$day . ' 00:00:01', $day . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_cash')->get()->sum('order_total'));
     $dMoneyorder = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$day . ' 00:00:01', $day . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_moneyorder')->get()->sum('order_total'));
     $dAbort = J2storeOrder::isAbort()->whereBetween('created_date', [$day . ' 00:00:01', $day . ' 23:59:59'])->having('order_state_id', '=', '5')->get();
     $dNul = J2storeOrder::isAbort()->whereBetween('created_date', [$day . ' 00:00:01', $day . ' 23:59:59'])->having('order_state_id', '=', '3')->get();
     //////////////////* WEEK *////////////////////
     if ($request->week) {
         $week = $request->week;
         $dayStart = $request->dayStart;
         $dayStop = $request->dayStop;
     } else {
         $week = date('d/m', strtotime('last Monday')) . '-' . date('d/m/Y', strtotime('next Sunday'));
         $dayStart = date('Y-m-d', strtotime('last Monday'));
         $dayStop = date('Y-m-d', strtotime('next Sunday'));
     }
     $wTotal = J2storeOrder::isValid()->whereBetween('created_date', [$dayStart . ' 00:00:01', $dayStop . ' 23:59:59'])->get();
     $wPaypal = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$dayStart . ' 00:00:01', $dayStop . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_paypal')->get()->sum('order_total'));
     $wCash = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$dayStart . ' 00:00:01', $dayStop . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_cash')->get()->sum('order_total'));
     $wMoneyorder = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$dayStart . ' 00:00:01', $dayStop . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_moneyorder')->get()->sum('order_total'));
     $wAbort = J2storeOrder::isAbort()->whereBetween('created_date', [$dayStart . ' 00:00:01', $dayStop . ' 23:59:59'])->having('order_state_id', '=', '5')->get();
     $wNul = J2storeOrder::isAbort()->whereBetween('created_date', [$dayStart . ' 00:00:01', $dayStop . ' 23:59:59'])->having('order_state_id', '=', '3')->get();
     //////////////////* MOIS *////////////////////
     if ($request->month) {
         $month = $request->month;
         $year = $request->year;
     } else {
         $month = date('m');
         $year = date('Y');
     }
     $mTotal = J2storeOrder::isValid()->whereBetween('created_date', [$year . '-' . $month . '-' . '01' . ' 00:00:01', $year . '-' . $month . '-' . '31' . ' 23:59:59'])->get();
     $mPaypal = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$year . '-' . $month . '-' . '01' . ' 00:00:01', $year . '-' . $month . '-' . '31' . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_paypal')->get()->sum('order_total'));
     $mCash = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$year . '-' . $month . '-' . '01' . ' 00:00:01', $year . '-' . $month . '-' . '31' . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_cash')->get()->sum('order_total'));
     $mMoneyorder = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$year . '-' . $month . '-' . '01' . ' 00:00:01', $year . '-' . $month . '-' . '31' . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_moneyorder')->get()->sum('order_total'));
     $mAbort = J2storeOrder::isAbort()->whereBetween('created_date', [$year . '-' . $month . '-' . '01' . ' 00:00:01', $year . '-' . $month . '-' . '31' . ' 23:59:59'])->having('order_state_id', '=', '5')->get();
     $mNul = J2storeOrder::isAbort()->whereBetween('created_date', [$year . '-' . $month . '-' . '01' . ' 00:00:01', $year . '-' . $month . '-' . '31' . ' 23:59:59'])->having('order_state_id', '=', '3')->get();
     //////////////////* YEAR *////////////////////
     if ($request->yYear) {
         $yYear = $request->yYear;
     } else {
         $yYear = date('Y');
     }
     $yTotal = J2storeOrder::isValid()->whereBetween('created_date', [$yYear . '-01-' . '01' . ' 00:00:01', $yYear . '-12-' . '31' . ' 23:59:59'])->get();
     $yPaypal = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$yYear . '-01-' . '01' . ' 00:00:01', $yYear . '-12-' . '31' . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_paypal')->get()->sum('order_total'));
     $yCash = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$yYear . '-01-' . '01' . ' 00:00:01', $yYear . '-12-' . '31' . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_cash')->get()->sum('order_total'));
     $yMoneyorder = floatval(J2storeOrder::isValid()->whereBetween('created_date', [$yYear . '-01-' . '01' . ' 00:00:01', $yYear . '-12-' . '31' . ' 23:59:59'])->having('orderpayment_type', '=', 'payment_moneyorder')->get()->sum('order_total'));
     $yAbort = J2storeOrder::isAbort()->whereBetween('created_date', [$yYear . '-01-' . '01' . ' 00:00:01', $yYear . '-12-' . '31' . ' 23:59:59'])->having('order_state_id', '=', '5')->get();
     $yNul = J2storeOrder::isAbort()->whereBetween('created_date', [$yYear . '-01-' . '01' . ' 00:00:01', $yYear . '-12-' . '31' . ' 23:59:59'])->having('order_state_id', '=', '3')->get();
     return view('pages.statistiques.index', compact('dTotal', 'dPaypal', 'dCash', 'dMoneyorder', 'dAbort', 'dNul', 'dDay', 'week', 'wTotal', 'wPaypal', 'wCash', 'wMoneyorder', 'wAbort', 'wNul', 'mTotal', 'mPaypal', 'mCash', 'mMoneyorder', 'mAbort', 'mNul', 'yYear', 'yTotal', 'yPaypal', 'yCash', 'yMoneyorder', 'yAbort', 'yNul'));
 }
 /**
  * @param Request $request
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update(Request $request)
 {
     if (isset($request)) {
         $order = J2storeOrder::find($request->order_id);
         $order->order_state = $request->order_state;
         if ($request->order_state === 'stay') {
             $order->order_state_id = 1;
         } else {
             if ($request->order_state === 'confirm') {
                 $order->order_state_id = 2;
             } else {
                 if ($request->order_state === 'stop') {
                     $order->order_state_id = 3;
                 }
             }
         }
         $order->save();
     }
     //        return view()->action('HomeController@index');
     return redirect()->back();
 }
Beispiel #3
0
 public function contact()
 {
     $tri = J2storeOrder::first()->contact->order_state;
     return $this->hasOne('tri');
 }
 /**
  * @return \Illuminate\View\View
  */
 public function waitCom()
 {
     $order = J2storeOrder::all()->where('order_state_id', 1);
     $orderInfo = J2storeOrderInfo::all();
     return view('pages.commandes.index', compact('orderInfo', 'order'));
 }