public function viewAction()
 {
     $id = $this->params()->fromRoute('id');
     $request = $this->getRequest();
     $getparams = $request->getQuery();
     isset($getparams['tab']) ? $tab = $getparams['tab'] : ($tab = '');
     $common = new Common();
     $redirectUrl = array('controller' => 'Practitioner', 'action' => 'view');
     if (!empty($id) && $id != null) {
         $session = new Container('frontend');
         $model = new Practitioners();
         $bookingModel = new Bookings();
         $api = new Api();
         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
         $chat_url = $this->getServiceLocator()->get('config')['chatpath']['url'];
         $reviewFlag = false;
         if (isset($getparams['review']) && $getparams['review'] == 1 && isset($getparams['s_id'])) {
             // check service
             $serivce_id = $getparams['s_id'];
             $user_id = $session->userid;
             $sp_id = $id;
             $result = $bookingModel->getBookings($api_url, $sp_id, $user_id, '4', "", "", $serivce_id);
             $reviewFlag = $model->setreviewFlg($result);
         } else {
             $reviewFlag = false;
         }
         $url = $api_url . "/api/spusers/" . $id . "/";
         $data = array('status_id' => 9);
         $res = $api->curl($url, $data, "GET");
         if ($res->getStatusCode() == 200) {
             $data = $this->getSpdata($res);
         } else {
             $redirectUrl = "/practitioner/list";
             return $this->redirect()->toUrl($redirectUrl);
             $content = '';
             $address = '';
             $work_address = '';
             $contact = '';
             $details = '';
             $service_list = '';
             $language = '';
         }
         //$forWishlist = new Container('last_url');
         $feedback_list = $this->getSPfeedback($id, $api, $api_url);
         //getting feedback list for service provider
         $video_list = $this->getSPmedia($id, $api, $api_url);
         //getting video list for service provider
         $options = $model->getSPoptions($id, $api_url);
         //getting available options for service provider
         $varification = $model->getSPvarification($id, $api_url);
         //getting varified/unverified ids for service provider
         $bookings_count = $bookingModel->getBookingsCount($api_url, $id);
         //getting bookings count for service provider
         $ratings = $model->getSPRatings($id, $api_url, 'detailed');
         //getting ratings for service provider
         $workdays = $model->getSPWorkdays($id, $api_url);
         //getting workdays for service provider
         //$all_services = $common->getAllservices($api,$api_url); //getting workdays for service provider
         //echo '<pre>'; var_dump($data); exit;
         if ($request->isPost()) {
             $map = $this->generateMap($api_url, $api, array('address' => $data['work_address']), '', trim($request->getPost('zip_code')));
         } else {
             $map = $this->generateMap($api_url, $api, array('address' => $data['work_address']), $session->userid);
         }
         $features = $common->getFeatures($api_url, $id);
         isset($features['chat']) ? $chat = $features['chat'] : ($chat = 0);
         $bookingsession = new Container('bookingsession');
         $bookingsession->currency = $currency = $model->getcurrency($api_url, $this->getRequest()->getServer('REMOTE_ADDR'));
         /* Start:- Search form */
         $loggedInUserAddress = $model->getLoggedInUserAddress($session->userid, $session->user_type_id, $api_url);
         $treatment_list = $common->getAllservices($api_url);
         $search_form = new SearchForm($treatment_list, $common->getstatesByCountry($api_url, $loggedInUserAddress->country_id));
         /* $data = $this->request->getPost();
            if ($this->request->isPost()) {
            $search_form->bind($data);
            } */
         /* End:- Search form */
         // fetching subscription features
         $subscriptionDetails = $common->getSubscriptiondetails($api_url, $id, true);
         // getting banner for this page
         $banners = $common->getBanner($api_url, 3);
         // getting response rate
         $response = $model->getResponseRate($api_url, $id);
         // getting advertisments
         $ad = $common->getAdvertisement($api_url, 3);
         return new ViewModel(array('content' => $data['content'], 'address' => $data['address'], 'work_address' => $data['work_address'], 'contact' => $data['contact'], 'details' => $data['details'], 'service_list' => $data['service_list'], 'form_review' => $data['form_review'], 'form_ask' => $data['form_ask'], 'form_booking' => $data['form_booking'], 'commission' => $data['commission'], 'language' => $data['language'], 'educations' => $data['educations'], 'feedback' => $feedback_list, 'ratings' => $ratings, 'workdays' => $workdays, 'response' => $response, 'map' => $map['map'], 'distances' => $map['distance'], 'feedback_count' => count($feedback_list), 'video_list' => $video_list, 'options' => $options, 'varification' => $varification, 'booking_count' => $bookings_count, 'auth' => $auth = new FrontEndAuth(), 'loggedin_userid' => $session->userid, 'successMsgs' => $this->flashMessenger()->getCurrentSuccessMessages(), 'errors' => $this->flashMessenger()->getCurrentErrorMessages(), 'wishlistform' => $data['form_wishlist'], 'chat' => $chat, 'chat_url' => $chat_url, 'reviewFlag' => $reviewFlag, 's_id' => $getparams['s_id'], 'reviewTab' => $getparams['review'], 'currency' => $currency, 'reviewFlag' => $reviewFlag, 'tab' => $tab, 'errors' => $this->flashMessenger()->getCurrentErrorMessages(), 'search_form' => $search_form, 'baseurl' => $this->getServiceLocator()->get('config')['basepath']['url'], 'features' => $subscriptionDetails['features'], 'total_referred_from' => count($model->getSPreferrals($api_url, $id)), 'banners' => $banners, 'posted_zip' => $request->getPost('zip_code'), 'advertisement' => $ad));
     } else {
         $redirectUrl = "/practitioner/list";
         return $this->redirect()->toUrl($redirectUrl);
     }
 }
