0) { $result = hesk_dbQuery("SELECT * FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` WHERE `id`={$reply_id} AND `replyto`=".intval($ticket['id'])." LIMIT 1"); if (hesk_dbNumRows($res) != 1) { hesk_error($hesklang['ernf']); } $reply = hesk_dbFetchAssoc($result); $ticket['message'] = $reply['message']; $ticket['message_html'] = $reply['message_html']; $ticket['attachments'] = $reply['attachments']; } /* --> Prepare message */ // 1. Generate the array with ticket info that can be used in emails $info = array( 'email' => $ticket['email'], 'category' => $ticket['category'], 'priority' => $ticket['priority'], 'owner' => $ticket['owner'], 'trackid' => $ticket['trackid'], 'status' => $ticket['status'], 'name' => $ticket['name'], 'subject' => $ticket['subject'], 'message' => $ticket['message'], 'message_html' => $ticket['message_html'], 'attachments' => $ticket['attachments'], 'dt' => hesk_date($ticket['dt'], true), 'lastchange' => hesk_date($ticket['lastchange'], true), 'due_date' => hesk_format_due_date($ticket['due_date']), 'id' => $ticket['id'], 'time_worked' => $ticket['time_worked'], 'last_reply_by' => hesk_getReplierName($ticket), ); // 2. Add custom fields to the array foreach ($hesk_settings['custom_fields'] as $k => $v) { $info[$k] = $v['use'] ? $ticket[$k] : ''; } // 3. Make sure all values are properly formatted for email $ticket = hesk_ticketToPlain($info, 1, 0); // Notification of a reply if ($reply_id > 0) { // Reply by staff, send notification to customer if ($reply['staffid']) { hesk_notifyCustomer('new_reply_by_staff'); } // Reply by customer, notify assigned staff? elseif ($ticket['owner']) { hesk_notifyAssignedStaff(false, 'new_reply_by_customer', 'notify_reply_my'); } // Reply by customer, notify staff else { hesk_notifyStaff('new_reply_by_customer',"`notify_reply_unassigned`='1'"); } hesk_process_messages($hesklang['rns'],'admin_ticket.php?track='.$trackingID.'&Refresh='.rand(10000,99999),'SUCCESS'); } // Notification of the original ticket if ($opened_by) { hesk_notifyCustomer('new_ticket_by_staff'); } else { hesk_notifyCustomer(); } // Notify staff? if ($ticket['owner']) { hesk_notifyAssignedStaff(false, 'ticket_assigned_to_you'); } else { hesk_notifyStaff('new_ticket_staff', "`notify_new_unassigned`='1'"); } hesk_process_messages($hesklang['tns'],'admin_ticket.php?track='.$trackingID.'&Refresh='.rand(10000,99999),'SUCCESS');