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);
     }
 }