public function viewmessageAction()
 {
     $auth = new FrontEndAuth();
     $id = $this->params()->fromRoute('id');
     if ($id == '') {
         die('redirect to practitioner inbox');
     }
     if (!$auth->hasIdentity(3)) {
         return $this->redirect()->toUrl('/login');
     }
     $session = new Container('frontend');
     $model = new Practitioners();
     $common = new Common();
     $api = new Api();
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $subscriptionDetails = $common->getSubscriptiondetails($api_url, '', true);
     if (!isset($subscriptionDetails['features']) || !is_array($subscriptionDetails['features']) || !in_array(5, $subscriptionDetails['features'])) {
         $this->flashMessenger()->addErrorMessage("Either you have not subscribed any subscription or your subscription don't have permission to access this section..!!");
         return $this->redirect()->toRoute('practitioner', array('action' => 'dashboard'));
     }
     $url_master = $api_url . "/api/messages/" . $id . "/";
     $res_master = $api->curl($url_master, array(''), "GET");
     if ($res_master->getStatusCode() == 200) {
         $result_master = json_decode($res_master->getBody(), true);
         if ($result_master['readFlag_p'] == 0) {
             $res_master = $api->curl($url_master, array('readFlag_p' => 1), "PUT");
         }
     } else {
         $result_master = array();
     }
     if (isset($result_master['topLevel_id'])) {
         $result_replies = $this->fetchallreplies($api_url, $result_master);
     } else {
         $result_replies = array();
     }
     $model_consumer = new Consumers();
     $model_common = $this->getServiceLocator()->get('Application/Model/Common');
     $notifications = $model->getNotifications($api_url);
     $sp_details = $model->getSPDetails($api_url, $session->userid);
     $request = $this->getRequest();
     if ($request->isPost()) {
         $reply_id = $request->getPost('replyId');
         $data = array('');
         $data['subject'] = $request->getPost("subject{$reply_id}");
         $data['message'] = $request->getPost("ReplyMessage{$reply_id}");
         $data['to_user_id'] = $request->getPost("toUserID{$reply_id}");
         $data['from_user_id'] = $session->userid;
         $data['replyId'] = $reply_id;
         $data['topLevel_id'] = $request->getPost("topLevel_id{$reply_id}");
         $data['from_name'] = $session->user_name;
         $data['readFlag'] = '0';
         $data['deleteFlag'] = '0';
         $data['created_date'] = date('Y-m-d H:i:s');
         if ($data['message'] != '') {
             // saving message in database;
             $url = $api_url . "/api/messages/";
             $res = $api->curl($url, $data, "POST");
             if ($res->getStatusCode() == 201) {
                 $replyMessage = "Reply Submitted Successfully";
                 //$consumer_data = $model_consumer->getConsumerdetails($api_url, $id);
                 $consumer_data = $model_consumer->getConsumerdetails($api_url, $data['to_user_id']);
                 if ($consumer_data) {
                     $subscriptionDetails = $model_common->getSubscriptiondetails($api_url, $session->userid, true);
                     $userFeatures = $model_common->getFeatures($api_url, $consumer_data['id']);
                     if (count($consumer_data['contact']) > 0) {
                         $contact_data = json_decode($consumer_data['contact'][0], true);
                     }
                     $pattern = array('/{{reciever}}/i', '/{{sender}}/i');
                     $replace = array('<strong>' . $consumer_data['first_name'] . ' ' . $consumer_data['last_name'] . '</strong>', '<strong>' . $session->first_name . ' ' . $session->last_name . '</strong>');
                     if (isset($consumer_data['email'])) {
                         if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(11, $subscriptionDetails['features']) && $userFeatures['sms'] == 1) {
                             $model_common->sendMail($api_url, $consumer_data['email'], '', 16, '', $pattern, $replace, '');
                         }
                     }
                     if (count($contact_data) > 0 && isset($contact_data['cell_phone'])) {
                         $replace = array($consumer_data['first_name'] . ' ' . $consumer_data['last_name'], $session->first_name . ' ' . $session->last_name);
                         if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(12, $subscriptionDetails['features']) && $userFeatures['sms'] == 1) {
                             $model_common->sendMsg($contact_data['cell_phone'], 6, '', $pattern, $replace);
                         }
                     }
                 }
                 $this->fetchallreplies($api_url, $result_master);
             } else {
                 $replyMessage = "Error! Reply Could not be submitted";
             }
         } else {
             $msg_error = "Reply cannot be empty";
         }
     }
     // getting banner for this page
     $banners = $common->getBanner($api_url, 4);
     return new ViewModel(array('master_message' => $result_master, 'replies' => $result_replies, 'notifications' => $notifications, 'current_user_id' => $session->userid, 'avtar_url' => $sp_details['avtar_url'], 'first_name' => $sp_details['first_name'], 'last_name' => $sp_details['last_name'], 'banners' => $banners));
 }
