/** * This action can be triggered within email sent to the agent * by clicking the link to view the invoice */ public function viewInvoiceAction() { $invoice = new Datasource_Core_Agent_Invoice(); $invoiceStatus = new Datasource_Core_Agent_InvoiceViewStatus(); /* 1. Get invoice filename from invoicing table - homeletuk_com.invoiceHashLookup 2. Make request for url from fileserver using Zend_XmlRpc_Client 3. Redirect client to url */ $filename = $invoice->getInvoiceFilename($this->_agentSchemeNumber, $_GET['month'], $_GET['year']); $rpcclient = new Zend_XmlRpc_Client($this->_params->fileserver->requestHost); $retrieveurl = null; try { $retrieveurl = $rpcclient->call('authenticate', array($filename, 0)); $digest = hash('sha256', $filename . 0); } catch (Zend_XmlRpc_Client_FaultException $ex) { $retrieveurl = null; // Ensure url is null to skip next section } if (isset($retrieveurl)) { // Insert agents invoiceView flag $invoiceStatus->insertInvoiceViewStatus($this->_agentSchemeNumber, $this->_agentId, $this->_agentrealname, $_GET['month'], $_GET['year']); $this->_redirect($this->_params->fileserver->request . $retrieveurl . '?filehash=' . $digest); } // Some kind of error, report error page $this->render('invoices_report_error'); }