$mdb2 = getConnection();
- $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.report_condition, c.status, fr.name from tt_cron c
+ $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition, c.status, fr.name from tt_cron c
left join tt_fav_reports fr on (fr.id = c.report_id)
where c.id = $id and c.team_id = $user->team_id";
$res = $mdb2->query($sql);
$next = (int) $fields['next'];
$report_id = (int) $fields['report_id'];
$email = $fields['email'];
+ $cc = $fields['cc'];
+ $subject = $fields['subject'];
$report_condition = $fields['report_condition'];
$status = $fields['status'];
- $sql = "insert into tt_cron (team_id, cron_spec, next, report_id, email, report_condition, status)
- values ($team_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($report_condition).", ".$mdb2->quote($status).")";
+ $sql = "insert into tt_cron (team_id, cron_spec, next, report_id, email, cc, subject, report_condition, status)
+ values ($team_id, ".$mdb2->quote($cron_spec).", $next, $report_id, ".$mdb2->quote($email).", ".$mdb2->quote($cc).", ".$mdb2->quote($subject).", ".$mdb2->quote($report_condition).", ".$mdb2->quote($status).")";
$affected = $mdb2->exec($sql);
if (is_a($affected, 'PEAR_Error'))
return false;
$next = (int) $fields['next'];
$report_id = (int) $fields['report_id'];
$email = $fields['email'];
+ $cc = $fields['cc'];
+ $subject = $fields['subject'];
$report_condition = $fields['report_condition'];
$status = $fields['status'];
- $sql = "update tt_cron set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id, email = ".$mdb2->quote($email).", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status).
+ $sql = "update tt_cron set cron_spec = ".$mdb2->quote($cron_spec).", next = $next, report_id = $report_id, email = ".$mdb2->quote($email).", cc = ".$mdb2->quote($cc).", subject = ".$mdb2->quote($subject).", report_condition = ".$mdb2->quote($report_condition).", status = ".$mdb2->quote($status).
" where id = $notification_id and team_id = $team_id";
$affected = $mdb2->exec($sql);
return (!is_a($affected, 'PEAR_Error'));
}
// sendFavReport - sends a favorite report to a specified email, called from cron.php
- static function sendFavReport($report, $email) {
+ static function sendFavReport($report, $subject, $email, $cc) {
// We are called from cron.php, we have no $bean in session.
// cron.php sets global $user and $i18n objects to match our favorite report user.
global $user;
$mailer->setCharSet(CHARSET);
$mailer->setContentType('text/html');
$mailer->setSender(SENDER);
+ if (!empty($cc))
+ $mailer->setReceiverCC($cc);
if (!empty($user->bcc_email))
$mailer->setReceiverBCC($user->bcc_email);
$mailer->setReceiver($email);
$mailer->setMailMode(MAIL_MODE);
- if (!$mailer->send($report['name'], $body))
+ if (empty($subject)) $subject = $report['name'];
+ if (!$mailer->send($subject, $body))
return false;
return true;
<br>
<table cellspacing="0" cellpadding="4" width="100%" border="0">
<tr>
- <td align="center"> Anuko Time Tracker 1.12.0.3665 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+ <td align="center"> Anuko Time Tracker 1.12.1.3666 | Copyright © <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
<td align="right">{$i18n.label.email} (*):</td>
<td>{$forms.notificationForm.email.control}</td>
</tr>
+ <tr>
+ <td align="right">{$i18n.form.mail.cc}:</td>
+ <td>{$forms.notificationForm.cc.control}</td>
+ </tr>
+ <tr>
+ <td align="right">{$i18n.form.mail.subject}:</td>
+ <td>{$forms.notificationForm.subject.control}</td>
+ </tr>
<tr>
<td align="right">{$i18n.label.condition}:</td>
<td>{$forms.notificationForm.report_condition.control} <a href="https://www.anuko.com/lp/tt_9.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
<td align="right">{$i18n.label.email} (*):</td>
<td>{$forms.notificationForm.email.control}</td>
</tr>
+ <tr>
+ <td align="right">{$i18n.form.mail.cc}:</td>
+ <td>{$forms.notificationForm.cc.control}</td>
+ </tr>
+ <tr>
+ <td align="right">{$i18n.form.mail.subject}:</td>
+ <td>{$forms.notificationForm.subject.control}</td>
+ </tr>
<tr>
<td align="right">{$i18n.label.condition}:</td>
<td>{$forms.notificationForm.report_condition.control} <a href="https://www.anuko.com/lp/tt_9.htm" target="_blank">{$i18n.label.what_is_it}</a></td>
$mdb2 = getConnection();
$now = time();
- $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.report_condition from tt_cron c
+ $sql = "select c.id, c.cron_spec, c.report_id, c.email, c.cc, c.subject, c.report_condition from tt_cron c
left join tt_fav_reports fr on (c.report_id = fr.id)
where $now >= c.next and fr.status = 1
and c.status = 1 and c.report_id is not null and c.email is not null";
// Email report if condition is okay.
if ($condition_ok) {
- if (ttReportHelper::sendFavReport($report, $val['email']))
+ if (ttReportHelper::sendFavReport($report, $val['subject'], $val['email'], $val['cc']))
echo "Report ".$val['report_id']. " sent to ".$val['email']."<br>";
else
echo "Error while emailing report...<br>";
setChange("ALTER TABLE `tt_cron` ADD `report_condition` varchar(255) default NULL AFTER `email`");
setChange("ALTER TABLE `tt_fav_reports` ADD `status` tinyint(4) default '1'");
setChange("ALTER TABLE `tt_teams` ADD `bcc_email` varchar(100) default NULL AFTER `uncompleted_indicators`");
+ setChange("ALTER TABLE `tt_cron` ADD `cc` varchar(100) default NULL AFTER `email`");
+ setChange("ALTER TABLE `tt_cron` ADD `subject` varchar(100) default NULL AFTER `cc`");
}
// The update_clients function updates projects field in tt_clients table.
`next` int(11) default NULL, # UNIX timestamp of when to run next job
`report_id` int(11) default NULL, # report id from tt_fav_reports, a report to mail on schedule
`email` varchar(100) default NULL, # email to send results to
+ `cc` varchar(100) default NULL, # cc email to send results to
+ `subject` varchar(100) default NULL, # email subject
`report_condition` varchar(255) default NULL, # report condition, "count > 0" for sending not empty reports
`status` tinyint(4) default '1', # entry status
PRIMARY KEY (`id`)
$cl_fav_report = trim($request->getParameter('fav_report'));
$cl_cron_spec = trim($request->getParameter('cron_spec'));
$cl_email = trim($request->getParameter('email'));
+ $cl_cc = trim($request->getParameter('cc'));
+ $cl_subject = trim($request->getParameter('subject'));
$cl_report_condition = trim($request->getParameter('report_condition'));
} else {
$cl_cron_spec = '0 4 * * 1'; // Default schedule - weekly on Mondays at 04:00 (server time).
));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'cron_spec','style'=>'width: 250px;','value'=>$cl_cron_spec));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','style'=>'width: 250px;','value'=>$cl_email));
+$form->addInput(array('type'=>'text','name'=>'cc','style'=>'width: 300px;','value'=>$cl_cc));
+$form->addInput(array('type'=>'text','name'=>'subject','style'=>'width: 300px;','value'=>$cl_subject));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'report_condition','style'=>'width: 250px;','value'=>$cl_report_condition));
$form->addInput(array('type'=>'submit','name'=>'btn_add','value'=>$i18n->getKey('button.add')));
if (!$cl_fav_report) $err->add($i18n->getKey('error.report'));
if (!ttValidCronSpec($cl_cron_spec)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.cron_schedule'));
if (!ttValidEmail($cl_email)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
+ if (!ttValidEmail($cl_cc, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.cc'));
+ if (!ttValidString($cl_subject, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.subject'));
if (!ttValidCondition($cl_report_condition)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.condition'));
if ($err->no()) {
'next' => $next,
'report_id' => $cl_fav_report,
'email' => $cl_email,
+ 'cc' => $cl_cc,
+ 'subject' => $cl_subject,
'report_condition' => $cl_report_condition,
'status' => ACTIVE))) {
header('Location: notifications.php');
$cl_fav_report = trim($request->getParameter('fav_report'));
$cl_cron_spec = trim($request->getParameter('cron_spec'));
$cl_email = trim($request->getParameter('email'));
+ $cl_cc = trim($request->getParameter('cc'));
+ $cl_subject = trim($request->getParameter('subject'));
$cl_report_condition = trim($request->getParameter('report_condition'));
} else {
$notification = ttNotificationHelper::get($notification_id);
$cl_fav_report = $notification['report_id'];
$cl_cron_spec = $notification['cron_spec'];
$cl_email = $notification['email'];
+ $cl_cc = $notification['cc'];
+ $cl_subject = $notification['subject'];
$cl_report_condition = $notification['report_condition'];
}
'empty'=>array(''=>$i18n->getKey('dropdown.select'))));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'cron_spec','style'=>'width: 250px;','value'=>$cl_cron_spec));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'email','style'=>'width: 250px;','value'=>$cl_email));
+$form->addInput(array('type'=>'text','name'=>'cc','style'=>'width: 300px;','value'=>$cl_cc));
+$form->addInput(array('type'=>'text','name'=>'subject','style'=>'width: 300px;','value'=>$cl_subject));
$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'report_condition','style'=>'width: 250px;','value'=>$cl_report_condition));
$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->getKey('button.save')));
if (!$cl_fav_report) $err->add($i18n->getKey('error.report'));
if (!ttValidCronSpec($cl_cron_spec)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.cron_schedule'));
if (!ttValidEmail($cl_email)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.email'));
+ if (!ttValidEmail($cl_cc, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.cc'));
+ if (!ttValidString($cl_subject, true)) $err->add($i18n->getKey('error.field'), $i18n->getKey('form.mail.subject'));
if (!ttValidCondition($cl_report_condition)) $err->add($i18n->getKey('error.field'), $i18n->getKey('label.condition'));
if ($err->no()) {
'next' => $next,
'report_id' => $cl_fav_report,
'email' => $cl_email,
+ 'cc' => $cl_cc,
+ 'subject' => $cl_subject,
'report_condition' => $cl_report_condition,
'status' => ACTIVE))) {
header('Location: notifications.php');