public function dashboardAction()
 {
     $auth = new FrontEndAuth();
     if (!$auth->hasIdentity(4)) {
         return $this->redirect()->toUrl('/login');
     }
     $session = new Container('frontend');
     // 0:- both(sms & mail) are verified 1:- any one or both(sms & mail) are unverified
     $verifystatus = $session->email_verification_status == 1 && $session->sms_verification_status == 1 ? 0 : 1;
     $api = new Api();
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $loggedInUser = $session->userid;
     $userType = $session->user_type_id;
     $model_practitioner = new Practitioners();
     $model_consumer = new Consumers();
     $loggedInUserAddress = $model_practitioner->getLoggedInUserAddress($loggedInUser, $userType, $api_url);
     $common = new Common();
     $search_form = new SearchForm($common->getAllservices($api_url), $common->getstatesByCountry($api_url, $loggedInUserAddress->country_id));
     $notifications = $model_practitioner->getNotifications($api_url, 'consumer');
     $consumer_details = $model_consumer->getConsumerdetails($api_url, $session->userid);
     $practitioners_list = $model_practitioner->getSPlist($api_url);
     if (!$consumer_details) {
         $this->redirect()->toUrl('/consumer/list');
     }
     $bookings_count = $this->getConsumerbookingsCount($session->userid, $api, $api_url);
     //getting bookings count for Consumer
     $wishlist_count = $this->getConsumerWishlistCount($session->userid, $api, $api_url);
     //getting wishlist count for Consumer
     $contact_list_count = $model_consumer->getContactedListCount($session->userid, $api_url);
     $data = $this->getConsumerData($consumer_details);
     // getting banner for this page
     $banners = $common->getBanner($api_url, 5);
     // getting advertisments
     $ad = $common->getAdvertisement($api_url, 5);
     return new ViewModel(array('consumer' => $data, 'states' => $common->getstatesByCountry($api_url), 'countries' => $common->getCountries($api_url), 'languages' => $model_consumer->getLanguages($api_url), 'booking_count' => $bookings_count, 'wishlist_count' => $wishlist_count, 'notifications' => $notifications, 'practitioners_list' => $practitioners_list, 'search_form' => $search_form, 'last_login' => $session->last_login, 'contact_list_count' => $contact_list_count, 'verifystatus' => $verifystatus, 'banners' => $banners, 'addresses' => $common->getAddresses($api_url), 'service_list' => $common->getServices($api_url), 'advertisement' => $ad));
 }
 public function referralsAction()
 {
     $api = new Api();
     $common = new Common();
     $model = new Practitioners();
     $session = new Container('frontend');
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     /* Ajax code starts here */
     $request = $this->getRequest();
     if ($request->isPost()) {
         switch ($request->getPost('action')) {
             case 'get':
                 //echo json_encode($model->getSPreferrals($api_url, $request->getPost('user'), $request->getPost('referred_by')));
                 echo json_encode($model->getSPreferrals($api_url, $request->getPost('user'), $request->getPost('referred_by'), $request->getPost('page'), $request->getPost('items')));
                 break;
             case 'update':
                 echo json_encode($model->addReference($api_url, $request->getPost(), $session->userid));
                 break;
             case 'delete':
                 echo json_encode($model->deleteReference($api_url, $request->getPost('ids')));
                 break;
         }
         exit;
     }
     /* Ajax code ends here */
     $auth = new FrontEndAuth();
     if (!$auth->hasIdentity(3)) {
         return $this->redirect()->toRoute('login', array('action' => 'index'));
     }
     $res = $api->curl($api_url . "/api/spusers/" . $session->userid . "/", array(''), "GET");
     if ($res->getStatusCode() != 200) {
         return $this->redirect()->toRoute('practitioner', array('action' => 'list'));
     }
     $data = $this->getSpdata($res);
     // getting banner for this page
     $banners = $common->getBanner($api_url, 4);
     return new ViewModel(array('user_id' => $session->userid, 'content' => $data['content'], 'notifications' => $model->getNotifications($api_url), 'total_referred_from' => count($model->getSPreferrals($api_url, $session->userid)), 'total_referred_to' => count($model->getSPreferrals($api_url, '', $session->userid)), 'services' => $model->getSpserviceData($api_url), 'practitioners' => $model->getSPlist($api_url, $session->userid), 'banners' => $banners));
 }