示例#1
0
 /**
  * Spawns a background process to generate a new report file.
  */
 public function generateAction()
 {
     $report = $this->_helper->db->findById();
     $reportFile = new Reports_File();
     $reportFile->report_id = $report->id;
     $reportFile->type = $_GET['format'];
     $reportFile->status = Reports_File::STATUS_STARTING;
     // Send the base URL to the background process for QR Code
     // This should be abstracted out to work more generally for
     // all generators.
     if ($reportFile->type == 'PdfQrCode') {
         $reportFile->options = serialize(array('baseUrl' => WEB_ROOT));
     }
     $errors = array();
     if (!$reportFile->canStore($errors)) {
         $errorMessage = __('The report cannot be saved.  Please check your report storage settings.');
         foreach ($errors as $error) {
             $errorMessage .= ' ' . $error;
         }
         $this->_helper->flashMessenger($errorMessage, 'error');
     } else {
         $reportFile->save();
         $this->_jobDispatcher->setQueueName('reports');
         $this->_jobDispatcher->sendLongRunning('Reports_GenerateJob', array('fileId' => $reportFile->id));
     }
     $this->_helper->redirector->gotoRoute(array('module' => 'reports', 'id' => $report->id, 'action' => 'show'), 'default');
 }