Get form URL for itemtype
static public getItemTypeFormURL ( $itemtype, $full = true ) | ||
$itemtype | string item type | |
$full | path or relative one (true by default) return string itemtype Form URL |
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { echo "<form name='notificationtargets_form' id='notificationtargets_form'\n method='post' action=' "; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class ='tab_cadre_fixe'>"; echo '<tr><th colspan="2">' . __('Access type', 'formcreator') . '</th></tr>'; echo '<td>' . __('Access', 'formcreator') . '</td>'; echo '<td>'; Dropdown::showFromArray('access_rights', array(PluginFormcreatorForm::ACCESS_PUBLIC => __('Public access', 'formcreator'), PluginFormcreatorForm::ACCESS_PRIVATE => __('Private access', 'formcreator'), PluginFormcreatorForm::ACCESS_RESTRICTED => __('Restricted access', 'formcreator')), array('value' => isset($item->fields["access_rights"]) ? $item->fields["access_rights"] : 1)); echo '</td>'; if ($item->fields["access_rights"] == PluginFormcreatorForm::ACCESS_RESTRICTED) { echo '<tr><th colspan="2">' . self::getTypeName(2) . '</th></tr>'; $table = getTableForItemType(__CLASS__); $table_profile = getTableForItemType('Profile'); $query = "SELECT p.`id`, p.`name`, IF(f.`plugin_formcreator_profiles_id` IS NOT NULL, 1, 0) AS `profile`\n FROM {$table_profile} p\n LEFT JOIN {$table} f\n ON p.`id` = f.`plugin_formcreator_profiles_id`\n AND f.`plugin_formcreator_forms_id` = " . (int) $item->fields['id']; $result = $GLOBALS['DB']->query($query); while (list($id, $name, $profile) = $GLOBALS['DB']->fetch_array($result)) { $checked = $profile ? ' checked' : ''; echo '<tr><td colspan="2"><label>'; echo '<input type="checkbox" name="profiles_id[]" value="' . $id . '" ' . $checked . '> '; echo $name; echo '</label></td></tr>'; } } echo '<tr>'; echo '<td class="center" colspan="2">'; echo '<input type="hidden" name="profiles_id[]" value="0" />'; echo '<input type="hidden" name="form_id" value="' . (int) $item->fields['id'] . '" />'; echo '<input type="submit" name="update" value="' . __('Save') . '" class="submit" />'; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); }
public function showForm($ID, $options = array()) { if (!$this->isNewID($ID)) { $this->check($ID, READ); } else { $this->check(-1, UPDATE); } $options['colspan'] = 2; $options['target'] = Toolbox::getItemTypeFormURL(__CLASS__); $this->showFormHeader($options); echo '<table class="tab_cadre_fixe">'; echo "<tr class='line0'><td>" . __('Name') . " <span class='red'>*</span></td>"; echo "<td>"; //Html::autocompletionTextField($this, "name"); echo '<input type="text" name="name" value="' . $this->fields['name'] . '" size="40" required>'; echo "</td>"; echo "</tr>"; echo "<tr class='line1'><td>" . __('Description') . "</td>"; echo "<td>"; echo "<textarea name='comment' id ='comment' cols='45' rows='2'>" . $this->fields['comment'] . "</textarea>"; //Html::initEditorSystem('comment'); echo "</td>"; echo "</tr>"; echo "<tr class='line1'><td>" . __('HTML color', 'tag') . "</td>"; echo "<td>"; Html::showColorField('color', array('value' => $this->fields['color'])); echo "</td>"; echo "</tr>"; $this->showFormButtons($options); return true; }
/** * @see Rule::showNewRuleForm() **/ function showNewRuleForm($ID) { echo "<form method='post' action='" . Toolbox::getItemTypeFormURL('Entity') . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='7'>" . __('Authorizations assignment rules') . "</th></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Name') . "</td><td>"; Html::autocompletionTextField($this, "name", array('value' => '', 'size' => 33)); echo '</td><td>' . __('Description') . "</td><td>"; Html::autocompletionTextField($this, "description", array('value' => '', 'size' => 33)); echo "</td><td>" . __('Logical operator') . "</td><td>"; $this->dropdownRulesMatch(); echo "</td><td rowspan='2' class='tab_bg_2 center middle'>"; echo "<input type=hidden name='sub_type' value='" . get_class($this) . "'>"; echo "<input type=hidden name='entities_id' value='-1'>"; echo "<input type=hidden name='affectentity' value='{$ID}'>"; echo "<input type=hidden name='_method' value='AddRule'>"; echo "<input type='submit' name='execute' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . _n('Profile', 'Profiles', 1) . "</td><td>"; Profile::dropdown(); echo "</td><td><span class='small_space'>" . __('Recursive') . "</span></td><td colspan='3'>"; Dropdown::showYesNo("is_recursive", 0); echo "</td></tr>\n"; echo "</table>"; Html::closeForm(); }
static function showForGroup(Group $group) { global $DB; $ID = $group->getField('id'); if (!$group->can($ID, READ)) { return false; } $canedit = $group->can($ID, UPDATE); if ($canedit) { // Get data $item = new self(); if (!$item->getFromDB($ID)) { $item->getEmpty(); } $rand = mt_rand(); echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />"; echo "<div class='spaced'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='center'>"; Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl'])); echo "</td></tr>"; echo "</td><td class='center'>"; if ($item->fields["id"]) { echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>"; echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n class='submit'>"; } else { echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>"; } echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); } }
static function showForDocumentCategory($item) { $documentCategory = new self(); if (!$documentCategory->getFromDBByQuery(" WHERE `documentcategories_id` = " . $item->fields['id'])) { $documentCategory->getEmpty(); } echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL($documentCategory->getType()) . "'>"; echo "<div align='center'><table class='tab_cadre_fixe'>"; echo "<tr><th colspan='2'>" . __('Document category prefix', 'order') . "</th></tr>"; echo "<tr class='tab_bg_1'>"; // Dropdown group echo "<td>"; echo __('Document category prefix', 'order'); echo "</td>"; echo "<td>"; echo "<input type='text' name='documentcategories_prefix' value='" . $documentCategory->fields['documentcategories_prefix'] . "'>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='tab_bg_2 center' colspan='6'>"; echo "<input type='submit' name='update' class='submit' value='" . _sx('button', 'Save') . "' >"; echo "<input type='hidden' name='documentcategories_id' class='submit' value='" . $item->fields['id'] . "' >"; echo "</td>"; echo "</tr>"; echo "</table></div>"; Html::closeForm(); }
public function showForm($ID, $options = array()) { if (!$this->isNewID($ID)) { $this->check($ID, READ); } else { $this->check(-1, UPDATE); } $options['colspan'] = 2; $options['target'] = Toolbox::getItemTypeFormURL(__CLASS__); $this->showFormHeader($options); echo '<table class="tab_cadre_fixe">'; echo "<tr class='line0'><td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td>"; echo "</tr>"; echo "<tr class='line1'><td>" . __('Content') . "</td>"; echo "<td>"; echo "<textarea name='comment' id ='comment' >" . $this->fields['comment'] . "</textarea>"; Html::initEditorSystem('comment'); echo "</td>"; echo "</tr>"; $this->showFormButtons($options); return true; }
/** * Show form * * @global type $CFG_GLPI * @param type $ID * @param type $options */ function showForm($ID = 0, $options = array()) { global $CFG_GLPI; echo "<div class='center first-bloc'>"; echo "<form name='field_form' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th>" . self::getTypeName() . "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='tab_bg_2 center'>"; echo PluginShellcommandsCommandGroup::getTypeName(1) . " "; Dropdown::show('PluginShellcommandsCommandGroup', array('entity' => $_SESSION['glpiactive_entity'], 'width' => 200)); echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='tab_bg_2 center'>"; $this->getEditValue(); echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td class='tab_bg_2 center'>"; echo "<input type='button' class='submit' onclick='shellcommand_advanced_execution(\"" . $CFG_GLPI['root_doc'] . "\",\"field_form\", \"advanced_execution_result\");' name='advanced_execution' value='" . __('Execute') . "'/>"; echo "</td>"; echo "</tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; echo "<div class='spaced' id='advanced_execution_result'></div>"; }
static function getMenuContent() { global $CFG_GLPI; $menu = array(); $menu['title'] = self::getMenuName(); $menu['page'] = '/plugins/connections/front/connection.php'; $menu['links'] = array('add' => Toolbox::getItemTypeFormURL('PluginConnectionsConnection', false), 'search' => Toolbox::getItemTypeSearchURL('PluginConnectionsConnection', false)); if (Session::haveRight(static::$rightname, READ)) { $menu['options']['connections'] = array('title' => self::getMenuName(), 'page' => Toolbox::getItemTypeFormURL('PluginConnectionsConnection', false), 'links' => array('add' => Toolbox::getItemTypeFormURL('PluginConnectionsConnection', false), 'search' => Toolbox::getItemTypeSearchURL('PluginConnectionsConnection', false))); } return $menu; }
/** * @param $model PluginDatainjectionModel object **/ static function showFormMappings(PluginDatainjectionModel $model) { global $CFG_GLPI; $canedit = $model->can($model->fields['id'], UPDATE); if (isset($_SESSION['datainjection']['lines'])) { $lines = unserialize($_SESSION['datainjection']['lines']); } else { $lines = array(); } echo "<form method='post' name=form action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; //Display link to the preview popup if (isset($_SESSION['datainjection']['lines']) && !empty($lines)) { $nblines = $_SESSION['datainjection']['nblines']; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td class='center'>"; $url = $CFG_GLPI["root_doc"] . "/plugins/datainjection/front/popup.php?popup=preview&models_id=" . $model->getID(); echo "<a href=# onClick=\"var w = window.open('{$url}' , 'glpipopup', " . "'height=400, width=600, top=100, left=100, scrollbars=yes' );w.focus();\"/>"; echo __('See the file', 'datainjection') . "</a>"; echo "</td></tr>"; } echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th>" . __('Header of the file', 'datainjection') . "</th>"; echo "<th>" . __('Tables', 'datainjection') . "</th>"; echo "<th>" . _n('Field', 'Fields', 2) . "</th>"; echo "<th>" . __('Link field', 'datainjection') . "</th>"; echo "</tr>"; $model->loadMappings(); foreach ($model->getMappings() as $mapping) { $mapping->fields = Toolbox::stripslashes_deep($mapping->fields); $mappings_id = $mapping->getID(); echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . $mapping->fields['name'] . "</td>"; echo "<td class='center'>"; $options = array('primary_type' => $model->fields['itemtype']); PluginDatainjectionInjectionType::dropdownLinkedTypes($mapping, $options); echo "</td>"; echo "<td class='center'><span id='span_field_{$mappings_id}'>"; echo "</span></td>"; echo "<td class='center'><span id='span_mandatory_{$mappings_id}'></span></td>"; } if ($canedit) { echo "<tr> <td class='tab_bg_2 center' colspan='4'>"; echo "<input type='hidden' name='models_id' value='" . $model->fields['id'] . "'>"; echo "<input type='submit' name='update' value='" . _sx('button', 'Save') . "' class='submit'>"; echo "</td></tr>"; } echo "</table>"; Html::closeForm(); }
function manageContacts($items_id) { $pmContact = new PluginMonitoringContact(); $user = new User(); $a_list = $this->find("`plugin_monitoring_hosts_id`='" . $items_id . "'"); echo "<form name='contacts_form' id='contacts_form'\n method='post' action=' "; echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th colspan='3'>"; echo __('Contacts', 'monitoring'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='right'>"; $a_contacts = $pmContact->find(); $a_elements = array(); foreach ($a_contacts as $data) { $user->getFromDB($data['users_id']); $a_elements[$data['id']] = $user->getName(); } asort($a_elements); Dropdown::showFromArray('plugin_monitoring_contacts_id', $a_elements); echo "</td>"; echo "<td class='center'>"; echo "<input type='submit' class='submit' name='parent_add' value='" . __('Add') . " >>'>"; echo "<br><br>"; if ($a_list) { echo "<input type='submit' class='submit' name='parent_delete' value='<< " . _sx('button', 'Delete permanently') . "'>"; } echo "</td>"; echo "<td>"; if ($a_list) { echo "<select name='parent_to_delete[]' multiple size='5'>"; foreach ($a_list as $data) { $pmContact->getFromDB($data['plugin_monitoring_contacts_id']); $user->getFromDB($pmContact->fields['users_id']); echo "<option value='" . $data['plugin_monitoring_contacts_id'] . "'>" . $user->getName() . "</option>"; } echo "</select>"; } else { echo " "; } echo "</td>"; echo "</tr>"; echo "</table>"; echo "<input type='hidden' name='id' value='" . $items_id . "' />"; Html::closeForm(); }
static function showPreferences() { global $DB, $CFG_GLPI, $PLUGIN_HOOKS; $target = Toolbox::getItemTypeFormURL(__CLASS__); $pref = new self(); echo "<div class='center' id='pdf_type'>"; foreach ($PLUGIN_HOOKS['plugin_pdf'] as $type => $plug) { if (!($item = getItemForItemtype($type))) { continue; } if ($item->canView()) { $pref->menu($item, $target); } } echo "</div>"; }
function plugin_example_giveItem($type, $ID, $data, $num) { $searchopt =& Search::getOptions($type); $table = $searchopt[$ID]["table"]; $field = $searchopt[$ID]["field"]; switch ($table . '.' . $field) { case "glpi_plugin_example_examples.name": $out = "<a href='" . Toolbox::getItemTypeFormURL('PluginExampleExample') . "?id=" . $data['id'] . "'>"; $out .= $data[$num][0]['name']; if ($_SESSION["glpiis_ids_visible"] || empty($data[$num][0]['name'])) { $out .= " (" . $data["id"] . ")"; } $out .= "</a>"; return $out; } return ""; }
public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { global $CFG_GLPI; echo '<div class="tab_cadre_pager" style="padding: 2px; margin: 5px 0"> <h3 class="tab_bg_2" style="padding: 5px"> <a href="' . Toolbox::getItemTypeFormURL(__CLASS__) . '" class="submit"> <img src="' . $CFG_GLPI['root_doc'] . '/pics/menu_add.png" alt="+" align="absmiddle" /> ' . __('Add a form category', 'formcreator') . ' </a> </h3> </div>'; $params['sort'] = !empty($_POST['sort']) ? (int) $_POST['sort'] : 0; $params['order'] = !empty($_POST['order']) && in_array($_POST['order'], array('ASC', 'DESC')) ? $_POST['order'] : 'ASC'; $params['start'] = !empty($_POST['start']) ? (int) $_POST['start'] : 0; Search::manageGetValues(__CLASS__); Search::showList(__CLASS__, $params); }
/** * Print the config form for display * */ function showFormDisplay() { $options = self::getConfigValues(array('group_by_users')); echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>"; echo "<div class='center' id='tabsbody'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . __('FP Software config') . "</th></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td width='30%'> " . __('Calculate licenses number per user instead of per computer') . "</td><td width='20%'>"; Dropdown::showYesNo('group_by_users', $options['group_by_users']); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='4' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">"; echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); }
function plugin_init_genericobject() { global $PLUGIN_HOOKS, $CFG_GLPI, $GO_BLACKLIST_FIELDS, $GO_FIELDS, $GENERICOBJECT_PDF_TYPES, $GO_LINKED_TYPES, $GO_READONLY_FIELDS; $GO_READONLY_FIELDS = array("is_helpdesk_visible", "comment"); $GO_BLACKLIST_FIELDS = array("itemtype", "table", "is_deleted", "id", "entities_id", "is_recursive", "is_template", "notepad", "template_name", "date_mod", "name", "is_helpdesk_visible", "comment"); $GO_LINKED_TYPES = array('Computer', 'Phone', 'Peripheral', 'Software', 'Monitor', 'Printer', 'NetworkEquipment'); $PLUGIN_HOOKS['csrf_compliant']['genericobject'] = true; $GENERICOBJECT_PDF_TYPES = array(); $plugin = new Plugin(); if ($plugin->isInstalled("genericobject") && $plugin->isActivated("genericobject")) { plugin_genericobject_includeCommonFields(); $PLUGIN_HOOKS['use_massive_action']['genericobject'] = 1; /* load changeprofile function */ $PLUGIN_HOOKS['change_profile']['genericobject'] = array('PluginGenericobjectProfile', 'changeProfile'); // Display a menu entry ? $PLUGIN_HOOKS['menu_entry']['genericobject'] = true; //Do not display icon if not using the genericobject plugin if (isset($_GET['id']) && $_GET['id'] != '' && strpos($_SERVER['REQUEST_URI'], Toolbox::getItemTypeFormURL("PluginGenericobjectType")) !== false) { $url = '/plugins/genericobject/index.php'; $type = new PluginGenericobjectType(); $type->getFromDB($_GET['id']); if ($type->fields['is_active']) { $url .= '?itemtypes_id=' . $_GET['id']; $image = "<img src='" . $CFG_GLPI["root_doc"] . "/pics/stats_item.png' title=\"" . __("Go to objects list", "genericobject") . "\" alt=\"" . __("Go to objects list", "genericobject") . "\">"; $PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links'][$image] = $url; } } $PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links']['add'] = Toolbox::getItemTypeFormURL('PluginGenericobjectType', false); $PLUGIN_HOOKS['submenu_entry']['genericobject']['options']['type']['links']['search'] = Toolbox::getItemTypeSearchURL('PluginGenericobjectType', false); // Config page if (Session::haveRight('config', 'w')) { $PLUGIN_HOOKS['submenu_entry']['genericobject']['config'] = 'front/type.php'; $PLUGIN_HOOKS['config_page']['genericobject'] = 'front/type.php'; $PLUGIN_HOOKS['submenu_entry']['genericobject']['add']['type'] = 'front/type.form.php'; $PLUGIN_HOOKS['submenu_entry']['genericobject']['search']['type'] = 'front/type.php'; } $PLUGIN_HOOKS['assign_to_ticket']['genericobject'] = true; $PLUGIN_HOOKS['use_massive_action']['genericobject'] = 1; $PLUGIN_HOOKS['post_init']['genericobject'] = 'plugin_post_init_genericobject'; $PLUGIN_HOOKS['plugin_datainjection_populate']['genericobject'] = "plugin_datainjection_populate_genericobject"; } }
static function showForm() { global $CFG_GLPI; $config = new self(); $config->getFromDB(1); echo "<div class='center'>"; echo "<form method='post' action='" . Toolbox::getItemTypeFormURL('PluginPositionsConfig') . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><th colspan='2'>" . __('General setup') . "</th></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; echo __('Add sub-places on the map objects', 'positions'); echo "</td>"; echo "<td>"; Dropdown::showYesNo('use_view_all_object', $config->fields['use_view_all_object']); echo "</td></tr>"; echo "<tr><th colspan='2'>"; echo "<input type='hidden' name='id' value='1'>"; echo "<div align='center'>"; echo "<input type='submit' name='update_config' value=\"" . _x('button', 'Post') . "\" class='submit' >"; echo "</div></th></tr>"; echo "</table></div>"; Html::closeForm(); echo "<div class='center'><table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'>"; echo "<th>"; _e('Setup'); echo "</th>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center'>"; echo "<a href='./imageitem.form.php'>" . __('Association : picture / types of equipment', 'positions') . "</a>"; echo "</td>"; echo "</tr>"; echo "<tr class='tab_bg_1'>"; echo "<td class='center'>"; echo "<a href='./info.php'>" . __('Configuring the display materials', 'positions') . "</a>"; echo "</td>"; echo "</tr>"; echo "</table></div>"; }
/** * Return item description * * @param $itemtype * @param $ID * @param $data * @param $num * @return string */ function plugin_rackview_giveItem($itemtype, $ID, $data, $num) { $searchopt = Search::getOptions($itemtype); $NAME = "ITEM_"; $unit = ''; if (isset($searchopt[$ID]['unit'])) { $unit = $searchopt[$ID]['unit']; } if (isset($searchopt[$ID]["itemlink_type"])) { $link = Toolbox::getItemTypeFormURL($searchopt[$ID]["itemlink_type"]); } else { $link = Toolbox::getItemTypeFormURL($itemtype); } $out = ""; $rackDisplay = ""; if ($ID == 1) { $rack = new PluginRackviewRack(); $rack->getFromDB($data['id']); $rackDisplay = '<div style="float:left; margin-right: 1em" ' . 'class="CSSTableGenerator">' . $rack->buildRack(true) . '</div>'; } $sub = ""; if (isset($data[$NAME . $num . "_2"])) { $sub = $data[$NAME . $num . "_2"]; } $out .= "<a id='" . $itemtype . "_" . $sub . "' href=\"" . $link; $out .= strstr($link, '?') ? '&' : '?'; $out .= 'id=' . $sub; if (isset($searchopt[$ID]['forcetab'])) { $out .= "&forcetab=" . $searchopt[$ID]['forcetab']; } $out .= "\">" . $data[$NAME . $num] . $unit; if (($_SESSION["glpiis_ids_visible"] || empty($data[$NAME . $num])) && isset($data[$NAME . $num . "_2"])) { $out .= " (" . $data[$NAME . $num . "_2"] . ")"; } $out .= "</a>"; if ($rackDisplay != "") { $out .= HTML::showToolTip($rackDisplay, array('applyto' => $itemtype . "_" . $sub, 'display' => false)); } return $out; }
function showWmi($contents_id) { $content = $this->find("`plugin_fusioninventory_collects_id`='" . $contents_id . "'"); echo "<div class='spaced'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th colspan=5>" . __('Windows WMI associated', 'fusioninventory') . "</th>"; echo "</tr>"; echo "<tr>\n <th>" . __("Name") . "</th>\n <th>" . __("Moniker", "fusioninventory") . "</th>\n <th>" . __("Class", "fusioninventory") . "</th>\n <th>" . __("Properties", "fusioninventory") . "</th>\n <th>" . __("Action") . "</th>\n </tr>"; foreach ($content as $data) { echo "<tr>"; echo "<td align='center'>" . $data['name'] . "</td>"; echo "<td align='center'>" . $data['moniker'] . "</td>"; echo "<td align='center'>" . $data['class'] . "</td>"; echo "<td align='center'>" . $data['properties'] . "</td>"; echo "<td align='center'>\n <form name='form_bundle_item' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' method='post'>\n <input type='hidden' name='id' value='" . $data['id'] . "'>\n <input type='image' name='delete' src='../pics/drop.png'>"; Html::closeForm(); echo "</td>"; echo "</tr>"; } echo "</table>"; echo "</div>"; }
static function showCloneForm(CommonGLPI $item) { echo "<form name='form' method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "' >"; echo "<div class='spaced' id='tabsbody'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('Clone', 'behaviors') . "</th></tr>"; if ($item->isEntityAssign()) { echo "<tr class='tab_bg_1'><td class='center'>"; printf(__('%1$s: %2$s'), __('Destination entity'), "<span class='b'>" . Dropdown::getDropdownName('glpi_entities', $_SESSION['glpiactive_entity']) . "</span>"); echo "</td></tr>"; } $name = sprintf(__('%1$s %2$s'), __('Clone of', 'behaviors'), $item->getName()); echo "<tr class='tab_bg_1'><td class='center'>" . sprintf(__('%1$s: %2$s'), __('Name'), $name); Html::autocompletionTextField($item, 'name', array('value' => $name, 'size' => 60)); echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>"; echo "<input type='hidden' name='id' value='" . $item->getID() . "'>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'><td class='center'>"; echo "<input type='submit' name='_clone' value='" . __('Clone', 'behaviors') . "' class='submit'>"; echo "</th></tr>"; echo "</table></div>"; Html::closeForm(); }
static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) { if (in_array(get_class($item), array("AuthLDAP"))) { $AuthLDAP = new PluginMoreldapAuthLDAP(); if (!$AuthLDAP->getFromDB($item->fields['id'])) { //The directory exists in GLPI but there is no data in the plugin $AuthLDAP->preconfig(); } $location_enabled = $AuthLDAP->fields['location_enabled'] == 'Y' ? ' checked' : ''; echo '<div class="spaced">'; echo '<form id="items" name="items" method="post" action="' . Toolbox::getItemTypeFormURL(__CLASS__) . '">'; echo '<table class="tab_cadre_fixehov">'; echo '<tr class="tab_bg_2">'; echo '<th colspan="2">' . __("MoreLDAP", "moreldap") . '</th>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>' . __("LDAP attribute : location of users", "moreldap") . '</td>'; echo '<td>' . __("Enabled", "moreldap") . ' <input type="checkbox" name="location_enabled"' . $location_enabled . ' value="location_enabled"><br />'; echo '<input size="72" type="text" name="location" value="' . $AuthLDAP->fields['location'] . '"> '; echo '<br />'; Entity::dropdown(array('value' => $AuthLDAP->fields['entities_id'])); echo ' ' . __("recursive", "moreldap") . " "; Dropdown::showYesNo('is_recursive', $AuthLDAP->fields['is_recursive']); echo ' </td>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td colspan="2" class="center">'; echo '<input type="hidden" value="' . $item->fields['id'] . '" name="id">'; echo '<input type="submit" class="submit" name="update" value="' . _sx('button', 'Save') . '">'; echo '</td>'; echo '</tr>'; echo '</table>'; Html::closeForm(); echo "</div>"; } return true; }
function showFormExample() { global $CFG_GLPI; if (!Session::haveRight("config", UPDATE)) { return false; } $my_config = Config::getConfigurationValues('plugin:Example'); echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL('Config') . "\" method='post'>"; echo "<div class='center' id='tabsbody'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr><th colspan='4'>" . __('Example setup') . "</th></tr>"; echo "<td >" . __('My boolean choice :') . "</td>"; echo "<td colspan='3'>"; echo "<input type='hidden' name='config_class' value='" . __CLASS__ . "'>"; echo "<input type='hidden' name='config_context' value='plugin:Example'>"; Dropdown::showYesNo("configuration", $my_config['configuration']); echo "</td></tr>"; echo "<tr class='tab_bg_2'>"; echo "<td colspan='4' class='center'>"; echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">"; echo "</td></tr>"; echo "</table></div>"; Html::closeForm(); }
/** * show defined display preferences for a user * * @param $users_id integer user ID **/ static function showForUser($users_id) { global $DB; $url = Toolbox::getItemTypeFormURL(__CLASS__); $query = "SELECT `itemtype`,\n COUNT(*) AS nb\n FROM `glpi_displaypreferences`\n WHERE `users_id` = '{$users_id}'\n GROUP BY `itemtype`"; $req = $DB->request($query); if ($req->numrows() > 0) { $rand = mt_rand(); echo "<div class='spaced'>"; Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('width' => 400, 'height' => 200, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'delete_for_user' => _x('button', 'Delete permanently')), 'extraparams' => array('massive_action_fields' => array('users_id'))); Html::showMassiveActions($massiveactionparams); echo Html::hidden('users_id', array('value' => $users_id, 'data-glpicore-ma-tags' => 'common')); echo "<table class='tab_cadre_fixe'>"; echo "<tr>"; echo "<th width='10'>"; Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); echo "</th>"; echo "<th colspan='2'>" . __('Type') . "</th></tr>"; foreach ($req as $data) { echo "<tr class='tab_bg_1'><td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["itemtype"]); echo "</td>"; if ($item = getItemForItemtype($data["itemtype"])) { $name = $item->getTypeName(1); } else { $name = $data["itemtype"]; } echo "<td>{$name}</td><td class='numeric'>" . $data['nb'] . "</td>"; echo "</tr>"; } echo "</table>"; $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); echo "</div>"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><td class='b center'>" . __('No item found') . "</td></tr>"; echo "</table>"; } }
/** * Prints display post import * * @param $type the type of device * @param $ID the ID of device * @param $fromsupplier selection on pre import * @param $fromwarranty selection on pre import * @param $configID ID of supplier plugin config * @return results of data import * */ static function seePostImport($type, $ID, $fromsupplier, $fromwarranty, $configID) { global $DB, $CFG_GLPI; $config = new PluginManufacturersimportsConfig(); $config->GetFromDB($configID); $manufacturerId = $config->fields["manufacturers_id"]; if ($fromsupplier) { $supplierId = $fromsupplier; } else { $supplierId = $config->fields["suppliers_id"]; } $suppliername = $config->fields["name"]; $adddoc = $config->fields["document_adding"]; $rubrique = $config->fields["documentcategories_id"]; $addcomments = $config->fields["comment_adding"]; if ($fromwarranty) { $warranty = $fromwarranty; } else { $warranty = $config->fields["warranty_duration"]; } $itemtable = getTableForItemType($type); $query = "SELECT `" . $itemtable . "`.`id`,\n `" . $itemtable . "`.`name`,\n `" . $itemtable . "`.`entities_id`,\n `" . $itemtable . "`.`serial`\n FROM `" . $itemtable . "`, `glpi_manufacturers`\n WHERE `" . $itemtable . "`.`manufacturers_id` = `glpi_manufacturers`.`id`\n AND `" . $itemtable . "`.`is_deleted` = '0'\n AND `" . $itemtable . "`.`is_template` = '0'\n AND `glpi_manufacturers`.`id` = '" . $manufacturerId . "'\n AND `" . $itemtable . "`.`serial` != ''\n AND `" . $itemtable . "`.`id` = '" . $ID . "' "; $query .= " ORDER BY `" . $itemtable . "`.`name`"; $result = $DB->query($query); while ($line = $DB->fetch_array($result)) { $compSerial = $line['serial']; $ID = $line['id']; echo "<tr class='tab_bg_1' ><td>"; $link = Toolbox::getItemTypeFormURL($type); $dID = ""; $model = new PluginManufacturersimportsModel(); $otherSerial = $model->checkIfModelNeeds($type, $ID); if ($_SESSION["glpiis_ids_visible"] || empty($line["name"])) { $dID .= " (" . $line["id"] . ")"; } echo "<a href='" . $link . "?id=" . $ID . "'>" . $line["name"] . $dID . "</a><br>" . $otherSerial . "</td>"; $url = PluginManufacturersimportsPreImport::selectSupplier($suppliername, $compSerial, $otherSerial); //On complete l url du support du fournisseur avec le serial echo "<td>" . $compSerial . "</td>"; echo "<td>"; echo "<a href='" . $url . "' target='_blank'>" . _n('Manufacturer', 'Manufacturers', 1) . "</a>"; echo "</td>"; $contents = ""; $msgerr = ""; $options = array("url" => $url, "download" => false, "file" => false, "suppliername" => $suppliername); $contents = self::cURLData($options); // On extrait la date de garantie de la variable contents. $field = self::selectSupplierfield($suppliername); if ($suppliername == "Dell" || $suppliername != "Dell" && !stristr($contents, $field) === FALSE) { if ($suppliername != "Dell") { $finduhtml = stristr($contents, $field); } else { $finduhtml = $compSerial; $contents = $compSerial; } $maDate = self::importDate($suppliername, $finduhtml); $warranty = self::importWarranty($suppliername, $maDate, $contents, $warranty); if ($maDate != "0000-00-00") { //warranty for life if ($warranty > 120) { $warranty = -1; } $date = date("Y-m-d"); $options = array("itemtype" => $type, "ID" => $ID, "date" => $date, "supplierId" => $supplierId, "warranty" => $warranty, "suppliername" => $suppliername, "addcomments" => $addcomments, "maDate" => $maDate); self::saveInfocoms($options); // on cree un doc dans GLPI qu'on va lier au materiel if ($adddoc != 0 && $suppliername != "Dell") { $options = array("itemtype" => $type, "ID" => $ID, "url" => $url, "entities_id" => $line["entities_id"], "rubrique" => $rubrique, "suppliername" => $suppliername); $values["documents_id"] = self::addDocument($options); } //insert base locale $values["import_status"] = 1; $values["items_id"] = $ID; $values["itemtype"] = $type; $values["date_import"] = $date; $log = new PluginManufacturersimportsLog(); $log->add($values); $_SESSION["glpi_plugin_manufacturersimports_total"] += 1; } else { // Failed check date self::isInError($type, $ID, $contents); } } else { // Failed checj contents self::isInError($type, $ID); } echo "</tr>\n"; } }
/** @file * @brief * @since version 0.84 */ include '../inc/includes.php'; Session::checkCentralAccess(); $cost = new TicketCost(); if (isset($_POST["add"])) { $cost->check(-1, CREATE, $_POST); if ($newID = $cost->add($_POST)) { Event::log($_POST['tickets_id'], "tickets", 4, "tracking", sprintf(__('%s adds a cost'), $_SESSION["glpiname"])); } Html::back(); } else { if (isset($_POST["purge"])) { $cost->check($_POST["id"], PURGE); if ($cost->delete($_POST, 1)) { Event::log($cost->fields['tickets_id'], "tickets", 4, "tracking", sprintf(__('%s purges a cost'), $_SESSION["glpiname"])); } Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . '?id=' . $cost->fields['tickets_id']); } else { if (isset($_POST["update"])) { $cost->check($_POST["id"], UPDATE); if ($cost->update($_POST)) { Event::log($cost->fields['tickets_id'], "tickets", 4, "tracking", sprintf(__('%s updates a cost'), $_SESSION["glpiname"])); } Html::back(); } } } Html::displayErrorAndDie('Lost');
/** * Show items of the current user * * @param $tech **/ function showItems($tech) { global $DB, $CFG_GLPI; $ID = $this->getField('id'); if ($tech) { $type_user = $CFG_GLPI['linkuser_tech_types']; $type_group = $CFG_GLPI['linkgroup_tech_types']; $field_user = '******'; $field_group = 'groups_id_tech'; } else { $type_user = $CFG_GLPI['linkuser_types']; $type_group = $CFG_GLPI['linkgroup_types']; $field_user = '******'; $field_group = 'groups_id'; } $group_where = ""; $groups = array(); $query = "SELECT `glpi_groups_users`.`groups_id`,\n `glpi_groups`.`name`\n FROM `glpi_groups_users`\n LEFT JOIN `glpi_groups` ON (`glpi_groups`.`id` = `glpi_groups_users`.`groups_id`)\n WHERE `glpi_groups_users`.`users_id` = '{$ID}'"; $result = $DB->query($query); $number = $DB->numrows($result); if ($number > 0) { $first = true; while ($data = $DB->fetch_assoc($result)) { if ($first) { $first = false; } else { $group_where .= " OR "; } $group_where .= " `" . $field_group . "` = '" . $data["groups_id"] . "' "; $groups[$data["groups_id"]] = $data["name"]; } } echo "<div class='spaced'><table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('Type') . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Serial number') . "</th>"; echo "<th>" . __('Inventory number') . "</th>"; echo "<th>" . __('Status') . "</th>"; echo "<th> </th></tr>"; foreach ($type_user as $itemtype) { if (!($item = getItemForItemtype($itemtype))) { continue; } if ($item->canView()) { $itemtable = getTableForItemType($itemtype); $query = "SELECT *\n FROM `{$itemtable}`\n WHERE `" . $field_user . "` = '{$ID}'"; if ($item->maybeTemplate()) { $query .= " AND `is_template` = '0' "; } if ($item->maybeDeleted()) { $query .= " AND `is_deleted` = '0' "; } $result = $DB->query($query); $type_name = $item->getTypeName(); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_assoc($result)) { $cansee = $item->can($data["id"], "r"); $link = $data["name"]; if ($cansee) { $link_item = Toolbox::getItemTypeFormURL($itemtype); if ($_SESSION["glpiis_ids_visible"] || empty($link)) { $link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]); } $link = "<a href='" . $link_item . "?id=" . $data["id"] . "'>" . $link . "</a>"; } $linktype = ""; if ($data[$field_user] == $ID) { $linktype = self::getTypeName(1); } echo "<tr class='tab_bg_1'><td class='center'>{$type_name}</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]) . "</td>"; echo "<td class='center'>{$link}</td>"; echo "<td class='center'>"; if (isset($data["serial"]) && !empty($data["serial"])) { echo $data["serial"]; } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["otherserial"]) && !empty($data["otherserial"])) { echo $data["otherserial"]; } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["states_id"])) { echo Dropdown::getDropdownName("glpi_states", $data['states_id']); } else { echo ' '; } echo "</td><td class='center'>{$linktype}</td></tr>"; } } } } echo "</table></div>"; if (!empty($group_where)) { echo "<div class='spaced'><table class='tab_cadre_fixe'><tr>" . "<th>" . __('Type') . "</th>" . "<th>" . __('Entity') . "</th>" . "<th>" . __('Name') . "</th>" . "<th>" . __('Serial number') . "</th>" . "<th>" . __('Inventory number') . "</th>" . "<th>" . __('Status') . "</th>" . "<th> </th></tr>"; foreach ($type_group as $itemtype) { if (!($item = getItemForItemtype($itemtype))) { continue; } if ($item->canView()) { $itemtable = getTableForItemType($itemtype); $query = "SELECT *\n FROM `{$itemtable}`\n WHERE {$group_where}"; if ($item->maybeTemplate()) { $query .= " AND `is_template` = '0' "; } if ($item->maybeDeleted()) { $query .= " AND `is_deleted` = '0' "; } $result = $DB->query($query); $type_name = $item->getTypeName(); if ($DB->numrows($result) > 0) { while ($data = $DB->fetch_assoc($result)) { $cansee = $item->can($data["id"], "r"); $link = $data["name"]; if ($cansee) { $link_item = Toolbox::getItemTypeFormURL($itemtype); if ($_SESSION["glpiis_ids_visible"] || empty($link)) { $link = sprintf(__('%1$s (%2$s)'), $link, $data["id"]); } $link = "<a href='" . $link_item . "?id=" . $data["id"] . "'>" . $link . "</a>"; } $linktype = ""; if (isset($groups[$data[$field_group]])) { $linktype = sprintf(__('%1$s = %2$s'), _n('Group', 'Groups', 1), $groups[$data[$field_group]]); } echo "<tr class='tab_bg_1'><td class='center'>{$type_name}</td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $data["entities_id"]); echo "</td><td class='center'>{$link}</td>"; echo "<td class='center'>"; if (isset($data["serial"]) && !empty($data["serial"])) { echo $data["serial"]; } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["otherserial"]) && !empty($data["otherserial"])) { echo $data["otherserial"]; } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["states_id"])) { echo Dropdown::getDropdownName("glpi_states", $data['states_id']); } else { echo ' '; } echo "</td><td class='center'>{$linktype}</td></tr>"; } } } } echo "</table></div>"; } }
$fup = new TicketFollowup(); if (isset($_POST["add"])) { $fup->check(-1, CREATE, $_POST); $fup->add($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s adds a followup'), $_SESSION["glpiname"])); Html::back(); } else { if (isset($_POST['add_close']) || isset($_POST['add_reopen'])) { $ticket = new Ticket(); if ($ticket->getFromDB($_POST["tickets_id"]) && $ticket->canApprove()) { $fup->add($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s approves or refuses a solution'), $_SESSION["glpiname"])); Html::back(); } } else { if (isset($_POST["update"])) { $fup->check($_POST['id'], UPDATE); $fup->update($_POST); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s updates a followup'), $_SESSION["glpiname"])); Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . "?id=" . $fup->getField('tickets_id')); } else { if (isset($_POST["purge"])) { $fup->check($_POST['id'], PURGE); $fup->delete($_POST, 1); Event::log($fup->getField('tickets_id'), "ticket", 4, "tracking", sprintf(__('%s purges a followup'), $_SESSION["glpiname"])); Html::redirect(Toolbox::getItemTypeFormURL('Ticket') . "?id=" . $fup->getField('tickets_id')); } } } } Html::displayErrorAndDie('Lost');
/** * Show tickets for a projecttask * * @param $projecttask ProjectTask object **/ static function showForProjectTask(ProjectTask $projecttask) { global $DB, $CFG_GLPI; $ID = $projecttask->getField('id'); if (!$projecttask->can($ID, READ)) { return false; } $canedit = $projecttask->canEdit($ID); $rand = mt_rand(); $query = "SELECT DISTINCT `glpi_projecttasks_tickets`.`id` AS linkID,\n `glpi_tickets`.*\n FROM `glpi_projecttasks_tickets`\n LEFT JOIN `glpi_tickets`\n ON (`glpi_projecttasks_tickets`.`tickets_id` = `glpi_tickets`.`id`)\n WHERE `glpi_projecttasks_tickets`.`projecttasks_id` = '{$ID}'\n ORDER BY `glpi_tickets`.`name`"; $result = $DB->query($query); $tickets = array(); $used = array(); if ($numrows = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $tickets[$data['id']] = $data; $used[$data['id']] = $data['id']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='projecttaskticket_form{$rand}' id='projecttaskticket_form{$rand}'\n method='post' action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='3'>" . __('Add a ticket') . "</th></tr>"; echo "<tr class='tab_bg_2'><td class='right'>"; echo "<input type='hidden' name='projecttasks_id' value='{$ID}'>"; $condition = "`glpi_tickets`.`status`\n NOT IN ('" . implode("', '", array_merge(Ticket::getSolvedStatusArray(), Ticket::getClosedStatusArray())) . "')"; Ticket::dropdown(array('used' => $used, 'entity' => $projecttask->getEntityID(), 'entity_sons' => $projecttask->isRecursive(), 'condition' => $condition, 'displaywith' => array('id'))); echo "</td><td width='20%'>"; echo "<a href='" . Toolbox::getItemTypeFormURL('Ticket') . "?_projecttasks_id={$ID}'>"; _e('Create a ticket from this task'); echo "</a>"; 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 ($canedit && $numrows) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov'>"; echo "<tr><th colspan='12'>" . Ticket::getTypeName($numrows) . "</th>"; echo "</tr>"; if ($numrows) { Ticket::commonListHeader(Search::HTML_OUTPUT, 'mass' . __CLASS__ . $rand); Session::initNavigateListItems('Ticket', sprintf(__('%1$s = %2$s'), ProjectTask::getTypeName(1), $projecttask->fields["name"])); $i = 0; foreach ($tickets as $data) { Session::addToNavigateListItems('Ticket', $data["id"]); Ticket::showShort($data['id'], array('followups' => false, 'row_num' => $i, 'type_for_massiveaction' => __CLASS__, 'id_for_massiveaction' => $data['linkID'])); $i++; } } echo "</table>"; if ($canedit && $numrows) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Display all device for a group * * @param $type the objet type * @param $result the resultset of all the devices found **/ function displayUserDevices($type, $result) { global $DB, $CFG_GLPI; $item = new $type(); while ($data = $DB->fetch_array($result)) { $link = $data["name"]; $url = Toolbox::getItemTypeFormURL("{$type}"); $link = "<a href='" . $url . "?id=" . $data["id"] . "'>" . $link . ($CFG_GLPI["is_ids_visible"] || empty($link) ? " (" . $data["id"] . ")" : "") . "</a>"; $linktype = ""; if (isset($groups[$data["groups_id"]])) { $linktype = sprintf(__('%1$s %2$s'), __('Group'), $groups[$data["groups_id"]]); } echo "<tr class='tab_bg_1'><td class='center'>" . $item->getTypeName() . "</td>" . "<td class='center'>{$link}</td>"; echo "<td class='center'>"; if (isset($data["serial"]) && !empty($data["serial"])) { echo $data["serial"]; } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["otherserial"]) && !empty($data["otherserial"])) { echo $data["otherserial"]; } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["immo_number"]) && !empty($data["immo_number"])) { echo $data["immo_number"]; } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["suppliers_id"]) && !empty($data["suppliers_id"])) { echo Dropdown::getDropdownName("glpi_suppliers", $data["suppliers_id"]); } else { echo ' '; } echo "</td><td class='center'>"; if (isset($data["buy_date"]) && !empty($data["buy_date"])) { echo Html::convDate($data["buy_date"]); } else { echo ' '; } echo "</td></tr>"; } }
/** * Print the HTML array for Items linked to a problem * * @param $problem Problem object * * @return Nothing (display) **/ static function showForProblem(Problem $problem) { global $DB, $CFG_GLPI; $instID = $problem->fields['id']; if (!$problem->can($instID, READ)) { return false; } $canedit = $problem->canEdit($instID); $rand = mt_rand(); $query = "SELECT DISTINCT `itemtype`\n FROM `glpi_items_problems`\n WHERE `glpi_items_problems`.`problems_id` = '{$instID}'\n ORDER BY `itemtype`"; $result = $DB->query($query); $number = $DB->numrows($result); if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='problemitem_form{$rand}' id='problemitem_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add an item') . "</th></tr>"; echo "<tr class='tab_bg_1'><td>"; $types = array(); foreach ($problem->getAllTypesForHelpdesk() as $key => $val) { $types[] = $key; } Dropdown::showSelectItemFromItemtypes(array('itemtypes' => $types, 'entity_restrict' => $problem->fields['is_recursive'] ? getSonsOf('glpi_entities', $problem->fields['entities_id']) : $problem->fields['entities_id'])); echo "</td><td class='center' width='30%'>"; echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>"; echo "<input type='hidden' name='problems_id' value='{$instID}'>"; echo "</td></tr>"; echo "</table>"; Html::closeForm(); echo "</div>"; } echo "<div class='spaced'>"; if ($canedit && $number) { Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); $massiveactionparams = array('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) { $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>" . __('Type') . "</th>"; $header_end .= "<th>" . __('Entity') . "</th>"; $header_end .= "<th>" . __('Name') . "</th>"; $header_end .= "<th>" . __('Serial number') . "</th>"; $header_end .= "<th>" . __('Inventory number') . "</th></tr>"; echo $header_begin . $header_top . $header_end; $totalnb = 0; for ($i = 0; $i < $number; $i++) { $itemtype = $DB->result($result, $i, "itemtype"); if (!($item = getItemForItemtype($itemtype))) { continue; } if ($item->canView()) { $itemtable = getTableForItemType($itemtype); $query = "SELECT `{$itemtable}`.*,\n `glpi_items_problems`.`id` AS IDD,\n `glpi_entities`.`id` AS entity\n FROM `glpi_items_problems`,\n `{$itemtable}`"; if ($itemtype != 'Entity') { $query .= " LEFT JOIN `glpi_entities`\n ON (`{$itemtable}`.`entities_id`=`glpi_entities`.`id`) "; } $query .= " WHERE `{$itemtable}`.`id` = `glpi_items_problems`.`items_id`\n AND `glpi_items_problems`.`itemtype` = '{$itemtype}'\n AND `glpi_items_problems`.`problems_id` = '{$instID}'"; if ($item->maybeTemplate()) { $query .= " AND `{$itemtable}`.`is_template` = '0'"; } $query .= getEntitiesRestrictRequest(" AND", $itemtable, '', '', $item->maybeRecursive()) . "\n ORDER BY `glpi_entities`.`completename`, `{$itemtable}`.`name`"; $result_linked = $DB->query($query); $nb = $DB->numrows($result_linked); for ($prem = true; $data = $DB->fetch_assoc($result_linked); $prem = false) { $name = $data["name"]; if ($_SESSION["glpiis_ids_visible"] || empty($data["name"])) { $name = sprintf(__('%1$s (%2$s)'), $name, $data["id"]); } $link = $itemtype::getFormURLWithID($data['id']); $namelink = "<a href=\"" . $link . "\">" . $name . "</a>"; echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td width='10'>"; Html::showMassiveActionCheckBox(__CLASS__, $data["IDD"]); echo "</td>"; } if ($prem) { $typename = $item->getTypeName($nb); echo "<td class='center top' rowspan='{$nb}'>" . ($nb > 1 ? sprintf(__('%1$s: %2$s'), $typename, $nb) : $typename) . "</td>"; } echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_entities", $data['entity']) . "</td>"; echo "<td class='center" . (isset($data['is_deleted']) && $data['is_deleted'] ? " tab_bg_2_2'" : "'"); echo ">" . $namelink . "</td>"; echo "<td class='center'>" . (isset($data["serial"]) ? "" . $data["serial"] . "" : "-") . "</td>"; echo "<td class='center'>" . (isset($data["otherserial"]) ? "" . $data["otherserial"] . "" : "-") . "</td>"; echo "</tr>"; } $totalnb += $nb; } } if ($number) { echo $header_begin . $header_bottom . $header_end; } echo "</table>"; if ($canedit && $number) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); Html::closeForm(); } echo "</div>"; }
/** * Print the HTML array of suppliers for this contract * * @since version 0.84 * * @param $contract Contract object * * @return Nothing (HTML display) **/ static function showForContract(Contract $contract) { global $DB, $CFG_GLPI; $instID = $contract->fields['id']; if (!$contract->can($instID, 'r') || !Session::haveRight("contact_enterprise", "r")) { return false; } $canedit = $contract->can($instID, 'w'); $rand = mt_rand(); $query = "SELECT `glpi_contracts_suppliers`.`id`,\n `glpi_suppliers`.`id` AS entID,\n `glpi_suppliers`.`name` AS name,\n `glpi_suppliers`.`website` AS website,\n `glpi_suppliers`.`phonenumber` AS phone,\n `glpi_suppliers`.`suppliertypes_id` AS type,\n `glpi_entities`.`id` AS entity\n FROM `glpi_contracts_suppliers`,\n `glpi_suppliers`\n LEFT JOIN `glpi_entities` ON (`glpi_entities`.`id`=`glpi_suppliers`.`entities_id`)\n WHERE `glpi_contracts_suppliers`.`contracts_id` = '{$instID}'\n AND `glpi_contracts_suppliers`.`suppliers_id`=`glpi_suppliers`.`id`" . getEntitiesRestrictRequest(" AND", "glpi_suppliers", '', '', true) . "\n ORDER BY `glpi_entities`.`completename`, `name`"; $result = $DB->query($query); $suppliers = array(); $used = array(); if ($number = $DB->numrows($result)) { while ($data = $DB->fetch_assoc($result)) { $suppliers[$data['id']] = $data; $used[$data['entID']] = $data['entID']; } } if ($canedit) { echo "<div class='firstbloc'>"; echo "<form name='contractsupplier_form{$rand}' id='contractsupplier_form{$rand}' method='post'\n action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>"; echo "<input type='hidden' name='contracts_id' value='{$instID}'>"; echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a supplier') . "</th></tr>"; echo "<tr class='tab_bg_1'><td class='right'>"; Supplier::dropdown(array('used' => $used, 'entity' => $contract->fields["entities_id"], 'entity_sons' => $contract->fields["is_recursive"])); 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 ($canedit && $number) { 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) { echo "<th width='10'>" . Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>"; } echo "<th>" . __('Supplier') . "</th>"; echo "<th>" . __('Entity') . "</th>"; echo "<th>" . __('Third party type') . "</th>"; echo "<th>" . __('Phone') . "</th>"; echo "<th>" . __('Website') . "</th>"; echo "</tr>"; $used = array(); foreach ($suppliers as $data) { $ID = $data['id']; $website = $data['website']; if (!empty($website)) { if (!preg_match("?https*://?", $website)) { $website = "http://" . $website; } $website = "<a target=_blank href='{$website}'>" . $data['website'] . "</a>"; } $entID = $data['entID']; $entity = $data['entity']; $used[$entID] = $entID; $entname = Dropdown::getDropdownName("glpi_suppliers", $entID); echo "<tr class='tab_bg_1'>"; if ($canedit) { echo "<td>"; Html::showMassiveActionCheckBox(__CLASS__, $data["id"]); echo "</td>"; } echo "<td class='center'>"; if ($_SESSION["glpiis_ids_visible"] || empty($entname)) { $entname = sprintf(__('%1$s (%2$s)'), $entname, $entID); } echo "<a href='" . $CFG_GLPI["root_doc"] . "/front/supplier.form.php?id={$entID}'>" . $entname; echo "</a></td>"; echo "<td class='center'>" . Dropdown::getDropdownName("glpi_entities", $entity) . "</td>"; echo "<td class='center'>"; echo Dropdown::getDropdownName("glpi_suppliertypes", $data['type']) . "</td>"; echo "<td class='center'>" . $data['phone'] . "</td>"; echo "<td class='center'>" . $website . "</td>"; echo "</tr>"; } echo "</table>"; if ($canedit && $number) { $paramsma['ontop'] = false; Html::showMassiveActions(__CLASS__, $paramsma); Html::closeForm(); } echo "</div>"; }