. * --------------------------------------------------------------------- */ if (!defined('GLPI_ROOT')) { die("Sorry. You can't access this file directly"); } /** * Item_Project Class * * Relation between Projects and Items * * @since 0.85 **/ class Item_Project extends CommonDBRelation{ // From CommonDBRelation static public $itemtype_1 = 'Project'; static public $items_id_1 = 'projects_id'; static public $itemtype_2 = 'itemtype'; static public $items_id_2 = 'items_id'; static public $checkItem_2_Rights = self::HAVE_VIEW_RIGHT_ON_ITEM; function getForbiddenStandardMassiveAction() { $forbidden = parent::getForbiddenStandardMassiveAction(); $forbidden[] = 'update'; return $forbidden; } function prepareInputForAdd($input) { // Avoid duplicate entry if (countElementsInTable($this->getTable(), ['projects_id' => $input['projects_id'], 'itemtype' => $input['itemtype'], 'items_id' => $input['items_id']]) > 0) { return false; } return parent::prepareInputForAdd($input); } /** * Print the HTML array for Items linked to a project * * @param $project Project object * * @return void **/ static function showForProject(Project $project) { global $CFG_GLPI; $instID = $project->fields['id']; if (!$project->can($instID, READ)) { return false; } $canedit = $project->canEdit($instID); $rand = mt_rand(); $types_iterator = self::getDistinctTypes($instID); $number = count($types_iterator); if ($canedit) { echo "
| ".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_top .= " | "; $header_bottom .= "".Html::getCheckAllAsCheckbox('mass'.__CLASS__.$rand); $header_bottom .= " | "; } $header_end .= ""._n('Type', 'Types', 1)." | "; $header_end .= "".Entity::getTypeName(1)." | "; $header_end .= "".__('Name')." | "; $header_end .= "".__('Serial number')." | "; $header_end .= "".__('Inventory number')." |
|---|---|---|---|---|---|---|
| "; Html::showMassiveActionCheckBox(__CLASS__, $data["linkid"]); echo " | "; } if ($prem) { $typename = $item->getTypeName($nb); echo "". (($nb > 1) ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename)." | "; $prem = false; } echo ""; echo Dropdown::getDropdownName("glpi_entities", $data['entity'])." | "; echo "".$namelink." | "; echo "".(isset($data["serial"])? "".$data["serial"]."" :"-"). " | "; echo "". (isset($data["otherserial"])? "".$data["otherserial"]."" :"-")." | "; echo "|
| ". (($totalnb > 0) ? sprintf(__('%1$s = %2$s'), __('Total'), $totalnb) :" "); echo " | ||||||