コード例 #1
0
 public function indexAction()
 {
     $api = new Api();
     $common = new Common();
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     $url = $api_url . "/api/partners/?status_id=1";
     $res = $api->curl($url, array(), "GET");
     if ($res->getStatusCode() == 200) {
         $content = json_decode($res->getBody(), true);
         if ($this->getRequest()->isXmlHttpRequest()) {
             $partners_list = '';
             foreach ($content as $data) {
                 $partners_list .= "<li>";
                 $partners_list .= "<img src='" . $data['logo'] . "' alt='' >";
                 $partners_list .= "</li>";
             }
             echo $partners_list;
             die;
         }
         // getting banners
         $banners = $common->getBanner($api_url, 13);
         $banner_content = $common->getPage($api_url, 14);
         return new ViewModel(array('partners' => $content, 'banners' => $banners, 'banner_content' => $banner_content));
     }
 }
コード例 #2
0
 public function indexAction()
 {
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     if ($this->getRequest()->isXmlHttpRequest()) {
         //echo $this->getRequest()->getPost('page'); exit;
         $next = $this->getRequest()->getPost('page') != '' ? $this->getRequest()->getPost('page') : '1';
         $api = new Api();
         $url = $api_url . "/api/testimonials/";
         $res = $api->curl($url, array('page' => $next, 'status_id' => '1'), "GET");
         if ($res->getStatusCode() == 200) {
             $content = json_decode($res->getBody(), true);
             if (count($content['results'])) {
                 $count = 0;
                 foreach ($content['results'] as $value) {
                     $currentDate = strtotime(date("Y-m-d H:i:s"));
                     $lastDate = strtotime($value['created_on']);
                     $dateTime = $lastDate + 86400 > $currentDate ? 'About ' . floor(($currentDate - $lastDate) / 3600) . ':' . floor(($currentDate - $lastDate) / (24 * 60)) . ' Hours Ago' : $value['created_on'];
                     $ts_list[$count]['id'] = $value['id'];
                     $ts_list[$count]['created_on'] = $dateTime;
                     $ts_list[$count]['text'] = $value['text'];
                     if (count($value['created_by_user']) > 0) {
                         $details = json_decode($value['created_by_user'], true);
                         foreach ($details as $user_detail) {
                             $ts_list[$count]['user_name'] = $details['first_name'] . ' ' . $details['last_name'];
                             $ts_list[$count]['user_id'] = $details['user_id'];
                             $ts_list[$count]['img_url'] = $details['avtar_url'] != 'None' ? $details['avtar_url'] : 0;
                         }
                     }
                     $count++;
                 }
                 if ($content['next'] != '') {
                     $str = str_replace("page", "@!##", $content['next']);
                     $str_arr = explode('@!##=', $str);
                     $next = explode('&', $str_arr[1]);
                     $ts_list['next'] = $next[0];
                 } else {
                     $ts_list['next'] = '';
                 }
                 //$ts_list['error'] = false;
                 $ts_list['count'] = $count;
                 echo json_encode($ts_list);
                 exit;
             } else {
                 $ts_list = '';
                 echo json_encode($ts_list);
                 // no data found
                 exit;
             }
         } else {
             $ts_list = array('next' => '', 'count' => '');
         }
         echo json_encode($ts_list);
         exit;
     } else {
         // getting banners
         $common = new Common();
         $banners = $common->getBanner($api_url, 8);
         return new ViewModel(array('banners' => $banners));
     }
 }
コード例 #3
0
 public function faqdetailsAction()
 {
     $request = $this->getRequest();
     if ($request->isPost()) {
         $common = new Common();
         $id = $request->getPost('id');
         $user_type = $request->getPost('user_type');
         $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
         $faqs = $common->getFaqs($api_url, $user_type, $id, 'single');
         echo json_encode($faqs);
     }
     exit;
 }
