Exemplo n.º 1
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();
     $common = new Common();
     $practitioners = new Practitioners();
     $session = new Container('frontend');
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     if ($auth->hasIdentity(3)) {
         // service provider invoice
         $data = $bookingModel->getBookings($api_url, '', '', '', '', '', '', $id, 'subscription');
         $userDetails = $practitioners->getSPDetails($api_url, $session->userid);
     } 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) {
         if ($this->getRequest()->getQuery('print') == 1) {
             $view = new viewModel(array('booking_details' => $data['results'], 'user_details' => $userDetails));
             $view->setTemplate('application/membership/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);
             return new viewModel(array('booking_details' => $data['results'], 'user_details' => $userDetails, 'id' => $id, 'banners' => $banners));
         }
     } else {
         return $this->redirect()->toRoute('home');
     }
     return new viewModel($this->invoicedetails());
 }
Exemplo n.º 2
0
 public function viewmessageAction()
 {
     $auth = new FrontEndAuth();
     $id = $this->params()->fromRoute('id');
     if ($id == '') {
         die('redirect to consumer inbox');
     }
     if (!$auth->hasIdentity(4)) {
         return $this->redirect()->toUrl('/login');
     }
     $session = new Container('frontend');
     $api = new Api();
     $api_url = $this->getServiceLocator()->get('config')['api_url']['value'];
     $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_c'] == 0) {
             $res_master = $api->curl($url_master, array('readFlag_c' => 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_practitioner = new Practitioners();
     $model_consumer = new Consumers();
     //$model_common = new Common;
     $model_common = $this->getServiceLocator()->get('Application/Model/Common');
     $notifications = $model_practitioner->getNotifications($api_url, 'consumer');
     $consumer_details = $model_consumer->getConsumerdetails($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";
                 //$practitioner_data = $model_practitioner->getSPDetails($api_url, $id);
                 $practitioner_data = $model_practitioner->getSPDetails($api_url, $data['to_user_id']);
                 if ($practitioner_data) {
                     $subscriptionDetails = $model_common->getSubscriptiondetails($api_url, $practitioner_data['id'], true);
                     $userFeatures = $model_common->getFeatures($api_url, $practitioner_data['id']);
                     if (count($practitioner_data['contact']) > 0) {
                         $contact_data = json_decode($practitioner_data['contact'][0], true);
                     }
                     $pattern = array('/{{reciever}}/i', '/{{sender}}/i');
                     $replace = array('<strong>' . $practitioner_data['first_name'] . ' ' . $practitioner_data['last_name'] . '</strong>', '<strong>' . $session->first_name . ' ' . $session->last_name . '</strong>');
                     if (isset($practitioner_data['email'])) {
                         if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(11, $subscriptionDetails['features']) && $userFeatures['email'] == 1) {
                             $model_common->sendMail($api_url, $practitioner_data['email'], '', 16, '', $pattern, $replace, '');
                         }
                     }
                     if (count($contact_data) > 0 && isset($contact_data['cellphone'])) {
                         $replace = array($practitioner_data['first_name'] . ' ' . $practitioner_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['cellphone'], 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 = $model_common->getBanner($api_url, 5);
     return new ViewModel(array('master_message' => $result_master, 'replies' => $result_replies, 'current_user_id' => $session->userid, 'notifications' => $notifications, 'current_user_id' => $session->userid, 'avtar_url' => $consumer_details['avtar_url'], 'first_name' => $consumer_details['first_name'], 'last_name' => $consumer_details['last_name'], 'banners' => $banners));
 }
 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;
 }
Exemplo n.º 4
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;
 }