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 getSplistByFilter($data, $api_url) { if ($data['service_id'] == "" && $data['auth_to_issue_insurence_rem_receipt'] == "" && $data['days_id'] == "" && $data['avg_rating'] == "" && $data['practitioners_name'] == "" && $data['company_name'] == "" && $data['booking_no'] == "" && $data['price'] == "" && $data['feedback_filter'] == "" && $data['distance'] == "" && $data['association_member'] == "" && $data['country_id'] == "" && $data['state_id'] == "" && $data['city'] == "" && $data['maxPrice'] == "0" && $data['minPrice'] == "0" && $data['zip_code'] == "" && $data['treatmentLength'] == "" && $data['treatment_for_physically_disabled_person'] == "" && $data['id'] == "" && $data['exclude_user'] == "" && isset($data['sp_availability']) && $data['sp_availability'] == "" && $data['location_type'] == "") { $data['date_range_filter'] = "1"; } $zip_code = $data['zip_code']; $data['status_id'] = 9; $sp_list = array(); $bookingModel = new Bookings(); $res = $this->api->curl($api_url . "/api/spusers/", $data, "GET"); if ($res->getStatusCode() == 200) { $content = json_decode($res->getBody(), true); isset($content['next']) ? $sp_list['next'] = $content['next'] : ($sp_list['next'] = ''); isset($content['count']) ? $sp_list['count'] = $content['count'] : ($sp_list['count'] = ''); if (count($content['results']) > 0) { $i = 0; $distance = array(); foreach ($content['results'] as $data) { $sp_list['result'][$i]['id'] = $data['id']; $sp_list['result'][$i]['first_name'] = $data['first_name']; $sp_list['result'][$i]['last_name'] = $data['last_name']; $sp_list['result'][$i]['avtar_url'] = $data['avtar_url']; $sp_list['result'][$i]['email'] = $data['email']; $sp_list['result'][$i]['user_type_id'] = $data['user_type_id']; $sp_list['result'][$i]['login_user_type_id'] = $userType; $sp_list['result'][$i]['rating'] = $this->getSPRatings($data['id'], $api_url); if (count($data['details']) > 0) { foreach ($data['details'] as $sp_details) { $details = json_decode($sp_details, true); $sp_list['result'][$i]['years_of_experience'] = $details['years_of_experience']; $sp_list['result'][$i]['degrees'] = $details['degrees']; $sp_list['result'][$i]['specialties'] = $details['specialties']; $sp_list['result'][$i]['work_days'] = $this->getSPWorkdays($data['id'], $api_url); } } /* Calculating nearest distance starts here */ $sp_list['result'][$i]['distance'] = "NA"; if (count($data['work_address']) > 0 && $zip_code != '') { $all_distances = array(); foreach ($data['work_address'] as $raw_add) { $address = json_decode($raw_add, true); $zips = array('consumer_zip' => $zip_code, 'practitioner_zip' => $address['zip_code']); $dist = $this->getDistance($api_url, $zip_code, $address['zip_code']); is_numeric($dist) ? $all_distances[] = round($dist) : ''; } $sp_list['result'][$i]['distance'] = count($all_distances) > 0 ? min($all_distances) : "NA"; $distance[$i] = is_numeric($sp_list['result'][$i]['distance']) ? $sp_list['result'][$i]['distance'] : 0; } /* Calculating nearest distance ends here */ /* Code added by Ritesh starts here */ $verification_details = $this->getSPvarification($data['id'], $api_url); $sp_list['result'][$i]['verified'] = $verification_details['verified']; /* Code added by Ritesh ends here */ if (count($data['contact']) > 0) { foreach ($data['contact'] as $sp_contacts) { $details = json_decode($sp_contacts, true); $sp_list['result'][$i]['cellphone'] = $details['cellphone']; } } $spPrice = array(); $price_arr = array(); if (count($data['service']) > 0) { foreach ($data['service'] as $value) { $spPrice[] = json_decode($value, true); } } if (count($spPrice) > 0) { foreach ($spPrice as $value) { $price_arr[] = $value['price']; } } count($price_arr) > 0 ? $sp_list['result'][$i]['price'] = min($price_arr) : ($sp_list['result'][$i]['price'] = ''); //$sp_list['result'][$i]['price'] = min($sp_price); $sp_list['result'][$i]['bookings_count'] = $bookingModel->getBookingsCount($api_url, $data['id']); $sp_list['result'][$i]['reviews_count'] = $this->getReviewscount($data['id'], $api_url); $i++; } //echo '<pre>'; print_r($distance); //exit; if (count($distance) > 0) { $sortedDistance = $distance; sort($sortedDistance, SORT_NUMERIC); $sp_list['result'] = $this->sortArrayByArray($sp_list['result'], $sortedDistance, $distance); } //echo '<pre>'; print_r($sp_list['result']); exit; if ($sp_list['next'] != '') { $str = str_replace("page", "@!##", $sp_list['next']); $str_arr = explode('@!##=', $str); $next = explode('&', $str_arr[1]); $sp_list['next'] = $next[0]; } echo json_encode($sp_list); exit; } else { $sp_list = ''; echo json_encode($sp_list); // no data found exit; } } else { $sp_list = array('next' => '', 'count' => '', 'result' => ''); echo json_encode($sp_list); exit; } }
public function getslotsAction() { $request = $this->getRequest(); if ($request->isPost()) { $bookingModel = new Bookings(); $session = new Container('frontend'); $service_duration = $request->getPost('duration', 0); $user = $request->getPost('user_id', $session->userid); $date = $request->getPost('selectedDate', date('Y-m-d')); $address = $request->getPost('address_id'); $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; $availableSlots = $bookingModel->getAvailableSlots($api_url, $user, date('Y-m-d', strtotime($date)), $service_duration, $address); $slots = array(); foreach ($availableSlots as $slot) { $slots[] = array('start' => date('H:i', strtotime($slot['start'])), 'end' => date('H:i', strtotime($slot['end']))); } echo json_encode($slots); } exit; }
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 mannualbookingAction() { $request = $this->getRequest(); if ($request->isPost()) { $bookingModel = new Bookings(); $session = new Container('frontend'); parse_str($request->getPost('bookingData'), $bookingData); $name = explode(' ', $bookingData['username']); $bookingData['first_name'] = $name[0]; $bookingData['last_name'] = isset($name[1]) ? $name[1] : ''; $bookingData['booked_date'] = date('Y-m-d H:i:s', strtotime(str_replace('/', '-', $bookingData['booking_time']))); //echo '<pre>'; print_r($bookingData); exit; $bookingData['payment_status'] = 7; $bookingData['user_id'] = ''; $bookingData['service_provider_id'] = $session->userid; $bookingData['status_id'] = 1; $api_url = $this->getServiceLocator()->get('config')['api_url']['value']; if ($bookingData['booking_id'] != '') { if ($bookingModel->changeBookingStatus($api_url, $bookingData['booking_id'], $bookingData['booking_status'], $this->getServiceLocator()->get('Application\\Model\\Common'))) { echo json_encode(array('status' => 1, 'msg' => 'Status updated successfully', 'data' => $bookingData['booking_id'])); } else { echo json_encode(array('status' => 0, 'msg' => 'Failed to update status', 'data' => $bookingData['booking_id'])); } } else { unset($bookingData['booking_id']); echo json_encode($bookingModel->addManualBooking($api_url, $bookingData)); } } exit; }