mirror of https://github.com/itflow-org/itflow
Allow linking closed tickets to a project
This commit is contained in:
parent
35d6b51770
commit
da3a1d2ce4
|
|
@ -0,0 +1,42 @@
|
|||
<div class="modal" id="linkClosedTicketModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fas fa-fw fa-life-ring mr-2"></i>Link closed ticket to project: <strong><?php echo $project_name; ?></strong></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="project_id" value="<?php echo $project_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Ticket number <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<?php
|
||||
// Show the ticket prefix, or just the tag icon
|
||||
$config_row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT config_ticket_prefix FROM settings WHERE company_id = 1"));
|
||||
$config_ticket_prefix = $config_row['config_ticket_prefix'];
|
||||
if (empty($config_ticket_prefix)) {
|
||||
echo "<span class=\"input-group-text\"><i class=\"fa fa-fw fa-tag\"></i></span>";
|
||||
} else {
|
||||
echo "<div class=\"input-group-text\"> $config_ticket_prefix </div>";
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="ticket_number" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" placeholder="Closed ticket number to link with project" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="submit" name="link_closed_ticket_to_project" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Link</button>
|
||||
<button type="button" class="btn btn-light" data-dismiss="modal"><i class="fas fa-times mr-2"></i>Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -234,3 +234,38 @@ if (isset($_POST['link_ticket_to_project'])) {
|
|||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_POST['link_closed_ticket_to_project'])) {
|
||||
|
||||
enforceUserPermission('module_support', 2);
|
||||
$project_id = intval($_POST['project_id']);
|
||||
$ticket_number = intval($_POST['ticket_number']);
|
||||
|
||||
// Get Project Name and Client ID for logging
|
||||
$sql = mysqli_query($mysqli, "SELECT project_client_id, project_name FROM projects WHERE project_id = $project_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$client_id = intval($row['project_client_id']);
|
||||
$project_name = sanitizeInput($row['project_name']);
|
||||
|
||||
// Get ticket details
|
||||
$sql = mysqli_query($mysqli, "SELECT ticket_id, ticket_prefix, ticket_number, ticket_subject, ticket_updated_at FROM tickets WHERE ticket_number = $ticket_number");
|
||||
if (mysqli_num_rows($sql) == 0) {
|
||||
$_SESSION['alert_message'] = "Cannot merge into that ticket.";
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
exit();
|
||||
}
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$ticket_id = intval($row['ticket_id']);
|
||||
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
||||
$ticket_number = intval($row['ticket_number']);
|
||||
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
||||
$ticket_updated = sanitizeInput($row['ticket_updated_at']); // So we don't mess with the last response
|
||||
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_project_id = $project_id, ticket_updated_at = '$ticket_updated' WHERE ticket_id = $ticket_id");
|
||||
|
||||
// Logging
|
||||
logAction("Project", "Edit", "$session_name added ticket $ticket_prefix$ticket_number - $ticket_subject to project $project_name", $client_id, $project_id);
|
||||
|
||||
$_SESSION['alert_message'] = "Ticket added to <strong>$project_name</strong>";
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
|
@ -235,6 +235,10 @@ if (isset($_GET['project_id'])) {
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#linkTicketModal">
|
||||
<i class="fas fa-fw fa-life-ring mr-2"></i>Open Ticket
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#linkClosedTicketModal">
|
||||
<i class="fas fa-fw fa-life-ring mr-2"></i>Closed Ticket
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
|
@ -552,6 +556,7 @@ if (isset($_GET['project_id'])) {
|
|||
<?php
|
||||
|
||||
require_once "modals/project_link_ticket_modal.php";
|
||||
require_once "modals/project_link_closed_ticket_modal.php";
|
||||
require_once "modals/ticket_add_modal.php";
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue