/** * Display reservations for an item * * @param $item CommonDBTM object for which the reservation tab need to be displayed * @param $withtemplate withtemplate param (default '') **/ static function showForItem(CommonDBTM $item, $withtemplate = '') { global $DB, $CFG_GLPI; $resaID = 0; if (!Session::haveRight("reservation", READ)) { return false; } echo "<div class='firstbloc'>"; ReservationItem::showActivationFormForItem($item); $ri = new ReservationItem(); if ($ri->getFromDBbyItem($item->getType(), $item->getID())) { $now = $_SESSION["glpi_currenttime"]; // Print reservation in progress $query = "SELECT *\n FROM `glpi_reservations`\n WHERE `end` > '" . $now . "'\n AND `reservationitems_id` = '" . $ri->fields['id'] . "'\n ORDER BY `begin`"; $result = $DB->query($query); echo "<table class='tab_cadre_fixehov'><tr><th colspan='5'>"; if ($ri->fields["is_active"]) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "'>" . __('Current and future reservations') . "</a>"; } else { _e('Current and future reservations'); } echo "</th></tr>\n"; if ($DB->numrows($result) == 0) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='5'>" . __('No reservation') . "</td></tr>\n"; } else { echo "<tr><th>" . __('Start date') . "</th>"; echo "<th>" . __('End date') . "</th>"; echo "<th>" . __('By') . "</th>"; echo "<th>" . __('Comments') . "</th><th> </th></tr>\n"; while ($data = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_2'>"; echo "<td class='center'>" . Html::convDateTime($data["begin"]) . "</td>"; echo "<td class='center'>" . Html::convDateTime($data["end"]) . "</td>"; echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $data["users_id"] . "'>" . getUserName($data["users_id"]) . "</a></td>"; echo "<td class='center'>" . nl2br($data["comment"]) . "</td>"; echo "<td class='center'>"; list($annee, $mois, $jour) = explode("-", $data["begin"]); echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "&mois_courant={$mois}&annee_courante={$annee}' title=\"" . __s('See planning') . "\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''>" . "</a>"; echo "</td></tr>\n"; } } echo "</table></div>\n"; // Print old reservations $query = "SELECT *\n FROM `glpi_reservations`\n WHERE `end` <= '" . $now . "'\n AND `reservationitems_id` = '" . $ri->fields['id'] . "'\n ORDER BY `begin` DESC"; $result = $DB->query($query); echo "<div class='spaced'><table class='tab_cadre_fixehov'><tr><th colspan='5'>"; if ($ri->fields["is_active"]) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "' >" . __('Past reservations') . "</a>"; } else { _e('Past reservations'); } echo "</th></tr>\n"; if ($DB->numrows($result) == 0) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='5'>" . __('No reservation') . "</td></tr>\n"; } else { echo "<tr><th>" . __('Start date') . "</th>"; echo "<th>" . __('End date') . "</th>"; echo "<th>" . __('By') . "</th>"; echo "<th>" . __('Comments') . "</th><th> </th></tr>\n"; while ($data = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_2'>"; echo "<td class='center'>" . Html::convDateTime($data["begin"]) . "</td>"; echo "<td class='center'>" . Html::convDateTime($data["end"]) . "</td>"; echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $data["users_id"] . "'>" . getUserName($data["users_id"]) . "</a></td>"; echo "<td class='center'>" . nl2br($data["comment"]) . "</td>"; echo "<td class='center'>"; list($annee, $mois, $jour) = explode("-", $data["begin"]); echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "&mois_courant={$mois}&annee_courante={$annee}' title=\"" . __s('See planning') . "\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''>"; echo "</a></td></tr>\n"; } } echo "</table>\n"; } echo "</div>\n"; }
/** * Display reservations for an item * * @param $ID ID a the item * @param $itemtype item type **/ static function showForItem($itemtype, $ID) { global $DB, $LANG, $CFG_GLPI; $resaID = 0; if (!haveRight("reservation_central", "r")) { return false; } echo "<div class='firstbloc'>"; ReservationItem::showActivationFormForItem($itemtype, $ID); $ri = new ReservationItem(); if ($ri->getFromDBbyItem($itemtype, $ID)) { $now = $_SESSION["glpi_currenttime"]; // Print reservation in progress $query = "SELECT *\n FROM `glpi_reservations`\n WHERE `end` > '{$now}'\n AND `reservationitems_id` = '" . $ri->fields['id'] . "'\n ORDER BY `begin`"; $result = $DB->query($query); echo "<table class='tab_cadre_fixehov'><tr><th colspan='5'>"; if ($ri->fields["is_active"]) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "' >" . $LANG['reservation'][35] . "</a>"; } else { echo $LANG['reservation'][35]; } echo "</th></tr>\n"; if ($DB->numrows($result) == 0) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='5'>" . $LANG['reservation'][37] . "</td></tr>\n"; } else { echo "<tr><th>" . $LANG['search'][8] . "</th>"; echo "<th>" . $LANG['search'][9] . "</th>"; echo "<th>" . $LANG['common'][95] . "</th>"; echo "<th>" . $LANG['common'][25] . "</th><th> </th></tr>\n"; while ($data = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_2'>"; echo "<td class='center'>" . convDateTime($data["begin"]) . "</td>"; echo "<td class='center'>" . convDateTime($data["end"]) . "</td>"; echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $data["users_id"] . "'>" . getUserName($data["users_id"]) . "</a></td>"; echo "<td class='center'>" . nl2br($data["comment"]) . "</td>"; echo "<td class='center'>"; list($annee, $mois, $jour) = explode("-", $data["begin"]); echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "&mois_courant={$mois}&annee_courante={$annee}' title=\"" . $LANG['reservation'][21] . "\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''></a>"; echo "</td></tr>\n"; } } echo "</table></div>\n"; // Print old reservations $query = "SELECT *\n FROM `glpi_reservations`\n WHERE `end` <= '{$now}'\n AND `reservationitems_id` = '" . $ri->fields['id'] . "'\n ORDER BY `begin` DESC"; $result = $DB->query($query); echo "<div class='spaced'><table class='tab_cadre_fixehov'><tr><th colspan='5'>"; if ($ri->fields["is_active"]) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "' >" . $LANG['reservation'][36] . "</a>"; } else { echo $LANG['reservation'][36]; } echo "</th></tr>\n"; if ($DB->numrows($result) == 0) { echo "<tr class='tab_bg_2'>"; echo "<td class='center' colspan='5'>" . $LANG['reservation'][37] . "</td></tr>\n"; } else { echo "<tr><th>" . $LANG['search'][8] . "</th>"; echo "<th>" . $LANG['search'][9] . "</th>"; echo "<th>" . $LANG['common'][95] . "</th>"; echo "<th>" . $LANG['common'][25] . "</th><th> </th></tr>\n"; while ($data = $DB->fetch_assoc($result)) { echo "<tr class='tab_bg_2'>"; echo "<td class='center'>" . convDateTime($data["begin"]) . "</td>"; echo "<td class='center'>" . convDateTime($data["end"]) . "</td>"; echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/user.form.php?id=" . $data["users_id"] . "'>" . getUserName($data["users_id"]) . "</a></td>"; echo "<td class='center'>" . nl2br($data["comment"]) . "</td>"; echo "<td class='center'>"; list($annee, $mois, $jour) = explode("-", $data["begin"]); echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $ri->fields['id'] . "&mois_courant={$mois}&annee_courante={$annee}' title=\"" . $LANG['reservation'][21] . "\">"; echo "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png\" alt='' title=''>"; echo "</a></td></tr>\n"; } } echo "</table>\n"; } echo "</div>\n"; }