function bookingAction() { $common = $this->getServiceLocator()->get('Application\\Model\\Common'); $bookingModel = new Bookings(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; // getting all bookings prior to 48 and 24 hours $bookings48hrs = $bookingModel->getBookings($api_url, '', '', 4, '', '', '', '', '', date('Y-m-d', strtotime('+2 days'))); // date('Y-m-d', strtotime('+2 days')) $bookings24hrs = $bookingModel->getBookings($api_url, '', '', 4, '', '', '', '', '', date('Y-m-d', strtotime('+1 days'))); // date('Y-m-d', strtotime('+1 days')) $bookings = array_merge($bookings48hrs['results'], $bookings24hrs['results']); foreach ($bookings as $booking) { if (is_numeric($booking['booking_status']['user_id'])) { $mailPattern = array('/{{user_name}}/i', '/{{user_type}}/i', '/{{service_name}}/i', '/{{date_time}}/i', '/{{name}}/i'); $mailReplace = array($booking['consumer_first_name'] . " " . $booking['consumer_last_name'], 'Practitioner', $booking['category_name'], date('l d/m/Y h:i A', strtotime($booking['booking_status']['booking_time'])), $booking['sp_first_name'] . " " . $booking['sp_last_name']); $common->sendMail($api_url, $booking['consumer_email'], '', 17, '', $mailPattern, $mailReplace); $subscriptionDetails = $common->getSubscriptiondetails($api_url, $booking['service_provider_id'], true); $practitionerFeatures = $common->getFeatures($api_url, $booking['service_provider_id']); $userFeatures = $common->getFeatures($api_url, $booking['user_id']); if (is_numeric($booking['consumer_number']) && isset($userFeatures['sms']) && $userFeatures['sms'] == 1) { $common->sendMsg($booking['consumer_number'], 7, '', $mailPattern, $mailReplace); } $mailReplace = array($booking['consumer_first_name'] . " " . $booking['consumer_last_name'], 'Consumer', $booking['category_name'], date('l d/m/Y h:i A', strtotime($booking['booking_status']['booking_time'])), $booking['sp_first_name'] . " " . $booking['sp_last_name']); $common->sendMail($api_url, $booking['sp_email'], '', 17, '', $mailPattern, $mailReplace); if ((isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(12, $subscriptionDetails['features']) || $practitionerFeatures['sms'] == 1) && is_numeric($booking['sp_number'])) { $common->sendMsg($booking['sp_number'], 7, '', $mailPattern, $mailReplace); } } } $bookings48hrs = $bookingModel->getBookings($api_url, '', '', 5, '', '', '', '', '', date('Y-m-d', strtotime('+2 days'))); $bookings24hrs = $bookingModel->getBookings($api_url, '', '', 5, '', '', '', '', '', date('Y-m-d', strtotime('+1 days'))); $bookings = array_merge($bookings48hrs['results'], $bookings24hrs['results']); foreach ($bookings as $booking) { // Cancel all pending bookings prior 48 hours $bookingModel->changeBookingStatus($api_url, $booking['id'], 6, $common); } die; }
public function settingsAction() { $auth = new FrontEndAuth(); if (!$auth->hasIdentity(4)) { return $this->redirect()->toUrl('/login'); } $session = new Container('frontend'); $api = new Api(); $common = new Common(); $booking_model = new Bookings(); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $featureData = $common->getFeatures($api_url, $session->userid); $result_newsletter = $common->chkNewsletter($api_url); $unsubscribe_reasons = $common->getUnsubscribereason($api_url); $model_practitioner = new Practitioners(); $model_consumer = new Consumers(); $notifications = $model_practitioner->getNotifications($api_url, 'consumer'); $consumer_details = $model_consumer->getConsumerdetails($api_url, $session->userid); if (!$consumer_details) { $this->redirect()->toUrl('/consumer/index'); } $form = new SPChangePasswordForm(); $form->get('submit')->setValue('Add'); $request = $this->getRequest(); if ($this->getRequest()->isXmlHttpRequest()) { $request = $this->getRequest(); $error = false; $request->getPost('action') != '' ? $action = $request->getPost('action') : ($action = ''); if ($action == "change_password") { if (preg_match('/^.*(?=.{6,})(?=.*[0-9])(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z0-9])(?!.*\\s).*$/', $request->getPost('Pass'))) { $request->getPost('old_pass') != '' ? $old_pass = $request->getPost('old_pass') : ($old_pass = ''); $request->getPost('Pass') != '' ? $Pass = $request->getPost('Pass') : ($Pass = ''); $request->getPost('confirm_password') != '' ? $confirm_password = $request->getPost('confirm_password') : ($confirm_password = ''); if ($old_pass != '' && $Pass != '' && $confirm_password != '') { if ($Pass == $confirm_password) { $data = array('op' => 'changepassword', 'old_password' => md5($old_pass), 'new_password' => md5($Pass), 'user_id' => $session->userid); $url = $api_url . "/api/useractivity/"; $res = $api->curl($url, $data, "POST"); if ($res->getStatusCode() == 200) { $msg = "Success!! Password changed sucessfully"; } else { if ($res->getStatusCode() == 404) { $error = true; $msg = "Error!! Old password is not correct"; } else { $error = true; $msg = "Error!! Password could not be updated"; } } } else { // Password and confirm password do not match $error = true; $msg = "Error!! Confirm password do not match"; } } else { $error = true; $msg = "Error!! Invalid form data"; } } else { $error = true; $msg = "Password must be at least 6 characters and must contain at least one lower case letter, one upper case letter, one digit and one special character."; } echo json_encode(array('error' => $error, 'msg' => $msg)); exit; } else { if ($action == "change_features") { $request->getPost('feature_email') != '' ? $feature_email = $request->getPost('feature_email') : ($feature_email = ''); $request->getPost('feature_sms') != '' ? $feature_sms = $request->getPost('feature_sms') : ($feature_sms = ''); $request->getPost('feature_chat') != '' ? $feature_chat = $request->getPost('feature_chat') : ($feature_chat = ''); $request->getPost('feature_table_id') != '' ? $feature_table_id = $request->getPost('feature_table_id') : ($feature_table_id = ''); $data = array('email' => $feature_email, 'sms' => $feature_sms, 'chat' => $feature_chat, 'user_id' => $session->userid); $data['id'] = $featureData['id']; if ($common->addFeature($api_url, $data)) { $msg = "Feature setting updated successfully"; } else { $error = true; $msg = "Feature setting updated successfully"; } echo json_encode(array('error' => $error, 'msg' => $msg)); exit; } else { if ($action == "newletter-chk") { $request->getPost('newletter_chk') != '' ? $newletter_chk = $request->getPost('newletter_chk') : ($newletter_chk = ''); $data = array('user_id' => $session->userid, 'newsletter' => $newletter_chk); if (isset($featureData['id'])) { // update $url = $api_url . '/api/userfeaturesetting/' . $featureData['id'] . '/'; $res = $api->curlUpdate($url, $data, "PUT"); } else { $url = $api_url . '/api/userfeaturesetting/'; $res = $api->curlUpdate($url, $data, "POST"); } if ($res) { $msg = "Feature setting updated successfully"; } else { $error = true; $msg = "Feature setting updated successfully"; } echo json_encode(array('error' => $error, 'msg' => $msg)); exit; } else { if ($action == "close-acc") { $reason_id = $request->getPost('reason_id') != '' ? $request->getPost('reason_id') : ''; $other_reason = $request->getPost('other_reason') != '' ? $request->getPost('other_reason') : ''; if ($reason_id !== '') { if ($reason_id == 5 && $other_reason == '') { $error = true; $msg = "Please provide other reason in the text area"; } else { $result = $common->closeAccount($api_url, $reason_id, $other_reason); if ($result) { // close acc here // remove all related bookings $bookings_data = $booking_model->getBookings($api_url, "", $session->userid, '', '', '', '', '', ''); if (isset($bookings_data['booking_ids']) && !empty($bookings_data['booking_ids'])) { $booking_ids = explode(',', $bookings_data['booking_ids']); $twilloconf = $this->getServiceLocator()->get('config')['Twilio']; if (count($booking_ids) > 0) { foreach ($booking_ids as $ids) { if (isset($ids['id']) && !empty($ids['id'])) { $booking_result = $booking_model->changeBookingStatus($api_url, $ids['id'], "6", $twilloconf); } } } } $msg = "You account has been deactivated successfully..you will be logged out in 5 seconds"; } else { // error acc could not be closed $error = true; $msg = "Some Error occured , Could not close your account , please try after some time"; } } } else { $error = true; $msg = "Please provide us a reason to close your account"; } echo json_encode(array('error' => $error, 'msg' => $msg)); exit; } else { $error = true; $msg = "Invalid request"; echo json_encode(array('error' => $error, 'msg' => $msg)); exit; } } } } } $consumer_details = $model_consumer->getConsumerdetails($api_url, $session->userid); $data = $this->getConsumerData($consumer_details); // getting banner for this page $banners = $common->getBanner($api_url, 5); return new ViewModel(array('consumer' => $data, 'form' => $form, 'featureData' => $featureData, 'notifications' => $notifications, 'avtar_url' => $consumer_details['avtar_url'], 'first_name' => $consumer_details['first_name'], 'last_name' => $consumer_details['last_name'], 'newsletter_chk' => $result_newsletter, 'reasonsList' => $unsubscribe_reasons, 'banners' => $banners)); }
public function mannualbookingAction() { $request = $this->getRequest(); if ($request->isPost()) { $bookingModel = new Bookings(); $session = new Container('frontend'); parse_str($request->getPost('bookingData'), $bookingData); $name = explode(' ', $bookingData['username']); $bookingData['first_name'] = $name[0]; $bookingData['last_name'] = isset($name[1]) ? $name[1] : ''; $bookingData['booked_date'] = date('Y-m-d H:i:s', strtotime(str_replace('/', '-', $bookingData['booking_time']))); //echo '<pre>'; print_r($bookingData); exit; $bookingData['payment_status'] = 7; $bookingData['user_id'] = ''; $bookingData['service_provider_id'] = $session->userid; $bookingData['status_id'] = 1; $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; if ($bookingData['booking_id'] != '') { if ($bookingModel->changeBookingStatus($api_url, $bookingData['booking_id'], $bookingData['booking_status'], $this->getServiceLocator()->get('Application\\Model\\Common'))) { echo json_encode(array('status' => 1, 'msg' => 'Status updated successfully', 'data' => $bookingData['booking_id'])); } else { echo json_encode(array('status' => 0, 'msg' => 'Failed to update status', 'data' => $bookingData['booking_id'])); } } else { unset($bookingData['booking_id']); echo json_encode($bookingModel->addManualBooking($api_url, $bookingData)); } } exit; }