コード例 #4
0
 public function indexAction()
 {
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     $api = new Api();
     $auth = new FrontEndAuth();
     $error = "";
     $redirectUrl = array('controller' => 'index');
     if ($auth->hasIdentity()) {
         return $this->redirect()->toRoute(null, $redirectUrl);
     }
     $form = new ForgetPasswordForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $model = new ForgetPassword();
         $form->setInputFilter($model->getInputFilter());
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             unset($data['submit']);
             $random_password = $model->generateRandomPassword();
             $data['password'] = $random_password;
             $session = new Container('frontend');
             $url = $api_url . "/api/useractivity/";
             $data['email'] = $request->getPost('email');
             $res = $api->curl($url, $data, "GET");
             //echo '<pre>'; var_dump($res); die;
             if ($res->getStatusCode() == 200) {
                 $content = json_decode($res->getBody(), true);
                 //echo '<pre>'; var_dump($content[0]); die;
                 $model = new Common();
                 $model->sendMail($api_url, $content[0]['email'], '', 22, '', array('/{{user_name}}/i', '/{{username}}/i'), array($content[0]['first_name'] . ' ' . $content[0]['last_name'], '<strong>' . $content[0]['user_name'] . '</strong>'));
                 $error = false;
                 $msg = "A mail has been send to " . $content[0]['email'] . " ,Please check ";
             } else {
                 $error = true;
                 $msg = "User with given email does not exist";
             }
         }
     }
     $view = new ViewModel(array('form' => $form, 'error' => $error, 'msg' => $msg));
     $view->setTemplate('application/forgetPassword/index.phtml');
     return $view;
 }
コード例 #5
0
 public function indexAction()
 {
     $api = new Api();
     $common = new Common();
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     //Start:-- Search form
     $session = new Container('frontend');
     $loggedInUser = $session->userid;
     $userType = $session->user_type_id;
     $model_practitioner = new Practitioners();
     $loggedInUserAddress = $model_practitioner->getLoggedInUserAddress($loggedInUser, $userType, $api_url);
     $treatment_list = $common->getAllservices($api_url);
     $search_form = new SearchForm($treatment_list, $common->getstatesByCountry($api_url, $loggedInUserAddress->country_id));
     // getting banners
     $banners = $common->getBanner($api_url, 1);
     //End:-- Search form
     $page1 = $common->getPage($api_url, 7);
     $page2 = $common->getPage($api_url, 8);
     $page3 = $common->getPage($api_url, 9);
     $page4 = $common->getMedia($api_url);
     $banner_content = $common->getPage($api_url, 13);
     $data = array('page1' => stripcslashes($page1), 'page2' => stripcslashes($page2), 'page3' => stripcslashes($page3), 'page4' => $page4, 'search_form' => $search_form, 'banners' => $banners, 'banner_content' => $banner_content);
     return new ViewModel($data);
 }
コード例 #6
0
ファイル: Resourceapi.php プロジェクト: ycheukf/report
 /**
     获取所有搜索结果
     @parm array aConf 同sql_getByConfig参数
 */
 function getAll($aConf)
 {
     $oSmHandle = \YcheukfReport\Lib\ALYS\ALYSConfig::get('smHandle');
     $aParams = $this->_getBySqlConfig($oSmHandle, $aConf);
     $aReturn = \Application\Model\Common::getResourceList2($oSmHandle, $aParams);
     return array($aReturn['dataset'], $aReturn['count']);
 }
コード例 #7
0
 public function getSubscriptionid($api_url)
 {
     $model_practitioner = new Practitioners();
     $common = new Common();
     $membership_details = $common->getSubscriptiondetails($api_url);
     if (count($membership_details) > 0) {
         foreach ($membership_details as $details) {
             $duration = json_decode($details['subscription_duration'], true);
             //$subscription_id = $duration['subscription_id'];
             $subscription_id = $duration['id'];
         }
     } else {
         $subscription_id = '';
     }
     return $subscription_id;
 }
