Esempio n. 1
0
 function endPostProcess(&$rows = null)
 {
     if ($this->_outputMode == 'print' || $this->_outputMode == 'pdf' || $this->_sendmail) {
         $templateFile = parent::getTemplateFileName();
         $content = $this->_formValues['report_header'] . CRM_Core_Form::$_template->fetch($templateFile) . $this->_formValues['report_footer'];
         if ($this->_sendmail) {
             if (CRM_Report_Utils_Report::mailReport($content, $this->_id, $this->_outputMode)) {
                 CRM_Core_Session::setStatus(ts("Report mail has been sent."));
             } else {
                 CRM_Core_Session::setStatus(ts("Report mail could not be sent."));
             }
             if ($this->get('instanceId')) {
                 CRM_Utils_System::civiExit();
             }
             CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
         } else {
             if ($this->_outputMode == 'print') {
                 echo $content;
             } else {
                 if ($chartType = CRM_Utils_Array::value('charts', $this->_params)) {
                     $config =& CRM_Core_Config::singleton();
                     //get chart image name
                     $chartImg = $chartType . '_' . $this->_id . '.png';
                     //get image url path
                     $uploadUrl = str_replace('persist/contribute', 'upload/openFlashChart', $config->imageUploadURL);
                     $uploadUrl .= $chartImg;
                     //get image doc path to overwrite
                     $uploadImg = $config->uploadDir . 'openFlashChart/' . $chartImg;
                     //Load the image
                     $chart = imagecreatefrompng($uploadUrl);
                     //convert it into formattd png
                     header('Content-type: image/png');
                     //overwrite with same image
                     imagepng($chart, $uploadImg);
                     //delete the object
                     imagedestroy($chart);
                 }
                 require_once 'CRM/Utils/PDF/Utils.php';
                 CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf");
             }
         }
         CRM_Utils_System::civiExit();
     } else {
         if ($this->_outputMode == 'csv') {
             CRM_Report_Utils_Report::export2csv($this, $rows);
         } else {
             if ($this->_outputMode == 'group') {
                 $group = $this->_params['groups'];
                 CRM_Report_Utils_Report::add2group($this, $group);
             } else {
                 if ($this->_instanceButtonName == $this->controller->getButtonName()) {
                     require_once 'CRM/Report/Form/Instance.php';
                     CRM_Report_Form_Instance::postProcess($this);
                 }
             }
         }
     }
 }
Esempio n. 2
0
 function endPostProcess(&$rows = null)
 {
     if ($this->_outputMode == 'print' || $this->_outputMode == 'pdf' || $this->_sendmail) {
         $templateFile = parent::getTemplateFileName();
         $content = $this->_formValues['report_header'] . CRM_Core_Form::$_template->fetch($templateFile) . $this->_formValues['report_footer'];
         if ($this->_sendmail) {
             if (CRM_Report_Utils_Report::mailReport($content, $this->_id, $this->_outputMode)) {
                 CRM_Core_Session::setStatus(ts("Report mail has been sent."));
             } else {
                 CRM_Core_Session::setStatus(ts("Report mail could not be sent."));
             }
             if ($this->get('instanceId')) {
                 exit;
             }
             CRM_Utils_System::redirect(CRM_Utils_System::url(CRM_Utils_System::currentPath(), 'reset=1'));
         } else {
             if ($this->_outputMode == 'print') {
                 echo $content;
             } else {
                 require_once 'CRM/Utils/PDF/Utils.php';
                 CRM_Utils_PDF_Utils::html2pdf($content, "CiviReport.pdf");
             }
         }
         exit;
     } else {
         if ($this->_outputMode == 'csv') {
             CRM_Report_Utils_Report::export2csv($this, $rows);
         } else {
             if ($this->_outputMode == 'group') {
                 $group = $this->_params['groups'];
                 CRM_Report_Utils_Report::add2group($this, $group);
             } else {
                 if ($this->_instanceButtonName == $this->controller->getButtonName()) {
                     require_once 'CRM/Report/Form/Instance.php';
                     CRM_Report_Form_Instance::postProcess($this);
                 }
             }
         }
     }
 }