/** * Display datas extracted from DB * * @param $data array of search datas prepared to get datas * * @return nothing **/ static function displayDatas(array &$data) { global $CFG_GLPI; $item = null; if (class_exists($data['itemtype'])) { $item = new $data['itemtype'](); } $rand = mt_rand(); if (!isset($data['data']) || !isset($data['data']['totalcount'])) { return false; } // Contruct Pager parameters $globallinkto = Toolbox::append_params(array('criteria' => Toolbox::stripslashes_deep($data['search']['criteria']), 'metacriteria' => Toolbox::stripslashes_deep($data['search']['metacriteria'])), '&'); $parameters = "sort=" . $data['search']['sort'] . "&order=" . $data['search']['order'] . '&' . $globallinkto; if (isset($_GET['_in_modal'])) { $parameters .= "&_in_modal=1"; } // Global search header if ($data['display_type'] == self::GLOBAL_SEARCH) { if ($data['item']) { echo "<div class='center'><h2>" . $data['item']->getTypeName(); // More items if ($data['data']['totalcount'] > $data['search']['start'] + self::GLOBAL_DISPLAY_COUNT) { echo " <a href='" . $data['search']['target'] . "?{$parameters}'>" . __('All') . "</a>"; } echo "</h2></div>\n"; } else { return false; } } // If the begin of the view is before the number of items if ($data['data']['count'] > 0) { // Display pager only for HTML if ($data['display_type'] == self::HTML_OUTPUT) { // For plugin add new parameter if available if ($plug = isPluginItemType($data['itemtype'])) { $function = 'plugin_' . $plug['plugin'] . '_addParamFordynamicReport'; if (function_exists($function)) { $out = $function($data['itemtype']); if (is_array($out) && count($out)) { $parameters .= Toolbox::append_params($out, '&'); } } } $search_config_top = ""; $search_config_bottom = ""; if (!isset($_GET['_in_modal']) && Session::haveRightsOr('search_config', array(DisplayPreference::PERSONAL, DisplayPreference::GENERAL))) { $search_config_top = $search_config_bottom = "<div class='pager_controls'><img alt=\"" . __s('Select default items to show') . "\" title=\"" . __s('Select default items to show') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $search_config_top .= " class='pointer' onClick=\""; $search_config_top .= Html::jsGetElementbyID('search_config_top') . ".dialog('open');\">"; $search_config_bottom .= " class='pointer' onClick=\""; $search_config_bottom .= Html::jsGetElementbyID('search_config_bottom') . ".dialog('open');\">"; $search_config_top .= Ajax::createIframeModalWindow('search_config_top', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false)); $search_config_bottom .= Ajax::createIframeModalWindow('search_config_bottom', $CFG_GLPI["root_doc"] . "/front/displaypreference.form.php?itemtype=" . $data['itemtype'], array('title' => __('Select default items to show'), 'reloadonclose' => true, 'display' => false)); } if ($item !== null && $item->maybeDeleted()) { $delete_ctrl = self::isDeletedSwitch($data['search']['is_deleted']); $search_config_top .= $delete_ctrl; } Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, $data['itemtype'], 0, $search_config_top); $search_config_top .= "</div>"; $search_config_bottom .= "</div>"; } // Define begin and end var for loop // Search case $begin_display = $data['data']['begin']; $end_display = $data['data']['end']; // Form to massive actions $isadmin = $data['item'] && $data['item']->canUpdate(); if (!$isadmin && InfoCom::canApplyOn($data['itemtype'])) { $isadmin = Infocom::canUpdate() || Infocom::canCreate(); } if ($data['itemtype'] != 'AllAssets') { $showmassiveactions = count(MassiveAction::getAllMassiveActions($data['item'], $data['search']['is_deleted'])); } else { $showmassiveactions = true; } $massformid = 'massform' . $data['itemtype']; if ($showmassiveactions && $data['display_type'] == self::HTML_OUTPUT) { Html::openMassiveActionsForm($massformid); $massiveactionparams = $data['search']['massiveactionparams']; $massiveactionparams['num_displayed'] = $end_display - $begin_display; $massiveactionparams['fixed'] = false; $massiveactionparams['is_deleted'] = $data['search']['is_deleted']; $massiveactionparams['container'] = $massformid; Html::showMassiveActions($massiveactionparams); } // Compute number of columns to display // Add toview elements $nbcols = count($data['data']['cols']); if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $nbcols++; } // Display List Header echo self::showHeader($data['display_type'], $end_display - $begin_display + 1, $nbcols); // New Line for Header Items Line $headers_line = ''; $headers_line_top = ''; $headers_line_bottom = ''; $headers_line_top .= self::showBeginHeader($data['display_type']); $headers_line_top .= self::showNewLine($data['display_type']); if ($data['display_type'] == self::HTML_OUTPUT) { // $headers_line_bottom .= self::showBeginHeader($data['display_type']); $headers_line_bottom .= self::showNewLine($data['display_type']); } $header_num = 1; if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $headers_line_top .= self::showHeaderItem($data['display_type'], Html::getCheckAllAsCheckbox($massformid), $header_num, "", 0, $data['search']['order']); if ($data['display_type'] == self::HTML_OUTPUT) { $headers_line_bottom .= self::showHeaderItem($data['display_type'], Html::getCheckAllAsCheckbox($massformid), $header_num, "", 0, $data['search']['order']); } } // Display column Headers for toview items $metanames = array(); foreach ($data['data']['cols'] as $key => $val) { $linkto = ''; if (!$val['meta'] && (!isset($val['searchopt']['nosort']) || !$val['searchopt']['nosort'])) { $linkto = $data['search']['target'] . (strpos($data['search']['target'], '?') ? '&' : '?') . "itemtype=" . $data['itemtype'] . "&sort=" . $val['id'] . "&order=" . ($data['search']['order'] == "ASC" ? "DESC" : "ASC") . "&start=" . $data['search']['start'] . "&" . $globallinkto; } $name = $val["name"]; // prefix by group name (corresponding to optgroup in dropdown) if exists if (isset($val['groupname'])) { $name = $val['groupname'] . " - " . $name; } // Not main itemtype add itemtype to display if ($data['itemtype'] != $val['itemtype']) { if (!isset($metanames[$val['itemtype']])) { if ($metaitem = getItemForItemtype($val['itemtype'])) { $metanames[$val['itemtype']] = $metaitem->getTypeName(); } } $name = sprintf(__('%1$s - %2$s'), $metanames[$val['itemtype']], $val["name"]); } $headers_line .= self::showHeaderItem($data['display_type'], $name, $header_num, $linkto, !$val['meta'] && $data['search']['sort'] == $val['id'], $data['search']['order']); } // Add specific column Header if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $headers_line .= self::showHeaderItem($data['display_type'], __('Item type'), $header_num); } // End Line for column headers $headers_line .= self::showEndLine($data['display_type']); $headers_line_top .= $headers_line; if ($data['display_type'] == self::HTML_OUTPUT) { $headers_line_bottom .= $headers_line; } $headers_line_top .= self::showEndHeader($data['display_type']); // $headers_line_bottom .= self::showEndHeader($data['display_type']); echo $headers_line_top; // Init list of items displayed if ($data['display_type'] == self::HTML_OUTPUT) { Session::initNavigateListItems($data['itemtype']); } // Num of the row (1=header_line) $row_num = 1; $massiveaction_field = 'id'; if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $massiveaction_field = 'refID'; } $typenames = array(); // Display Loop foreach ($data['data']['rows'] as $rowkey => $row) { // Column num $item_num = 1; $row_num++; // New line echo self::showNewLine($data['display_type'], $row_num % 2, $data['search']['is_deleted']); $current_type = isset($row['TYPE']) ? $row['TYPE'] : $data['itemtype']; $massiveaction_type = $current_type; if ($data['itemtype'] != 'AllAssets' && isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { $massiveaction_type = $data['itemtype']; } // Add item in item list Session::addToNavigateListItems($current_type, $row["id"]); if ($data['display_type'] == self::HTML_OUTPUT && $showmassiveactions) { // HTML display - massive modif $tmpcheck = ""; if ($data['itemtype'] == 'Entity' && !in_array($row["id"], $_SESSION["glpiactiveentities"])) { $tmpcheck = " "; } else { if ($data['item'] instanceof CommonDBTM && $data['item']->maybeRecursive() && !in_array($row["entities_id"], $_SESSION["glpiactiveentities"])) { $tmpcheck = " "; } else { $tmpcheck = Html::getMassiveActionCheckBox($massiveaction_type, $row[$massiveaction_field]); } } echo self::showItem($data['display_type'], $tmpcheck, $item_num, $row_num, "width='10'"); } // Print other toview items foreach ($data['data']['cols'] as $colkey => $col) { if (!$col['meta']) { echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num, self::displayConfigItem($data['itemtype'], $col['id'], $row, $colkey)); } else { // META case echo self::showItem($data['display_type'], $row[$colkey]['displayname'], $item_num, $row_num); } } if (isset($CFG_GLPI["union_search_type"][$data['itemtype']])) { if (!isset($typenames[$row["TYPE"]])) { if ($itemtmp = getItemForItemtype($row["TYPE"])) { $typenames[$row["TYPE"]] = $itemtmp->getTypeName(); } } echo self::showItem($data['display_type'], $typenames[$row["TYPE"]], $item_num, $row_num); } // End Line echo self::showEndLine($data['display_type']); } // Create title $title = ''; if ($data['display_type'] == self::PDF_OUTPUT_LANDSCAPE || $data['display_type'] == self::PDF_OUTPUT_PORTRAIT) { $title = self::computeTitle($data); } if ($data['display_type'] == self::HTML_OUTPUT) { echo $headers_line_bottom; } // Display footer echo self::showFooter($data['display_type'], $title); // Delete selected item if ($data['display_type'] == self::HTML_OUTPUT) { if ($showmassiveactions) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); // End form for delete item Html::closeForm(); } else { echo "<br>"; } } if ($data['display_type'] == self::HTML_OUTPUT) { // In case of HTML display Html::printPager($data['search']['start'], $data['data']['totalcount'], $data['search']['target'], $parameters, '', 0, $search_config_bottom); } } else { if ($item !== null && $item->maybeDeleted()) { echo "<div class='center'>" . self::isDeletedSwitch($data['search']['is_deleted']) . "</div><br/>"; } echo self::showError($data['display_type']); } }
function showForm($ID, $options) { global $DB, $CFG_GLPI; if (!Config::canUpdate()) { return false; } $notificationtemplates_id = -1; if (isset($options['notificationtemplates_id'])) { $notificationtemplates_id = $options['notificationtemplates_id']; } if ($this->getFromDB($ID)) { $notificationtemplates_id = $this->getField('notificationtemplates_id'); } $this->initForm($ID, $options); $template = new NotificationTemplate(); $template->getFromDB($notificationtemplates_id); Html::initEditorSystem('content_html'); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . NotificationTemplate::getTypeName() . "</td>"; echo "<td colspan='2'><a href='" . Toolbox::getItemTypeFormURL('NotificationTemplate') . "?id=" . $notificationtemplates_id . "'>" . $template->getField('name') . "</a>"; echo "</td><td>"; $rand = mt_rand(); Ajax::createIframeModalWindow("tags" . $rand, $CFG_GLPI['root_doc'] . "/front/notification.tags.php?sub_type=" . $template->getField('itemtype')); echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID("tags" . $rand) . ".dialog('open');\">" . __('Show list of available tags') . "</a>"; echo "</td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Language') . "</td><td colspan='3'>"; //Get all used languages $used = self::getAllUsedLanguages($notificationtemplates_id); if ($ID > 0) { if (isset($used[$this->getField('language')])) { unset($used[$this->getField('language')]); } } Dropdown::showLanguages("language", array('display_emptychoice' => true, 'value' => $this->fields['language'], 'used' => $used)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>" . __('Subject') . "</td>"; echo "<td colspan='3'>"; Html::autocompletionTextField($this, 'subject', array('size' => 100)); echo "</td></tr>"; echo "<tr class='tab_bg_1'><td>"; _e('Email text body'); echo "<br>" . __('(leave the field empty for a generation from HTML)'); echo "</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_text' >" . $this->fields["content_text"]; echo "</textarea></td></tr>"; echo "<tr class='tab_bg_1'>"; echo "<td>"; _e('Email HTML body'); echo "</td><td colspan='3'>"; echo "<textarea cols='100' rows='15' name='content_html'>" . $this->fields["content_html"]; echo "</textarea>"; echo "<input type='hidden' name='notificationtemplates_id' value='" . $template->getField('id') . "'>"; echo "</td></tr>"; $this->showFormButtons($options); return true; }
/** * Print out list kb item * * @param $options $_GET * @param $type string search type : browse / search (default search) **/ static function showList($options, $type = 'search') { global $DB, $CFG_GLPI; // Default values of parameters $params['faq'] = !Session::haveRight(self::$rightname, READ); $params["start"] = "0"; $params["knowbaseitemcategories_id"] = "0"; $params["contains"] = ""; $params["target"] = $_SERVER['PHP_SELF']; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } $ki = new self(); switch ($type) { case 'myunpublished': if (!Session::haveRightsOr(self::$rightname, array(UPDATE, self::PUBLISHFAQ))) { return false; } break; case 'allunpublished': if (!Session::haveRight(self::$rightname, self::KNOWBASEADMIN)) { return false; } break; default: break; } if (!$params["start"]) { $params["start"] = 0; } $query = self::getListRequest($params, $type); // Get it from database if ($result = $DB->query($query)) { $KbCategory = new KnowbaseItemCategory(); $title = ""; if ($KbCategory->getFromDB($params["knowbaseitemcategories_id"])) { $title = empty($KbCategory->fields['name']) ? "(" . $params['knowbaseitemcategories_id'] . ")" : $KbCategory->fields['name']; $title = sprintf(__('%1$s: %2$s'), __('Category'), $title); } Session::initNavigateListItems('KnowbaseItem', $title); $numrows = $DB->numrows($result); $list_limit = $_SESSION['glpilist_limit']; $showwriter = in_array($type, array('myunpublished', 'allunpublished', 'allmy')); // Limit the result, if no limit applies, use prior result if ($numrows > $list_limit && !isset($_GET['export_all'])) { $query_limit = $query . " LIMIT " . intval($params["start"]) . ", " . intval($list_limit) . " "; $result_limit = $DB->query($query_limit); $numrows_limit = $DB->numrows($result_limit); } else { $numrows_limit = $numrows; $result_limit = $result; } if ($numrows_limit > 0) { // Set display type for export if define $output_type = Search::HTML_OUTPUT; if (isset($_GET["display_type"])) { $output_type = $_GET["display_type"]; } // Pager $parameters = "start=" . $params["start"] . "&knowbaseitemcategories_id=" . $params['knowbaseitemcategories_id'] . "&contains=" . $params["contains"] . "&is_faq=" . $params['faq']; if (isset($options['item_itemtype']) && isset($options['item_items_id'])) { $parameters .= "&item_items_id=" . $options['item_items_id'] . "&item_itemtype=" . $options['item_itemtype']; } if ($output_type == Search::HTML_OUTPUT) { Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } $nbcols = 1; // Display List Header echo Search::showHeader($output_type, $numrows_limit + 1, $nbcols); echo Search::showNewLine($output_type); $header_num = 1; echo Search::showHeaderItem($output_type, __('Subject'), $header_num); if ($output_type != Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, __('Content'), $header_num); } if ($showwriter) { echo Search::showHeaderItem($output_type, __('Writer'), $header_num); } echo Search::showHeaderItem($output_type, __('Category'), $header_num); if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) { echo Search::showHeaderItem($output_type, ' ', $header_num); } // Num of the row (1=header_line) $row_num = 1; for ($i = 0; $i < $numrows_limit; $i++) { $data = $DB->fetch_assoc($result_limit); Session::addToNavigateListItems('KnowbaseItem', $data["id"]); // Column num $item_num = 1; $row_num++; echo Search::showNewLine($output_type, $i % 2); $item = new self(); $item->getFromDB($data["id"]); $name = $data["name"]; $answer = $data["answer"]; // Manage translations if (isset($data['transname']) && !empty($data['transname'])) { $name = $data["transname"]; } if (isset($data['transanswer']) && !empty($data['transanswer'])) { $answer = $data["transanswer"]; } if ($output_type == Search::HTML_OUTPUT) { $toadd = ''; if (isset($options['item_itemtype']) && isset($options['item_items_id'])) { $href = " href='#' onClick=\"" . Html::jsGetElementbyID('kbshow' . $data["id"]) . ".dialog('open');\""; $toadd = Ajax::createIframeModalWindow('kbshow' . $data["id"], $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?id=" . $data["id"], array('display' => false)); } else { $href = " href=\"" . $CFG_GLPI['root_doc'] . "/front/knowbaseitem.form.php?id=" . $data["id"] . "\" "; } echo Search::showItem($output_type, "<div class='kb'>{$toadd}<a " . ($data['is_faq'] ? " class='pubfaq' title='" . __("This item is part of the FAQ") . "' " : " class='knowbase' ") . " {$href}>" . Html::resume_text($name, 80) . "</a></div>\n <div class='kb_resume'>" . Html::resume_text(Html::clean(Toolbox::unclean_cross_side_scripting_deep($answer)), 600) . "</div>", $item_num, $row_num); } else { echo Search::showItem($output_type, $name, $item_num, $row_num); echo Search::showItem($output_type, Html::clean(Toolbox::unclean_cross_side_scripting_deep(html_entity_decode($answer, ENT_QUOTES, "UTF-8"))), $item_num, $row_num); } $showuserlink = 0; if (Session::haveRight('user', READ)) { $showuserlink = 1; } if ($showwriter) { echo Search::showItem($output_type, getUserName($data["users_id"], $showuserlink), $item_num, $row_num); } $categ = $data["category"]; if ($output_type == Search::HTML_OUTPUT) { $cathref = $ki->getSearchURL() . "?knowbaseitemcategories_id=" . $data["knowbaseitemcategories_id"] . '&forcetab=Knowbase$2'; $categ = "<a href='{$cathref}'>" . $categ . '</a>'; } echo Search::showItem($output_type, $categ, $item_num, $row_num); if (isset($options['item_itemtype']) && isset($options['item_items_id']) && $output_type == Search::HTML_OUTPUT) { $forcetab = $options['item_itemtype']; if (!$_SESSION['glpiticket_timeline'] || $_SESSION['glpiticket_timeline_keep_replaced_tabs']) { $forcetab .= '$2'; //Solution tab } else { $forcetab .= '$1'; //Timeline tab } $content = "<a href='" . Toolbox::getItemTypeFormURL($options['item_itemtype']) . "?load_kb_sol=" . $data['id'] . "&id=" . $options['item_items_id'] . "&forcetab=" . $forcetab . "'>" . __('Use as a solution') . "</a>"; echo Search::showItem($output_type, $content, $item_num, $row_num); } // End Line echo Search::showEndLine($output_type); } // Display footer if ($output_type == Search::PDF_OUTPUT_LANDSCAPE || $output_type == Search::PDF_OUTPUT_PORTRAIT) { echo Search::showFooter($output_type, Dropdown::getDropdownName("glpi_knowbaseitemcategories", $params['knowbaseitemcategories_id'])); } else { echo Search::showFooter($output_type); } echo "<br>"; if ($output_type == Search::HTML_OUTPUT) { Html::printPager($params['start'], $numrows, Toolbox::getItemTypeSearchURL('KnowbaseItem'), $parameters, 'KnowbaseItem'); } } else { echo "<div class='center b'>" . __('No item found') . "</div>"; } } }
/** form for Task * * @param $ID Integer : Id of the task * @param $options array * - parent Object : the object **/ function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; $rand_template = mt_rand(); $rand_text = mt_rand(); $rand_type = mt_rand(); $rand_time = mt_rand(); if (isset($options['parent']) && !empty($options['parent'])) { $item = $options['parent']; } $fkfield = $item->getForeignKeyField(); if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[$fkfield] = $item->getField('id'); $this->check(-1, CREATE, $options); } $rand = mt_rand(); $this->showFormHeader($options); $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED); $rowspan = 5; if ($this->maybePrivate()) { $rowspan++; } if (isset($this->fields["state"])) { $rowspan++; } echo "<tr class='tab_bg_1'>"; echo "<td rowspan='{$rowspan}' style='width:100px'>" . __('Description') . "</td>"; echo "<td rowspan='{$rowspan}' style='width:50%' id='content{$rand_text}'>" . "<textarea name='content' style='width: 95%; height: 160px' id='task{$rand_text}'>" . $this->fields["content"] . "</textarea>"; echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });"); echo "</td>"; echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td style='width:100px'>" . _n('Task template', 'Task templates', 1) . "</td><td>"; TaskTemplate::dropdown(array('value' => 0, 'entity' => $this->getEntityID(), 'rand' => $rand_template, 'on_change' => 'tasktemplate_update(this.value)')); echo "</td>"; echo "</tr>"; echo Html::scriptBlock(' function tasktemplate_update(value) { jQuery.ajax({ url: "' . $CFG_GLPI["root_doc"] . '/ajax/task.php", type: "POST", data: { tasktemplates_id: value } }).done(function(datas) { datas.taskcategories_id = isNaN(parseInt(datas.taskcategories_id)) ? 0 : parseInt(datas.taskcategories_id); datas.actiontime = isNaN(parseInt(datas.actiontime)) ? 0 : parseInt(datas.actiontime); $("#task' . $rand_text . '").html(datas.content); $("#dropdown_taskcategories_id' . $rand_type . '").select2("val", parseInt(datas.taskcategories_id)); $("#dropdown_actiontime' . $rand_time . '").select2("val", parseInt(datas.actiontime)); }); } '); if ($ID > 0) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Date') . "</td>"; echo "<td>"; Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false)); echo "</tr>"; } else { echo "<tr class='tab_bg_1'>"; echo "<td colspan='2'> "; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Category') . "</td><td>"; TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'rand' => $rand_type, 'entity' => $item->fields["entities_id"], 'condition' => "`is_active` = '1'")); echo "</td></tr>\n"; if (isset($this->fields["state"])) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Status') . "</td><td>"; Planning::dropdownState("state", $this->fields["state"]); echo "</td></tr>\n"; } if ($this->maybePrivate()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Private') . "</td>"; echo "<td>"; Dropdown::showYesNo('is_private', $this->fields["is_private"]); echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Duration') . "</td><td>"; $toadd = array(); for ($i = 9; $i <= 100; $i++) { $toadd[] = $i * HOUR_TIMESTAMP; } Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'rand' => $rand_time, 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd)); echo "</td></tr>\n"; if ($ID <= 0) { Document_Item::showSimpleAddForItem($item); } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('By') . "</td>"; echo "<td colspan='2'>"; echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . " "; echo _n('User', 'Users', 1); $rand_user = mt_rand(); $params = array('name' => "users_id_tech", 'value' => $ID > -1 ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"], 'width' => ''); $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php"); User::dropdown($params); echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">"; echo " <img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n class='calendrier'>"; echo "</a>"; Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability'))); echo "<br />"; echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . " "; echo _n('Group', 'Groups', 1) . " "; $rand_group = mt_rand(); $params = array('name' => "groups_id_tech", 'value' => $ID > -1 ? $this->fields["groups_id_tech"] : Dropdown::EMPTY_VALUE, 'condition' => "is_task", 'rand' => $rand_group, 'entity' => $item->fields["entities_id"]); $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "group_available{$rand_group}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php"); Group::dropdown($params); echo "</td>\n"; echo "<td>"; if ($canplan) { echo __('Planning'); } if (!empty($this->fields["begin"])) { if (Session::haveRight('planning', Planning::READMY)) { echo "<script type='text/javascript' >\n"; echo "function showPlan" . $ID . $rand_text . "() {\n"; echo Html::jsHide("plan{$rand_text}"); $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'groups_id' => $this->fields["groups_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; echo "<div id='plan{$rand_text}' onClick='showPlan" . $ID . $rand_text . "()'>\n"; echo "<span class='showplan'>"; } if (isset($this->fields["state"])) { echo Planning::getState($this->fields["state"]) . "<br>"; } printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); if (isset($this->fields["users_id_tech"]) && $this->fields["users_id_tech"] > 0) { echo "<br>" . getUserName($this->fields["users_id_tech"]); } if (isset($this->fields["groups_id_tech"]) && $this->fields["groups_id_tech"] > 0) { echo "<br>" . Dropdown::getDropdownName('glpi_groups', $this->fields["groups_id_tech"]); } if (Session::haveRight('planning', Planning::READMY)) { echo "</span>"; echo "</div>\n"; echo "<div id='viewplan{$rand_text}'></div>\n"; } } else { if ($canplan) { echo "<script type='text/javascript' >\n"; echo "function showPlanUpdate{$rand_text}() {\n"; echo Html::jsHide("plan{$rand_text}"); $params = array('action' => 'add_event_classic_form', 'form' => 'followups', 'entity' => $item->fields['entities_id'], 'rand_user' => $rand_user, 'rand_group' => $rand_group, 'itemtype' => $this->getType(), 'items_id' => $this->getID()); Ajax::updateItemJsCode("viewplan{$rand_text}", $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "};"; echo "</script>"; if ($canplan) { echo "<div id='plan{$rand_text}' onClick='showPlanUpdate{$rand_text}()'>\n"; echo "<span class='vsubmit'>" . __('Plan this task') . "</span>"; echo "</div>\n"; echo "<div id='viewplan{$rand_text}'></div>\n"; } } else { _e('None'); } } echo "</td></tr>"; if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) { echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>"; PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID())); echo "</td><td colspan='2'></td></tr>"; } $this->showFormButtons($options); return true; }
/** form for rule criteria * * @since version 0.85 * * @param $ID integer Id of the criteria * @param $options array of possible options: * - rule Object : the rule **/ function showForm($ID, $options = array()) { global $CFG_GLPI; // Yllen: you always have parent for criteria $rule = $options['parent']; if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[static::$items_id] = $rule->getField('id'); //force itemtype of parent static::$itemtype = get_class($rule); $this->check(-1, CREATE, $options); } $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td class='center'>" . _n('Criterion', 'Criteria', 1) . "</td><td colspan='3'>"; echo "<input type='hidden' name='" . $rule->getRuleIdField() . "' value='" . $this->fields[$rule->getRuleIdField()] . "'>"; $rand = $rule->dropdownCriteria(array('value' => $this->fields['criteria'])); $params = array('criteria' => '__VALUE__', 'rand' => $rand, 'sub_type' => $rule->getType()); Ajax::updateItemOnSelectEvent("dropdown_criteria{$rand}", "criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params); if (isset($this->fields['criteria']) && !empty($this->fields['criteria'])) { $params['criteria'] = $this->fields['criteria']; $params['condition'] = $this->fields['condition']; $params['pattern'] = $this->fields['pattern']; echo "<script type='text/javascript' >\n"; Ajax::updateItemJsCode("criteria_span", $CFG_GLPI["root_doc"] . "/ajax/rulecriteria.php", $params); echo '</script>'; } if ($rule->specific_parameters) { $itemtype = get_class($rule) . 'Parameter'; echo "<img alt='' title=\"" . __s('Add a criterion') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('addcriterion' . $rand) . ".dialog('open');\">"; Ajax::createIframeModalWindow('addcriterion' . $rand, Toolbox::getItemTypeFormURL($itemtype), array('reloadonclose' => true)); } echo "</td></tr>"; echo "<tr><td colspan='4'><span id='criteria_span'>\n"; echo "</span></td></tr>\n"; $this->showFormButtons($options); }
/** * @since version 0.85 **/ static function showAvailableTypesLink() { global $CFG_GLPI; echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('documenttypelist') . ".dialog('open');\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/info-small.png' title=\"" . __s('Help') . "\"\n alt=\"" . __s('Help') . "\" class='calendrier pointer'>"; echo "</a>"; Ajax::createIframeModalWindow('documenttypelist', $CFG_GLPI["root_doc"] . "/front/documenttype.list.php", array('title' => static::getTypeName(Session::getPluralNumber()))); }
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. GLPI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GLPI. If not, see <http://www.gnu.org/licenses/>. -------------------------------------------------------------------------- */ /** @file * @brief * @since version 0.83 */ // Direct access to file if (strpos($_SERVER['PHP_SELF'], "planningcheck.php")) { $AJAX_INCLUDE = 1; include '../inc/includes.php'; header("Content-Type: text/html; charset=UTF-8"); Html::header_nocache(); } Session::checkLoginUser(); if (isset($_POST['users_id']) && $_POST['users_id'] > 0) { $rand = mt_rand(); echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n class='calendrier'>"; echo "</a>"; Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=User&users_id=" . $_POST['users_id'], array('title' => __('Availability'))); }
/** * Make a select box with all glpi users where select key = name * * @param $options array of possible options: * - name : string / name of the select (default is users_id) * - value * - right : string / limit user who have specific right : * id -> only current user (default case); * interface -> central ; * all -> all users ; * specific right like Ticket::READALL, CREATE.... (is array passed one of all passed right is needed) * - comments : boolean / is the comments displayed near the dropdown (default true) * - entity : integer or array / restrict to a defined entity or array of entities * (default -1 : no restriction) * - entity_sons : boolean / if entity restrict specified auto select its sons * only available if entity is a single value not an array(default false) * - all : Nobody or All display for none selected * all=0 (default) -> Nobody * all=1 -> All * all=-1-> nothing * - rand : integer / already computed rand value * - toupdate : array / Update a specific item on select change on dropdown * (need value_fieldname, to_update, url * (see Ajax::updateItemOnSelectEvent for information) * and may have moreparams) * - used : array / Already used items ID: not to display in dropdown (default empty) * - ldap_import * - on_change : string / value to transmit to "onChange" * - display : boolean / display or get string (default true) * - width : specific width needed (default 80%) * - specific_tags : array of HTML5 tags to add the the field * - url : url of the ajax php code which should return the json data to show in * the dropdown (default /ajax/getDropdownUsers.php) * * @return rand value if displayed / string if not **/ static function dropdown($options = array()) { global $DB, $CFG_GLPI; // Default values $p['name'] = 'users_id'; $p['value'] = ''; $p['right'] = 'id'; $p['all'] = 0; $p['on_change'] = ''; $p['comments'] = 1; $p['width'] = '80%'; $p['entity'] = -1; $p['entity_sons'] = false; $p['used'] = array(); $p['ldap_import'] = false; $p['toupdate'] = ''; $p['rand'] = mt_rand(); $p['display'] = true; $p['_user_index'] = 0; $p['specific_tags'] = array(); $p['url'] = $CFG_GLPI['root_doc'] . "/ajax/getDropdownUsers.php"; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $p[$key] = $val; } } // check default value (in case of multiple observers) if (is_array($p['value'])) { $p['value'] = $p['value'][$p['_user_index']]; } // Check default value for dropdown : need to be a numeric if (strlen($p['value']) == 0 || !is_numeric($p['value'])) { $p['value'] = 0; } $output = ''; if (!($p['entity'] < 0) && $p['entity_sons']) { if (is_array($p['entity'])) { $output .= "entity_sons options is not available with array of entity"; } else { $p['entity'] = getSonsOf('glpi_entities', $p['entity']); } } // Make a select box with all glpi users $user = getUserName($p['value'], 2); $view_users = self::canView(); if (!empty($p['value']) && $p['value'] > 0) { $default = $user["name"]; } else { if ($p['all']) { $default = __('All'); } else { $default = Dropdown::EMPTY_VALUE; } } $field_id = Html::cleanId("dropdown_" . $p['name'] . $p['rand']); $param = array('value' => $p['value'], 'valuename' => $default, 'width' => $p['width'], 'all' => $p['all'], 'right' => $p['right'], 'on_change' => $p['on_change'], 'used' => $p['used'], 'entity_restrict' => $p['entity'], 'specific_tags' => $p['specific_tags']); $output = Html::jsAjaxDropdown($p['name'], $field_id, $p['url'], $param); // Display comment if ($p['comments']) { $comment_id = Html::cleanId("comment_" . $p['name'] . $p['rand']); $link_id = Html::cleanId("comment_link_" . $p["name"] . $p['rand']); if (!$view_users) { $user["link"] = ''; } else { if (empty($user["link"])) { $user["link"] = $CFG_GLPI['root_doc'] . "/front/user.php"; } } $output .= " " . Html::showToolTip($user["comment"], array('contentid' => $comment_id, 'display' => false, 'link' => $user["link"], 'linkid' => $link_id)); $paramscomment = array('value' => '__VALUE__', 'table' => "glpi_users"); if ($view_users) { $paramscomment['withlink'] = $link_id; } $output .= Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false); } $output .= Ajax::commonDropdownUpdateItem($p, false); if (Session::haveRight('user', self::IMPORTEXTAUTHUSERS) && $p['ldap_import'] && Entity::isEntityDirectoryConfigured($_SESSION['glpiactive_entity'])) { $output .= "<img alt='' title=\"" . __s('Import a user') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('userimport' . $p['rand']) . ".dialog('open');\">"; $output .= Ajax::createIframeModalWindow('userimport' . $p['rand'], $CFG_GLPI["root_doc"] . "/front/ldap.import.php?entity=" . $_SESSION['glpiactive_entity'], array('title' => __('Import a user'), 'display' => false)); } if ($p['display']) { echo $output; return $p['rand']; } return $output; }
/** * Print out an HTML "<select>" for a dropdown with preselected value * * @param $itemtype itemtype used for create dropdown * @param $options array of possible options: * - name : string / name of the select (default is depending itemtype) * - value : integer / preselected value (default -1) * - comments : boolean / is the comments displayed near the dropdown (default true) * - toadd : array / array of specific values to add at the begining * - entity : integer or array / restrict to a defined entity or array of entities * (default -1 : no restriction) * - entity_sons : boolean / if entity restrict specified auto select its sons * only available if entity is a single value not an array * (default false) * - toupdate : array / Update a specific item on select change on dropdown * (need value_fieldname, to_update, * url (see Ajax::updateItemOnSelectEvent for information) * and may have moreparams) * - used : array / Already used items ID: not to display in dropdown * (default empty) * - on_change : string / value to transmit to "onChange" * - rand : integer / already computed rand value * - condition : string / aditional SQL condition to limit display * - displaywith : array / array of field to display with request * - emptylabel : Empty choice's label (default self::EMPTY_VALUE) * - display_emptychoice : Display emptychoice ? (default true) * - display : boolean / display or get string (default true) * - width : specific width needed (default auto adaptive) * - permit_select_parent : boolean / for tree dropdown permit to see parent items * not available by default (default false) * - specific_tags : array of HTML5 tags to add the the field * - url : url of the ajax php code which should return the json data to show in * the dropdown * * @return boolean : false if error and random id if OK **/ static function show($itemtype, $options = array()) { global $DB, $CFG_GLPI; if ($itemtype && !($item = getItemForItemtype($itemtype))) { return false; } $table = $item->getTable(); $params['name'] = $item->getForeignKeyField(); $params['value'] = $itemtype == 'Entity' ? $_SESSION['glpiactive_entity'] : ''; $params['comments'] = true; $params['entity'] = -1; $params['entity_sons'] = false; $params['toupdate'] = ''; $params['width'] = ''; $params['used'] = array(); $params['toadd'] = array(); $params['on_change'] = ''; $params['condition'] = ''; $params['rand'] = mt_rand(); $params['displaywith'] = array(); //Parameters about choice 0 //Empty choice's label $params['emptylabel'] = self::EMPTY_VALUE; //Display emptychoice ? $params['display_emptychoice'] = $itemtype != 'Entity'; $params['display'] = true; $params['permit_select_parent'] = false; $params['addicon'] = true; $params['specific_tags'] = array(); $params['url'] = $CFG_GLPI['root_doc'] . "/ajax/getDropdownValue.php"; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $params[$key] = $val; } } $output = ''; $name = $params['emptylabel']; $comment = ""; // Check default value for dropdown : need to be a numeric if (strlen($params['value']) == 0 || !is_numeric($params['value']) && $params['value'] != 'mygroups') { $params['value'] = 0; } if (isset($params['toadd'][$params['value']])) { $name = $params['toadd'][$params['value']]; } else { if ($params['value'] > 0 || $itemtype == "Entity" && $params['value'] >= 0) { $tmpname = self::getDropdownName($table, $params['value'], 1); if ($tmpname["name"] != " ") { $name = $tmpname["name"]; $comment = $tmpname["comment"]; } } } // Manage entity_sons if (!($params['entity'] < 0) && $params['entity_sons']) { if (is_array($params['entity'])) { // translation not needed - only for debug $output .= "entity_sons options is not available with entity option as array"; } else { $params['entity'] = getSonsOf('glpi_entities', $params['entity']); } } $field_id = Html::cleanId("dropdown_" . $params['name'] . $params['rand']); // Manage condition if (!empty($params['condition'])) { $params['condition'] = static::addNewCondition($params['condition']); } if (!$item instanceof CommonTreeDropdown) { $name = Toolbox::unclean_cross_side_scripting_deep($name); } $p = array('value' => $params['value'], 'valuename' => $name, 'width' => $params['width'], 'itemtype' => $itemtype, 'display_emptychoice' => $params['display_emptychoice'], 'displaywith' => $params['displaywith'], 'emptylabel' => $params['emptylabel'], 'condition' => $params['condition'], 'used' => $params['used'], 'toadd' => $params['toadd'], 'entity_restrict' => is_array($params['entity']) ? json_encode(array_values($params['entity'])) : $params['entity'], 'on_change' => $params['on_change'], 'permit_select_parent' => $params['permit_select_parent'], 'specific_tags' => $params['specific_tags']); $output = "<span class='no-wrap'>"; $output .= Html::jsAjaxDropdown($params['name'], $field_id, $params['url'], $p); // Display comment if ($params['comments']) { $comment_id = Html::cleanId("comment_" . $params['name'] . $params['rand']); $link_id = Html::cleanId("comment_link_" . $params['name'] . $params['rand']); $options_tooltip = array('contentid' => $comment_id, 'linkid' => $link_id, 'display' => false); if ($item->canView()) { if ($params['value'] && $item->getFromDB($params['value']) && $item->canViewItem()) { $options_tooltip['link'] = $item->getLinkURL(); } else { $options_tooltip['link'] = $item->getSearchURL(); } $options_tooltip['linktarget'] = '_blank'; } $output .= " " . Html::showToolTip($comment, $options_tooltip); if ($item instanceof CommonDropdown && $item->canCreate() && !isset($_REQUEST['_in_modal']) && $params['addicon']) { $output .= "<img alt='' title=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n onClick=\"" . Html::jsGetElementbyID('add_dropdown' . $params['rand']) . ".dialog('open');\">"; $output .= Ajax::createIframeModalWindow('add_dropdown' . $params['rand'], $item->getFormURL(), array('display' => false)); } // Display specific Links if ($itemtype == "Supplier") { if ($item->getFromDB($params['value'])) { $output .= $item->getLinks(); } } if ($itemtype == 'ITILCategory' && Session::haveRight('knowbase', READ)) { if ($params['value'] && $item->getFromDB($params['value'])) { $output .= ' ' . $item->getLinks(); } } $paramscomment = array('value' => '__VALUE__', 'table' => $table); if ($item->canView()) { $paramscomment['withlink'] = $link_id; } $output .= Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false); } $output .= Ajax::commonDropdownUpdateItem($params, false); if ($params['display']) { echo $output; return $params['rand']; } $output .= "</span>"; return $output; }
/** * Display bookmark buttons * * @param $type bookmark type to use * @param $itemtype device type of item where is the bookmark (default 0) **/ static function showSaveButton($type, $itemtype = 0) { global $CFG_GLPI; echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('bookmarksave') . ".dialog('open');\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/bookmark_record.png'\n title=\"" . __s('Save as bookmark') . "\" alt=\"" . __s('Save as bookmark') . "\"\n class='calendrier pointer'>"; echo "</a>"; Ajax::createIframeModalWindow('bookmarksave', $CFG_GLPI["root_doc"] . "/front/bookmark.php?type={$type}" . "&action=edit&itemtype={$itemtype}&" . "url=" . rawurlencode($_SERVER["REQUEST_URI"]), array('title' => __('Save as bookmark'), 'reloadonclose' => true)); }
/** * Show the list of rules * * @param $target * @param $options array * * @return nothing **/ function showListRules($target, $options = array()) { global $CFG_GLPI; $p['inherited'] = 1; $p['childrens'] = 0; $p['active'] = false; $p['condition'] = 0; $rand = mt_rand(); foreach (array('inherited', 'childrens', 'condition') as $param) { if (isset($options[$param]) && $this->isRuleRecursive()) { $p[$param] = $options[$param]; } } $rule = $this->getRuleClass(); $display_entities = $this->isRuleRecursive() && ($p['inherited'] || $p['childrens']); // Do not know what it is ? $canedit = self::canUpdate() && !$display_entities; $use_conditions = false; if ($rule->useConditions()) { // First get saved option $p['condition'] = Session::getSavedOption($this->getType(), 'condition', 0); if ($p['condition'] == 0) { $p['condition'] = $this->getDefaultRuleConditionForList(); } $use_conditions = true; // Mini Search engine echo "<table class='tab_cadre_fixe'>"; echo "<tr class='tab_bg_1'><td class='center' width='50%'>"; echo __('Rules used for') . "</td><td>"; $rule->dropdownConditions(array('value' => $p['condition'], 'on_change' => 'reloadTab("start=0&inherited=' . $p['inherited'] . '&childrens=' . $p['childrens'] . '&condition="+this.value)')); echo "</td></tr></table>"; } $nb = $this->getCollectionSize($p['inherited'], $p['condition']); $p['start'] = isset($options["start"]) ? $options["start"] : 0; if ($p['start'] >= $nb) { $p['start'] = 0; } $p['limit'] = $_SESSION['glpilist_limit']; $this->getCollectionPart($p); Html::printAjaxPager('', $p['start'], $nb); Html::openMassiveActionsForm('mass' . __CLASS__ . $rand); echo "\n<div class='spaced'>"; if ($canedit && $nb) { $massiveactionparams = array('num_displayed' => min($p['limit'], $nb), 'container' => 'mass' . __CLASS__ . $rand, 'extraparams' => array('entity' => $this->entity, 'condition' => $p['condition'], 'rule_class_name' => $this->getRuleClassName())); Html::showMassiveActions($massiveactionparams); } echo "<table class='tab_cadre_fixehov table-striped table-hover'>"; $colspan = 6; if ($display_entities) { $colspan++; } if ($use_conditions) { $colspan++; } echo "<tr><th colspan='{$colspan}'>" . $this->getTitle() . "</th></tr>\n"; echo "<tr>"; echo "<th>"; if ($canedit) { Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); } echo "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Description') . "</th>"; if ($use_conditions) { echo "<th>" . __('Use rule for') . "</th>"; } echo "<th>" . __('Active') . "</th>"; if ($display_entities) { echo "<th>" . __('Entity') . "</th>\n"; } if (!$display_entities) { echo "<th colspan='2'> </th>"; } echo "</tr>\n"; if (count($this->RuleList->list)) { $ruletype = $this->RuleList->list[0]->getType(); Session::initNavigateListItems($ruletype); } for ($i = $p['start'], $j = 0; isset($this->RuleList->list[$j]); $i++, $j++) { $this->RuleList->list[$j]->showMinimalForm($target, $i == 0, $i == $nb - 1, $display_entities, $p['condition']); Session::addToNavigateListItems($ruletype, $this->RuleList->list[$j]->fields['id']); } if ($nb) { echo "<tr>"; echo "<th>"; if ($canedit) { Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand); } echo "</th>"; echo "<th>" . __('Name') . "</th>"; echo "<th>" . __('Description') . "</th>"; if ($use_conditions) { echo "<th>" . __('Use rule for') . "</th>"; } echo "<th>" . __('Active') . "</th>"; if ($display_entities) { echo "<th>" . __('Entity') . "</th>\n"; } if (!$display_entities) { echo "<th colspan='2'> </th>"; } echo "</tr>\n"; } echo "</table>\n"; if ($canedit && $nb) { $massiveactionparams['ontop'] = false; Html::showMassiveActions($massiveactionparams); } echo "</div>"; Html::closeForm(); Html::printAjaxPager('', $p['start'], $nb); echo "<div class='spaced center'>"; if ($plugin = isPluginItemType($this->getType())) { $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']); } else { $url = $CFG_GLPI["root_doc"]; } echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID('allruletest' . $rand) . ".dialog('open');\">" . __('Test rules engine') . "</a>"; Ajax::createIframeModalWindow('allruletest' . $rand, $url . "/front/rulesengine.test.php?" . "sub_type=" . $this->getRuleClassName() . "&condition=" . $p['condition'], array('title' => __('Test rules engine'))); echo "</div>"; if ($this->can_replay_rules) { echo "<div class='spaced center'>"; echo "<a class='vsubmit' href='" . $rule->getSearchURL() . "?replay_rule=replay_rule'>" . __s('Replay the dictionary rules') . "</a>"; echo "</div>"; } echo "<div class='spaced'>"; $this->showAdditionalInformationsInForm($target); echo "</div>"; }
/** * @param $type * @param $items_id **/ static function displayItemLogID($type, $items_id) { global $CFG_GLPI; if ($items_id == "-1" || $items_id == "0") { echo " "; //$item; } else { switch ($type) { case "rules": echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/rule.generic.form.php?id=" . $items_id . "\">" . $items_id . "</a>"; break; case "infocom": $rand = mt_rand(); echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('infocom' . $rand) . ".\n dialog('open');\">{$items_id}</a>"; Ajax::createIframeModalWindow('infocom' . $rand, $CFG_GLPI["root_doc"] . "/front/infocom.form.php" . "?id=" . $items_id, array('height' => 600)); case "devices": echo $items_id; break; case "reservationitem": echo "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/reservation.php?reservationitems_id=" . $items_id . "\">" . $items_id . "</a>"; break; default: $type = getSingular($type); $url = ''; if ($item = getItemForItemtype($type)) { $url = $item->getFormURL(); } if (!empty($url)) { echo "<a href=\"" . $url . "?id=" . $items_id . "\">" . $items_id . "</a>"; } else { echo $items_id; } break; } } }
function getWidgetContentForItem($widgetId) { global $CFG_GLPI, $DB; if (empty($this->form)) { $this->init(); } switch ($widgetId) { case $this->getType() . "1": $plugin = new Plugin(); if ($plugin->isActivated("tasklists")) { $widget = new PluginMydashboardDatatable(); $headers = array(__('Name'), __('Priority'), _n('Context', 'Contexts', 1, 'tasklists'), __('User'), __('Percent done'), __('Due date'), __('Action')); $query = "SELECT `glpi_plugin_tasklists_tasks`.*,`glpi_plugin_tasklists_tasktypes`.`completename` as 'type' \n FROM `glpi_plugin_tasklists_tasks`\n LEFT JOIN `glpi_plugin_tasklists_tasktypes` ON (`glpi_plugin_tasklists_tasks`.`plugin_tasklists_tasktypes_id` = `glpi_plugin_tasklists_tasktypes`.`id`) \n WHERE NOT `glpi_plugin_tasklists_tasks`.`is_deleted`\n AND `glpi_plugin_tasklists_tasks`.`state` < 2 "; $query .= getEntitiesRestrictRequest('AND', 'glpi_plugin_tasklists_tasks'); $query .= "ORDER BY `glpi_plugin_tasklists_tasks`.`priority`DESC "; $tasks = array(); if ($result = $DB->query($query)) { if ($DB->numrows($result)) { while ($data = $DB->fetch_array($result)) { //$groups = Group_User::getGroupUsers($data['groups_id']); $groupusers = Group_User::getGroupUsers($data['groups_id']); $groups = array(); foreach ($groupusers as $groupuser) { $groups[] = $groupuser["id"]; } if ($data['visibility'] == 1 && $data['users_id'] == Session::getLoginUserID() || $data['visibility'] == 2 && ($data['users_id'] == Session::getLoginUserID() || in_array(Session::getLoginUserID(), $groups)) || $data['visibility'] == 3) { $ID = $data['id']; $rand = mt_rand(); $url = Toolbox::getItemTypeFormURL("PluginTasklistsTask") . "?id=" . $data['id']; $tasks[$data['id']][0] = "<a id='task" . $data["id"] . $rand . "' target='_blank' href='{$url}'>" . $data['name'] . "</a>"; $tasks[$data['id']][0] .= Html::showToolTip($data['comment'], array('applyto' => 'task' . $data["id"] . $rand, 'display' => false)); $bgcolor = $_SESSION["glpipriority_" . $data['priority']]; $tasks[$data['id']][1] = "<div class='center' style='background-color:{$bgcolor};'>" . CommonITILObject::getPriorityName($data['priority']) . "</div>"; $tasks[$data['id']][2] = $data['type']; $tasks[$data['id']][3] = getUserName($data['users_id']); $tasks[$data['id']][4] = Dropdown::getValueWithUnit($data['percent_done'], "%"); $due_date = $data['due_date']; $display = Html::convDate($data['due_date']); if ($due_date <= date('Y-m-d') && !empty($due_date)) { $display = "<div class='deleted'>" . Html::convDate($data['due_date']) . "</div>"; } $tasks[$data['id']][5] = $display; $tasks[$data['id']][6] = "<div align='center'>"; if (Session::haveRight("plugin_tasklists", UPDATE)) { $tasks[$data['id']][6] .= "<a class='pointer' onclick=\" submitGetLink('" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/front/task.form.php', {'done': 'done', 'id': '" . $data['id'] . "', '_glpi_csrf_token': '" . Session::getNewCSRFToken() . "', '_glpi_simple_form': '1'});\"><img src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/ok.png' title='" . __('Mark as done', 'tasklists') . "'></a>"; } if (Session::haveRight("plugin_tasklists", UPDATENOTE)) { $link = " <a href=\"javascript:" . Html::jsGetElementbyID('comment' . $rand) . ".dialog('open');\">"; $link .= "<img class='pointer' src='" . $CFG_GLPI['root_doc'] . "/plugins/tasklists/pics/plus.png' title='" . __('Add comment', 'tasklists') . "'>"; $link .= "</a>"; $link .= Ajax::createIframeModalWindow('comment' . $rand, $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/comment.form.php?id=" . $ID, array('title' => __('Add comment', 'tasklists'), 'reloadonclose' => false, 'width' => 1100, 'display' => false, 'height' => 300)); $tasks[$data['id']][6] .= $link; } $tasks[$data['id']][6] .= "</div>"; } } } } $widget->setTabDatas($tasks); $widget->setTabNames($headers); $widget->setOption("bSort", false); $widget->toggleWidgetRefresh(); $link = "<div align='right'><a class='vsubmit' href=\"javascript:" . Html::jsGetElementbyID('task') . ".dialog('open');\">"; $link .= __('Add task', 'tasklists'); $link .= "</a></div>"; $link .= Ajax::createIframeModalWindow('task', $CFG_GLPI["root_doc"] . "/plugins/tasklists/front/task.form.php", array('title' => __('Add task', 'tasklists'), 'reloadonclose' => false, 'width' => 1180, 'display' => false, 'height' => 600)); $widget->appendWidgetHtmlContent($link); $widget->setWidgetTitle(__("Tasks list", 'tasklists')); return $widget; } else { $widget = new PluginMydashboardDatatable(); $widget->setWidgetTitle(__("Tasks list", 'tasklists')); return $widget; } break; } }
if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { Html::helpHeader(Ticket::getTypeName(Session::getPluralNumber()), '', $_SESSION["glpiname"]); } else { Html::header(Ticket::getTypeName(Session::getPluralNumber()), '', "helpdesk", "ticket"); } $available_options = array('load_kb_sol', '_openfollowup'); $options = array(); foreach ($available_options as $key) { if (isset($_GET[$key])) { $options[$key] = $_GET[$key]; } } $options['id'] = $_GET["id"]; $track->display($options); if (isset($_GET['_sol_to_kb'])) { Ajax::createIframeModalWindow('savetokb', $CFG_GLPI["root_doc"] . "/front/knowbaseitem.form.php?_in_modal=1&item_itemtype=Ticket&item_items_id=" . $_GET["id"], array('title' => __('Save solution to the knowledge base'), 'reloadonclose' => false)); echo Html::scriptBlock(Html::jsGetElementbyID('savetokb') . ".dialog('open');"); } } else { Html::header(__('New ticket'), '', "helpdesk", "ticket"); unset($_REQUEST['id']); // Add a ticket from item : format data if (isset($_REQUEST['_add_fromitem'])) { $_REQUEST['items_id'] = array($_REQUEST['itemtype'] => array($_REQUEST['items_id'])); } $track->display($_REQUEST); } if ($_SESSION["glpiactiveprofile"]["interface"] == "helpdesk") { Html::helpFooter(); } else { Html::footer();
/** * Show infocom link to display modal * * @param $itemtype integer item type * @param $device_id integer item ID * * @return float **/ static function showDisplayLink($itemtype, $device_id) { global $DB, $CFG_GLPI; if (!Session::haveRight(self::$rightname, READ) || !($item = getItemForItemtype($itemtype))) { return false; } $query = "SELECT COUNT(*)\n FROM `glpi_infocoms`\n WHERE `items_id` = '{$device_id}'\n AND `itemtype` = '{$itemtype}'"; $add = "add"; $text = __('Add'); $result = $DB->query($query); if ($DB->result($result, 0, 0) > 0) { $add = ""; $text = _x('button', 'Show'); } else { if (!Infocom::canUpdate()) { return false; } } if ($item->canView()) { echo "<span onClick=\"" . Html::jsGetElementbyID('infocom' . $itemtype . $device_id) . ".\n dialog('open');\" style='cursor:pointer'>\n <img src=\"" . $CFG_GLPI["root_doc"] . "/pics/dollar{$add}.png\" alt=\"{$text}\" title=\"{$text}\">\n </span>"; Ajax::createIframeModalWindow('infocom' . $itemtype . $device_id, $CFG_GLPI["root_doc"] . "/front/infocom.form.php" . "?itemtype={$itemtype}&items_id={$device_id}", array('height' => 600)); } }
/** * Print out an HTML "<select>" for a dropdown with preselected value * * @param $myname the name of the HTML select * @param $value the preselected value we want (default 0) * @param $locations_id default location ID for search (default -1) * @param $display_comment display the comment near the dropdown (default 1) * @param $entity_restrict Restrict to a defined entity(default -1) * @param $devtype (default '') * * @return nothing (display the select box) **/ static function dropdownNetpoint($myname, $value = 0, $locations_id = -1, $display_comment = 1, $entity_restrict = -1, $devtype = '') { global $CFG_GLPI; $rand = mt_rand(); $name = Dropdown::EMPTY_VALUE; $comment = ""; if (empty($value)) { $value = 0; } if ($value > 0) { $tmpname = Dropdown::getDropdownName("glpi_netpoints", $value, 1); if ($tmpname["name"] != " ") { $name = $tmpname["name"]; $comment = $tmpname["comment"]; } } $field_id = Html::cleanId("dropdown_" . $myname . $rand); $param = array('value' => $value, 'valuename' => $name, 'entity_restrict' => $entity_restrict, 'devtype' => $devtype, 'locations_id' => $locations_id); echo Html::jsAjaxDropdown($myname, $field_id, $CFG_GLPI['root_doc'] . "/ajax/getDropdownNetpoint.php", $param); // Display comment if ($display_comment) { $comment_id = Html::cleanId("comment_" . $myname . $rand); Html::showToolTip($comment, array('contentid' => $comment_id)); $item = new self(); if ($item->canCreate()) { echo "<img alt='' title=\"" . __s('Add') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;' " . "onClick=\"" . Html::jsGetElementbyID('netpoint' . $rand) . ".dialog('open');\">"; Ajax::createIframeModalWindow('netpoint' . $rand, $item->getFormURL()); } $paramscomment = array('value' => '__VALUE__', 'table' => "glpi_netpoints"); echo Ajax::updateItemOnSelectEvent($field_id, $comment_id, $CFG_GLPI["root_doc"] . "/ajax/comments.php", $paramscomment, false); } return $rand; }
/** * Show the rule * * @param $ID ID of the rule * @param $options array of possible options: * - target filename : where to go when done. * - withtemplate boolean : template or basic item * * @return nothing **/ function showForm($ID, $options = array()) { global $CFG_GLPI; if (!$this->isNewID($ID)) { $this->check($ID, READ); } else { // Create item $this->checkGlobal(UPDATE); } $canedit = $this->canEdit(static::$rightname); $rand = mt_rand(); $this->showFormHeader($options); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td>"; echo "<td>" . __('Description') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "description"); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Logical operator') . "</td>"; echo "<td>"; $this->dropdownRulesMatch(array('value' => $this->fields["match"])); echo "</td>"; echo "<td>" . __('Active') . "</td>"; echo "<td>"; Dropdown::showYesNo("is_active", $this->fields["is_active"]); echo "</td></tr>\n"; if ($this->useConditions()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Use rule for') . "</td>"; echo "<td>"; $this->dropdownConditions(array('value' => $this->fields["condition"])); echo "</td>"; echo "<td colspan='2'>"; echo "</td></tr>\n"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Comments') . "</td>"; echo "<td class='middle' colspan='3'>"; echo "<textarea cols='110' rows='3' name='comment' >" . $this->fields["comment"] . "</textarea>"; if (!$this->isNewID($ID)) { if ($this->fields["date_mod"]) { echo "<br>"; printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"])); } } if ($canedit) { echo "<input type='hidden' name='ranking' value='" . $this->fields["ranking"] . "'>"; echo "<input type='hidden' name='sub_type' value='" . get_class($this) . "'>"; } echo "</td></tr>\n"; if ($canedit) { if ($ID > 0) { if ($plugin = isPluginItemType($this->getType())) { $url = $CFG_GLPI["root_doc"] . "/plugins/" . strtolower($plugin['plugin']); } else { $url = $CFG_GLPI["root_doc"]; } echo "<tr><td class='tab_bg_2 center' colspan='4'>"; echo "<a class='vsubmit' href='#' onClick=\"" . Html::jsGetElementbyID('ruletest' . $rand) . ".dialog('open');\">" . _x('button', 'Test') . "</a>"; Ajax::createIframeModalWindow('ruletest' . $rand, $url . "/front/rule.test.php?" . "sub_type=" . $this->getType() . "&rules_id=" . $this->fields["id"], array('title' => _x('button', 'Test'))); echo "</td></tr>\n"; } } $this->showFormButtons($options); return true; }
/** * Get link for display options * * @since version 0.84 * @param $sub_itemtype string sub itemtype if needed for display options * @return link **/ static function getDisplayOptionsLink($sub_itemtype = '') { global $CFG_GLPI; $rand = mt_rand(); $link = "<img alt=\"" . __s('Display options') . "\" title=\""; $link .= __s('Display options') . "\" src='"; $link .= $CFG_GLPI["root_doc"] . "/pics/options_search.png' "; $link .= " class='pointer' onClick=\"" . Html::jsGetElementbyID("displayoptions" . $rand) . ".dialog('open');\">"; $link .= Ajax::createIframeModalWindow("displayoptions" . $rand, $CFG_GLPI['root_doc'] . "/front/display.options.php?itemtype=" . static::getType() . "&sub_itemtype={$sub_itemtype}", array('display' => false, 'width' => 600, 'height' => 500, 'reloadonclose' => true)); return $link; }
/** form for Task * * @param $ID Integer : Id of the task * @param $options array * - parent Object : the object **/ function showForm($ID, $options = array()) { global $DB, $CFG_GLPI; if (isset($options['parent']) && !empty($options['parent'])) { $item = $options['parent']; } $fkfield = $item->getForeignKeyField(); if ($ID > 0) { $this->check($ID, READ); } else { // Create item $options[$fkfield] = $item->getField('id'); $this->check(-1, CREATE, $options); } $rand = mt_rand(); $this->showFormHeader($options); $canplan = !$item->isStatusExists(CommonITILObject::PLANNED) || $item->isAllowedStatus($item->fields['status'], CommonITILObject::PLANNED); $rowspan = 3; if ($this->maybePrivate()) { $rowspan++; } if (isset($this->fields["state"])) { $rowspan++; } echo "<tr class='tab_bg_1'>"; echo "<td rowspan='{$rowspan}' class='middle'>" . __('Description') . "</td>"; echo "<td class='center middle' rowspan='{$rowspan}'>" . "<textarea id ='content{$rand}' name='content' cols='50' rows='{$rowspan}'>" . $this->fields["content"] . "</textarea>"; echo Html::scriptBlock("\$(document).ready(function() { \$('#content{$rand}').autogrow(); });"); echo "</td>"; if ($ID > 0) { echo "<td>" . __('Date') . "</td>"; echo "<td>"; Html::showDateTimeField("date", array('value' => $this->fields["date"], 'timestep' => 1, 'maybeempty' => false)); } else { echo "<td colspan='2'> "; } echo "<input type='hidden' name='{$fkfield}' value='" . $this->fields[$fkfield] . "'>"; echo "</td></tr>\n"; echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Category') . "</td><td>"; TaskCategory::dropdown(array('value' => $this->fields["taskcategories_id"], 'entity' => $item->fields["entities_id"])); echo "</td></tr>\n"; if (isset($this->fields["state"])) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Status') . "</td><td>"; Planning::dropdownState("state", $this->fields["state"]); echo "</td></tr>\n"; } if ($this->maybePrivate()) { echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Private') . "</td>"; echo "<td>"; Dropdown::showYesNo('is_private', $this->fields["is_private"]); echo "</td>"; echo "</tr>"; } echo "<tr class='tab_bg_1'>"; echo "<td>" . __('Duration') . "</td><td>"; $toadd = array(); for ($i = 9; $i <= 100; $i++) { $toadd[] = $i * HOUR_TIMESTAMP; } Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 8 * HOUR_TIMESTAMP, 'value' => $this->fields["actiontime"], 'addfirstminutes' => true, 'inhours' => true, 'toadd' => $toadd)); echo "</td></tr>\n"; Document_Item::showSimpleAddForItem($item); echo "<tr class='tab_bg_1'>"; echo "<td>" . __('By'); echo " <a href='#' onClick=\"" . Html::jsGetElementbyID('planningcheck' . $rand) . ".dialog('open');\">"; echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/reservation-3.png'\n title=\"" . __s('Availability') . "\" alt=\"" . __s('Availability') . "\"\n class='calendrier'>"; echo "</a>"; Ajax::createIframeModalWindow('planningcheck' . $rand, $CFG_GLPI["root_doc"] . "/front/planning.php?checkavailability=checkavailability" . "&itemtype=" . $item->getType() . "&{$fkfield}=" . $item->getID(), array('title' => __('Availability'))); echo "</td>"; echo "<td class='center'>"; $rand_user = mt_rand(); $params = array('name' => "users_id_tech", 'value' => $this->fields["users_id_tech"] ? $this->fields["users_id_tech"] : Session::getLoginUserID(), 'right' => "own_ticket", 'rand' => $rand_user, 'entity' => $item->fields["entities_id"]); $params['toupdate'] = array('value_fieldname' => 'users_id', 'to_update' => "user_available{$rand_user}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/planningcheck.php"); User::dropdown($params); echo "</td>\n"; if ($canplan) { echo "<td>" . __('Planning') . "</td>"; } echo "<td>"; if (!empty($this->fields["begin"])) { if (Session::haveRight('planning', Planning::READMY)) { echo "<script type='text/javascript' >\n"; echo "function showPlan" . $ID . "() {\n"; echo Html::jsHide('plan'); $params = array('form' => 'followups', 'users_id' => $this->fields["users_id_tech"], 'id' => $this->fields["id"], 'begin' => $this->fields["begin"], 'end' => $this->fields["end"], 'rand_user' => $rand_user, 'entity' => $item->fields["entities_id"], 'itemtype' => $this->getType(), 'items_id' => $this->getID()); Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "}"; echo "</script>\n"; echo "<div id='plan' onClick='showPlan" . $ID . "()'>\n"; echo "<span class='showplan'>"; } if (isset($this->fields["state"])) { echo Planning::getState($this->fields["state"]) . "<br>"; } printf(__('From %1$s to %2$s'), Html::convDateTime($this->fields["begin"]), Html::convDateTime($this->fields["end"])); echo "<br>" . getUserName($this->fields["users_id_tech"]); if (Session::haveRight('planning', Planning::READMY)) { echo "</span>"; echo "</div>\n"; echo "<div id='viewplan'></div>\n"; } } else { if ($canplan) { echo "<script type='text/javascript' >\n"; echo "function showPlanUpdate() {\n"; echo Html::jsHide('plan'); $params = array('form' => 'followups', 'entity' => $_SESSION["glpiactive_entity"], 'rand_user' => $rand_user, 'itemtype' => $this->getType(), 'items_id' => $this->getID()); Ajax::updateItemJsCode('viewplan', $CFG_GLPI["root_doc"] . "/ajax/planning.php", $params); echo "};"; echo "</script>"; if ($canplan) { echo "<div id='plan' onClick='showPlanUpdate()'>\n"; echo "<span class='vsubmit'>" . __('Plan this task') . "</span>"; echo "</div>\n"; echo "<div id='viewplan'></div>\n"; } } else { _e('None'); } } echo "</td></tr>"; if (!empty($this->fields["begin"]) && PlanningRecall::isAvailable()) { echo "<tr class='tab_bg_1'><td>" . _x('Planning', 'Reminder') . "</td><td class='center'>"; PlanningRecall::dropdown(array('itemtype' => $this->getType(), 'items_id' => $this->getID())); echo "</td></tr>"; } $this->showFormButtons($options); return true; }
/** * Show a tooltip on an item * * @param $content string data to put in the tooltip * @param $options array of possible options: * - applyto : string / id of the item to apply tooltip (default empty). * If not set display an icon * - title : string / title to display (default empty) * - contentid : string / id for the content html container (default auto generated) (used for ajax) * - link : string / link to put on displayed image if contentid is empty * - linkid : string / html id to put to the link link (used for ajax) * - linktarget : string / target for the link * - popup : string / popup action : link not needed to use it * - img : string / url of a specific img to use * - display : boolean / display the item : false return the datas * - autoclose : boolean / autoclose the item : default true (false permit to scroll) * * @return nothing (print out an HTML div) **/ static function showToolTip($content, $options = array()) { global $CFG_GLPI; $param['applyto'] = ''; $param['title'] = ''; $param['contentid'] = ''; $param['link'] = ''; $param['linkid'] = ''; $param['linktarget'] = ''; $param['img'] = $CFG_GLPI["root_doc"] . "/pics/info-small.png"; $param['popup'] = ''; $param['ajax'] = ''; $param['display'] = true; $param['autoclose'] = true; if (is_array($options) && count($options)) { foreach ($options as $key => $val) { $param[$key] = $val; } } // No empty content to have a clean display if (empty($content)) { $content = " "; } $rand = mt_rand(); $out = ''; // Force link for popup if (!empty($param['popup'])) { $param['link'] = '#'; } if (empty($param['applyto'])) { if (!empty($param['link'])) { $out .= "<a id='" . (!empty($param['linkid']) ? $param['linkid'] : "tooltiplink{$rand}") . "'"; if (!empty($param['linktarget'])) { $out .= " target='" . $param['linktarget'] . "' "; } $out .= " href='" . $param['link'] . "'"; if (!empty($param['popup'])) { $out .= " onClick=\"" . Html::jsGetElementbyID('tooltippopup' . $rand) . ".dialog('open');\" "; } $out .= '>'; } $out .= "<img id='tooltip{$rand}' alt='ffff' src='" . $param['img'] . "' class='pointer'>"; if (!empty($param['link'])) { $out .= "</a>"; } $param['applyto'] = "tooltip{$rand}"; } if (empty($param['contentid'])) { $param['contentid'] = "content" . $param['applyto']; } $out .= "<div id='" . $param['contentid'] . "' class='invisible'>{$content}</div>"; if (!empty($param['popup'])) { $out .= Ajax::createIframeModalWindow('tooltippopup' . $rand, $param['popup'], array('display' => false, 'width' => 600, 'height' => 300)); } $js = ""; $js .= Html::jsGetElementbyID($param['applyto']) . ".qtip({\n content: {text: " . Html::jsGetElementbyID($param['contentid']); if (!$param['autoclose']) { $js .= ", title: {text: ' ',button: true}"; } $js .= "}, style: { classes: 'qtip-shadow qtip-bootstrap'}"; if (!$param['autoclose']) { $js .= ",show: {\n solo: true, // ...and hide all other tooltips...\n }, hide: false,"; } $js .= "});"; $out .= Html::scriptBlock($js); if ($param['display']) { echo $out; } else { return $out; } }
static function getLinkToCreateFromTypeAndTypeMIB(array $fields = array()) { $link = static::getFormURL() . '?TYPE=' . $fields['TYPE'] . '&TYPEMIB=' . $fields['TYPEMIB']; if (!empty($fields['speed'])) { $speed = NetworkPortEthernet::transformPortSpeed($fields['speed'], false); if (!empty($speed)) { $link .= '&SPEED=' . $speed; } } $link .= '&rand=1'; // To reload main window Ajax::createIframeModalWindow('create_network', $link, array('title' => __('Create', 'ocsinventoryng'))); return "<a href='#' onClick=\"\$('#create_network').dialog('open');\">" . __('Create', 'ocsinventoryng') . "</a>"; }