コード例 #8
0
 public function sendmsgAction()
 {
     $request = $this->getRequest();
     $session = new Container('frontend');
     // User detail session
     $verify_session = new Container('verify');
     // verify type session
     $sendcode = rand();
     $common = new Common();
     $number = $request->getPost('number');
     $api = new Api();
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     if ($smstemplate = $common->smsTemplate($api_url, 5)) {
         // Create a msg
         $patterns = array('/{{code}}/i');
         $replacements = array($sendcode);
         $newMessage = preg_replace($patterns, $replacements, $smstemplate['message']);
         $config = $this->getServiceLocator()->get('Config');
         $client = new \Services_Twilio($config['Twilio']['sid'], $config['Twilio']['token']);
         $msg = $client->account->messages->sendMessage($config['Twilio']['fromNumber'], $number, $newMessage, null, array("MessageStatus", "ErrorCode"));
         if ($msg->status == 'queued') {
             // Enter verify code in database
             // maintain sms history
             $url = $api_url . "/api/smshistory/";
             $data = array('subject' => $smstemplate['subject'], 'message' => $newMessage, 'to_user_id' => $session->userid, 'from_user_id' => $session->userid, 'status' => 1);
             $res = $api->curl($url, $data, "POST");
             // End maintain sms history
             $data = array('user_id' => $session->userid, 'verification_type_id' => $verify_session->type, 'verification_code' => $sendcode, 'created_date' => date('Y-m-d H:i:s'));
             $getvalue = $this->checkuserexistence();
             if (count($getvalue) > 0) {
                 // verification code  time out
                 if ($getvalue['timeverification'] == false) {
                     $url = $api_url . "/api/userverification/" . $getvalue['id'] . "/";
                     $type = "PUT";
                 }
             } else {
                 // new user
                 $url = $api_url . "/api/userverification/";
                 $type = "POST";
             }
             $res = $api->curl($url, $data, $type);
             //$msg = ($res->getStatusCode()==201)? ('Your verified code was sent to your number'):('Error in create verified code');
             //$error = ($res->getStatusCode()==201)? false: true;
             $msg = 'Your verified code was sent to your number';
             $error = false;
             // End :- Enter verify code in database
         } else {
             $error = true;
             $msg = 'Invalid contact number for send verify code';
         }
     } else {
         $error = true;
         $msg = 'Message template not found..!!';
     }
     echo json_encode(array('msg' => $msg, 'error' => $error));
     die;
 }
コード例 #9
0
 public function savepdfbusinesscardAction()
 {
     $api = new Api();
     $model = new Practitioners();
     $common = new Common();
     $request = $this->getRequest();
     $session = new Container('frontend');
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $imgname = $request->getQuery('imgurl') == 'verso' ? 'verso' : 'recto';
     $url = './public';
     $logo = $url . '/img/business-logo.png';
     $profileurl = $this->getServiceLocator()->get('config')['basepath']['url'] . 'practitioner/view/' . $user_details['id'];
     $user_details = $model->getSPDetails($api_url, $session->userid);
     $address = $cellphone = 'Not Available';
     // getting address
     if (isset($user_details['work_address']) && is_array($user_details['work_address']) && count($user_details['work_address']) > 0) {
         $mainAddress = json_decode($user_details['work_address'][0], true);
         $address = $mainAddress['city'] . ', ' . $mainAddress['state_name'];
     }
     // getting contact details
     if (isset($user_details['contact']) && is_array($user_details['contact']) && count($user_details['contact']) > 0) {
         $contactDetails = json_decode($user_details['contact'][0], true);
         $cellphone = $contactDetails['cellphone'];
     }
     $services_count = $this->getservicesdata($session->userid, $api, $api_url);
     // get all services list
     $parentService = isset($services_count['results'][0]['category_id']) ? $model->getParentService($api_url, $services_count['results'][0]['category_id']) : 'Not Available';
     $bussCategoryName = $parentService ? $parentService['category_name'] : 'Not Avaialable';
     //$bussCategoryName = isset($services_count['results'][0]['parent_category'])?$services_count['results'][0]['parent_category']:'Not Available';
     $back_ground = $imgname == 'recto' ? '' : 'background: url(' . $url . '/img/bg_verso.jpg) no-repeat scroll center center transparent;';
     $patterns = array('/{{id}}/i', '/{{card_logo}}/i', '/{{main_category}}/i', '/{{user_name}}/i', '/{{url}}/i', '/{{cellphone}}/i', '/{{address}}/i', '/{{profile_url}}/i', '/{{back_ground}}/i');
     $replacements = array($session->userid, $logo, $bussCategoryName, $user_details['first_name'] . ' ' . $user_details['last_name'], $url, $cellphone, $address, $profileurl, $back_ground);
     $template = $imgname == 'recto' ? $common->emailTemplate($api_url, 25) : $common->emailTemplate($api_url, 24);
     $newtemp = preg_replace($patterns, $replacements, stripslashes($template['content']));
     // Store in PDF format
     $dompdf = new \DOMPDF();
     $dompdf->load_html($newtemp);
     $dompdf->render();
     //$dompdf->Output('businesscard.pdf');
     $dompdf->stream('businesscard.pdf', array('Attachment' => 0));
     die;
 }
