本文整理汇总了PHP中CommonDBTM::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonDBTM::getName方法的具体用法?PHP CommonDBTM::getName怎么用?PHP CommonDBTM::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommonDBTM
的用法示例。
在下文中一共展示了CommonDBTM::getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: showForItem
/**
* Show rack associated to an item
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated rack must be displayed
* @param $withtemplate (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID) || !self::canView() || !$item->can($item->fields['id'], READ)) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$canedit = $item->canadditem('PluginRacksRack');
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$itemtype = $item->getType() . "Model";
$query = "SELECT `glpi_plugin_racks_racks_items`.`id` AS assocID,\n `glpi_plugin_racks_racks_items`.`faces_id`,\n `glpi_plugin_racks_racks_items`.`position`,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_racks_racks`.`name` AS assocName,\n `glpi_plugin_racks_racks`.*\n FROM `glpi_plugin_racks_racks_items`\n LEFT JOIN `glpi_plugin_racks_racks`\n ON (`glpi_plugin_racks_racks_items`.`plugin_racks_racks_id`=`glpi_plugin_racks_racks`.`id`)\n LEFT JOIN `glpi_entities` ON (`glpi_plugin_racks_racks`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_plugin_racks_racks_items`.`items_id` = '{$ID}'\n AND `glpi_plugin_racks_racks_items`.`itemtype` = '" . $itemtype . "' ";
$query .= getEntitiesRestrictRequest(" AND", "glpi_plugin_racks_racks", '', '', true);
$query .= " ORDER BY `assocName`";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$racks = array();
$rack = new PluginRacksRack();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$racks[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Disposition', 'racks') . "</th>";
echo "<th>" . __('Position', 'racks') . "</th>";
echo "<th>" . __('Location') . "</th>";
echo "<th>" . __('Place', 'racks') . "</th>";
echo "<th>" . __('Manufacturer') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginRacksRack', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($racks as $data) {
$rackID = $data["id"];
$link = NOT_AVAILABLE;
if ($rack->getFromDB($rackID)) {
$link = $rack->getLink();
}
Session::addToNavigateListItems('PluginRacksRack', $rackID);
$used[$rackID] = $rackID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
if ($data["faces_id"] == PluginRacksRack::FRONT_FACE) {
$faces_id = __('Front', 'racks');
} else {
$faces_id = _x('Rack enclosure', 'Back', 'racks');
}
echo "<td class='center'>" . $faces_id . "</td>";
echo "<td class='center'>" . $data["position"] . "</td>";
echo "<td>" . Dropdown::getDropdownName("glpi_locations", $data["locations_id"]) . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_plugin_racks_roomlocations", $data["plugin_racks_roomlocations_id"], 0) . "</td>";
echo "<td>" . Dropdown::getDropdownName("glpi_manufacturers", $data["manufacturers_id"]) . "</td>";
echo "</tr>";
$i++;
}
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
//.........这里部分代码省略.........
示例2: processMassiveActionsForOneItemtype
/**
* Execute massive action for PluginFormcreatorFrom
*
* @since version 0.85
*
* @see CommonDBTM::processMassiveActionsForOneItemtype()
**/
static function processMassiveActionsForOneItemtype(MassiveAction $ma, CommonDBTM $item, array $ids)
{
global $DB;
switch ($ma->getAction()) {
case 'Duplicate':
foreach ($ids as $id) {
if ($item->getFromDB($id) && $item->Duplicate()) {
Session::addMessageAfterRedirect(sprintf(__('Form duplicated: %s', 'formcreator'), $item->getName()));
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_OK);
} else {
// Example of ko count
$ma->itemDone($item->getType(), $id, MassiveAction::ACTION_KO);
}
}
return;
}
parent::processMassiveActionsForOneItemtype($ma, $item, $ids);
}
示例3: showListForItem
/**
* Display changes for an item
*
* Will also display changes of linked items
*
* @param $item CommonDBTM object
*
* @return nothing (display a table)
**/
static function showListForItem(CommonDBTM $item)
{
global $DB, $CFG_GLPI;
if (!Session::haveRight(self::$rightname, self::READALL)) {
return false;
}
if ($item->isNewID($item->getID())) {
return false;
}
$restrict = '';
$order = '';
$options['reset'] = 'reset';
switch ($item->getType()) {
case 'User':
$restrict = "(`glpi_changes_users`.`users_id` = '" . $item->getID() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 4;
// status
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'OR';
$options['criteria'][1]['field'] = 66;
// status
$options['criteria'][1]['searchtype'] = 'equals';
$options['criteria'][1]['value'] = $item->getID();
$options['criteria'][1]['link'] = 'OR';
$options['criteria'][5]['field'] = 5;
// status
$options['criteria'][5]['searchtype'] = 'equals';
$options['criteria'][5]['value'] = $item->getID();
$options['criteria'][5]['link'] = 'OR';
break;
case 'Supplier':
$restrict = "(`glpi_changes_suppliers`.`suppliers_id` = '" . $item->getID() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 6;
$options['criteria'][0]['searchtype'] = 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
case 'Group':
// Mini search engine
if ($item->haveChildren()) {
$tree = Session::getSavedOption(__CLASS__, 'tree', 0);
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'><th>" . __('Last changes') . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
_e('Child groups');
Dropdown::showYesNo('tree', $tree, -1, array('on_change' => 'reloadTab("start=0&tree="+this.value)'));
} else {
$tree = 0;
}
echo "</td></tr></table>";
if ($tree) {
$restrict = "IN (" . implode(',', getSonsOf('glpi_groups', $item->getID())) . ")";
} else {
$restrict = "='" . $item->getID() . "'";
}
$restrict = "(`glpi_changes_groups`.`groups_id` {$restrict}\n AND `glpi_changes_groups`.`type` = " . CommonITILActor::REQUESTER . ")";
$order = '`glpi_changes`.`date_mod` DESC';
$options['criteria'][0]['field'] = 71;
$options['criteria'][0]['searchtype'] = $tree ? 'under' : 'equals';
$options['criteria'][0]['value'] = $item->getID();
$options['criteria'][0]['link'] = 'AND';
break;
default:
$restrict = "(`items_id` = '" . $item->getID() . "'\n AND `itemtype` = '" . $item->getType() . "')";
$order = '`glpi_changes`.`date_mod` DESC';
break;
}
$query = "SELECT " . self::getCommonSelect() . "\n FROM `glpi_changes`\n LEFT JOIN `glpi_changes_items`\n ON (`glpi_changes`.`id` = `glpi_changes_items`.`changes_id`) " . self::getCommonLeftJoin() . "\n WHERE {$restrict} " . getEntitiesRestrictRequest("AND", "glpi_changes") . "\n ORDER BY {$order}\n LIMIT " . intval($_SESSION['glpilist_limit']);
$result = $DB->query($query);
$number = $DB->numrows($result);
// Ticket for the item
echo "<div class='firstbloc'><table class='tab_cadre_fixe'>";
$colspan = 11;
if (count($_SESSION["glpiactiveentities"]) > 1) {
$colspan++;
}
if ($number > 0) {
Session::initNavigateListItems('Change', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
echo "<tr><th colspan='{$colspan}'>";
//TRANS : %d is the number of problems
echo sprintf(_n('Last %d change', 'Last %d changes', $number), $number);
// echo "<span class='small_space'><a href='".$CFG_GLPI["root_doc"]."/front/ticket.php?".
// Toolbox::append_params($options,'&')."'>".__('Show all')."</a></span>";
echo "</th></tr>";
} else {
echo "<tr><th>" . __('No change found.') . "</th></tr>";
}
// Ticket list
//.........这里部分代码省略.........
示例4: generateLinkContents
/**
* Generate link
*
* @param $link string : original string content
* @param $item CommonDBTM : item used to make replacements
* @param $name string : name used for multi link generation
* @param $noip boolean : true to not evaluate IP/MAC
*
* @return array of link contents (may have several when item have several IP / MAC cases)
*/
static function generateLinkContents($link, CommonDBTM $item, $name = '', $noip = false)
{
global $DB;
if (strstr($link, "[ID]")) {
$link = str_replace("[ID]", $item->fields['id'], $link);
}
if (strstr($link, "[LOGIN]") && isset($_SESSION["glpiname"])) {
if (isset($_SESSION["glpiname"])) {
$link = str_replace("[LOGIN]", $_SESSION["glpiname"], $link);
}
}
if (strstr($link, "[NAME]")) {
$link = str_replace("[NAME]", $item->getName(), $link);
}
if (strstr($link, "[SERIAL]")) {
if ($item->isField('serial')) {
$link = str_replace("[SERIAL]", $item->getField('serial'), $link);
}
}
if (strstr($link, "[OTHERSERIAL]")) {
if ($item->isField('otherserial')) {
$link = str_replace("[OTHERSERIAL]", $item->getField('otherserial'), $link);
}
}
if (strstr($link, "[LOCATIONID]")) {
if ($item->isField('locations_id')) {
$link = str_replace("[LOCATIONID]", $item->getField('locations_id'), $link);
}
}
if (strstr($link, "[LOCATION]")) {
if ($item->isField('locations_id')) {
$link = str_replace("[LOCATION]", Dropdown::getDropdownName("glpi_locations", $item->getField('locations_id')), $link);
}
}
if (strstr($link, "[NETWORK]")) {
if ($item->isField('networks_id')) {
$link = str_replace("[NETWORK]", Dropdown::getDropdownName("glpi_networks", $item->getField('networks_id')), $link);
}
}
if (strstr($link, "[DOMAIN]")) {
if ($item->isField('domains_id')) {
$link = str_replace("[DOMAIN]", Dropdown::getDropdownName("glpi_domains", $item->getField('domains_id')), $link);
}
}
if (strstr($link, "[USER]")) {
if ($item->isField('users_id')) {
$link = str_replace("[USER]", Dropdown::getDropdownName("glpi_users", $item->getField('users_id')), $link);
}
}
if (strstr($link, "[GROUP]")) {
if ($item->isField('groups_id')) {
$link = str_replace("[GROUP]", Dropdown::getDropdownName("glpi_groups", $item->getField('groups_id')), $link);
}
}
$ipmac = array();
$i = 0;
if ($noip || !strstr($link, "[IP]") && !strstr($link, "[MAC]")) {
return array($link);
} else {
// Return sevral links id several IP / MAC
$links = array();
$query2 = "SELECT `ip`, `mac`, `logical_number`\n FROM `glpi_networkports`\n WHERE `items_id` = '" . $item->fields['id'] . "'\n AND `itemtype` = '" . get_class($item) . "'\n ORDER BY `logical_number`";
$result2 = $DB->query($query2);
if ($DB->numrows($result2) > 0) {
while ($data2 = $DB->fetch_array($result2)) {
$ipmac[$i]['ip'] = $data2["ip"];
$ipmac[$i]['mac'] = $data2["mac"];
$ipmac[$i]['number'] = $data2["logical_number"];
$i++;
}
}
// Add IP/MAC internal switch
if (get_class($item) == 'NetworkEquipment') {
$tmplink = $link;
$tmplink = str_replace("[IP]", $item->getField('ip'), $tmplink);
$tmplink = str_replace("[MAC]", $item->getField('mac'), $tmplink);
$links["{$name} - {$tmplink}"] = $tmplink;
}
if (count($ipmac) > 0) {
foreach ($ipmac as $key => $val) {
$tmplink = $link;
$disp = 1;
if (strstr($link, "[IP]")) {
if (empty($val['ip'])) {
$disp = 0;
} else {
$tmplink = str_replace("[IP]", $val['ip'], $tmplink);
}
}
if (strstr($link, "[MAC]")) {
//.........这里部分代码省略.........
示例5: showForItem
/**
* Show Infocom form for an item (not a standard showForm)
*
* @param $item CommonDBTM object
* @param $withtemplate integer template or basic item (default '')
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $CFG_GLPI;
// Show Infocom or blank form
if (!Session::haveRight("infocom", "r")) {
return false;
}
if (!$item) {
echo "<div class='spaced'>" . __('Requested item not found') . "</div>";
} else {
$date_tax = $CFG_GLPI["date_tax"];
$dev_ID = $item->getField('id');
$ic = new self();
$option = "";
if ($withtemplate == 2) {
$option = " readonly ";
}
if (!strpos($_SERVER['PHP_SELF'], "infocoms-show") && in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
echo "<div class='firstbloc center'>" . __('For this type of item, the financial and administrative information are only a model for the items which you should add.') . "</div>";
}
if (!$ic->getFromDBforDevice($item->getType(), $dev_ID)) {
$input = array('itemtype' => $item->getType(), 'items_id' => $dev_ID, 'entities_id' => $item->getEntityID());
if ($ic->can(-1, "w", $input) && $withtemplate != 2) {
echo "<div class='spaced b'>";
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><th>";
echo sprintf(__('%1$s - %2$s'), $item->getTypeName(1), $item->getName()) . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
Html::showSimpleForm($CFG_GLPI["root_doc"] . "/front/infocom.form.php", 'add', __('Enable the financial and administrative information'), array('itemtype' => $item->getType(), 'items_id' => $dev_ID));
echo "</td></tr></table></div>";
}
} else {
// getFromDBforDevice
$canedit = $ic->can($ic->fields['id'], "w") && $withtemplate != 2;
if ($canedit) {
echo "<form name='form_ic' method='post' action='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php'>";
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre" . (!strpos($_SERVER['PHP_SELF'], "infocoms-show") ? "_fixe" : "") . "'>";
echo "<tr><th colspan='4'>" . __('Financial and administrative information') . "</th></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Supplier') . "</td>";
echo "<td>";
if ($withtemplate == 2) {
echo Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]);
} else {
Supplier::dropdown(array('value' => $ic->fields["suppliers_id"], 'entity' => $item->getEntityID()));
}
echo "</td>";
if (Session::haveRight("budget", "r")) {
echo "<td>" . __('Budget') . "</td><td >";
Budget::dropdown(array('value' => $ic->fields["budgets_id"], 'entity' => $item->getEntityID(), 'comments' => 1));
} else {
echo "<td colspan='2'>";
}
echo "</td></tr>";
// Can edit calendar ?
$editcalendar = $withtemplate != 2;
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Order number') . "</td>";
echo "<td >";
Html::autocompletionTextField($ic, "order_number", array('option' => $option));
echo "</td>";
echo "<td>" . __('Order date') . "</td><td>";
Html::showDateFormItem("order_date", $ic->fields["order_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
$istemplate = '';
if ($item->isTemplate() || in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
$istemplate = '*';
}
echo "<td>" . sprintf(__('%1$s%2$s'), __('Immobilization number'), $istemplate) . "</td>";
echo "<td>";
$objectName = autoName($ic->fields["immo_number"], "immo_number", $withtemplate == 2, 'Infocom', $item->getEntityID());
Html::autocompletionTextField($ic, "immo_number", array('value' => $objectName, 'option' => $option));
echo "</td>";
echo "<td>" . __('Date of purchase') . "</td><td>";
Html::showDateFormItem("buy_date", $ic->fields["buy_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Invoice number') . "</td>";
echo "<td>";
Html::autocompletionTextField($ic, "bill", array('option' => $option));
echo "</td>";
echo "<td>" . __('Delivery date') . "</td><td>";
Html::showDateFormItem("delivery_date", $ic->fields["delivery_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . __('Delivery form') . "</td><td>";
Html::autocompletionTextField($ic, "delivery_number", array('option' => $option));
echo "</td>";
echo "<td>" . __('Startup date') . "</td><td>";
Html::showDateFormItem("use_date", $ic->fields["use_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
//.........这里部分代码省略.........
示例6: getTableGroup
/**
* Get the group of elements regarding given item.
* Two kind of item :
* - Device* feed by a link to the attached item (Computer, Printer ...)
* - Computer, Printer ...: feed by the "global" properties of the CommonDevice
* Then feed with the specificities of the Item_Device elements
* In cas of $item is an instance, then $options contains the type of the item (Computer,
* Printer ...).
*
* @param $item
* @param $table
* @param $options array
* @param $delete_all_column (default NULL)
* @param $common_column
* @param $specific_column
* @param $delete_column (default NULL)
* @param $dynamic_column
**/
function getTableGroup(CommonDBTM $item, HTMLTableMain $table, array $options, HTMLTableSuperHeader $delete_all_column = NULL, HTMLTableSuperHeader $common_column, HTMLTableSuperHeader $specific_column, HTMLTableSuperHeader $delete_column = NULL, $dynamic_column)
{
global $DB;
$is_device = $item instanceof CommonDevice;
if ($is_device) {
$peer_type = $options['itemtype'];
if (empty($peer_type)) {
$column_label = __('Dissociated devices');
$group_name = 'None';
} else {
$column_label = $peer_type::getTypeName(Session::getPluralNumber());
$group_name = $peer_type;
}
$table_group = $table->createGroup($group_name, '');
$peer_column = $table_group->addHeader('item', $column_label, $common_column, NULL);
if (!empty($peer_type)) {
//TRANS : %1$s is the type of the device
// %2$s is the type of the item
// %3$s is the name of the item (used for headings of a list),
$itemtype_nav_title = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
$peer_column->setItemType($peer_type, $itemtype_nav_title);
}
} else {
$peer_type = $this->getDeviceType();
$table_group = $table->createGroup($peer_type, '');
//TRANS : %1$s is the type of the device
// %2$s is the type of the item
// %3$s is the name of the item (used for headings of a list),
$options['itemtype_title'] = sprintf(__('%1$s of %2$s: %3$s'), $peer_type::getTypeName(Session::getPluralNumber()), $item->getTypeName(1), $item->getName());
$peer_type::getHTMLTableHeader($item->getType(), $table_group, $common_column, NULL, $options);
}
$specificity_columns = array();
$link_column = $table_group->addHeader('spec_link', '', $specific_column);
$spec_column = $link_column;
foreach ($this->getSpecificities() as $field => $attributs) {
$spec_column = $table_group->addHeader('spec_' . $field, $attributs['long name'], $specific_column, $spec_column);
$specificity_columns[$field] = $spec_column;
}
$infocom_column = $table_group->addHeader('infocom', Infocom::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
$document_column = $table_group->addHeader('document', Document::getTypeName(Session::getPluralNumber()), $specific_column, $spec_column);
if ($item->isDynamic()) {
$dynamics_column = $table_group->addHeader('one', ' ', $dynamic_column, $spec_column);
$previous_column = $dynamics_column;
} else {
$previous_column = $spec_column;
}
if ($options['canedit']) {
$group_checkbox_tag = empty($peer_type) ? '__' : $peer_type;
$content = Html::getCheckbox(array('criterion' => array('tag_for_massive' => $group_checkbox_tag)));
$delete_one = $table_group->addHeader('one', $content, $delete_column, $previous_column);
}
if ($is_device) {
$fk = 'items_id';
// Entity restrict
$leftjoin = '';
$where = "";
if (!empty($peer_type)) {
$leftjoin = "LEFT JOIN `" . getTableForItemType($peer_type) . "`\n ON (`" . $this->getTable() . "`.`items_id` = `" . getTableForItemType($peer_type) . "`.`id`\n AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}')";
$where = getEntitiesRestrictRequest(" AND", getTableForItemType($peer_type));
}
$query = "SELECT `" . $this->getTable() . "`.*\n FROM `" . $this->getTable() . "`\n {$leftjoin}\n WHERE `" . $this->getDeviceForeignKey() . "` = '" . $item->getID() . "'\n AND `" . $this->getTable() . "`.`itemtype` = '{$peer_type}'\n AND `" . $this->getTable() . "`.`is_deleted` = '0'\n {$where}\n ORDER BY `" . $this->getTable() . "`.`itemtype`, `" . $this->getTable() . "`.`{$fk}`";
} else {
$fk = $this->getDeviceForeignKey();
$query = "SELECT *\n FROM `" . $this->getTable() . "`\n WHERE `itemtype` = '" . $item->getType() . "'\n AND `items_id` = '" . $item->getID() . "'\n AND `is_deleted` = '0'\n ORDER BY {$fk}";
}
if (!empty($peer_type)) {
$peer = new $peer_type();
$peer->getEmpty();
} else {
$peer = NULL;
}
foreach ($DB->request($query) as $link) {
Session::addToNavigateListItems(static::getType(), $link["id"]);
$this->getFromDB($link['id']);
if (is_null($peer) || $link[$fk] != $peer->getID()) {
if ($peer instanceof CommonDBTM) {
$peer->getFromDB($link[$fk]);
}
$current_row = $table_group->createRow();
$peer_group = $peer_type . '_' . $link[$fk] . '_' . mt_rand();
$current_row->setHTMLID($peer_group);
if ($options['canedit']) {
//.........这里部分代码省略.........
示例7: showForItem
//.........这里部分代码省略.........
if ($item->getEntityID() >= 0) {
$entity = $item->getEntityID();
}
if ($item->isRecursive()) {
$entities = getSonsOf('glpi_entities', $entity);
} else {
$entities = $entity;
}
}
$limit = getEntitiesRestrictRequest(" AND ", "glpi_plugin_routetables_routetables", '', $entities, false);
$q = "SELECT COUNT(*)\n FROM `glpi_plugin_routetables_routetables`\n WHERE `is_deleted` = '0'\n {$limit}";
$result = $DB->query($q);
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (plugin_routetables_haveRight('routetables', 'r') && $nb > count($used)) {
echo "<form name='routetable_form{$rand}' id='routetable_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginRoutetablesRoutetable') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
$routetable->dropdownRouteTables("plugin_routetables_routetables_id", $entities, $used);
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a routing table', 'routetables') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Network') . "</th>";
echo "<th>" . __('Subnet mask') . "</th>";
echo "<th>" . __('Gateway') . "</th>";
echo "<th>" . __('Metric', 'routetables') . "</th>";
echo "<th>" . __('Interface') . "</th>";
echo "<th>" . __('Persistance', 'routetables') . "</th>";
echo "<th>" . __('Comments') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginRoutetablesRoutetable', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($routetables as $data) {
$routetableID = $data["id"];
$link = NOT_AVAILABLE;
if ($routetable->getFromDB($routetableID)) {
$link = $routetable->getLink();
}
Session::addToNavigateListItems('PluginRoutetablesRoutetable', $routetable);
$used[$routetableID] = $routetableID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td class='center'>" . $data["destination"] . "</td>";
echo "<td class='center'>" . $data["netmask"] . "</td>";
echo "<td class='center'>" . $data["gateway"] . "</td>";
echo "<td class='center'>" . $data["metric"] . "</td>";
echo "<td class='center'>" . $data["interface"] . "</td>";
echo "<td class='center'>" . Dropdown::getYesNo($data["persistence"]) . "</td>";
echo "<td class='center'>" . $data["comment"] . "</td>";
echo "</tr>";
$i++;
}
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions(__CLASS__, $massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例8: showForItem
//.........这里部分代码省略.........
PluginResourcesResource::dropdown(array('entity' => $entities, 'used' => $used));
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . __s('Associate a resource', 'resources') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
if (Session::isMultiEntitiesMode()) {
$colsup = 1;
} else {
$colsup = 0;
}
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
echo "<th>" . __('First name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Location') . "</th>";
echo "<th>" . PluginResourcesContractType::getTypeName(1) . "</th>";
echo "<th>" . PluginResourcesDepartment::getTypeName(1) . "</th>";
echo "<th>" . __('Arrival date', 'resources') . "</th>";
echo "<th>" . __('Departure date', 'resources') . "</th>";
echo "</tr>";
$used = array();
$resourceID = 0;
if ($number) {
Session::initNavigateListItems('PluginResourcesResource', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($resources as $data) {
$resourceID = $data["id"];
$link = NOT_AVAILABLE;
if ($resource->getFromDB($resourceID)) {
$link = $resource->getLink();
}
Session::addToNavigateListItems('PluginResourcesResource', $resourceID);
$used[$resourceID] = $resourceID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
echo "<td class='center'>" . $data['firstname'] . "</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_locations", $data["locations_id"]);
echo "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_plugin_resources_contracttypes", $data["plugin_resources_contracttypes_id"]);
echo "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_plugin_resources_departments", $data["plugin_resources_departments_id"]);
echo "</td>";
echo "<td class='center'>" . Html::convDate($data["date_begin"]) . "</td>";
if ($data["date_end"] <= date('Y-m-d') && !empty($data["date_end"])) {
echo "<td class='center'>";
echo "<span class='plugin_resources_date_color'>";
echo Html::convDate($data["date_end"]);
echo "</span>";
echo "</td>";
} else {
if (empty($data["date_end"])) {
echo "<td class='center'>" . __('Not defined', 'resources') . "</td>";
} else {
echo "<td class='center'>" . Html::convDate($data["date_end"]) . "</td>";
}
}
echo "</tr>";
$i++;
}
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions(__CLASS__, $massiveactionparams);
Html::closeForm();
}
echo "</div>";
if ($item->getType() == "User") {
$PluginResourcesEmployee = new PluginResourcesEmployee();
$PluginResourcesEmployee->showForm($resourceID, $ID, 0);
}
}
示例9: showForSupplier
/**
* Show domains associated to a supplier
*
* @since version 0.84
*
* @param $item CommonDBTM object for which associated domains must be displayed
* @param $withtemplate (default '')
**/
static function showForSupplier(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$ID = $item->getField('id');
if ($item->isNewID($ID)) {
return false;
}
if (!plugin_domains_haveRight('domains', 'r')) {
return false;
}
if (!$item->can($item->fields['id'], 'r')) {
return false;
}
if (empty($withtemplate)) {
$withtemplate = 0;
}
$rand = mt_rand();
$is_recursive = $item->isRecursive();
$query = "SELECT `glpi_plugin_domains_domains`.`id` AS assocID,\n `glpi_entities`.`id` AS entity,\n `glpi_plugin_domains_domains`.`name` AS assocName,\n `glpi_plugin_domains_domains`.* " . "FROM `glpi_plugin_domains_domains` " . " LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id` = `glpi_plugin_domains_domains`.`entities_id`) " . " WHERE `suppliers_id` = '{$ID}' " . getEntitiesRestrictRequest(" AND ", "glpi_plugin_domains_domains", '', '', true);
$query .= " ORDER BY `assocName` ";
$result = $DB->query($query);
$number = $DB->numrows($result);
$i = 0;
$domains = array();
$domain = new PluginDomainsDomain();
$used = array();
if ($numrows = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$domains[$data['assocID']] = $data;
$used[$data['id']] = $data['id'];
}
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Group in charge of the hardware') . "</th>";
echo "<th>" . __('Supplier') . "</th>";
echo "<th>" . __('Technician in charge of the hardware') . "</th>";
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Creation date') . "</th>";
echo "<th>" . __('Expiration date') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginDomainsDomain', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($domains as $data) {
$domainID = $data["id"];
$link = NOT_AVAILABLE;
if ($domain->getFromDB($domainID)) {
$link = $domain->getLink();
}
Session::addToNavigateListItems('PluginDomainsDomain', $domainID);
$used[$domainID] = $domainID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"]) . "</td>";
echo "<td>";
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/enterprise.form.php?ID=" . $data["suppliers_id"] . "\">";
echo Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]);
if ($_SESSION["glpiis_ids_visible"] == 1) {
echo " (" . $data["suppliers_id"] . ")";
}
echo "</a></td>";
echo "<td class='center'>" . getUsername($data["users_id_tech"]) . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_plugin_domains_domaintypes", $data["plugin_domains_domaintypes_id"]) . "</td>";
echo "<td class='center'>" . Html::convdate($data["date_creation"]) . "</td>";
if ($data["date_expiration"] <= date('Y-m-d') && !empty($data["date_expiration"])) {
echo "<td class='center'><div class='deleted'>" . convdate($data["date_expiration"]) . "</div></td>";
} else {
if (empty($data["date_expiration"])) {
echo "<td class='center'>" . __('Does not expire', 'domains') . "</td>";
} else {
echo "<td class='center'>" . Html::convdate($data["date_expiration"]) . "</td>";
}
}
echo "</tr>";
$i++;
}
}
echo "</table>";
echo "</div>";
}
示例10: showGrupos
static function showGrupos(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$objeto = $item->getType();
$appli = new $objeto();
$ID = $item->fields['id'];
$appli->getFromDB($item->fields['id']);
//$canedit = $appli->can($appli->fields['id'],'w');
$canedit = $appli->canCreate();
//$canedit = Session::haveRight('update_ticket', 1);
$rand = mt_rand();
$groups = self::getFormGroups($ID);
$used = array();
if (!empty($groups)) {
foreach ($groups as $data) {
$used[$data["id"]] = $data["id"];
}
}
echo "<div class='center'>";
echo "<form name='form_grupo' id='form_grupo' method='post' action='../front/formgroup.form.php'>";
echo "<table class='tab_cadre_fixe'>";
echo "<th colspan=2>" . __('Grupos', 'Grupos') . "</th>";
echo "<tr>";
echo "<th>" . __('Grupo', 'Grupo') . " :" . "</th>";
echo "<td>";
if ($canedit) {
Group::dropdown(array('name' => 'groups_id', 'entity' => $_SESSION['glpiactive_entity'], 'condition' => '`is_assign`'));
}
echo "</td>";
//-----------------------------
echo "</tr>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='2' align = 'center'>";
echo "<input type='submit' name='agregarGrupo' value='Agregar' class='submit'>";
echo "</td></tr>";
echo "</table>";
echo "<input type='hidden' name='itemtype' value='Group'>";
echo "<input type='hidden' name='peticion_id' value='" . $item->fields['id'] . "'>";
//echo "</form>";
Html::closeForm();
echo "</div>";
// Listado de Grupos
echo "<div class='spaced'>";
/*
if ($canedit && count($used)) {
$rand = mt_rand();
Html::openMassiveActionsForm('mass'.__CLASS__.$rand);
echo "<input type='hidden' name='plugin_formcreator_forms_id' value='".$item->fields['id']."'>";
$massiveactionparams = array('num_displayed' => count($used),
'container' => 'mass'.__CLASS__.$rand);
Html::showMassiveActions($massiveactionparams);
}*/
if ($canedit && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => count($used));
Html::showMassiveActions($massiveactionparams);
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && count($used)) {
$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>" . Group::getTypeName(1) . "</th>";
echo $header_begin . $header_top . $header_end;
$group = new Group();
if (!empty($groups)) {
Session::initNavigateListItems('PluginFormcreatorForm', sprintf(__('%1$s = %2$s'), $item::getTypeName(1), $item->getName()));
foreach ($groups as $data) {
if (!$group->getFromDB($data["id"])) {
continue;
}
Session::addToNavigateListItems('PluginFormcreatorForm', $data["id"]);
echo "<tr class='tab_bg_1'>";
if ($canedit && count($used)) {
echo "<td width='10'>";
// echo __CLASS__;
Html::showMassiveActionCheckBox('PluginFormcreatorForm_Item', $data["linkID"]);
echo "</td>";
}
$link = $data["completename"];
if ($_SESSION["glpiis_ids_visible"]) {
$link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]);
}
$href = "<a href='" . $CFG_GLPI["root_doc"] . "/front/group.form.php?id=" . $data["id"] . "'>" . $link . "</a>";
echo "<td>" . $group->getLink() . "</td>";
echo "</tr>";
}
echo $header_begin . $header_bottom . $header_end;
} else {
echo "<tr class='tab_bg_1'>";
echo "<td colspan='5' class='center'>" . __('None') . "</td></tr>";
}
echo "</table>";
if ($canedit && count($used)) {
//.........这里部分代码省略.........
示例11: showForItem
//.........这里部分代码省略.........
$nb = $DB->result($result, 0, 0);
echo "<div class='firstbloc'>";
if (plugin_domains_haveRight('domains', 'r') && $nb > count($used)) {
echo "<form name='domain_form{$rand}' id='domain_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL('PluginDomainsDomain') . "'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
$domain->dropdownDomains("plugin_domains_domains_id", $entities, $used);
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . __s('Associate a domain', 'domains') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Group in charge of the hardware') . "</th>";
echo "<th>" . __('Supplier') . "</th>";
echo "<th>" . __('Technician in charge of the hardware') . "</th>";
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Creation date') . "</th>";
echo "<th>" . __('Expiration date') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginDomainsDomain', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($domains as $data) {
$domainID = $data["id"];
$link = NOT_AVAILABLE;
if ($domain->getFromDB($domainID)) {
$link = $domain->getLink();
}
Session::addToNavigateListItems('PluginDomainsDomain', $domainID);
$used[$domainID] = $domainID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_groups", $data["groups_id_tech"]) . "</td>";
echo "<td>";
echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/enterprise.form.php?ID=" . $data["suppliers_id"] . "\">";
echo Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]);
if ($_SESSION["glpiis_ids_visible"] == 1) {
echo " (" . $data["suppliers_id"] . ")";
}
echo "</a></td>";
echo "<td class='center'>" . getUsername($data["users_id_tech"]) . "</td>";
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_plugin_domains_domaintypes", $data["plugin_domains_domaintypes_id"]) . "</td>";
echo "<td class='center'>" . Html::convdate($data["date_creation"]) . "</td>";
if ($data["date_expiration"] <= date('Y-m-d') && !empty($data["date_expiration"])) {
echo "<td class='center'><div class='deleted'>" . convdate($data["date_expiration"]) . "</div></td>";
} else {
if (empty($data["date_expiration"])) {
echo "<td class='center'>" . __('Does not expire', 'domains') . "</td>";
} else {
echo "<td class='center'>" . Html::convdate($data["date_expiration"]) . "</td>";
}
}
echo "</tr>";
$i++;
}
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions(__CLASS__, $massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例12: showForItem
//.........这里部分代码省略.........
} else {
$alert = __('There is no encryption key for this entity', 'accounts');
}
$aeskey = new PluginAccountsAesKey();
echo "<tr><th colspan='" . (8 + $colsup) . "'>";
if ($hash) {
if (!$aeskey->getFromDBByHash($hash_id) || !$aeskey->fields["name"]) {
_e('Encryption key', 'accounts');
echo "<input type='password' name='aeskey' id='aeskey' autocomplete='off'>";
} else {
echo Html::hidden('aeskey', array('value' => $aeskey->fields["name"], 'id' => 'aeskey', 'autocomplete' => 'off'));
}
} else {
echo __('Encryption key', 'accounts');
echo "<div class='red'>";
echo $alert;
echo "</div>";
}
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Login') . "</th>";
echo "<th>" . __('Password') . "</th>";
echo "<th>" . __('Affected User', 'accounts') . "</th>";
echo "<th>" . __('Type') . "</th>";
echo "<th>" . __('Creation date') . "</th>";
echo "<th>" . __('Expiration date') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginAccountsAccount', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($accounts as $data) {
$accountID = $data["id"];
$link = NOT_AVAILABLE;
if ($account->getFromDB($accountID)) {
$link = $account->getLink();
}
Session::addToNavigateListItems('PluginAccountsAccount', $accountID);
$used[$accountID] = $accountID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td class='center'>" . $data["login"] . "</td>";
echo "<td class='center'>";
//hash
if (isset($hash_id) && $aeskey->getFromDBByHash($hash_id) && $aeskey->fields["name"]) {
echo Html::hidden("encrypted_password{$accountID}", array('value' => $data["encrypted_password"], 'id' => "encrypted_password{$accountID}", 'autocomplete' => 'off'));
echo "<input type='text' id='hidden_password{$accountID}' value='' size='30' >";
echo Html::scriptBlock("\n if (!check_hash()) {\n \$('#hidden_password{$accountID}')\n .after('" . __('Wrong encryption key', 'accounts') . "')\n .remove();\n } else {\n decrypt_password('{$accountID}');\n }\n ");
} else {
$url = $CFG_GLPI["root_doc"] . "/plugins/accounts/front/account.form.php";
echo " <input type='button' id='decrypt_link{$accountID}' name='decrypte' value='" . __s('Uncrypt', 'accounts') . "'\n class='submit'>";
echo Html::hidden("encrypted_password{$accountID}", array('value' => $data["encrypted_password"], 'id' => "encrypted_password{$accountID}", 'autocomplete' => 'off'));
echo Html::scriptBlock("\$(document).on('click', '#decrypt_link{$accountID}', function(event) {\n if (!check_hash()) {\n alert('" . __('Wrong encryption key', 'accounts') . "');\n } else {\n var decrypted_password = decrypt_password('{$accountID}');\n \$('#decrypt_link{$accountID}')\n .after(decrypted_password)\n .remove();\n }\n });");
}
echo "</td>";
echo "<td class='center'>";
echo getUsername($data["users_id"]);
echo "</td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_plugin_accounts_accounttypes", $data["plugin_accounts_accounttypes_id"]);
echo "</td>";
echo "<td class='center'>" . Html::convdate($data["date_creation"]) . "</td>";
if ($data["date_expiration"] <= date('Y-m-d') && !empty($data["date_expiration"])) {
echo "<td class='center'>";
echo "<div class='deleted'>" . Html::convdate($data["date_expiration"]) . "</div>";
echo "</td>";
} else {
if (empty($data["date_expiration"])) {
echo "<td class='center'>" . __('Don\'t expire', 'accounts') . "</td>";
} else {
echo "<td class='center'>" . Html::convdate($data["date_expiration"]) . "</td>";
}
}
echo "</tr>";
$i++;
}
}
echo "</table>";
echo Html::hidden('good_hash', array('value' => $hash, 'id' => 'good_hash'));
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions($massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例13: showForItem
//.........这里部分代码省略.........
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_1'>";
echo "<td colspan='4' class='center'>";
echo "<input type='hidden' name='entities_id' value='{$entity}'>";
echo "<input type='hidden' name='is_recursive' value='{$is_recursive}'>";
echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
if ($item->getType() == 'Ticket') {
echo "<input type='hidden' name='tickets_id' value='{$ID}'>";
}
if ($item->getType() != 'User') {
$projet->dropdownProjet("plugin_projet_projets_id", $entities, $used);
} else {
$strict_entities = Profile_User::getUserEntities($ID, true);
if (!Session::haveAccessToOneOfEntities($strict_entities) && !isViewAllEntities()) {
$canedit = false;
}
if (countElementsInTableForEntity("glpi_plugin_projet_projets", $strict_entities) > count($used)) {
Dropdown::show('PluginProjetProjet', array('name' => "plugin_projet_projets_id", 'used' => $used, 'entity' => $strict_entities));
}
}
echo "</td><td class='center' width='20%'>";
echo "<input type='submit' name='additem' value=\"" . _sx('button', 'Associate a project', 'projet') . "\" class='submit'>";
echo "</td>";
echo "</tr>";
echo "</table>";
Html::closeForm();
}
echo "</div>";
}
echo "<div class='spaced'>";
if ($canedit && $number && $withtemplate < 2) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number);
Html::showMassiveActions(__CLASS__, $massiveactionparams);
}
echo "<table class='tab_cadre_fixe'>";
if (Session::isMultiEntitiesMode()) {
$colsup = 1;
} else {
$colsup = 0;
}
if ($item->getType() == "Group" || $item->getType() == "User") {
echo "<tr><th colspan='" . (7 + $colsup) . "'>" . _n('Associated project', 'Associated projects', 2, 'projet') . ":</th></tr>";
}
echo "<tr>";
if ($canedit && $number && $withtemplate < 2) {
echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
}
echo "<th>" . __('Name') . "</th>";
if (Session::isMultiEntitiesMode()) {
echo "<th>" . __('Entity') . "</th>";
}
echo "<th>" . __('Description') . "</th>";
echo "<th>" . __('Progress') . "</th>";
echo "<th>" . __('Start date') . "</th>";
echo "<th>" . __('End date') . "</th>";
echo "</tr>";
$used = array();
if ($number) {
Session::initNavigateListItems('PluginProjetProjet', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($projets as $data) {
$projetID = $data["id"];
$link = NOT_AVAILABLE;
if ($projet->getFromDB($projetID)) {
$link = $projet->getLink();
}
Session::addToNavigateListItems('PluginProjetProjet', $projetID);
$used[$projetID] = $projetID;
$assocID = $data["assocID"];
echo "<tr class='tab_bg_1" . ($data["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate < 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["assocID"]);
echo "</td>";
}
echo "<td class='center'>{$link}</td>";
if (Session::isMultiEntitiesMode()) {
echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data['entities_id']) . "</td>";
}
echo "<td align='center'>" . Html::resume_text($data["description"], 250) . "</td>";
echo "<td align='center'>" . PluginProjetProjet::displayProgressBar('100', $data["advance"]) . "</td>";
echo "<td class='center'>" . Html::convdate($data["date_begin"]) . "</td>";
if ($data["date_end"] <= date('Y-m-d') && !empty($data["date_end"])) {
echo "<td class='center'><span class='red'>" . Html::convdate($data["date_end"]) . "</span></td>";
} else {
echo "<td class='center'><span class='green'>" . Html::convdate($data["date_end"]) . "</span></td>";
}
echo "</tr>";
$i++;
}
}
echo "</table>";
if ($canedit && $number && $withtemplate < 2) {
$massiveactionparams['ontop'] = false;
Html::showMassiveActions(__CLASS__, $massiveactionparams);
Html::closeForm();
}
echo "</div>";
}
示例14: showForItem
/**
* Print an HTML array of contract associated to an object
*
* @since version 0.84
*
* @param $item CommonDBTM object wanted
* @param $withtemplate not used (to be deleted) (default '')
*
* @return Nothing (display)
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $DB, $CFG_GLPI;
$itemtype = $item->getType();
$ID = $item->fields['id'];
if (!Contract::canView() || !$item->can($ID, READ)) {
return false;
}
$canedit = $item->can($ID, UPDATE);
$rand = mt_rand();
$query = "SELECT `glpi_contracts_items`.*\n FROM `glpi_contracts_items`,\n `glpi_contracts`\n LEFT JOIN `glpi_entities` ON (`glpi_contracts`.`entities_id`=`glpi_entities`.`id`)\n WHERE `glpi_contracts`.`id`=`glpi_contracts_items`.`contracts_id`\n AND `glpi_contracts_items`.`items_id` = '{$ID}'\n AND `glpi_contracts_items`.`itemtype` = '{$itemtype}'" . getEntitiesRestrictRequest(" AND", "glpi_contracts", '', '', true) . "\n ORDER BY `glpi_contracts`.`name`";
$result = $DB->query($query);
$contracts = array();
$used = array();
if ($number = $DB->numrows($result)) {
while ($data = $DB->fetch_assoc($result)) {
$contracts[$data['id']] = $data;
$used[$data['contracts_id']] = $data['contracts_id'];
}
}
if ($canedit && $withtemplate != 2) {
echo "<div class='firstbloc'>";
echo "<form name='contractitem_form{$rand}' id='contractitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
echo "<input type='hidden' name='items_id' value='{$ID}'>";
echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
echo "<table class='tab_cadre_fixe'>";
echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a contract') . "</th></tr>";
echo "<tr class='tab_bg_1'><td>";
Contract::dropdown(array('entity' => $item->getEntityID(), 'used' => $used));
echo "</td><td class='center'>";
echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
echo "</td></tr>";
echo "</table>";
Html::closeForm();
echo "</div>";
}
echo "<div class='spaced'>";
if ($withtemplate != 2) {
if ($canedit && $number) {
Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
$massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand);
Html::showMassiveActions($massiveactionparams);
}
}
echo "<table class='tab_cadre_fixehov'>";
$header_begin = "<tr>";
$header_top = '';
$header_bottom = '';
$header_end = '';
if ($canedit && $number && $withtemplate != 2) {
$header_top .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_top .= "</th>";
$header_bottom .= "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
$header_bottom .= "</th>";
}
$header_end .= "<th>" . __('Name') . "</th>";
$header_end .= "<th>" . __('Entity') . "</th>";
$header_end .= "<th>" . _x('phone', 'Number') . "</th>";
$header_end .= "<th>" . __('Contract type') . "</th>";
$header_end .= "<th>" . __('Supplier') . "</th>";
$header_end .= "<th>" . __('Start date') . "</th>";
$header_end .= "<th>" . __('Initial contract period') . "</th>";
$header_end .= "</tr>";
echo $header_begin . $header_top . $header_end;
if ($number > 0) {
Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
foreach ($contracts as $data) {
$cID = $data["contracts_id"];
Session::addToNavigateListItems(__CLASS__, $cID);
$contracts[] = $cID;
$assocID = $data["id"];
$con = new Contract();
$con->getFromDB($cID);
echo "<tr class='tab_bg_1" . ($con->fields["is_deleted"] ? "_2" : "") . "'>";
if ($canedit && $withtemplate != 2) {
echo "<td width='10'>";
Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
echo "</td>";
}
echo "<td class='center b'>";
$name = $con->fields["name"];
if ($_SESSION["glpiis_ids_visible"] || empty($con->fields["name"])) {
$name = sprintf(__('%1$s (%2$s)'), $name, $con->fields["id"]);
}
echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/contract.form.php?id={$cID}'>" . $name;
echo "</a></td>";
echo "<td class='center'>";
echo Dropdown::getDropdownName("glpi_entities", $con->fields["entities_id"]) . "</td>";
echo "<td class='center'>" . $con->fields["num"] . "</td>";
echo "<td class='center'>";
//.........这里部分代码省略.........
示例15: showForItem
/**
* Show Infocom form for an item (not a standard showForm)
*
* @param $item CommonDBTM object
* @param $withtemplate integer: template or basic item
**/
static function showForItem(CommonDBTM $item, $withtemplate = '')
{
global $CFG_GLPI, $LANG;
// Show Infocom or blank form
if (!haveRight("infocom", "r")) {
return false;
}
if (!$item) {
echo "<div class='spaced'>" . $LANG['financial'][85] . "</div>";
} else {
$date_tax = $CFG_GLPI["date_tax"];
$dev_ID = $item->getField('id');
$ic = new self();
$option = "";
if ($withtemplate == 2) {
$option = " readonly ";
}
if (!strpos($_SERVER['PHP_SELF'], "infocoms-show") && in_array($item->getType(), array('CartridgeItem', 'ConsumableItem', 'Software'))) {
echo "<div class='firstbloc center'>" . $LANG['financial'][84] . "</div>";
}
if (!$ic->getFromDBforDevice($item->getType(), $dev_ID)) {
$input = array('itemtype' => $item->getType(), 'items_id' => $dev_ID, 'entities_id' => $item->getEntityID());
if ($ic->can(-1, "w", $input) && $withtemplate != 2) {
echo "<div class='spaced b'>";
echo "<table class='tab_cadre_fixe'><tr class='tab_bg_1'><th>";
echo $item->getTypeName() . " - " . $item->getName() . "</th></tr>";
echo "<tr class='tab_bg_1'><td class='center'>";
echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php?itemtype=" . $item->getType() . "&items_id={$dev_ID}&add=add'>" . $LANG['financial'][68];
echo "</a></td></tr></table></div>";
}
} else {
// getFromDBforDevice
$canedit = $ic->can($ic->fields['id'], "w") && $withtemplate != 2;
if ($canedit) {
echo "<form name='form_ic' method='post' action='" . $CFG_GLPI["root_doc"] . "/front/infocom.form.php'>";
}
echo "<div class='spaced'>";
echo "<table class='tab_cadre" . (!strpos($_SERVER['PHP_SELF'], "infocoms-show") ? "_fixe" : "") . "'>";
echo "<tr><th colspan='4'>" . $LANG['financial'][3] . "</th></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][26] . " :</td>";
echo "<td>";
if ($withtemplate == 2) {
echo Dropdown::getDropdownName("glpi_suppliers", $ic->fields["suppliers_id"]);
} else {
Dropdown::show('Supplier', array('value' => $ic->fields["suppliers_id"], 'entity' => $item->getEntityID()));
}
echo "</td>";
if (haveRight("budget", "r")) {
echo "<td>" . $LANG['financial'][87] . " :</td><td >";
Dropdown::show('Budget', array('value' => $ic->fields["budgets_id"], 'entity' => $item->getEntityID(), 'comments' => 1));
} else {
echo "<td colspan='2'>";
}
echo "</td></tr>";
// Can edit calendar ?
$editcalendar = $withtemplate != 2;
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][18] . " :</td>";
echo "<td >";
autocompletionTextField($ic, "order_number", array('option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][28] . " :</td><td>";
showDateFormItem("order_date", $ic->fields["order_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][20] . "* :</td>";
echo "<td>";
$objectName = autoName($ic->fields["immo_number"], "immo_number", $withtemplate == 2, 'Infocom', $item->getEntityID());
autocompletionTextField($ic, "immo_number", array('value' => $objectName, 'option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][14] . " :</td><td>";
showDateFormItem("buy_date", $ic->fields["buy_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][82] . " :</td>";
echo "<td>";
autocompletionTextField($ic, "bill", array('option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][27] . " :</td><td>";
showDateFormItem("delivery_date", $ic->fields["delivery_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][19] . " :</td><td>";
autocompletionTextField($ic, "delivery_number", array('option' => $option));
echo "</td>";
echo "<td>" . $LANG['financial'][76] . " :</td><td>";
showDateFormItem("use_date", $ic->fields["use_date"], true, $editcalendar);
echo "</td></tr>";
echo "<tr class='tab_bg_1'>";
echo "<td>" . $LANG['financial'][21] . " :</td>";
echo "<td><input type='text' name='value' {$option} value='" . formatNumber($ic->fields["value"], true) . "' size='14'></td>";
echo "</td>";
echo "<td>" . $LANG['financial'][114] . " :</td><td>";
//.........这里部分代码省略.........