Skip to content

Commit

Permalink
Fix climbing with history & update full history window (#212)
Browse files Browse the repository at this point in the history
* Fix climbing with history & update full history window

* Update CHANGELOG.md
  • Loading branch information
RomainLvr authored Jul 30, 2024
1 parent 927c248 commit b89556e
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 34 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- Prevent an escalation when a ticket is updated
- Fix climbing with history

### Changed

- Full history window (now is a modal)

## [2.9.7] - 2024-07-04

Expand Down
4 changes: 1 addition & 3 deletions front/climb_group.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,4 @@
Html::displayErrorAndDie(__("missing parameters", "escalade"));
}

$full_history = (isset($_REQUEST['full_history']));

PluginEscaladeTicket::climb_group($_REQUEST['tickets_id'], $_REQUEST['groups_id'], $full_history);
PluginEscaladeTicket::climb_group($_REQUEST['tickets_id'], $_REQUEST['groups_id']);
4 changes: 0 additions & 4 deletions front/popup_histories.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

include("../../../inc/includes.php");

Html::popHeader(__("full assignation history", "escalade"), $_SERVER['PHP_SELF']);
echo "<div class='center'><br><a href='javascript:window.close()'>" . __("Close") . "</a>";
echo "</div>";

echo "<div id='page'>";
PluginEscaladeHistory::getHistory($_REQUEST['tickets_id'], true);
echo "</div>";
Expand Down
50 changes: 36 additions & 14 deletions inc/history.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static function getHistory($tickets_id, $full_history = false)
$use_filter_assign_group = false;
}

$plugin_dir = ($full_history) ? ".." : Plugin::getWebDir('escalade');
$plugin_dir = Plugin::getWebDir('escalade');

//get all line for this ticket
$group = new Group();
Expand Down Expand Up @@ -122,18 +122,36 @@ public static function getHistory($tickets_id, $full_history = false)
echo "<div class='escalade_history'>";

if (! $use_filter_assign_group || isset($filter_groups_id[$hline['groups_id']])) {
//up link and image
echo "<a href='$plugin_dir/front/climb_group.php?tickets_id="
. $tickets_id . "&groups_id=" . $hline['groups_id'];
if ($full_history) {
echo "&full_history=true";
}
echo "' title='" . __("Reassign the ticket to group", "escalade") . "' class='btn btn-icon btn-sm btn-ghost-secondary'><i class='ti ti-arrow-up'></i></a>";
$rand = mt_rand();
// Remplacement du lien par un formulaire
echo "<form action='$plugin_dir/front/climb_group.php' method='GET' id='history-form-$rand'>";
echo "<input type='hidden' name='tickets_id' value='" . $tickets_id . "'>";
echo "<input type='hidden' name='groups_id' value='" . $hline['groups_id'] . "'>";
echo "<button type='submit' title='" . __("Reassign the ticket to group", "escalade") . "' class='btn btn-icon btn-sm btn-ghost-secondary'>
<i class='ti ti-arrow-up'></i>
</button>";
echo "</form>";

echo "<script>
$(document).ready(function () {
var form = $('#itil-form');
var inputs = form.serializeArray();
var asset_form = $('#history-form-$rand');
if (asset_form.length > 0) {
$.each(inputs, function(i, input) {
if (input.name != '_actors') {
asset_form.append('<input type=\"hidden\" name=\"ticket_details[' + input.name + ']\" value=\"' + input.value + '\">');
}
});
}
});
</script>";
} else {
echo "&nbsp;&nbsp;&nbsp;";
}

//group link
//group link
echo "&nbsp;<i class='ti ti-users'></i>&nbsp;";
if ($group->getFromDB($hline['groups_id'])) {
echo self::showGroupLink($group, $full_history);
Expand All @@ -148,11 +166,15 @@ public static function getHistory($tickets_id, $full_history = false)
}

//In case there are more than 10 group changes, a popup can display historical
if ($nb_histories - 1 > self::HISTORY_LIMIT && ! $full_history) {
echo "<a href='#' onclick='var w=window.open(\""
. $plugin_dir . "/front/popup_histories.php?tickets_id=" . $tickets_id
. "\" ,\"\", \"height=500, width=250, top=100, left=100, scrollbars=yes\" ); "
. "w.focus();' title='" . __("View full history", "escalade") . "'>...</a>";
if ($nb_histories - 1 > self::HISTORY_LIMIT && !$full_history) {
echo Ajax::createModalWindow(
'full_history',
$plugin_dir . "/front/popup_histories.php?tickets_id=" . $tickets_id,
[
'title' => __("full assignation history", "escalade")
]
);
echo "<a href='#' onclick='full_history.show();' title='" . __("View full history", "escalade") . "'>...</a>";
}

echo "</div>";
Expand Down
17 changes: 4 additions & 13 deletions inc/ticket.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ public static function assignUserGroup(Ticket $ticket)
* @param int $groups_id the group to assign
* @return void
*/
public static function climb_group($tickets_id, $groups_id, $full_history = false)
public static function climb_group($tickets_id, $groups_id)
{
//don't add group if already exist for this ticket
$group_ticket = new Group_Ticket();
Expand All @@ -517,8 +517,9 @@ public static function climb_group($tickets_id, $groups_id, $full_history = fals
if ($_SESSION['plugins']['escalade']['config']['ticket_last_status'] != -1) {
$_form_object['status'] = $_SESSION['plugins']['escalade']['config']['ticket_last_status'];
}
$ticket_details = $_POST['ticket_details'] ?? $_GET['ticket_details'] ?? [];
$updates_ticket = new Ticket();
$updates_ticket->update($_POST['ticket_details'] + [
$updates_ticket->update($ticket_details + [
'_actors' => PluginEscaladeTicket::getTicketFieldsWithActors($tickets_id, $groups_id),
'_plugin_escalade_no_history' => true, // Prevent a duplicated task to be added
'actortype' => CommonITILActor::ASSIGN,
Expand All @@ -527,17 +528,7 @@ public static function climb_group($tickets_id, $groups_id, $full_history = fals
]);
}

if (!$full_history) {
Html::back();
} else {
//reload parent window and close popup
echo "<script type='text/javascript'>
if (window.opener && !window.opener.closed) {
window.opener.location.reload();
}
window.close();
</script>";
}
Html::back();
}


Expand Down

0 comments on commit b89556e

Please sign in to comment.