showToolTip() static public method

Show a tooltip on an item
static public showToolTip ( $content, $options = [] ) : nothing
$content string data to put in the tooltip
$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)
コード例 #1
0
ファイル: reference.class.php プロジェクト: pluginsGLPI/order
 /**
  * Permet l'affichage dynamique d'une liste d�roulante imbriquee
  *
  * @static
  * @param array ($itemtype,$options)
  */
 public static function dropdownReferencesByEnterprise($itemtype, $options = array())
 {
     global $DB, $CFG_GLPI;
     $item = getItemForItemtype($itemtype);
     if ($itemtype && !($item = getItemForItemtype($itemtype))) {
         return false;
     }
     $table = $item->getTable();
     $params['comments'] = true;
     $params['condition'] = '';
     $params['entity'] = -1;
     $params['name'] = "reference";
     $params['value'] = 0;
     $params['entity_sons'] = false;
     $params['rand'] = mt_rand();
     $params['used'] = array();
     $params['table'] = $table;
     $params['emptylabel'] = Dropdown::EMPTY_VALUE;
     //specific
     $params['action'] = "";
     $params['itemtype'] = "";
     $params['span'] = "";
     $params['orders_id'] = 0;
     $params['suppliers_id'] = 0;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $name = $params['emptylabel'];
     $comment = "";
     $limit_length = $_SESSION["glpidropdown_chars_limit"];
     if (strlen($params['value']) == 0 || !is_numeric($params['value'])) {
         $params['value'] = 0;
     }
     if ($params['value'] > 0) {
         $tmpname = Dropdown::getDropdownName($table, $params['value'], 1);
         if ($tmpname["name"] != " ") {
             $name = $tmpname["name"];
             $comment = $tmpname["comment"];
             if (Toolbox::strlen($name) > $_SESSION["glpidropdown_chars_limit"]) {
                 if ($item instanceof CommonTreeDropdown) {
                     $pos = strrpos($name, ">");
                     $limit_length = max(Toolbox::strlen($name) - $pos, $_SESSION["glpidropdown_chars_limit"]);
                     if (Toolbox::strlen($name) > $limit_length) {
                         $name = "…" . Toolbox::substr($name, -$limit_length);
                     }
                 } else {
                     $limit_length = Toolbox::strlen($name);
                 }
             } else {
                 $limit_length = $_SESSION["glpidropdown_chars_limit"];
             }
         }
     }
     // Manage entity_sons
     if (!($params['entity'] < 0) && $params['entity_sons']) {
         if (is_array($params['entity'])) {
             echo "entity_sons options is not available with array of entity";
         } else {
             $params['entity'] = getSonsOf('glpi_entities', $params['entity']);
         }
     }
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax_autocompletion"]) {
         $nb = 0;
         $query = "SELECT COUNT(*) AS cpt\n                   FROM `{$table}` as t\n                   LEFT JOIN `glpi_plugin_order_references_suppliers` as s\n                      ON (`t`.`id` = `s`.`plugin_order_references_id`)\n                   WHERE `s`.`suppliers_id` = '{$params['suppliers_id']}'\n                   AND `t`.`itemtype` = '{$params['itemtype']}'";
         if ($item->isEntityAssign()) {
             if (!($params['entity'] < 0)) {
                 $query .= getEntitiesRestrictRequest("AND", 't', '', $params['entity'], true);
             } else {
                 $query .= getEntitiesRestrictRequest("AND", 't', '', '', true);
             }
         }
         $result = $DB->query($query);
         if ($DB->numrows($result) == 1) {
             $nb = $DB->result($result, 0, "cpt");
         }
         $nb -= count($params['used']);
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $param = array('searchText' => '__VALUE__', 'value' => $params['value'], 'itemtype' => $params['itemtype'], 'myname' => $params['name'], 'limit' => $limit_length, 'comment' => $params['comments'], 'rand' => $params['rand'], 'entity_restrict' => $params['entity'], 'used' => $params['used'], 'condition' => $params['condition'], 'table' => $params['table'], 'action' => $params['action'], 'span' => $params['span'], 'orders_id' => $params['orders_id'], 'suppliers_id' => $params['suppliers_id']);
     $default = "<select name='" . $params['name'] . "' id='dropdown_" . $params['name'] . $params['rand'] . "'>";
     $default .= "<option value='" . $params['value'] . "'>{$name}</option></select>";
     Ajax::Dropdown($use_ajax, "/plugins/order/ajax/dropdownValue.php", $param, $default, $params['rand']);
     // Display comment
     if ($params['comments']) {
         $options_tooltip = array('contentid' => "comment_" . $param['myname'] . $params['rand']);
         if ($params['value'] && $item->getFromDB($params['value'])) {
             $options_tooltip['link'] = $item->getLinkURL();
             $options_tooltip['linktarget'] = '_blank';
         }
         Html::showToolTip($comment, $options_tooltip);
         if ($itemtype::canCreate() && !isset($_GET['popup'])) {
             echo "<img alt='' title=\"" . __("Add") . "\" src='" . $CFG_GLPI["root_doc"] . "\n               /pics/add_dropdown.png' style='cursor:pointer; margin-left:2px;'\n               onClick=\"var w = window . open('" . $item->getFormURL() . "?popup=1&amp;rand=" . $params['rand'] . "&amp;itemtype=" . $params['itemtype'] . "&amp;entities_id=" . $params['entity'] . "', " . "'glpipopup', 'height=400,width=1000, top=100, left=100,\n               scrollbars=yes' );w.focus();\">";
         }
     }
     return $params['rand'];
 }
コード例 #2
0
ファイル: networkport.class.php プロジェクト: gaforeror/glpi
 /**
  * Show ports for an item
  *
  * @param $item                     CommonDBTM object
  * @param $withtemplate   integer   withtemplate param (default '')
  **/
 static function showForItem(CommonDBTM $item, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $rand = mt_rand();
     $itemtype = $item->getType();
     $items_id = $item->getField('id');
     if (!Session::haveRight('networking', 'r') || !$item->can($items_id, 'r')) {
         return false;
     }
     $netport = new self();
     $netport->item = $item;
     if ($itemtype == 'NetworkPort') {
         $canedit = false;
     } else {
         $canedit = $item->can($items_id, 'w');
     }
     $showmassiveactions = false;
     if ($withtemplate != 2) {
         $showmassiveactions = $canedit;
     }
     // Show Add Form
     if ($canedit && (empty($withtemplate) || $withtemplate != 2)) {
         echo "\n<form method='get' action='" . $netport->getFormURL() . "'>\n";
         echo "<input type='hidden' name='items_id' value='" . $item->getID() . "'>\n";
         echo "<input type='hidden' name='itemtype' value='" . $item->getType() . "'>\n";
         echo "<div class='firstbloc'><table class='tab_cadre_fixe'>\n";
         echo "<tr class='tab_bg_2'><td class='center'>\n";
         _e('Network port type to be added');
         echo "&nbsp;";
         $instantiations = array();
         foreach (self::getNetworkPortInstantiations() as $inst_type) {
             if (call_user_func(array($inst_type, 'canCreate'))) {
                 $instantiations[$inst_type] = call_user_func(array($inst_type, 'getTypeName'));
             }
         }
         Dropdown::showFromArray('instantiation_type', $instantiations, array('value' => 'NetworkPortEthernet'));
         echo "</td>\n";
         echo "<td class='tab_bg_2 center' width='50%'>";
         _e('Add several ports');
         echo "&nbsp;<input type='checkbox' name='several' value='1'></td>\n";
         echo "<td>\n";
         echo "<input type='submit' name='create' value=\"" . _sx('button', 'Add') . "\" class='submit'>\n";
         echo "</td></tr></table></div>\n";
         Html::closeForm();
     }
     if ($showmassiveactions) {
         $checkbox_column = true;
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     } else {
         $checkbox_column = false;
     }
     $is_active_network_port = false;
     Session::initNavigateListItems('NetworkPort', sprintf(__('%1$s = %2$s'), $item->getTypeName(1), $item->getName()));
     if ($itemtype == 'NetworkPort') {
         $porttypes = array('NetworkPortAlias', 'NetworkPortAggregate');
     } else {
         $porttypes = self::getNetworkPortInstantiations();
         // Manage NetworkportMigration
         $porttypes[] = '';
     }
     $display_options = self::getDisplayOptions($itemtype);
     $table = new HTMLTableMain();
     $number_port = self::countForItem($item);
     $table_options = array('canedit' => $canedit, 'display_options' => &$display_options);
     // Make table name and add the correct show/hide parameters
     $table_name = sprintf(__('%1$s: %2$d'), self::getTypeName($number_port), $number_port);
     // Add the link to the popup to display the options ...
     $table_namelink = self::getDisplayOptionsLink($itemtype);
     $table_name = sprintf(__('%1$s - %2$s'), $table_name, $table_namelink);
     $table->setTitle($table_name);
     $c_main = $table->addHeader('main', self::getTypeName(2));
     if ($display_options['dynamic_import'] && $item->isDynamic()) {
         $table_options['display_isDynamic'] = true;
     } else {
         $table_options['display_isDynamic'] = false;
     }
     if ($display_options['characteristics']) {
         $c_instant = $table->addHeader('Instantiation', __('Characteristics'));
         $c_instant->setHTMLClass('center');
     }
     if ($display_options['internet']) {
         $options = array('names' => 'NetworkName', 'aliases' => 'NetworkAlias', 'ipaddresses' => 'IPAddress', 'ipnetworks' => 'IPNetwork');
         $table_options['dont_display'] = array();
         foreach ($options as $option => $itemtype_for_option) {
             if (!$display_options[$option]) {
                 $table_options['dont_display'][$itemtype_for_option] = true;
             }
         }
         $c_network = $table->addHeader('Internet', _n(__('Internet information'), __('Internet information'), 2));
         $c_network->setHTMLClass('center');
     } else {
         $c_network = NULL;
     }
     foreach ($porttypes as $portType) {
         if (empty($portType)) {
             $group_name = 'Migration';
             $group_title = __('Network ports waiting for manual migration');
         } else {
             $group_name = $portType;
             $group_title = $portType::getTypeName(2);
         }
         $t_group = $table->createGroup($group_name, $group_title);
         if ($withtemplate != 2 && $canedit) {
             $c_checkbox = $t_group->addHeader('checkbox', Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand, '__RAND__'), $c_main);
         } else {
             $c_checkbox = NULL;
         }
         $c_number = $t_group->addHeader('NetworkPort', "#", $c_main);
         $c_name = $t_group->addHeader("Name", __('Name'), $c_main);
         $c_name->setItemType('NetworkPort');
         $c_name->setHTMLClass('center');
         if ($table_options['display_isDynamic']) {
             $c_dynamic = $t_group->addHeader("Dynamic", __('Automatic inventory'), $c_main);
             $c_dynamic->setHTMLClass('center');
         }
         if ($display_options['characteristics']) {
             if (empty($portType)) {
                 NetworkPortMigration::getMigrationInstantiationHTMLTableHeaders($t_group, $c_instant, $c_network, NULL, $table_options);
             } else {
                 $instantiation = new $portType();
                 $instantiation->getInstantiationHTMLTableHeaders($t_group, $c_instant, $c_network, NULL, $table_options);
                 unset($instantiation);
             }
         }
         if ($display_options['internet'] && !$display_options['characteristics']) {
             NetworkName::getHTMLTableHeader(__CLASS__, $t_group, $c_network, NULL, $table_options);
         }
         if ($itemtype == 'NetworkPort') {
             switch ($portType) {
                 case 'NetworkPortAlias':
                     $search_table = 'glpi_networkportaliases';
                     $search_request = "`networkports_id_alias`='{$items_id}'";
                     break;
                 case 'NetworkPortAggregate':
                     $search_table = 'glpi_networkportaggregates';
                     $search_request = "`networkports_id_list` like '%\"{$items_id}\"%'";
                     break;
             }
             $query = "SELECT `networkports_id` AS id\n                      FROM  `{$search_table}`\n                      WHERE {$search_request}";
         } else {
             $query = "SELECT `id`\n                      FROM `glpi_networkports`\n                      WHERE `items_id` = '{$items_id}'\n                            AND `itemtype` = '{$itemtype}'\n                            AND `instantiation_type` = '{$portType}'\n                            AND `is_deleted` = '0'\n                      ORDER BY `name`,\n                               `logical_number`";
         }
         if ($result = $DB->query($query)) {
             echo "<div class='spaced'>";
             $number_port = $DB->numrows($result);
             if ($number_port != 0) {
                 $is_active_network_port = true;
                 $save_canedit = $canedit;
                 if (!empty($portType)) {
                     $name = sprintf(__('%1$s (%2$s)'), self::getTypeName($number_port), call_user_func(array($portType, 'getTypeName')));
                     $name = sprintf(__('%1$s: %2$s'), $name, $number_port);
                 } else {
                     $name = __('Network ports waiting for manual migration');
                     $canedit = false;
                 }
                 while ($devid = $DB->fetch_row($result)) {
                     $t_row = $t_group->createRow();
                     $netport->getFromDB(current($devid));
                     // No massive action for migration ports
                     if ($withtemplate != 2 && $canedit && !empty($portType)) {
                         $ce_checkbox = $t_row->addCell($c_checkbox, "<input type='checkbox' name='item[" . $netport->fields["id"] . "]' value='1'>");
                     } else {
                         $ce_checkbox = NULL;
                     }
                     $content = "<span class='b'>";
                     // Display link based on default rights
                     if ($save_canedit && $withtemplate != 2) {
                         if (!empty($portType)) {
                             $content .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networkport.form.php?id=" . $netport->fields["id"] . "\">";
                         } else {
                             $content .= "<a href=\"" . $CFG_GLPI["root_doc"] . "/front/networkportmigration.form.php?id=" . $netport->fields["id"] . "\">";
                         }
                     }
                     $content .= $netport->fields["logical_number"];
                     if ($canedit && $withtemplate != 2) {
                         $content .= "</a>";
                     }
                     $content .= "</span>";
                     $content .= Html::showToolTip($netport->fields['comment'], array('display' => false));
                     $t_row->addCell($c_number, $content);
                     $value = $netport->fields["name"];
                     $t_row->addCell($c_name, $value, NULL, $netport);
                     if ($table_options['display_isDynamic']) {
                         $t_row->addCell($c_dynamic, Dropdown::getYesNo($netport->fields['is_dynamic']));
                     }
                     $instant_cell = NULL;
                     if ($display_options['characteristics']) {
                         $instantiation = $netport->getInstantiation();
                         if ($instantiation !== false) {
                             $instantiation->getInstantiationHTMLTable($netport, $t_row, NULL, $table_options);
                             unset($instantiation);
                         }
                     } else {
                         if ($display_options['internet']) {
                             NetworkName::getHTMLTableCellsForItem($t_row, $netport, NULL, $table_options);
                         }
                     }
                 }
                 $canedit = $save_canedit;
             }
             echo "</div>";
         }
     }
     if ($is_active_network_port && $showmassiveactions) {
         $massiveactionparams = array('num_displayed' => $number_port, 'check_itemtype' => $itemtype, 'check_items_id' => $items_id);
         Html::showMassiveActions('NetworkPort', $massiveactionparams);
     }
     $table->display(array('display_thead' => false, 'display_tfoot' => false));
     unset($table);
     if (!$is_active_network_port) {
         echo "<table class='tab_cadre_fixe'><tr><th>" . __('No network port found') . "</th></tr>";
         echo "</table>";
     }
     if ($showmassiveactions) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions('NetworkPort', $massiveactionparams);
         Html::closeForm();
     }
 }