Пример #2
0
 public function updateAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $action = $request->getPost('action', 'profile');
         $api = new Api();
         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
         $session = new Container('frontend');
         $consumer = new Consumers();
         switch ($action) {
             case 'profile':
                 $errors = array();
                 $user_id = $details_data['user_id'] = $request->getQuery('user_id');
                 $contact_data['first_name'] = trim($request->getQuery('first_name')) != "" ? trim($request->getQuery('first_name')) : '';
                 $contact_data['last_name'] = trim($request->getQuery('last_name')) != "" ? trim($request->getQuery('last_name')) : '';
                 $contact_data['age'] = trim($request->getQuery('age')) != "" ? trim($request->getQuery('age')) : '';
                 $contact_data['gender'] = trim($request->getQuery('gender')) != "" ? trim($request->getQuery('gender')) : '';
                 /* contact validation starts here */
                 foreach ($contact_data as $key => $value) {
                     if ($value == '' && $key != 'language') {
                         $errors[$key] = "This field is required.";
                     } elseif ($key == "age" && $value > 99) {
                         $errors[$key] = "Please provide valid age.";
                     }
                 }
                 /* contact validation starts here */
                 $languages = $request->getQuery('language');
                 $del_res = $api->curlUpdate($api_url . "/api/consumerrelateddata/", array('op' => "language", 'users_id' => $user_id), "DELETE");
                 if (is_array($languages) && count($languages) > 0) {
                     foreach ($languages as $language) {
                         $user_languages[] = array('user_id' => $user_id, 'language_id' => $language);
                     }
                     $result = $api->curl($api_url . "/api/consumerrelateddata/", array('language' => json_encode($user_languages, true)), "POST");
                 }
                 if (count($errors) <= 0) {
                     $user_res = $api->curl($api_url . "/api/users/" . $user_id . "/", $contact_data, "PUT");
                     if ($user_res->getStatusCode() == 200) {
                         echo json_encode(array('status' => 1, 'msg' => 'Profile successfully updated..!!'));
                     } else {
                         $errors = $user_res->getStatusCode() != 200 && is_array(json_decode($user_res->getBody(), true)) ? array_merge($errors, json_decode($user_res->getBody(), true)) : $errors;
                         echo json_encode(array('status' => 0, 'errors' => $errors));
                     }
                 } else {
                     echo json_encode(array('status' => 0, 'errors' => $errors));
                 }
                 break;
             case 'contact':
                 $contact_data = array();
                 $errors = array();
                 $contact_data['home_phone'] = $request->getQuery('home_phone') != "" ? trim($request->getQuery('home_phone')) : '';
                 $contact_data['cell_phone'] = $request->getQuery('cell_phone') != "" ? trim($request->getQuery('cell_phone')) : '';
                 $contact_data['work_phone'] = $request->getQuery('work_phone') != "" ? trim($request->getQuery('work_phone')) : '';
                 $contact_data['fax'] = $request->getQuery('fax') != "" ? trim($request->getQuery('fax')) : '';
                 $contact_data['user_id'] = $session->userid != "" ? $session->userid : '';
                 /* contact validation starts here */
                 foreach ($contact_data as $key => $value) {
                     /*if ($value != '' && !in_array($key, array('')) && !is_numeric($value)) {
                           $errors[$key] = "Must be a numberic value.";
                       } else*/
                     if ($key == "home_phone" && $value == '') {
                         $errors[$key] = "Field is requried.";
                     } elseif ($key == "cell_phone" && $value == '') {
                         $errors[$key] = "Field is requried.";
                     } elseif ($key == "fax" && $value != '' && !is_numeric($value)) {
                         $errors[$key] = "Valid Fax No. must be a numberic value.";
                     } elseif ($key == "home_phone" && !preg_match('/^\\d{11}$/', $value)) {
                         //} elseif (($key == "home_phone" && !preg_match('/^(\(\+[0-9]\))\s*([0-9]{3})-([0-9]{3})-([0-9]{4})$/', $value))) {
                         $errors[$key] = "Valid Phone number must be 11 digit number (1 as a prefix and 10 digit phone number).";
                     } elseif ($key == "work_phone" && $value != '' && !preg_match('/^\\d{11}$/', $value)) {
                         //} elseif (($key == "home_phone" && !preg_match('/^(\(\+[0-9]\))\s*([0-9]{3})-([0-9]{3})-([0-9]{4})$/', $value))) {
                         $errors[$key] = "Valid Phone number must be 11 digit number (1 as a prefix and 10 digit phone number).";
                     } elseif ($key == "cell_phone" && !preg_match('/^\\d{11}$/', $value)) {
                         //} elseif (($key == "cell_phone" && !preg_match('/^(\(\+[0-9]\))\s*([0-9]{3})-([0-9]{3})-([0-9]{4})$/', $value))) {
                         $errors[$key] = "Valid Phone number must be 11 digit number (1 as a prefix and 10 digit phone number).";
                     } elseif ($key == "fax" && $value != '' && !preg_match('/^\\d{11}$/', $value)) {
                         //} elseif (($key == "home_phone" && !preg_match('/^(\(\+[0-9]\))\s*([0-9]{3})-([0-9]{3})-([0-9]{4})$/', $value))) {
                         $errors[$key] = "Valid Fax number must be 11 digit number (1 as a prefix and 10 digit phone number).";
                     }
                 }
                 /* contact validation ends here */
                 if (count($errors) <= 0) {
                     $contact_id = $request->getQuery('contact_id');
                     /* check if contact exists */
                     $contact_check = $api->curl($api_url . "/api/users/contact/" . $contact_id . "/", array(), "GET");
                     //$contact_data_check = json_decode($contact_check->getBody(), true);
                     if ($contact_check->getStatusCode() == 404 && $contact_id == "") {
                         $contact_res = $api->curl($api_url . "/api/users/contact/", $contact_data, "POST");
                         if ($contact_res->getStatusCode() == 201) {
                             echo json_encode(array('status' => 1, 'msg' => 'User contact successfully added..!!'));
                         } else {
                             $errors = $contact_res->getStatusCode() != 200 && is_array(json_decode($contact_res->getBody(), true)) ? array_merge($errors, json_decode($contact_res->getBody(), true)) : $errors;
                             echo json_encode(array('status' => 0, 'errors' => $errors));
                         }
                     } elseif ($contact_check->getStatusCode() == 200 && $contact_id != "") {
                         $contact_check_res = json_decode($contact_check->getBody(), true);
                         if ($contact_id == $contact_check_res['id'] && $contact_check_res['user_id'] == $session->userid) {
                             $contact_res = $api->curl($api_url . "/api/users/contact/" . $contact_id . "/", $contact_data, "PUT");
                             if ($contact_res->getStatusCode() == 200) {
                                 echo json_encode(array('status' => 1, 'msg' => 'User contact successfully updated..!!'));
                             } else {
                                 $errors = $contact_res->getStatusCode() != 200 && is_array(json_decode($contact_res->getBody(), true)) ? array_merge($errors, json_decode($contact_res->getBody(), true)) : $errors;
                                 echo json_encode(array('status' => 0, 'errors' => $errors));
                             }
                         }
                     } else {
                         $errors['Contact'] = "Unable to update contact please try again..!!.";
                         echo json_encode(array('status' => 0, 'errors' => $errors));
                     }
                 } else {
                     echo json_encode(array('status' => 0, 'errors' => $errors));
                 }
                 break;
             case 'address':
                 $address_data = array();
                 $errors = array();
                 $address_data['user_type'] = '';
                 $address_data['location_type_id'] = 1;
                 $address_data['user_id'] = $session->userid;
                 $address_data['street1_address'] = trim($request->getQuery('street1_address')) != "" ? trim($request->getQuery('street1_address')) : '';
                 $address_data['city'] = trim($request->getQuery('city')) != "" ? trim($request->getQuery('city')) : '';
                 $address_data['state_id'] = trim($request->getQuery('state_id')) != "" ? trim($request->getQuery('state_id')) : '';
                 $address_data['country_id'] = trim($request->getQuery('country_id')) != "" ? trim($request->getQuery('country_id')) : '';
                 $address_data['zip_code'] = trim($request->getQuery('zip_code')) != "" ? trim($request->getQuery('zip_code')) : '';
                 /* contact validation starts here */
                 foreach ($address_data as $key => $value) {
                     if ($key == "zip_code" && $value == '') {
                         $errors[$key] = "Please enter a valid zip code.";
                     }
                 }
                 /* contact validation ends here */
                 if (count($errors) <= 0) {
                     $address_id = $request->getQuery('address_id');
                     /* check if contact exists */
                     $address_check = $api->curl($api_url . "/api/address/" . $address_id . "/", array(), "GET");
                     //$address_check = $api->curl($api_url . "/api/address/505/", array(), "GET");
                     if ($address_check->getStatusCode() == 404 && $address_id == "") {
                         $address_res = $api->curl($api_url . "/api/address/", $address_data, "POST");
                         if ($address_res->getStatusCode() == 200) {
                             echo json_encode(array('status' => 1, 'msg' => 'User contact successfully added..!!'));
                         } else {
                             $errors = $address_res->getStatusCode() != 200 && is_array(json_decode($address_res->getBody(), true)) ? array_merge($errors, json_decode($address_res->getBody(), true)) : $errors;
                             echo json_encode(array('status' => 0, 'errors' => $errors));
                         }
                     } elseif ($address_check->getStatusCode() == 200 && $address_id != "") {
                         $address_res = $api->curl($api_url . "/api/address/" . $address_id . "/", $address_data, "PUT");
                         if ($address_res->getStatusCode() == 201) {
                             echo json_encode(array('status' => 1, 'msg' => 'User address successfully updated..!!'));
                         } else {
                             $errors = $address_res->getStatusCode() != 201 && is_array(json_decode($address_res->getBody(), true)) ? array_merge($errors, json_decode($address_res->getBody(), true)) : $errors;
                             echo json_encode(array('status' => 0, 'errors' => $errors));
                         }
                     } else {
                         $errors['Address'] = "Unable to update address please try again..!!.";
                         echo json_encode(array('status' => 0, 'errors' => $errors));
                     }
                 } else {
                     echo json_encode(array('status' => 0, 'errors' => $errors));
                 }
                 break;
             case 'consumer-avatar':
                 $File = $this->params()->fromFiles('consumer-avatar');
                 $valid_file_ext = array("image/jpg", "image/jpeg", "image/bmp", "image/gif", "image/png");
                 if ($File['error'] == 0 && $File['size'] > 0) {
                     if (in_array($File['type'], $valid_file_ext)) {
                         $session = new Container('frontend');
                         $user_id = $session->userid;
                         $api = new Api();
                         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
                         $res = $api->curl($api_url . "/api/users/" . $user_id . "/", array(), "GET");
                         if ($res->getStatusCode() == 200) {
                             $data = json_decode($res->getBody());
                             $old_avtar_url = $data->avtar_url;
                             // uploading consumer avtar
                             $S3 = new ImageS3();
                             $avatar_data = $S3->uploadFiles($_FILES['consumer-avatar'], '', array(), array('Avtars' => '378x378\\>\\!'));
                             //deleting existing avatar from Amazone
                             $old_avtar_url != '' ? $S3->deleteFile(str_replace('https://ovessence.s3.amazonaws.com/', '', $old_avtar_url)) : '';
                             //updating avtar for user
                             $res = $api->curl($api_url . "/api/users/" . $user_id . "/", array('avtar_url' => $avatar_data['Avtars']), "PUT");
                             if ($res->getStatusCode() == 200 || $res->getStatusCode() == 201) {
                                 echo json_encode(array('status' => 1, 'msg' => 'Avtar image changed successfully..!!', 'image_url' => $avatar_data['Avtars']));
                             } else {
                                 echo json_encode(array('status' => 0, 'msg' => 'Failed to update avtar image..!!'));
                             }
                         } else {
                             echo json_encode(array('status' => 0, 'msg' => 'Failed to update avtar image..!!'));
                         }
                     } else {
                         echo json_encode(array('status' => 0, 'msg' => 'Please upload a valid image..!!'));
                     }
                 } else {
                     echo json_encode(array('status' => 0, 'msg' => 'No file selected for upload..!!'));
                 }
                 break;
             case 'delete_avtar':
                 $details = $consumer->getConsumerdetails($api_url, $session->userid);
                 if (isset($details['avtar_url']) && $details['avtar_url'] != '') {
                     $S3 = new ImageS3();
                     $res = $S3->deleteFile(str_replace('https://ovessence.s3.amazonaws.com/', '', $details['avtar_url']));
                     //updating avtar for user
                     $res = $api->curl($api_url . "/api/users/" . $session->userid . "/", array('avtar_url' => ''), "PUT");
                     if ($res->getStatusCode() == 200 || $res->getStatusCode() == 201) {
                         echo json_encode(array('status' => 1, 'msg' => 'Avtar image deleted successfully..!!', 'code' => $res));
                     } else {
                         echo json_encode(array('status' => 0, 'msg' => 'Failed to delete avtar image..!!'));
                     }
                 } else {
                     echo json_encode(array('status' => 0, 'msg' => 'No image found..!!'));
                 }
                 break;
         }
     }
     exit;
 }
