public function myReservationDetails()
    {
        $userID = Input::get('user_id');
        if (isset($userID) && $userID != "" && $userID > 0) {
            $arrReservation = ReservationModel::getReservationRecord($userID);
            $arrUpcomingReservations = '';
            foreach ($arrReservation['data']['upcomingReservation'] as $data) {
                $arrUpcomingReservations .= '<div class="panel panel-default">
                                                    <div class="panel-heading">
                                                        <div class="row">
                                                            <span class="lead col-md-8">';
                if ($data['type'] == 'experience' || $data['type'] == 'event') {
                    $arrUpcomingReservations .= $data['vendor_name'] . ': ' . $data['name'];
                } else {
                    $arrUpcomingReservations .= $data['vendor_name'] . ': ' . 'Classic Reservation';
                }
                $arrUpcomingReservations .= '</span>
                                                                <ul class="col-md-4 list-inline text-right">';
                if ($data['type'] == 'experience' || $data['type'] == 'event') {
                    $arrUpcomingReservations .= '<li>
                                                                                                        <a href="' . $data['type'] . ',' . $data['vl_id'] . ',' . $data['product_id'] . ',' . $data['city_id'] . '" class="btn btn-defaulbt tn-sm" data-toggle="modal" data-keyboard="false" data-backdrop="static" data-target="#editModal" id="change_reservation">Change</a>
                                                                                                     </li>';
                } else {
                    if ($data['type'] == "alacarte") {
                        $arrUpcomingReservations .= '<li>
                                                                                                            <a href="' . $data['type'] . ',' . $data['vendor_location_id'] . ',' . $data['vendor_location_id'] . '" class="btn btn-defaulbt tn-sm" data-toggle="modal" data-keyboard="false" data-backdrop="static" data-target="#editModal" id="change_reservation">Change</a>
                                                                                                        </li>';
                    }
                }
                $arrUpcomingReservations .= '<li>';
                if ($data['type'] == "experience") {
                    $change_id = "cancel_reservation";
                } else {
                    if ($data['type'] == "alacarte") {
                        $change_id = "ac_cancel_reservation";
                    } else {
                        if ($data['type'] == "event") {
                            $change_id = "event_reservation";
                        }
                    }
                }
                $arrUpcomingReservations .= '<a href="javascript:" class="btn btn-default btn-sm" data-toggle="modal" data-keyboard="false" data-backdrop="static" data-target="#cancelModal" id="' . $change_id . '" data-reserve-type="' . $data['type'] . '">Cancel</a>';
                $arrUpcomingReservations .= '</li>
                                                                                <input type="hidden" value="' . $data['id'] . '">
                                                                                <input type="hidden" value="' . $data['type'] . '" class="reserv_typee">
                                                                </ul>
                                                            </div>
                                                        </div>
                                                        <div class="panel-body">';
                if ($data['type'] == 'experience') {
                    $arrUpcomingReservations .= '<p class="res-desc"><strong>Description: ' . $data['short_description'] . '</strong></p>';
                }
                $arrUpcomingReservations .= '<div class="row">
                                                                <div class="col-md-4 col-sm-4 res-details">
                                                                    <ul>
                                                                        <li>
                                                                            <p class="text-warning"><em>Date</em></p>
                                                                            <p><strong>' . $data['dayname'] . ', ' . date('F j Y', strtotime($data['date'])) . '</strong></p>
                                                                        </li>
                                                                        <li>
                                                                            <p class="text-warning"><em>Time</em></p>
                                                                            <p><strong>' . date('h:i A', strtotime($data['time'])) . '</strong></p>
                                                                        </li>
                                                                        <li>
                                                                            <p class="text-warning"><em>Number of guests</em></p>
                                                                            <p><strong>' . $data['no_of_persons'] . '</strong></p>
                                                                        </li>
                                                                        <li>
                                                                            <p class="text-warning"><em>Reservation ID</em></p>
                                                                            <p><strong>EU-' . $data['id'] . '</strong></p>
                                                                        </li>';
                if ($data['type'] == 'experience') {
                    $arrUpcomingReservations .= '<li>
                                                                                <p class="text-warning"><em>Experience</em></p>
                                                                                <p><strong><a href="' . URL::to('/') . '/' . $data['city'] . '/experiences/' . $data['product_slug'] . '" target="_blank">View Details</a></strong></p>
                                                                            </li>';
                }
                $arrUpcomingReservations .= '</ul>
                                                                </div>
                                                                <div class="col-md-8 col-sm-8 res-location">
                                                                    <ul>
                                                                        <li>
                                                                            <p class="text-warning"><em>Outlet</em></p>
                                                                            <p><strong>' . $data['locality'] . '</strong></p>
                                                                        </li>
                                                                        <li>
                                                                            <p class="text-warning"><em>Address</em></p>
                                                                            <address>
                                                                                <strong>' . $data['name'] . '</strong><br>
                                                                                ' . $data['address'] . '<br>

                                                                            </address>
                                                                        </li>
                                                                    </ul>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>';
            }
            $arrPastReservations = '';
            foreach ($arrReservation['data']['pastReservation'] as $data) {
                $arrPastReservations .= '<div class="panel panel-default">
                                            <div class="panel-heading">
                                                <div class="row">
                                                    <span class="lead col-md-8">';
                if ($data['type'] == 'experience') {
                    $arrPastReservations .= $data['vendor_name'] . ' : ' . $data['name'];
                } else {
                    $arrPastReservations .= $data['name'] . ' : ' . 'Classic Reservation';
                }
                $arrPastReservations .= '</span>
                                                </div>
                                            </div>
                                            <div class="panel-body">';
                if ($data['type'] == 'experience') {
                    $arrPastReservations .= '<p class="res-desc"><strong>Description: ' . $data['short_description'] . '</strong></p>';
                }
                $arrPastReservations .= '<div class="row">
                                                    <div class="col-md-4 col-sm-4 res-details">
                                                        <ul>
                                                            <li>
                                                                <p class="text-warning"><em>Date</em></p>
                                                                <p><strong>' . $data['dayname'] . ', ' . date('F j Y', strtotime($data['date'])) . '</strong></p>
                                                            </li>
                                                            <li>
                                                                <p class="text-warning"><em>Time</em></p>
                                                                <p><strong>' . date('h:i A', strtotime($data['time'])) . '</strong></p>
                                                            </li>
                                                            <li>
                                                                <p class="text-warning"><em>Number of guests</em></p>
                                                                <p><strong>' . $data['no_of_persons'] . '</strong></p>
                                                            </li>
                                                            <li>
                                                                <p class="text-warning"><em>Reservation ID</em></p>
                                                                <p><strong>EU-' . $data['id'] . '</strong></p>
                                                            </li>';
                if ($data['type'] == 'experience') {
                    $arrPastReservations .= '<li>
                                                                    <p class="text-warning"><em>Experience</em></p>
                                                                    <p><strong><a href="' . URL::to('/') . '/' . $data['city'] . '/experiences/' . $data['product_slug'] . '" target="_blank">View Details</a></strong></p>
                                                                  </li>';
                }
                $arrPastReservations .= '</ul>
                                                    </div>
                                                    <div class="col-md-8 col-sm-8 res-location">
                                                        <ul>
                                                            <li>
                                                                <p class="text-warning"><em>Outlet</em></p>
                                                                <p><strong>' . $data['locality'] . '</strong></p>
                                                            </li>
                                                            <li>
                                                                <p class="text-warning"><em>Address</em></p>
                                                                <address>
                                                                    <strong>' . $data['name'] . '</strong><br>
                                                                    ' . $data['address'] . '<br>

                                                                </address>
                                                            </li>

                                                        </ul>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>';
            }
            $newData['upcomings'] = $arrUpcomingReservations;
            $newData['previous'] = $arrPastReservations;
            echo json_encode($newData);
        }
    }
 /**
  * Handles requests for cancelling a reservation.
  * 
  * @access	public
  * @return	response
  * @since	1.0.0
  */
 public function reservationCancel()
 {
     //echo "<pre>"; print_r(Input::all()); die;
     $reservationID = $this->request->input('reserv_id');
     $reservationType = $this->request->input('reserv_type');
     $user_id = $this->request->input('user_id');
     $added_by = $this->request->input('added_by');
     //echo "reservationID == ".$reservationID." , reservationType == ".$reservationType; die;
     $arrResponse = ReservationModel::cancelReservation($reservationID, $reservationType);
     $userID = $user_id;
     $userData = Profile::getUserProfileWeb($userID);
     //print_r($userData);die;
     //for the new db structure support
     $newDb['attributes']['reservation_status_id'] = 3;
     $newDb['userdetails']['user_id'] = $userID;
     $newDb['userdetails']['status'] = 3;
     $newDb['attributes']['seating_status'] = 3;
     $newDb['attributes']['closed_on'] = Carbon::now()->toDateTimeString();
     //print_r($newDb);die;
     $reservDetails = new ReservDetailsModel();
     $newDbStatus = $reservDetails->updateAttributes($reservationID, $newDb);
     $tokens = $reservDetails->pushToRestaurant($reservationID);
     $this->restaurantapp->push($reservationID, $tokens, true);
     //print_r($newDbStatus);die;
     /*TODO: Add the status of success check and include added_by and transaction_id attributes */
     //die;
     $rewardsPoints = '';
     $type = '';
     $bookingsMade = '';
     $lastOrderId = '';
     $arrReservationDetails = DB::table('reservation_details')->where('id', $reservationID)->select('reservation_date', 'reservation_time', 'no_of_persons', 'product_vendor_location_id', 'vendor_location_id')->get();
     //echo "<pre>"; print_r($arrReservationDetails); //die;
     if ($arrResponse['status'] == 'ok') {
         if ($reservationType == "experience") {
             $zoho_data = array('Loyalty_Points_Awarded' => 0, 'Order_completed' => isset($added_by) && $added_by == 'user' ? 'User Cancelled' : 'Admin Cancelled');
             $res_data = $this->zoho_edit_booking('E' . sprintf("%06d", $reservationID), $zoho_data);
             $setBookingKey = 'MERGE11';
             $setBookingsValue = $userData['data']['bookings_made'];
             $arrProductID = DB::table('product_vendor_locations')->where('id', $arrReservationDetails[0]->product_vendor_location_id)->select('product_id', 'vendor_location_id')->get();
             $productDetails = $this->experiencesRepository->getByExperienceId($arrProductID[0]->product_id);
             $outlet = $this->experiences_model->getOutlet($arrReservationDetails[0]->product_vendor_location_id);
             //$locationDetails = $this->experiences_model->getLocationDetails($arrReservationDetails[0]->product_vendor_location_id);
             //echo "<br/>---- productdetails---<pre>"; print_r($productDetails);
             //echo "<br/>---- outlet---<pre>"; print_r($outlet);
             $rewardsPoints = $productDetails['attributes']['reward_points_per_reservation'];
             $bookingsMade = $userData['data']['bookings_made'] - 1;
             $type = "cancel";
             $reservationType = "experience";
             $lastOrderId = $reservationID;
             $dataPost = array('reservation_type' => $reservationType, 'reservationID' => $reservationID, 'partySize' => $arrReservationDetails[0]->no_of_persons, 'reservationDate' => $arrReservationDetails[0]->reservation_date, 'reservationTime' => $arrReservationDetails[0]->reservation_time, 'guestName' => $userData['data']['full_name'], 'guestEmail' => $userData['data']['email'], 'guestPhoneNo' => $userData['data']['phone_number'], 'order_id' => "#E" . sprintf("%06d", $reservationID), 'venue' => $outlet->vendor_name);
         } else {
             if ($reservationType == "alacarte") {
                 $setBookingKey = 'MERGE26';
                 $setBookingsValue = $userData['data']['a_la_carte_reservation'];
                 $zoho_data = array('Loyalty_Points_Awarded' => 0, 'Order_completed' => isset($added_by) && $added_by == 'user' ? 'User Cancelled' : 'Admin Cancelled');
                 $res_data = $this->zoho_edit_booking('A' . sprintf("%06d", $reservationID), $zoho_data);
                 $outlet = $this->alacarte_model->getOutlet($arrReservationDetails[0]->vendor_location_id);
                 $locationDetails = $this->alacarte_model->getLocationDetails($arrReservationDetails[0]->vendor_location_id);
                 $vendorDetails = $this->restaurantLocationsRepository->getByRestaurantLocationId($arrReservationDetails[0]->vendor_location_id);
                 //echo "<br/>---- vendorDetails---<pre>"; print_r($vendorDetails);
                 //echo "<br/>---- outlet---<pre>"; print_r($outlet);
                 $rewardsPoints = $vendorDetails['attributes']['reward_points_per_reservation'];
                 $bookingsMade = $userData['data']['a_la_carte_reservation'] - 1;
                 $type = "cancel";
                 $reservationType = "alacarte";
                 $lastOrderId = $reservationID;
                 $dataPost = array('reservation_type' => $reservationType, 'reservationID' => $reservationID, 'partySize' => $arrReservationDetails[0]->no_of_persons, 'reservationDate' => $arrReservationDetails[0]->reservation_date, 'reservationTime' => $arrReservationDetails[0]->reservation_time, 'guestName' => $userData['data']['full_name'], 'guestEmail' => $userData['data']['email'], 'guestPhoneNo' => $userData['data']['phone_number'], 'order_id' => "#A" . sprintf("%06d", $reservationID), 'venue' => $outlet->vendor_name);
             }
         }
         if (!empty($userData)) {
             $merge_vars = array($setBookingKey => $setBookingsValue - 1, 'GROUPINGS' => array(array('id' => 9713, 'groups' => [$userData['data']['location']])));
             //$email = ["email"["email":]];
             $this->mailchimp->lists->subscribe($this->listId, ["email" => $userData['data']['email']], $merge_vars, "html", true, true);
             //$this->mc_api->listSubscribe($list_id, $_POST['email'], $merge_vars,"html",true,true );
         }
         Profile::updateReservationInUsers($rewardsPoints, $type, $bookingsMade, $reservationType, $userID, $lastOrderId);
         Mail::send('site.pages.cancel_reservation', ['post_data' => $dataPost], function ($message) use($dataPost) {
             $message->from('*****@*****.**', 'WowTables by GourmetItUp');
             $message->to($dataPost['guestEmail'])->subject('Your WowTables Reservation at ' . $dataPost['venue'] . ' has been cancelled');
             //$message->cc('*****@*****.**', '*****@*****.**');
         });
         Mail::send('site.pages.cancel_reservation', ['post_data' => $dataPost], function ($message) use($dataPost) {
             $message->from('*****@*****.**', 'WowTables by GourmetItUp');
             $message->to('*****@*****.**')->subject('CR - ' . $dataPost['order_id'] . ' | ' . date('d-F-Y', strtotime($dataPost['reservationDate'])) . ' , ' . date('g:i a', strtotime($dataPost['reservationTime'])) . ' | ' . $dataPost['venue'] . ' | ' . $dataPost['guestName']);
             $message->cc('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**');
         });
         echo '1';
     }
 }