Пример #1
0
 public function getByUserId($id)
 {
     $userWithAttributes = User::with('role', 'attributesBoolean', 'attributesDate', 'attributesInteger', 'attributesFloat', 'attributesText', 'attributesVarChar', 'attributesSingleSelect', 'attributesMultiSelect')->find($id);
     $this->populateUserAttributes($userWithAttributes->attributesBoolean);
     $this->populateUserAttributes($userWithAttributes->attributesInteger);
     $this->populateUserAttributes($userWithAttributes->attributesFloat);
     $this->populateUserAttributes($userWithAttributes->attributesDate);
     $this->populateUserAttributes($userWithAttributes->attributesText);
     $this->populateUserAttributes($userWithAttributes->attributesVarChar);
     $this->populateUserAttributes($userWithAttributes->attributesSingleSelect);
     $this->populateUserAttributes($userWithAttributes->attributesMultiSelect);
     return ['user' => User::find($id), 'attributes' => $this->attributes];
 }
Пример #2
0
 public function changeReservationStatus($reservation_id, $data)
 {
     $userModel = User::find($data['user_id']);
     //$reservStatus = new ReservationStatus();
     $statusId = $data['status'];
     $reservType = isset($data['reserv_type']) ? $data['reserv_type'] : "";
     //$reservStatus->save();
     $statusLog = ReservStatusLog::where('reservation_id', '=', $reservation_id)->orderBy('id', 'desc')->take(1)->get();
     if ($statusLog->isEmpty()) {
         $statusLogEntry = new ReservStatusLog();
         $statusLogEntry->reservation_id = $reservation_id;
         $statusLogEntry->user_id = $userModel->id;
         $statusLogEntry->old_reservation_status_id = 0;
         $statusLogEntry->new_reservation_status_id = $statusId;
         $statusLogEntry->save();
     } else {
         $statusLogEntry = new ReservStatusLog();
         $statusLogEntry->reservation_id = $reservation_id;
         $statusLogEntry->user_id = $userModel->id;
         $statusLogEntry->old_reservation_status_id = $statusLog[0]->new_reservation_status_id;
         $statusLogEntry->new_reservation_status_id = $statusId;
         $statusLogEntry->save();
     }
     if (!empty($data['addons'])) {
         //print_r($data['addons']);die;
         if (isset($data['mobile']) && $data['mobile'] == 1) {
             /*foreach($data['addons'] as $key => $detail) {
                   $result = ReservAddonVarientDetails::where('options_id', $detail['prod_id'])->where('reservation_id', $reservation_id)->first();
                   $result->reservation_status_id = $statusId;
                   $result->save();
               }*/
             foreach ($data['addons'] as $addonInfo) {
                 //print_r($addonInfo['prod_id']);die;
                 if ($addonInfo['qty'] > 0) {
                     $result = new ReservAddonVarientDetails();
                     $result->no_of_persons = $addonInfo['qty'];
                     $result->options_id = $addonInfo['prod_id'];
                     $result->option_type = 'addon';
                     $result->reservation_type = 'experience';
                     $result->reservation_id = $reservation_id;
                     $result->reservation_status_id = $statusId;
                     $result->save();
                 }
             }
             //self::addActualAddonTakers($reservation_id,$data['addons']);
         } else {
             /*foreach ($data['addons'] as $prod_id => $count) {
                   if($count > 0) {
                       $result = ReservAddonVarientDetails::where('options_id', $prod_id)->where('reservation_id', $reservation_id)->first();
                       $result->reservation_status_id = $statusId;
                       $result->save();
                   }
                   //print_r($result);die;
               }*/
             self::addActualAddonTakers($reservation_id, $data['addons']);
         }
     }
     /*if($statusId == 1 || $statusId == 2 || $statusId == 3){
           $this->pushToRestaurant($reservation_id);
       }*/
     if (!empty($reservType)) {
         switch ($statusId) {
             case 2:
                 //for edited status
                 //prepare the array for sending status to zoho
                 $zoho_data = array('Order_completed' => 'User Changed');
                 if ($reservType == "Experience") {
                     $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data);
                 } else {
                     if ($reservType == "Alacarte") {
                         $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data);
                     }
                 }
                 break;
             case 3:
                 //for cancelled status
                 $zoho_data = array('Order_completed' => 'User Cancelled');
                 if ($reservType == "Experience") {
                     $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data);
                 } else {
                     if ($reservType == "Alacarte") {
                         $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data);
                     }
                 }
                 break;
             case 6:
                 //for accepted status
                 $adminComments = DB::table('reservation_attributes_text')->where('reservation_id', $reservation_id)->where('reservation_attribute_id', 17)->select('attribute_value')->first();
                 $zoho_data = array('Order_completed' => 'Confirmed with rest & customer', 'Satisfaction' => $adminComments->attribute_value);
                 if ($reservType == "Experience") {
                     $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data);
                 } else {
                     if ($reservType == "Alacarte") {
                         $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data);
                     }
                 }
                 break;
             case 7:
                 //for rejected status
                 $zoho_data = array('Order_completed' => 'Rejected by restaurant');
                 if ($reservType == "Experience") {
                     $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data);
                 } else {
                     if ($reservType == "Alacarte") {
                         $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data);
                     }
                 }
                 break;
             case 8:
                 //for closed status
                 $zoho_data = array('Order_completed' => 'yes');
                 if ($reservType == "Experience") {
                     $this->changeStatusInZoho('E' . sprintf("%06d", $reservation_id), $zoho_data);
                 } else {
                     if ($reservType == "Alacarte") {
                         $this->changeStatusInZoho('A' . sprintf("%06d", $reservation_id), $zoho_data);
                     }
                 }
                 break;
         }
     }
     return "Success";
 }