Пример #3
0
 public function indexAction()
 {
     $contact_form = new ContactForm();
     $request = $this->getRequest();
     $common = new Common();
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     if ($request->isXmlHttpRequest()) {
         $email = $request->getPost('email') != '' ? $request->getPost('email') : '';
         $first_name = $request->getPost('first_name') != '' ? $request->getPost('first_name') : '';
         $last_name = $request->getPost('last_name') != '' ? $request->getPost('last_name') : '';
         $message = $request->getPost('message') != '' ? $request->getPost('message') : '';
         $phone = $request->getPost('phone') != '' ? $request->getPost('phone') : '';
         /* $api = new Api();
                       $url = $api_url."/api/contactus/";
                       $data = array('email' => $email, 'first_name'=> $first_name, 'last_name'=> $last_name, 'phone'=> $phone, 'message'=> $message );
         
                       $res = $api->curl($url, $data, "POST");
                       if($res->getStatusCode() == 200){
                       $msgbody = json_decode($res->getBody(), true);
                       }else {
                       $msgbody = '';
                       } */
         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
         $consumer = new Consumers();
         // Start :- Get admin email id
         $res = $consumer->getConsumerdetails($api_url, 1);
         if (count($res) > 0) {
             $adminEmailId = $res['email'];
         }
         if ($common->sendMail($api_url, $adminEmailId, $email, 23, '', array('/{{first_name}}/i', '/{{user_name}}/i', '/{{email}}/i', '/{{phone}}/i', '/{{message}}/i'), array($first_name, $first_name . " " . $last_name, $email, $phone, $message))) {
             $error = false;
             $msg = "Success!! Mail send sucessfully";
         } else {
             $error = true;
             $msg = "Failed to send mail. Please try again later..!!";
         }
         /* $mail = new Mail\Message();
                       $mail->setBody($messagebody);
                       $mail->addTo(/*$adminEmailId'*****@*****.**', 'Name of recipient');
                       $mail->setSubject('An ovessence visitor whants to contact you.');
         
                       $transport = new Mail\Transport\Sendmail();
                       if($transport->send($mail)){
                       $msg = "Success!! Mail send sucessfully";
                       }else{
                       $error = true;
                       $msg = "Error!! Unable to contact.";
                       } */
         echo json_encode(array('error' => $error, 'msg' => $msg));
         exit;
     }
     $api = new Api();
     $response = $api->curl($api_url . '/api/pages/3/', array(), "GET");
     $content = '{{form}}';
     if ($response->getStatusCode() == 200) {
         $data = json_decode($response->getBody(), true);
         $content = $data['content'];
     }
     $banners = $common->getBanner($api_url, 7);
     return new ViewModel(array('form' => $contact_form, 'content' => $content, 'banners' => $banners));
 }
