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()); }
public function transactionsAction() { $api = new Api(); $trans = new Transactions(); $model = new Practitioners(); $common = new Common(); $bookingModel = new Bookings(); $session = new Container('frontend'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $request = $this->getRequest(); if ($request->isPost()) { $page = $request->getPost('page'); $recordsPerPage = $request->getPost('items'); switch ($request->getPost('action')) { case 'subscriptions': $subscriptions = $bookingModel->getBookings($api_url, '', $session->userid, '', $page, $recordsPerPage, '', '', 'subscription'); echo json_encode($subscriptions['results']); break; case 'bookings': $bookings = $bookingModel->getBookings($api_url, $session->userid, '', '', $page, $recordsPerPage); echo json_encode($bookings['results']); break; } exit; } $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), 'booking_total' => $bookingModel->getBookings($api_url, $session->userid)['count'], 'subs_total' => $bookingModel->getBookings($api_url, '', $session->userid, '', '', '', '', '', 'subscription')['count'], 'banners' => $banners)); }
public function isaccountRemovable($api_url, $type = 'practitioner') { $session = new Container('frontend'); if ($session->user_type_id === 3) { // practitioner - check for any active bookings $booking_model = new Bookings(); $bookingArr = $booking_model->getBookings($api_url, $session->userid, "", "", "", "", "", ""); $date1 = new \DateTime("now"); if (isset($bookingArr['results']) && count($bookingArr['results']) > 0) { foreach ($bookingArr['results'] as $arr) { $date2 = new \DateTime($arr['booked_date']); if ($date1 < $date2 && $arr['status_id'] != "6") { // future booking cannot deactivate account return false; exit; } else { return true; } } } else { // no future booking at all , can deactivate his account return true; exit; } } else { return false; } }
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)); }
public function autorenewcodeAction($api_url, $common, $detail) { $data = array('user_id' => $detail['user_id'], 'use_for_renew' => 1); $getCardDetails = $common->getUserCardDetails($api_url, $data); $card = end($getCardDetails); // Start:-- Get card details if ($card['creditCardDetails_token'] != '' && $card['customerDetails_id'] != '') { $bookingModel = new Bookings(); $trans = new Transactions(); $model = new Practitioners(); $transaction['amount'] = $detail['price']; //$details['price']; $transaction['creditCardDetails_token'] = $card['creditCardDetails_token']; //$getCardDetails['creditCardDetails_token']; $transaction['customerDetails_id'] = $card['customerDetails_id']; //$getCardDetails['customerDetails_id']; $result = $trans->processPayment($this->getServiceLocator()->get('Config'), $transaction, 1); $user_details = $model->getSPDetails($api_url, $detail['user_id']); // getting use email permissions $subscriptionDetails = $common->getSubscriptiondetails($api_url, $detail['user_id'], true); // getting service provider subscription details $userFeatures = $common->getFeatures($api_url, $detail['user_id']); // If transaction done if ($result['status'] == 1) { $sendMail = 0; // Not send mail // Start :- Get subscription end date if (isset($detail['duration_in'])) { if ($detail['duration_in'] == "1") { // move subs date $selected['duration'] year ahed $new_expireDate = date('Y-m-d', strtotime("+" . $detail['duration'] . " year", strtotime($detail['subscription_end_date']))); } else { if ($detail['duration_in'] == "2") { // move subs date $selected['duration'] month ahed $new_expireDate = date('Y-m-d', strtotime("+" . $detail['duration'] . " month", strtotime($detail['subscription_end_date']))); } else { if ($detail['duration_in'] == "3") { // move subs date $selected['duration'] month ahed $new_expireDate = date('Y-m-d', strtotime("+" . $detail['duration'] . " days", strtotime($detail['subscription_end_date']))); } else { // do nothing } } } } // End :- Get subscription end date $subscriptionData = array(); $subscriptionData['subscription_duration_id'] = $detail['subscription_duration_id']; $subscriptionData['payment_status_id'] = 7; $subscriptionData['site_commision'] = "0"; $subscriptionData['status_id'] = 1; $subscriptionData['user_id'] = $detail['user_id']; $subscriptionData['invoice_total'] = $detail['price']; $subscriptionData['created_by'] = $detail['user_id']; $subscriptionData['invoice_status'] = 1; $subscriptionData['amount'] = $detail['price']; $subscriptionData['currency'] = $detail['currency']; $subscriptionData['payment_date'] = date('Y-m-d H:i:s'); $subscriptionData['amount_paid'] = $detail['price']; $subscriptionData['transaction_id'] = $result['transaction_id']; $subscriptionData['payment_instrument_no'] = '5100'; $subscriptionData['payment_method_id'] = '1'; $subscriptionData['payment_status'] = 7; $subscriptionData['subscription_start_date'] = date('Y-m-d'); $subscriptionData['sale_type'] = 1; $subscriptionData['subscription_end_date'] = $new_expireDate; $response = $bookingModel->addBooking($api_url, $subscriptionData); if ($response['status'] == 1 && isset($response['id'])) { $user_details['address'] = json_decode($user_details['address'][0], true); $user_details['contact'] = json_decode($user_details['contact'][0], true); $data = $bookingModel->getBookings($api_url, '', '', '', '', '', '', $response['id'], 'subscription'); $view = new viewModel(array('booking_details' => $data['results'], 'user_details' => $user_details)); $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(); $output = $dompdf->output(); $attachment = new MimePart($output); $attachment->type = 'application/pdf'; $attachment->filename = 'invoice.pdf'; $attachment->encoding = \Zend\Mime\Mime::ENCODING_BASE64; $attachment->disposition = \Zend\Mime\Mime::DISPOSITION_ATTACHMENT; $patterns = array('/{{user_name}}/i'); $replaces = array('<strong>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . '</strong>'); if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(11, $subscriptionDetails['features']) || $userFeatures['email'] == 1) { $common->sendMail($api_url, $user_details['email'], '', 11, '', $patterns, $replaces, $attachment); } } } else { /* Make entry in failed payment history (pi21jan) */ $check_failedpayArr = array('user_id' => $detail['user_id'], 'date' => date('Y-m-d', strtotime('-3 days'))); $res = $common->check_failed_payment_history($api_url, $check_failedpayArr); if ($res) { // there is a failed payment in last three days then set the subscription to basic one $ongoing_subscription = $common->getSubscriptiondetails($api_url, $detail['user_id']); $common->addSubscription($api_url, array('user_id' => $detail['user_id'], 'id' => $ongoing_subscription[0]['id'])); $delete_arr = array('user_id' => $detail['user_id']); $common->deletefailedpayment($api_url, $delete_arr); } else { $failed_payment_data = array('user_id' => $detail['user_id'], 'sale_type' => '1', 'instrument_no' => '', 'date' => date('Y-m-d H:i:s')); $common->setfailedpayment($api_url, $failed_payment_data); } /* Failed payment code ends here */ $consumer = new Consumers(); // Start :- Get admin email id $res = $consumer->getConsumerdetails($api_url, 1); if (count($res) > 0) { $adminEmailId = $res['email']; } // End :- Get admin email id $pattern = array('/{{user_name}}/i', '/{{subscription_name}}/i', '/{{error_message}}/i'); $replace = array('<strong>' . $user_details['first_name'] . ' ' . $user_details['last_name'] . '</strong>', $detail['subscription_name'], '<strong>Transaction failed with message :- </strong>' . $result['msg']); if (isset($subscriptionDetails['features']) && is_array($subscriptionDetails['features']) && in_array(11, $subscriptionDetails['features']) || $userFeatures['email'] == 1) { $common->sendMail($api_url, $user_details['email'], '', 19, '', $pattern, $replace, '', $adminEmailId); } } } else { /* Make entry in failed payment history (pi21jan) */ $check_failedpayArr = array('user_id' => $detail['user_id'], 'date' => date('Y-m-d', strtotime('-3 days'))); $res = $common->check_failed_payment_history($api_url, $check_failedpayArr); if ($res) { // there is a failed payment in last three days then set the subscription to basic one $ongoing_subscription = $common->getSubscriptiondetails($api_url, $detail['user_id']); $common->addSubscription($api_url, array('user_id' => $detail['user_id'], 'id' => $ongoing_subscription[0]['id'])); $delete_arr = array('user_id' => $detail['user_id']); $common->deletefailedpayment($api_url, $delete_arr); } else { $failed_payment_data = array('user_id' => $detail['user_id'], 'sale_type' => '1', 'instrument_no' => '', 'date' => date('Y-m-d H:i:s')); $common->setfailedpayment($api_url, $failed_payment_data); } /* Failed payment code ends here */ } // End:-- Get card details }
public function detailsAction() { $request = $this->getRequest(); if ($request->isPost()) { $auth = new FrontEndAuth(); $bookingModel = new Bookings(); $id = $request->getPost('booking'); $session = new Container('frontend'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; if ($auth->hasIdentity(4)) { $bookingDetails = $bookingModel->getBookings($api_url, '', $session->userid, '', '', '', '', $id); } else { if ($auth->hasIdentity(3)) { $bookingDetails = $bookingModel->getBookings($api_url, $session->userid, '', '', '', '', '', $id); } else { echo json_encode(array('status' => 0, 'msg' => 'Not authorized to see the bookings details. Please login first..!!')); exit; } } if ($bookingDetails != false) { echo json_encode(array('status' => 1, 'data' => $bookingDetails['results'])); } else { echo json_encode(array('status' => 0, 'msg' => 'No booking found for this reference..!!')); } } exit; }