Ejemplo n.º 1
0
 /**
 * Get the Profile details of the user in web requrest
 *
 * @static  true
 * @access  public
 * @param   array $id
 * @since   1.0.0
 */
 public static function getUserProfileWeb($id)
 {
     $queryProfileResult = DB::table('users as u')->leftjoin('user_attributes_date as uad', 'u.id', '=', 'uad.user_id')->leftjoin('user_attributes as ua', function ($join) {
         $join->on('uad.user_attribute_id', '=', 'ua.id')->where('ua.alias', '=', 'date_of_birth');
     })->leftjoin('locations as l', 'l.id', '=', 'u.location_id')->leftjoin('user_attributes_singleselect as uas', 'u.id', '=', 'uas.user_id')->leftjoin('user_attributes_select_options as uaso', 'uas.user_attributes_select_option_id', '=', 'uaso.id')->leftjoin('user_attributes as ua2', function ($join) {
         $join->on('uaso.user_attribute_id', '=', 'ua2.id')->where('ua2.alias', '=', 'gender');
     })->leftjoin('user_attributes_integer as uai', 'uai.user_id', '=', 'u.id')->leftjoin('user_attributes_varchar as uav', 'uav.user_id', '=', 'u.id')->leftjoin('user_attributes as ua3', 'ua3.id', '=', 'uai.user_attribute_id')->leftjoin('user_attributes as ua4', 'ua4.id', '=', 'uad.user_attribute_id')->leftjoin('user_attributes as ua5', 'ua5.id', '=', 'uav.user_attribute_id')->leftjoin('user_devices as ud', 'u.id', '=', 'ud.user_id')->where('u.id', $id)->select('u.id as user_id', 'u.full_name', 'u.email', 'phone_number', 'u.zip_code', 'u.newsletter_frequency', 'uaso.option as gender', 'l.id as location_id', 'l.name as location', 'ud.access_token', 'u.points_earned as points_earned', 'u.points_spent as points_spent', DB::raw('MAX(IF(ua3.alias = "bookings_made", uai.attribute_value, 0)) AS bookings_made'), DB::raw('MAX(IF(ua5.alias = "membership_number", uav.attribute_value, 0)) AS membership_number'), DB::raw('MAX(IF(ua3.alias = "a_la_carte_reservation", uai.attribute_value, 0)) AS a_la_carte_reservation'), DB::raw('MAX(IF(ua4.alias = "date_of_birth", date(uad.attribute_value), 0)) AS dob'), DB::raw('MAX(IF(ua4.alias = "anniversary_date", date(uad.attribute_value), 0)) AS anniversary_date'))->groupby('u.id')->first();
     //Read all the preferred locations
     //$preferredLocations=Profile::getUserPreferences($id);
     //Read all the AREAS related to user's location
     $cityAreas = Locations::readCityArea($queryProfileResult->location_id);
     //array to contain the response to be sent back to client
     $arrResponse = array();
     $lastReservationDetail = ReservationDetails::getUserLastReservation($queryProfileResult->user_id);
     //print_r($lastReservationDetail);
     if ($queryProfileResult) {
         $arrResponse['status'] = Config::get('constants.API_SUCCESS');
         $arrResponse['data'] = array('user_id' => $queryProfileResult->user_id, 'full_name' => $queryProfileResult->full_name, 'email' => $queryProfileResult->email, 'phone_number' => $queryProfileResult->phone_number == 0 ? "" : $queryProfileResult->phone_number, 'zip_code' => $queryProfileResult->zip_code, 'gender' => $queryProfileResult->gender, 'location_id' => $queryProfileResult->location_id, 'location' => $queryProfileResult->location, 'points_earned' => $queryProfileResult->points_earned, 'points_spent' => $queryProfileResult->points_spent, 'points_remaining' => $queryProfileResult->points_earned - $queryProfileResult->points_spent, 'bookings_made' => $queryProfileResult->bookings_made, 'membership_number' => $queryProfileResult->membership_number, 'a_la_carte_reservation' => $queryProfileResult->a_la_carte_reservation, 'dob' => $queryProfileResult->dob, 'anniversary_date' => $queryProfileResult->anniversary_date, 'newsletter_frequency' => $queryProfileResult->newsletter_frequency, 'areas' => $cityAreas['data'], 'last_reservation_date' => empty($lastReservationDetail->reservation_date) ? "" : $lastReservationDetail->reservation_date, 'last_reservation_time' => empty($lastReservationDetail->reservation_time) ? "" : $lastReservationDetail->reservation_time);
     } else {
         $arrResponse['status'] = Config::get('constants.API_SUCCESS');
         $arrResponse['data'] = array();
     }
     return $arrResponse;
 }