Пример #4
0
 public function changeBookingStatus($api_url, $id, $status, $common)
 {
     $suggestion_res = $this->api->curl($api_url . "/api/suggestionhistory/", array('booking_id' => $id), "GET");
     $session = new Container('frontend');
     //print_r($id); exit;
     if ($suggestion_res->getStatusCode() == 200) {
         $suggestions = json_decode($suggestion_res->getBody(), true);
         $last = end($suggestions);
         $user = json_decode($last['user'], true);
         $user_name = $user['first_name'] . ' ' . $user['last_name'];
         $user_email = $user['email'];
         if ($user['user_type_id'] != '3') {
             $userObject = new Consumers();
             $user_type = 'Practitioner';
             $contact = $userObject->getContact($api_url, $user['user_id']);
             $phone = $contact[0]['home_phone'];
         } else {
             $userObject = new Practitioners();
             $user_type = 'Consumer';
             $contact = $userObject->getContact($api_url, $user['user_id']);
             $phone = $contact[0]['phone_number'];
         }
         $update_res = $this->api->curl($api_url . "/api/suggestionhistory/" . $last['id'] . "/", array('booking_status' => $status), "PUT");
         if ($update_res->getStatusCode() != 200 && $update_res->getStatusCode() != 201) {
             return false;
         } else {
             switch ($status) {
                 case 4:
                     $status = 'Confirmed';
                     break;
                 case 5:
                     $status = 'Pending Approval';
                     break;
                 case 6:
                     $status = 'Cancelled';
                     break;
             }
             $pattern = array('/{{user_name}}/i', '/{{user_type}}/i', '/{{booking_id}}/i', '/{{status}}/i');
             $replace = array('<strong>' . $user_name . '</strong>', $user_type, '<strong>#' . $last['booking_id'] . '</strong>', $status);
             $userFeatures = $common->getFeatures($api_url, $user['user_id']);
             if ($user_type == 'Consumer') {
                 $subscriptionDetails = $common->getSubscriptiondetails($api_url, $session->userid, true);
                 if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(11, $subscriptionDetails['features']) || $userFeatures['email'] == 1) {
                     $common->sendMail($api_url, $user_email, '', 14, '', $pattern, $replace);
                 }
                 if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(12, $subscriptionDetails['features']) && $userFeatures['sms'] == 1) {
                     $common->sendMsg($phone, 3, '', $pattern, array($user_name, $user_type, $last['booking_id'], $status));
                 }
             } else {
                 $subscriptionDetails = $common->getSubscriptiondetails($api_url, $user['user_id'], true);
                 $common->sendMail($api_url, $user_email, '', 14, '', $pattern, $replace);
                 if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(12, $subscriptionDetails['features']) && $userFeatures['sms'] == 1) {
                     $common->sendMsg($phone, 3, '', $pattern, array($user_name, $user_type, $last['booking_id'], $status));
                 }
             }
             return true;
         }
     } else {
         return false;
     }
 }