コード例 #10
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));
 }
コード例 #11
0
 public function unsubscribeAction()
 {
     $status = array();
     $error = array();
     $token = $this->params()->fromRoute('id');
     if ($token != "" && strlen($token) == 44) {
         $model = new Common();
         $id = $model->getDecode($token);
         if ($id != "" && is_numeric($id)) {
             $api = new Api();
             $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
             $newsletter_res = $api->curl($api_url . "/api/newslettersubscription/" . $id . "/", array("status_id" => 0), "PUT");
             if ($newsletter_res->getStatusCode() == 200) {
                 $status = array('status' => 1, 'msg' => 'Your Email is sucessfully unsubscribe for newsletter..!!');
             } else {
                 $status = array('status' => 0, 'err' => "Sorry!!..Unsubscribe link is broken. Unable to process your request please try again.");
             }
         } else {
             $status = array('status' => 0, 'err' => "Sorry!!..Unsubscribe link is broken. Unable to process your request please try again.");
         }
     } else {
         return $this->redirect()->toUrl('/contact');
     }
     return new ViewModel(array('status' => $status));
 }
コード例 #12
0
 public function indexAction()
 {
     $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
     $api = new Api();
     $auth = new FrontEndAuth();
     $error = "";
     $redirectUrl = array('controller' => 'index');
     if ($auth->hasIdentity()) {
         return $this->redirect()->toRoute(null, $redirectUrl);
     }
     $form = new ForgetPasswordForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $model = new ForgetPassword();
         $form->setInputFilter($model->getInputFilter());
         $data = $request->getPost()->toArray();
         $form->setData($data);
         if ($form->isValid()) {
             unset($data['submit']);
             $random_password = $model->generateRandomPassword();
             $data['password'] = $random_password;
             $session = new Container('frontend');
             $url = $api_url . "/api/useractivity/";
             $data['op'] = 'forgotpassword';
             $res = $api->curl($url, $data, "POST");
             //var_dump($res); die;
             if ($res->getStatusCode() == 200) {
                 $model = new Common();
                 if ($template = $model->emailTemplate($api_url, 3)) {
                     $content = json_decode($res->getBody(), true);
                     // '{{user_first_name}}', '{{username}}', '{{password}}'
                     //$content['first_name'], $content['user_name'], $random_password), $template['content']);
                     $patterns = array('/{{user_first_name}}/i', '/{{username}}/i', '/{{password}}/i');
                     $replacements = array($content['first_name'], '<strong>' . $content['user_name'] . '</strong>', '<strong>' . $random_password . '</strong>', '<strong>' . $getservices . '</strong>');
                     $mail = new Message();
                     $transport = new \Zend\Mail\Transport\Sendmail();
                     $html = new MimePart(preg_replace($patterns, $replacements, $template['content']));
                     $html->type = "text/html";
                     $body = new MimeMessage();
                     $body->setParts(array($html));
                     $url = $api_url . "/api/useractivity/";
                     $data = array('email' => $content['email'], 'password' => $random_password);
                     $data['op'] = 'resetpassword';
                     $res = $api->curl($url, $data, "POST");
                     if ($res->getStatusCode() == 200) {
                         $mail->setBody($body)->setFrom($template['fromEmail'], 'Ovessence')->addTo($content['email'], '')->setSubject($template['subject']);
                         $transport->send($mail);
                         $error = false;
                         $msg = "A mail has been send to " . $content['email'] . " ,Please check ";
                     } else {
                         $error = true;
                         $msg = "Unable to set password..!! ";
                     }
                     // echo json_encode(array('status' => 1, 'msg' => 'Business card sent to the email address..!!'));
                 } else {
                     $error = true;
                     $msg = "Unable to find mail template..!!";
                     //echo json_encode(array('status' => 0, 'msg' => 'Unable to find mail template..!!'));
                 }
                 /*
                                     $content = json_decode($res->getBody(), true);
                                                         
                                     $forget_pass_url = $api_url."/api/emailtemplate/3/";
                                     
                                     $forget_pass_res = $api->curl($forget_pass_url, array(), "GET");
                                     //print_r($forget_pass_res); die;
                                     if($forget_pass_res->getStatusCode() == 200) {
                                         $template = json_decode($forget_pass_res->getBody(), true);
                                         
                                         $template_data = str_replace(array('{{user_first_name}}', '{{username}}', '{{password}}' ), array($content['first_name'], $content['user_name'], $random_password), $template['content']);
                                         
                                         $wp_user_detail = $auth->wordpress_user_detail($content['user_name']);
                                         $auth->wordpress_set_password($random_password, $wp_user_detail->ID);
                                         
                                         $reset_data['op'] = 'resetpassword';
                                         $reset_data['email'] = $content['email'];
                                         $reset_data['password'] = $random_password;
                 						$reset_res = $api->curl($url, $reset_data, "POST");
                                         
                                         $mail = new \Zend\Mail\Message();                 
                                     
                                         $html = new \Zend\Mime\Part($template_data);
                                         $html->type = "text/html";
                 
                                         $body = new \Zend\Mime\Message();
                                         $body->setParts(array($html));
                 						//$content['email']
                                         $mail->setBody($body)
                                              ->setFrom($template['fromEmail'], 'Ovessence')
                                              ->addTo('*****@*****.**', $content['first_name'].' '.$content['last_name'])
                                              ->setSubject($template['subject']);
                                         $transport = new \Zend\Mail\Transport\Sendmail($template['fromEmail']);
                                         $transport->send($mail);                    
                                         $error = "A mail has been send to ". $content['email'] ." ,Please check ";
                                     
                                     }*/
             } else {
                 if ($res->getStatusCode() == "404") {
                     $error = true;
                     $msg = "User with given email does not exist";
                 } else {
                     $error = true;
                     $msg = $res->getReasonPhrase();
                 }
             }
         }
     }
     $view = new ViewModel(array('form' => $form, 'error' => $error, 'msg' => $msg));
     $view->setTemplate('application/forgetPassword/index.phtml');
     return $view;
 }
