#66 Business Logic portion of emails to admins are done.

Still need to add the option to the edit user / profile page
merge-requests/2/head
Mike Koch 10 years ago
parent 219b722917
commit 3d4c0a99b7

@ -241,51 +241,47 @@ if (isset($_POST['notemsg']) && hesk_token_check('POST'))
hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."notes` (`ticket`,`who`,`dt`,`message`) VALUES ('".intval($ticket['id'])."','".intval($_SESSION['id'])."',NOW(),'".hesk_dbEscape($msg)."')"); hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."notes` (`ticket`,`who`,`dt`,`message`) VALUES ('".intval($ticket['id'])."','".intval($_SESSION['id'])."',NOW(),'".hesk_dbEscape($msg)."')");
/* Notify assigned staff that a note has been added if needed */ /* Notify assigned staff that a note has been added if needed */
if ($ticket['owner'] && $ticket['owner'] != $_SESSION['id']) $users = hesk_dbQuery("SELECT `email`, `notify_note` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE (`id`='".intval($ticket['owner'])."' OR (`isadmin` = '1' AND `notify_note_unassigned` = '1')) AND `id` <> '".intval($_SESSION['id'])."'");
{
$res = hesk_dbQuery("SELECT `email`, `notify_note` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."users` WHERE `id`='".intval($ticket['owner'])."' LIMIT 1");
if (hesk_dbNumRows($res) == 1) if (hesk_dbNumRows($users) > 0)
{ {
$owner = hesk_dbFetchAssoc($res); // 1. Generate the array with ticket info that can be used in emails
$info = array(
// 1. Generate the array with ticket info that can be used in emails 'email' => $ticket['email'],
$info = array( 'category' => $ticket['category'],
'email' => $ticket['email'], 'priority' => $ticket['priority'],
'category' => $ticket['category'], 'owner' => $ticket['owner'],
'priority' => $ticket['priority'], 'trackid' => $ticket['trackid'],
'owner' => $ticket['owner'], 'status' => $ticket['status'],
'trackid' => $ticket['trackid'], 'name' => $_SESSION['name'],
'status' => $ticket['status'], 'lastreplier' => $ticket['lastreplier'],
'name' => $_SESSION['name'], 'subject' => $ticket['subject'],
'lastreplier' => $ticket['lastreplier'], 'message' => stripslashes($msg),
'subject' => $ticket['subject'], 'dt' => hesk_date($ticket['dt'], true),
'message' => stripslashes($msg), 'lastchange' => hesk_date($ticket['lastchange'], true),
'dt' => hesk_date($ticket['dt'], true), );
'lastchange' => hesk_date($ticket['lastchange'], true),
); // 2. Add custom fields to the array
foreach ($hesk_settings['custom_fields'] as $k => $v)
// 2. Add custom fields to the array {
foreach ($hesk_settings['custom_fields'] as $k => $v) $info[$k] = $v['use'] ? $ticket[$k] : '';
{ }
$info[$k] = $v['use'] ? $ticket[$k] : '';
}
// 3. Make sure all values are properly formatted for email // 3. Make sure all values are properly formatted for email
$ticket = hesk_ticketToPlain($info, 1, 0); $ticket = hesk_ticketToPlain($info, 1, 0);
/* Get email functions */ /* Get email functions */
require(HESK_PATH . 'inc/email_functions.inc.php'); require(HESK_PATH . 'inc/email_functions.inc.php');
/* Format email subject and message for staff */ /* Format email subject and message for staff */
$subject = hesk_getEmailSubject('new_note',$ticket); $subject = hesk_getEmailSubject('new_note',$ticket);
$message = hesk_getEmailMessage('new_note',$ticket,1); $message = hesk_getEmailMessage('new_note',$ticket,1);
/* Send email to staff */ /* Send email to staff */
hesk_mail($owner['email'], $subject, $message); while ($user = hesk_dbFetchAssoc($users)) {
} hesk_mail($user['email'], $subject, $message);
}
} }
} }
header('Location: admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999)); header('Location: admin_ticket.php?track='.$trackingID.'&Refresh='.mt_rand(10000,99999));
exit(); exit();

Loading…
Cancel
Save