コード例 #3
0
 /**
  * Show projecttasks for a ticket
  *
  * @param $ticket Ticket object
  **/
 static function showForTicket(Ticket $ticket)
 {
     global $DB, $CFG_GLPI;
     $ID = $ticket->getField('id');
     if (!$ticket->can($ID, READ)) {
         return false;
     }
     $canedit = $ticket->canEdit($ID);
     $rand = mt_rand();
     $query = "SELECT DISTINCT `glpi_projecttasks_tickets`.`id` AS linkID,\n                                `glpi_projecttasks`.*\n                FROM `glpi_projecttasks`\n                LEFT JOIN `glpi_projecttasks_tickets`\n                   ON (`glpi_projecttasks_tickets`.`projecttasks_id` = `glpi_projecttasks`.`id`)\n                WHERE `glpi_projecttasks_tickets`.`tickets_id` = '{$ID}'\n                ORDER BY `glpi_projecttasks`.`name`";
     $result = $DB->query($query);
     $pjtasks = array();
     $used = array();
     if ($numrows = $DB->numrows($result)) {
         while ($data = $DB->fetch_assoc($result)) {
             $pjtasks[$data['id']] = $data;
             $used[$data['id']] = $data['id'];
         }
     }
     //       if ($canedit) {
     //          echo "<div class='firstbloc'>";
     //          echo "<form name='projecttaskticket_form$rand' id='projecttaskticket_form$rand'
     //                 method='post' action='".Toolbox::getItemTypeFormURL(__CLASS__)."'>";
     //
     //          echo "<table class='tab_cadre_fixe'>";
     //          echo "<tr class='tab_bg_2'><th colspan='3'>".__('Add a project task')."</th></tr>";
     //
     //          echo "<tr class='tab_bg_2'><td class='right'>";
     //          echo "<input type='hidden' name='tickets_id' value='$ID'>";
     //          $condition = "`glpi_projecttasks`.`projectstates_id` <> 3";
     //          ProjectTask::dropdown(array('used'        => $used,
     //                                      'entity'      => $ticket->getEntityID(),
     //                                      'entity_sons' => $ticket->isRecursive(),
     //                                      'condition'   => $condition,
     //                                      'displaywith' => array('id')));
     //          echo "</td><td width='20%'>";
     // //          echo "<a href='".Toolbox::getItemTypeFormURL('ProjectTask')."?tickets_id=$ID'>";
     // //                 _e('Create a project task from this ticket');
     // //          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 ($numrows) {
         $columns = array('projectname' => Project::getTypeName(Session::getPluralNumber()), 'name' => ProjectTask::getTypeName(Session::getPluralNumber()), 'tname' => __('Type'), 'sname' => __('Status'), 'percent_done' => __('Percent done'), 'plan_start_date' => __('Planned start date'), 'plan_end_date' => __('Planned end date'), 'planned_duration' => __('Planned duration'), '_effect_duration' => __('Effective duration'), 'fname' => __('Father'));
         if (isset($_GET["order"]) && $_GET["order"] == "DESC") {
             $order = "DESC";
         } else {
             $order = "ASC";
         }
         if (!isset($_GET["sort"]) || empty($_GET["sort"])) {
             $_GET["sort"] = "plan_start_date";
         }
         if (isset($_GET["sort"]) && !empty($_GET["sort"]) && isset($columns[$_GET["sort"]])) {
             $sort = "`" . $_GET["sort"] . "`";
         } else {
             $sort = "`plan_start_date` {$order}, `name`";
         }
         $query = "SELECT `glpi_projecttasks`.*,\n                       `glpi_projecttasktypes`.`name` AS tname,\n                       `glpi_projectstates`.`name` AS sname,\n                       `glpi_projectstates`.`color`,\n                       `father`.`name` AS fname,\n                       `father`.`id` AS fID,\n                       `glpi_projects`.`name` AS projectname,\n                       `glpi_projects`.`content` AS projectcontent\n                FROM `glpi_projecttasks`\n                LEFT JOIN `glpi_projecttasktypes`\n                   ON (`glpi_projecttasktypes`.`id` = `glpi_projecttasks`.`projecttasktypes_id`)\n                LEFT JOIN `glpi_projectstates`\n                   ON (`glpi_projectstates`.`id` = `glpi_projecttasks`.`projectstates_id`)\n                LEFT JOIN `glpi_projecttasks` as father\n                   ON (`father`.`id` = `glpi_projecttasks`.`projecttasks_id`)\n                LEFT JOIN `glpi_projecttasks_tickets`\n                   ON (`glpi_projecttasks_tickets`.`projecttasks_id` = `glpi_projecttasks`.`id`)\n                LEFT JOIN `glpi_projects`\n                   ON (`glpi_projecttasks`.`projects_id` = `glpi_projects`.`id`)\n                WHERE `glpi_projecttasks_tickets`.`tickets_id` = '{$ID}'\n                ORDER BY {$sort} {$order}";
         Session::initNavigateListItems('ProjectTask', sprintf(__('%1$s = %2$s'), $ticket::getTypeName(1), $ticket->getName()));
         if ($result = $DB->query($query)) {
             if ($DB->numrows($result)) {
                 echo "<table class='tab_cadre_fixehov'>";
                 echo "<tr><th colspan='10'>" . ProjectTask::getTypeName($numrows) . "</th>";
                 echo "</tr>";
                 $sort_img = "<img src=\"" . $CFG_GLPI["root_doc"] . "/pics/" . ($order == "DESC" ? "puce-down.png" : "puce-up.png") . "\" alt='' title=''>";
                 $header = '<tr>';
                 foreach ($columns as $key => $val) {
                     // Non order column
                     if ($key[0] == '_') {
                         $header .= "<th>{$val}</th>";
                     } else {
                         $header .= "<th>" . ($sort == "`{$key}`" ? $sort_img : "") . "<a href='javascript:reloadTab(\"sort={$key}&amp;order=" . ($order == "ASC" ? "DESC" : "ASC") . "&amp;start=0\");'>{$val}</a></th>";
                     }
                 }
                 $header .= "</tr>\n";
                 echo $header;
                 while ($data = $DB->fetch_assoc($result)) {
                     Session::addToNavigateListItems('ProjectTask', $data['id']);
                     $rand = mt_rand();
                     echo "<tr class='tab_bg_2'>";
                     echo "<td>";
                     $link = "<a id='Project" . $data["projects_id"] . $rand . "' href='project.form.php?id=" . $data['projects_id'] . "'>" . $data['projectname'] . (empty($data['projectname']) ? "(" . $data['projects_id'] . ")" : "") . "</a>";
                     echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['projectcontent'], array('display' => false, 'applyto' => "Project" . $data["projects_id"] . $rand)));
                     echo "</td>";
                     echo "<td>";
                     $link = "<a id='ProjectTask" . $data["id"] . $rand . "' href='projecttask.form.php?id=" . $data['id'] . "'>" . $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a>";
                     echo sprintf(__('%1$s %2$s'), $link, Html::showToolTip($data['content'], array('display' => false, 'applyto' => "ProjectTask" . $data["id"] . $rand)));
                     echo "</td>";
                     echo "<td>" . $data['tname'] . "</td>";
                     echo "<td";
                     echo " style=\"background-color:" . $data['color'] . "\"";
                     echo ">" . $data['sname'] . "</td>";
                     echo "<td>";
                     echo Dropdown::getValueWithUnit($data["percent_done"], "%");
                     echo "</td>";
                     echo "<td>" . Html::convDateTime($data['plan_start_date']) . "</td>";
                     echo "<td>" . Html::convDateTime($data['plan_end_date']) . "</td>";
                     echo "<td>" . Html::timestampToString($data['planned_duration'], false) . "</td>";
                     echo "<td>" . Html::timestampToString(ProjectTask::getTotalEffectiveDuration($data['id']), false) . "</td>";
                     echo "<td>";
                     if ($data['projecttasks_id'] > 0) {
                         $father = Dropdown::getDropdownName('glpi_projecttasks', $data['projecttasks_id']);
                         echo "<a id='ProjectTask" . $data["projecttasks_id"] . $rand . "' href='projecttask.form.php?id=" . $data['projecttasks_id'] . "'>" . $father . (empty($father) ? "(" . $data['projecttasks_id'] . ")" : "") . "</a>";
                     }
                     echo "</td></tr>";
                 }
                 echo $header;
                 echo "</table>\n";
             } else {
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . __('No item found') . "</th></tr>";
                 echo "</table>\n";
             }
         }
         echo "</div>";
     }
 }
