diff --git a/admin/admin_reply_ticket.php b/admin/admin_reply_ticket.php index c4b11321..bb93285d 100644 --- a/admin/admin_reply_ticket.php +++ b/admin/admin_reply_ticket.php @@ -1,7 +1,7 @@
'.$hesklang['rssn']; + header('Location: admin_ticket.php?track='.$row['trackid'].'&Refresh='.rand(10000,99999)); + } + else + { + header('Location: admin_main.php'); + } + } + else + { + header('Location: admin_ticket.php?track='.$ticket['trackid'].'&Refresh='.rand(10000,99999)); + } + exit(); + } + + // Attach signature to the message? + if ( ! $submit_as_customer && ! empty($_POST['signature'])) { $message .= "\n\n" . addslashes($_SESSION['signature']) . "\n"; } @@ -153,8 +197,15 @@ if ($hesk_settings['attachments']['use'] && !empty($attachments)) } } -/* Add reply */ -$result = hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` (`replyto`,`name`,`message`,`dt`,`attachments`,`staffid`) VALUES ('".intval($replyto)."','".hesk_dbEscape(addslashes($_SESSION['name']))."','".hesk_dbEscape($message)."',NOW(),'".hesk_dbEscape($myattachments)."','".intval($_SESSION['id'])."')"); +// Add reply +if ($submit_as_customer) +{ + hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` (`replyto`,`name`,`message`,`dt`,`attachments`) VALUES ('".intval($replyto)."','".hesk_dbEscape(addslashes($ticket['name']))."','".hesk_dbEscape($message."