コード例 #13
0
ファイル: Transactions.php プロジェクト: riteshkmr33/ovessnce
 public function updateCard($config, $data)
 {
     $common = new Common();
     $updateData = array();
     $oldCardExists = false;
     $session = new Container('frontend');
     \Braintree_Configuration::environment($config['payment_gateway']['tree_env']);
     \Braintree_Configuration::merchantId($config['payment_gateway']['merchant_id']);
     \Braintree_Configuration::publicKey($config['payment_gateway']['public_key']);
     \Braintree_Configuration::privateKey($config['payment_gateway']['private_key']);
     $cardDetails = $common->getUserCardDetails($config['api_url']['value'], array('user_id' => $session->userid));
     //print_r($cardDetails); exit;
     $card = isset($cardDetails[0]) ? $cardDetails[0] : '';
     if (!is_array($data)) {
         parse_str($data, $data);
     }
     if (isset($card) && is_array($card)) {
         try {
             $result = \Braintree_CreditCard::find($card['creditCardDetails_token']);
             $oldCardExists = true;
         } catch (\Exception $ex) {
             $oldCardExists = false;
             //echo $ex->getMessage();
         }
         try {
             $delete = \Braintree_CreditCard::delete($card['creditCardDetails_token']);
         } catch (\Exception $ex) {
             //echo $ex->getMessage();
         }
     }
     if (!isset($data['creditCardDetails_token']) && !isset($data['customerDetails_id'])) {
         $result = \Braintree_CreditCard::create(array('customerId' => isset($card['customerDetails_id']) ? $card['customerDetails_id'] : '', 'number' => $data['card_no'], 'cvv' => $data['cvv'], 'expirationDate' => $data['month'] . '/' . $data['year'], 'cardholderName' => $data['name_on_card'], 'options' => array('makeDefault' => true)));
         if ($result->success) {
             $data['creditCardDetails_token'] = $result->creditCard->token;
             $data['customerDetails_id'] = $result->creditCard->customerId;
         } else {
             return array('status' => 0, 'msg' => $result->message, 'errors' => $result->errors->deepAll());
         }
     }
     $updateData['user_id'] = $session->userid;
     $updateData['card_expiration_hash'] = isset($data['card_expiration_hash']) ? $data['card_expiration_hash'] : md5($data['month'] . '-' . $data['Year']);
     $updateData['creditCardDetails_token'] = $data['creditCardDetails_token'];
     $updateData['customerDetails_id'] = $data['customerDetails_id'];
     isset($card['use_for_renew']) ? $updateData['use_for_renew'] = $card['use_for_renew'] : '';
     isset($data['use_for_renew']) ? $updateData['use_for_renew'] = $data['use_for_renew'] : '';
     $res = isset($card['id']) ? $this->api->curl($config['api_url']['value'] . '/api/card_details/' . $card['id'] . '/', $updateData, 'PUT') : $this->api->curl($config['api_url']['value'] . '/api/card_details/', $updateData, 'POST');
     if ($res->getStatusCode() == 200 || $res->getStatusCode() == 201) {
         return array('status' => 1, 'msg' => 'Card details successfully updated..!!');
     } else {
         return array('status' => 1, 'msg' => 'Failed to update card details..!!', 'errors' => json_decode($res->getBody(), true));
     }
 }
