LICENSE This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("consumable", READ); Html::header(Consumable::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "consumableitem"); if (isset($_GET["synthese"])) { Consumable::showSummary(); } else { Search::show('ConsumableItem'); } Html::footer();
/** * Print out the consumables of a defined type * * @param $consitem ConsumableItem object * @param $show_old boolean show old consumables or not. (default 0) * * @return Nothing (displays) **/ static function showForConsumableItem(ConsumableItem $consitem, $show_old = 0) { global $DB, $CFG_GLPI; $tID = $consitem->getField('id'); if (!$consitem->can($tID, READ)) { return false; } if (isset($_GET["start"])) { $start = $_GET["start"]; } else { $start = 0; } $canedit = $consitem->can($tID, UPDATE); $rand = mt_rand(); $where = ""; if (!$show_old) { // NEW $where = " AND `date_out` IS NULL\n ORDER BY `date_in`, `id`"; } else { //OLD $where = " AND `date_out` IS NOT NULL\n ORDER BY `date_out` DESC,\n `date_in`,\n `id`"; } $number = countElementsInTable("glpi_consumables", "`consumableitems_id` = '{$tID}' {$where}"); $query = "SELECT `glpi_consumables`.*\n FROM `glpi_consumables`\n WHERE `consumableitems_id` = '{$tID}'\n {$where}\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']); $result = $DB->query($query); echo "<div class='spaced'>"; // Display the pager Html::printAjaxPager(Consumable::getTypeName(Session::getPluralNumber()), $start, $number); if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $actions = array('delete' => _x('button', 'Delete permanently'), 'Infocom' . MassiveAction::CLASS_ACTION_SEPARATOR . 'activate' => __('Enable the financial and administrative information')); if ($show_old) { $actions['Consumable' . MassiveAction::CLASS_ACTION_SEPARATOR . 'backtostock'] = __('Back to stock'); } else { $actions[__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'give'] = _x('button', 'Give'); } $entparam = array('entities_id' => $consitem->getEntityID()); if ($consitem->isRecursive()) { $entparam = array('entities_id' => getSonsOf('glpi_entities', $consitem->getEntityID())); } $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => $actions, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => $entparam); Html::showMassiveActions($massiveactionparams); echo "<input type='hidden' name='consumableitems_id' value='{$tID}'>\n"; } echo "<table class='tab_cadre_fixehov'>"; if (!$show_old) { echo "<tr><th colspan=" . ($canedit ? '5' : '4') . ">"; echo self::getCount($tID, -1); echo "</th></tr>"; } else { // Old echo "<tr><th colspan='" . ($canedit ? '7' : '6') . "'>" . __('Used consumables') . "</th></tr>"; } if ($number) { $i = 0; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit) { $header_begin .= "<th width='10'>"; $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand); $header_end .= "</th>"; } $header_end .= "<th>" . __('ID') . "</th>"; $header_end .= "<th>" . _x('item', 'State') . "</th>"; $header_end .= "<th>" . __('Add date') . "</th>"; if ($show_old) { $header_end .= "<th>" . __('Use date') . "</th>"; $header_end .= "<th>" . __('Given to') . "</th>"; } $header_end .= "<th width='200px'>" . __('Financial and administrative information') . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; while ($data = $DB->fetch_assoc($result)) { $date_in = Html::convDate($data["date_in"]); $date_out = Html::convDate($data["date_out"]); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center'>" . $data["id"] . "</td>"; echo "<td class='center'>" . self::getStatus($data["id"]) . "</td>"; echo "<td class='center'>" . $date_in . "</td>"; if ($show_old) { echo "<td class='center'>" . $date_out . "</td>"; echo "<td class='center'>"; if ($item = getItemForItemtype($data['itemtype'])) { if ($item->getFromDB($data['items_id'])) { echo $item->getLink(); } } echo "</td>"; } echo "<td class='center'>"; Infocom::showDisplayLink('Consumable', $data["id"]); echo "</td>"; echo "</tr>"; } echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * @see CommonGLPI::getMenuName() * * @since version 0.85 **/ static function getMenuName() { return Consumable::getTypeName(Session::getPluralNumber()); }
LICENSE This file is part of GLPI. GLPI is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief */ include '../inc/includes.php'; Session::checkRight("consumable", "r"); Html::header(Consumable::getTypeName(2), $_SERVER['PHP_SELF'], "inventory", "consumable"); if (isset($_GET["synthese"])) { Consumable::showSummary(); } else { Search::show('ConsumableItem'); } Html::footer();