Пример #5
0
 public function renewcardAction()
 {
     set_time_limit(0);
     $model = new Practitioners();
     $common = $this->getServiceLocator()->get('Application\\Model\\Common');
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $filter = array('card_expiration_hash' => md5(date('n-Y')));
     $cardDetails = $common->getUserCardDetails($api_url, $filter);
     // Start :- Get admin email id
     $adminEmailId = '';
     $consumer = new Consumers();
     $res = $consumer->getConsumerdetails($api_url, 1);
     if (count($res) > 0) {
         $adminEmailId = $res['email'];
     }
     $card = end($cardDetails);
     /* renew card code for all users pi20jan */
     if (count($cardDetails) > 0) {
         foreach ($cardDetails as $card) {
             $user_details = $model->getSPDetails($api_url, $card['user_id']);
             // getting use email permissions
             $subscriptionDetails = $common->getSubscriptiondetails($api_url, $card['user_id'], true);
             // getting service provider subscription details
             $userFeatures = $common->getFeatures($api_url, $card['user_id']);
             if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(11, $subscriptionDetails['features']) || $userFeatures['email'] == 1) {
                 $pattern = array('/{{user_name}}/i');
                 $replace = array('<strong>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . '</strong>');
                 $common->sendMail($api_url, $user_details['email'], '', 20, '', $pattern, $replace, '', $adminEmailId);
                 $common->sendMail($api_url, $adminEmailId, '', 20, '', $pattern, $replace, '', '');
             }
         }
     }
     exit;
 }
