mirror of https://github.com/itflow-org/itflow
Reworked how watchers get added and edited
This commit is contained in:
parent
e1ef89a9a4
commit
d82e6f99ab
|
|
@ -155,19 +155,6 @@ if (isset($_POST['edit_ticket'])) {
|
|||
|
||||
mysqli_query($mysqli,"UPDATE tickets SET ticket_subject = '$subject', ticket_priority = '$priority', ticket_details = '$details', ticket_vendor_ticket_number = '$vendor_ticket_number', ticket_contact_id = $contact_id, ticket_vendor_id = $vendor_id, ticket_asset_id = $asset_id WHERE ticket_id = $ticket_id");
|
||||
|
||||
// Add Watchers
|
||||
if (!empty($_POST['watchers'])) {
|
||||
|
||||
// Remove all watchers first
|
||||
mysqli_query($mysqli,"DELETE FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
||||
|
||||
//Add the Watchers
|
||||
foreach($_POST['watchers'] as $watcher) {
|
||||
$watcher_email = sanitizeInput($watcher);
|
||||
mysqli_query($mysqli,"INSERT INTO ticket_watchers SET watcher_email = '$watcher_email', watcher_ticket_id = $ticket_id");
|
||||
}
|
||||
}
|
||||
|
||||
//Logging
|
||||
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");
|
||||
|
||||
|
|
@ -216,6 +203,26 @@ if (isset($_POST['edit_ticket_contact'])) {
|
|||
|
||||
}
|
||||
|
||||
if (isset($_POST['add_ticket_watcher'])) {
|
||||
|
||||
validateTechRole();
|
||||
|
||||
$ticket_id = intval($_POST['ticket_id']);
|
||||
$client_id = intval($_POST['client_id']);
|
||||
$ticket_number = sanitizeInput($_POST['ticket_number']);
|
||||
$watcher_email = sanitizeInput($_POST['watcher_email']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO ticket_watchers SET watcher_email = '$watcher_email', watcher_ticket_id = $ticket_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Ticket', log_action = 'Edit', log_description = '$session_name added watcher $watcher_email to ticket $ticket_number', 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");
|
||||
|
||||
$_SESSION['alert_message'] = "You added $watcher_email as a watcher to Ticket <strong>$ticket_number</strong>";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['edit_ticket_watchers'])) {
|
||||
|
||||
validateTechRole();
|
||||
|
|
|
|||
|
|
@ -557,7 +557,7 @@ if (isset($_GET['ticket_id'])) {
|
|||
<h4 class="text-secondary">Watchers</h4>
|
||||
|
||||
<div>
|
||||
<a href="#" data-toggle="modal" data-target="#editTicketWatchersModal<?php echo $ticket_id; ?>"><i class="fa fa-fw fa-plus mr-2"></i>Add a Watcher</a>
|
||||
<a href="#" data-toggle="modal" data-target="#addTicketWatcherModal"><i class="fa fa-fw fa-plus mr-2"></i>Add a Watcher</a>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
|
@ -803,7 +803,7 @@ if (isset($_GET['ticket_id'])) {
|
|||
require_once("ticket_edit_contact_modal.php");
|
||||
require_once("ticket_edit_asset_modal.php");
|
||||
require_once("ticket_edit_vendor_modal.php");
|
||||
require_once("ticket_edit_watchers_modal.php");
|
||||
require_once("ticket_add_watcher_modal.php");
|
||||
require_once("ticket_edit_priority_modal.php");
|
||||
require_once("ticket_change_client_modal.php");
|
||||
require_once("ticket_merge_modal.php");
|
||||
|
|
@ -824,6 +824,4 @@ if ($ticket_status !== "Closed") { ?>
|
|||
<script src="js/ticket_button_respond_note.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<script src="js/ticket_add_remove_watchers.js"></script>
|
||||
|
||||
<script src="js/pretty_content.js"></script>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
<div class="modal" id="addTicketWatcherModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-eye mr-2"></i>Adding a ticket Watcher: <strong><?php echo "$ticket_prefix$ticket_number"; ?></strong> - <?php echo $client_name; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
|
||||
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||
<input type="hidden" name="ticket_number" value="<?php echo "$ticket_prefix$ticket_number"; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Watcher Email</label>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="email" class="form-control" name="watcher_email" placeholder="sombody@company.com">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="submit" name="add_ticket_watcher" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Add</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fa fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -105,35 +105,6 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Watchers</label>
|
||||
|
||||
<div class="watchers">
|
||||
|
||||
<?php
|
||||
$sql_watchers = mysqli_query($mysqli, "SELECT * FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
||||
while ($row = mysqli_fetch_array($sql_watchers)) {
|
||||
$watcher_id = intval($row['ticket_watcher_id']);
|
||||
$watcher_email = nullable_htmlentities($row['watcher_email']);
|
||||
?>
|
||||
<div class="input-group mb-3">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-envelope"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="watchers[]" value="<?php echo $watcher_email; ?>">
|
||||
<div class="input-group-append">
|
||||
<button type="button" class="btn btn-danger" onclick="removeWatcher(this)"><i class="fas fa-fw fa-minus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary" type="button" onclick="addWatcher(this)"><i class="fas fa-fw fa-plus"></i> Add Watcher</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-assets<?php echo $ticket_id; ?>">
|
||||
|
|
|
|||
Loading…
Reference in New Issue