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; }