Exemple #1
0
 static function sendSystemMail($subject, $body, $attachments = NULL)
 {
     if ($subject == '' or $body == '') {
         return FALSE;
     }
     //Only send errors to TimeTrex support, not the customer.
     $cc = NULL;
     $to = '*****@*****.**';
     $from = APPLICATION_NAME . '@' . Misc::getHostName(FALSE);
     $headers = array('From' => $from, 'Subject' => $subject, 'cc' => $cc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     //$mail->setBody( $body );
     @$mail->getMIMEObject()->setTXTBody($body);
     if (is_array($attachments)) {
         foreach ($attachments as $attachment) {
             if (isset($attachment['data']) and isset($attachment['mime_type']) and isset($attachment['file_name'])) {
                 @$mail->getMIMEObject()->addAttachment($attachment['data'], $attachment['mime_type'], $attachment['file_name'], FALSE);
             }
         }
     }
     $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
     $retval = $mail->Send();
     return $retval;
 }
 function emailMessage()
 {
     Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10);
     $email_to_arr = $this->getEmailMessageAddresses();
     if ($email_to_arr == FALSE) {
         return FALSE;
     }
     //Get from User Object so we can include more information in the message.
     if (is_object($this->getFromUserObject())) {
         $u_obj = $this->getFromUserObject();
     } else {
         Debug::Text('From object does not exist: ' . $this->getFromUserID(), __FILE__, __LINE__, __METHOD__, 10);
         return FALSE;
     }
     $from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE);
     global $current_user, $config_vars;
     if (is_object($current_user) and $current_user->getWorkEmail() != '') {
         $reply_to = $current_user->getWorkEmail();
     }
     Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10);
     $to = array_shift($email_to_arr);
     Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($email_to_arr) and count($email_to_arr) > 0) {
         $bcc = implode(',', $email_to_arr);
     } else {
         $bcc = NULL;
     }
     Debug::Text('Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10);
     //Define subject/body variables here.
     $search_arr = array('#from_employee_first_name#', '#from_employee_last_name#', '#from_employee_default_branch#', '#from_employee_default_department#', '#from_employee_group#', '#from_employee_title#', '#company_name#', '#link#');
     $replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL);
     $email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME;
     $email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n";
     $email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n";
     $email_body .= $this->getSubject() != '' ? TTi18n::gettext('Subject') . ': ' . $this->getSubject() . "\n" : NULL;
     $email_body .= TTi18n::gettext('From') . ': #from_employee_first_name# #from_employee_last_name#' . "\n";
     $email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #from_employee_default_branch#' . "\n" : NULL;
     $email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #from_employee_default_department#' . "\n" : NULL;
     $email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #from_employee_group#' . "\n" : NULL;
     $email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #from_employee_title#' . "\n" : NULL;
     $email_body .= TTi18n::gettext('Link:') . ' <a href="http://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
     $email_body .= $replace_arr[6] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL;
     //Always put at the end
     $subject = str_replace($search_arr, $replace_arr, $email_subject);
     Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
     $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to);
     $body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>';
     Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     @$mail->getMIMEObject()->setHTMLBody($body);
     $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
     $retval = $mail->Send();
     if ($retval == TRUE) {
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
         return TRUE;
     }
     return TRUE;
     //Always return true
 }
 function emailMessage()
 {
     Debug::Text('emailMessage: ', __FILE__, __LINE__, __METHOD__, 10);
     $email_to_arr = $this->getEmailMessageAddresses();
     if ($email_to_arr == FALSE) {
         return FALSE;
     }
     $from = $reply_to = 'DoNotReply@' . Misc::getHostName(FALSE);
     global $current_user, $config_vars;
     if (is_object($current_user) and $current_user->getWorkEmail() != '') {
         $reply_to = $current_user->getWorkEmail();
     }
     Debug::Text('From: ' . $from . ' Reply-To: ' . $reply_to, __FILE__, __LINE__, __METHOD__, 10);
     $to = array_shift($email_to_arr);
     Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($email_to_arr) and count($email_to_arr) > 0) {
         $bcc = implode(',', $email_to_arr);
     } else {
         $bcc = NULL;
     }
     $email_subject = TTi18n::gettext('New message waiting in') . ' ' . APPLICATION_NAME;
     $email_body = TTi18n::gettext('*DO NOT REPLY TO THIS EMAIL - PLEASE USE THE LINK BELOW INSTEAD*') . "\n\n";
     $email_body .= TTi18n::gettext('You have a new message waiting for you in') . ' ' . APPLICATION_NAME . "\n";
     if ($this->getSubject() != '') {
         $email_body .= TTi18n::gettext('Subject:') . ' ' . $this->getSubject() . "\n";
     }
     $protocol = 'http';
     if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) {
         $protocol .= 's';
     }
     $email_body .= TTi18n::gettext('Link') . ': <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::getText('Login') . '</a>';
     //Define subject/body variables here.
     $search_arr = array('#employee_first_name#', '#employee_last_name#');
     $replace_arr = array(NULL, NULL);
     $subject = str_replace($search_arr, $replace_arr, $email_subject);
     Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
     $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $reply_to, 'Return-Path' => $reply_to, 'Errors-To' => $reply_to);
     $body = '<pre>' . str_replace($search_arr, $replace_arr, $email_body) . '</pre>';
     Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     @$mail->getMIMEObject()->setHTMLBody($body);
     $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
     $retval = $mail->Send();
     if ($retval == TRUE) {
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Message to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
         return TRUE;
     }
     return TRUE;
     //Always return true
 }
 function emailException($u_obj, $user_date_obj, $punch_obj = NULL, $schedule_obj = NULL, $ep_obj = NULL)
 {
     global $config_vars;
     if (!is_object($u_obj)) {
         return FALSE;
     }
     if (!is_object($user_date_obj)) {
         return FALSE;
     }
     if (!is_object($ep_obj)) {
         $ep_obj = $this->getExceptionPolicyObject();
     }
     //Only email on active exceptions.
     if ($this->getType() != 50) {
         return FALSE;
     }
     $email_to_arr = $this->getEmailExceptionAddresses($u_obj, $ep_obj);
     if ($email_to_arr == FALSE) {
         return FALSE;
     }
     $from = 'DoNotReply@' . Misc::getHostName(FALSE);
     $to = array_shift($email_to_arr);
     if (is_array($email_to_arr) and count($email_to_arr) > 0) {
         $bcc = implode(',', $email_to_arr);
     } else {
         $bcc = NULL;
     }
     Debug::Text('To: ' . $to . ' Bcc: ' . $bcc, __FILE__, __LINE__, __METHOD__, 10);
     $protocol = 'http';
     if (isset($config_vars['other']['force_ssl']) and $config_vars['other']['force_ssl'] == 1) {
         $protocol .= 's';
     }
     //Define subject/body variables here.
     $search_arr = array('#employee_first_name#', '#employee_last_name#', '#employee_default_branch#', '#employee_default_department#', '#employee_group#', '#employee_title#', '#exception_code#', '#exception_name#', '#exception_severity#', '#date#', '#company_name#', '#link#', '#schedule_start_time#', '#schedule_end_time#', '#schedule_branch#', '#schedule_department#', '#punch_time#');
     $replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), is_object($u_obj->getDefaultBranchObject()) ? $u_obj->getDefaultBranchObject()->getName() : NULL, is_object($u_obj->getDefaultDepartmentObject()) ? $u_obj->getDefaultDepartmentObject()->getName() : NULL, is_object($u_obj->getGroupObject()) ? $u_obj->getGroupObject()->getName() : NULL, is_object($u_obj->getTitleObject()) ? $u_obj->getTitleObject()->getName() : NULL, $ep_obj->getType(), Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')), Option::getByKey($ep_obj->getSeverity(), $ep_obj->getOptions('severity')), TTDate::getDate('DATE', $user_date_obj->getDateStamp()), is_object($u_obj->getCompanyObject()) ? $u_obj->getCompanyObject()->getName() : NULL, NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getStartTime()) : NULL, is_object($schedule_obj) ? TTDate::getDate('TIME', $schedule_obj->getEndTime()) : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getBranchObject())) ? $schedule_obj->getBranchObject()->getName() : NULL, (is_object($schedule_obj) and is_object($schedule_obj->getDepartmentObject())) ? $schedule_obj->getDepartmentObject()->getName() : NULL, is_object($punch_obj) ? TTDate::getDate('TIME', $punch_obj->getTimeStamp()) : NULL);
     $exception_email_subject = ' #exception_name# (#exception_code#) ' . TTi18n::gettext('exception for') . ' #employee_first_name# #employee_last_name# ' . TTi18n::gettext('on') . ' #date#';
     $exception_email_body = TTi18n::gettext('Employee') . ': #employee_first_name# #employee_last_name#' . "\n";
     $exception_email_body .= TTi18n::gettext('Date') . ': #date#' . "\n";
     $exception_email_body .= TTi18n::gettext('Exception') . ': #exception_name# (#exception_code#)' . "\n";
     $exception_email_body .= TTi18n::gettext('Severity') . ': #exception_severity#' . "\n";
     $exception_email_body .= ($replace_arr[12] != '' or $replace_arr[13] != '' or $replace_arr[14] != '' or $replace_arr[15] != '' or $replace_arr[16] != '') ? "\n" : NULL;
     $exception_email_body .= ($replace_arr[12] != '' and $replace_arr[13] != '') ? TTi18n::gettext('Schedule') . ': #schedule_start_time# - #schedule_end_time#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[14] != '' ? TTi18n::gettext('Schedule Branch') . ': #schedule_branch#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[15] != '' ? TTi18n::gettext('Schedule Department') . ': #schedule_department#' . "\n" : NULL;
     if ($replace_arr[16] != '') {
         $exception_email_body .= TTi18n::gettext('Punch') . ': #punch_time#' . "\n";
     } elseif ($replace_arr[12] != '' and $replace_arr[13] != '') {
         $exception_email_body .= TTi18n::gettext('Punch') . ': ' . TTi18n::gettext('None') . "\n";
     }
     $exception_email_body .= ($replace_arr[2] != '' or $replace_arr[3] != '' or $replace_arr[4] != '' or $replace_arr[5] != '') ? "\n" : NULL;
     $exception_email_body .= $replace_arr[2] != '' ? TTi18n::gettext('Default Branch') . ': #employee_default_branch#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[3] != '' ? TTi18n::gettext('Default Department') . ': #employee_default_department#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[4] != '' ? TTi18n::gettext('Group') . ': #employee_group#' . "\n" : NULL;
     $exception_email_body .= $replace_arr[5] != '' ? TTi18n::gettext('Title') . ': #employee_title#' . "\n" : NULL;
     $exception_email_body .= "\n";
     $exception_email_body .= TTi18n::gettext('Link:') . ' <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getDefaultInterfaceBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
     $exception_email_body .= $replace_arr[10] != '' ? "\n\n\n" . TTi18n::gettext('Company') . ': #company_name#' . "\n" : NULL;
     //Always put at the end
     $exception_email_body .= "\n\n" . TTi18n::gettext('Email sent') . ': ' . TTDate::getDate('DATE+TIME', time()) . "\n";
     $subject = str_replace($search_arr, $replace_arr, $exception_email_subject);
     //Debug::Text('Subject: '. $subject, __FILE__, __LINE__, __METHOD__,10);
     $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to);
     $body = '<pre>' . str_replace($search_arr, $replace_arr, $exception_email_body) . '</pre>';
     Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     @$mail->getMIMEObject()->setHTMLBody($body);
     $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
     $retval = $mail->Send();
     if ($retval == TRUE) {
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Exception') . ': ' . Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')) . ' To: ' . $to . ' Bcc: ' . $headers['Bcc'], $u_obj->getID(), $this->getTable());
         //Make sure this log entry is assigned to the user triggering the exception so it can be viewed in the audit log.
     }
     return TRUE;
 }
 function emailException($u_obj, $user_date_obj, $ep_obj = NULL)
 {
     if (!is_object($u_obj)) {
         return FALSE;
     }
     if (!is_object($user_date_obj)) {
         return FALSE;
     }
     if (!is_object($ep_obj)) {
         $ep_obj = $this->getExceptionPolicyObject();
     }
     //Only email on active exceptions.
     if ($this->getType() != 50) {
         return FALSE;
     }
     $email_to_arr = $this->getEmailExceptionAddresses($u_obj, $ep_obj);
     if ($email_to_arr == FALSE) {
         return FALSE;
     }
     $from = 'DoNotReply@' . Misc::getHostName(FALSE);
     $to = array_shift($email_to_arr);
     Debug::Text('To: ' . $to, __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($email_to_arr) and count($email_to_arr) > 0) {
         $bcc = implode(',', $email_to_arr);
     } else {
         $bcc = NULL;
     }
     $exception_email_subject = ' #exception_name# (#exception_code#) ' . TTi18n::gettext('exception for') . ' #employee_first_name# #employee_last_name# ' . TTi18n::gettext('on') . ' #date#';
     $exception_email_body = TTi18n::gettext('Employee:') . ' #employee_first_name# #employee_last_name#' . "\n";
     $exception_email_body .= TTi18n::gettext('Date:') . ' #date#' . "\n";
     $exception_email_body .= TTi18n::gettext('Exception:') . ' #exception_name# (#exception_code#)' . "\n";
     $exception_email_body .= TTi18n::gettext('Severity:') . ' #exception_severity#' . "\n";
     $exception_email_body .= TTi18n::gettext('Link:') . ' <a href="http://' . Misc::getHostName() . Environment::getBaseURL() . '">' . APPLICATION_NAME . ' ' . TTi18n::gettext('Login') . '</a>';
     //Define subject/body variables here.
     $search_arr = array('#employee_first_name#', '#employee_last_name#', '#exception_code#', '#exception_name#', '#exception_severity#', '#date#', '#link#');
     $replace_arr = array($u_obj->getFirstName(), $u_obj->getLastName(), $ep_obj->getType(), Option::getByKey($ep_obj->getType(), $ep_obj->getOptions('type')), Option::getByKey($ep_obj->getSeverity(), $ep_obj->getOptions('severity')), TTDate::getDate('DATE', $user_date_obj->getDateStamp()), NULL);
     //For some reason the EOL defaults to \r\n, which seems to screw with Amavis
     if (!defined('MAIL_MIMEPART_CRLF')) {
         define('MAIL_MIMEPART_CRLF', "\n");
     }
     $subject = str_replace($search_arr, $replace_arr, $exception_email_subject);
     Debug::Text('Subject: ' . $subject, __FILE__, __LINE__, __METHOD__, 10);
     $headers = array('From' => $from, 'Subject' => $subject, 'Bcc' => $bcc, 'Reply-To' => $to, 'Return-Path' => $to, 'Errors-To' => $to);
     Debug::Arr($headers, 'Headers: ', __FILE__, __LINE__, __METHOD__, 10);
     $body = '<pre>' . str_replace($search_arr, $replace_arr, $exception_email_body) . '</pre>';
     Debug::Text('Body: ' . $body, __FILE__, __LINE__, __METHOD__, 10);
     $mail = new TTMail();
     $mail->setTo($to);
     $mail->setHeaders($headers);
     @$mail->getMIMEObject()->setHTMLBody($body);
     $mail->setBody($mail->getMIMEObject()->get());
     $retval = $mail->Send();
     if ($retval == TRUE) {
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Email Exception to') . ': ' . $to . ' Bcc: ' . $headers['Bcc'], NULL, $this->getTable());
         return TRUE;
     }
     return TRUE;
 }
 function sendPasswordResetEmail()
 {
     global $config_vars;
     if ($this->getHomeEmail() != FALSE or $this->getWorkEmail() != FALSE) {
         if ($this->getWorkEmail() != FALSE) {
             $primary_email = $this->getWorkEmail();
             if ($this->getHomeEmail() != FALSE) {
                 $secondary_email = $this->getHomeEmail();
             } else {
                 $secondary_email = NULL;
             }
         } else {
             $primary_email = $this->getHomeEmail();
             $secondary_email = NULL;
         }
         $this->setPasswordResetKey(md5(uniqid()));
         $this->setPasswordResetDate(time());
         $this->Save(FALSE);
         if ($config_vars['other']['force_ssl'] == 1) {
             $protocol = 'https';
         } else {
             $protocol = 'http';
         }
         $subject = APPLICATION_NAME . ' ' . TTi18n::gettext('password reset requested at ') . TTDate::getDate('DATE+TIME', time()) . ' ' . TTi18n::gettext('from') . ' ' . $_SERVER['REMOTE_ADDR'];
         $body = '<html><body>';
         $body .= TTi18n::gettext('A password reset has been requested for') . ' "' . $this->getUserName() . '", ';
         $body .= ' <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getBaseURL() . 'ForgotPassword.php?action:password_reset=1&key=' . $this->getPasswordResetKey() . '">' . TTi18n::gettext('please click here to reset your password now') . '</a>.';
         $body .= '<br><br>';
         $body .= TTi18n::gettext('If you did not request your password to be reset, you may ignore this email.');
         $body .= '<br><br>';
         $body .= '--<br>';
         $body .= APPLICATION_NAME;
         $body .= '</body></html>';
         TTLog::addEntry($this->getId(), 500, TTi18n::getText('Employee Password Reset By') . ': ' . $_SERVER['REMOTE_ADDR'] . ' ' . TTi18n::getText('Key') . ': ' . $this->getPasswordResetKey(), NULL, $this->getTable());
         $headers = array('From' => '"' . APPLICATION_NAME . ' - ' . TTi18n::gettext('Password Reset') . '"<DoNotReply@' . Misc::getHostName(FALSE) . '>', 'Subject' => $subject, 'Cc' => $secondary_email);
         $mail = new TTMail();
         $mail->setTo($primary_email);
         $mail->setHeaders($headers);
         @$mail->getMIMEObject()->setHTMLBody($body);
         $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
         $retval = $mail->Send();
         return $retval;
     }
     return FALSE;
 }
