Esempio n. 1
0
 * Portions created by vtiger are Copyright (C) vtiger.
 * All Rights Reserved.
*
 ********************************************************************************/
ini_set('max_execution_time', '1800');
require_once "modules/Reports/ReportRun.php";
require_once "modules/Reports/Reports.php";
//require('include/fpdf/fpdf.php');
require 'include/tcpdf/tcpdf.php';
$language = $_SESSION['authenticated_user_language'] . '.lang.php';
require_once "include/language/{$language}";
$reportid = vtlib_purify($_REQUEST["record"]);
$oReport = new Reports($reportid);
//Code given by Csar Rodrguez for Rwport Filter
$filtercolumn = $_REQUEST["stdDateFilterField"];
$filter = $_REQUEST["stdDateFilter"];
$oReportRun = new ReportRun($reportid);
$startdate = $_REQUEST['startdate'];
$enddate = $_REQUEST['enddate'];
if (!empty($startdate) && !empty($enddate) && $startdate != "0000-00-00" && $enddate != "0000-00-00") {
    $date = new DateTimeField($_REQUEST['startdate']);
    $endDate = new DateTimeField($_REQUEST['enddate']);
    $startdate = $date->getDBInsertDateValue();
    //Convert the user date format to DB date format
    $enddate = $endDate->getDBInsertDateValue();
    //Convert the user date format to DB date format
}
$filterlist = $oReportRun->RunTimeFilter($filtercolumn, $filter, $startdate, $enddate);
$pdf = $oReportRun->getReportPDF($filterlist);
$pdf->Output('Reports.pdf', 'D');
exit;
Esempio n. 2
0
 public function sendEmail()
 {
     require_once 'modules/Emails/mail.php';
     require_once 'modules/Emails/Emails.php';
     global $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $currentModule;
     $recipientEmails = $this->getRecipientEmails();
     $emails_to = '';
     foreach ($recipientEmails as $name => $email) {
         $emails_to .= $email . ',';
     }
     $emails_to = trim($emails_to, ',');
     $currentTime = date('Y-m-d H:i:s');
     $subject = $this->reportname . ' - ' . $currentTime . ' (' . DateTimeField::getDBTimeZone() . ')';
     $contents = getTranslatedString('LBL_AUTO_GENERATED_REPORT_EMAIL', $currentModule) . '<br/><br/>';
     $contents .= '<b>' . getTranslatedString('LBL_REPORT_NAME', $currentModule) . ' :</b> ' . $this->reportname . '<br/>';
     $contents .= '<b>' . getTranslatedString('LBL_DESCRIPTION', $currentModule) . ' :</b><br/>' . $this->reportdescription . '<br/><br/>';
     $baseFileName = utf8_decode(preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $this->reportname) . '_' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', date('YmdHis')));
     $oReportRun = new ReportRun($this->id);
     $reportFormat = $this->scheduledFormat;
     $attachments = array();
     if ($reportFormat == 'pdf' || $reportFormat == 'both') {
         $fileName = $baseFileName . '.pdf';
         $filePath = 'storage/' . $fileName;
         $attachments[$fileName] = $filePath;
         $_REQUEST['filename_hidden_pdf'] = $filePath;
         $pdf = $oReportRun->getReportPDF(NULL);
         $pdf->Output($filePath, 'F');
     }
     if ($reportFormat == 'excel' || $reportFormat == 'both') {
         $fileName = $baseFileName . '.xls';
         $filePath = 'storage/' . $fileName;
         $attachments[$fileName] = $filePath;
         $_REQUEST['filename_hidden_xls'] = $filePath;
         $oReportRun->writeReportToExcelFile($filePath, NULL);
     }
     $sendifempty = GlobalVariable::getVariable('Report_Send_Scheduled_ifEmpty', 1);
     if ($sendifempty or $oReportRun->number_of_rows > 0) {
         $mail_status = send_mail('Emails', $emails_to, $HELPDESK_SUPPORT_NAME, $HELPDESK_SUPPORT_EMAIL_ID, $subject, $contents, '', '', 'attReports');
         foreach ($attachments as $attachmentName => $path) {
             unlink($path);
         }
     }
 }
 public function sendEmail()
 {
     global $currentModule;
     require_once 'vtlib/Vtiger/Mailer.php';
     $vtigerMailer = new Vtiger_Mailer();
     $recipientEmails = $this->getRecipientEmails();
     foreach ($recipientEmails as $name => $email) {
         $vtigerMailer->AddAddress($email, $name);
     }
     $currentTime = date('Y-m-d H:i:s');
     $subject = $this->reportname . ' - ' . $currentTime . ' (' . DateTimeField::getDBTimeZone() . ')';
     $contents = getTranslatedString('LBL_AUTO_GENERATED_REPORT_EMAIL', $currentModule) . '<br/><br/>';
     $contents .= '<b>' . getTranslatedString('LBL_REPORT_NAME', $currentModule) . ' :</b> ' . $this->reportname . '<br/>';
     $contents .= '<b>' . getTranslatedString('LBL_DESCRIPTION', $currentModule) . ' :</b><br/>' . $this->reportdescription . '<br/><br/>';
     $vtigerMailer->Subject = $subject;
     $vtigerMailer->Body = $contents;
     $vtigerMailer->ContentType = "text/html";
     $baseFileName = preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $this->reportname) . '_' . preg_replace('/[^a-zA-Z0-9_-\\s]/', '', $currentTime);
     $oReportRun = new ReportRun($this->id);
     $reportFormat = $this->scheduledFormat;
     $attachments = array();
     if ($reportFormat == 'pdf' || $reportFormat == 'both') {
         $fileName = $baseFileName . '.pdf';
         $filePath = 'storage/' . $fileName;
         $attachements[$fileName] = $filePath;
         $pdf = $oReportRun->getReportPDF();
         $pdf->Output($filePath, 'F');
     }
     if ($reportFormat == 'excel' || $reportFormat == 'both') {
         $fileName = $baseFileName . '.xls';
         $filePath = 'storage/' . $fileName;
         $attachements[$fileName] = $filePath;
         $oReportRun->writeReportToExcelFile($filePath);
     }
     foreach ($attachements as $attachmentName => $path) {
         $vtigerMailer->AddAttachment($path, $attachmentName);
     }
     $vtigerMailer->Send(true);
     foreach ($attachements as $attachmentName => $path) {
         unlink($path);
     }
 }