{$hesklang['creb']} {$_SESSION['name']}")."',NOW(),'".hesk_dbEscape($myattachments)."')"); +} +else +{ + hesk_dbQuery("INSERT INTO `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` (`replyto`,`name`,`message`,`dt`,`attachments`,`staffid`) VALUES ('".intval($replyto)."','".hesk_dbEscape(addslashes($_SESSION['name']))."','".hesk_dbEscape($message)."',NOW(),'".hesk_dbEscape($myattachments)."','".intval($_SESSION['id'])."')"); +} /* Track ticket status changes for history */ $revision = ''; @@ -189,15 +240,61 @@ $defaultStatusReplyStatus = hesk_dbFetchAssoc(hesk_dbQuery("SELECT `ID`, `IsClos $staffClosedCheckboxStatus = hesk_dbFetchAssoc(hesk_dbQuery("SELECT `ID`, `IsClosed` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `IsStaffClosedOption` = 1 LIMIT 1")); $lockedTicketStatus = hesk_dbFetchAssoc(hesk_dbQuery("SELECT `ID` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."statuses` WHERE `LockedTicketStatus` = 1 LIMIT 1")); -$new_status = empty($_POST['close']) ? $defaultStatusReplyStatus['ID'] : $staffClosedCheckboxStatus['ID']; - -/* --> If a ticket is locked keep it closed */ +// Get new ticket status +$sql_status = ''; +// -> If locked, keep it resolved if ($ticket['locked']) { $new_status = $lockedTicketStatus['ID']; } +elseif (isset($_POST['submit_as_status'])) +{ + $new_status = $_POST['submit_as_status']; + + if ($ticket['status'] != $new_status) + { + // Does this status close the ticket? + $newStatusRs = hesk_dbQuery('SELECT `IsClosed`, `ShortNameContentKey` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `ID` = '.hesk_dbEscape($new_status)); + $newStatus = hesk_dbFetchAssoc($newStatusRs); + + if ($newStatus['IsClosed']) + { + $revision = sprintf($hesklang['thist3'],hesk_date(),$_SESSION['name'].' ('.$_SESSION['user'].')'); + $sql_status = " , `closedat`=NOW(), `closedby`=".intval($_SESSION['id']).", `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') "; + + // Lock the ticket if customers are not allowed to reopen tickets + if ($hesk_settings['custopen'] != 1) + { + $sql_status .= " , `locked`='1' "; + } + } else + { + // Ticket isn't being closed, just add the history to the sql query + $revision = sprintf($hesklang['thist9'],hesk_date(),$hesklang[$newStatus['ShortNameContentKey']],$_SESSION['name'].' ('.$_SESSION['user'].')'); + $sql_status = " , `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') "; + } + } +} +// -> Submit as Customer reply +elseif ($submit_as_customer) +{ + //Get the status ID for customer replies + $customerReplyStatusRs = hesk_dbQuery('SELECT `ID` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsCustomerReplyStatus` = 1 LIMIT 1'); + $customerReplyStatus = hesk_dbFetchAssoc($customerReplyStatusRs); + $new_status = $customerReplyStatus['ID']; +} +// -> Default: submit as "Replied by staff" +else +{ + //Get the status ID for staff replies + $staffReplyStatusRs = hesk_dbQuery('SELECT `ID` FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` WHERE `IsDefaultStaffReplyStatus` = 1 LIMIT 1'); + $staffReplyStatus = hesk_dbFetchAssoc($staffReplyStatusRs); + $new_status = $staffReplyStatus['ID']; +} + +$sql = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `status`='{$new_status}',"; +$sql.= $submit_as_customer ? "`lastreplier`='0', `replierid`='0' " : "`lastreplier`='1', `replierid`='".intval($_SESSION['id'])."' "; -$sql = "UPDATE `".hesk_dbEscape($hesk_settings['db_pfix'])."tickets` SET `status`='{$new_status}', `lastreplier`='1', `replierid`='".intval($_SESSION['id'])."' "; /* Update time_worked or force update lastchange */ if ($time_worked == '00:00:00') @@ -216,19 +313,19 @@ if ( ! empty($_POST['assign_self']) && hesk_checkPermission('can_assign_self',0) } $sql .= " $priority_sql "; +$sql .= " $sql_status "; -$isNewStatusClosed = empty($_POST['close']) ? $defaultStatusReplyStatus['IsClosed'] : $staffClosedCheckboxStatus['IsClosed']; -if ($isNewStatusClosed) +if ( ! $ticket['firstreplyby'] ) { - $revision = sprintf($hesklang['thist3'],hesk_date(),$_SESSION['name'].' ('.$_SESSION['user'].')'); - $sql .= " , `history`=CONCAT(`history`,'".hesk_dbEscape($revision)."') "; - - if ($hesk_settings['custopen'] != 1) - { - $sql .= " , `locked`='1' "; - } + $sql .= " , `firstreply`=NOW(), `firstreplyby`=".intval($_SESSION['id'])." "; } + +// Keep track of replies to this ticket for easier reporting +$sql .= " , `replies`=`replies`+1 "; +$sql .= $submit_as_customer ? '' : " , `staffreplies`=`staffreplies`+1 "; + +// End and execute the query $sql .= " WHERE `id`='{$replyto}' LIMIT 1"; hesk_dbQuery($sql); unset($sql); @@ -247,12 +344,13 @@ $info = array( 'trackid' => $ticket['trackid'], 'status' => $new_status, 'name' => $ticket['name'], -'lastreplier' => $_SESSION['name'], +'lastreplier' => ($submit_as_customer ? $ticket['name'] : $_SESSION['name']), 'subject' => $ticket['subject'], 'message' => stripslashes($message), 'attachments' => $myattachments, 'dt' => hesk_date($ticket['dt'], true), 'lastchange' => hesk_date($ticket['lastchange'], true), +'id' => $ticket['id'], ); // 2. Add custom fields to the array @@ -264,19 +362,26 @@ foreach ($hesk_settings['custom_fields'] as $k => $v) // 3. Make sure all values are properly formatted for email $ticket = hesk_ticketToPlain($info, 1, 0); -// Notify the customer -if ( ! isset($_POST['no_notify']) || intval( hesk_POST('no_notify') ) != 1) +// Notify the assigned staff? +if ($submit_as_customer) +{ + if ($ticket['owner'] && $ticket['owner'] != $_SESSION['id']) + { + hesk_notifyAssignedStaff(false, 'new_reply_by_customer', 'notify_reply_my'); + } +} +// Notify customer? +elseif ( ! isset($_POST['no_notify']) || intval( hesk_POST('no_notify') ) != 1) { hesk_notifyCustomer('new_reply_by_staff'); } +// Delete any existing drafts from this owner for this ticket +hesk_dbQuery("DELETE FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."reply_drafts` WHERE `owner`=".intval($_SESSION['id'])." AND `ticket`=".intval($ticket['id'])." LIMIT 1"); + /* Set reply submitted message */ $_SESSION['HESK_SUCCESS'] = TRUE; $_SESSION['HESK_MESSAGE'] = $hesklang['reply_submitted']; -if (!empty($_POST['close'])) -{ - $_SESSION['HESK_MESSAGE'] .= '