Ejemplo n.º 2
0
 /**
  * Writes the details of the reservation in the DB.
  * 
  * @static	true
  * @access	public
  * @param	array 	$arrData
  * @return	boolean
  * @since	1.0.0
  */
 public static function addReservationDetails($arrData, $userID, $objMailChimp, $userType = 'website_user')
 {
     //creating a new instance of the table
     $reservation = new ReservationDetails();
     $date = date_create($arrData['reservationTime']);
     $arrData['reservationTime'] = date_format($date, "h:i A");
     //initializing the data
     $reservation->reservation_status = 'new';
     $reservation->reservation_date = $arrData['reservationDate'];
     $reservation->reservation_time = $arrData['reservationTime'];
     $reservation->no_of_persons = $arrData['partySize'];
     $reservation->guest_name = $arrData['guestName'];
     $reservation->guest_email = $arrData['guestEmail'];
     $reservation->guest_phone = $arrData['phone'];
     $reservation->reservation_type = $arrData['reservationType'];
     $reservation->order_amount = 0;
     $reservation->user_id = $userID;
     $reservation->added_by = $userType;
     //setting up the variables that may be present
     if (isset($arrData['specialRequest'])) {
         $reservation->special_request = $arrData['specialRequest'];
     }
     if (isset($arrData['giftCardID'])) {
         $reservation->giftcard_id = $arrData['giftCardID'];
     }
     //get the user city for mailchimp
     if (isset($reservation->user_id)) {
         $city_name = self::getLocationOfUser($reservation->user_id);
     }
     //setting up the value of the location id as per type
     if ($arrData['reservationType'] == 'alacarte') {
         //reading the resturants detail
         $aLaCarteDetail = self::readVendorDetailByLocationID($arrData['vendorLocationID']);
         $reservation->points_awarded = $aLaCarteDetail['reward_point'];
         $reservation->vendor_location_id = $arrData['vendorLocationID'];
         $reservation->product_vendor_location_id = 0;
     } else {
         if ($arrData['reservationType'] == 'experience') {
             //reading the product detail
             $productDetail = self::readProductDetailByProductVendorLocationID($arrData['vendorLocationID']);
             $arrResult = self::readProductIdAndVendorLocation($arrData['vendorLocationID']);
             //print_r($arrResult);die;
             $reservation->points_awarded = $productDetail['reward_point'];
             $reservation->vendor_location_id = $arrResult->vendor_location_id;
             $reservation->product_id = $arrResult->product_id;
             $reservation->product_vendor_location_id = $arrData['vendorLocationID'];
         }
     }
     #saving the information into the DB
     $savedData = $reservation->save();
     if ($savedData) {
         $reservation_id = ReservationDetails::where('user_id', '=', $userID)->where('reservation_date', '=', $arrData['reservationDate'])->where('reservation_time', '=', $arrData['reservationTime'])->where('reservation_status', '!=', 'cancel')->select('id')->first();
         //Reading user detail to get membership number(GIU_Membership_ID)
         $token = $_SERVER['HTTP_X_WOW_TOKEN'];
         $userDetail = Profile::getUserProfile($token);
         if ($arrData['reservationType'] == 'alacarte') {
             $arrResponse['status'] = Config::get('constants.API_SUCCESS');
             $arrResponse['data']['reservation_id'] = $reservation_id['id'];
             $arrResponse['data']['name'] = $aLaCarteDetail['name'];
             $arrResponse['data']['url'] = URL::to('/') . '/alacarte/' . $aLaCarteDetail['vl_id'];
             $arrResponse['data']['reservationDate'] = $arrData['reservationDate'];
             $arrResponse['data']['reservationTime'] = $arrData['reservationTime'];
             $arrResponse['data']['partySize'] = $arrData['partySize'];
             $arrResponse['data']['reward_point'] = $aLaCarteDetail['reward_point'];
             //Increment the Reservation count by 1
             $reservationCount = self::incrementReservationCount($userID, $arrData['reservationType']);
             //Increment reward point in user table
             DB::table('users')->where('id', $userID)->increment('points_earned', $aLaCarteDetail['reward_point']);
             //Insert record for new reward point
             $storeRewardPoint = self::storeRewardPoint($userID, $aLaCarteDetail['reward_point'], $reservation_id['id']);
             //Reading offers detail
             $offersResult = self::getSpecialOfferDetail($arrData['vendorLocationID']);
             //for the new db structure support
             $combined_date_and_time = $arrData['reservationDate'] . ' ' . $arrData['reservationTime'];
             $newDb['attributes']['reserv_datetime'] = Carbon::createFromFormat('Y-m-d H:i A', $combined_date_and_time)->toDateTimeString();
             $newDb['attributes']['no_of_people_booked'] = $arrData['partySize'];
             $newDb['attributes']['cust_name'] = $arrData['guestName'];
             $newDb['attributes']['email'] = $arrData['guestEmail'];
             $newDb['attributes']['contact_no'] = $arrData['phone'];
             $newDb['attributes']['reserv_type'] = "Alacarte";
             //$newDb['attributes']['gift_card_id_reserv'] = $dataPost['giftCardID'];
             $newDb['attributes']['loyalty_points_awarded'] = $aLaCarteDetail['reward_point'];
             $newDb['attributes']['special_request'] = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? $arrData['specialRequest'] : "";
             $newDb['attributes']['experience'] = $aLaCarteDetail['name'] . ' - Ala Carte';
             $newDb['attributes']['api_added'] = "Mobile";
             $newDb['attributes']['giu_membership_id'] = $userDetail['data']['membership_number'];
             $newDb['attributes']['outlet'] = $aLaCarteDetail['location'];
             $newDb['attributes']['auto_reservation'] = "Not available";
             $newDb['attributes']['ar_confirmation_id'] = "0";
             $newDb['attributes']['alternate_id'] = 'A' . sprintf("%06d", $reservation_id['id']);
             $newDb['attributes']['reservation_status_id'] = 1;
             $newDb['userdetails']['user_id'] = $userID;
             $newDb['userdetails']['status'] = 1;
             //print_r($newDb);die;
             $reservDetails = new ReservationModel();
             $newDbStatus = $reservDetails->updateAttributes($reservation_id['id'], $newDb);
             //print_r($newDbStatus);die;
             /*TODO: Add the status of success check and include added_by and transaction_id attributes */
             //echo "alacarte success";die;
             //Mail by mailchimp
             $mailStatus = self::mailByMailChimp($arrData, $userID, $objMailChimp, $city_name);
             $zoho_data = array('Name' => $arrData['guestName'], 'Email_ids' => $arrData['guestEmail'], 'Contact' => $arrData['phone'], 'Experience_Title' => $aLaCarteDetail['name'] . ' - Ala Carte', 'No_of_People' => $arrData['partySize'], 'Date_of_Visit' => date('d-M-Y', strtotime($arrData['reservationDate'])), 'Time' => date("g:ia", strtotime($arrData['reservationTime'])), 'Alternate_ID' => 'A' . sprintf("%06d", $reservation_id['id']), 'Special_Request' => isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? $arrData['specialRequest'] : "", 'Type' => "Alacarte", 'API_added' => 'Mobile', 'GIU_Membership_ID' => $userDetail['data']['membership_number'], 'Outlet' => $aLaCarteDetail['location'], 'AR_Confirmation_ID' => '0', 'Auto_Reservation' => 'Not available', 'Special_offer_title' => $offersResult['special_offer_title'], 'Special_offer_desc' => $offersResult['special_offer_desc'], 'Calling_option' => 'No');
             //Calling zoho api method
             $zoho_res = Self::zohoAddBooking($zoho_data);
             //Call zoho send mail method
             Self::zohoSendMail($zoho_res, $zoho_data, $reservation_id['id'], $arrData);
         } else {
             if ($arrData['reservationType'] == 'experience') {
                 $arrResponse['status'] = Config::get('constants.API_SUCCESS');
                 if (array_key_exists('addon', $arrData) && !empty($arrData['addon'])) {
                     //self::addReservationAddonDetails($reservation->id, $arrData['addon']);
                     //Reading value for addon
                     $count = $arrData['addon'];
                     if ($count == "") {
                         $arrData['addon'] = array();
                     }
                     // echo "<pre>"; print_r($dataPost);
                     $addonsText = '';
                     foreach ($arrData['addon'] as $key => $value) {
                         if ($value['qty'] > 0) {
                             //echo "prod id = ".$prod_id." , qty = ".$qty;
                             $prod_id = $value['prod_id'];
                             $addonsDetails = DB::select("SELECT attribute_value from product_attributes_text where product_id = {$prod_id} and product_attribute_id = 17");
                             //echo "<pre>"; print_r($addonsDetails);
                             $addonsText .= $addonsDetails[0]->attribute_value . " (" . $value['qty'] . ") , ";
                         }
                     }
                     /*
                     			        foreach($arrData['addon'] as $prod_id => $qty) {
                     			            if($qty > 0){
                     			                //echo "prod id = ".$prod_id." , qty = ".$qty;
                     			                $addonsDetails = DB::select("SELECT attribute_value from product_attributes_text where product_id = $prod_id and product_attribute_id = 17");
                     
                     			                //echo "<pre>"; print_r($addonsDetails);
                     			                $addonsText .= $addonsDetails[0]->attribute_value." (".$qty.") , ";
                     			            }
                     
                     }
                     */
                     $finalAddontext = isset($addonsText) && $addonsText != "" ? "Addons: " . $addonsText : " ";
                     $special_request = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? "Spl Req: " . $arrData['specialRequest'] : "";
                     $arrData['addons_special_request'] = $finalAddontext . " " . $special_request;
                     //---------------------------------------------------------------------------
                 } else {
                     $finalAddontext = " ";
                     $special_request = isset($arrData['specialRequest']) && !empty($arrData['specialRequest']) ? "Spl Req: " . $arrData['specialRequest'] : "";
                     $arrData['addons_special_request'] = $finalAddontext . " " . $special_request;
                 }
                 $arrResponse['data']['reservation_id'] = $reservation_id['id'];
                 $arrResponse['data']['name'] = $productDetail['name'];
                 $arrResponse['data']['url'] = URL::to('/') . '/experience/' . $productDetail['id'];
                 $arrResponse['data']['reservationDate'] = $arrData['reservationDate'];
                 $arrResponse['data']['reservationTime'] = $arrData['reservationTime'];
                 $arrResponse['data']['partySize'] = $arrData['partySize'];
                 $arrResponse['data']['reward_point'] = $productDetail['reward_point'];
                 //Increment the Reservation count by 1
                 $reservationCount = self::incrementReservationCount($userID, $arrData['reservationType']);
                 //Insert reward point in user table
                 DB::table('users')->where('id', $userID)->increment('points_earned', $productDetail['reward_point']);
                 //Insert record for new reward point
                 $storeRewardPoint = self::storeRewardPoint($userID, $productDetail['reward_point'], $reservation_id['id']);
                 $arrData['giftCardID'] = isset($arrData['giftCardID']) && !empty($arrData['giftCardID']) ? $arrData['giftCardID'] : "";
                 //for the new db structure support
                 $combined_date_and_time = $arrData['reservationDate'] . ' ' . $arrData['reservationTime'];
                 $newDb['attributes']['reserv_datetime'] = Carbon::createFromFormat('Y-m-d H:i A', $combined_date_and_time)->toDateTimeString();
                 $newDb['attributes']['no_of_people_booked'] = $arrData['partySize'];
                 $newDb['attributes']['cust_name'] = $arrData['guestName'];
                 $newDb['attributes']['email'] = $arrData['guestEmail'];
                 $newDb['attributes']['contact_no'] = $arrData['phone'];
                 $newDb['attributes']['reserv_type'] = "Experience";
                 $newDb['attributes']['gift_card_id_reserv'] = $arrData['giftCardID'];
                 $newDb['attributes']['loyalty_points_awarded'] = $productDetail['reward_point'];
                 $newDb['attributes']['special_request'] = $arrData['addons_special_request'];
                 $newDb['attributes']['experience'] = $productDetail['vendor_name'] . ' - ' . $productDetail['descriptive_title'];
                 $newDb['attributes']['api_added'] = "Mobile";
                 $newDb['attributes']['giu_membership_id'] = $userDetail['data']['membership_number'];
                 $newDb['attributes']['outlet'] = $productDetail['location'];
                 $newDb['attributes']['auto_reservation'] = "Not available";
                 $newDb['attributes']['ar_confirmation_id'] = "0";
                 $newDb['attributes']['alternate_id'] = 'E' . sprintf("%06d", $reservation_id['id']);
                 $newDb['attributes']['reservation_status_id'] = 1;
                 $newDb['userdetails']['user_id'] = $userID;
                 $newDb['userdetails']['status'] = 1;
                 $newDb['userdetails']['addons'] = isset($arrData['addon']) ? $arrData['addon'] : "";
                 $newDb['userdetails']['mobile'] = 1;
                 //print_r($newDb);die;
                 $reservDetails = new ReservationModel();
                 $newDbStatus = $reservDetails->updateAttributes($reservation_id['id'], $newDb);
                 //print_r($newDbStatus);die;
                 /*TODO: Add the status of success check and include added_by and transaction_id attributes */
                 //echo "experience success";die;
                 //Mail by mailchimp
                 $mailStatus = self::mailByMailChimp($arrData, $userID, $objMailChimp, $city_name);
                 $zoho_data = array('Name' => $arrData['guestName'], 'Email_ids' => $arrData['guestEmail'], 'Contact' => $arrData['phone'], 'Experience_Title' => $productDetail['vendor_name'] . ' - ' . $productDetail['descriptive_title'], 'No_of_People' => $arrData['partySize'], 'Date_of_Visit' => date('d-M-Y', strtotime($arrData['reservationDate'])), 'Time' => date("g:ia", strtotime($arrData['reservationTime'])), 'Alternate_ID' => 'E' . sprintf("%06d", $reservation_id['id']), 'Special_Request' => $arrData['addons_special_request'], 'Type' => "Experience", 'API_added' => 'Mobile', 'GIU_Membership_ID' => $userDetail['data']['membership_number'], 'Outlet' => $productDetail['location'], 'AR_Confirmation_ID' => '0', 'Auto_Reservation' => 'Not available', 'Calling_option' => 'No', 'gift_card_id_from_reservation' => $arrData['giftCardID']);
                 //Calling zoho api method
                 $zoho_res = Self::zohoAddBooking($zoho_data);
                 //Call zoho send mail method
                 Self::zohoSendMail($zoho_res, $zoho_data, $reservation_id['id'], $arrData);
                 //code for generating the payu hash
                 if (self::isPaidExperience($arrResult->product_id)) {
                     //its a paid product so generating the hash
                     if (!array_key_exists('total_amount', $arrData)) {
                         $arrData['total_amount'] = 0;
                     }
                     $arrPayUData = array('guestName' => $arrData['guestName'], 'reservationID' => $reservation->id, 'amount' => $arrData['total_amount'], 'shortDescription' => $productDetail['descriptive_title'], 'email' => $arrData['guestEmail'], 'userCredentials' => $arrData['userCredentials']);
                     $arrHash = Payment::getPayUHash($arrPayUData);
                     //setting up the hash value
                     $arrResponse['data']['hash'] = array('paymentHash' => $arrHash['paymentHash'], 'paymentRelatedDetailsForMobileSDKHash' => array_key_exists('paymentRelatedDetailsForMobileSDKHash', $arrHash) ? $arrHash['paymentRelatedDetailsForMobileSDKHash'] : '', 'getUserCardsHash' => array_key_exists('getUserCardsHash', $arrHash) ? $arrHash['getUserCardsHash'] : '', 'saveUserCardHash' => array_key_exists('saveUserCardHash', $arrHash) ? $arrHash['saveUserCardHash'] : '');
                 }
             } else {
                 $arrResponse['status'] = Config::get('constants.API_ERROR');
             }
         }
         return $arrResponse;
     }
     return FALSE;
 }
