本文整理汇总了PHP中Software::getTypeName方法的典型用法代码示例。如果您正苦于以下问题:PHP Software::getTypeName方法的具体用法?PHP Software::getTypeName怎么用?PHP Software::getTypeName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Software
的用法示例。
在下文中一共展示了Software::getTypeName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pdfMain
static function pdfMain(PluginPdfSimplePDF $pdf, SoftwareLicense $license, $main = true, $cpt = true)
{
global $DB;
$ID = $license->getField('id');
$pdf->setColumnsSize(100);
$entity = '';
if (Session::isMultiEntitiesMode() && !$main) {
$entity = ' (' . Html::clean(Dropdown::getDropdownName('glpi_entities', $license->fields['entities_id'])) . ')';
}
$pdf->displayTitle('<b><i>' . sprintf(__('%1$s: %2$s'), __('ID') . "</i>", $ID . "</b>" . $entity));
$pdf->setColumnsSize(50, 50);
$pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), Software::getTypeName(1) . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwares', $license->fields['softwares_id']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Type') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $license->fields['softwarelicensetypes_id']))));
$pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Name') . '</i></b>', $license->fields['name']), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Serial number') . '</i></b>', $license->fields['serial']));
$pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Purchase version') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_buy']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Inventory number') . '</i></b>', $license->fields['otherserial']));
$pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), __('Version in use') . '</i></b>', Html::clean(Dropdown::getDropdownName('glpi_softwareversions', $license->fields['softwareversions_id_use']))), '<b><i>' . sprintf(__('%1$s: %2$s'), __('Expiration') . '</i></b>', Html::convDate($license->fields['expire'])));
$col2 = '';
if ($cpt) {
$col2 = '<b><i>' . sprintf(__('%1$s: %2$s'), __('Affected computers') . '</i></b>', Computer_SoftwareLicense::countForLicense($ID));
}
$pdf->displayLine('<b><i>' . sprintf(__('%1$s: %2$s'), _x('quantity', 'Number') . '</i></b>', $license->fields['number'] > 0 ? $license->fields['number'] : __('Unlimited')), $col2);
$pdf->setColumnsSize(100);
PluginPdfCommon::mainLine($pdf, $license, 'comment');
if ($main) {
$pdf->displaySpace();
}
}
示例2: showForSoftware
/**
* Show Licenses of a software
*
* @param $software Software object
*
* @return nothing
**/
static function showForSoftware(Software $software)
{
global $DB, $CFG_GLPI;
$softwares_id = $software->getField('id');
$license = new self();
$computer = new Computer();
if (!$software->can($softwares_id, READ)) {
return false;
}
$columns = array('name' => __('Name'), 'entity' => __('Entity'), 'serial' => __('Serial number'), 'number' => _x('quantity', 'Number'), '_affected' => __('Affected computers'), 'typename' => __('Type'), 'buyname' => __('Purchase version'), 'usename' => __('Version in use'), 'expire' => __('Expiration'));
if (!$software->isRecursive()) {
unset($columns['entity']);
}
if (isset($_GET["start"])) {
$start = $_GET["start"];
} else {
$start = 0;
}
if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
$order = "DESC";
} else {
$order = "ASC";
}
if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) {
$sort = "`" . $_GET["sort"] . "`";
} else {
$sort = "`entity` {$order}, `name`";
}
// Righ type is enough. Can add a License on a software we have Read access
$canedit = Software::canUpdate();
$showmassiveactions = $canedit;
// Total Number of events
$number = countElementsInTable("glpi_softwarelicenses", "glpi_softwarelicenses.softwares_id = {$softwares_id} " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true));
echo "<div class='spaced'>";
Session::initNavigateListItems('SoftwareLicense', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $software->getName()));
if ($canedit) {
echo "<div class='center firstbloc'>";
echo "<a class='vsubmit' href='softwarelicense.form.php?softwares_id={$softwares_id}'>" . _x('button', 'Add a license') . "</a>";
echo "</div>";
}
$rand = mt_rand();
$query = "SELECT `glpi_softwarelicenses`.*,\n `buyvers`.`name` AS buyname,\n `usevers`.`name` AS usename,\n `glpi_entities`.`completename` AS entity,\n `glpi_softwarelicensetypes`.`name` AS typename\n FROM `glpi_softwarelicenses`\n LEFT JOIN `glpi_softwareversions` AS buyvers\n ON (`buyvers`.`id` = `glpi_softwarelicenses`.`softwareversions_id_buy`)\n LEFT JOIN `glpi_softwareversions` AS usevers\n ON (`usevers`.`id` = `glpi_softwarelicenses`.`softwareversions_id_use`)\n LEFT JOIN `glpi_entities`\n ON (`glpi_entities`.`id` = `glpi_softwarelicenses`.`entities_id`)\n LEFT JOIN `glpi_softwarelicensetypes`\n ON (`glpi_softwarelicensetypes`.`id`\n = `glpi_softwarelicenses`.`softwarelicensetypes_id`)\n WHERE (`glpi_softwarelicenses`.`softwares_id` = '{$softwares_id}') " . getEntitiesRestrictRequest('AND', 'glpi_softwarelicenses', '', '', true) . "\n ORDER BY {$sort} {$order}\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
if ($result = $DB->query($query)) {
if ($num_displayed = $DB->numrows($result)) {
// Display the pager
Html::printAjaxPager(self::getTypeName(Session::getPluralNumber()), $start, $number);
if ($showmassiveactions) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $num_displayed, 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('options' => array('glpi_softwareversions.name' => array('condition' => "`glpi_softwareversions`.`softwares_id`\n = {$softwares_id}"), 'glpi_softwarelicenses.name' => array('itemlink_as_string' => true))));
Html::showMassiveActions($massiveactionparams);
}
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr><th>";
$header_top = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom = Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_end = '';
foreach ($columns as $key => $val) {
// Non order column
if ($key[0] == '_') {
$header_end .= "<th>{$val}</th>";
} else {
$header_end .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&order=" . ($order == "ASC" ? "DESC" : "ASC") . "&start=0\");'>{$val}</a></th>";
}
}
$header_end .= "</tr>\n";
echo $header_begin . $header_top . $header_end;
$tot_assoc = 0;
for ($tot = 0; $data = $DB->fetch_assoc($result);) {
Session::addToNavigateListItems('SoftwareLicense', $data['id']);
$expired = true;
if (is_null($data['expire']) || $data['expire'] > date('Y-m-d')) {
$expired = false;
}
echo "<tr class='tab_bg_2" . ($expired ? '_2' : '') . "'>";
if ($license->canEdit($data['id'])) {
echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
} else {
echo "<td> </td>";
}
echo "<td><a href='softwarelicense.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a></td>";
if (isset($columns['entity'])) {
echo "<td>";
echo $data['entity'];
echo "</td>";
}
echo "<td>" . $data['serial'] . "</td>";
echo "<td class='numeric'>" . ($data['number'] > 0 ? $data['number'] : __('Unlimited')) . "</td>";
$nb_assoc = Computer_SoftwareLicense::countForLicense($data['id']);
$tot_assoc += $nb_assoc;
$color = $data['is_valid'] ? 'green' : 'red';
echo "<td class='numeric {$color}'>" . $nb_assoc . "</td>";
//.........这里部分代码省略.........
示例3: dropdownMyDevices
/**
* Make a select box for Ticket my devices
*
* @param $userID User ID for my device section (default 0)
* @param $entity_restrict restrict to a specific entity (default -1)
* @param $itemtype of selected item (default 0)
* @param $items_id of selected item (default 0)
*
* @return nothing (print out an HTML select box)
**/
static function dropdownMyDevices($userID = 0, $entity_restrict = -1, $itemtype = 0, $items_id = 0)
{
global $DB, $CFG_GLPI;
if ($userID == 0) {
$userID = Session::getLoginUserID();
}
$rand = mt_rand();
$already_add = array();
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, self::HELPDESK_MY_HARDWARE)) {
$my_devices = "";
$my_item = $itemtype . '_' . $items_id;
// My items
foreach ($CFG_GLPI["linkuser_types"] as $itemtype) {
if (($item = getItemForItemtype($itemtype)) && parent::isPossibleToAssignType($itemtype)) {
$itemtable = getTableForItemType($itemtype);
$query = "SELECT *\n FROM `{$itemtable}`\n WHERE `users_id` = '{$userID}'";
if ($item->maybeDeleted()) {
$query .= " AND `is_deleted` = '0' ";
}
if ($item->maybeTemplate()) {
$query .= " AND `is_template` = '0' ";
}
if (in_array($itemtype, $CFG_GLPI["helpdesk_visible_types"])) {
$query .= " AND `is_helpdesk_visible` = '1' ";
}
$query .= getEntitiesRestrictRequest("AND", $itemtable, "", $entity_restrict, $item->maybeRecursive()) . "\n ORDER BY `name` ";
$result = $DB->query($query);
$nb = $DB->numrows($result);
if ($DB->numrows($result) > 0) {
$type_name = $item->getTypeName($nb);
while ($data = $DB->fetch_assoc($result)) {
$output = $data["name"];
if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
$output = sprintf(__('%1$s (%2$s)'), $output, $data['id']);
}
$output = sprintf(__('%1$s - %2$s'), $type_name, $output);
if ($itemtype != 'Software') {
if (!empty($data['serial'])) {
$output = sprintf(__('%1$s - %2$s'), $output, $data['serial']);
}
if (!empty($data['otherserial'])) {
$output = sprintf(__('%1$s - %2$s'), $output, $data['otherserial']);
}
}
$my_devices .= "<option title=\"{$output}\" value='" . $itemtype . "_" . $data["id"] . "' " . ($my_item == $itemtype . "_" . $data["id"] ? "selected" : "") . ">" . Toolbox::substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
$already_add[$itemtype][] = $data["id"];
}
}
}
}
if (!empty($my_devices)) {
$my_devices = "<optgroup label=\"" . __s('My devices') . "\">" . $my_devices . "</optgroup>";
}
// My group items
if (Session::haveRight("show_group_hardware", "1")) {
$group_where = "";
$query = "SELECT `glpi_groups_users`.`groups_id`, `glpi_groups`.`name`\n FROM `glpi_groups_users`\n LEFT JOIN `glpi_groups`\n ON (`glpi_groups`.`id` = `glpi_groups_users`.`groups_id`)\n WHERE `glpi_groups_users`.`users_id` = '{$userID}' " . getEntitiesRestrictRequest("AND", "glpi_groups", "", $entity_restrict, true);
$result = $DB->query($query);
$first = true;
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_assoc($result)) {
if ($first) {
$first = false;
} else {
$group_where .= " OR ";
}
$a_groups = getAncestorsOf("glpi_groups", $data["groups_id"]);
$a_groups[$data["groups_id"]] = $data["groups_id"];
$group_where .= " `groups_id` IN (" . implode(',', $a_groups) . ") ";
}
$tmp_device = "";
foreach ($CFG_GLPI["linkgroup_types"] as $itemtype) {
if (($item = getItemForItemtype($itemtype)) && parent::isPossibleToAssignType($itemtype)) {
$itemtable = getTableForItemType($itemtype);
$query = "SELECT *\n FROM `{$itemtable}`\n WHERE ({$group_where}) " . getEntitiesRestrictRequest("AND", $itemtable, "", $entity_restrict, $item->maybeRecursive());
if ($item->maybeDeleted()) {
$query .= " AND `is_deleted` = '0' ";
}
if ($item->maybeTemplate()) {
$query .= " AND `is_template` = '0' ";
}
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$type_name = $item->getTypeName();
if (!isset($already_add[$itemtype])) {
$already_add[$itemtype] = array();
}
while ($data = $DB->fetch_assoc($result)) {
if (!in_array($data["id"], $already_add[$itemtype])) {
$output = '';
//.........这里部分代码省略.........
示例4: dropdownMyDevices
/**
* Make a select box for Ticket my devices
*
*
* @param $userID User ID for my device section
* @param $entity_restrict restrict to a specific entity
* @param $itemtype of selected item
* @param $items_id of selected item
*
* @return nothing (print out an HTML select box)
**/
static function dropdownMyDevices($userID = 0, $entity_restrict = -1, $itemtype = 0, $items_id = 0)
{
global $DB, $LANG, $CFG_GLPI;
if ($userID == 0) {
$userID = getLoginUserID();
}
$rand = mt_rand();
$already_add = array();
if ($_SESSION["glpiactiveprofile"]["helpdesk_hardware"] & pow(2, HELPDESK_MY_HARDWARE)) {
$my_devices = "";
$my_item = $itemtype . '_' . $items_id;
// My items
foreach ($CFG_GLPI["linkuser_types"] as $itemtype) {
if (class_exists($itemtype) && self::isPossibleToAssignType($itemtype)) {
$itemtable = getTableForItemType($itemtype);
$item = new $itemtype();
$query = "SELECT *\n FROM `{$itemtable}`\n WHERE `users_id` = '{$userID}'";
if ($item->maybeDeleted()) {
$query .= " AND `is_deleted` = '0' ";
}
if ($item->maybeTemplate()) {
$query .= " AND `is_template` = '0' ";
}
if (in_array($itemtype, $CFG_GLPI["helpdesk_visible_types"])) {
$query .= " AND `is_helpdesk_visible` = '1' ";
}
$query .= getEntitiesRestrictRequest("AND", $itemtable, "", $entity_restrict, $item->maybeRecursive());
"\n ORDER BY `name` ";
$result = $DB->query($query);
$nb = $DB->numrows($result);
if ($DB->numrows($result) > 0) {
$type_name = $item->getTypeName($nb);
while ($data = $DB->fetch_array($result)) {
$output = $data["name"];
if (empty($output) || $_SESSION["glpiis_ids_visible"]) {
$output .= " (" . $data['id'] . ")";
}
$output = $type_name . " - " . $output;
if ($itemtype != 'Software') {
if (!empty($data['serial'])) {
$output .= " - " . $data['serial'];
}
if (!empty($data['otherserial'])) {
$output .= " - " . $data['otherserial'];
}
}
$my_devices .= "<option title=\"{$output}\" value='" . $itemtype . "_" . $data["id"] . "' " . ($my_item == $itemtype . "_" . $data["id"] ? "selected" : "") . ">" . utf8_substr($output, 0, $_SESSION["glpidropdown_chars_limit"]) . "</option>";
$already_add[$itemtype][] = $data["id"];
}
}
}
}
if (!empty($my_devices)) {
$my_devices = "<optgroup label=\"" . $LANG['tracking'][1] . "\">" . $my_devices . "</optgroup>";
}
// My group items
if (haveRight("show_group_hardware", "1")) {
$group_where = "";
$query = "SELECT `glpi_groups_users`.`groups_id`, `glpi_groups`.`name`\n FROM `glpi_groups_users`\n LEFT JOIN `glpi_groups`\n ON (`glpi_groups`.`id` = `glpi_groups_users`.`groups_id`)\n WHERE `glpi_groups_users`.`users_id` = '{$userID}' " . getEntitiesRestrictRequest("AND", "glpi_groups", "", $entity_restrict, true);
$result = $DB->query($query);
$first = true;
if ($DB->numrows($result) > 0) {
while ($data = $DB->fetch_array($result)) {
if ($first) {
$first = false;
} else {
$group_where .= " OR ";
}
$group_where .= " `groups_id` = '" . $data["groups_id"] . "' ";
}
$tmp_device = "";
foreach ($CFG_GLPI["linkgroup_types"] as $itemtype) {
if (class_exists($itemtype) && self::isPossibleToAssignType($itemtype)) {
$itemtable = getTableForItemType($itemtype);
$item = new $itemtype();
$query = "SELECT *\n FROM `{$itemtable}`\n WHERE ({$group_where}) " . getEntitiesRestrictRequest("AND", $itemtable, "", $entity_restrict, $item->maybeRecursive());
if ($item->maybeDeleted()) {
$query .= " AND `is_deleted` = '0' ";
}
if ($item->maybeTemplate()) {
$query .= " AND `is_template` = '0' ";
}
$result = $DB->query($query);
if ($DB->numrows($result) > 0) {
$type_name = $item->getTypeName();
if (!isset($already_add[$itemtype])) {
$already_add[$itemtype] = array();
}
while ($data = $DB->fetch_array($result)) {
//.........这里部分代码省略.........
示例5: Copyright
based on GLPI - Gestionnaire Libre de Parc Informatique
Copyright (C) 2003-2014 by the INDEPNET Development Team.
-------------------------------------------------------------------------
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("software", READ);
Html::header(Software::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "software");
Search::show('Software');
Html::footer();
示例6: showForItem
/**
* Display form to unlock fields and links
*
* @param CommonDBTM $item the source item
**/
static function showForItem(CommonDBTM $item)
{
global $DB;
$ID = $item->getID();
$itemtype = $item->getType();
$header = false;
//If user doesn't have write right on the item, lock form must not be displayed
if (!$item->canCreate()) {
return false;
}
echo "<div width='50%'>";
echo "<form method='post' id='lock_form'\n name='lock_form' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='id' value='{$ID}'>\n";
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>\n";
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th colspan='2''>" . __('Locked items') . "</th></tr>";
//Use a hook to allow external inventory tools to manage per field lock
$results = Plugin::doHookFunction('display_locked_fields', array('item' => $item, 'header' => $header));
$header |= $results['header'];
//Special locks for computers only
if ($itemtype == 'Computer') {
//Locks for items recorded in glpi_computers_items table
$types = array('Monitor', 'Peripheral', 'Printer');
foreach ($types as $type) {
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID, 'itemtype' => $type);
$params['FIELDS'] = array('id', 'items_id');
$first = true;
foreach ($DB->request('glpi_computers_items', $params) as $line) {
$tmp = new $type();
$tmp->getFromDB($line['items_id']);
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_Item[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $tmp->getName() . "</td>";
echo "</tr>\n";
}
}
$types = array('ComputerDisk', 'ComputerVirtualMachine');
foreach ($types as $type) {
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$params['FIELDS'] = array('id', 'name');
$first = true;
foreach ($DB->request(getTableForItemType($type), $params) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . $type::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='" . $type . "[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['name'] . "</td>";
echo "</tr>\n";
}
}
//Software versions
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$first = true;
$query = "SELECT `csv`.`id` AS `id`,\n `sv`.`name` AS `version`,\n `s`.`name` AS `software`\n FROM `glpi_computers_softwareversions` AS csv\n LEFT JOIN `glpi_softwareversions` AS sv\n ON (`csv`.`softwareversions_id` = `sv`.`id`)\n LEFT JOIN `glpi_softwares` AS s\n ON (`sv`.`softwares_id` = `s`.`id`)\n WHERE `csv`.`is_deleted` = '1'\n AND `csv`.`is_dynamic` = '1'\n AND `csv`.`computers_id` = '{$ID}'";
foreach ($DB->request($query) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . Software::getTypeName(2) . "</th></tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_SoftwareVersion[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
echo "</tr>\n";
}
//Software licenses
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'computers_id' => $ID);
$first = true;
$query = "SELECT `csv`.`id` AS `id`,\n `sv`.`name` AS `version`,\n `s`.`name` AS `software`\n FROM `glpi_computers_softwarelicenses` AS csv\n LEFT JOIN `glpi_softwarelicenses` AS sv\n ON (`csv`.`softwarelicenses_id` = `sv`.`id`)\n LEFT JOIN `glpi_softwares` AS s\n ON (`sv`.`softwares_id` = `s`.`id`)\n WHERE `csv`.`is_deleted` = '1'\n AND `csv`.`is_dynamic` = '1'\n AND `csv`.`computers_id` = '{$ID}'";
foreach ($DB->request($query) as $line) {
$header = true;
if ($first) {
echo "<tr><th colspan='2'>" . SoftwareLicense::getTypeName(2) . "</th>" . "</tr>\n";
$first = false;
}
echo "<tr class='tab_bg_1'><td class='center' width='10'>";
echo "<input type='checkbox' name='Computer_SoftwareLicense[" . $line['id'] . "]'></td>";
echo "<td class='left' width='95%'>" . $line['software'] . " " . $line['version'] . "</td>";
echo "</tr>\n";
}
}
$first = true;
$item = new NetworkPort();
$params = array('is_dynamic' => 1, 'is_deleted' => 1, 'items_id' => $ID, 'itemtype' => $itemtype);
$params['FIELDS'] = array('id');
foreach ($DB->request('glpi_networkports', $params) as $line) {
$item->getFromDB($line['id']);
//.........这里部分代码省略.........
示例7: showForSoftware
/**
* Show Versions of a software
*
* @param $soft Software object
*
* @return nothing
**/
static function showForSoftware(Software $soft)
{
global $DB, $CFG_GLPI;
$softwares_id = $soft->getField('id');
if (!$soft->can($softwares_id, READ)) {
return false;
}
$canedit = $soft->canEdit($softwares_id);
echo "<div class='spaced'>";
if ($canedit) {
echo "<div class='center firstbloc'>";
echo "<a class='vsubmit' href='softwareversion.form.php?softwares_id={$softwares_id}'>" . _x('button', 'Add a version') . "</a>";
echo "</div>";
}
$query = "SELECT `glpi_softwareversions`.*,\n `glpi_states`.`name` AS sname\n FROM `glpi_softwareversions`\n LEFT JOIN `glpi_states` ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n WHERE `softwares_id` = '{$softwares_id}'\n ORDER BY `name`";
Session::initNavigateListItems('SoftwareVersion', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->getName()));
if ($result = $DB->query($query)) {
if ($DB->numrows($result)) {
echo "<table class='tab_cadre_fixehov'><tr>";
echo "<th>" . self::getTypeName(Session::getPluralNumber()) . "</th>";
echo "<th>" . __('Status') . "</th>";
echo "<th>" . __('Operating system') . "</th>";
echo "<th>" . _n('Installation', 'Installations', Session::getPluralNumber()) . "</th>";
echo "<th>" . __('Comments') . "</th>";
echo "</tr>\n";
for ($tot = $nb = 0; $data = $DB->fetch_assoc($result); $tot += $nb) {
Session::addToNavigateListItems('SoftwareVersion', $data['id']);
$nb = Computer_SoftwareVersion::countForVersion($data['id']);
echo "<tr class='tab_bg_2'>";
echo "<td><a href='softwareversion.form.php?id=" . $data['id'] . "'>";
echo $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a></td>";
echo "<td>" . $data['sname'] . "</td>";
echo "<td class='right'>" . Dropdown::getDropdownName('glpi_operatingsystems', $data['operatingsystems_id']);
echo "</td>";
echo "<td class='numeric'>{$nb}</td>";
echo "<td>" . $data['comment'] . "</td></tr>\n";
}
echo "<tr class='tab_bg_1 noHover'><td class='right b' colspan='3'>" . __('Total') . "</td>";
echo "<td class='numeric b'>{$tot}</td><td></td></tr>";
echo "</table>\n";
} else {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table>\n";
}
}
echo "</div>";
}
示例8: showForLicense
/**
* Show computers linked to a License
*
* @param $license SoftwareLicense object
*
* @return nothing
**/
static function showForLicense(SoftwareLicense $license)
{
global $DB, $CFG_GLPI;
$searchID = $license->getField('id');
if (!Software::canView() || !$searchID) {
return false;
}
$canedit = Session::haveRightsOr("software", array(CREATE, UPDATE, DELETE, PURGE));
$canshowcomputer = Computer::canView();
if (isset($_GET["start"])) {
$start = $_GET["start"];
} else {
$start = 0;
}
if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
$order = "DESC";
} else {
$order = "ASC";
}
if (isset($_GET["sort"]) && !empty($_GET["sort"])) {
// manage several param like location,compname : order first
$tmp = explode(",", $_GET["sort"]);
$sort = "`" . implode("` {$order},`", $tmp) . "`";
} else {
$sort = "`entity` {$order}, `compname`";
}
//SoftwareLicense ID
$query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_computers_softwarelicenses`\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwarelicenses`.`computers_id`\n = `glpi_computers`.`id`)\n WHERE `glpi_computers_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'" . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'\n AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'";
$number = 0;
if ($result = $DB->query($query_number)) {
$number = $DB->result($result, 0, 0);
}
echo "<div class='center'>";
if ($canedit) {
echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2 center'>";
echo "<td>";
Computer::dropdown(array('entity' => $license->fields['entities_id'], 'entity_sons' => $license->fields['is_recursive']));
echo "</td>";
echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
}
if ($number < 1) {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table></div>\n";
return;
}
// Display the pager
Html::printAjaxPager(__('Affected computers'), $start, $number);
$query = "SELECT `glpi_computers_softwarelicenses`.*,\n `glpi_computers`.`name` AS compname,\n `glpi_computers`.`id` AS cID,\n `glpi_computers`.`serial`,\n `glpi_computers`.`otherserial`,\n `glpi_users`.`name` AS username,\n `glpi_users`.`id` AS userid,\n `glpi_users`.`realname` AS userrealname,\n `glpi_users`.`firstname` AS userfirstname,\n `glpi_softwarelicenses`.`name` AS license,\n `glpi_softwarelicenses`.`id` AS vID,\n `glpi_softwarelicenses`.`name` AS vername,\n `glpi_entities`.`completename` AS entity,\n `glpi_locations`.`completename` AS location,\n `glpi_states`.`name` AS state,\n `glpi_groups`.`name` AS groupe,\n `glpi_softwarelicenses`.`name` AS lname,\n `glpi_softwarelicenses`.`id` AS lID,\n `glpi_softwarelicenses`.`softwares_id` AS softid\n FROM `glpi_computers_softwarelicenses`\n INNER JOIN `glpi_softwarelicenses`\n ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n = `glpi_softwarelicenses`.`id`)\n INNER JOIN `glpi_computers`\n ON (`glpi_computers_softwarelicenses`.`computers_id` = `glpi_computers`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_computers`.`entities_id` = `glpi_entities`.`id`)\n LEFT JOIN `glpi_locations`\n ON (`glpi_computers`.`locations_id` = `glpi_locations`.`id`)\n LEFT JOIN `glpi_states` ON (`glpi_computers`.`states_id` = `glpi_states`.`id`)\n LEFT JOIN `glpi_groups` ON (`glpi_computers`.`groups_id` = `glpi_groups`.`id`)\n LEFT JOIN `glpi_users` ON (`glpi_computers`.`users_id` = `glpi_users`.`id`)\n WHERE (`glpi_softwarelicenses`.`id` = '{$searchID}') " . getEntitiesRestrictRequest(' AND', 'glpi_computers') . "\n AND `glpi_computers`.`is_deleted` = '0'\n AND `glpi_computers`.`is_template` = '0'\n AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'\n ORDER BY {$sort} {$order}\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
$rand = mt_rand();
if ($result = $DB->query($query)) {
if ($data = $DB->fetch_assoc($result)) {
if ($canedit) {
$rand = mt_rand();
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $_SESSION['glpilist_limit'], 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
// show transfer only if multi licenses for this software
if (self::countLicenses($data['softid']) > 1) {
$massiveactionparams['specific_actions'][__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'move_license'] = _x('button', 'Move');
}
// Options to update license
$massiveactionparams['extraparams']['options']['move']['used'] = array($searchID);
$massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id'];
Html::showMassiveActions($massiveactionparams);
}
$soft = new Software();
$soft->getFromDB($license->fields['softwares_id']);
$showEntity = $license->isRecursive();
$linkUser = User::canView();
$text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]);
$text = sprintf(__('%1$s - %2$s'), $text, $data["vername"]);
Session::initNavigateListItems('Computer', $text);
$sort_img = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "' alt='' title=''>";
echo "<table class='tab_cadre_fixehov'>";
$columns = array('compname' => __('Name'), 'entity' => __('Entity'), 'serial' => __('Serial number'), 'otherserial' => __('Inventory number'), 'location,compname' => __('Location'), 'state,compname' => __('Status'), 'groupe,compname' => __('Group'), 'username,compname' => __('User'));
if (!$showEntity) {
unset($columns['entity']);
}
$sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
$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);
//.........这里部分代码省略.........
示例9: sprintf
$soft->check($_POST["id"], 'd');
$soft->delete($_POST);
Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s deletes an item'), $_SESSION["glpiname"]));
$soft->redirectToList();
} else {
if (isset($_POST["restore"])) {
$soft->check($_POST["id"], 'd');
$soft->restore($_POST);
Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s restores an item'), $_SESSION["glpiname"]));
$soft->redirectToList();
} else {
if (isset($_POST["purge"])) {
$soft->check($_POST["id"], 'd');
$soft->delete($_POST, 1);
Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s purges an item'), $_SESSION["glpiname"]));
$soft->redirectToList();
} else {
if (isset($_POST["update"])) {
$soft->check($_POST["id"], 'w');
$soft->update($_POST);
Event::log($_POST["id"], "software", 4, "inventory", sprintf(__('%s updates an item'), $_SESSION["glpiname"]));
Html::back();
} else {
Html::header(Software::getTypeName(2), $_SERVER['PHP_SELF'], "inventory", "software");
$soft->showForm($_GET["id"], array('withtemplate' => $_GET["withtemplate"]));
Html::footer();
}
}
}
}
}
示例10: getTabNameForItem
/**
* @see CommonGLPI::getTabNameForItem()
**/
function getTabNameForItem(CommonGLPI $item, $withtemplate = 0)
{
switch ($item->getType()) {
case 'Software':
if (!$withtemplate) {
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(self::getTypeName(Session::getPluralNumber()), self::countForSoftware($item->getID()));
}
return self::getTypeName(Session::getPluralNumber());
}
break;
case 'SoftwareVersion':
if (!$withtemplate) {
$nb = 0;
if ($_SESSION['glpishow_count_on_tabs']) {
$nb = self::countForVersion($item->getID());
}
return array(1 => __('Summary'), 2 => self::createTabEntry(self::getTypeName(Session::getPluralNumber()), $nb));
}
break;
case 'Computer':
// Installation allowed for template
if (Software::canView()) {
if ($_SESSION['glpishow_count_on_tabs']) {
return self::createTabEntry(Software::getTypeName(Session::getPluralNumber()), countElementsInTable('glpi_computers_softwareversions', "computers_id = '" . $item->getID() . "'\n AND `is_deleted`='0'"));
}
return Software::getTypeName(Session::getPluralNumber());
}
break;
}
return '';
}
示例11: showForLicense
/**
* Show users linked to a License
*
* @param $license SoftwareLicense object
*
* @return nothing
**/
static function showForLicense(SoftwareLicense $license)
{
global $DB, $CFG_GLPI;
$searchID = $license->getField('id');
if (!Software::canView() || !$searchID) {
return false;
}
$canedit = PluginFpsoftwareVersionhelper::checkRights("software", array(CREATE, UPDATE, DELETE, PURGE), "Or");
$canshowuser = User::canView();
if (isset($_GET["start"])) {
$start = $_GET["start"];
} else {
$start = 0;
}
if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
$order = "DESC";
} else {
$order = "ASC";
}
//SoftwareLicense ID
$query_number = "SELECT COUNT(*) AS cpt\n FROM `glpi_users_softwarelicenses`\n INNER JOIN `glpi_users`\n ON (`glpi_users_softwarelicenses`.`users_id`\n = `glpi_users`.`id`)\n WHERE `glpi_users_softwarelicenses`.`softwarelicenses_id` = '{$searchID}'";
$number = 0;
if ($result = $DB->query($query_number)) {
$number = $DB->result($result, 0, 0);
}
echo "<div class='center'>";
if ($canedit) {
echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . self::$front_url . "/front/user_softwarelicense.form.php'>";
echo "<input type='hidden' name='softwarelicenses_id' value='{$searchID}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2 center'>";
echo "<td>";
//FOR NOW ALL USERS ARE SHOWN, DON'T KNOW IF THERE SHOULD BE ANY RESTRICTION.
//ALSO IT CAUSES A POSSIBILITY TO ONE USER MANY TIMES.
User::dropdown(array('right' => 'all'));
echo "</td>";
echo "<td><input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
}
if ($number < 1) {
echo "<table class='tab_cadre_fixe'>";
echo "<tr><th>" . __('No item found') . "</th></tr>";
echo "</table></div>\n";
return;
}
// Display the pager
Html::printAjaxPager(__('Affected users'), $start, $number);
$query = "SELECT `glpi_users_softwarelicenses`.*,\n `glpi_users`.`name` AS username,\n `glpi_users`.`id` AS userid,\n `glpi_users`.`realname` AS userrealname,\n `glpi_users`.`firstname` AS userfirstname,\n `glpi_softwarelicenses`.`name` AS license,\n `glpi_softwarelicenses`.`id` AS lID\n FROM `glpi_users_softwarelicenses`\n INNER JOIN `glpi_softwarelicenses`\n ON (`glpi_users_softwarelicenses`.`softwarelicenses_id`\n = `glpi_softwarelicenses`.`id`)\n INNER JOIN `glpi_users`\n ON (`glpi_users_softwarelicenses`.`users_id` = `glpi_users`.`id`)\n WHERE `glpi_softwarelicenses`.`id` = '{$searchID}'\n LIMIT " . intval($start) . "," . intval($_SESSION['glpilist_limit']);
$rand = mt_rand();
if ($result = $DB->query($query)) {
if ($data = $DB->fetch_assoc($result)) {
if ($canedit) {
$rand = mt_rand();
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
list($higher_version, $massiveactionparams) = PluginFpsoftwareVersionhelper::massiveActionParams($rand, __CLASS__);
// Options to update license
$massiveactionparams['extraparams']['options']['move']['used'] = array($searchID);
$massiveactionparams['extraparams']['options']['move']['softwares_id'] = $license->fields['softwares_id'];
Html::showMassiveActions($higher_version ? $massiveactionparams : __CLASS__, $massiveactionparams);
}
$soft = new Software();
$soft->getFromDB($license->fields['softwares_id']);
$text = sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->fields["name"]);
$text = sprintf(__('%1$s - ID %2$s'), $text, $license->fields['softwares_id']);
Session::initNavigateListItems('User', $text);
echo "<table class='tab_cadre_fixehov'>";
$columns = array('username' => __('Username'), 'userrealname' => __('Surname'), 'userfirstname' => __('First name'), 'added' => __('Added'));
$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>";
}
foreach ($columns as $key => $val) {
// Non order column
$header_end .= "<th>{$val}</th>";
}
$header_end .= "</tr>\n";
echo $header_begin . $header_top . $header_end;
do {
Session::addToNavigateListItems('User', $data["userid"]);
echo "<tr class='tab_bg_2'>";
if ($canedit) {
echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
}
if ($canshowuser) {
echo "<td><a href='user.form.php?id=" . $data['userid'] . "'>" . $data['username'] . "</a></td>";
//.........这里部分代码省略.........