showColorField() static public method

Display Color field
static public showColorField ( $name, $options = [] )
$name name of the element
$options array of possible options: - value : default value to display (default '') - display : boolean display or get string (default true) - rand : specific random value (default generated one)
 public function showForm($ID, $options = array())
 {
     if (!$this->isNewID($ID)) {
         $this->check($ID, READ);
     } else {
         $this->check(-1, UPDATE);
     }
     $options['colspan'] = 2;
     $options['target'] = Toolbox::getItemTypeFormURL(__CLASS__);
     $this->showFormHeader($options);
     echo '<table class="tab_cadre_fixe">';
     echo "<tr class='line0'><td>" . __('Name') . " <span class='red'>*</span></td>";
     echo "<td>";
     //Html::autocompletionTextField($this, "name");
     echo '<input type="text" name="name" value="' . $this->fields['name'] . '" size="40" required>';
     echo "</td>";
     echo "</tr>";
     echo "<tr class='line1'><td>" . __('Description') . "</td>";
     echo "<td>";
     echo "<textarea name='comment' id ='comment' cols='45' rows='2'>" . $this->fields['comment'] . "</textarea>";
     //Html::initEditorSystem('comment');
     echo "</td>";
     echo "</tr>";
     echo "<tr class='line1'><td>" . __('HTML color', 'tag') . "</td>";
     echo "<td>";
     Html::showColorField('color', array('value' => $this->fields['color']));
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
Beispiel #2
0
 public function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo '<table class="tab_cadre_fixe">';
     echo "<tr class='line0 tab_bg_2'><td><label for='name'>" . __('Name') . " <span class='red'>*</span></label></td>";
     echo "<td>";
     echo '<input type="text" id="name" name="name" value="' . $this->fields['name'] . '" size="40" required>';
     echo "</td>";
     echo "</tr>";
     echo "<tr class='line1 tab_bg_2'><td><label for='comment'>" . __('Description') . "</label></td>";
     echo "<td>";
     echo "<textarea name='comment' id ='comment' cols='45' rows='2'>" . $this->fields['comment'] . "</textarea>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='line1 tab_bg_2'><td><label>" . __('HTML color', 'tag') . "</label></td>";
     echo "<td>";
     //Note : create some bugs
     Html::showColorField('color', array('value' => $this->fields['color']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='line0 tab_bg_2'>";
     echo "<td colspan='2'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='line1 tab_bg_2'>";
     echo "<th>" . _n('Associated item type', 'Associated item types', 2) . "</th>";
     echo "</tr>";
     echo "<tr class='line1 tab_bg_2'>";
     echo "<td class='center'>";
     echo _n('Tag type', 'Tag types', 1, 'tag') . " ";
     $values = array(0 => Dropdown::EMPTY_VALUE);
     $menus = Html::getMenuInfos();
     foreach ($menus as $key => $value) {
         if ($key != 'plugins' && $key != 'preference') {
             $values[$key] = $menus[$key]['title'];
         }
     }
     $rand = Dropdown::showFromArray("type_menu", $values, array('value' => $this->fields['type_menu'], 'width' => '50%', 'on_change' => 'pluginTagSubType();'));
     echo "<div id='plugin_tag_itemtype'></div><br>";
     $JS = 'function pluginTagSubType(){';
     $JS .= Ajax::updateItemJsCode('plugin_tag_itemtype', $CFG_GLPI['root_doc'] . "/plugins/tag/ajax/tag.php", array('action' => 'add_subtypes', 'type_menu' => '__VALUE__', 'rand' => $rand), "dropdown_type_menu{$rand}", false);
     $JS .= '}';
     $JS .= 'pluginTagSubType();';
     echo Html::scriptBlock($JS);
     // Sub type choice
     $itemtypes = array();
     $selected = array();
     if (!empty($this->fields['type_menu'])) {
         foreach (json_decode($this->fields['type_menu'], true) as $itemtype) {
             $item = getItemForItemtype($itemtype);
             $itemtypes[$itemtype] = $item->getTypeName();
             $selected[] = $itemtype;
         }
     }
     Dropdown::showFromArray("subtypes", $itemtypes, array('values' => $selected, 'multiple' => true, 'rand' => $rand, 'width' => '100%'));
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Print the config form for default user prefs
  *
  * @param $data array containing datas
  * (CFG_GLPI for global config / glpi_users fields for user prefs)
  *
  * @return Nothing (display)
  **/
 function showFormUserPrefs($data = array())
 {
     global $DB, $CFG_GLPI;
     $oncentral = $_SESSION["glpiactiveprofile"]["interface"] == "central";
     $userpref = false;
     $url = Toolbox::getItemTypeFormURL(__CLASS__);
     if (array_key_exists('last_login', $data)) {
         $userpref = true;
         if ($data["id"] === Session::getLoginUserID()) {
             $url = $CFG_GLPI['root_doc'] . "/front/preference.php";
         } else {
             $url = $CFG_GLPI['root_doc'] . "/front/user.form.php";
         }
     }
     echo "<form name='form' action='{$url}' method='post'>";
     // Only set id for user prefs
     if ($userpref) {
         echo "<input type='hidden' name='id' value='" . $data['id'] . "'>";
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('Personalization') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td width='30%'>" . ($userpref ? __('Language') : __('Default language')) . "</td>";
     echo "<td width='20%'>";
     if (Config::canUpdate() || !GLPI_DEMO_MODE) {
         Dropdown::showLanguages("language", array('value' => $data["language"]));
     } else {
         echo "&nbsp;";
     }
     echo "<td width='30%'>" . __('Date format') . "</td>";
     echo "<td width='20%'>";
     $date_formats = array(0 => __('YYYY-MM-DD'), 1 => __('DD-MM-YYYY'), 2 => __('MM-DD-YYYY'));
     Dropdown::showFromArray('date_format', $date_formats, array('value' => $data["date_format"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Results to display by page') . "</td><td>";
     // Limit using global config
     $value = $data['list_limit'] < $CFG_GLPI['list_limit_max'] ? $data['list_limit'] : $CFG_GLPI['list_limit_max'];
     Dropdown::showNumber('list_limit', array('value' => $value, 'min' => 5, 'max' => $CFG_GLPI['list_limit_max'], 'step' => 5));
     echo "</td>";
     echo "<td>" . __('Number format') . "</td>";
     $values = array(0 => '1 234.56', 1 => '1,234.56', 2 => '1 234,56', 3 => '1234.56', 4 => '1234,56');
     echo "<td>";
     Dropdown::showFromArray('number_format', $values, array('value' => $data["number_format"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Display order of surnames firstnames') . "</td><td>";
     $values = array(User::REALNAME_BEFORE => __('Surname, First name'), User::FIRSTNAME_BEFORE => __('First name, Surname'));
     Dropdown::showFromArray('names_format', $values, array('value' => $data["names_format"]));
     echo "</td>";
     echo "<td>" . __("Color palette") . "</td><td>";
     $themes_files = scandir(GLPI_ROOT . "/css/palettes/");
     echo "<select name='palette' id='theme-selector'>";
     foreach ($themes_files as $key => $file) {
         if (strpos($file, ".css") !== false) {
             $name = substr($file, 0, -4);
             $selected = "";
             if ($data["palette"] == $name) {
                 $selected = "selected='selected'";
             }
             echo "<option value='{$name}' {$selected}>" . ucfirst($name) . "</option>";
         }
     }
     echo Html::scriptBlock("\n         function formatThemes(theme) {\n             return \"&nbsp;<img src='../css/palettes/previews/\" + theme.text.toLowerCase() + \".png'/>\"\n                     + \"&nbsp;\" + theme.text;\n         }\n         \$(\"#theme-selector\").select2({\n             formatResult: formatThemes,\n             formatSelection: formatThemes,\n             width: '100%',\n             escapeMarkup: function(m) { return m; }\n         });\n      ");
     echo "</select>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     if ($oncentral) {
         echo "<td>" . __('Display the complete name in tree dropdowns') . "</td><td>";
         Dropdown::showYesNo('use_flat_dropdowntree', $data["use_flat_dropdowntree"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     if (!$userpref || $CFG_GLPI['show_count_on_tabs'] != -1) {
         echo "<td>" . __('Display counts in tabs') . "</td><td>";
         $values = array(0 => __('No'), 1 => __('Yes'));
         if (!$userpref) {
             $values[-1] = __('Never');
         }
         Dropdown::showFromArray('show_count_on_tabs', $values, array('value' => $data["show_count_on_tabs"]));
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     if ($oncentral) {
         echo "<td>" . __('Show GLPI ID') . "</td><td>";
         Dropdown::showYesNo("is_ids_visible", $data["is_ids_visible"]);
         echo "</td>";
     } else {
         echo "<td colspan='2'></td>";
     }
     echo "<td>" . __('CSV delimiter') . "</td><td>";
     $values = array(';' => ';', ',' => ',');
     Dropdown::showFromArray('csv_delimiter', $values, array('value' => $data["csv_delimiter"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Notifications for my changes') . "</td><td>";
     Dropdown::showYesNo("notification_to_myself", $data["notification_to_myself"]);
     echo "</td>";
     if ($oncentral) {
         echo "<td>" . __('Results to display on home page') . "</td><td>";
         Dropdown::showNumber('display_count_on_home', array('value' => $data['display_count_on_home'], 'min' => 0, 'max' => 30));
         echo "</td>";
     } else {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('PDF export font') . "</td><td>";
     Dropdown::showFromArray("pdffont", GLPIPDF::getFontList(), array('value' => $data["pdffont"], 'width' => 200));
     echo "</td>";
     echo "<td>" . __('Keep devices when purging an item') . "</td><td>";
     Dropdown::showYesNo('keep_devices_when_purging_item', $data['keep_devices_when_purging_item']);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Go to created item after creation') . "</td>";
     echo "<td>";
     Dropdown::showYesNo("backcreated", $data["backcreated"]);
     echo "</td>";
     echo "<td>" . __('Layout') . "</td><td>";
     $layout_options = array('lefttab' => __("Tabs on left"), 'classic' => __("Classic view"), 'vsplit' => __("Vertical split"));
     echo "<select name='layout' id='layout-selector'>";
     foreach ($layout_options as $key => $name) {
         $selected = "";
         if ($data["layout"] == $key) {
             $selected = "selected='selected'";
         }
         echo "<option value='{$key}' {$selected}>" . ucfirst($name) . "</option>";
     }
     echo Html::scriptBlock("\n         function formatLayout(layout) {\n             return \"&nbsp;<img src='../pics/layout_\" + layout.id.toLowerCase() + \".png'/>\"\n                     + \"&nbsp;\" + layout.text;\n         }\n         \$(\"#layout-selector\").select2({\n             formatResult: formatLayout,\n             formatSelection: formatLayout,\n             escapeMarkup: function(m) { return m; }\n         });\n      ");
     echo "</select>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Enable ticket timeline') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('ticket_timeline', $data['ticket_timeline']);
     echo "</td>";
     echo "<td>" . __('Keep tabs replaced by the ticket timeline') . "</td><td>";
     Dropdown::showYesNo('ticket_timeline_keep_replaced_tabs', $data['ticket_timeline_keep_replaced_tabs']);
     echo "</td></tr>";
     if ($oncentral) {
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Assistance') . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Private followups by default') . "</td><td>";
         Dropdown::showYesNo("followup_private", $data["followup_private"]);
         echo "</td><td>" . __('Show new tickets on the home page') . "</td><td>";
         if (Session::haveRightsOr("ticket", array(Ticket::READMY, Ticket::READALL, Ticket::READASSIGN))) {
             Dropdown::showYesNo("show_jobs_at_login", $data["show_jobs_at_login"]);
         } else {
             echo Dropdown::getYesNo(0);
         }
         echo " </td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Private tasks by default') . "</td><td>";
         Dropdown::showYesNo("task_private", $data["task_private"]);
         echo "</td><td> " . __('Request sources by default') . "</td><td>";
         RequestType::dropdown(array('value' => $data["default_requesttypes_id"], 'name' => "default_requesttypes_id"));
         echo "</td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Tasks state by default') . "</td><td>";
         Planning::dropdownState("task_state", $data["task_state"]);
         echo "</td><td colspan='2'>&nbsp;</td></tr>";
         echo "<tr class='tab_bg_2'><td>" . __('Pre-select me as a technician when creating a ticket') . "</td><td>";
         if (!$userpref || Session::haveRight('ticket', Ticket::OWN)) {
             Dropdown::showYesNo("set_default_tech", $data["set_default_tech"]);
         } else {
             echo Dropdown::getYesNo(0);
         }
         echo "</td><td>" . __('Automatically refresh the list of tickets (minutes)') . "</td><td>";
         Dropdown::showNumber('refresh_ticket_list', array('value' => $data["refresh_ticket_list"], 'min' => 1, 'max' => 30, 'step' => 1, 'toadd' => array(0 => __('Never'))));
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Priority colors') . "</td>";
         echo "<td colspan='3'>";
         echo "<table><tr>";
         echo "<td>1&nbsp;";
         Html::showColorField('priority_1', array('value' => $data["priority_1"]));
         echo "</td>";
         echo "<td>2&nbsp;";
         Html::showColorField('priority_2', array('value' => $data["priority_2"]));
         echo "</td>";
         echo "<td>3&nbsp;";
         Html::showColorField('priority_3', array('value' => $data["priority_3"]));
         echo "</td>";
         echo "<td>4&nbsp;";
         Html::showColorField('priority_4', array('value' => $data["priority_4"]));
         echo "</td>";
         echo "<td>5&nbsp;";
         Html::showColorField('priority_5', array('value' => $data["priority_5"]));
         echo "</td>";
         echo "<td>6&nbsp;";
         Html::showColorField('priority_6', array('value' => $data["priority_6"]));
         echo "</td>";
         echo "</tr></table>";
         echo "</td></tr>";
     }
     // Only for user
     if (array_key_exists('personal_token', $data)) {
         echo "<tr class='tab_bg_1'><th colspan='4'>" . __('Remote access key') . "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Remote access key');
         if (!empty($data["personal_token"])) {
             //TRANS: %s is the generation date
             echo "<br>" . sprintf(__('generated on %s'), Html::convDateTime($data["personal_token_date"]));
         }
         echo "</td><td colspan='3'>";
         echo "<input type='checkbox' name='_reset_personal_token'>&nbsp;" . __('Regenerate');
         echo "</td></tr>";
     }
     echo "<tr><th colspan='4'>" . __('Due date progression') . "</th></tr>";
     echo "<tr class='tab_bg_1'>" . "<td>" . __('OK state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedateok_color', array('value' => $data["duedateok_color"]));
     echo "</td><td colspan='2'>&nbsp;</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Warning state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedatewarning_color', array('value' => $data["duedatewarning_color"]));
     echo "</td>";
     echo "<td>" . __('Warning state threshold') . "</td>";
     echo "<td>";
     Dropdown::showNumber("duedatewarning_less", array('value' => $data['duedatewarning_less']));
     $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber()));
     echo "&nbsp;";
     Dropdown::showFromArray("duedatewarning_unit", $elements, array('value' => $data['duedatewarning_unit']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>" . "<td>" . __('Critical state color') . "</td>";
     echo "<td>";
     Html::showColorField('duedatecritical_color', array('value' => $data["duedatecritical_color"]));
     echo "</td>";
     echo "<td>" . __('Critical state threshold') . "</td>";
     echo "<td>";
     Dropdown::showNumber("duedatecritical_less", array('value' => $data['duedatecritical_less']));
     echo "&nbsp;";
     $elements = array('%' => '%', 'hours' => _n('Hour', 'Hours', Session::getPluralNumber()), 'days' => _n('Day', 'Days', Session::getPluralNumber()));
     Dropdown::showFromArray("duedatecritical_unit", $elements, array('value' => $data['duedatecritical_unit']));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
     echo "</td></tr>";
     echo "</table></div>";
     Html::closeForm();
 }
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $options['colspan'] = 4;
     $this->initForm($ID, $options);
     $this->showFormHeader($this->fields);
     echo "<tr><th colspan='4'>" . __('Customise GLPI style', 'custom') . "</th></tr>";
     echo "<tr>";
     echo "<td>##BODY##</td>";
     echo "<td>";
     Html::showColorField('body', array('value' => $this->fields['body']));
     echo "</td>";
     echo "<tr><th colspan='4'>Button</th></tr>";
     echo "<tr>";
     echo "<td>##BUTTON_BG_COLOR##</td>";
     echo "<td>";
     Html::showColorField('button_bg_color', array('value' => $this->fields['button_bg_color']));
     echo "</td>";
     echo "<td>##BUTTON_BG_COLOR_HOVER##</td>";
     echo "<td>";
     Html::showColorField('button_bg_color_hover', array('value' => $this->fields['button_bg_color_hover']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##BUTTON_BORDER##</td>";
     echo "<td>";
     Html::showColorField('button_border', array('value' => $this->fields['button_border']));
     echo "</td>";
     echo "<td>##BUTTON_BORDER_HOVER##</td>";
     echo "<td>";
     Html::showColorField('button_border_hover', array('value' => $this->fields['button_border_hover']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##BUTTON_COLOR##</td>";
     echo "<td>";
     Html::showColorField('button_color', array('value' => $this->fields['button_color']));
     echo "</td>";
     echo "<td>##BUTTON_COLOR_HOVER##</td>";
     echo "<td>";
     Html::showColorField('button_color_hover', array('value' => $this->fields['button_color_hover']));
     echo "</td>";
     echo "</tr>";
     echo "<td>##TEXT_COLOR##</td>";
     echo "<td>";
     Html::showColorField('text_color', array('value' => $this->fields['text_color']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><th colspan='4'>Links</th></tr>";
     echo "<tr>";
     echo "<td>##LINK_COLOR##</td>";
     echo "<td>";
     Html::showColorField('link_color', array('value' => $this->fields['link_color']));
     echo "</td>";
     echo "<td>##HOVER_LINK_COLOR##</td>";
     echo "<td>";
     Html::showColorField('link_hover_color', array('value' => $this->fields['link_hover_color']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><th colspan='4'>Menu</th></tr>";
     echo "<tr>";
     echo "<td>##MENU_BORDER##</td>";
     echo "<td>";
     Html::showColorField('menu_border', array('value' => $this->fields['menu_border']));
     echo "</td>";
     echo "<td>##MENU_ITEM_BG##</td>";
     echo "<td>";
     Html::showColorField('menu_item_bg', array('value' => $this->fields['menu_item_bg']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##MENU_ITEM_BORDER##</td>";
     echo "<td>";
     Html::showColorField('menu_item_border', array('value' => $this->fields['menu_item_border']));
     echo "</td>";
     echo "<td>##MENU_ITEM_BG_HOVER##</td>";
     echo "<td>";
     Html::showColorField('menu_item_bg_hover', array('value' => $this->fields['menu_item_bg_hover']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##MENU_LINK##</td>";
     echo "<td>";
     Html::showColorField('menu_link', array('value' => $this->fields['menu_link']));
     echo "</td>";
     echo "<td>##MENU_ITEM_LINK##</td>";
     echo "<td>";
     Html::showColorField('menu_item_link', array('value' => $this->fields['menu_item_link']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##SSMENU1_LINK##</td>";
     echo "<td>";
     Html::showColorField('ssmenu1_link', array('value' => $this->fields['ssmenu1_link']));
     echo "</td>";
     echo "<td>##SSMENU2_LINK##</td>";
     echo "<td>";
     Html::showColorField('ssmenu2_link', array('value' => $this->fields['ssmenu2_link']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##LINK_TOPRIGHT##</td>";
     echo "<td>";
     Html::showColorField('link_topright', array('value' => $this->fields['link_topright']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><th colspan='4'>Tables</th></tr>";
     echo "<tr>";
     echo "<td>##TH##</td>";
     echo "<td>";
     Html::showColorField('th', array('value' => $this->fields['th']));
     echo "</td>";
     echo "<td>##TH_TEXT_COLOR##</td>";
     echo "<td>";
     Html::showColorField('th_text_color', array('value' => $this->fields['th_text_color']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##TABLE_BG_COLOR##</td>";
     echo "<td>";
     Html::showColorField('table_bg_color', array('value' => $this->fields['table_bg_color']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##TAB_BG_1##</td>";
     echo "<td>";
     Html::showColorField('tab_bg_1', array('value' => $this->fields['tab_bg_1']));
     echo "</td>";
     echo "<td>##TAB_BG_2##</td>";
     echo "<td>";
     Html::showColorField('tab_bg_2', array('value' => $this->fields['tab_bg_2']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##TAB_BG_1_2##</td>";
     echo "<td>";
     Html::showColorField('tab_bg_1_2', array('value' => $this->fields['tab_bg_1_2']));
     echo "</td>";
     echo "<td>##TAB_BG_2_2##</td>";
     echo "<td>";
     Html::showColorField('tab_bg_2_2', array('value' => $this->fields['tab_bg_2_2']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##TAB_BG_3##</td>";
     echo "<td>";
     Html::showColorField('tab_bg_3', array('value' => $this->fields['tab_bg_3']));
     echo "</td>";
     echo "<td>##TAB_BG_4##</td>";
     echo "<td>";
     Html::showColorField('tab_bg_4', array('value' => $this->fields['tab_bg_4']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##TAB_BG_5##</td>";
     echo "<td>";
     Html::showColorField('tab_bg_5', array('value' => $this->fields['tab_bg_5']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><th colspan='4'>Cadres</th></tr>";
     echo "<tr>";
     echo "<td>##CADRE_CENTRAL_BG1##</td>";
     echo "<td>";
     Html::showColorField('cadre_central_bg1', array('value' => $this->fields['cadre_central_bg1']));
     echo "</td>";
     echo "<td>##CADRE_CENTRAL_BG1##</td>";
     echo "<td>";
     Html::showColorField('cadre_central_bg2', array('value' => $this->fields['cadre_central_bg2']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><th colspan='4'>Onglets</th></tr>";
     echo "<tr>";
     echo "<td>##TABS_BG1##</td>";
     echo "<td>";
     Html::showColorField('tabs_bg1', array('value' => $this->fields['tabs_bg1']));
     echo "</td>";
     echo "<td>##TABS_BG2##</td>";
     echo "<td>";
     Html::showColorField('tabs_bg2', array('value' => $this->fields['tabs_bg2']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##TABS_BG3##</td>";
     echo "<td>";
     Html::showColorField('tabs_bg3', array('value' => $this->fields['tabs_bg3']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##TABS_BORDER##</td>";
     echo "<td>";
     Html::showColorField('tabs_border', array('value' => $this->fields['tabs_border']));
     echo "</td>";
     echo "<td>##TABS_TITLE_COLOR##</td>";
     echo "<td>";
     Html::showColorField('tabs_title_color', array('value' => $this->fields['tabs_title_color']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><th colspan='4'>Header</th></tr>";
     echo "<tr>";
     echo "<td>##HEADER_BG1##</td>";
     echo "<td>";
     Html::showColorField('header_bg1', array('value' => $this->fields['header_bg1']));
     echo "</td>";
     echo "<td>##HEADER_BG2##</td>";
     echo "<td>";
     Html::showColorField('header_bg2', array('value' => $this->fields['header_bg2']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##HEADER_BG3##</td>";
     echo "<td>";
     Html::showColorField('header_bg3', array('value' => $this->fields['header_bg3']));
     echo "</td>";
     echo "<td>##HEADER_BG4##</td>";
     echo "<td>";
     Html::showColorField('header_bg4', array('value' => $this->fields['header_bg4']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##HEADER_BG5##</td>";
     echo "<td>";
     Html::showColorField('header_bg5', array('value' => $this->fields['header_bg5']));
     echo "</td>";
     echo "<td>##HEADER_BG6##</td>";
     echo "<td>";
     Html::showColorField('header_bg6', array('value' => $this->fields['header_bg6']));
     echo "</td>";
     echo "</tr>";
     echo "<tr><th colspan='4'>Ombres</th></tr>";
     echo "<tr>";
     echo "<td>##HEADER_SHADOW_COLOR##</td>";
     echo "<td>";
     Html::showColorField('header_shadow_color', array('value' => $this->fields['header_shadow_color']));
     echo "</td>";
     echo "<td>##HEADER_SHADOW_SIZE##</td>";
     echo "<td>";
     ##size input
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##PAGE_SHADOW_COLOR##</td>";
     echo "<td>";
     Html::showColorField('page_shadow_color', array('value' => $this->fields['page_shadow_color']));
     echo "</td>";
     echo "<td>##PAGE_SHADOW_SIZE##</td>";
     echo "<td>";
     ##size input
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##FOOTER_SHADOW_COLOR##</td>";
     echo "<td>";
     Html::showColorField('footer_shadow_color', array('value' => $this->fields['footer_shadow_color']));
     echo "</td>";
     echo "<td>##FOOTER_SHADOW_SIZE##</td>";
     echo "<td>";
     ##size input
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>##FOOTER_BG1##</td>";
     echo "<td>";
     Html::showColorField('footer_bg1', array('value' => $this->fields['footer_bg1']));
     echo "</td>";
     echo "<td>##FOOTER_BG2##</td>";
     echo "<td>";
     Html::showColorField('footer_bg2', array('value' => $this->fields['footer_bg2']));
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
 }
Beispiel #5
0
 /**
  * Display a single line of planning filter.
  * See self::showPlanningFilter function
  *
  * @param $filter_key  : identify curent line of filter
  * @param $filter_data : array of filter date, must contains :
  *   * 'show_delete' (boolean): show delete button
  *   * 'filter_color_index' (integer): index of the color to use in self::$palette_bg
  * @param $options
  *
  * @return Nothing (display function)
  */
 static function showSingleLinePlanningFilter($filter_key, $filter_data, $options = array())
 {
     global $CFG_GLPI;
     $params['show_delete'] = true;
     $params['filter_color_index'] = 0;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $params[$key] = $val;
         }
     }
     $actor = explode('_', $filter_key);
     $uID = 0;
     $gID = 0;
     if ($filter_data['type'] == 'user') {
         $uID = $actor[1];
         $user = new User();
         $user->getFromDB($actor[1]);
         $title = $user->getName();
     } else {
         if ($filter_data['type'] == 'group_users') {
             $group = new Group();
             $group->getFromDB($actor[1]);
             $title = $group->getName();
         } else {
             if ($filter_data['type'] == 'group') {
                 $gID = $actor[1];
                 $group = new Group();
                 $group->getFromDB($actor[1]);
                 $title = $group->getName();
             } else {
                 if ($filter_data['type'] == 'event_filter') {
                     $title = $filter_key::getTypeName();
                 }
             }
         }
     }
     echo "<li event_type='" . $filter_data['type'] . "'\n               event_name='{$filter_key}'\n               class='" . $filter_data['type'] . "'>";
     Html::showCheckbox(array('name' => 'filters[]', 'value' => $filter_key, 'title' => $title, 'checked' => $filter_data['display']));
     if ($filter_data['type'] != 'event_filter') {
         $icon_type = explode('_', $filter_data['type']);
         echo "<img class='actor_icon' src='" . $CFG_GLPI['root_doc'] . "/pics/" . $icon_type[0] . ".png'>";
     }
     echo "<label for='{$filter_key}'>{$title}</label>";
     $color = self::$palette_bg[$params['filter_color_index']];
     if (isset($filter_data['color']) && !empty($filter_data['color'])) {
         $color = $filter_data['color'];
     } else {
         $params['filter_color_index']++;
         if (!isset(self::$palette_bg[$params['filter_color_index']])) {
             $params['filter_color_index'] = 0;
             $color = self::$palette_bg[$params['filter_color_index']];
         }
     }
     if ($filter_data['type'] != 'event_filter') {
         echo "<span class='filter_option'>";
         echo "<img class='pointer' src='" . $CFG_GLPI['root_doc'] . "/pics/down.png' />";
         echo "<ul>";
         if ($params['show_delete']) {
             echo "<li class='delete_planning' value='{$filter_key}'>" . __("Delete") . "</li>";
         }
         if ($filter_data['type'] != 'group_users') {
             $url = parse_url($CFG_GLPI["url_base"]);
             $port = 80;
             if (isset($url['port'])) {
                 $port = $url['port'];
             } else {
                 if (isset($url['scheme']) && $url["scheme"] == 'https') {
                     $port = 443;
                 }
             }
             $cal_url = "/front/planning.php?genical=1&uID=" . $uID . "&gID=" . $gID . "&entities_id=" . $_SESSION["glpiactive_entity"] . "&is_recursive=" . $_SESSION["glpiactive_entity_recursive"] . "&token=" . User::getPersonalToken(Session::getLoginUserID(true));
             echo "<li><a target='_blank' href='" . $CFG_GLPI["root_doc"] . "{$cal_url}'>" . _sx("button", "Export") . " - " . __("Ical") . "</a></li>";
             echo "<li><a target='_blank' href='webcal://" . $url['host'] . ":{$port}" . (isset($url['path']) ? $url['path'] : '') . "{$cal_url}'>" . _sx("button", "Export") . " - " . __("Webcal") . "</a></li>";
         }
         echo "</ul>";
         echo "</span>";
     }
     // colors not for groups
     if ($filter_data['type'] != 'group_users') {
         echo "<span class='color_input'>";
         Html::showColorField($filter_key . "_color", array('value' => $color));
         echo "</span>";
     }
     if ($filter_data['type'] == 'group_users') {
         echo "<span class='toggle pointer' />";
     }
     if ($filter_data['type'] == 'group_users') {
         echo "<ul class='group_listofusers filters'>";
         foreach ($filter_data['users'] as $user_key => $userdata) {
             self::showSingleLinePlanningFilter($user_key, $userdata, array('show_delete' => false, 'filter_color_index' => $params['filter_color_index']));
         }
         echo "</ul>";
     }
     echo "</li>";
 }
Beispiel #6
0
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     if (!$this->isNewID($ID)) {
         $this->check($ID, READ);
     } else {
         // Create item
         $this->check(-1, CREATE);
     }
     $this->showFormHeader($options);
     $fields = $this->getAdditionalFields();
     $nb = count($fields);
     echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>";
     echo "<td>";
     if ($this instanceof CommonDevice) {
         // Awfull hack for CommonDevice where name is designation
         Html::autocompletionTextField($this, "designation");
     } else {
         Html::autocompletionTextField($this, "name");
     }
     echo "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>" . __('Comments') . "</td>";
     echo "<td rowspan='" . ($nb + 1) . "'>\n            <textarea cols='45' rows='" . ($nb + 2) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     foreach ($fields as $field) {
         if ($field['name'] == 'entities_id' && $ID == 0 && !$this->isNewID($ID)) {
             // No display for root entity
             echo "<tr class='tab_bg_1'><td colspan='2'>&nbsp;</td></tr>";
             break;
         }
         if (!isset($field['type'])) {
             $field['type'] = '';
         }
         if ($field['name'] == 'header') {
             echo "<tr class='tab_bg_1'><th colspan='2'>" . $field['label'] . "</th></tr>";
             continue;
         }
         echo "<tr class='tab_bg_1'><td>" . $field['label'];
         if (isset($field['comment']) && !empty($field['comment'])) {
             echo "&nbsp;";
             Html::showToolTip($field['comment']);
         }
         echo "</td><td>";
         switch ($field['type']) {
             case 'UserDropdown':
                 $param = array('name' => $field['name'], 'value' => $this->fields[$field['name']], 'right' => 'interface', 'entity' => $this->fields["entities_id"]);
                 if (isset($field['right'])) {
                     $params['right'] = $field['right'];
                 }
                 User::dropdown($param);
                 break;
             case 'dropdownValue':
                 $params = array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $this->getEntityID());
                 if (isset($field['condition'])) {
                     $params['condition'] = $field['condition'];
                 }
                 Dropdown::show(getItemTypeForTable(getTableNameForForeignKeyField($field['name'])), $params);
                 break;
             case 'text':
                 Html::autocompletionTextField($this, $field['name']);
                 break;
             case 'textarea':
                 $cols = 40;
                 $rows = 3;
                 if (isset($field['rows'])) {
                     $rows = $field['rows'];
                 }
                 if (isset($field['cols'])) {
                     $cols = $field['cols'];
                 }
                 echo "<textarea name='" . $field['name'] . "' cols='{$cols}' rows='{$rows}'>" . $this->fields[$field['name']] . "</textarea >";
                 break;
             case 'integer':
                 Dropdown::showNumber($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'timestamp':
                 $param = array('value' => $this->fields[$field['name']]);
                 if (isset($field['min'])) {
                     $param['min'] = $field['min'];
                 }
                 if (isset($field['max'])) {
                     $param['max'] = $field['max'];
                 }
                 if (isset($field['step'])) {
                     $param['step'] = $field['step'];
                 }
                 Dropdown::showTimeStamp($field['name'], $param);
                 break;
             case 'parent':
                 if ($field['name'] == 'entities_id') {
                     $restrict = -1;
                 } else {
                     $restrict = $this->getEntityID();
                 }
                 Dropdown::show(getItemTypeForTable($this->getTable()), array('value' => $this->fields[$field['name']], 'name' => $field['name'], 'entity' => $restrict, 'used' => $ID > 0 ? getSonsOf($this->getTable(), $ID) : array()));
                 break;
             case 'icon':
                 Dropdown::dropdownIcons($field['name'], $this->fields[$field['name']], GLPI_ROOT . "/pics/icones");
                 if (!empty($this->fields[$field['name']])) {
                     echo "&nbsp;<img style='vertical-align:middle;' alt='' src='" . $CFG_GLPI["typedoc_icon_dir"] . "/" . $this->fields[$field['name']] . "'>";
                 }
                 break;
             case 'bool':
                 Dropdown::showYesNo($field['name'], $this->fields[$field['name']]);
                 break;
             case 'color':
                 Html::showColorField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'date':
                 Html::showDateField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'datetime':
                 Html::showDateTimeField($field['name'], array('value' => $this->fields[$field['name']]));
                 break;
             case 'password':
                 echo "<input type='password' name='password' value='' size='20' autocomplete='off'>";
                 break;
             default:
                 $this->displaySpecificTypeField($ID, $field);
                 break;
         }
         if (isset($field['unit'])) {
             echo "&nbsp;" . $field['unit'];
         }
         echo "</td></tr>\n";
     }
     if (isset($this->fields['is_protected']) && $this->fields['is_protected']) {
         $options['candel'] = false;
     }
     if (isset($_REQUEST['_in_modal'])) {
         echo "<input type='hidden' name='_in_modal' value='1'>";
     }
     $this->showFormButtons($options);
     return true;
 }
 /**
  * Select a field using standard system
  *
  * @since version 0.83
  *
  * @param $field_id_or_search_options  integer/string/array id of the search option field
  *                                                             or field name
  *                                                             or search option array
  * @param $name                        string               name of the select (if empty use linkfield)
  *                                                          (default '')
  * @param $values                                           mixed default value to display
  *                                                          (default '')
  * @param $options                     array                of possible options:
  * Parameters which could be used in options array :
  *    - comments : boolean / is the comments displayed near the value (default false)
  *    - any others options passed to specific display method
  *
  * @return return the string to display
  **/
 function getValueToSelect($field_id_or_search_options, $name = '', $values = '', $options = array())
 {
     global $CFG_GLPI;
     $param['comments'] = false;
     $param['html'] = false;
     foreach ($param as $key => $val) {
         if (!isset($options[$key])) {
             $options[$key] = $val;
         }
     }
     $searchoptions = array();
     if (is_array($field_id_or_search_options)) {
         $searchoptions = $field_id_or_search_options;
     } else {
         $searchopt = $this->getSearchOptions();
         // Get if id of search option is passed
         if (is_numeric($field_id_or_search_options)) {
             if (isset($searchopt[$field_id_or_search_options])) {
                 $searchoptions = $searchopt[$field_id_or_search_options];
             }
         } else {
             // Get if field name is passed
             $searchoptions = $this->getSearchOptionByField('field', $field_id_or_search_options, $this->getTable());
         }
     }
     if (count($searchoptions)) {
         $field = $searchoptions['field'];
         // Normalize option
         if (is_array($values)) {
             $value = $values[$field];
         } else {
             $value = $values;
             $values = array($field => $value);
         }
         if (empty($name)) {
             $name = $searchoptions['linkfield'];
         }
         // If not set : set to specific
         if (!isset($searchoptions['datatype'])) {
             $searchoptions['datatype'] = 'specific';
         }
         $options['display'] = false;
         $unit = '';
         if (isset($searchoptions['unit'])) {
             $unit = $searchoptions['unit'];
         }
         if (isset($options[$searchoptions['table'] . '.' . $searchoptions['field']])) {
             $options = array_merge($options, $options[$searchoptions['table'] . '.' . $searchoptions['field']]);
         }
         switch ($searchoptions['datatype']) {
             case "count":
             case "number":
             case "integer":
                 $copytooption = array('min', 'max', 'step', 'toadd', 'unit');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showNumber($name, $options);
             case "decimal":
             case "mac":
             case "ip":
             case "string":
             case "email":
             case "weblink":
                 $this->fields[$name] = $value;
                 return Html::autocompletionTextField($this, $name, $options);
             case "text":
                 $out = '';
                 if (isset($searchoptions['htmltext']) && $searchoptions['htmltext']) {
                     $out = Html::initEditorSystem($name, '', false);
                 }
                 return $out . "<textarea cols='45' rows='5' name='{$name}'>{$value}</textarea>";
             case "bool":
                 return Dropdown::showYesNo($name, $value, -1, $options);
             case "color":
                 return Html::showColorField($name, $options);
             case "date":
             case "date_delay":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('min', 'max', 'maybeempty', 'showyear');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateField($name, $options);
             case "datetime":
                 if (isset($options['relative_dates']) && $options['relative_dates']) {
                     if (isset($searchoptions['maybefuture']) && $searchoptions['maybefuture']) {
                         $options['with_future'] = true;
                     }
                     $options['with_time'] = true;
                     return Html::showGenericDateTimeSearch($name, $value, $options);
                 }
                 $copytooption = array('mindate', 'maxdate', 'mintime', 'maxtime', 'maybeempty', 'timestep');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Html::showDateTimeField($name, $options);
             case "timestamp":
                 $copytooption = array('addfirstminutes', 'emptylabel', 'inhours', 'max', 'min', 'step', 'toadd', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showTimeStamp($name, $options);
             case "itemlink":
                 // Do not use dropdown if wanted to select string value instead of ID
                 if (isset($options['itemlink_as_string']) && $options['itemlink_as_string']) {
                     break;
                 }
             case "dropdown":
                 $copytooption = array('condition', 'displaywith', 'emptylabel', 'right', 'toadd');
                 $options['name'] = $name;
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (!isset($options['entity'])) {
                     $options['entity'] = $_SESSION['glpiactiveentities'];
                 }
                 $itemtype = getItemTypeForTable($searchoptions['table']);
                 return $itemtype::dropdown($options);
             case "right":
                 return Profile::dropdownRights(Profile::getRightsFor($searchoptions['rightclass']), $name, $value, array('multiple' => false, 'display' => false));
             case "itemtypename":
                 if (isset($searchoptions['itemtype_list'])) {
                     $options['types'] = $CFG_GLPI[$searchoptions['itemtype_list']];
                 }
                 $copytooption = array('types');
                 $options['value'] = $value;
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 if (isset($options['types'])) {
                     return Dropdown::showItemTypes($name, $options['types'], $options);
                 }
                 return false;
             case "language":
                 $copytooption = array('emptylabel', 'display_emptychoice');
                 foreach ($copytooption as $key) {
                     if (isset($searchoptions[$key]) && !isset($options[$key])) {
                         $options[$key] = $searchoptions[$key];
                     }
                 }
                 $options['value'] = $value;
                 return Dropdown::showLanguages($name, $options);
         }
         // Get specific display if available
         $itemtype = getItemTypeForTable($searchoptions['table']);
         if ($item = getItemForItemtype($itemtype)) {
             $specific = $item->getSpecificValueToSelect($searchoptions['field'], $name, $values, $options);
             if (strlen($specific)) {
                 return $specific;
             }
         }
     }
     // default case field text
     $this->fields[$name] = $value;
     return Html::autocompletionTextField($this, $name, $options);
 }