Ejemplo n.º 3
0
 /**
  * Validates the data entered for the edit reservation.
  * 
  * @access	public
  * @param	array 	$arrData
  * @return	array
  * @since	v1.0.0
  */
 public static function validateEditReservationData($arrData)
 {
     //array to store response
     $arrResponse = array();
     if ($arrData['reservationType'] == 'alacarte') {
         //validating that user has not selected blocked date
         $returnResult = VendorLocationBlockedSchedules::isDateBlocked($arrData['vendorLocationID'], $arrData['reservationDate']);
         if ($returnResult) {
             $arrResponse['status'] = Config::get('constants.API_ERROR');
             $arrResponse['msg'] = 'You cannot make any reservation on the selected date.';
             return $arrResponse;
         }
         //reading details of the existing reservation from tables
         $arrCurrentReservation = ReservationDetails::getActiveReservationDetail($arrData['reservationID']);
         //checking the availability for the booking
         $arrTimeRangeLimits = VendorLocationBookingTimeRangeLimit::checkBookingTimeRangeLimits($arrData);
         $existingReservationCount = ReservationDetails::getReservationCount($arrData);
         if ($arrData['vendorLocationID'] == $arrCurrentReservation['vendorLocationID']) {
             //removing the existing number with max number
             $existingReservationCount = $existingReservationCount - $arrCurrentReservation['numOfPersons'];
         }
         //converting the reservation time
         $reservationTime = strtotime($arrData['reservationTime']);
         if (!empty($arrTimeRangeLimits)) {
             foreach ($arrTimeRangeLimits as $key => $value) {
                 $maxCount = $value['max_covers_limit'] == 0 ? $value['max_tables_limit'] : $value['max_covers_limit'];
                 if ($maxCount == $existingReservationCount) {
                     $arrResponse['status'] = Config::get('constants.API_ERROR');
                     $arrResponse['msg'] = 'Sorry. Currently the place is full. Please try another day.';
                     return $arrResponse;
                 } else {
                     if ($maxCount > $existingReservationCount) {
                         if ($maxCount - ($existingReservationCount + $arrData['partySize']) < 0) {
                             $arrResponse['status'] = Config::get('constants.API_ERROR');
                             $arrResponse['msg'] = "Sorry. We have only " . $maxCount - $arrReservationCount . ' seats available.';
                             return $arrResponse;
                         }
                     }
                 }
             }
         }
         $arrResponse['status'] = Config::get('constants.API_SUCCESS');
         return $arrResponse;
     } else {
         if ($arrData['reservationType'] == 'experience') {
             //validating that user has not selected blocked date
             $returnResult = ProductVendorLocationBlockedSchedule::isDateBlocked($arrData['vendorLocationID'], $arrData['reservationDate']);
             if ($returnResult) {
                 $arrResponse['status'] = Config::get('constants.API_ERROR');
                 $arrResponse['msg'] = 'You cannot make any reservation on the selected date.';
                 return $arrResponse;
             }
             //reading details of the existing reservation from tables
             $arrCurrentReservation = ReservationDetails::getActiveReservationDetail($arrData['reservationID']);
             //checking the availability for the booking
             $arrTimeRangeLimits = ProductVendorLocationBookingTimeRangeLimit::checkBookingTimeRangeLimits($arrData);
             $existingReservationCount = ReservationDetails::getReservationCount($arrData);
             if ($arrData['vendorLocationID'] == $arrCurrentReservation['vendorLocationID']) {
                 //removing the existing number with max number
                 $existingReservationCount = $existingReservationCount - $arrCurrentReservation['numOfPersons'];
             }
             //converting the reservation time
             $reservationTime = strtotime($arrData['reservationTime']);
             if (!empty($arrTimeRangeLimits)) {
                 foreach ($arrTimeRangeLimits as $key => $value) {
                     $maxCount = $value['max_covers_limit'] == 0 ? $value['max_tables_limit'] : $value['max_covers_limit'];
                     $startTime = strtotime($value['start_time']);
                     $endTime = strtotime($value['end_time']);
                     if ($startTime <= $reservationTime && $endTime >= $reservationTime) {
                         if ($maxCount == $existingReservationCount) {
                             $arrResponse['status'] = Config::get('constants.API_ERROR');
                             $arrResponse['msg'] = 'Sorry. Currently the place is full. Please try another day.';
                             return $arrResponse;
                         } else {
                             if ($maxCount > $existingReservationCount) {
                                 if ($maxCount - ($existingReservationCount + $arrData['partySize']) < 0) {
                                     $arrResponse['status'] = Config::get('constants.API_ERROR');
                                     $arrResponse['msg'] = "Sorry. We have only " . abs($maxCount - $existingReservationCount) . ' seats available.';
                                     return $arrResponse;
                                 }
                             }
                         }
                     }
                 }
             }
             $arrResponse['status'] = Config::get('constants.API_SUCCESS');
             return $arrResponse;
         }
     }
     return -1;
 }
