. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } // Relation between CartridgeItem and PrinterModel // since version 0.84 class CartridgeItem_PrinterModel extends CommonDBRelation { // From CommonDBRelation static public $itemtype_1 = 'CartridgeItem'; static public $items_id_1 = 'cartridgeitems_id'; static public $itemtype_2 = 'PrinterModel'; static public $items_id_2 = 'printermodels_id'; static public $checkItem_2_Rights = self::DONT_CHECK_ITEM_RIGHTS; function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); $forbidden[] = 'update'; return $forbidden; } static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { switch ($item->getType()) { case 'CartridgeItem' : self::showForCartridgeItem($item); break; } return true; } function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { if (!$withtemplate && Printer::canView()) { $nb = 0; switch ($item->getType()) { case 'CartridgeItem' : if ($_SESSION['glpishow_count_on_tabs']) { $nb = self::countForItem($item); } return self::createTabEntry(PrinterModel::getTypeName(Session::getPluralNumber()), $nb); } } return ''; } /** * Show the printer types that are compatible with a cartridge type * * @param $item CartridgeItem object * * @return boolean|void **/ static function showForCartridgeItem(CartridgeItem $item) { $instID = $item->getField('id'); if (!$item->can($instID, READ)) { return false; } $canedit = $item->canEdit($instID); $rand = mt_rand(); $iterator = self::getListForItem($item); $number = count($iterator); $used = []; $datas = []; while ($data = $iterator->next()) { $used[$data["id"]] = $data["id"]; $datas[$data["linkid"]] = $data; } if ($canedit) { echo "
| "; $header_top .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_bottom .= Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_end .= " | "; } $header_end .= ""._n('Model', 'Models', 1)." |
|---|---|
| "; Html::showMassiveActionCheckBox(__CLASS__, $data["linkid"]); echo " | "; } $opt = [ 'is_deleted' => 0, 'criteria' => [ [ 'field' => 40, // printer model 'searchtype' => 'equals', 'value' => $data["id"], ] ] ]; $url = Printer::getSearchURL()."?".Toolbox::append_params($opt, '&'); echo "".$data["name"]." | "; echo "
".__('No item found')."
"; } } }