コード例 #1
0
 public function run()
 {
     $month = Zend_Registry::get('invoice_month');
     $year = Zend_Registry::get('invoice_year');
     $invoice = new Datasource_Core_Agent_Invoice();
     $email_status = new Datasource_Core_Agent_InvoiceEmailStatus();
     $agent_manager = new Manager_Core_Agent();
     // Get agent details that already invoiced for the reporting month
     $agents = $invoice->getAgentDetailsForInvoicing($month . "_" . $year);
     if ($agents) {
         foreach ($agents as $agent) {
             if ($agent['invoicesend'] === 'email' || $agent['invoicesend'] === 'both') {
                 if ($agent['email_address']) {
                     //if ($agent_manager->sendEmailNotification($agent['agentSchemeNo'], $agent['email_address'], $month, $year)) {
                     if ($agent['id']) {
                         if (!$agent['emailSent']) {
                             $agent_manager->sendEmailNotification($agent['agentSchemeNo'], $agent['email_address'], $month, $year);
                             $email_status->updateInvoiceEmailStatus($agent['agentSchemeNo']);
                         }
                     } else {
                         $agent_manager->sendEmailNotification($agent['agentSchemeNo'], $agent['email_address'], $month, $year);
                         $email_status->insertInvoiceEmailStatus($agent['agentSchemeNo'], $month, $year);
                     }
                     //}
                 }
             }
         }
     } else {
         echo "No agents to process\n";
     }
 }
コード例 #2
0
 /**
  * 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');
 }