Ejemplo n.º 4
0
 /**
  * Handle requests for payment failure response by PayU.	  
  * 
  * @access  public
  * @return  response
  * @since   1.0.0
  */
 public function getFailureResponse()
 {
     //reading data input by the user
     $data = $this->request->all();
     //Setting token value if user has not sent the token in request
     if (!isset($data['access_token'])) {
         $data['access_token'] = $_SERVER['HTTP_X_WOW_TOKEN'];
     }
     $userID = UserDevices::getUserDetailsByAccessToken($data['access_token']);
     $reservationID = $this->request->input('reservationID');
     $arrResponse = ReservationDetails::cancelReservation($reservationID, $this->mailchimp, $userID);
     return response()->json($data, 200);
 }
Ejemplo n.º 5
0
 /**
  * Handles requests for updating an existing reservation.
  * 
  * @access	public
  * @return	response
  * @since	1.0.0
  */
 public function changeReservation()
 {
     //array to store response
     $arrResponse = array();
     //reading data input by the user
     $data = $this->request->all();
     /*
     		//reading the reservation rules
     		$arrRule = Reservation::$arrRules;
     		
     		//updating the validation rule for reservation time
     		$arrRule['reservationTime'] = 'required|OutsidePrevReservationTimeRange: reservationDate, reservationID'; 
     */
     //print_r($data); die();
     //validating user data
     $validator = Validator::make($data, Reservation::$arrRules);
     //print_r($validator->fails());die;
     if ($validator->fails()) {
         $message = $validator->messages();
         $errorMessage = "";
         foreach ($data as $key => $value) {
             if ($message->has($key)) {
                 $errorMessage .= $message->first($key) . '\\n ';
             }
         }
         $arrResponse['status'] = Config::get('constants.API_ERROR');
         $arrResponse['error'] = $errorMessage;
     } else {
         //validating the user input data
         $arrResponse = Reservation::validateEditReservationData($data);
         //die('hello');
         if ($arrResponse['status'] == Config::get('constants.API_SUCCESS')) {
             $arrResponse = ReservationDetails::updateReservationDetail($data);
         }
     }
     if (!empty($data['reservationID'])) {
         $tokens = ReservationModel::pushToRestaurant($data['reservationID']);
         $this->restaurantapp->push($data['reservationID'], $tokens, true);
     }
     return response()->json($arrResponse, 200);
 }