Show infocom link to display modal
static public showDisplayLink ( $itemtype, $device_id ) : float | ||
$itemtype | integer item type | |
$device_id | integer item ID | |
Résultat | float |
/** * Print out the cartridges of a defined type * * @param $cartitem object of CartridgeItem class * @param $show_old boolean show old cartridges or not (default 0) * * @return Nothing (displays) **/ static function showForCartridgeItem(CartridgeItem $cartitem, $show_old = 0) { global $DB, $CFG_GLPI; $tID = $cartitem->getField('id'); if (!$cartitem->can($tID, READ)) { return false; } $canedit = $cartitem->can($tID, UPDATE); $query = "SELECT COUNT(*) AS count\n FROM `glpi_cartridges`\n WHERE (`cartridgeitems_id` = '{$tID}')"; if ($result = $DB->query($query)) { $total = $DB->result($result, 0, "count"); if (!$show_old) { // NEW $where = " AND `glpi_cartridges`.`date_out` IS NULL"; } else { //OLD $where = " AND `glpi_cartridges`.`date_out` IS NOT NULL"; } $stock_time = 0; $use_time = 0; $pages_printed = 0; $nb_pages_printed = 0; $ORDER = " `glpi_cartridges`.`date_use` ASC,\n `glpi_cartridges`.`date_out` DESC,\n `glpi_cartridges`.`date_in`"; if (!$show_old) { $ORDER = " `glpi_cartridges`.`date_out` ASC,\n `glpi_cartridges`.`date_use` ASC,\n `glpi_cartridges`.`date_in`"; } $query = "SELECT `glpi_cartridges`.*,\n `glpi_printers`.`id` AS printID,\n `glpi_printers`.`name` AS printname,\n `glpi_printers`.`init_pages_counter`\n FROM `glpi_cartridges`\n LEFT JOIN `glpi_printers`\n ON (`glpi_cartridges`.`printers_id` = `glpi_printers`.`id`)\n WHERE `glpi_cartridges`.`cartridgeitems_id` = '{$tID}'\n {$where}\n ORDER BY {$ORDER}"; $result = $DB->query($query); $number = $DB->numrows($result); echo "<div class='spaced'>"; if ($canedit && $number) { $rand = mt_rand(); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $actions = array('purge' => _x('button', 'Delete permanently'), 'Infocom' . MassiveAction::CLASS_ACTION_SEPARATOR . 'activate' => __('Enable the financial and administrative information')); if ($show_old) { $actions['Cartridge' . MassiveAction::CLASS_ACTION_SEPARATOR . 'backtostock'] = __('Back to stock'); } $massiveactionparams = array('num_displayed' => $number, 'specific_actions' => $actions, 'container' => 'mass' . __CLASS__ . $rand, 'rand' => $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; if (!$show_old) { echo "<tr class='noHover'><th colspan='" . ($canedit ? '7' : '6') . "'>" . self::getCount($tID, -1) . "</th>"; echo "</tr>"; } else { // Old echo "<tr class='noHover'><th colspan='" . ($canedit ? '9' : '8') . "'>" . __('Worn cartridges'); echo "</th></tr>"; } $i = 0; $header_begin = "<tr>"; $header_top = ''; $header_bottom = ''; $header_end = ''; if ($canedit && $number) { $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><th>" . __('Use date') . "</th>"; $header_end .= "<th>" . __('Used on') . "</th>"; if ($show_old) { $header_end .= "<th>" . __('End date') . "</th>"; $header_end .= "<th>" . __('Printer counter') . "</th>"; } $header_end .= "<th width='18%'>" . __('Financial and administrative information') . "</th>"; $header_end .= "</tr>"; echo $header_begin . $header_top . $header_end; } $pages = array(); if ($number) { while ($data = $DB->fetch_assoc($result)) { $date_in = Html::convDate($data["date_in"]); $date_use = Html::convDate($data["date_use"]); $date_out = Html::convDate($data["date_out"]); $printer = $data["printers_id"]; $page = $data["pages"]; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td>" . $data['id'] . '</td>'; echo "<td class='center'>" . self::getStatus($data["date_use"], $data["date_out"]); echo "</td><td class='center'>" . $date_in . "</td>"; echo "<td class='center'>" . $date_use . "</td>"; echo "<td class='center'>"; if (!is_null($date_use)) { if ($data["printID"] > 0) { $printname = $data["printname"]; if ($_SESSION['glpiis_ids_visible'] || empty($printname)) { $printname = sprintf(__('%1$s (%2$s)'), $printname, $data["printID"]); } echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/printer.form.php?id=" . $data["printID"] . "'><span class='b'>" . $printname . "</span></a>"; } else { echo NOT_AVAILABLE; } $tmp_dbeg = explode("-", $data["date_in"]); $tmp_dend = explode("-", $data["date_use"]); $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]); $stock_time += $stock_time_tmp; } if ($show_old) { echo "</td><td class='center'>"; echo $date_out; $tmp_dbeg = explode("-", $data["date_use"]); $tmp_dend = explode("-", $data["date_out"]); $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]); $use_time += $use_time_tmp; } echo "</td>"; if ($show_old) { // Get initial counter page if (!isset($pages[$printer])) { $pages[$printer] = $data['init_pages_counter']; } echo "<td class='center'>"; if ($pages[$printer] < $data['pages']) { $pages_printed += $data['pages'] - $pages[$printer]; $nb_pages_printed++; $pp = $data['pages'] - $pages[$printer]; printf(_n('%d printed page', '%d printed pages', $pp), $pp); $pages[$printer] = $data['pages']; } else { if ($data['pages'] != 0) { echo "<span class='tab_bg_1_2'>" . __('Counter error') . "</span>"; } } echo "</td>"; } echo "<td class='center'>"; Infocom::showDisplayLink('Cartridge', $data["id"]); echo "</td>"; echo "</tr>"; } if ($show_old && $number > 0) { if ($nb_pages_printed == 0) { $nb_pages_printed = 1; } echo "<tr class='tab_bg_2'><td colspan='" . ($canedit ? '4' : '3') . "'> </td>"; echo "<td class='center b'>" . __('Average time in stock') . "<br>"; echo round($stock_time / $number / 60 / 60 / 24 / 30.5, 1) . " " . __('month') . "</td>"; echo "<td> </td>"; echo "<td class='center b'>" . __('Average time in use') . "<br>"; echo round($use_time / $number / 60 / 60 / 24 / 30.5, 1) . " " . __('month') . "</td>"; echo "<td class='center b'>" . __('Average number of printed pages') . "<br>"; echo round($pages_printed / $nb_pages_printed) . "</td>"; echo "<td colspan='" . ($canedit ? '3' : '1') . "'> </td></tr>"; } else { echo $header_begin . $header_bottom . $header_end; } } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>\n\n"; }
/** * 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>"; }
/** * Print out the consumables of a defined type * *@param $consitem oject of ConsumableItem class *@param $show_old boolean : show old consumables or not. * *@return Nothing (displays) **/ static function showForItem(ConsumableItem $consitem, $show_old = 0) { global $DB, $CFG_GLPI, $LANG; $tID = $consitem->getField('id'); if (!$consitem->can($tID, 'r')) { return false; } $canedit = $consitem->can($tID, 'w'); $query = "SELECT count(*) AS COUNT\n FROM `glpi_consumables`\n WHERE (`consumableitems_id` = '{$tID}')"; if ($result = $DB->query($query)) { if (!$show_old && $canedit) { echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/consumable.form.php'>"; echo "<input type='hidden' name='tID' value='{$tID}'>\n"; } echo "<div class='spaced'><table class='tab_cadre_fixe'>"; if (!$show_old) { echo "<tr><th colspan='7'>"; echo self::getCount($tID, -1); echo "</th></tr>"; } else { // Old echo "<tr><th colspan='8'>" . $LANG['consumables'][35] . "</th></tr>"; } $i = 0; echo "<tr><th>" . $LANG['common'][2] . "</th><th>" . $LANG['consumables'][23] . "</th>"; echo "<th>" . $LANG['cartridges'][24] . "</th><th>" . $LANG['consumables'][26] . "</th>"; if ($show_old) { echo "<th>" . $LANG['common'][34] . "</th>"; } echo "<th>" . $LANG['financial'][3] . "</th>"; if (!$show_old && $canedit && $DB->result($result, 0, 0) != 0) { echo "<th>"; User::dropdown(array('value' => $consitem->fields["entities_id"], 'right' => 'all')); echo " <input type='submit' class='submit' name='give' value='" . $LANG['consumables'][32] . "'>"; echo "</th>"; } else { echo "<th> </th>"; } if ($canedit) { echo "<th> </th>"; } echo "</tr>"; } $where = ""; $leftjoin = ""; $addselect = ""; 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`"; $leftjoin = " LEFT JOIN `glpi_users` ON (`glpi_users`.`id` = `glpi_consumables`.`users_id`) "; $addselect = ", `glpi_users`.`realname` AS REALNAME,\n `glpi_users`.`firstname` AS FIRSTNAME,\n `glpi_users`.`id` AS USERID,\n `glpi_users`.`name` AS USERNAME "; } $query = "SELECT `glpi_consumables`.*\n {$addselect}\n FROM `glpi_consumables`\n {$leftjoin}\n WHERE `consumableitems_id` = '{$tID}'\n {$where}"; if ($result = $DB->query($query)) { $number = $DB->numrows($result); while ($data = $DB->fetch_array($result)) { $date_in = convDate($data["date_in"]); $date_out = convDate($data["date_out"]); echo "<tr class='tab_bg_1'><td class='center'>" . $data["id"] . "</td>"; echo "<td class='center'>" . self::getStatus($data["id"]) . "</td>"; echo "<td class='center'>" . $date_in . "</td>"; echo "<td class='center'>" . $date_out . "</td>"; if ($show_old) { echo "<td class='center'>"; echo formatUserName($data["USERID"], $data["USERNAME"], $data["REALNAME"], $data["FIRSTNAME"]); echo "</td>"; } echo "<td class='center'>"; Infocom::showDisplayLink('Consumable', $data["id"], 1); echo "</td>"; if (!$show_old && $canedit) { echo "<td class='center'>"; echo "<input type='checkbox' name='out[" . $data["id"] . "]'>"; echo "</td>"; } if ($show_old && $canedit) { echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/consumable.form.php?restore=restore&id=" . $data["id"] . "&tID={$tID}'>" . $LANG['consumables'][37] . "</a>"; echo "</td>"; } echo "<td class='center'>"; echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/consumable.form.php?delete=delete&id=" . $data["id"] . "&tID={$tID}'>" . $LANG['buttons'][6] . "</a>"; echo "</td></tr>"; } } echo "</table></div>"; if (!$show_old && $canedit) { echo "</form>"; } }
/** * 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, 'r')) { return false; } $canedit = $consitem->can($tID, 'w'); $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`"; } $query = "SELECT `glpi_consumables`.*\n FROM `glpi_consumables`\n WHERE `consumableitems_id` = '{$tID}'\n {$where}"; $result = $DB->query($query); $number = $DB->numrows($result); if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $actions = array('delete' => _x('button', 'Delete permanently'), 'activate_infocoms' => __('Enable the financial and administrative information')); if ($show_old) { $actions['restore'] = __('Back to stock'); } else { $actions['give'] = _x('button', 'Give'); } $paramsma = array('num_displayed' => $number, 'specific_actions' => $actions, 'extraparams' => array('entities_id' => $consitem->getEntityID())); Html::showMassiveActions(__CLASS__, $paramsma); echo "<input type='hidden' name='consumableitems_id' value='{$tID}'>\n"; } echo "<div class='spaced'><table class='tab_cadre_fixe'>"; 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; echo "<tr>"; if ($canedit) { echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; } echo "<th>" . __('ID') . "</th>"; echo "<th>" . _x('item', 'State') . "</th>"; echo "<th>" . __('Add date') . "</th>"; if ($show_old) { echo "<th>" . __('Use date') . "</th>"; echo "<th>" . __('Given to') . "</th>"; } echo "<th width='200px'>" . __('Financial and administrative information') . "</th>"; echo "</tr>"; } if ($result = $DB->query($query)) { $number = $DB->numrows($result); 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"], 1); echo "</td>"; echo "</tr>"; } } echo "</table>"; if ($canedit && $number) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }
/** * Print out the cartridges of a defined type * * @param $cartitem object of CartridgeItem class * @param $show_old boolean : show old cartridges or not. * *@return Nothing (displays) **/ static function showForCartridgeItem(CartridgeItem $cartitem, $show_old = 0) { global $DB, $CFG_GLPI, $LANG; $tID = $cartitem->getField('id'); if (!$cartitem->can($tID, 'r')) { return false; } $canedit = $cartitem->can($tID, 'r'); $query = "SELECT count(*) AS COUNT\n FROM `glpi_cartridges`\n WHERE (`cartridgeitems_id` = '{$tID}')"; if ($result = $DB->query($query)) { $total = $DB->result($result, 0, "COUNT"); // $unused = self::getUnusedNumber($tID); // $used = self::getUsedNumber($tID); // $old = self::getOldNumber($tID); echo "<div class='spaced'><table class='tab_cadre_fixe'>"; if (!$show_old) { echo "<tr><th colspan='7'>" . self::getCount($tID, -1) . "</th>"; echo "<th colspan='2'> </th></tr>"; } else { // Old echo "<tr><th colspan='8'>" . $LANG['cartridges'][35] . "</th>"; echo "<th colspan='2'> </th></tr>"; } $i = 0; echo "<tr><th>" . $LANG['common'][2] . "</th><th>" . $LANG['consumables'][23] . "</th>"; echo "<th>" . $LANG['cartridges'][24] . "</th><th>" . $LANG['consumables'][26] . "</th>"; echo "<th>" . $LANG['cartridges'][27] . "</th><th>" . $LANG['search'][9] . "</th>"; if ($show_old) { echo "<th>" . $LANG['cartridges'][39] . "</th>"; } echo "<th>" . $LANG['financial'][3] . "</th>"; echo "<th colspan='2'> </th>"; echo "</tr>"; } if (!$show_old) { // NEW $where = " AND `glpi_cartridges`.`date_out` IS NULL"; } else { //OLD $where = " AND `glpi_cartridges`.`date_out` IS NOT NULL"; } $stock_time = 0; $use_time = 0; $pages_printed = 0; $nb_pages_printed = 0; $ORDER = " `glpi_cartridges`.`date_use` ASC,\n `glpi_cartridges`.`date_out` DESC,\n `glpi_cartridges`.`date_in`"; if (!$show_old) { $ORDER = " `glpi_cartridges`.`date_out` ASC,\n `glpi_cartridges`.`date_use` ASC,\n `glpi_cartridges`.`date_in`"; } $query = "SELECT `glpi_cartridges`.*,\n `glpi_printers`.`id` AS printID,\n `glpi_printers`.`name` AS printname,\n `glpi_printers`.`init_pages_counter`\n FROM `glpi_cartridges`\n LEFT JOIN `glpi_printers`\n ON (`glpi_cartridges`.`printers_id` = `glpi_printers`.`id`)\n WHERE `glpi_cartridges`.`cartridgeitems_id` = '{$tID}'\n {$where}\n ORDER BY {$ORDER}"; $pages = array(); if ($result = $DB->query($query)) { $number = $DB->numrows($result); while ($data = $DB->fetch_array($result)) { $date_in = convDate($data["date_in"]); $date_use = convDate($data["date_use"]); $date_out = convDate($data["date_out"]); $printer = $data["printers_id"]; $page = $data["pages"]; echo "<tr class='tab_bg_1'><td class='center'>" . $data["id"] . "</td>"; echo "<td class='center'>" . self::getStatus($data["date_use"], $data["date_out"]); echo "</td><td class='center'>" . $date_in . "</td>"; echo "<td class='center'>" . $date_use . "</td>"; echo "<td class='center'>"; if (!is_null($date_use)) { if ($data["printID"] > 0) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/printer.form.php?id=" . $data["printID"] . "'><strong>" . $data["printname"]; if ($_SESSION['glpiis_ids_visible']) { echo " (" . $data["printID"] . ")"; } echo "</strong></a>"; } else { echo NOT_AVAILABLE; } $tmp_dbeg = explode("-", $data["date_in"]); $tmp_dend = explode("-", $data["date_use"]); $stock_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]); $stock_time += $stock_time_tmp; } echo "</td><td class='center'>"; echo $date_out; if ($show_old) { $tmp_dbeg = explode("-", $data["date_use"]); $tmp_dend = explode("-", $data["date_out"]); $use_time_tmp = mktime(0, 0, 0, $tmp_dend[1], $tmp_dend[2], $tmp_dend[0]) - mktime(0, 0, 0, $tmp_dbeg[1], $tmp_dbeg[2], $tmp_dbeg[0]); $use_time += $use_time_tmp; } echo "</td>"; if ($show_old) { // Get initial counter page if (!isset($pages[$printer])) { $pages[$printer] = $data['init_pages_counter']; } echo "<td class='center'>"; if ($pages[$printer] < $data['pages']) { $pages_printed += $data['pages'] - $pages[$printer]; $nb_pages_printed++; echo $data['pages'] - $pages[$printer] . " " . $LANG['printers'][31]; $pages[$printer] = $data['pages']; } echo "</td>"; } echo "<td class='center'>"; Infocom::showDisplayLink('Cartridge', $data["id"], 1); echo "</td>"; echo "<td class='center'>"; if (!is_null($date_use) && $canedit) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/cartridge.form.php?restore=restore&id=" . $data["id"] . "&tID={$tID}'>" . $LANG['consumables'][37] . "</a>"; } else { echo " "; } echo "</td>"; echo "<td class='center'>"; if ($canedit) { echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/cartridge.form.php?delete=delete&id=" . $data["id"] . "&tID={$tID}'>" . $LANG['buttons'][6] . "</a>"; } else { echo " "; } echo "</td></tr>"; } if ($show_old && $number > 0) { if ($nb_pages_printed == 0) { $nb_pages_printed = 1; } echo "<tr class='tab_bg_2'><td colspan='3'> </td>"; echo "<td class='center'>" . $LANG['cartridges'][40] . " :<br>"; echo round($stock_time / $number / 60 / 60 / 24 / 30.5, 1) . " " . $LANG['financial'][57] . "</td>"; echo "<td> </td>"; echo "<td class='center'>" . $LANG['cartridges'][41] . " :<br>"; echo round($use_time / $number / 60 / 60 / 24 / 30.5, 1) . " " . $LANG['financial'][57] . "</td>"; echo "<td class='center'>" . $LANG['cartridges'][42] . " :<br>"; echo round($pages_printed / $nb_pages_printed) . "</td>"; echo "<td colspan='3'> </td></tr>"; } } echo "</table></div>\n\n"; }