コード例 #4
0
 /**
  * Display a line for an object
  *
  * @since version 0.85 (befor in each object with differents parameters)
  *
  * @param $id                 Integer  ID of the object
  * @param $options            array of options
  *      output_type            : Default output type (see Search class / default Search::HTML_OUTPUT)
  *      row_num                : row num used for display
  *      type_for_massiveaction : itemtype for massive action
  *      id_for_massaction      : default 0 means no massive action
  *      followups              : only for Tickets : show followup columns
  */
 static function showShort($id, $options = array())
 {
     global $CFG_GLPI, $DB;
     $p['output_type'] = Search::HTML_OUTPUT;
     $p['row_num'] = 0;
     $p['type_for_massiveaction'] = 0;
     $p['id_for_massiveaction'] = 0;
     $p['followups'] = false;
     if (count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     $rand = mt_rand();
     /// TODO to be cleaned. Get datas and clean display links
     // Prints a job in short form
     // Should be called in a <table>-segment
     // Print links or not in case of user view
     // Make new job object and fill it from database, if success, print it
     $item = new static();
     $candelete = static::canDelete();
     $canupdate = Session::haveRight(static::$rightname, UPDATE);
     $showprivate = Session::haveRight('followup', TicketFollowup::SEEPRIVATE);
     $align = "class='center";
     $align_desc = "class='left";
     if ($p['followups']) {
         $align .= " top'";
         $align_desc .= " top'";
     } else {
         $align .= "'";
         $align_desc .= "'";
     }
     if ($item->getFromDB($id)) {
         $item_num = 1;
         $bgcolor = $_SESSION["glpipriority_" . $item->fields["priority"]];
         echo Search::showNewLine($p['output_type'], $p['row_num'] % 2);
         $check_col = '';
         if (($candelete || $canupdate) && $p['output_type'] == Search::HTML_OUTPUT && $p['id_for_massiveaction']) {
             $check_col = Html::getMassiveActionCheckBox($p['type_for_massiveaction'], $p['id_for_massiveaction']);
         }
         echo Search::showItem($p['output_type'], $check_col, $item_num, $p['row_num'], $align);
         // First column
         $first_col = sprintf(__('%1$s: %2$s'), __('ID'), $item->fields["id"]);
         if ($p['output_type'] == Search::HTML_OUTPUT) {
             $first_col .= "<br><img src='" . static::getStatusIconURL($item->fields["status"]) . "'\n                                alt=\"" . static::getStatus($item->fields["status"]) . "\" title=\"" . static::getStatus($item->fields["status"]) . "\">";
         } else {
             $first_col = sprintf(__('%1$s - %2$s'), $first_col, static::getStatus($item->fields["status"]));
         }
         echo Search::showItem($p['output_type'], $first_col, $item_num, $p['row_num'], $align);
         // Second column
         if ($item->fields['status'] == static::CLOSED) {
             $second_col = sprintf(__('Closed on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['closedate']));
         } else {
             if ($item->fields['status'] == static::SOLVED) {
                 $second_col = sprintf(__('Solved on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['solvedate']));
             } else {
                 if ($item->fields['begin_waiting_date']) {
                     $second_col = sprintf(__('Put on hold on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['begin_waiting_date']));
                 } else {
                     if ($item->fields['due_date']) {
                         $second_col = sprintf(__('%1$s: %2$s'), __('Due date'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['due_date']));
                     } else {
                         $second_col = sprintf(__('Opened on %s'), ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($item->fields['date']));
                     }
                 }
             }
         }
         echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=130");
         // Second BIS column
         $second_col = Html::convDateTime($item->fields["date_mod"]);
         echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=90");
         // Second TER column
         if (count($_SESSION["glpiactiveentities"]) > 1) {
             $second_col = Dropdown::getDropdownName('glpi_entities', $item->fields['entities_id']);
             echo Search::showItem($p['output_type'], $second_col, $item_num, $p['row_num'], $align . " width=100");
         }
         // Third Column
         echo Search::showItem($p['output_type'], "<span class='b'>" . static::getPriorityName($item->fields["priority"]) . "</span>", $item_num, $p['row_num'], "{$align} bgcolor='{$bgcolor}'");
         // Fourth Column
         $fourth_col = "";
         foreach ($item->getUsers(CommonITILActor::REQUESTER) as $d) {
             $userdata = getUserName($d["users_id"], 2);
             $fourth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
             $fourth_col .= "<br>";
         }
         foreach ($item->getGroups(CommonITILActor::REQUESTER) as $d) {
             $fourth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
             $fourth_col .= "<br>";
         }
         echo Search::showItem($p['output_type'], $fourth_col, $item_num, $p['row_num'], $align);
         // Fifth column
         $fifth_col = "";
         foreach ($item->getUsers(CommonITILActor::ASSIGN) as $d) {
             $userdata = getUserName($d["users_id"], 2);
             $fifth_col .= sprintf(__('%1$s %2$s'), "<span class='b'>" . $userdata['name'] . "</span>", Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
             $fifth_col .= "<br>";
         }
         foreach ($item->getGroups(CommonITILActor::ASSIGN) as $d) {
             $fifth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
             $fifth_col .= "<br>";
         }
         foreach ($item->getSuppliers(CommonITILActor::ASSIGN) as $d) {
             $fifth_col .= Dropdown::getDropdownName("glpi_suppliers", $d["suppliers_id"]);
             $fifth_col .= "<br>";
         }
         echo Search::showItem($p['output_type'], $fifth_col, $item_num, $p['row_num'], $align);
         // Sixth Colum
         // Ticket : simple link to item
         $sixth_col = "";
         $is_deleted = false;
         $item_ticket = new Item_Ticket();
         $data = $item_ticket->find("`tickets_id` = " . $item->fields['id']);
         if ($item->getType() == 'Ticket') {
             if (!empty($data)) {
                 foreach ($data as $val) {
                     if (!empty($val["itemtype"]) && $val["items_id"] > 0) {
                         if ($object = getItemForItemtype($val["itemtype"])) {
                             if ($object->getFromDB($val["items_id"])) {
                                 $is_deleted = $object->isDeleted();
                                 $sixth_col .= $object->getTypeName();
                                 $sixth_col .= " - <span class='b'>";
                                 if ($item->canView()) {
                                     $sixth_col .= $object->getLink();
                                 } else {
                                     $sixth_col .= $object->getNameID();
                                 }
                                 $sixth_col .= "</span><br>";
                             }
                         }
                     }
                 }
             } else {
                 $sixth_col = __('General');
             }
             echo Search::showItem($p['output_type'], $sixth_col, $item_num, $p['row_num'], $is_deleted ? " class='center deleted' " : $align);
         }
         // Seventh column
         echo Search::showItem($p['output_type'], "<span class='b'>" . Dropdown::getDropdownName('glpi_itilcategories', $item->fields["itilcategories_id"]) . "</span>", $item_num, $p['row_num'], $align);
         // Eigth column
         $eigth_column = "<span class='b'>" . $item->getName() . "</span>&nbsp;";
         // Add link
         if ($item->canViewItem()) {
             $eigth_column = "<a id='" . $item->getType() . $item->fields["id"] . "{$rand}' href=\"" . $item->getLinkURL() . "\">{$eigth_column}</a>";
             if ($p['followups'] && $p['output_type'] == Search::HTML_OUTPUT) {
                 $eigth_column .= TicketFollowup::showShortForTicket($item->fields["id"]);
             } else {
                 if (method_exists($item, 'numberOfFollowups')) {
                     $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, sprintf(__('%1$s - %2$s'), $item->numberOfFollowups($showprivate), $item->numberOfTasks($showprivate)));
                 } else {
                     $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, $item->numberOfTasks($showprivate));
                 }
             }
         }
         if ($p['output_type'] == Search::HTML_OUTPUT) {
             $eigth_column = sprintf(__('%1$s %2$s'), $eigth_column, Html::showToolTip(Html::clean(Html::entity_decode_deep($item->fields["content"])), array('display' => false, 'applyto' => $item->getType() . $item->fields["id"] . $rand)));
         }
         echo Search::showItem($p['output_type'], $eigth_column, $item_num, $p['row_num'], $align_desc . " width='200'");
         //tenth column
         $tenth_column = '';
         $planned_infos = '';
         $tasktype = $item->getType() . "Task";
         $plan = new $tasktype();
         $items = array();
         foreach ($DB->request($plan->getTable(), array($item->getForeignKeyField() => $item->fields['id'])) as $plan) {
             if (isset($plan['begin']) && $plan['begin']) {
                 $items[$plan['id']] = $plan['id'];
                 $planned_infos .= sprintf(__('From %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), Html::convDateTime($plan['begin']));
                 $planned_infos .= sprintf(__('To %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), Html::convDateTime($plan['end']));
                 if ($plan['users_id_tech']) {
                     $planned_infos .= sprintf(__('By %s') . ($p['output_type'] == Search::HTML_OUTPUT ? '<br>' : ''), getUserName($plan['users_id_tech']));
                 }
                 $planned_infos .= "<br>";
             }
         }
         unset($i, $j);
         $tenth_column = count($items);
         if ($tenth_column) {
             $tenth_column = "<span class='pointer'\n                              id='" . $item->getType() . $item->fields["id"] . "planning{$rand}'>" . $tenth_column . '</span>';
             $tenth_column = sprintf(__('%1$s %2$s'), $tenth_column, Html::showToolTip($planned_infos, array('display' => false, 'applyto' => $item->getType() . $item->fields["id"] . "planning" . $rand)));
         }
         echo Search::showItem($p['output_type'], $tenth_column, $item_num, $p['row_num'], $align_desc . " width='150'");
         // Finish Line
         echo Search::showEndLine($p['output_type']);
     } else {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' ><i>" . __('No item in progress.') . "</i></td></tr>";
     }
 }
コード例 #5
0
 /**
  * Print the Software / license form
  *
  * @param $ID        integer  Id of the version or the template to print
  * @param $options   array    of possible options:
  *     - target form target
  *     - softwares_id ID of the software for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $softwares_id = -1;
     if (isset($options['softwares_id'])) {
         $softwares_id = $options['softwares_id'];
     }
     if ($ID < 0) {
         // Create item
         $this->fields['softwares_id'] = $softwares_id;
         $this->fields['number'] = 1;
         $soft = new Software();
         if ($soft->getFromDB($softwares_id) && in_array($_SESSION['glpiactive_entity'], getAncestorsOf('glpi_entities', $soft->getEntityID()))) {
             $options['entities_id'] = $soft->getEntityID();
         }
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     // Restore saved value or override with page parameter
     if (!isset($options['template_preview'])) {
         if (isset($_REQUEST)) {
             $saved = Html::cleanPostForTextArea($_REQUEST);
         }
     }
     foreach ($this->fields as $name => $value) {
         if (isset($saved[$name]) && empty($this->fields[$name])) {
             $this->fields[$name] = $saved[$name];
         }
     }
     echo "<input type='hidden' name='withtemplate' value='" . $options['withtemplate'] . "'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . Software::getTypeName(1) . "</td>";
     echo "<td>";
     if ($ID > 0) {
         $softwares_id = $this->fields["softwares_id"];
         echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>";
         echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>";
     } else {
         Dropdown::show('Software', array('condition' => "`is_template`='0' AND `is_deleted`='0'", 'entity' => $_SESSION['glpiactive_entity'], 'entity_sons' => $_SESSION['glpiactive_entity_recursive'], 'on_change' => 'this.form.submit()', 'value' => $softwares_id));
     }
     echo "</td>";
     echo "<td colspan='2'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_softwarelicense`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td><td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     SoftwareLicenseType::dropdown(array('value' => $this->fields["softwarelicensetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Publisher') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . __('User') . "</td>";
     echo "<td >";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "");
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td><td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='4'>";
     echo "<textarea cols='45' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version in use') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdownForOneSoftware(array('name' => "softwareversions_id_use", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_use"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Purchase version') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdownForOneSoftware(array('name' => "softwareversions_id_buy", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_buy"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('quantity', 'Number') . "</td>";
     echo "<td>";
     Dropdown::showNumber("number", array('value' => $this->fields["number"], 'min' => 1, 'max' => 10000, 'step' => 1, 'toadd' => array(-1 => __('Unlimited'))));
     if ($ID > 0) {
         echo "&nbsp;";
         if ($this->fields['is_valid']) {
             echo "<span class='green'>" . _x('adjective', 'Valid') . '<span>';
         } else {
             echo "<span class='red'>" . _x('adjective', 'Invalid') . '<span>';
         }
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration') . "</td>";
     echo "<td>";
     Html::showDateField('expire', array('value' => $this->fields["expire"]));
     if ($ID && is_null($this->fields["expire"])) {
         echo "<br>" . __('Never expire') . "&nbsp;";
         Html::showToolTip(__('On search engine, use "Expiration contains NULL" to search licenses with no expiration date'));
     }
     Alert::displayLastAlert('SoftwareLicense', $ID);
     echo "</td><td colspan='2'></td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
コード例 #6
0
ファイル: ticket.class.php プロジェクト: glpi-project/glpi
 /**
  * @since version 0.90
  *
  * @param $rand
  **/
 function showTimeline($rand)
 {
     global $CFG_GLPI, $DB, $autolink_options;
     //get ticket actors
     $ticket_users_keys = $this->getTicketActors();
     $user = new User();
     $group = new Group();
     $followup_obj = new TicketFollowup();
     $pics_url = $CFG_GLPI['root_doc'] . "/pics/timeline";
     $timeline = $this->getTimelineItems();
     $autolink_options['strip_protocols'] = false;
     //display timeline
     echo "<div class='timeline_history'>";
     $tmp = array_values($timeline);
     $first_item = array_shift($tmp);
     // show approbation form on top when ticket is solved
     if ($this->fields["status"] == CommonITILObject::SOLVED) {
         echo "<div class='approbation_form' id='approbation_form{$rand}'>";
         $followup_obj->showApprobationForm($this);
         echo "</div>";
     }
     // show title for timeline
     self::showTimelineHeader();
     $timeline_index = 0;
     foreach ($timeline as $item) {
         $options = array('parent' => $this, 'rand' => $rand);
         if ($obj = getItemForItemtype($item['type'])) {
             $obj->fields = $item['item'];
         } else {
             $obj = $item;
         }
         Plugin::doHook('pre_show_item', array('item' => &$obj, 'options' => &$options));
         if (is_array($obj)) {
             $item_i = $obj['item'];
         } else {
             $item_i = $obj->fields;
         }
         $date = "";
         if (isset($item_i['date'])) {
             $date = $item_i['date'];
         }
         if (isset($item_i['date_mod'])) {
             $date = $item_i['date_mod'];
         }
         // check if curent item user is assignee or requester
         $user_position = 'left';
         if (isset($ticket_users_keys[$item_i['users_id']]) && $ticket_users_keys[$item_i['users_id']] == CommonItilActor::ASSIGN || $item['type'] == 'Assign') {
             $user_position = 'right';
         }
         //display solution in middle
         if ($timeline_index == 0 && $item['type'] == "Solution" && $this->fields["status"] == CommonITILObject::SOLVED) {
             $user_position .= ' middle';
         }
         echo "<div class='h_item {$user_position}'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($date) . "</div>";
         if ($item_i['users_id'] !== false) {
             echo "<div class='h_user'>";
             if (isset($item_i['users_id']) && $item_i['users_id'] != 0) {
                 $user->getFromDB($item_i['users_id']);
                 echo "<div class='tooltip_picture_border'>";
                 echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($user->fields['picture']) . "'>";
                 echo "</div>";
                 echo "<span class='h_user_name'>";
                 $userdata = getUserName($item_i['users_id'], 2);
                 echo $user->getLink() . "&nbsp;";
                 echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link']));
                 echo "</span>";
             } else {
                 _e("Requester");
             }
             echo "</div>";
             // h_user
         }
         echo "</div>";
         //h_date
         echo "<div class='h_content " . $item['type'] . (isset($item_i['status']) ? " " . $item_i['status'] : "") . "'" . "id='viewitem" . $item['type'] . $item_i['id'] . $rand . "'>";
         if (isset($item_i['can_edit']) && $item_i['can_edit']) {
             echo "<div class='edit_item_content'></div>";
             echo "<span class='cancel_edit_item_content'></span>";
         }
         echo "<div class='displayed_content'>";
         if (!in_array($item['type'], array('Document_Item', 'Assign')) && $item_i['can_edit']) {
             echo "<span class='edit_item' ";
             echo "onclick='javascript:viewEditSubitem" . $this->fields['id'] . "{$rand}(event, \"" . $item['type'] . "\", " . $item_i['id'] . ", this, \"viewitem" . $item['type'] . $item_i['id'] . $rand . "\")'";
             echo "></span>";
         }
         if (isset($item_i['requesttypes_id']) && file_exists("{$pics_url}/" . $item_i['requesttypes_id'] . ".png")) {
             echo "<img src='{$pics_url}/" . $item_i['requesttypes_id'] . ".png' title='' class='h_requesttype' />";
         }
         if (isset($item_i['content'])) {
             $content = $item_i['content'];
             $content = autolink($content, 40);
             //$content = nl2br($content);
             $long_text = "";
             if (substr_count($content, "<br") > 30 || strlen($content) > 2000) {
                 $long_text = "long_text";
             }
             echo "<div class='item_content {$long_text}'>";
             echo "<p>";
             if (isset($item_i['state'])) {
                 $onClick = "onclick='change_task_state(" . $item_i['id'] . ", this)'";
                 if (!$item_i['can_edit']) {
                     $onClick = "style='cursor: not-allowed;'";
                 }
                 echo "<span class='state state_" . $item_i['state'] . "'\n                           {$onClick}\n                           title='" . Planning::getState($item_i['state']) . "'>";
                 echo "</span>";
             }
             echo $content;
             echo "</p>";
             if (!empty($long_text)) {
                 echo "<p class='read_more'>";
                 echo "<a class='read_more_button'>.....</a>";
                 echo "</p>";
             }
             echo "</div>";
         }
         echo "<div class='b_right'>";
         if (isset($item_i['solutiontypes_id']) && !empty($item_i['solutiontypes_id'])) {
             echo Dropdown::getDropdownName("glpi_solutiontypes", $item_i['solutiontypes_id']) . "<br>";
         }
         if (isset($item_i['taskcategories_id']) && !empty($item_i['taskcategories_id'])) {
             echo Dropdown::getDropdownName("glpi_taskcategories", $item_i['taskcategories_id']) . "<br>";
         }
         if (isset($item_i['requesttypes_id']) && !empty($item_i['requesttypes_id'])) {
             echo Dropdown::getDropdownName("glpi_requesttypes", $item_i['requesttypes_id']) . "<br>";
         }
         if (isset($item_i['actiontime']) && !empty($item_i['actiontime'])) {
             echo "<span class='actiontime'>";
             echo Html::timestampToString($item_i['actiontime'], false);
             echo "</span>";
         }
         if (isset($item_i['begin'])) {
             echo "<span class='planification'>";
             echo Html::convDateTime($item_i["begin"]);
             echo " &rArr; ";
             echo Html::convDateTime($item_i["end"]);
             echo "</span>";
         }
         if (isset($item_i['users_id_tech']) && $item_i['users_id_tech'] > 0) {
             echo "<div class='users_id_tech' id='users_id_tech_" . $item_i['users_id_tech'] . "'>";
             $user->getFromDB($item_i['users_id_tech']);
             echo Html::image($CFG_GLPI['root_doc'] . "/pics/user.png") . "&nbsp;";
             $userdata = getUserName($item_i['users_id_tech'], 2);
             echo $user->getLink() . "&nbsp;";
             echo Html::showToolTip($userdata["comment"], array('link' => $userdata['link']));
             echo "</div>";
         }
         if (isset($item_i['groups_id_tech']) && $item_i['groups_id_tech'] > 0) {
             echo "<div class='groups_id_tech'>";
             $group->getFromDB($item_i['groups_id_tech']);
             echo Html::image($CFG_GLPI['root_doc'] . "/pics/group.png") . "&nbsp;";
             echo $group->getLink() . "&nbsp;";
             echo Html::showToolTip($group->getComments(), array('link' => $group->getLinkURL()));
             echo "</div>";
         }
         // show "is_private" icon
         if (isset($item_i['is_private']) && $item_i['is_private']) {
             echo "<div class='private'>" . __('Private') . "</div>";
         }
         echo "</div>";
         // b_right
         if ($item['type'] == 'Document_Item') {
             $filename = $item_i['filename'];
             $ext = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
             echo "<img src='";
             if (empty($filename)) {
                 $filename = $item_i['name'];
             }
             if (file_exists(GLPI_ROOT . "/pics/icones/{$ext}-dist.png")) {
                 echo $CFG_GLPI['root_doc'] . "/pics/icones/{$ext}-dist.png";
             } else {
                 echo "{$pics_url}/file.png";
             }
             echo "' title='file' />&nbsp;";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' target='_blank'>{$filename}";
             if (in_array($ext, array('jpg', 'jpeg', 'png', 'bmp'))) {
                 echo "<div class='timeline_img_preview'>";
                 echo "<img src='" . $CFG_GLPI['root_doc'] . "/front/document.send.php?docid=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "'/>";
                 echo "</div>";
             }
             echo "</a>";
             if (!empty($item_i['mime'])) {
                 echo "&nbsp;(" . $item_i['mime'] . ")";
             }
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/document.form.php?id=" . $item_i['id'] . "' class='edit_document' title='" . _sx("button", "Update") . "'>";
             echo "<img src='{$pics_url}/edit.png' /></a>";
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/front/ticket.form.php?delete_document&documents_id=" . $item_i['id'] . "&tickets_id=" . $this->getID() . "' class='delete_document' title='" . _sx("button", "Delete permanently") . "'>";
             echo "<img src='{$pics_url}/delete.png' /></a>";
         }
         echo "</div>";
         // displayed_content
         echo "</div>";
         //end h_content
         echo "</div>";
         //end  h_info
         $timeline_index++;
         Plugin::doHook('post_show_item', array('item' => $obj, 'options' => $options));
     }
     // end foreach timeline
     echo "<div class='break'></div>";
     // recall ticket content (not needed in classic and splitted layout)
     if (!CommonGLPI::isLayoutWithMain()) {
         echo "<div class='h_item middle'>";
         echo "<div class='h_info'>";
         echo "<div class='h_date'>" . Html::convDateTime($this->fields['date']) . "</div>";
         echo "<div class='h_user'>";
         $dem = '0';
         foreach ($DB->request("glpi_tickets_users", "`tickets_id` = " . $this->fields['id'] . " AND `type` = 1") as $req) {
             $dem = $req['users_id'];
         }
         if ((!isset($item_i['users_id_recipient']) || $item_i['users_id_recipient'] == 0) && $dem == 0) {
             _e("Requester");
         } else {
             if (isset($item_i['users_id_recipient']) && $item_i['users_id_recipient'] != 0) {
                 $user->getFromDB($this->fields['users_id_recipient']);
             } else {
                 if ($dem > 0) {
                     $requester = new User();
                     if ($requester->getFromDB($dem)) {
                         $user = $requester;
                     }
                 }
             }
             echo "<div class='tooltip_picture_border'>";
             $picture = "";
             if (isset($user->fields['picture'])) {
                 $picture = $user->fields['picture'];
             }
             echo "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($picture) . "'>";
             echo "</div>";
             echo $user->getLink();
         }
         echo "</div>";
         // h_user
         echo "</div>";
         //h_info
         echo "<div class='h_content TicketContent'>";
         echo "<div class='b_right'>" . __("Ticket recall") . "</div>";
         echo "<div class='ticket_title'>";
         echo html_entity_decode($this->fields['name']);
         echo "</div>";
         echo "<div class='ticket_description'>";
         echo $this->setSimpleTextContent($this->fields['content']);
         echo "</div>";
         echo "</div>";
         // h_content TicketContent
         echo "</div>";
         // h_item middle
         echo "<div class='break'></div>";
     }
     // end timeline
     echo "</div>";
     // h_item $user_position
     echo "<script type='text/javascript'>read_more();</script>";
 }
コード例 #7
0
ファイル: task.class.php プロジェクト: InfotelGLPI/tasklists
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . _n('Context', 'Contexts', 1, 'tasklists') . "</td><td>";
     Dropdown::show('PluginTasklistsTaskType', array('name' => "plugin_tasklists_tasktypes_id", 'value' => $this->fields["plugin_tasklists_tasktypes_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Priority') . "</td>";
     echo "<td>";
     CommonITILObject::dropdownPriority(array('value' => $this->fields['priority'], 'withmajor' => 1));
     echo "</td>";
     echo "<td>" . __('Planned duration') . "</td>";
     echo "<td>";
     $toadd = array();
     //for ($i=9 ; $i<=100 ; $i++) {
     //   $toadd[] = $i*HOUR_TIMESTAMP;
     //}
     Dropdown::showTimeStamp("actiontime", array('min' => 0, 'max' => 50 * DAY_TIMESTAMP, 'step' => DAY_TIMESTAMP, 'value' => $this->fields["actiontime"], 'toadd' => $toadd));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Visibility') . "</td>";
     echo "<td>";
     self::dropdownVisibility(array('value' => $this->fields['visibility']));
     echo "</td>";
     echo "<td>" . __('Due date');
     echo "&nbsp;";
     Html::showToolTip(nl2br(__('Empty for infinite', 'tasklists')));
     echo "</td>";
     echo "<td>";
     Html::showDateFormItem("due_date", $this->fields["due_date"], true, true);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td><td>";
     User::dropdown(array('name' => "users_id", 'value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Percent done') . "</td>";
     echo "<td>";
     Dropdown::showNumber("percent_done", array('value' => $this->fields['percent_done'], 'min' => 0, 'max' => 100, 'step' => 20, 'unit' => '%'));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Dropdown::show('Group', array('name' => "groups_id", 'value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Status') . "</td><td>";
     Planning::dropdownState("state", $this->fields["state"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Description') . "</td>";
     echo "<td colspan = '3' class='center'>";
     echo "<textarea cols='100' rows='15' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
コード例 #8
0
 /**
  * Show visibility config for a knowbaseitem
  *
  * @since version 0.83
  **/
 function showVisibility()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->fields['id'];
     $canedit = $this->can($ID, UPDATE);
     echo "<div class='center'>";
     $rand = mt_rand();
     $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='knowbaseitemvisibility_form{$rand}' id='knowbaseitemvisibility_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('KnowbaseItem') . "'>";
         echo "<input type='hidden' name='knowbaseitems_id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td width='100px'>";
         $types = array('Entity', 'Group', 'Profile', 'User');
         $addrand = Dropdown::showItemTypes('_type', $types);
         $params = array('type' => '__VALUE__', 'right' => $this->getField('is_faq') ? 'faq' : 'knowbase');
         Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params);
         echo "</td>";
         echo "<td><span id='visibility{$rand}'></span>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('delete' => _x('button', 'Delete permanently')));
         if ($this->fields['users_id'] != Session::getLoginUserID()) {
             $massiveactionparams['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         }
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     $header_begin = "<tr>";
     $header_top = '';
     $header_bottom = '';
     $header_end = '';
     if ($canedit && $nb) {
         $header_begin .= "<th width='10'>";
         $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
         $header_end .= "</th>";
     }
     $header_end .= "<th>" . __('Type') . "</th>";
     $header_end .= "<th>" . _n('Recipient', 'Recipients', Session::getPluralNumber()) . "</th>";
     $header_end .= "</tr>";
     echo $header_begin . $header_top . $header_end;
     // Users
     if (count($this->users)) {
         foreach ($this->users as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('KnowbaseItem_User', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('User') . "</td>";
                 echo "<td>" . getUserName($data['users_id']) . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Groups
     if (count($this->groups)) {
         foreach ($this->groups as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('Group_KnowbaseItem', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('Group') . "</td>";
                 echo "<td>";
                 $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1);
                 $groupname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['entities_id'] >= 0) {
                     $groupname = sprintf(__('%1$s / %2$s'), $groupname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         $groupname = sprintf(__('%1$s %2$s'), $groupname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo $groupname;
                 echo "</td>";
                 echo "</tr>";
             }
         }
     }
     // Entity
     if (count($this->entities)) {
         foreach ($this->entities as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('Entity_KnowbaseItem', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . __('Entity') . "</td>";
                 echo "<td>";
                 $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1);
                 $entityname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['is_recursive']) {
                     $entityname = sprintf(__('%1$s %2$s'), $entityname, "<span class='b'>(" . __('R') . ")</span>");
                 }
                 echo $entityname;
                 echo "</td>";
                 echo "</tr>";
             }
         }
     }
     // Profiles
     if (count($this->profiles)) {
         foreach ($this->profiles as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_1'>";
                 if ($canedit) {
                     echo "<td>";
                     Html::showMassiveActionCheckBox('KnowbaseItem_Profile', $data["id"]);
                     echo "</td>";
                 }
                 echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>";
                 echo "<td>";
                 $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1);
                 $profilename = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['entities_id'] >= 0) {
                     $profilename = sprintf(__('%1$s / %2$s'), $profilename, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         $profilename = sprintf(__('%1$s %2$s'), $profilename, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo $profilename;
                 echo "</td>";
                 echo "</tr>";
             }
         }
     }
     if ($nb) {
         echo $header_begin . $header_bottom . $header_end;
     }
     echo "</table>";
     if ($canedit && $nb) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
コード例 #9
0
ファイル: reservation.class.php プロジェクト: btry/glpi
 /**
  * Display a reservation
  *
  * @param $ID     ID a the reservation item
  * @param $date   date to display
  **/
 static function displayReservationsForAnItem($ID, $date)
 {
     global $DB;
     $users_id = Session::getLoginUserID();
     $resa = new self();
     $user = new User();
     list($year, $month, $day) = explode("-", $date);
     $debut = $date . " 00:00:00";
     $fin = $date . " 23:59:59";
     $query = "SELECT *\n                FROM `glpi_reservations`\n                WHERE '" . $debut . "' < `end`\n                      AND '" . $fin . "' > `begin`\n                      AND `reservationitems_id` = '{$ID}'\n                ORDER BY `begin`";
     if ($result = $DB->query($query)) {
         if ($DB->numrows($result) > 0) {
             echo "<table width='100%'>";
             while ($row = $DB->fetch_assoc($result)) {
                 echo "<tr>";
                 $user->getFromDB($row["users_id"]);
                 $display = "";
                 if ($debut > $row['begin']) {
                     $heure_debut = "00:00";
                 } else {
                     $heure_debut = get_hour_from_sql($row['begin']);
                 }
                 if ($fin < $row['end']) {
                     $heure_fin = "24:00";
                 } else {
                     $heure_fin = get_hour_from_sql($row['end']);
                 }
                 if (strcmp($heure_debut, "00:00") == 0 && strcmp($heure_fin, "24:00") == 0) {
                     $display = __('Day');
                 } else {
                     if (strcmp($heure_debut, "00:00") == 0) {
                         $display = sprintf(__('To %s'), $heure_fin);
                     } else {
                         if (strcmp($heure_fin, "24:00") == 0) {
                             $display = sprintf(__('From %s'), $heure_debut);
                         } else {
                             $display = $heure_debut . "-" . $heure_fin;
                         }
                     }
                 }
                 $rand = mt_rand();
                 $modif = $modif_end = "";
                 if ($resa->canEdit($row['id'])) {
                     $modif = "<a id='content_" . $ID . $rand . "'\n                                  href='reservation.form.php?id=" . $row['id'] . "'>";
                     $modif_end = "</a>";
                     $modif_end .= Html::showToolTip($row["comment"], array('applyto' => "content_" . $ID . $rand, 'display' => false));
                 }
                 echo "<td class='tab_resa center'>" . $modif . "<span>" . $display . "<br><span class='b'>" . formatUserName($user->fields["id"], $user->fields["name"], $user->fields["realname"], $user->fields["firstname"]);
                 echo "</span></span>";
                 echo $modif_end;
                 echo "</td></tr>\n";
             }
             echo "</table>\n";
         }
     }
 }
コード例 #10
0
 /**
  * Display a connection of a networking port
  *
  * @param $netport      to be displayed
  * @param $edit         boolean permit to edit ? (false by default)
  **/
 static function showConnection($netport, $edit = false)
 {
     $ID = $netport->fields["id"];
     if (empty($ID)) {
         return false;
     }
     $device1 = $netport->getItem();
     if (!$device1->can($device1->getID(), READ)) {
         return false;
     }
     $canedit = $device1->canEdit($device1->fields["id"]);
     $relations_id = 0;
     $oppositePort = NetworkPort_NetworkPort::getOpposite($netport, $relations_id);
     if ($oppositePort !== false) {
         $device2 = $oppositePort->getItem();
         if ($device2->can($device2->fields["id"], READ)) {
             $networklink = $oppositePort->getLink();
             $tooltip = Html::showToolTip($oppositePort->fields['comment'], array('display' => false));
             $netlink = sprintf(__('%1$s %2$s'), "<span class='b'>" . $networklink . "</span>\n", $tooltip);
             //TRANS: %1$s and %2$s are links
             echo "&nbsp;" . sprintf(__('%1$s on %2$s'), $netlink, "<span class='b'>" . $device2->getLink() . "</span>");
             if ($device1->fields["entities_id"] != $device2->fields["entities_id"]) {
                 echo "<br>(" . Dropdown::getDropdownName("glpi_entities", $device2->getEntityID()) . ")";
             }
             // write rights on dev1 + READ on dev2 OR READ on dev1 + write rights on dev2
             if ($canedit || $device2->canEdit($device2->fields["id"])) {
                 echo "&nbsp;";
                 Html::showSimpleForm($oppositePort->getFormURL(), 'disconnect', _x('button', 'Disconnect'), array('id' => $relations_id));
             }
         } else {
             if (rtrim($oppositePort->fields["name"]) != "") {
                 $netname = $oppositePort->fields["name"];
             } else {
                 $netname = __('Without name');
             }
             printf(__('%1$s on %2$s'), "<span class='b'>" . $netname . "</span>", "<span class='b'>" . $device2->getName() . "</span>");
             echo "<br>(" . Dropdown::getDropdownName("glpi_entities", $device2->getEntityID()) . ")";
         }
     } else {
         echo "<div id='not_connected_display{$ID}'>" . __('Not connected.') . "</div>";
         if ($canedit) {
             if (!$device1->isTemplate()) {
                 if ($edit) {
                     self::dropdownConnect($ID, array('name' => 'NetworkPortConnect_networkports_id_2', 'entity' => $device1->fields["entities_id"], 'entity_sons' => $device1->isRecursive()));
                 } else {
                     echo "<a href=\"" . $netport->getFormURL() . "?id={$ID}\">" . _x('button', 'Connect') . "</a>";
                 }
             } else {
                 echo "&nbsp;";
             }
         }
     }
 }
コード例 #11
0
ファイル: display.class.php プロジェクト: geldarr/hack-space
 static function displayLine($data, $displayhost = 1)
 {
     global $DB, $CFG_GLPI;
     $pMonitoringService = new PluginMonitoringService();
     $networkPort = new NetworkPort();
     $pMonitoringComponent = new PluginMonitoringComponent();
     $pmComponentscatalog_Host = new PluginMonitoringComponentscatalog_Host();
     $entity = new Entity();
     $pMonitoringService->getFromDB($data['id']);
     echo "<td width='32' class='center'>";
     $shortstate = self::getState($data['state'], $data['state_type'], $data['event'], $data['is_acknowledged']);
     $alt = __('Ok', 'monitoring');
     if ($shortstate == 'orange') {
         $alt = __('Warning (data)', 'monitoring');
     } else {
         if ($shortstate == 'yellow') {
             $alt = __('Warning (connection)', 'monitoring');
         } else {
             if ($shortstate == 'red') {
                 $alt = __('Critical', 'monitoring');
             } else {
                 if ($shortstate == 'redblue') {
                     $alt = __('Critical / Acknowledge', 'monitoring');
                 }
             }
         }
     }
     echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/box_" . $shortstate . "_32.png'\n         title='" . $alt . "' alt='" . $alt . "' />";
     echo "</td>";
     echo "<td>";
     $entity->getFromDB($data['entities_id']);
     echo $entity->fields['completename'];
     echo "</td>";
     $pMonitoringComponent->getFromDB($data['plugin_monitoring_components_id']);
     echo "<td class='center'>";
     $timezone = '0';
     if (isset($_SESSION['plugin_monitoring_timezone'])) {
         $timezone = $_SESSION['plugin_monitoring_timezone'];
     }
     if ($pMonitoringComponent->fields['graph_template'] != '') {
         echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/display.form.php?itemtype=PluginMonitoringService&items_id=" . $data['id'] . "'>";
         $pmServicegraph = new PluginMonitoringServicegraph();
         ob_start();
         $pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'], "PluginMonitoringService", $data['id'], "0", '2h', "div", "600");
         $div = ob_get_contents();
         ob_end_clean();
         $chart = "<table width='600' class='tab_cadre'><tr><td>" . $div . "</td></tr></table>";
         Html::showToolTip($chart, array('img' => $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/stats_32.png"));
         $pmServicegraph->displayGraph($pMonitoringComponent->fields['graph_template'], "PluginMonitoringService", $data['id'], "0", '2h', "js");
     }
     echo "</a>";
     echo "</td>";
     if ($displayhost == '1') {
         $pmComponentscatalog_Host->getFromDB($data["plugin_monitoring_componentscatalogs_hosts_id"]);
         if (isset($pmComponentscatalog_Host->fields['itemtype']) and $pmComponentscatalog_Host->fields['itemtype'] != '') {
             $itemtype = $pmComponentscatalog_Host->fields['itemtype'];
             $item = new $itemtype();
             $item->getFromDB($pmComponentscatalog_Host->fields['items_id']);
             echo "<td>";
             echo $item->getTypeName() . " : " . $item->getLink();
             if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
                 $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
                 echo " [" . $networkPort->getLink() . "]";
             }
             echo "</td>";
         } else {
             echo "<td>" . __('Resources', 'monitoring') . "</td>";
         }
     }
     echo "<td>" . $pMonitoringComponent->getLink();
     if (!is_null($pMonitoringService->fields['networkports_id']) and $pMonitoringService->fields['networkports_id'] > 0) {
         $networkPort->getFromDB($pMonitoringService->fields['networkports_id']);
         echo " [" . $networkPort->getLink() . "]";
     }
     echo "</td>";
     //      $nameitem = '';
     //      if (isset($itemmat->fields['name'])) {
     //         $nameitem = "[".$itemmat->getLink(1)."]";
     //      }
     //if ($pMonitoringService->fields['plugin_monitoring_services_id'] == '0') {
     //echo "<td>".$itemmat->getLink(1)."</td>";
     //      } else {
     //         $pMonitoringServiceH->getFromDB($pMonitoringService->fields['plugin_monitoring_services_id']);
     //         $itemtypemat = $pMonitoringServiceH->fields['itemtype'];
     //         $itemmat = new $itemtypemat();
     //         $itemmat->getFromDB($pMonitoringServiceH->fields['items_id']);
     //         echo "<td>".$pMonitoringService->getLink(1).$nameitem." ".__('on', 'monitoring')." ".$itemmat->getLink(1)."</td>";
     //      }
     //      unset($itemmat);
     echo "<td class='center'>";
     if ($shortstate == 'red') {
         echo "<table>";
         echo "<tr>";
         echo "<td>";
         echo $data['state'];
         echo "</td>";
         echo "<td>";
         echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/acknowledge.form.php?id=" . $data['id'] . "'>" . "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/acknowledge_checked.png'" . " alt='" . __('Define an acknowledge', 'monitoring') . "'" . " title='" . __('Define an acknowledge', 'monitoring') . "'/>" . "</a>";
         echo "</td>";
         echo "</tr>";
         echo "</table>";
     } else {
         echo $data['state'];
     }
     echo "</td>";
     echo "<td>";
     echo Html::convDate($data['last_check']) . ' ' . substr($data['last_check'], 11, 8);
     echo "</td>";
     echo "<td>";
     echo $data['event'];
     echo "</td>";
     echo "<td align='center'>";
     $segments = CalendarSegment::getSegmentsBetween($pMonitoringComponent->fields['calendars_id'], date('w', date('U')), date('H:i:s'), date('w', date('U')), date('H:i:s'));
     if (count($segments) == '0') {
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_pause.png' />";
     } else {
         echo "<img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/service_run.png' />";
     }
     echo "</td>";
     if ($displayhost == '0') {
         $pmUnavaibility = new PluginMonitoringUnavaibility();
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentmonth', 1);
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'lastmonth', 1);
         $pmUnavaibility->displayValues($pMonitoringService->fields['id'], 'currentyear', 1);
         echo "<td class='center'>";
         echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/unavaibility.php?" . "field[0]=2&searchtype[0]=equals&contains[0]=" . $pMonitoringService->fields['id'] . "&sort=3&order=DESC&itemtype=PluginMonitoringUnavaibility'>\n            <img src='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/pics/info.png'/></a>";
         echo "</td>";
     }
     echo "<td>";
     if ($shortstate == 'redblue') {
         echo "<i>" . _n('User', 'Users', 1) . " : </i>";
         $user = new User();
         $user->getFromDB($data['acknowledge_users_id']);
         echo $user->getName(1);
         echo "<br/>";
         echo "<i>" . __('Comments') . " : </i>" . $data['acknowledge_comment'];
     }
     echo "</td>";
     if ($displayhost == '0') {
         echo "<td>";
         if (PluginMonitoringProfile::haveRight("componentscatalog", 'w')) {
             $a_arg = importArrayFromDB($pMonitoringService->fields['arguments']);
             $cnt = '';
             if (count($a_arg) > 0) {
                 $cnt = " (" . count($a_arg) . ")";
             }
             echo "<a href='" . $CFG_GLPI['root_doc'] . "/plugins/monitoring/front/servicearg.form.php?id=" . $data['id'] . "'>" . __('Configure', 'monitoring') . $cnt . "</a>";
         }
         echo "</td>";
     }
 }
コード例 #12
0
ファイル: config.class.php プロジェクト: glpi-project/glpi
 /**
  * Print the config form for External API
  *
  * @since 9.1
  * @return Nothing (display)
  **/
 function showFormAPI()
 {
     global $DB, $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     echo "<div class='center spaced' id='tabsbody'>";
     $canedit = Config::canUpdate();
     if ($canedit) {
         echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     }
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('API') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('URL of the API') . "</td>";
     echo "<td colspan='3'><input type='text' name='url_base_api' size='80' value='" . $CFG_GLPI["url_base_api"] . "'></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __("Enable Rest API") . "</td>";
     echo "<td>";
     Dropdown::showYesNo("enable_api", $CFG_GLPI["enable_api"]);
     echo "</td>";
     if ($CFG_GLPI["enable_api"]) {
         echo "<td colspan='2'>";
         $inline_doc_api = trim($CFG_GLPI['url_base_api'], '/') . "/";
         echo "<a href='{$inline_doc_api}'>" . __("API inline Documentation") . "</a>";
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr><th colspan='4'>" . __('Authentication') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>";
     echo __("Enable login with credentials") . "&nbsp;";
     Html::showToolTip(__("Allow to login to api and get a session token with user credentials"));
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("enable_api_login_credentials", $CFG_GLPI["enable_api_login_credentials"]);
     echo "</td>";
     echo "<td>";
     echo __("Enable login with external token") . "&nbsp;";
     Html::showToolTip(__("Allow to login to api and get a session token with user external token. See Remote access key in user Settings tab "));
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("enable_api_login_external_token", $CFG_GLPI["enable_api_login_external_token"]);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
     echo "<br><br><br>";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><td>";
     echo "<hr>";
     $buttons["apiclient.form.php"] = __('Add API client');
     $title = "";
     Html::displayTitle("", self::getTypeName(Session::getPluralNumber()), "", $buttons);
     Search::show("APIClient");
     echo "</td></tr>";
     echo "</table></div>";
 }
コード例 #13
0
ファイル: host.class.php プロジェクト: euqip/glpi-smartcities
   /**
    * Get comments for host
    * $id, host id
    *    default is current host instance
    *
    */
   function getComments($id=-1) {
      global $CFG_GLPI;

      if ($id == -1) {
         $pm_Host = $this;
      } else {
         $pm_Host = new PluginMonitoringHost();
         $pm_Host->getFromDB($id);
      }

      // Toolbox::logInFile("pm", "Host getcomments : $id : ".$pm_Host->getID()."\n");
      $comment = "";
      $toadd   = array();

      // associated computer ...
      $item = new $pm_Host->fields['itemtype'];
      $item->getFromDB($pm_Host->fields['items_id']);

      if ($pm_Host->getField('itemtype') == 'Computer') {
         if ($item->isField('completename')) {
            $toadd[] = array('name'  => __('Complete name'),
                             'value' => nl2br($item->getField('completename')));
         }

         $type = new ComputerType();
         if ($item->getField("computertypes_id")) {
            $type->getFromDB($item->getField("computertypes_id"));
            $type = $type->getName();
            if (! empty($type)) {
               $toadd[] = array('name'  => __('Type'),
                                'value' => nl2br($type));
            }
         } else {
            return $comment;
         }

         $model = new ComputerModel();
         if ($item->getField("computermodels_id")) {
            $model->getFromDB($item->getField("computermodels_id"));
            $model = $model->getName();
            if (! empty($model)) {
               $toadd[] = array('name'  => __('Model'),
                                'value' => nl2br($model));
            }
         }

         $state = new State();
         $state->getFromDB($item->fields["states_id"]);
         $state = $state->getName();
         if (! empty($state)) {
            $toadd[] = array('name'  => __('State'),
                             'value' => nl2br($state));
         }

         $entity = new Entity();
         $entity->getFromDB($item->fields["entities_id"]);
         $entity = $entity->getName();
         if (! empty($entity)) {
            $toadd[] = array('name'  => __('Entity'),
                             'value' => nl2br($entity));
         }

         $location = new Location();
         $location->getFromDB($item->fields["locations_id"]);
         $location = $location->getName(array('complete'  => true));
         if (! empty($location)) {
            $toadd[] = array('name'  => __('Location'),
                             'value' => nl2br($location));
         }

         if (! empty($item->fields["serial"])) {
            $toadd[] = array('name'  => __('Serial'),
                             'value' => nl2br($item->fields["serial"]));
         }
         if (! empty($item->fields["otherserial"])) {
            $toadd[] = array('name'  => __('Inventory number'),
                             'value' => nl2br($item->fields["otherserial"]));
         }

         if (($pm_Host instanceof CommonDropdown)
             && $pm_Host->isField('comment')) {
            $toadd[] = array('name'  => __('Comments'),
                             'value' => nl2br($pm_Host->getField('comment')));
         }

         if (count($toadd)) {
            foreach ($toadd as $data) {
               $comment .= sprintf(__('%1$s: %2$s')."<br>",
                                   "<span class='b'>".$data['name'], "</span>".$data['value']);
            }
         }
      } else {
         $toadd[] = array('name'  => __('Host type'),
                          'value' => nl2br($item->getTypeName()));

         if ($item->isField('completename')) {
            $toadd[] = array('name'  => __('Complete name'),
                             'value' => nl2br($item->getField('completename')));
         }
      }

      if (!empty($comment)) {
         return Html::showToolTip($comment, array('display' => false));
      }
   }
コード例 #14
0
 /**
  * Display a Planning Item
  *
  * @param $itemtype  itemtype
  * @param $val       Array of the item to display
  * @param $who             ID of the user (0 if all)
  * @param $type            position of the item in the time block (in, through, begin or end)
  *                         (default '')
  * @param $complete        complete display (more details) (default 0)
  *
  * @return Nothing (display function)
  **/
 static function genericDisplayPlanningItem($itemtype, array $val, $who, $type = "", $complete = 0)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     $styleText = "";
     if (isset($val["state"])) {
         switch ($val["state"]) {
             case 2:
                 // Done
                 $styleText = "color:#747474;";
                 break;
         }
     }
     $parenttype = str_replace('Task', '', $itemtype);
     if ($parent = getItemForItemtype($parenttype)) {
         $parenttype_fk = $parent->getForeignKeyField();
     } else {
         return;
     }
     echo "<img src='" . $CFG_GLPI["root_doc"] . "/pics/rdv_interv.png' alt='' title=\"" . Html::entities_deep($parent->getTypeName(1)) . "\">&nbsp;&nbsp;";
     echo "<img src='" . $parent->getStatusIconURL($val["status"]) . "' alt='" . Html::entities_deep($parent->getStatus($val["status"])) . "' title=\"" . Html::entities_deep($parent->getStatus($val["status"])) . "\">";
     echo "&nbsp;<a id='content_tracking_" . $val["id"] . $rand . "'\n                   href='" . Toolbox::getItemTypeFormURL($parenttype) . "?id=" . $val[$parenttype_fk] . "'\n                   style='{$styleText}'>";
     switch ($type) {
         case "in":
             //TRANS: %1$s is the start time of a planned item, %2$s is the end
             printf(__('From %1$s to %2$s :'), date("H:i", strtotime($val["begin"])), date("H:i", strtotime($val["end"])));
             break;
         case "through":
             break;
         case "begin":
             //TRANS: %s is the start time of a planned item
             printf(__('Start at %s:'), date("H:i", strtotime($val["begin"])));
             break;
         case "end":
             //TRANS: %s is the end time of a planned item
             printf(__('End at %s:'), date("H:i", strtotime($val["end"])));
             break;
     }
     echo "<br>";
     //TRANS: %1$s is name of the item, %2$d is its ID
     printf(__('%1$s (#%2$d)'), Html::resume_text($val["name"], 80), $val[$parenttype_fk]);
     if (!empty($val["device"])) {
         echo "<br>" . $val["device"];
     }
     if ($who <= 0) {
         // show tech for "show all and show group"
         echo "<br>";
         //TRANS: %s is user name
         printf(__('By %s'), getUserName($val["users_id_tech"]));
     }
     echo "</a>";
     $recall = '';
     if (isset($val[getForeignKeyFieldForItemType($itemtype)]) && PlanningRecall::isAvailable()) {
         $pr = new PlanningRecall();
         if ($pr->getFromDBForItemAndUser($val['itemtype'], $val[getForeignKeyFieldForItemType($itemtype)], Session::getLoginUserID())) {
             $recall = "<br><span class='b'>" . sprintf(__('Recall on %s'), Html::convDateTime($pr->fields['when'])) . "<span>";
         }
     }
     if ($complete) {
         echo "<br><span class='b'>";
         if (isset($val["state"])) {
             echo Planning::getState($val["state"]) . "<br>";
         }
         echo sprintf(__('%1$s: %2$s'), __('Priority'), $parent->getPriorityName($val["priority"]));
         echo "<br>" . __('Description') . "</span><br>" . $val["content"];
         echo $recall;
     } else {
         $content = "<span class='b'>";
         if (isset($val["state"])) {
             $content .= Planning::getState($val["state"]) . "<br>";
         }
         $content .= sprintf(__('%1$s: %2$s'), __('Priority'), $parent->getPriorityName($val["priority"])) . "<br>" . __('Description') . "</span><br>" . $val["content"] . $recall;
         Html::showToolTip($content, array('applyto' => "content_tracking_" . $val["id"] . $rand));
     }
 }
コード例 #15
0
ファイル: survey.class.php プロジェクト: geldarr/hack-space
 function displaySurvey($questions_id)
 {
     global $CFG_GLPI;
     $psQuestion = new PluginSurveyticketQuestion();
     if ($psQuestion->getFromDB($questions_id)) {
         echo "<table class='tab_cadre' align='left' width='700' >";
         echo "<tr class='tab_bg_1'>";
         echo "<th colspan='3'>";
         echo $psQuestion->fields['name'];
         echo "&nbsp;";
         Html::showToolTip($psQuestion->fields['comment']);
         echo "</th>";
         echo "</tr>";
         $nb_answer = $this->displayAnswers($questions_id);
         echo "</table>";
         if ($psQuestion->fields['type'] == 'radio' || $psQuestion->fields['type'] == 'yesno') {
             $event = array("click");
             $a_ids = array();
             for ($i = 0; $i < $nb_answer; $i++) {
                 //array_push($a_ids, 'question'.$questions_id."_".$i);
                 $a_ids[] = 'question' . $questions_id . "-" . $i;
             }
             $params = array("question" . $questions_id => '__VALUE__', 'rand' => $questions_id, 'myname' => "question" . $questions_id);
         } else {
             if ($psQuestion->fields['type'] == 'date') {
                 $event = array("change");
                 $a_ids = "realquestion" . $questions_id;
                 $params = array("realquestion" . $questions_id => '__VALUE__', 'rand' => $questions_id, 'myname' => "realquestion" . $questions_id);
             } else {
                 if ($psQuestion->fields['type'] == 'input') {
                     $event = array("change");
                     $a_ids = "realquestion" . $questions_id;
                     $params = array("realquestion" . $questions_id => '__VALUE__', 'rand' => $questions_id, 'myname' => "realquestion" . $questions_id);
                 } else {
                     $event = array("change");
                     $a_ids = 'question' . $questions_id;
                     $params = array("question" . $questions_id => '__VALUE__', 'rand' => $questions_id, 'myname' => "question" . $questions_id);
                 }
             }
         }
         if ($psQuestion->fields['type'] == 'date' || $psQuestion->fields['type'] == 'input') {
             echo "<script type='text/javascript'>";
             Ajax::updateItemJsCode("nextquestion" . $questions_id, $CFG_GLPI["root_doc"] . "/plugins/surveyticket/ajax/displaysurvey.php", $params, $a_ids);
             echo "</script>";
         } else {
             self::UpdateItemOnSelectEvent($a_ids, "nextquestion" . $questions_id, $CFG_GLPI["root_doc"] . "/plugins/surveyticket/ajax/displaysurvey.php", $params, $event);
         }
         echo "<br/><div id='nextquestion" . $questions_id . "'></div>";
     }
 }
コード例 #16
0
ファイル: problem.class.php プロジェクト: gaforeror/glpi
 /**
  * @param $id
  * @param $output_type        (default Search::HTML_OUTPUT)
  * @param $row_num            (default 0)
  * @param $id_for_massaction  (default -1)
  */
 static function showShort($id, $output_type = Search::HTML_OUTPUT, $row_num = 0, $id_for_massaction = -1)
 {
     global $CFG_GLPI;
     $rand = mt_rand();
     /// TODO to be cleaned. Get datas and clean display links
     // Prints a job in short form
     // Should be called in a <table>-segment
     // Print links or not in case of user view
     // Make new job object and fill it from database, if success, print it
     $job = new self();
     // If id is specified it will be used as massive aciton id
     // Used when displaying ticket and wanting to delete a link data
     if ($id_for_massaction == -1) {
         $id_for_massaction = $id;
     }
     $candelete = Session::haveRight("edit_all_problem", "1");
     $canupdate = Session::haveRight("edit_all_problem", "1");
     $showprivate = Session::haveRight("show_all_problem", "1");
     $align = "class='center'";
     $align_desc = "class='left'";
     if ($job->getFromDB($id)) {
         $item_num = 1;
         $bgcolor = $_SESSION["glpipriority_" . $job->fields["priority"]];
         echo Search::showNewLine($output_type, $row_num % 2);
         $check_col = '';
         if (($candelete || $canupdate) && $output_type == Search::HTML_OUTPUT) {
             $check_col = Html::getMassiveActionCheckBox(__CLASS__, $id_for_massaction);
         }
         echo Search::showItem($output_type, $check_col, $item_num, $row_num, $align);
         // First column
         $first_col = sprintf(__('%1$s: %2$s'), __('ID'), $job->fields["id"]);
         if ($output_type == Search::HTML_OUTPUT) {
             $first_col .= "<br><img src='" . self::getStatusIconURL($job->fields["status"]) . "'\n                           alt=\"" . self::getStatus($job->fields["status"]) . "\" title=\"" . self::getStatus($job->fields["status"]) . "\">";
         } else {
             $first_col = sprintf(__('%1$s - %2$s'), $first_col, self::getStatus($job->fields["status"]));
         }
         echo Search::showItem($output_type, $first_col, $item_num, $row_num, $align);
         // Second column
         if ($job->fields['status'] == self::CLOSED) {
             $second_col = sprintf(__('Closed on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['closedate']));
         } else {
             if ($job->fields['status'] == self::SOLVED) {
                 $second_col = sprintf(__('Solved on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['solvedate']));
             } else {
                 if ($job->fields['due_date']) {
                     $second_col = sprintf(__('%1$s: %2$s'), __('Due date'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['due_date']));
                 } else {
                     $second_col = sprintf(__('Opened on %s'), ($output_type == Search::HTML_OUTPUT ? '<br>' : '') . Html::convDateTime($job->fields['date']));
                 }
             }
         }
         echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=130");
         // Second BIS column
         $second_col = Html::convDateTime($job->fields["date_mod"]);
         echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=90");
         // Second TER column
         if (count($_SESSION["glpiactiveentities"]) > 1) {
             $second_col = Dropdown::getDropdownName('glpi_entities', $job->fields['entities_id']);
             echo Search::showItem($output_type, $second_col, $item_num, $row_num, $align . " width=100");
         }
         // Third Column
         echo Search::showItem($output_type, "<span class='b'>" . parent::getPriorityName($job->fields["priority"]) . "</span>", $item_num, $row_num, "{$align} bgcolor='{$bgcolor}'");
         // Fourth Column
         $fourth_col = "";
         if (isset($job->users[CommonITILActor::REQUESTER]) && count($job->users[CommonITILActor::REQUESTER])) {
             foreach ($job->users[CommonITILActor::REQUESTER] as $d) {
                 $userdata = getUserName($d["users_id"], 2);
                 $fourth_col .= "<span class='b'>" . $userdata['name'] . "</span>";
                 $fourth_col = sprintf(__('%1$s %2$s') . "<br>", $fourth_col, Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
             }
         }
         if (isset($job->groups[CommonITILActor::REQUESTER]) && count($job->groups[CommonITILActor::REQUESTER])) {
             foreach ($job->groups[CommonITILActor::REQUESTER] as $d) {
                 $fourth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
                 $fourth_col .= "<br>";
             }
         }
         echo Search::showItem($output_type, $fourth_col, $item_num, $row_num, $align);
         // Fifth column
         $fifth_col = "";
         if (isset($job->users[CommonITILActor::ASSIGN]) && count($job->users[CommonITILActor::ASSIGN])) {
             foreach ($job->users[CommonITILActor::ASSIGN] as $d) {
                 $userdata = getUserName($d["users_id"], 2);
                 $fifth_col .= "<span class='b'>" . $userdata['name'] . "</span>";
                 $fifth_col = sprintf(__('%1$s %2$s') . "<br>", $fifth_col, Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
             }
         }
         if (isset($job->groups[CommonITILActor::ASSIGN]) && count($job->groups[CommonITILActor::ASSIGN])) {
             foreach ($job->groups[CommonITILActor::ASSIGN] as $d) {
                 $fifth_col .= Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
                 $fifth_col .= "<br>";
             }
         }
         if (isset($job->suppliers[CommonITILActor::ASSIGN]) && count($job->suppliers[CommonITILActor::ASSIGN])) {
             foreach ($job->suppliers[CommonITILActor::ASSIGN] as $d) {
                 $fifth_col .= Dropdown::getDropdownName("glpi_suppliers", $d["suppliers_id"]);
                 $fifth_col .= "<br>";
             }
         }
         echo Search::showItem($output_type, $fifth_col, $item_num, $row_num, $align);
         // Sixth Colum
         // Seventh column
         echo Search::showItem($output_type, "<span class='b'>" . Dropdown::getDropdownName('glpi_itilcategories', $job->fields["itilcategories_id"]) . "</span>", $item_num, $row_num, $align);
         // Eigth column
         $eigth_column = "<span class='b'>" . $job->fields["name"] . "</span>&nbsp;";
         // Add link
         if ($job->canViewItem()) {
             $eigth_column = "<a id='problem" . $job->fields["id"] . "{$rand}' href=\"" . $CFG_GLPI["root_doc"] . "/front/problem.form.php?id=" . $job->fields["id"] . "\">{$eigth_column}</a>";
             if ($output_type == Search::HTML_OUTPUT) {
                 $eigth_column = sprintf(__('%1$s (%2$s)'), $eigth_column, $job->numberOfTasks($showprivate));
             }
         }
         if ($output_type == Search::HTML_OUTPUT) {
             $eigth_column = sprintf(__('%1$s %2$s'), $eigth_column, Html::showToolTip($job->fields['content'], array('display' => false, 'applyto' => "ticket" . $job->fields["id"] . $rand)));
         }
         echo Search::showItem($output_type, $eigth_column, $item_num, $row_num, $align_desc . "width='300'");
         // Finish Line
         echo Search::showEndLine($output_type);
     } else {
         echo "<tr class='tab_bg_2'><td colspan='6'><i>" . __('No problem in progress.') . "</i></td></tr>";
     }
 }
コード例 #17
0
ファイル: reminder.class.php プロジェクト: gaforeror/glpi
 /**
  * Show visibility config for a reminder
  **/
 function showVisibility()
 {
     global $DB, $CFG_GLPI;
     $ID = $this->fields['id'];
     $canedit = Session::haveRight('reminder_public', 'w');
     echo "<div class='center'>";
     $rand = mt_rand();
     $nb = count($this->users) + count($this->groups) + count($this->profiles) + count($this->entities);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='remindervisibility_form{$rand}' id='remindervisibility_form{$rand}' ";
         echo " method='post' action='" . Toolbox::getItemTypeFormURL('Reminder') . "'>";
         echo "<input type='hidden' name='reminders_id' value='{$ID}'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Add a target') . "</tr>";
         echo "<tr class='tab_bg_2'><td width='100px'>";
         $types = array('Entity', 'Group', 'Profile', 'User');
         $addrand = Dropdown::showItemTypes('_type', $types);
         $params = array('type' => '__VALUE__', 'right' => 'reminder_public');
         Ajax::updateItemOnSelectEvent("dropdown__type" . $addrand, "visibility{$rand}", $CFG_GLPI["root_doc"] . "/ajax/visibility.php", $params);
         echo "</td>";
         echo "<td><span id='visibility{$rand}'></span>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $nb) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $paramsma = array('num_displayed' => $nb, 'specific_actions' => array('deletevisibility' => _x('button', 'Delete permanently')));
         if ($this->fields['users_id'] != Session::getLoginUserID()) {
             $paramsma['confirm'] = __('Caution! You are not the author of this element. Delete targets can result in loss of access to that element.');
         }
         Html::showMassiveActions(__CLASS__, $paramsma);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $nb) {
         echo "<th width='10'>";
         echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Type') . "</th>";
     echo "<th>" . _n('Recipient', 'Recipients', 2) . "</th>";
     echo "</tr>";
     // Users
     if (count($this->users)) {
         foreach ($this->users as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Reminder_User][" . $data["id"] . "]'\n                          value='1' >";
                     echo "</td>";
                 }
                 echo "<td>" . __('User') . "</td>";
                 echo "<td>" . getUserName($data['users_id']) . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Groups
     if (count($this->groups)) {
         foreach ($this->groups as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Group_Reminder][" . $data["id"] . "]'\n                         value='1'>";
                     echo "</td>";
                 }
                 echo "<td>" . __('Group') . "</td>";
                 $names = Dropdown::getDropdownName('glpi_groups', $data['groups_id'], 1);
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], Html::showToolTip($names["comment"], array('display' => false)));
                 if ($data['entities_id'] >= 0) {
                     $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         //TRANS: R for Recursive
                         sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Entity
     if (count($this->entities)) {
         foreach ($this->entities as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Entity_Reminder][" . $data["id"] . "]'\n                          value='1'>";
                     echo "</td>";
                 }
                 echo "<td>" . __('Entity') . "</td>";
                 $names = Dropdown::getDropdownName('glpi_entities', $data['entities_id'], 1);
                 $tooltip = Html::showToolTip($names["comment"], array('display' => false));
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], $tooltip);
                 if ($data['is_recursive']) {
                     $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     // Profiles
     if (count($this->profiles)) {
         foreach ($this->profiles as $key => $val) {
             foreach ($val as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>";
                     echo "<input type='checkbox' name='item[Profile_Reminder][" . $data["id"] . "]'\n                         value='1'>";
                     echo "</td>";
                 }
                 echo "<td>" . _n('Profile', 'Profiles', 1) . "</td>";
                 $names = Dropdown::getDropdownName('glpi_profiles', $data['profiles_id'], 1);
                 $tooltip = Html::showToolTip($names["comment"], array('display' => false));
                 $entname = sprintf(__('%1$s %2$s'), $names["name"], $entname);
                 if ($data['entities_id'] >= 0) {
                     $entname = sprintf(__('%1$s / %2$s'), $entname, Dropdown::getDropdownName('glpi_entities', $data['entities_id']));
                     if ($data['is_recursive']) {
                         $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
                     }
                 }
                 echo "<td>" . $entname . "</td>";
                 echo "</tr>";
             }
         }
     }
     echo "</table>";
     if ($canedit && $nb) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
         Html::closeForm();
     }
     echo "</div>";
     // Add items
     return true;
 }
コード例 #18
0
ファイル: netpoint.class.php プロジェクト: jose-martins/glpi
 /**
  * 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"] != "&nbsp;") {
             $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;
 }
コード例 #19
0
ファイル: search.class.php プロジェクト: jose-martins/glpi
 /**
  * Print generic normal Item Cell
  *
  * @param $type         display type (0=HTML, 1=Sylk,2=PDF,3=CSV)
  * @param $value        value to display
  * @param &$num         column number
  * @param $row          row number
  * @param $extraparam   extra parameters for display (default '')
  *
  *@return string to display
  **/
 static function showItem($type, $value, &$num, $row, $extraparam = '')
 {
     $out = "";
     switch ($type) {
         case self::PDF_OUTPUT_LANDSCAPE:
             //pdf
         //pdf
         case self::PDF_OUTPUT_PORTRAIT:
             global $PDF_TABLE;
             $value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
             $value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
             $PDF_TABLE .= "<td {$extraparam} valign='top'>";
             $PDF_TABLE .= Html::weblink_extract(Html::clean($value));
             $PDF_TABLE .= "</td>\n";
             break;
         case self::SYLK_OUTPUT:
             //sylk
             global $SYLK_ARRAY, $SYLK_HEADER, $SYLK_SIZE;
             $value = Html::weblink_extract($value);
             $value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
             $value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
             $SYLK_ARRAY[$row][$num] = self::sylk_clean($value);
             $SYLK_SIZE[$num] = max($SYLK_SIZE[$num], Toolbox::strlen($SYLK_ARRAY[$row][$num]));
             break;
         case self::CSV_OUTPUT:
             //csv
             $value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
             $value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
             $value = Html::weblink_extract($value);
             $out = "\"" . self::csv_clean($value) . "\"" . $_SESSION["glpicsv_delimiter"];
             break;
         default:
             $out = "<td {$extraparam} valign='top'>";
             if (!preg_match('/' . self::LBHR . '/', $value)) {
                 $values = preg_split('/' . self::LBBR . '/i', $value);
                 $line_delimiter = '<br>';
             } else {
                 $values = preg_split('/' . self::LBHR . '/i', $value);
                 $line_delimiter = '<hr>';
             }
             $limitto = 20;
             if (count($values) > $limitto) {
                 for ($i = 0; $i < $limitto; $i++) {
                     $out .= $values[$i] . $line_delimiter;
                 }
                 //                $rand=mt_rand();
                 $out .= "...&nbsp;";
                 $value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
                 $value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
                 $out .= Html::showToolTip($value, array('display' => false, 'autoclose' => false));
             } else {
                 $value = preg_replace('/' . self::LBBR . '/', '<br>', $value);
                 $value = preg_replace('/' . self::LBHR . '/', '<hr>', $value);
                 $out .= $value;
             }
             $out .= "</td>\n";
     }
     $num++;
     return $out;
 }
コード例 #20
0
ファイル: view.class.php プロジェクト: geldarr/hack-space
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='1'>" . __('Name') . "</td>";
     echo "<td colspan='3'>";
     Html::autocompletionTextField($this, "name", array('size' => 20));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><th colspan='4'>" . __('Display of items', 'archires') . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Computer', 'Computers', 2) . "</td>";
     echo "<td>";
     Dropdown::showYesNo("computer", $this->fields["computer"]);
     echo "</td>";
     echo "<td>" . _n('Network equipment', 'Network equipments', 2, 'archires') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("networking", $this->fields["networking"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Printer', 'Printers', 2) . "</td>";
     echo "<td>";
     Dropdown::showYesNo("printer", $this->fields["printer"]);
     echo "</td>";
     echo "<td>" . _n('Device', 'Devices', 2) . "</td>";
     echo "<td>";
     Dropdown::showYesNo("peripheral", $this->fields["peripheral"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Phone', 'Phones', 2) . "</td>";
     echo "<td colspan='3'>";
     Dropdown::showYesNo("phone", $this->fields["phone"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><th colspan='4'>" . __('Display description', 'archires') . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Display sockets', 'archires') . "</td>";
     echo "<td><select name='display_ports'> ";
     echo "<option ";
     if ($this->fields["display_ports"] == '0') {
         echo "selected ";
     }
     echo "value='0'>" . __('No') . "</option>";
     echo "<option ";
     if ($this->fields["display_ports"] == '1') {
         echo "selected ";
     }
     echo "value='1'>" . __('See numbers', 'archires') . "</option>";
     echo "<option ";
     if ($this->fields["display_ports"] == '2') {
         echo "selected ";
     }
     echo "value='2'>" . __('See names', 'archires') . "</option>";
     echo "</select></td>";
     echo "<td>" . __('Display IP/Mask', 'archires') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("display_ip", $this->fields["display_ip"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Display item types', 'archires') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("display_type", $this->fields["display_type"]);
     echo "</td>";
     echo "<td>" . __('Display item statuses', 'archires') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("display_state", $this->fields["display_state"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Display item locations', 'archires') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("display_location", $this->fields["display_location"]);
     echo "</td>";
     echo "<td>" . __('Display item entities', 'archires') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("display_entity", $this->fields["display_entity"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><th colspan='4'>" . __('Generation', 'archires') . "</th></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Rendering engine', 'archires') . "</td>";
     echo "<td><select name='engine'> ";
     echo "<option ";
     if ($this->fields["engine"] == '0') {
         echo "selected ";
     }
     echo "value='0'>Dot</option>";
     echo "<option ";
     if ($this->fields["engine"] == '1') {
         echo "selected ";
     }
     echo "value='1'>Neato</option>";
     echo "</select>&nbsp;";
     Html::showToolTip(nl2br(__('With neato, the sockets will not be displayed', 'archires')));
     echo "</td>";
     echo "<td>" . __('Image format', 'archires') . "</td>";
     echo "<td><select name='format'> ";
     echo "<option ";
     if ($this->fields["format"] == self::PLUGIN_ARCHIRES_JPEG_FORMAT) {
         echo "selected ";
     }
     echo "value='0'>jpeg</option>";
     echo "<option ";
     if ($this->fields["format"] == self::PLUGIN_ARCHIRES_PNG_FORMAT) {
         echo "selected ";
     }
     echo "value='1'>png</option>";
     echo "<option ";
     if ($this->fields["format"] == self::PLUGIN_ARCHIRES_GIF_FORMAT) {
         echo "selected ";
     }
     echo "value='2'>gif</option>";
     echo "</select></td>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Color', 'archires') . "</td>";
     echo "<td colspan='3'><select name='color'> ";
     echo "<option ";
     if ($this->fields["color"] == '0') {
         echo "selected ";
     }
     echo "value='0'>" . __('Type of network', 'archires') . "</option>";
     echo "<option ";
     if ($this->fields["color"] == '1') {
         echo "selected ";
     }
     echo "value='1'>" . __('VLAN') . "</option>";
     echo "</select></td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
コード例 #21
0
 function displayValues($services_id, $period, $tooltip = 0)
 {
     $a_times = $this->parseEvents($services_id, $period);
     $displaytime = '';
     if ($a_times[0] > 0) {
         echo "<td style='background-color: rgb(255, 120, 0);-moz-border-radius: 4px;-webkit-border-radius: 4px;-o-border-radius: 4px;padding: 2px;' align='center'>";
         if ($tooltip == '1') {
             $displaytime = '&nbsp;' . Html::showToolTip(Html::timestampToString($a_times[0]), array('display' => false));
         } else {
             $displaytime = '<br/>' . Html::timestampToString($a_times[0]);
         }
     } else {
         echo "<td align='center'>";
     }
     echo round(($a_times[1] - $a_times[0]) / $a_times[1] * 100, 3) . "%" . $displaytime;
     echo "</td>";
 }
コード例 #22
0
ファイル: softwarelicense.class.php プロジェクト: kipman/glpi
 /**
  * Print the Software / license form
  *
  * @param $ID        integer  Id of the version or the template to print
  * @param $options   array    of possible options:
  *     - target form target
  *     - softwares_id ID of the software for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $softwares_id = -1;
     if (isset($options['softwares_id'])) {
         $softwares_id = $options['softwares_id'];
     }
     if ($ID < 0) {
         // Create item
         $this->fields['softwares_id'] = $softwares_id;
         $this->fields['number'] = 1;
         $soft = new Software();
         if ($soft->getFromDB($softwares_id) && in_array($_SESSION['glpiactive_entity'], getAncestorsOf('glpi_entities', $soft->getEntityID()))) {
             $options['entities_id'] = $soft->getEntityID();
         }
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . Software::getTypeName(1) . "</td>";
     echo "<td>";
     if ($ID > 0) {
         $softwares_id = $this->fields["softwares_id"];
     } else {
         echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>";
     }
     echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>";
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     SoftwareLicenseType::dropdown(array('value' => $this->fields["softwarelicensetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Purchase version') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdown(array('name' => "softwareversions_id_buy", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_buy"]));
     echo "</td>";
     echo "<td>" . __('Inventory number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "otherserial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version in use') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdown(array('name' => "softwareversions_id_use", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_use"]));
     echo "</td>";
     echo "<td rowspan='" . ($ID > 0 ? '4' : '3') . "' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='" . ($ID > 0 ? '4' : '3') . "'>";
     echo "<textarea cols='45' rows='5' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('quantity', 'Number') . "</td>";
     echo "<td>";
     Dropdown::showNumber("number", array('value' => $this->fields["number"], 'min' => 1, 'max' => 10000, 'step' => 1, 'toadd' => array(-1 => __('Unlimited'))));
     if ($ID > 0) {
         echo "&nbsp;";
         if ($this->fields['is_valid']) {
             echo "<span class='green'>" . _x('adjective', 'Valid') . '<span>';
         } else {
             echo "<span class='red'>" . _x('adjective', 'Invalid') . '<span>';
         }
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration') . "</td>";
     echo "<td>";
     Html::showDateField('expire', array('value' => $this->fields["expire"]));
     if ($ID && is_null($this->fields["expire"])) {
         echo "<br>" . __('Never expire') . "&nbsp;";
         Html::showToolTip(__('On search engine, use "Expiration contains NULL" to search licenses with no expiration date'));
     }
     Alert::displayLastAlert('SoftwareLicense', $ID);
     echo "</td></tr>\n";
     if ($ID > 0) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Last update') . "</td>";
         echo "<td>" . ($this->fields["date_mod"] ? Html::convDateTime($this->fields["date_mod"]) : __('Never'));
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
コード例 #23
0
 /**
  * Print the contract costs
  *
  * @param $contract               Contract object
  * @param $withtemplate  boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForContract(Contract $contract, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     $ID = $contract->fields['id'];
     if (!$contract->getFromDB($ID) || !$contract->can($ID, READ)) {
         return false;
     }
     $canedit = $contract->can($ID, UPDATE);
     echo "<div class='center'>";
     $query = "SELECT *\n                FROM `glpi_contractcosts`\n                WHERE `contracts_id` = '{$ID}'\n                ORDER BY `begin_date`";
     $rand = mt_rand();
     if ($canedit) {
         echo "<div id='viewcost" . $ID . "_{$rand}'></div>\n";
         echo "<script type='text/javascript' >\n";
         echo "function viewAddCost" . $ID . "_{$rand}() {\n";
         $params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $ID, 'id' => -1);
         Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
         echo "};";
         echo "</script>\n";
         echo "<div class='center firstbloc'>" . "<a class='vsubmit' href='javascript:viewAddCost" . $ID . "_{$rand}();'>";
         echo __('Add a new cost') . "</a></div>\n";
     }
     if ($result = $DB->query($query)) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr><th colspan='5'>" . self::getTypeName($DB->numrows($result)) . "</th></tr>";
         if ($DB->numrows($result)) {
             echo "<tr><th>" . __('Name') . "</th>";
             echo "<th>" . __('Begin date') . "</th>";
             echo "<th>" . __('End date') . "</th>";
             echo "<th>" . __('Budget') . "</th>";
             echo "<th>" . __('Cost') . "</th>";
             echo "</tr>";
             Session::initNavigateListItems(__CLASS__, sprintf(__('%1$s = %2$s'), Contract::getTypeName(1), $contract->getName()));
             $total = 0;
             while ($data = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2' " . ($canedit ? "style='cursor:pointer' onClick=\"viewEditCost" . $data['contracts_id'] . "_" . $data['id'] . "_{$rand}();\"" : '') . ">";
                 $name = empty($data['name']) ? sprintf(__('%1$s (%2$s)'), $data['name'], $data['id']) : $data['name'];
                 echo "<td>";
                 printf(__('%1$s %2$s'), $name, Html::showToolTip($data['comment'], array('display' => false)));
                 if ($canedit) {
                     echo "\n<script type='text/javascript' >\n";
                     echo "function viewEditCost" . $data['contracts_id'] . "_" . $data["id"] . "_{$rand}() {\n";
                     $params = array('type' => __CLASS__, 'parenttype' => 'Contract', 'contracts_id' => $data["contracts_id"], 'id' => $data["id"]);
                     Ajax::updateItemJsCode("viewcost" . $ID . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/viewsubitem.php", $params);
                     echo "};";
                     echo "</script>\n";
                 }
                 echo "</td>";
                 echo "<td>" . Html::convDate($data['begin_date']) . "</td>";
                 echo "<td>" . Html::convDate($data['end_date']) . "</td>";
                 echo "<td>" . Dropdown::getDropdownName('glpi_budgets', $data['budgets_id']) . "</td>";
                 echo "<td class='numeric'>" . Html::formatNumber($data['cost']) . "</td>";
                 $total += $data['cost'];
                 echo "</tr>";
                 Session::addToNavigateListItems(__CLASS__, $data['id']);
             }
             echo "<tr class='b noHover'><td colspan='3'>&nbsp;</td>";
             echo "<td class='right'>" . __('Total cost') . '</td>';
             echo "<td class='numeric'>" . Html::formatNumber($total) . '</td></tr>';
         } else {
             echo "<tr><th colspan='5'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
     }
     echo "</div><br>";
 }
コード例 #24
0
    include '../inc/includes.php';
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
Session::checkLoginUser();
if (isset($_POST["my_items"]) && !empty($_POST["my_items"])) {
    $splitter = explode("_", $_POST["my_items"]);
    if (count($splitter) == 2) {
        $_POST["itemtype"] = $splitter[0];
        $_POST["items_id"] = $splitter[1];
    }
}
if (isset($_POST['itemtype']) && isset($_POST['items_id']) && $_POST['items_id'] > 0) {
    // Security
    if (!class_exists($_POST['itemtype'])) {
        exit;
    }
    $days = 3;
    $ticket = new Ticket();
    $data = $ticket->getActiveOrSolvedLastDaysTicketsForItem($_POST['itemtype'], $_POST['items_id'], $days);
    $nb = count($data);
    printf(_n('%s ticket in progress or recently solved on this item.', '%s tickets in progress or recently solved on this item.', $nb), $nb);
    if ($nb) {
        $content = '';
        foreach ($data as $title) {
            $content .= $title . '<br>';
        }
        echo '&nbsp;';
        Html::showToolTip($content);
    }
}
コード例 #25
0
 /**
  * Print the computers disks
  *
  * @param $comp Computer object
  *
  * @return Nothing (call to classes members)
  **/
 static function showForComputer(Computer $comp)
 {
     global $DB;
     $ID = $comp->fields['id'];
     if (!$comp->getFromDB($ID) || !$comp->can($ID, "r")) {
         return false;
     }
     $canedit = $comp->can($ID, "w");
     echo "<div class='spaced center'>";
     $virtualmachines = getAllDatasFromTable('glpi_computervirtualmachines', "`computers_id` = '{$ID}' AND `is_deleted` = '0'");
     echo "<table class='tab_cadre_fixe'>";
     Session::initNavigateListItems('ComputerVirtualMachine', sprintf(__('%1$s = %2$s'), __('Computer'), empty($comp->fields['name']) ? "({$ID})" : $comp->fields['name']));
     if (empty($virtualmachines)) {
         echo "<tr><th>" . __('No virtual machine associated with the computer') . "</th></tr>";
     } else {
         echo "<tr><th colspan='10'>" . __('List of virtual machines') . "</th></tr>";
         echo "<tr><th>" . __('Name') . "</th>";
         if (Plugin::haveImport()) {
             echo "<th>" . __('Automatic inventory') . "</th>";
         }
         echo "<th>" . __('Virtualization system') . "</th>";
         echo "<th>" . __('Virtualization model') . "</th>";
         echo "<th>" . __('State of the virtual machine') . "</th>";
         echo "<th>" . __('UUID') . "</th>";
         echo "<th>" . _x('quantity', 'Processors number') . "</th>";
         echo "<th>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</th>";
         echo "<th>" . __('Machine') . "</th>";
         echo "</tr>";
         $vm = new self();
         foreach ($virtualmachines as $virtualmachine) {
             $vm->getFromDB($virtualmachine['id']);
             echo "<tr class='tab_bg_2'>";
             echo "<td>" . $vm->getLink() . "</td>";
             if (Plugin::haveImport()) {
                 echo "<td>";
                 echo Dropdown::getYesNo($vm->isDynamic());
                 echo "</td>";
             }
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_virtualmachinetypes', $virtualmachine['virtualmachinetypes_id']);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_virtualmachinesystems', $virtualmachine['virtualmachinesystems_id']);
             echo "</td>";
             echo "<td>";
             echo Dropdown::getDropdownName('glpi_virtualmachinestates', $virtualmachine['virtualmachinestates_id']);
             echo "</td>";
             echo "<td>" . $virtualmachine['uuid'] . "</a></td>";
             echo "<td>" . $virtualmachine['vcpu'] . "</td>";
             echo "<td>" . $virtualmachine['ram'] . "</td>";
             echo "<td>";
             if ($link_computer = self::findVirtualMachine($virtualmachine)) {
                 $computer = new Computer();
                 if ($computer->can($link_computer, 'r')) {
                     $url = "<a href='computer.form.php?id=" . $link_computer . "'>";
                     $url .= $computer->fields["name"] . "</a>";
                     $tooltip = "<table><tr><td>" . __('Name') . "</td><td>" . $computer->fields['name'] . '</td></tr>';
                     $tooltip .= "<tr><td>" . __('Serial number') . "</td><td>" . $computer->fields['serial'] . '</td></tr>';
                     $tooltip .= "<tr><td>" . __('Comments') . "</td><td>" . $computer->fields['comment'] . '</td></tr></table>';
                     $url .= "&nbsp; " . Html::showToolTip($tooltip, array('display' => false));
                 } else {
                     $url = $computer->fields['name'];
                 }
                 echo $url;
             }
             echo "</td>";
             echo "</tr>";
             Session::addToNavigateListItems('ComputerVirtualMachine', $virtualmachine['id']);
         }
     }
     if ($canedit) {
         echo "<tr class='tab_bg_1'><td colspan='8' class='center'>";
         echo "<a class='vsubmit' href='computervirtualmachine.form.php?computers_id={$ID}'>" . __('Add a virtual machine') . "</a></td></tr>";
     }
     echo "</table>";
     echo "</div>";
 }
コード例 #26
0
ファイル: ticket.class.php プロジェクト: gaforeror/glpi
 /**
  * @param $ID
  * @param $forcetab  string   name of the tab to force at the display (default '')
  **/
 static function showVeryShort($ID, $forcetab = '')
 {
     global $CFG_GLPI;
     // Prints a job in short form
     // Should be called in a <table>-segment
     // Print links or not in case of user view
     // Make new job object and fill it from database, if success, print it
     $showprivate = Session::haveRight("show_full_ticket", 1);
     $job = new self();
     $rand = mt_rand();
     if ($job->getFromDBwithData($ID, 0)) {
         $bgcolor = $_SESSION["glpipriority_" . $job->fields["priority"]];
         //      $rand    = mt_rand();
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' bgcolor='{$bgcolor}'>" . sprintf(__('%1$s: %2$s'), __('ID'), $job->fields["id"]) . "</td>";
         echo "<td class='center'>";
         if (isset($job->users[CommonITILActor::REQUESTER]) && count($job->users[CommonITILActor::REQUESTER])) {
             foreach ($job->users[CommonITILActor::REQUESTER] as $d) {
                 if ($d["users_id"] > 0) {
                     $userdata = getUserName($d["users_id"], 2);
                     $name = "<span class='b'>" . $userdata['name'] . "</span>";
                     $name = sprintf(__('%1$s %2$s'), $name, Html::showToolTip($userdata["comment"], array('link' => $userdata["link"], 'display' => false)));
                     echo $name;
                 } else {
                     echo $d['alternative_email'] . "&nbsp;";
                 }
                 echo "<br>";
             }
         }
         if (isset($job->groups[CommonITILActor::REQUESTER]) && count($job->groups[CommonITILActor::REQUESTER])) {
             foreach ($job->groups[CommonITILActor::REQUESTER] as $d) {
                 echo Dropdown::getDropdownName("glpi_groups", $d["groups_id"]);
                 echo "<br>";
             }
         }
         echo "</td>";
         if ($job->hardwaredatas && $job->hardwaredatas->canView()) {
             echo "<td class='center";
             if ($job->hardwaredatas->isDeleted()) {
                 echo " tab_bg_1_2";
             }
             echo "'>";
             echo $job->hardwaredatas->getTypeName() . "<br>";
             echo "<span class='b'>" . $job->hardwaredatas->getLink() . "</span>";
             echo "</td>";
         } else {
             if ($job->hardwaredatas) {
                 echo "<td class='center' >" . $job->hardwaredatas->getTypeName() . "<br><span class='b'>" . $job->hardwaredatas->getNameID() . "</span></td>";
             } else {
                 echo "<td class='center' >" . __('General') . "</td>";
             }
         }
         echo "<td>";
         $link = "<a id='ticket" . $job->fields["id"] . $rand . "' href='" . $CFG_GLPI["root_doc"] . "/front/ticket.form.php?id=" . $job->fields["id"];
         if ($forcetab != '') {
             $link .= "&amp;forcetab=" . $forcetab;
         }
         $link .= "'>";
         $link .= "<span class='b'>" . $job->getNameID() . "</span></a>";
         $link = sprintf(__('%1$s (%2$s)'), $link, sprintf(__('%1$s - %2$s'), $job->numberOfFollowups($showprivate), $job->numberOfTasks($showprivate)));
         $link = printf(__('%1$s %2$s'), $link, Html::showToolTip($job->fields['content'], array('applyto' => 'ticket' . $job->fields["id"] . $rand, 'display' => false)));
         echo "</td>";
         // Finish Line
         echo "</tr>";
     } else {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' ><i>" . __('No ticket in progress.') . "</i></td></tr>";
     }
 }
コード例 #27
0
 function showConfigForm($canupdate = false)
 {
     global $DB;
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                ORDER BY `vlans_id` ASC";
     $i = 0;
     $used = array();
     if ($result = $DB->query($query)) {
         $number = $DB->numrows($result);
         if ($canupdate) {
             echo "<form method='post' name='massiveaction_form_vlan_color' id='" . "massiveaction_form_vlan_color' action='./config.form.php'>";
         }
         if ($number != 0) {
             echo "<div id='liste_vlan'>";
             echo "<table class='tab_cadre' cellpadding='5'>";
             echo "<tr>";
             echo "<th class='left'>" . __('VLAN') . "</th>";
             echo "<th class='left'>" . __('Color', 'archires') . "</th><th></th>";
             if ($number > 1) {
                 echo "<th class='left'>" . __('VLAN') . "</th>";
                 echo "<th class='left'>" . __('Color', 'archires') . "</th><th></th>";
             }
             echo "</tr>";
             while ($ligne = $DB->fetch_assoc($result)) {
                 $ID = $ligne["id"];
                 $vlans_id = $ligne["vlans_id"];
                 $used[] = $vlans_id;
                 if ($i % 2 == 0 && $number > 1) {
                     echo "<tr class='tab_bg_1'>";
                 }
                 if ($number == 1) {
                     echo "<tr class='tab_bg_1'>";
                 }
                 echo "<td>" . Dropdown::getDropdownName("glpi_vlans", $ligne["vlans_id"]) . "</td>";
                 echo "<td bgcolor='" . $ligne["color"] . "'>" . $ligne["color"] . "</td>";
                 echo "<td><input type='hidden' name='id' value='{$ID}'>";
                 if ($canupdate) {
                     echo "<input type='checkbox' name='item_color[{$ID}]' value='1'>";
                 }
                 echo "</td>";
                 $i++;
                 if ($i == $number && $number % 2 != 0 && $number > 1) {
                     echo "<td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>";
                 }
             }
             if ($canupdate) {
                 echo "<tr class='tab_bg_1'>";
                 if ($number > 1) {
                     echo "<td colspan='8' class='center'>";
                 } else {
                     echo "<td colspan='4' class='center'>";
                 }
                 echo "<a onclick= \"if (markCheckboxes ('massiveaction_form_vlan_color')) " . "return false;\" href='#'>" . __('Select all') . "</a>";
                 echo " - <a onclick= \"if (unMarkCheckboxes ('massiveaction_form_vlan_color')) " . "return false;\" href='#'>" . __('Deselect all') . "</a> ";
                 Html::closeArrowMassives(array('delete_color_vlan' => _sx('button', 'Delete permanently')));
             } else {
                 echo "</table>";
             }
             echo "</div>";
         }
         if ($canupdate) {
             echo "<table class='tab_cadre' cellpadding='5'><tr ><th colspan='3'>";
             echo __('Associate colors to VLANs', 'archires') . "</th></tr>";
             echo "<tr class='tab_bg_1'><td>";
             $this->dropdownVlan($used);
             echo "</td>";
             echo "<td><input type='text' name='color'>";
             echo "&nbsp;";
             Html::showToolTip(nl2br(__('Please use this color format', 'archires')), array('link' => 'http://www.graphviz.org/doc/info/colors.html', 'linktarget' => '_blank'));
             echo "<td class='center'><input type='submit' name='add_color_vlan' value=\"" . _sx('button', 'Add') . "\" class='submit'></td></tr>";
             echo "</table>";
             Html::closeForm();
         }
     }
 }
コード例 #28
0
ファイル: user.class.php プロジェクト: pvasener/glpi
 /**
  * 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 .= "&nbsp;" . 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;
 }
コード例 #29
0
ファイル: user.class.php プロジェクト: geldarr/hack-space
 /**
  * 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 show_all_ticket, create_ticket.... (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)
  *
  * @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['entity'] = -1;
     $p['entity_sons'] = false;
     $p['used'] = array();
     $p['ldap_import'] = false;
     $p['toupdate'] = '';
     $p['rand'] = mt_rand();
     $p['display'] = true;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     $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
     $use_ajax = false;
     if ($CFG_GLPI["use_ajax"]) {
         $res = self::getSqlSearchResult(true, $p['right'], $p['entity'], $p['value'], $p['used']);
         $nb = $res ? $DB->result($res, 0, "CPT") : 0;
         if ($nb > $CFG_GLPI["ajax_limit_count"]) {
             $use_ajax = true;
         }
     }
     $user = getUserName($p['value'], 2);
     $default_display = "<select id='dropdown_" . $p['name'] . $p['rand'] . "' name='" . $p['name'] . "'>";
     $default_display .= "<option value='" . $p['value'] . "'>";
     $default_display .= Toolbox::substr($user["name"], 0, $_SESSION["glpidropdown_chars_limit"]);
     $default_display .= "</option></select>";
     $view_users = Session::haveRight("user", "r");
     $params = array('searchText' => '__VALUE__', 'value' => $p['value'], 'myname' => $p['name'], 'all' => $p['all'], 'right' => $p['right'], 'comment' => $p['comments'], 'rand' => $p['rand'], 'on_change' => $p['on_change'], 'entity_restrict' => $p['entity'], 'used' => $p['used'], 'update_item' => $p['toupdate']);
     if ($view_users) {
         $params['update_link'] = $view_users;
     }
     $default = "";
     if (!empty($p['value']) && $p['value'] > 0) {
         $default = $default_display;
     } else {
         $default = "<select name='" . $p['name'] . "' id='dropdown_" . $p['name'] . $p['rand'] . "'>";
         if ($p['all']) {
             $default .= "<option value='0'>--" . __('All') . "--</option></select>";
         } else {
             $default .= "<option value='0'>" . Dropdown::EMPTY_VALUE . "</option></select>\n";
         }
     }
     $output .= Ajax::dropdown($use_ajax, "/ajax/dropdownUsers.php", $params, $default, $p['rand'], false);
     // Display comment
     if ($p['comments']) {
         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_" . $p['name'] . $p['rand'], 'display' => false, 'link' => $user["link"], 'linkid' => "comment_link_" . $p["name"] . $p['rand']));
     }
     if (Session::haveRight('import_externalauth_users', 'w') && $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=\"var w = window.open('" . $CFG_GLPI['root_doc'] . "/front/popup.php?popup=add_ldapuser&amp;rand=" . $p['rand'] . "&amp;entity=" . $_SESSION['glpiactive_entity'] . "' ,'glpipopup', 'height=400, " . "width=1000, top=100, left=100, scrollbars=yes' );w.focus();\">";
     }
     if ($p['display']) {
         echo $output;
         return $p['rand'];
     }
     return $output;
 }
コード例 #30
0
ファイル: rule.class.php プロジェクト: pvasener/glpi
 /**
  * Show the minimal form for the rule
  *
  * @param $target             link to the form page
  * @param $first              is it the first rule ?(false by default)
  * @param $last               is it the last rule ? (false by default)
  * @param $display_entities   display entities / make it read only display (false by default)
  * @param $active_condition   active condition used (default 0)
  **/
 function showMinimalForm($target, $first = false, $last = false, $display_entities = false, $active_condition = 0)
 {
     global $CFG_GLPI;
     $canedit = self::canUpdate() && !$display_entities;
     echo "<tr class='tab_bg_1'>";
     if ($canedit) {
         echo "<td width='10'>";
         Html::showMassiveActionCheckBox($this->getType(), $this->fields["id"]);
         echo "</td>";
     } else {
         echo "<td>&nbsp;</td>";
     }
     $link = $this->getLink();
     if (!empty($this->fields["comment"])) {
         $link = sprintf(__('%1$s %2$s'), $link, Html::showToolTip($this->fields["comment"], array('display' => false)));
     }
     echo "<td>" . $link . "</td>";
     echo "<td>" . $this->fields["description"] . "</td>";
     if ($this->useConditions()) {
         echo "<td>" . $this->getConditionName($this->fields["condition"]) . "</td>";
     }
     echo "<td>" . Dropdown::getYesNo($this->fields["is_active"]) . "</td>";
     if ($display_entities) {
         $entname = Dropdown::getDropdownName('glpi_entities', $this->fields['entities_id']);
         if ($this->maybeRecursive() && $this->fields['is_recursive']) {
             $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(" . __('R') . ")</span>");
         }
         echo "<td>" . $entname . "</td>";
     }
     if (!$display_entities) {
         if ($this->can_sort && !$first && $canedit) {
             echo "<td>";
             Html::showSimpleForm($target, array('action' => 'up', 'condition' => $active_condition), '', array('type' => $this->fields["sub_type"], 'id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_up.png");
             echo "</td>";
         } else {
             echo "<td>&nbsp;</td>";
         }
     }
     if (!$display_entities) {
         if ($this->can_sort && !$last && $canedit) {
             echo "<td>";
             Html::showSimpleForm($target, array('action' => 'down', 'condition' => $active_condition), '', array('type' => $this->fields["sub_type"], 'id' => $this->fields["id"]), $CFG_GLPI["root_doc"] . "/pics/deplier_down.png");
             echo "</td>";
         } else {
             echo "<td>&nbsp;</td>";
         }
     }
     echo "</tr>\n";
 }