Пример #6
0
 public function invoiceAction()
 {
     $id = (int) $this->params()->fromRoute('id', 0);
     if (!$id) {
         return $this->redirect()->toRoute('home');
     }
     $auth = new FrontEndAuth();
     $bookingModel = new Bookings();
     $consumers = new Consumers();
     $practitioners = new Practitioners();
     $common = new Common();
     $session = new Container('frontend');
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     if ($auth->hasIdentity(4)) {
         // Consumer invoice
         $data = $bookingModel->getBookings($api_url, '', $session->userid, '', '', '', '', $id);
         $userDetails = $consumers->getConsumerdetails($api_url, $data['results'][0]['user_id']);
     } else {
         if ($auth->hasIdentity(3)) {
             // service provider invoice
             $data = $bookingModel->getBookings($api_url, $session->userid, '', '', '', '', '', $id);
             $userDetails = $consumers->getConsumerdetails($api_url, $data['results'][0]['user_id']);
         } else {
             return $this->redirect()->toRoute('home');
         }
     }
     $userDetails['address'] = json_decode($userDetails['address'][0], true);
     $userDetails['contact'] = json_decode($userDetails['contact'][0], true);
     //print_r($userDetails['address']); exit;
     if (isset($data['results']) && count($data['results']) == 1) {
         $sp_details = $practitioners->getSPDetails($api_url, $data['results'][0]['service_provider_id']);
         $service_rendering_address = $data['results'][0]['service_address_id'] != '' && $data['results'][0]['service_address_id'] != 'None' ? $common->address($api_url, $data['results'][0]['service_address_id']) : 'Not Available';
         if ($this->getRequest()->getQuery('print') == 1) {
             $view = new viewModel(array('booking_details' => $data['results'], 'user_details' => $userDetails, 'service_rendering_address' => $service_rendering_address, 'service_rendering_details' => $sp_details));
             $view->setTemplate('application/booking/printinvoice.phtml');
             $printData = $this->getServiceLocator()->get('viewrenderer')->render($view);
             // Store in PDF format
             $dompdf = new \DOMPDF();
             $dompdf->load_html($printData);
             $dompdf->render();
             $dompdf->stream('invoice.pdf', array('Attachment' => 0));
             exit;
         } else {
             $banners = $common->getBanner($api_url, 16);
             if ($session->user_type_id == 3) {
                 $subscriptionDetails = $common->getSubscriptiondetails($api_url, '', true);
                 return new viewModel(array('booking_details' => $data['results'], 'user_details' => $userDetails, 'id' => $id, 'features' => $subscriptionDetails['features'], 'service_rendering_address' => $service_rendering_address, 'banners' => $banners, 'service_rendering_details' => $sp_details));
             } else {
                 return new viewModel(array('booking_details' => $data['results'], 'user_details' => $userDetails, 'id' => $id, 'service_rendering_address' => $service_rendering_address, 'banners' => $banners, 'service_rendering_details' => $sp_details));
             }
         }
     } else {
         return $this->redirect()->toRoute('home');
     }
     exit;
 }