Skip to content

Commit ffb37f0

Browse files
committed
gestion date, resolve #70
1 parent 2526757 commit ffb37f0

File tree

4 files changed

+27
-4
lines changed

4 files changed

+27
-4
lines changed

front/menu.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
$item_to_switch = $_POST['switch_item'];
8989
PluginReservationReservation::switchItemToResa($item_to_switch, $current_reservation);
9090
}
91+
if (isset($_SESSION['glpi_plugin_reservation_change_in_progress'])) {
92+
$form_dates = $_SESSION['glpi_plugin_reservation_form_dates'];
93+
unset($_SESSION['glpi_plugin_reservation_change_in_progress']);
94+
}
9195

9296
$_SESSION['glpi_plugin_reservation_form_dates'] = $form_dates;
9397

front/query.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,9 @@
3838
}
3939
}
4040

41+
if (isset($_GET['change_in_progress'])) {
42+
$_SESSION['glpi_plugin_reservation_change_in_progress'] = true;
43+
return http_response_code(200);
44+
}
45+
4146
return http_response_code(400);

inc/menu.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -531,28 +531,28 @@ private static function displayTabReservations($begin, $end, $listResaByUser, $i
531531

532532
// case if multi edit enabled for first item
533533
echo "<td class='showIfMultiEditEnabled' rowspan='" . $rowspan_line . "'>";
534-
echo "<a class='bouton' title='" . __('Edit multiple', 'reservation') . "' href='" . 'multiedit.form.php' . $str_multiEditParams . "'>" . __('Edit multiple', 'reservation') . "</a>";
534+
echo "<a class='bouton' title='" . __('Edit multiple', 'reservation') . "' onclick=\"makeAChange('" .'multiedit.form.php' . $str_multiEditParams . "');\" href=\"javascript:void(0);\">" . __('Edit multiple', 'reservation') . "</a>";
535535
echo "</td>";
536536

537537
// case if multi edit disable for first item
538538
echo "<td class='hideIfMultiEditEnabled' style='display: none;'>";
539539
echo '<ul style="list-style: none;">';
540-
echo "<li><a class=\"bouton\" title=\"" . __('Edit') . "\" href='" . Toolbox::getItemTypeFormURL('Reservation') . "?id=" . $reservation_user_info['reservations_id'] . "'>" . _sx('button', 'Edit') . "</a></li>";
540+
echo "<li><a class=\"bouton\" title=\"" . __('Edit') . "\" onclick=\"makeAChange('" . Toolbox::getItemTypeFormURL('Reservation') . "?id=" . $reservation_user_info['reservations_id'] . "');\" href=\"javascript:void(0);\">" . _sx('button', 'Edit') . "</a></li>";
541541
echo "</ul>";
542542
echo "</td>";
543543
} else {
544544
// normal case (no group)
545545
echo "<td>";
546546
echo '<ul style="list-style: none;">';
547-
echo "<li><a class=\"bouton\" title=\"" . __('Edit') . "\" href='" . Toolbox::getItemTypeFormURL('Reservation') . "?id=" . $reservation_user_info['reservations_id'] . "'>" . _sx('button', 'Edit') . "</a></li>";
547+
echo "<li><a class=\"bouton\" title=\"" . __('Edit') . "\" onclick=\"makeAChange('" . Toolbox::getItemTypeFormURL('Reservation') . "?id=" . $reservation_user_info['reservations_id'] . "');\" href=\"javascript:void(0);\">" . _sx('button', 'Edit') . "</a></li>";
548548
echo "</ul>";
549549
echo "</td>";
550550
}
551551
} else {
552552
// case if multi edit enabled for other items
553553
echo "<td class='hideIfMultiEditEnabled' style='display: none;'>";
554554
echo '<ul style="list-style: none;">';
555-
echo "<li><a class=\"bouton\" title=\"" . __('Edit') . "\" href='" . Toolbox::getItemTypeFormURL('Reservation') . "?id=" . $reservation_user_info['reservations_id'] . "'>" . _sx('button', 'Edit') . "</a></li>";
555+
echo "<li><a class=\"bouton\" title=\"" . __('Edit') . "\" onclick=\"makeAChange('" . Toolbox::getItemTypeFormURL('Reservation') . "?id=" . $reservation_user_info['reservations_id'] . "');\" href=\"javascript:void(0);\">" . _sx('button', 'Edit') . "</a></li>";
556556
echo "</ul>";
557557
echo "</td>";
558558
}

js/tools.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,18 @@ function mailuser(resa_id) {
258258
document.getElementById('mailed'+resa_id).innerHTML = "error...";
259259
}
260260
});
261+
}
262+
263+
function makeAChange(redirect) {
264+
$.ajax({
265+
type: "GET",
266+
url: window.location.origin + window.location.pathname+'/../query.php',
267+
data: "change_in_progress",
268+
success: function() {
269+
location.href = redirect;
270+
},
271+
error: function() {
272+
console.log("error");
273+
}
274+
});
261275
}

0 commit comments

Comments
 (0)