public function anyDashboard() { $website_views = WebsiteViews::all(); $total_pending = Bookings::where('pending', 1)->count(); $total_consulted = Bookings::where('consulted', 1)->count(); $total_completed = Bookings::where('completed', 1)->count(); $total_cancelled = Bookings::where('cancelled', 1)->count(); $total_service_sales = 0; $total_shop_sales = 0; return View::make('dashboard.dashboard', ['website_views' => $website_views->count(), 'total_pending' => $total_pending, 'total_consulted' => $total_consulted, 'total_completed' => $total_completed, 'total_cancelled' => $total_cancelled, 'total_service_sales' => $total_service_sales, 'total_shop_sales' => $total_shop_sales]); }
public function anyUpdateStatus($booking_uid, $status) { $booking = Bookings::where('uid', '=', $booking_uid)->first(); $error_msg = []; $tz = new \DateTimeZone('NZ'); $now = new \DateTime(date('Y-m-d H:i:s')); $now->setTimezone($tz); $current_date_time = $now->format('Y-m-d H:i:s'); $success = false; $booking_date = Input::get('booking_date'); $booking_time = Input::get('booking_time'); if (Request::method() == 'GET') { return view('booking.update_status', ['booking' => $booking, 'success' => $success, 'status' => $status, 'error_msg' => $error_msg]); } else { if ($booking) { if ($status == 'consulted') { $booking->pending = 0; $booking->consulted = 1; $booking->completed = 0; $booking->cancelled = 0; $booking->consulted_at = $current_date_time; $booking->save(); $success = true; } elseif ($status == 'completed') { if ($booking_date && $booking_time) { $booking->pending = 0; $booking->consulted = 0; $booking->completed = 1; $booking->cancelled = 0; $booking->completed_at = $current_date_time; $booking->booking_date = date('Y-m-d', strtotime($booking_date)); $booking->booking_time = date('H:i:s', strtotime($booking_time)); $booking->save(); $success = true; } else { $error_msg[] = 'Booking date and booking time are required.'; $success = false; } } elseif ($status == 'cancelled') { $booking->pending = 0; $booking->consulted = 0; $booking->completed = 0; $booking->cancelled = 1; $booking->cancelled_at = $current_date_time; $booking->save(); $success = true; } else { $error_msg[] = 'No status selected'; $success = false; } if ($success) { return Redirect::back()->with('success', $success); } else { return view('booking.update_status', ['booking' => $booking, 'success' => $success, 'status' => $status, 'error_msg' => $error_msg]); } } else { return Redirect::back()->with(['success', $success, 'error_msg', $error_msg]); } } }