|
77 | 77 | } |
78 | 78 |
|
79 | 79 | // Add Watchers |
80 | | - if (!empty($_POST['watchers'])) { |
| 80 | + if (isset($_POST['watchers'])) { |
81 | 81 | foreach ($_POST['watchers'] as $watcher) { |
82 | 82 | $watcher_email = sanitizeInput($watcher); |
83 | 83 | mysqli_query($mysqli, "INSERT INTO ticket_watchers SET watcher_email = '$watcher_email', watcher_ticket_id = $ticket_id"); |
|
157 | 157 | customAction('ticket_create', $ticket_id); |
158 | 158 |
|
159 | 159 | // Logging |
160 | | - mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Create', log_description = '$session_name created ticket $config_ticket_prefix$ticket_number - $ticket_subject', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $ticket_id"); |
| 160 | + logAction("Ticket", "Create", "$session_name created ticket $config_ticket_prefix$ticket_number - $ticket_subject", $client_id, $ticket_id); |
161 | 161 |
|
162 | | - $_SESSION['alert_message'] = "You created Ticket $ticket_subject <strong>$config_ticket_prefix$ticket_number</strong>"; |
| 162 | + $_SESSION['alert_message'] = "Ticket <strong>$config_ticket_prefix$ticket_number</strong> created"; |
163 | 163 |
|
164 | | - header("Location: ticket.php?ticket_id=" . $ticket_id); |
| 164 | + header("Location: ticket.php?ticket_id=$ticket_id"); |
165 | 165 | } |
166 | 166 |
|
167 | 167 | if (isset($_POST['edit_ticket'])) { |
|
183 | 183 | $project_id = intval($_POST['project']); |
184 | 184 | $client_id = intval($_POST['client_id']); |
185 | 185 | $ticket_number = sanitizeInput($_POST['ticket_number']); |
| 186 | + $ticket_prefix = sanitizeInput($config_ticket_prefix); |
186 | 187 |
|
187 | 188 | mysqli_query($mysqli, "UPDATE tickets SET ticket_category = $category, ticket_subject = '$subject', ticket_priority = '$priority', ticket_billable = $billable, ticket_details = '$details', ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_contact_id = $contact_id, ticket_vendor_id = $vendor_id, ticket_location_id = $location_id, ticket_asset_id = $asset_id, ticket_project_id = $project_id WHERE ticket_id = $ticket_id"); |
188 | 189 |
|
|
193 | 194 | $sql = mysqli_query($mysqli, "SELECT contact_name, contact_email, ticket_prefix, ticket_number, ticket_category, ticket_subject, ticket_details, ticket_priority, ticket_status_name, ticket_created_by, ticket_assigned_to, ticket_client_id FROM tickets |
194 | 195 | LEFT JOIN clients ON ticket_client_id = client_id |
195 | 196 | LEFT JOIN contacts ON ticket_contact_id = contact_id |
196 | | - LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id |
| 197 | + LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id |
197 | 198 | WHERE ticket_id = $ticket_id |
198 | 199 | AND ticket_closed_at IS NULL"); |
199 | 200 | $row = mysqli_fetch_array($sql); |
|
242 | 243 | // Custom action/notif handler |
243 | 244 | customAction('ticket_update', $ticket_id); |
244 | 245 |
|
245 | | - //Logging |
246 | | - mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Modify', log_description = '$session_name modified ticket $ticket_number - $subject', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $ticket_id"); |
| 246 | + // Logging |
| 247 | + logAction("Ticket", "Edit", "$session_name edited ticket $ticket_prefix$ticket_number", $client_id, $ticket_id); |
247 | 248 |
|
248 | | - $_SESSION['alert_message'] = "Ticket <strong>$ticket_number</strong> updated"; |
| 249 | + $_SESSION['alert_message'] = "Ticket <strong>$ticket_prefix$ticket_number</strong> updated"; |
249 | 250 |
|
250 | 251 | header("Location: " . $_SERVER["HTTP_REFERER"]); |
251 | 252 | } |
|
258 | 259 | $priority = sanitizeInput($_POST['priority']); |
259 | 260 | $client_id = intval($_POST['client_id']); |
260 | 261 |
|
| 262 | + // Get ticket details |
| 263 | + $sql = mysqli_query($mysqli, "SELECT |
| 264 | + ticket_prefix, ticket_number ticket_priority, ticket_status_name, ticket_client_id |
| 265 | + FROM tickets |
| 266 | + LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id |
| 267 | + WHERE ticket_id = $ticket_id" |
| 268 | + ); |
| 269 | + $row = mysqli_fetch_array($sql); |
| 270 | + $ticket_prefix = sanitizeInput($row['ticket_prefix']); |
| 271 | + $ticket_number = intval($row['ticket_number']); |
| 272 | + $original_priority = sanitizeInput($row['ticket_priority']); |
| 273 | + $ticket_status = sanitizeInput($row['ticket_status_name']); |
| 274 | + $client_id = intval($row['ticket_client_id']); |
| 275 | + |
261 | 276 | mysqli_query($mysqli, "UPDATE tickets SET ticket_priority = '$priority' WHERE ticket_id = $ticket_id"); |
262 | 277 |
|
263 | | - //Logging |
264 | | - mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Modify', log_description = '$session_name edited ticket priority', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, log_entity_id = $ticket_id"); |
| 278 | + // Update Ticket History |
| 279 | + mysqli_query($mysqli, "INSERT INTO ticket_history SET ticket_history_status = '$ticket_status', ticket_history_description = '$session_name changed priority from $original_priority to $priority', ticket_history_ticket_id = $ticket_id"); |
| 280 | + |
| 281 | + // Logging |
| 282 | + logAction("Ticket", "Edit", "$session_name changed priority from $original_priority to $priority for ticket $ticket_prefix$ticket_number", $client_id, $ticket_id); |
265 | 283 |
|
266 | 284 | customAction('ticket_update', $ticket_id); |
267 | 285 |
|
268 | | - $_SESSION['alert_message'] = "Ticket priority updated"; |
| 286 | + $_SESSION['alert_message'] = "Priority updated <strong>$original_priority</strong> to <strong>$priority</strong>"; |
269 | 287 |
|
270 | 288 | header("Location: " . $_SERVER["HTTP_REFERER"]); |
271 | 289 | } |
|
0 commit comments