Exemplo n.º 2
0
 public function ratingsAction()
 {
     $id = $this->params()->fromRoute('id');
     $getparams = $this->getRequest()->getQuery();
     if (!empty($id) && $id != null && $id != "") {
         $auth = new FrontEndAuth();
         if (!$auth->hasIdentity(4)) {
             return $this->redirect()->toUrl('/login');
         }
         $ratingType = array();
         $ratingData = array();
         $session = new Container('frontend');
         $model = new Practitioners();
         $bookingModel = new Bookings();
         $common = new Common();
         $api = new Api();
         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
         $reviewFlag = false;
         $user_id = $session->userid;
         if (isset($getparams['review']) && $getparams['review'] == 1 && isset($getparams['s_id'])) {
             // check service
             $serivce_id = $getparams['s_id'];
             $sp_id = $id;
             $result = $bookingModel->getBookings($api_url, $sp_id, $user_id, '4', "", "", $serivce_id);
             $reviewFlag = $model->setreviewFlg($result);
             //get service provider details
             $sp_res = $api->curl($api_url . "/api/spusers/" . $sp_id . "/", array(), "GET");
             if ($sp_res->getStatusCode() == 200) {
                 $spData = json_decode($sp_res->getBody(), true);
             }
         }
         if ($reviewFlag == true) {
             //get previous ratings
             $ratings_data_res = $api->curl($api_url . "/api/rating/", array("users_id" => $id, "service_id" => $serivce_id, "created_by" => $user_id), "GET");
             if ($ratings_data_res->getStatusCode() == 200) {
                 $ratingData = json_decode($ratings_data_res->getBody(), true);
             }
             //Check if rating data exits otherwise send $ratingType for fresh reviews.
             if (empty($ratingData)) {
                 if (empty($ratingData)) {
                     $rating_res = $api->curl($api_url . "/api/ratingtype/", array("status_id" => 1), "GET");
                     if ($rating_res->getStatusCode() == 200) {
                         $ratingType = json_decode($rating_res->getBody(), true);
                     }
                 }
             }
         } else {
             return $this->redirect()->toUrl('/consumer/dashboard');
         }
     } else {
         return $this->redirect()->toUrl('/consumer/dashboard');
     }
     // getting banner for this page
     $banners = $common->getBanner($api_url, 5);
     return new viewModel(array("ratingType" => $ratingType, "ratingData" => $ratingData, "spData" => $spData, "service_id" => $serivce_id, 'banners' => $banners));
 }