Exemple #7
0
 function email($output, $report_schedule_obj = NULL)
 {
     Debug::Text('Emailing report...', __FILE__, __LINE__, __METHOD__, 10);
     if (is_array($output) and isset($output['data']) and $output['data'] != '' and is_object($this->getUserObject()) and ($this->getUserObject()->getHomeEmail() != FALSE or $this->getUserObject()->getWorkEmail() != FALSE)) {
         if ($this->getUserObject()->getWorkEmail() != FALSE) {
             $primary_email = $this->getUserObject()->getWorkEmail();
             $secondary_email = NULL;
             if (is_object($report_schedule_obj) and $report_schedule_obj->getEnableHomeEmail() == TRUE and $this->getUserObject()->getHomeEmail() != FALSE) {
                 $secondary_email .= $this->getUserObject()->getHomeEmail();
             }
             if (is_object($report_schedule_obj) and $report_schedule_obj->getOtherEmail() != '') {
                 $secondary_email .= ' ' . $report_schedule_obj->getOtherEmail();
             }
         } else {
             $primary_email = $this->getUserObject()->getHomeEmail();
             $secondary_email = NULL;
         }
         Debug::Text('Emailing report to: ' . $primary_email . ' CC: ' . $secondary_email, __FILE__, __LINE__, __METHOD__, 10);
         $subject = APPLICATION_NAME . ' ';
         $other_config = $this->getOtherConfig();
         if (isset($other_config['report_name']) and $other_config['report_name'] != '') {
             $subject .= $other_config['report_name'] . ' (';
         }
         $subject .= $this->title;
         if (isset($other_config['report_name']) and $other_config['report_name'] != '') {
             $subject .= ')';
         }
         $body = '<html><body>';
         $body .= TTI18n::getText('Report') . ': ' . $this->title . '<br><br>';
         $body .= $this->getDescriptionBlock(TRUE);
         $body .= '</body></html>';
         //Debug::Text('Email Subject: '. $subject, __FILE__, __LINE__, __METHOD__,10);
         //Debug::Text('Email Body: '. $body, __FILE__, __LINE__, __METHOD__,10);
         TTLog::addEntry(0, 500, TTi18n::getText('Emailing Report') . ': ' . $this->title . ' ' . TTi18n::getText('To') . ': ' . $primary_email, NULL, $this->getTable());
         $headers = array('From' => '"' . APPLICATION_NAME . ' - ' . TTi18n::gettext('Reports') . '"<DoNotReply@' . Misc::getHostName(FALSE) . '>', 'Subject' => $subject, 'Cc' => $secondary_email);
         $mail = new TTMail();
         $mail->setTo($primary_email);
         $mail->setHeaders($headers);
         @$mail->getMIMEObject()->setHTMLBody($body);
         //$mail->getMIMEObject()->addAttachment($output, 'application/pdf', $this->file_name.'.pdf', FALSE, 'base64');
         $mail->getMIMEObject()->addAttachment($output['data'], $output['mime_type'], $output['file_name'], FALSE, 'base64');
         $mail->setBody($mail->getMIMEObject()->get($mail->default_mime_config));
         return $mail->Send();
     }
     Debug::Text('No report data to email, or not email address to send them to!', __FILE__, __LINE__, __METHOD__, 10);
     return FALSE;
 }
    function sendPasswordResetEmail()
    {
        global $config_vars;
        if ($this->getHomeEmail() != FALSE or $this->getWorkEmail() != FALSE) {
            if ($this->getWorkEmail() != FALSE) {
                $primary_email = $this->getWorkEmail();
                if ($this->getHomeEmail() != FALSE) {
                    $secondary_email = $this->getHomeEmail();
                } else {
                    $secondary_email = NULL;
                }
            } else {
                $primary_email = $this->getHomeEmail();
                $secondary_email = NULL;
            }
            $this->setPasswordResetKey(md5(uniqid()));
            $this->setPasswordResetDate(time());
            $this->Save(FALSE);
            if ($config_vars['other']['force_ssl'] == 1) {
                $protocol = 'https';
            } else {
                $protocol = 'http';
            }
            $subject = 'Password Reset requested at ' . TTDate::getDate('DATE+TIME', time()) . ' from ' . $_SERVER['REMOTE_ADDR'];
            $body = '
			<html><body>
			If you did not request your password to be reset, you may ignore this email.
			<br>
			<br>
			If you did request the password for ' . $this->getUserName() . ' to be reset,
			please click <a href="' . $protocol . '://' . Misc::getHostName() . Environment::getBaseURL() . 'ForgotPassword.php?action:password_reset=null&key=' . $this->getPasswordResetKey() . '">here</a>
			</body></html>
			';
            //Debug::Text('Emailing Report to: '. $this->getUserName() .' Email: '. $primary_email , __FILE__, __LINE__, __METHOD__,10);
            //Debug::Arr($body, 'Email Report', __FILE__, __LINE__, __METHOD__,10);
            //echo "<pre>$body</pre><br>\n";
            //$retval = -->liam<--($primary_email, $subject, $body, "MIME-Version: 1.0\nContent-type: text/html; charset=iso-8859-1\nFrom: \"TimeTrex - Password Reset\"<DoNotReply@".Misc::getHostName().">\nCc: ". $secondary_email ."\n");
            //Debug::Text('Mail() result: '. (int)$retval, __FILE__, __LINE__, __METHOD__,10);
            TTLog::addEntry($this->getId(), 500, TTi18n::getText('Employee Password Reset By') . ': ' . $_SERVER['REMOTE_ADDR'] . ' ' . TTi18n::getText('Key') . ': ' . $this->getPasswordResetKey(), NULL, $this->getTable());
            $headers = array('From' => '"TimeTrex - Password Reset"<DoNotReply@' . Misc::getHostName(FALSE) . ">", 'Subject' => $subject, 'Cc' => $secondary_email, 'MIME-Version' => '1.0', 'Content-type' => 'text/html; charset=iso-8859-1');
            $mail = new TTMail();
            $mail->setTo($primary_email);
            $mail->setHeaders($headers);
            $mail->setBody($body);
            $retval = $mail->Send();
            return $retval;
        }
        return FALSE;
    }