mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
send expired docs mail as html, log sending mail
This commit is contained in:
parent
47b3416b5b
commit
a0ef972028
|
@ -20,20 +20,40 @@ class SeedDMS_ExpiredDocumentsTask extends SeedDMS_SchedulerTaskBase { /* {{{ */
|
|||
*/
|
||||
public function execute($task) {
|
||||
$dms = $this->dms;
|
||||
$user = $this->user;
|
||||
$settings = $this->settings;
|
||||
$logger = $this->logger;
|
||||
$taskparams = $task->getParameter();
|
||||
$docs = $dms->getDocumentsExpired(intval($taskparams['days']));
|
||||
$tableformat = " %-10s %5d %-60s";
|
||||
$tableformathead = " %-10s %5s %-60s";
|
||||
$tableformathtml = "<tr><td>%s</td><td>%d</td><td>%s</td></tr>";
|
||||
$tableformatheadhtml = "<tr><th>%s</th><th>%s</th><th>%s</th></tr>";
|
||||
$body = '';
|
||||
$bodyhtml = '';
|
||||
if (count($docs)>0) {
|
||||
$bodyhtml .= "<table>".PHP_EOL;
|
||||
$bodyhtml .= sprintf($tableformatheadhtml."\n", getMLText("expiration_date", array(), ""), "ID", getMLText("name", array(), ""));
|
||||
$body .= sprintf($tableformathead."\n", getMLText("expiration_date", array(), ""), "ID", getMLText("name", array(), ""));
|
||||
$body .= "---------------------------------------------------------------------------------\n";
|
||||
foreach($docs as $doc) {
|
||||
$body .= sprintf($tableformat."\n", getReadableDate($doc->getExpires()), $doc->getId(), $doc->getName());
|
||||
// echo $doc->getName().PHP_EOL;
|
||||
$bodyhtml .= sprintf($tableformathtml."\n", getReadableDate($doc->getExpires()), $doc->getId(), $doc->getName());
|
||||
}
|
||||
$bodyhtml .= "</table>".PHP_EOL;
|
||||
if($taskparams['email'])
|
||||
mail($taskparams['email'], getMLText('expired_docs_mail_subject',array('sitename'=>$settings->_siteName, 'count'=>count($docs))), $body);
|
||||
require_once('inc/inc.ClassEmailNotify.php');
|
||||
$email = new SeedDMS_EmailNotify($dms, $settings->_smtpSendFrom, $settings->_smtpServer, $settings->_smtpPort, $settings->_smtpUser, $settings->_smtpPassword);
|
||||
|
||||
$params = array();
|
||||
$params['count'] = count($docs);
|
||||
$params['__body__'] = $body;
|
||||
$params['__body_html__'] = $bodyhtml;
|
||||
$params['sitename'] = $settings->_siteName;
|
||||
$email->toIndividual('', $taskparams['email'], 'expired_docs_mail_subject', '', $params);
|
||||
|
||||
$logger->log('Task \'expired_docs\': Sending reminder \'expired_docs_mail_subject\' to user \''.$taskparams['email'].'\'', PEAR_LOG_INFO);
|
||||
// mail($taskparams['email'], getMLText('expired_docs_mail_subject',array('sitename'=>$settings->_siteName, 'count'=>count($docs))), $body);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user