|
|
|
@ -260,25 +260,24 @@ function do_login()
|
|
|
|
|
$revision = sprintf($hesklang['thist3'],hesk_date(),$hesklang['auto']);
|
|
|
|
|
$dt = date('Y-m-d H:i:s',time() - $hesk_settings['autoclose']*86400);
|
|
|
|
|
|
|
|
|
|
// Notify customer of closed ticket?
|
|
|
|
|
if ($hesk_settings['notify_closed'])
|
|
|
|
|
{
|
|
|
|
|
$closedStatusRs = hesk_dbQuery('SELECT `ID` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsDefaultStaffReplyStatus` = 1');
|
|
|
|
|
|
|
|
|
|
$closedStatusRs = hesk_dbQuery('SELECT `ID`, `Closable` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsDefaultStaffReplyStatus` = 1');
|
|
|
|
|
$closedStatus = hesk_dbFetchAssoc($closedStatusRs);
|
|
|
|
|
// Are we allowed to close tickets in this status?
|
|
|
|
|
if ($closedStatus['Closable'] == 'yes' || $closedStatus['Closable'] == 'sonly') {
|
|
|
|
|
// Notify customer of closed ticket?
|
|
|
|
|
if ($hesk_settings['notify_closed']) {
|
|
|
|
|
// Get list of tickets
|
|
|
|
|
$result = hesk_dbQuery("SELECT * FROM `" . $hesk_settings['db_pfix'] . "tickets` WHERE `status` = " . $closedStatus['ID'] . " AND `lastchange` <= '" . hesk_dbEscape($dt) . "' ");
|
|
|
|
|
if (hesk_dbNumRows($result) > 0)
|
|
|
|
|
{
|
|
|
|
|
if (hesk_dbNumRows($result) > 0) {
|
|
|
|
|
global $ticket;
|
|
|
|
|
|
|
|
|
|
// Load required functions?
|
|
|
|
|
if ( ! function_exists('hesk_notifyCustomer') )
|
|
|
|
|
{
|
|
|
|
|
if (!function_exists('hesk_notifyCustomer')) {
|
|
|
|
|
require(HESK_PATH . 'inc/email_functions.inc.php');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
while ($ticket = hesk_dbFetchAssoc($result))
|
|
|
|
|
{
|
|
|
|
|
while ($ticket = hesk_dbFetchAssoc($result)) {
|
|
|
|
|
$ticket['dt'] = hesk_date($ticket['dt'], true);
|
|
|
|
|
$ticket['lastchange'] = hesk_date($ticket['lastchange'], true);
|
|
|
|
|
$ticket = hesk_ticketToPlain($ticket, 1, 0);
|
|
|
|
@ -287,8 +286,11 @@ function do_login()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Update ticket statuses and history in database
|
|
|
|
|
hesk_dbQuery("UPDATE `".$hesk_settings['db_pfix']."tickets` SET `status`='3', `closedat`=NOW(), `closedby`='-1', `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') WHERE `status` = '2' AND `lastchange` <= '".hesk_dbEscape($dt)."' ");
|
|
|
|
|
// Update ticket statuses and history in database if we're allowed to do so
|
|
|
|
|
$defaultCloseRs = hesk_dbQuery('SELECT `ID` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsStaffClosedOption` = 1');
|
|
|
|
|
$defaultCloseStatus = hesk_dbFetchAssoc($defaultCloseRs);
|
|
|
|
|
hesk_dbQuery("UPDATE `" . $hesk_settings['db_pfix'] . "tickets` SET `status`=".intval($defaultCloseStatus['ID']).", `closedat`=NOW(), `closedby`='-1', `history`=CONCAT(`history`,'" . hesk_dbEscape($revision) . "') WHERE `status` = '".$closedStatus['ID']."' AND `lastchange` <= '" . hesk_dbEscape($dt) . "' ");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Redirect to the destination page */
|
|
|
|
|