'.$hesklang['ticket_marked'].' '.$hesklang['closed'].''; -} /* What to do after reply? */ if ($_SESSION['afterreply'] == 1) diff --git a/admin/admin_ticket.php b/admin/admin_ticket.php index b5210f76..d44b4efe 100644 --- a/admin/admin_ticket.php +++ b/admin/admin_ticket.php @@ -220,6 +220,28 @@ if (isset($_GET['delete_post']) && $can_delete && hesk_token_check()) else { $closed_sql = ''; + $changeStatusRs = hesk_dbQuery('SELECT `id`, `LockedTicketStatus`, `IsCustomerReplyStatus`, `IsDefaultStaffReplyStatus`, `IsNewTicketStatus` + FROM `'.hesk_dbEscape($hesk_settings['db_pfix']).'statuses` + WHERE `LockedTicketStatus` = 1 + OR `IsCustomerReplyStatus` = 1 + OR `IsDefaultStaffReplyStatus` = 1 + OR `IsNewTicketStatus` = 1'); + $lockedTicketStatus = ''; + $customerReplyStatus = ''; + $defaultStaffReplyStatus = ''; + $newTicketStatus = ''; + while ($row = hesk_dbFetchAssoc($changeStatusRs)) + { + if ($row['LockedTicketStatus']) { + $lockedTicketStatus = $row['id']; + } elseif ($row['IsCustomerReplyStatus']) { + $customerReplyStatus = $row['id']; + } elseif ($row['IsDefaultStaffReplyStatus']) { + $defaultStaffReplyStatus = $row['id']; + } elseif ($row['IsNewTicketStatus']) { + $newTicketStatus = $row['id']; + } + } /* Reply deleted. Need to update status and last replier? */ $res = hesk_dbQuery("SELECT `dt`, `staffid` FROM `".hesk_dbEscape($hesk_settings['db_pfix'])."replies` WHERE `replyto`='".intval($ticket['id'])."' ORDER BY `id` DESC LIMIT 1"); @@ -232,12 +254,11 @@ if (isset($_GET['delete_post']) && $can_delete && hesk_token_check()) $status_sql = ''; if ($last_reply_id == $n) { - //TODO Update this to MFH-compatible statuses - $status = $ticket['locked'] ? 3 : ($last_replier ? 2 : 1); + $status = $ticket['locked'] ? $lockedTicketStatus : ($last_replier ? $defaultStaffReplyStatus : $customerReplyStatus); $status_sql = " , `status`='".intval($status)."' "; // Update closedat and closedby columns as required - if ($status == 3) + if ($status == $lockedTicketStatus) { $closed_sql = " , `closedat`=NOW(), `closedby`=".intval($_SESSION['id'])." "; } @@ -250,12 +271,12 @@ if (isset($_GET['delete_post']) && $can_delete && hesk_token_check()) // Update status, closedat and closedby columns as required if ($ticket['locked']) { - $status = 3; + $status = $lockedTicketStatus; $closed_sql = " , `closedat`=NOW(), `closedby`=".intval($_SESSION['id'])." "; } else { - $status = 0; + $status = $newTicketStatus; $closed_sql = " , `closedat`=NULL, `closedby`=NULL "; } @@ -1686,8 +1707,8 @@ function hesk_printReplyForm() {
- + ?>

()
-

+

'; } ?> - - +
+ + + +
diff --git a/css/hesk_newStyle.php b/css/hesk_newStyle.php index 142ca8a2..aecade8e 100644 --- a/css/hesk_newStyle.php +++ b/css/hesk_newStyle.php @@ -364,3 +364,12 @@ div.setupButtons { cursor: text !important; background-color: #fff !important; } + +button.btn.dropdown-toggle { + height: 34px; +} + +button.dropdown-submit { + background:none!important; + border:none; +} diff --git a/css/hesk_newStyleRTL.php b/css/hesk_newStyleRTL.php index 8d8778f9..d5a0e365 100644 --- a/css/hesk_newStyleRTL.php +++ b/css/hesk_newStyleRTL.php @@ -357,4 +357,15 @@ div.setupButtons { margin-right: auto; margin-left: auto; width: 90%; +} +.white-readonly { + cursor: text !important; + background-color: #fff !important; +} +button.btn.dropdown-toggle { + height: 34px; +} +button.dropdown-submit { + background:none!important; + border:none; } \ No newline at end of file diff --git a/language/en/text.php b/language/en/text.php index bfc10fbc..57304f8b 100644 --- a/language/en/text.php +++ b/language/en/text.php @@ -24,6 +24,8 @@ $hesklang['EMAIL_HR']='------ Reply above this line ------'; // ADDED OR MODIFIED IN Mods For HESK 2.0.0 $hesklang['saved_ticket_tpl'] = 'Saved Templates'; $hesklang['new_ticket_tpl']='Add or Edit a Ticket Template'; +$hesklang['and_change_status_to'] = 'and change status to'; // Used in combination with $hesklang['submit_reply'] (Reads as "Submit reply and change status to") + // ADDED OR MODIFIED IN Mods For HESK 1.7.0 $hesklang['date_custom_field'] = 'Date';