コード例 #14
0
 public function indexAction()
 {
     $fb_login = new Container('facebook');
     $google_login = new Container('google');
     $linkedin_login = new Container('linkedin');
     $social_media_id = '';
     if (isset($fb_login->social_id)) {
         $common_object = $fb_login;
         $social_media_id = $fb_login->social_id;
     }
     if (isset($google_login->social_id)) {
         $common_object = $google_login;
         $social_media_id = $google_login->social_id;
     }
     if (isset($linkedin_login->social_id)) {
         $common_object = $linkedin_login;
         $social_media_id = $linkedin_login->social_id;
     }
     $api = new Api();
     $auth = new FrontEndAuth();
     $session = new Container('frontend');
     $loginError = "";
     $redirectUrl = array('controller' => 'index');
     if ($auth->hasIdentity()) {
         //$redirectUrl = array('controller'=>'index');
         //$redirectUrl = array('controller'=>'login', 'action' => 'dashboard');
         return $this->redirect()->toRoute(null, $redirectUrl);
     }
     //var_dump($session->user_name); die;
     $common = new Common();
     $form = new LoginForm();
     $register_form = new RegisterForm();
     $request = $this->getRequest();
     if ($request->isPost()) {
         //die('hello');
         $register = new Register();
         $register_form->setInputFilter($register->getInputFilter());
         $data = $request->getPost()->toArray();
         $register_form->setData($data);
         //$validation_result = json_decode($this->passwordValidation($data['confirm_password']), true);
         if ($register_form->isValid()) {
             $loginError = $validation_result['msg'];
             //if(!$validation_result['error']){
             $loginError = '';
             unset($data['confirm_password'], $data['register_submit']);
             //die('hello');
             $api_url = $this->getServiceLocator()->get('Config')['api_url']['value'];
             $url = $api_url . "/api/users/";
             $data['op'] = 'register';
             $data['social_media_id'] = $social_media_id;
             $data['status_id'] = $data['user_type_id'] == 4 ? 9 : 5;
             $res = $api->curl($url, $data, "POST");
             if ($res->getStatusCode() == 201) {
                 $content = json_decode($res->getBody(), true);
                 $common->addChatAccount($this->getServiceLocator()->get('Config')['chatpath']['url'], $content, $data, $request);
                 // Creating account for live chat
                 $newsletter = $content['user_type_id'] == 3 ? 1 : 4;
                 $common->addFeature($api_url, array('user_id' => $content['id'], 'email' => 1, 'sms' => 1, 'chat' => 0, 'newsletter' => $newsletter));
                 // Adding user feature setting
                 $common->sendMail($api_url, $content['email'], '', 21, '', array('/{{user_name}}/i'), array($content['first_name'] . ' ' . $content['last_name']));
                 $session->userid = $content['id'];
                 $session->first_name = $content['first_name'];
                 $session->last_name = $content['last_name'];
                 $session->email = $content['email'];
                 $session->user_name = $content['user_name'];
                 $session->user_type_id = $content['user_type_id'];
                 $session->user_data = $content;
                 // adding default subscription
                 if ($session->user_type_id == 3) {
                     $common->addSubscription($api_url, array('user_id' => $session->userid));
                 }
                 $auth->wordpress_create_user($session->user_name, $session->email, $data['confirm_password']);
                 $auth->wordpress_login($session->user_name);
                 $bookingData = new Container('bookingData');
                 //var_dump($res); die;
                 //return ($session->user_type_id == 4) ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard'));
                 if (isset($bookingData->bookingData)) {
                     return $this->redirect()->toRoute('booking', array('action' => 'schedule', 'id' => $bookingData->sp));
                 } else {
                     if ($this->getRequest()->getQuery('lasturl') != '') {
                         return $this->redirect()->toUrl($this->getRequest()->getQuery('lasturl'));
                     } else {
                         return $session->user_type_id == 4 ? $this->redirect()->toRoute('consumer', array('action' => 'dashboard')) : $this->redirect()->toRoute('practitioner', array('action' => 'dashboard'));
                     }
                 }
                 //return $this->redirect()->toRoute(null, $redirectUrl);
             } else {
                 $errors = json_decode($res->getBody(), true);
                 foreach ($errors as $key => $value) {
                     if (isset($value[0])) {
                         $register_form->setMessages(array($key => array($value[0])));
                     }
                 }
                 $this->errors = $register_form->getMessages();
                 // added by Ritesh to get error messages
             }
             //var_dump($errors); die;
             //}// validation condition
         } else {
             $this->errors = $register_form->getMessages();
         }
     }
     $view = new ViewModel(array('form' => $form, 'register_form' => $register_form, 'loginError' => $loginError, 'fb_login' => $common_object, 'errors' => $this->errors));
     $view->setTemplate('application/login/index.phtml');
     return $view;
 }
コード例 #15
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;
 }