Пример #3
0
 public function create_reward($id)
 {
     $users = \WowTables\Http\Models\Eloquent\User::find($id);
     $rewards = $this->user->get_all_records($id);
     $points_earned = $this->user->get_all_points_earned($id);
     $points_spent = $this->user->get_all_points_spent($id);
     return view('admin.users.rewards', ['user_id' => $id, 'rewards' => $rewards, 'users' => $users, 'points_earned' => $points_earned, 'points_spent' => $points_spent]);
 }
Пример #4
0
 public function today()
 {
     $todayBookings = array();
     $count = 0;
     $statusCancelledNew = DB::select(DB::raw('select rd.id as reservation_id,rd.user_id as user_id from reservation_details as rd left join reservation_attributes_date as rad on rd.id = rad.reservation_id where DATE(rad.attribute_value) = \'' . Carbon::now()->format('Y-m-d') . '\''));
     $reservationIdArr = array();
     foreach ($statusCancelledNew as $reservId) {
         $reservationIdArr[$reservId->reservation_id] = $reservId->user_id;
     }
     $reservStatusArr = $this->reservationDetails->getReservationStatus(array_keys($reservationIdArr), [1, 2, 3, 6, 7, 8]);
     $todayPaginate = ReservationDetails::with('experience', 'vendor_location.vendor', 'vendor_location.address.city_name', 'attributesDatetime')->where('vendor_location_id', '!=', '0')->where('vendor_location_id', '!=', '54')->whereIn('id', array_keys($reservationIdArr))->where('created_at', '>=', '2015-10-12 15:20:00')->orderBy('created_at', 'desc')->paginate(15);
     foreach (ReservationDetails::with('experience', 'vendor_location.vendor', 'vendor_location.address.city_name', 'attributesDatetime')->where('vendor_location_id', '!=', '0')->where('vendor_location_id', '!=', '54')->whereIn('id', array_keys($reservationIdArr))->where('created_at', '>=', '2015-10-12 15:20:00')->orderBy('created_at', 'desc')->paginate(15) as $today) {
         $booking = new \stdClass();
         $booking->id = $today->id;
         /*$reservCarbonDate = Carbon::createFromFormat('Y-m-d H:i:s',$today->attributesDatetime->attribute_value);
         		$booking->bdate = $reservCarbonDate->format('d-m-Y');
         		$booking->btime = $reservCarbonDate->format('h:i A');*/
         if ($today->product_id == 0) {
             $booking->name = "Classic Reservation";
         } else {
             $booking->name = $today->experience->name;
         }
         $booking->cust_name = $today->guest_name;
         if (isset($today->vendor_location->vendor->name)) {
             $booking->restaurant_name = $today->vendor_location->vendor->name;
         } else {
             $booking->restaurant_name = "";
         }
         if (empty($today->vendor_location->address->city_name)) {
             $booking->city = "";
         } else {
             $booking->city = $today->vendor_location->address->city_name->name;
         }
         //$reservStatus = $today->reservationStatus->first();
         //dd($reservStatus);
         $booking->email = $today->guest_email;
         $booking->phone_no = $today->guest_phone;
         $booking->no_of_persons = $today->no_of_persons;
         //$booking->status = $reservStatus->status;
         $userModel = User::find($reservationIdArr[$today->id]);
         $booking->lastmodified = $userModel->role->name;
         $booking->user_id = $today->user_id;
         $statusArr = $this->reservStatuses;
         $statusKey = array_search($reservStatusArr[$today->id], $statusArr);
         if ($statusKey != -1) {
             unset($statusArr[$statusKey]);
         }
         $booking->reserv_status = $reservStatusArr[$today->id][0];
         $booking->statusArr = $statusArr;
         $reservationDetailsAttr = $this->reservationDetails->getByReservationId($today->id);
         $booking->special_request = isset($reservationDetailsAttr['attributes']['special_request']) ? $reservationDetailsAttr['attributes']['special_request'] : "";
         $booking->gift_card_id = isset($reservationDetailsAttr['attributes']['gift_card_id_reserv']) ? $reservationDetailsAttr['attributes']['gift_card_id_reserv'] : "";
         $booking->outlet = isset($reservationDetailsAttr['attributes']['outlet']) ? $reservationDetailsAttr['attributes']['outlet'] : "";
         $booking->reserv_type = $reservationDetailsAttr['attributes']['reserv_type'];
         $reservCarbonDate = Carbon::createFromFormat('Y-m-d H:i:s', $reservationDetailsAttr['attributes']['reserv_datetime']);
         $booking->bdate = $reservCarbonDate->format('d-m-Y');
         $booking->btime = $reservCarbonDate->format('h:i A');
         $todayBookings[$count] = $booking;
         $count++;
         //print_r($today);
     }
     return view('admin.bookings.list.today')->with('todaysbookings', $todayBookings)->with('today_paginate', $todayPaginate);
 }