showFromArray() static public method

Dropdown of values in an array
static public showFromArray ( $name, array $elements, $options = [] )
$name select name
$elements array array of elements to display
$options array of possible options: - value : integer / preselected value (default 0) - used : array / Already used items ID: not to display in dropdown (default empty) - readonly : boolean / used as a readonly item (default false) - on_change : string / value to transmit to "onChange" - multiple : boolean / can select several values (default false) - size : integer / number of rows for the select (default = 1) - display : boolean / display or return string - other : boolean or string if not false, then we can use an "other" value if it is a string, then the default value will be this string - rand : specific rand if needed (default is generated one) - width : specific width needed (default not set) - emptylabel : empty label if empty displayed (default self::EMPTY_VALUE) - display_emptychoice : display empty choice (default false) - tooltip : string / message to add as tooltip on the dropdown (default '') - option_tooltips : array / message to add as tooltip on the dropdown options. Use the same keys as for the $elements parameter, but none is mandotary. Missing keys will just be ignored and no tooltip will be added. To add a tooltip on an option group, is the '__optgroup_label' key inside the array describing option tooltips : 'optgroupname1' => array('__optgroup_label' => 'tooltip for option group') (default empty) Permit to use optgroup defining items in arrays array('optgroupname' => array('key1' => 'val1', 'key2' => 'val2'), 'optgroupname2' => array('key3' => 'val3', 'key4' => 'val4'))
コード例 #1
1
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     echo "<form name='notificationtargets_form' id='notificationtargets_form'\n             method='post' action=' ";
     echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
     echo "<table class    ='tab_cadre_fixe'>";
     echo '<tr><th colspan="2">' . __('Access type', 'formcreator') . '</th></tr>';
     echo '<td>' . __('Access', 'formcreator') . '</td>';
     echo '<td>';
     Dropdown::showFromArray('access_rights', array(PluginFormcreatorForm::ACCESS_PUBLIC => __('Public access', 'formcreator'), PluginFormcreatorForm::ACCESS_PRIVATE => __('Private access', 'formcreator'), PluginFormcreatorForm::ACCESS_RESTRICTED => __('Restricted access', 'formcreator')), array('value' => isset($item->fields["access_rights"]) ? $item->fields["access_rights"] : 1));
     echo '</td>';
     if ($item->fields["access_rights"] == PluginFormcreatorForm::ACCESS_RESTRICTED) {
         echo '<tr><th colspan="2">' . self::getTypeName(2) . '</th></tr>';
         $table = getTableForItemType(__CLASS__);
         $table_profile = getTableForItemType('Profile');
         $query = "SELECT p.`id`, p.`name`, IF(f.`plugin_formcreator_profiles_id` IS NOT NULL, 1, 0) AS `profile`\n                   FROM {$table_profile} p\n                   LEFT JOIN {$table} f\n                     ON p.`id` = f.`plugin_formcreator_profiles_id`\n                     AND f.`plugin_formcreator_forms_id` = " . (int) $item->fields['id'];
         $result = $GLOBALS['DB']->query($query);
         while (list($id, $name, $profile) = $GLOBALS['DB']->fetch_array($result)) {
             $checked = $profile ? ' checked' : '';
             echo '<tr><td colspan="2"><label>';
             echo '<input type="checkbox" name="profiles_id[]" value="' . $id . '" ' . $checked . '> ';
             echo $name;
             echo '</label></td></tr>';
         }
     }
     echo '<tr>';
     echo '<td class="center" colspan="2">';
     echo '<input type="hidden" name="profiles_id[]" value="0" />';
     echo '<input type="hidden" name="form_id" value="' . (int) $item->fields['id'] . '" />';
     echo '<input type="submit" name="update" value="' . __('Save') . '" class="submit" />';
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     Html::closeForm();
 }
コード例 #2
0
 static function showForGroup(Group $group)
 {
     global $DB;
     $ID = $group->getField('id');
     if (!$group->can($ID, READ)) {
         return false;
     }
     $canedit = $group->can($ID, UPDATE);
     if ($canedit) {
         // Get data
         $item = new self();
         if (!$item->getFromDB($ID)) {
             $item->getEmpty();
         }
         $rand = mt_rand();
         echo "<form name='group_level_form{$rand}' id='group_level_form{$rand}' method='post'\n                action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<input type='hidden' name='" . self::$items_id . "' value='{$ID}' />";
         echo "<div class='spaced'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th>" . __('Level attribution', 'itilcategorygroups') . "</th></tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         Dropdown::showFromArray('lvl', array(NULL => "---", 1 => __('Level 1', 'itilcategorygroups'), 2 => __('Level 2', 'itilcategorygroups'), 3 => __('Level 3', 'itilcategorygroups'), 4 => __('Level 4', 'itilcategorygroups')), array('value' => $item->fields['lvl']));
         echo "</td></tr>";
         echo "</td><td class='center'>";
         if ($item->fields["id"]) {
             echo "<input type='hidden' name='id' value='" . $item->fields["id"] . "'>";
             echo "<input type='submit' name='update' value=\"" . __('Save') . "\"\n                   class='submit'>";
         } else {
             echo "<input type='submit' name='add' value=\"" . __('Save') . "\" class='submit'>";
         }
         echo "</td></tr>";
         echo "</table></div>";
         Html::closeForm();
     }
 }
コード例 #3
0
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Name');
     echo "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'name');
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     Dropdown::showFromArray('type', PluginFusioninventoryCollect::getTypes(), array('value' => $this->fields['type']));
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     echo __('Comments');
     echo "</td>";
     echo "<td class='middle'>";
     echo "<textarea cols='45' rows='3' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td>";
     echo "<td>" . __('Active') . "</td>";
     echo "<td>";
     Dropdown::showYesNo('is_active', $this->fields['is_active']);
     echo "</td>";
     echo "</tr>\n";
     $this->showFormButtons($options);
     return TRUE;
 }
コード例 #4
0
 public function displayField($canEdit = true)
 {
     if ($canEdit) {
         $rand = mt_rand();
         $tab_values = array();
         $required = $this->fields['required'] ? ' required' : '';
         $values = $this->getAvailableValues();
         echo '<div class="form_field">';
         if (!empty($this->fields['values'])) {
             foreach ($values as $value) {
                 if (trim($value) != '') {
                     $tab_values[$value] = $value;
                 }
             }
             if ($this->fields['show_empty']) {
                 $tab_values = array('' => '-----') + $tab_values;
             }
             Dropdown::showFromArray('formcreator_field_' . $this->fields['id'], $tab_values, array('value' => static::IS_MULTIPLE ? '' : $this->getValue(), 'values' => static::IS_MULTIPLE ? $this->getValue() : array(), 'rand' => $rand, 'multiple' => static::IS_MULTIPLE));
         }
         echo '</div>' . PHP_EOL;
         echo '<script type="text/javascript">
               jQuery(document).ready(function($) {
                  jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").on("change", function(e) {
                     var selectedValues = jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").val();
                     formcreatorChangeValueOf (' . $this->fields['id'] . ', selectedValues);
                  });
               });
            </script>';
     } else {
         echo '<div class="form_field">';
         echo nl2br($this->getAnswer());
         echo '</div>' . PHP_EOL;
     }
 }
コード例 #5
0
 static function dropdownEvents($itemtype, $value = '')
 {
     $events = array();
     $target = NotificationTarget::getInstanceByType($itemtype);
     if ($target) {
         $events = $target->getAllEvents();
     }
     $events[''] = DROPDOWN_EMPTY_VALUE;
     Dropdown::showFromArray('event', $events, array('value' => $value));
 }
コード例 #6
0
 function manageContacts($items_id)
 {
     global $LANG;
     $pmContact = new PluginMonitoringContact();
     $user = new User();
     $a_list = $this->find("`plugin_monitoring_hosts_id`='" . $items_id . "'");
     echo "<form name='contacts_form' id='contacts_form'\n             method='post' action=' ";
     echo getItemTypeFormURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='3'>";
     echo $LANG['plugin_monitoring']['contact'][20];
     echo "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td class='right'>";
     $a_contacts = $pmContact->find();
     $a_elements = array();
     foreach ($a_contacts as $data) {
         $user->getFromDB($data['users_id']);
         $a_elements[$data['id']] = $user->getName();
     }
     asort($a_elements);
     Dropdown::showFromArray('plugin_monitoring_contacts_id', $a_elements);
     echo "</td>";
     echo "<td class='center'>";
     echo "<input type='submit' class='submit' name='parent_add' value='" . $LANG['buttons'][8] . " >>'>";
     echo "<br><br>";
     if ($a_list) {
         echo "<input type='submit' class='submit' name='parent_delete' value='<< " . $LANG['buttons'][6] . "'>";
     }
     echo "</td>";
     echo "<td>";
     if ($a_list) {
         echo "<select name='parent_to_delete[]' multiple size='5'>";
         foreach ($a_list as $data) {
             $pmContact->getFromDB($data['plugin_monitoring_contacts_id']);
             $user->getFromDB($pmContact->fields['users_id']);
             echo "<option value='" . $data['plugin_monitoring_contacts_id'] . "'>" . $user->getName() . "</option>";
         }
         echo "</select>";
     } else {
         echo "&nbsp;";
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
     echo "<input type='hidden' name='id' value='" . $items_id . "' />";
     echo "</form>";
 }
コード例 #7
0
 function displayCriteria()
 {
     $this->getReport()->startColumn();
     echo $this->getCriteriaLabel() . '&nbsp;:';
     $this->getReport()->endColumn();
     $this->getReport()->startColumn();
     if (empty($this->signe)) {
         Dropdown::showFromArray($this->getName() . "_sign", array('<=' => '<=', '>=' => '>='), array('value' => Toolbox::unclean_cross_side_scripting_deep($this->getParameter($this->getName() . "_sign"))));
         echo "&nbsp;";
     }
     Dropdown::showInteger($this->getName(), $this->getParameterValue(), $this->min, $this->max, 1);
     echo '&nbsp; ' . $this->unit;
     $this->getReport()->endColumn();
 }
コード例 #8
0
ファイル: state.class.php プロジェクト: geldarr/hack-space
 /**
  * Dropdown of states for behaviour config
  *
  * @param $name            select name
  * @param $lib    string   to add for -1 value (default '')
  * @param $value           default value (default 0)
  **/
 static function dropdownBehaviour($name, $lib = "", $value = 0)
 {
     global $DB;
     $elements = array("0" => __('Keep status'));
     if ($lib) {
         $elements["-1"] = $lib;
     }
     $queryStateList = "SELECT `id`, `name`\n                         FROM `glpi_states`\n                         ORDER BY `name`";
     $result = $DB->query($queryStateList);
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_assoc($result)) {
             $elements[$data["id"]] = sprintf(__('Set status: %s'), $data["name"]);
         }
     }
     Dropdown::showFromArray($name, $elements, array('value' => $value));
 }
コード例 #9
0
 /**
  * Dropdown of states for behaviour config
  *
  * @param $name select name
  * @param $lib string to add for -1 value
  * @param $value default value
  **/
 static function dropdownBehaviour($name, $lib = "", $value = 0)
 {
     global $DB, $LANG;
     $elements = array("0" => $LANG['setup'][195]);
     if ($lib) {
         $elements["-1"] = $lib;
     }
     $queryStateList = "SELECT `id`, `name`\n                         FROM `glpi_states`\n                         ORDER BY `name`";
     $result = $DB->query($queryStateList);
     if ($DB->numrows($result) > 0) {
         while ($data = $DB->fetch_assoc($result)) {
             $elements[$data["id"]] = $LANG['setup'][198] . " : " . $data["name"];
         }
     }
     Dropdown::showFromArray($name, $elements, array('value' => $value));
 }
コード例 #10
0
ファイル: bookmark.class.php プロジェクト: pvasener/glpi
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     global $CFG_GLPI;
     switch ($ma->getAction()) {
         case 'move_bookmark':
             $values = array('after' => __('After'), 'before' => __('Before'));
             Dropdown::showFromArray('move_type', $values, array('width' => '20%'));
             $param = array('name' => "bookmarks_id_ref", 'width' => '50%');
             $param['condition'] = "(`is_private`='1' AND `users_id`='" . Session::getLoginUserID() . "') ";
             $param['entity'] = -1;
             Bookmark::dropdown($param);
             echo "<br><br>\n";
             echo Html::submit(_x('button', 'Move'), array('name' => 'massiveaction')) . "</span>";
             return true;
     }
     return parent::showMassiveActionsSubForm($ma);
 }
コード例 #11
0
 /**
  * @param $itemtype
  * @param $options   array to pass to showFromArray or $value
  **/
 static function dropdownEvents($itemtype, $options = array())
 {
     $p['name'] = 'event';
     $p['display'] = true;
     $p['value'] = '';
     $p['display_emptychoice'] = true;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     $events = array();
     $target = NotificationTarget::getInstanceByType($itemtype);
     if ($target) {
         $events = $target->getAllEvents();
     }
     return Dropdown::showFromArray($p['name'], $events, $p);
 }
コード例 #12
0
 public function displayField($canEdit = true)
 {
     if ($canEdit) {
         $rand = mt_rand();
         $required = $this->fields['required'] ? ' required' : '';
         echo '<div class="form_field">';
         if (!empty($this->fields['values'])) {
             $values = array();
             if ($this->fields['show_empty']) {
                 $values[0] = Dropdown::EMPTY_VALUE;
             }
             $obj = new $this->fields['values']();
             $obj->getEmpty();
             $where = '';
             $whereTab = array();
             if (isset($obj->fields['is_deleted'])) {
                 $whereTab[] = '`is_deleted` = 0';
             }
             if (isset($obj->fields['is_active'])) {
                 $whereTab[] = '`is_active` = 1';
             }
             $where = implode(' AND ', $whereTab);
             $result = $obj->find($where);
             foreach ($result as $id => $datas) {
                 if ($this->fields['values'] == 'User') {
                     $values[$id] = getUserName($id);
                 } else {
                     $values[$id] = $datas['name'];
                 }
             }
             Dropdown::showFromArray('formcreator_field_' . $this->fields['id'], $values, array('value' => $this->getValue(), 'comments' => false, 'rand' => $rand));
         }
         echo '</div>' . PHP_EOL;
         echo '<script type="text/javascript">
               jQuery(document).ready(function($) {
                  jQuery("#dropdown_formcreator_field_' . $this->fields['id'] . $rand . '").on("select2-selecting", function(e) {
                     formcreatorChangeValueOf (' . $this->fields['id'] . ', e.val);
                  });
               });
            </script>';
     } else {
         echo $this->getAnswer();
     }
 }
コード例 #13
0
 function showForm($user_id, $options = array())
 {
     global $LANG;
     $target = $this->getFormURL();
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     $tzID = $this->getIDFromUserID($user_id);
     if ($user_id) {
         if (!$tzID) {
             $tz = ini_get('date.timezone');
             if (empty($tz)) {
                 $tz = @date_default_timezone_get();
             }
             $this->add(array('users_id' => $user_id, 'timezone' => $tz));
             $tzID = $this->getID();
         } else {
             $this->getFromDB($tzID);
         }
     } else {
         return;
     }
     echo "<form action='" . $target . "' method='post'>";
     echo "<input type=hidden name=users_id value='{$user_id}'/>";
     echo "<input type=hidden name=id value='{$tzID}'/>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . $LANG['timezones']['item']['header'] . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . $LANG['timezones']['item']['dropdown'] . " :</td><td>";
     $timezones = self::getTimezones();
     Dropdown::showFromArray('timezone', $timezones, array('value' => $this->fields["timezone"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center'>";
     echo "<input type='submit' name='update' class='submit' value=\"" . $LANG['timezones']['item']['submit'] . "\">";
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
 }
コード例 #14
0
 function displaySpecificTypeField($ID, $field = array())
 {
     switch ($field['type']) {
         case 'instantiation_type':
             Dropdown::showFromArray($field['name'], NetworkPort::getNetworkPortInstantiationsWithNames(), array('value' => $this->fields[$field['name']]));
             break;
         case 'type':
             Dropdown::showFromArray('type', NetworkPortEthernet::getPortTypeName(), array('value' => $this->fields[$field['name']]));
             break;
         case 'speed':
             $standard_speeds = NetworkPortEthernet::getPortSpeed();
             if (!isset($standard_speeds[$this->fields['speed']]) && !empty($this->fields['speed'])) {
                 $speed = NetworkPortEthernet::transformPortSpeed($this->fields['speed'], true);
             } else {
                 $speed = true;
             }
             Dropdown::showFromArray('speed', $standard_speeds, array('value' => $this->fields['speed'], 'other' => $speed));
             break;
         case 'version':
             Dropdown::showFromArray('version', WifiNetwork::getWifiCardVersion(), array('value' => $this->fields['version']));
             break;
     }
 }
コード例 #15
0
 /**
  * @since version 0.84
  **/
 static function title()
 {
     global $PLUGIN_HOOKS, $CFG_GLPI;
     $opt_list["Ticket"] = __('Tickets');
     $stat_list["Ticket"]["Ticket_Global"]["name"] = __('Global');
     $stat_list["Ticket"]["Ticket_Global"]["file"] = "stat.global.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Ticket"]["name"] = __('By ticket');
     $stat_list["Ticket"]["Ticket_Ticket"]["file"] = "stat.tracking.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Location"]["name"] = __('By hardware characteristics');
     $stat_list["Ticket"]["Ticket_Location"]["file"] = "stat.location.php?itemtype=Ticket";
     $stat_list["Ticket"]["Ticket_Item"]["name"] = __('By hardware');
     $stat_list["Ticket"]["Ticket_Item"]["file"] = "stat.item.php";
     if (Problem::canView()) {
         $opt_list["Problem"] = _n('Problem', 'Problems', Session::getPluralNumber());
         $stat_list["Problem"]["Problem_Global"]["name"] = __('Global');
         $stat_list["Problem"]["Problem_Global"]["file"] = "stat.global.php?itemtype=Problem";
         $stat_list["Problem"]["Problem_Problem"]["name"] = __('By problem');
         $stat_list["Problem"]["Problem_Problem"]["file"] = "stat.tracking.php?itemtype=Problem";
     }
     if (Change::canView()) {
         $opt_list["Change"] = _n('Change', 'Changes', Session::getPluralNumber());
         $stat_list["Change"]["Change_Global"]["name"] = __('Global');
         $stat_list["Change"]["Change_Global"]["file"] = "stat.global.php?itemtype=Change";
         $stat_list["Change"]["Change_Change"]["name"] = __('By change');
         $stat_list["Change"]["Change_Change"]["file"] = "stat.tracking.php?itemtype=Change";
     }
     //Affichage du tableau de presentation des stats
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='2'>" . __('Select statistics to be displayed') . "</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     $values = array($CFG_GLPI["root_doc"] . '/front/stat.php' => Dropdown::EMPTY_VALUE);
     $i = 0;
     $selected = -1;
     $count = count($stat_list);
     foreach ($opt_list as $opt => $group) {
         while ($data = each($stat_list[$opt])) {
             $name = $data[1]["name"];
             $file = $data[1]["file"];
             $comment = "";
             if (isset($data[1]["comment"])) {
                 $comment = $data[1]["comment"];
             }
             $key = $CFG_GLPI["root_doc"] . "/front/" . $file;
             $values[$group][$key] = $name;
             if (stripos($_SERVER['REQUEST_URI'], $key) !== false) {
                 $selected = $key;
             }
         }
     }
     // Manage plugins
     $names = array();
     $optgroup = array();
     if (isset($PLUGIN_HOOKS["stats"]) && is_array($PLUGIN_HOOKS["stats"])) {
         foreach ($PLUGIN_HOOKS["stats"] as $plug => $pages) {
             if (is_array($pages) && count($pages)) {
                 foreach ($pages as $page => $name) {
                     $names[$plug . '/' . $page] = array("name" => $name, "plug" => $plug);
                     $optgroup[$plug] = Plugin::getInfo($plug, 'name');
                 }
             }
         }
         asort($names);
     }
     foreach ($optgroup as $opt => $title) {
         $group = $title;
         foreach ($names as $key => $val) {
             if ($opt == $val["plug"]) {
                 $file = $CFG_GLPI["root_doc"] . "/plugins/" . $key;
                 $values[$group][$file] = $val["name"];
                 if (stripos($_SERVER['REQUEST_URI'], $file) !== false) {
                     $selected = $file;
                 }
             }
         }
     }
     Dropdown::showFromArray('statmenu', $values, array('on_change' => "window.location.href=this.options[this.selectedIndex].value", 'value' => $selected));
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
コード例 #16
0
ファイル: user.class.php プロジェクト: geldarr/hack-space
 /**
  * Print the user preference form
  *
  * @param $target          form target
  * @param $ID     integer  Id of the user
  *
  * @return boolean : user found
  **/
 function showMyForm($target, $ID)
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) {
         return false;
     }
     if ($this->getFromDB($ID)) {
         $authtype = $this->getAuthMethodsByID();
         $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
         // No autocopletion :
         $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"];
         $CFG_GLPI["use_ajax_autocompletion"] = false;
         echo "<div class='center'>";
         echo "<form method='post' name='user_manager' action='" . $target . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . sprintf(__('%1$s: %2$s'), __('Login'), $this->fields["name"]);
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>";
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
         if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) {
             echo $this->fields["realname"];
         } else {
             Html::autocompletionTextField($this, "realname");
         }
         echo "</td>";
         //do some rights verification
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<td>" . __('Password') . "</td>";
             echo "<td><input id='password' type='password' name='password' value='' size='30' autocomplete='off' onkeyup=\"return passwordCheck();\">";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'></tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
         if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
             echo $this->fields["firstname"];
         } else {
             Html::autocompletionTextField($this, "firstname");
         }
         echo "</td>";
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<td>" . __('Password confirmation') . "</td>";
             echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
             echo "</td></tr>";
         } else {
             echo "<td colspan='2'></tr>";
         }
         echo "<tr class='tab_bg_1'><td class='top'>" . _n('Email', 'Emails', 2);
         UserEmail::showAddEmailButton($this);
         echo "</td><td>";
         UserEmail::showForUser($this);
         echo "</td>";
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<td>" . __('Password security policy') . "</td>";
             echo "<td>";
             Config::displayPasswordSecurityChecks();
             echo "</td>";
         } else {
             echo "<td colspan='2'>";
         }
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Mobile phone') . "&nbsp;:</td><td>";
         if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
             echo $this->fields["mobile"];
         } else {
             Html::autocompletionTextField($this, "mobile");
         }
         echo "</td>";
         if (!GLPI_DEMO_MODE) {
             echo "<td>" . __('Language') . "</td><td>";
             // Use session variable because field in table may be null if same of the global config
             Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Phone') . "</td><td>";
         if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
             echo $this->fields["phone"];
         } else {
             Html::autocompletionTextField($this, "phone");
         }
         echo "</td>";
         if (count($_SESSION['glpiprofiles']) > 1) {
             echo "<td>" . __('Default profile') . "</td><td>";
             $options = array(0 => Dropdown::EMPTY_VALUE);
             $options += Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Phone 2') . "</td><td>";
         if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
             echo $this->fields["phone2"];
         } else {
             Html::autocompletionTextField($this, "phone2");
         }
         echo "</td>";
         $entities = Profile_User::getUserEntities($this->fields['id'], 1);
         if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
             echo "<td>" . __('Default entity') . "</td><td>";
             Entity::dropdown(array('value' => $this->fields['entities_id'], 'entity' => $entities));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
         $entities = Profile_User::getUserEntities($ID, true);
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $entities));
         if (Session::haveRight("config", "w")) {
             echo "<td>" . __('Use GLPI in mode') . "</td><td>";
             $modes[Session::NORMAL_MODE] = __('Normal');
             //$modes[Session::TRANSLATION_MODE] = __('Translation');
             $modes[Session::DEBUG_MODE] = __('Debug');
             Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
         return true;
     }
     return false;
 }
コード例 #17
0
ファイル: profile.class.php プロジェクト: glpi-project/glpi
 /**
  * Dropdown profiles which have rights under the active one
  *
  * @since version 0.84
  *
  * @param $options array of possible options:
  *    - name : string / name of the select (default is profiles_id)
  *    - values : array of values
  **/
 static function dropdownHelpdeskItemtypes($options)
 {
     global $CFG_GLPI;
     $p['name'] = 'helpdesk_item_type';
     $p['values'] = array();
     $p['display'] = true;
     if (is_array($options) && count($options)) {
         foreach ($options as $key => $val) {
             $p[$key] = $val;
         }
     }
     $values = self::getHelpdeskItemtypes();
     $p['multiple'] = true;
     $p['size'] = 3;
     return Dropdown::showFromArray($p['name'], $values, $p);
 }
コード例 #18
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();
     }
 }
コード例 #19
0
ファイル: networkportwifi.class.php プロジェクト: kipman/glpi
 /**
  * @param $field
  * @param $name            (default'')
  * @param $values           (default '')
  * @param $options   array
  **/
 static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array())
 {
     if (!is_array($values)) {
         $values = array($field => $values);
     }
     $options['display'] = false;
     switch ($field) {
         case 'mode':
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, WifiNetwork::getWifiCardModes(), $options);
         case 'version':
             $options['value'] = $values[$field];
             return Dropdown::showFromArray($name, WifiNetwork::getWifiCardVersion(), $options);
     }
     return parent::getSpecificValueToSelect($field, $name, $values, $options);
 }
コード例 #20
0
ファイル: calendarsegment.class.php プロジェクト: kipman/glpi
 /**
  * Show segments of a calendar
  *
  * @param $calendar Calendar object
  **/
 static function showForCalendar(Calendar $calendar)
 {
     global $DB, $CFG_GLPI;
     $ID = $calendar->getField('id');
     if (!$calendar->can($ID, READ)) {
         return false;
     }
     $canedit = $calendar->can($ID, UPDATE);
     $rand = mt_rand();
     $query = "SELECT *\n                FROM `glpi_calendarsegments`\n                WHERE `calendars_id` = '{$ID}'\n                ORDER BY `day`, `begin`, `end`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='calendarsegment_form{$rand}' id='calendarsegment_form{$rand}' method='post'\n                action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='7'>" . __('Add a schedule') . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>" . __('Day') . "</td><td>";
         echo "<input type='hidden' name='calendars_id' value='{$ID}'>";
         Dropdown::showFromArray('day', Toolbox::getDaysOfWeekArray());
         echo "</td><td class='center'>" . __('Start') . '</td><td>';
         Dropdown::showHours("begin", array('value' => date('H') . ":00"));
         echo "</td><td class='center'>" . __('End') . '</td><td>';
         Dropdown::showHours("end", array('value' => date('H') + 1 . ":00"));
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     echo "<div class='spaced'>";
     if ($canedit && $numrows) {
         Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
         $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
         Html::showMassiveActions($massiveactionparams);
     }
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr>";
     if ($canedit && $numrows) {
         echo "<th width='10'>";
         Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
         echo "</th>";
     }
     echo "<th>" . __('Day') . "</th>";
     echo "<th>" . __('Start') . "</th>";
     echo "<th>" . __('End') . "</th>";
     echo "</tr>";
     $daysofweek = Toolbox::getDaysOfWeekArray();
     if ($numrows) {
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td>";
                 Html::showMassiveActionCheckBox(__CLASS__, $data["id"]);
                 echo "</td>";
             }
             echo "<td>";
             echo $daysofweek[$data['day']];
             echo "</td>";
             echo "<td>" . $data["begin"] . "</td>";
             echo "<td>" . $data["end"] . "</td>";
         }
         echo "</tr>";
     }
     echo "</table>";
     if ($canedit && $numrows) {
         $massiveactionparams['ontop'] = false;
         Html::showMassiveActions($massiveactionparams);
         Html::closeForm();
     }
     echo "</div>";
 }
コード例 #21
0
 /**
  * Print the mandatory fields
  *
  * @since version 0.83
  *
  * @param $tt                       Ticket Template
  * @param $withtemplate    boolean  Template or basic item (default '')
  *
  * @return Nothing (call to classes members)
  **/
 static function showForTicketTemplate(TicketTemplate $tt, $withtemplate = '')
 {
     global $DB;
     $ID = $tt->fields['id'];
     if (!$tt->getFromDB($ID) || !$tt->can($ID, READ)) {
         return false;
     }
     $canedit = $tt->canEdit($ID);
     $ttm = new self();
     $used = $ttm->getMandatoryFields($ID);
     $fields = $tt->getAllowedFieldsNames(true);
     $simplified_fields = $tt->getSimplifiedInterfaceFields();
     $both_interfaces = sprintf(__('%1$s + %2$s'), __('Simplified interface'), __('Standard interface'));
     $rand = mt_rand();
     $query = "SELECT `glpi_tickettemplatemandatoryfields`.*\n                FROM `glpi_tickettemplatemandatoryfields`\n                WHERE (`tickettemplates_id` = '{$ID}')";
     if ($result = $DB->query($query)) {
         $mandatoryfields = array();
         $used = array();
         if ($numrows = $DB->numrows($result)) {
             while ($data = $DB->fetch_assoc($result)) {
                 $mandatoryfields[$data['id']] = $data;
                 $used[$data['num']] = $data['num'];
             }
         }
         if ($canedit) {
             echo "<div class='firstbloc'>";
             echo "<form name='changeproblem_form{$rand}' id='changeproblem_form{$rand}' method='post'\n                   action='" . Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_2'><th colspan='2'>" . __('Add a mandatory field') . "</th></tr>";
             echo "<tr class='tab_bg_2'><td class='right'>";
             echo "<input type='hidden' name='tickettemplates_id' value='{$ID}'>";
             $select_fields = $fields;
             foreach ($select_fields as $key => $val) {
                 if (in_array($key, $simplified_fields)) {
                     $select_fields[$key] = sprintf(__('%1$s (%2$s)'), $val, $both_interfaces);
                 } else {
                     $select_fields[$key] = sprintf(__('%1$s (%2$s)'), $val, __('Standard interface'));
                 }
             }
             Dropdown::showFromArray('num', $select_fields, array('used' => $used));
             echo "</td><td class='center'>";
             echo "&nbsp;<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</td></tr>";
             echo "</table>";
             Html::closeForm();
             echo "</div>";
         }
         echo "<div class='spaced'>";
         if ($canedit && $numrows) {
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $numrows, 'container' => 'mass' . __CLASS__ . $rand);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr class='noHover'><th colspan='3'>";
         echo self::getTypeName($DB->numrows($result));
         echo "</th></tr>";
         if ($numrows) {
             $header_begin = "<tr>";
             $header_top = '';
             $header_bottom = '';
             $header_end = '';
             if ($canedit) {
                 $header_top .= "<th width='10'>";
                 $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
                 $header_bottom .= "<th width='10'>";
                 $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand) . "</th>";
             }
             $header_end .= "<th>" . __('Name') . "</th>";
             $header_end .= "<th>" . __("Profile's interface") . "</th>";
             $header_end .= "</tr>";
             echo $header_begin . $header_top . $header_end;
             foreach ($mandatoryfields as $data) {
                 echo "<tr class='tab_bg_2'>";
                 if ($canedit) {
                     echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                 }
                 echo "<td>" . $fields[$data['num']] . "</td>";
                 echo "<td>";
                 if (in_array($data['num'], $simplified_fields)) {
                     echo $both_interfaces;
                 } else {
                     _e('Standard interface');
                 }
                 echo "</td>";
                 echo "</tr>";
             }
             echo $header_begin . $header_bottom . $header_end;
         } else {
             echo "<tr><th colspan='2'>" . __('No item found') . "</th></tr>";
         }
         echo "</table>";
         if ($canedit && $numrows) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
         echo "</div>";
     }
 }
コード例 #22
0
ファイル: reservationitem.class.php プロジェクト: btry/glpi
 static function showListSimple()
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight(self::$rightname, self::RESERVEANITEM)) {
         return false;
     }
     $ri = new self();
     $ok = false;
     $showentity = Session::isMultiEntitiesMode();
     $values = array();
     if (isset($_SESSION['glpi_saved']['ReservationItem'])) {
         $_POST = $_SESSION['glpi_saved']['ReservationItem'];
     }
     if (isset($_POST['reserve'])) {
         echo "<div id='viewresasearch'  class='center'>";
         Toolbox::manageBeginAndEndPlanDates($_POST['reserve']);
         echo "<div id='nosearch' class='center firstbloc'>" . "<a href=\"" . $CFG_GLPI['root_doc'] . "/front/reservationitem.php\">";
         echo __('See all reservable items') . "</a></div>\n";
     } else {
         echo "<div id='makesearch' class='center firstbloc'>" . "<a class='pointer' onClick=\"javascript:showHideDiv('viewresasearch','','','');" . "showHideDiv('makesearch','','','')\">";
         echo __('Find a free item in a specific period') . "</a></div>\n";
         echo "<div id='viewresasearch' style=\"display:none;\" class='center'>";
         $begin_time = time();
         $begin_time -= $begin_time % HOUR_TIMESTAMP;
         $_POST['reserve']["begin"] = date("Y-m-d H:i:s", $begin_time);
         $_POST['reserve']["end"] = date("Y-m-d H:i:s", $begin_time + HOUR_TIMESTAMP);
         $_POST['reservation_types'] = '';
     }
     echo "<form method='post' name='form' action='" . Toolbox::getItemTypeSearchURL(__CLASS__) . "'>";
     echo "<table class='tab_cadre_fixe'><tr class='tab_bg_2'>";
     echo "<th colspan='3'>" . __('Find a free item in a specific period') . "</th></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Start date') . "</td><td>";
     Html::showDateTimeField("reserve[begin]", array('value' => $_POST['reserve']["begin"], 'maybeempty' => false));
     echo "</td><td rowspan='3'>";
     echo "<input type='submit' class='submit' name='submit' value=\"" . _sx('button', 'Search') . "\">";
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Duration') . "</td><td>";
     $default_delay = floor((strtotime($_POST['reserve']["end"]) - strtotime($_POST['reserve']["begin"])) / $CFG_GLPI['time_step'] / MINUTE_TIMESTAMP) * $CFG_GLPI['time_step'] * MINUTE_TIMESTAMP;
     $rand = Dropdown::showTimeStamp("reserve[_duration]", array('min' => 0, 'max' => 48 * HOUR_TIMESTAMP, 'value' => $default_delay, 'emptylabel' => __('Specify an end date')));
     echo "<br><div id='date_end{$rand}'></div>";
     $params = array('duration' => '__VALUE__', 'end' => $_POST['reserve']["end"], 'name' => "reserve[end]");
     Ajax::updateItemOnSelectEvent("dropdown_reserve[_duration]{$rand}", "date_end{$rand}", $CFG_GLPI["root_doc"] . "/ajax/planningend.php", $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Item type') . "</td><td>";
     $sql = "SELECT DISTINCT(`itemtype`)\n              FROM `glpi_reservationitems`\n              WHERE `is_active` = 1" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']);
     $result = $DB->query($sql);
     while ($data = $DB->fetch_assoc($result)) {
         $values[$data['itemtype']] = $data['itemtype']::getTypeName();
     }
     $query = "SELECT `glpi_peripheraltypes`.`name`, `glpi_peripheraltypes`.`id`\n                FROM `glpi_peripheraltypes`\n                LEFT JOIN `glpi_peripherals`\n                  ON `glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`\n                LEFT JOIN `glpi_reservationitems`\n                  ON `glpi_reservationitems`.`items_id` = `glpi_peripherals`.`id`\n                WHERE `itemtype` = 'Peripheral'\n                      AND `is_active` = 1\n                      AND `peripheraltypes_id`" . getEntitiesRestrictRequest(" AND", 'glpi_reservationitems', 'entities_id', $_SESSION['glpiactiveentities']) . "\n                ORDER BY `glpi_peripheraltypes`.`name`";
     foreach ($DB->request($query) as $ptype) {
         $id = $ptype['id'];
         $values["Peripheral#{$id}"] = $ptype['name'];
     }
     Dropdown::showFromArray("reservation_types", $values, array('value' => $_POST['reservation_types'], 'display_emptychoice' => true));
     echo "</td></tr>";
     echo "</table>";
     Html::closeForm();
     echo "</div>";
     // GET method passed to form creation
     echo "<div id='nosearch' class='center'>";
     echo "<form name='form' method='GET' action='reservation.form.php'>";
     echo "<table class='tab_cadre_fixehov'>";
     echo "<tr><th colspan='" . ($showentity ? "5" : "4") . "'>" . self::getTypeName(1) . "</th></tr>\n";
     foreach ($CFG_GLPI["reservation_types"] as $itemtype) {
         if (!($item = getItemForItemtype($itemtype))) {
             continue;
         }
         $itemtable = getTableForItemType($itemtype);
         $otherserial = "'' AS otherserial";
         if ($item->isField('otherserial')) {
             $otherserial = "`{$itemtable}`.`otherserial`";
         }
         $begin = $_POST['reserve']["begin"];
         $end = $_POST['reserve']["end"];
         $left = "";
         $where = "";
         if (isset($_POST['submit']) && isset($begin) && isset($end)) {
             $left = "LEFT JOIN `glpi_reservations`\n                        ON (`glpi_reservationitems`.`id` = `glpi_reservations`.`reservationitems_id`\n                            AND '" . $begin . "' < `glpi_reservations`.`end`\n                            AND '" . $end . "' > `glpi_reservations`.`begin`)";
             $where = " AND `glpi_reservations`.`id` IS NULL ";
         }
         if (isset($_POST["reservation_types"]) && !empty($_POST["reservation_types"])) {
             $tmp = explode('#', $_POST["reservation_types"]);
             $where .= " AND `glpi_reservationitems`.`itemtype` = '" . $tmp[0] . "'";
             if (isset($tmp[1]) && $tmp[0] == 'Peripheral' && $itemtype == 'Peripheral') {
                 $left .= " LEFT JOIN `glpi_peripheraltypes`\n                              ON (`glpi_peripherals`.`peripheraltypes_id` = `glpi_peripheraltypes`.`id`)";
                 $where .= " AND `{$itemtable}`.`peripheraltypes_id` = '" . $tmp[1] . "'";
             }
         }
         $query = "SELECT `glpi_reservationitems`.`id`,\n                          `glpi_reservationitems`.`comment`,\n                          `{$itemtable}`.`name` AS name,\n                          `{$itemtable}`.`entities_id` AS entities_id,\n                          {$otherserial},\n                          `glpi_locations`.`id` AS location,\n                          `glpi_reservationitems`.`items_id` AS items_id\n                   FROM `glpi_reservationitems`\n                   INNER JOIN `{$itemtable}`\n                        ON (`glpi_reservationitems`.`itemtype` = '{$itemtype}'\n                            AND `glpi_reservationitems`.`items_id` = `{$itemtable}`.`id`)\n                   {$left}\n                   LEFT JOIN `glpi_locations`\n                        ON (`{$itemtable}`.`locations_id` = `glpi_locations`.`id`)\n                   WHERE `glpi_reservationitems`.`is_active` = '1'\n                         AND `glpi_reservationitems`.`is_deleted` = '0'\n                         AND `{$itemtable}`.`is_deleted` = '0'\n                         {$where} " . getEntitiesRestrictRequest(" AND", $itemtable, '', $_SESSION['glpiactiveentities'], $item->maybeRecursive()) . "\n                   ORDER BY `{$itemtable}`.`entities_id`,\n                            `{$itemtable}`.`name`";
         if ($result = $DB->query($query)) {
             while ($row = $DB->fetch_assoc($result)) {
                 echo "<tr class='tab_bg_2'><td>";
                 echo "<input type='checkbox' name='item[" . $row["id"] . "]' value='" . $row["id"] . "'>" . "</td>";
                 $typename = $item->getTypeName();
                 if ($itemtype == 'Peripheral') {
                     $item->getFromDB($row['items_id']);
                     if (isset($item->fields["peripheraltypes_id"]) && $item->fields["peripheraltypes_id"] != 0) {
                         $typename = Dropdown::getDropdownName("glpi_peripheraltypes", $item->fields["peripheraltypes_id"]);
                     }
                 }
                 echo "<td><a href='reservation.php?reservationitems_id=" . $row['id'] . "'>" . sprintf(__('%1$s - %2$s'), $typename, $row["name"]) . "</a></td>";
                 echo "<td>" . Dropdown::getDropdownName("glpi_locations", $row["location"]) . "</td>";
                 echo "<td>" . nl2br($row["comment"]) . "</td>";
                 if ($showentity) {
                     echo "<td>" . Dropdown::getDropdownName("glpi_entities", $row["entities_id"]) . "</td>";
                 }
                 echo "</tr>\n";
                 $ok = true;
             }
         }
     }
     if ($ok) {
         echo "<tr class='tab_bg_1 center'><td colspan='" . ($showentity ? "5" : "4") . "'>";
         if (isset($_POST['reserve'])) {
             echo Html::hidden('begin', array('value' => $_POST['reserve']["begin"]));
             echo Html::hidden('end', array('value' => $_POST['reserve']["end"]));
         }
         echo "<input type='submit' value=\"" . _sx('button', 'Add') . "\" class='submit'></td></tr>\n";
     }
     echo "</table>\n";
     echo "<input type='hidden' name='id' value=''>";
     echo "</form>";
     // No CSRF token needed
     echo "</div>\n";
 }
コード例 #23
0
 /**
  * Print the transfer form
  *
  * @param $ID Integer : Id of the contact to print
  * @param $options array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $LANG;
     if (!haveRight("transfer", "r")) {
         return false;
     }
     $edit_form = true;
     if (!strpos($_SERVER['PHP_SELF'], "transfer.form.php")) {
         $edit_form = false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $params = array();
     if (!haveRight("transfer", "w")) {
         $params['readonly'] = true;
     }
     if ($edit_form) {
         $this->showTabs($options);
         $this->showFormHeader($options);
     } else {
         echo "<form method='post' name=form action='" . $options['target'] . "'>";
         echo "<div class='center' id='tabsbody' >";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><td class='tab_bg_2 top' colspan='4'>";
         echo "<div class='center'>";
         Dropdown::show('Entity', array('name' => 'to_entity'));
         echo "&nbsp;<input type='submit' name='transfer' value=\"" . $LANG['buttons'][48] . "\"\n                      class='submit'></div>";
         echo "</td></tr>";
     }
     if ($edit_form) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['common'][16] . "&nbsp;:</td><td>";
         autocompletionTextField($this, "name");
         echo "</td>";
         echo "<td rowspan='3' class='middle right'>" . $LANG['common'][25] . "&nbsp;: </td>";
         echo "<td class='center middle' rowspan='3'>\n               <textarea cols='45' rows='3' name='comment' >" . $this->fields["comment"] . "</textarea>";
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['common'][26] . "&nbsp;: </td>";
         echo "<td>" . ($this->fields["date_mod"] ? convDateTime($this->fields["date_mod"]) : $LANG['setup'][307]);
         echo "</td></tr>";
     }
     $keep = array(0 => $LANG['buttons'][6], 1 => $LANG['buttons'][49]);
     $clean = array(0 => $LANG['buttons'][49], 1 => $LANG['buttons'][6], 2 => $LANG['buttons'][22]);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['title'][38] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_history'];
     Dropdown::showFromArray('keep_history', $keep, $params);
     echo "</td>";
     if (!$edit_form) {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . $LANG['Menu'][38] . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['networking'][6] . "&nbsp;:</td><td>";
     $options = array(0 => $LANG['buttons'][6], 1 => $LANG['buttons'][49] . " - " . $LANG['buttons'][10], 2 => $LANG['buttons'][49] . " - " . $LANG['buttons'][9]);
     $params['value'] = $this->fields['keep_networklink'];
     Dropdown::showFromArray('keep_networklink', $options, $params);
     echo "</td>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['title'][28] . "&nbsp;:</td><td>";
     $options = array(0 => $LANG['buttons'][6], 1 => $LANG['buttons'][49] . " - " . $LANG['buttons'][10], 2 => $LANG['buttons'][49] . " - " . $LANG['buttons'][48]);
     $params['value'] = $this->fields['keep_ticket'];
     Dropdown::showFromArray('keep_ticket', $options, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][0] . " -> " . $LANG["Menu"][4] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_software'];
     Dropdown::showFromArray('keep_software', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][4] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_software'];
     Dropdown::showFromArray('clean_software', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['Menu'][17] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_reservation'];
     Dropdown::showFromArray('keep_reservation', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][0] . " -> " . $LANG['title'][30] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_device'];
     Dropdown::showFromArray('keep_device', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][2] . " -> " . $LANG["Menu"][21] . " / " . $LANG['cartridges'][12] . "&nbsp;:" . "</td><td>";
     $params['value'] = $this->fields['keep_cartridgeitem'];
     Dropdown::showFromArray('keep_cartridgeitem', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG['cartridges'][12] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_cartridgeitem'];
     Dropdown::showFromArray('clean_cartridgeitem', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['cartridges'][12] . " -> " . $LANG["Menu"][21] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_cartridge'];
     Dropdown::showFromArray('keep_cartridge', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG['financial'][3] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_infocom'];
     Dropdown::showFromArray('keep_infocom', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][92] . " -> " . $LANG["Menu"][32] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_consumable'];
     Dropdown::showFromArray('keep_consumable', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][0] . " -> " . $LANG['computers'][8] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_disk'];
     Dropdown::showFromArray('keep_disk', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . $LANG['connect'][0] . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][3] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_monitor'];
     Dropdown::showFromArray('keep_dc_monitor', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][3] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_monitor'];
     Dropdown::showFromArray('clean_dc_monitor', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][2] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_printer'];
     Dropdown::showFromArray('keep_dc_printer', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][2] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_printer'];
     Dropdown::showFromArray('clean_dc_printer', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][16] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_peripheral'];
     Dropdown::showFromArray('keep_dc_peripheral', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][16] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_peripheral'];
     Dropdown::showFromArray('clean_dc_peripheral', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][34] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_dc_phone'];
     Dropdown::showFromArray('keep_dc_phone', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][34] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_dc_phone'];
     Dropdown::showFromArray('clean_dc_phone', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . $LANG["Menu"][26] . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG["Menu"][23] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_supplier'];
     Dropdown::showFromArray('keep_supplier', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][23] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_supplier'];
     Dropdown::showFromArray('clean_supplier', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG["Menu"][23] . " -> " . $LANG["Menu"][22] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_contact'];
     Dropdown::showFromArray('keep_contact', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][22] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_contact'];
     Dropdown::showFromArray('clean_contact', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG["Menu"][27] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_document'];
     Dropdown::showFromArray('keep_document', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][27] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_document'];
     Dropdown::showFromArray('clean_document', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][66] . " -> " . $LANG["Menu"][25] . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_contract'];
     Dropdown::showFromArray('keep_contract', $keep, $params);
     echo "</td>";
     echo "<td>" . $LANG["Menu"][25] . " (" . $LANG['transfer'][3] . ")&nbsp;:</td><td>";
     $params['value'] = $this->fields['clean_contract'];
     Dropdown::showFromArray('clean_contract', $clean, $params);
     echo "</td></tr>";
     if (haveRight("transfer", "w")) {
         if ($edit_form) {
             $this->showFormButtons($options);
             $this->addDivForTabs();
         } else {
             echo "</table></div></form>";
         }
     }
 }
コード例 #24
0
function displaySearchForm()
{
    global $_SERVER, $_GET, $LANG, $CFG_GLPI;
    echo "<form action='" . $_SERVER["PHP_SELF"] . "' method='post'>";
    echo "<table class='tab_cadre' cellpadding='5'>";
    echo "<tr class='tab_bg_1' align='center'>";
    echo "<td>";
    echo $LANG["financial"][8] . " :";
    $values = array();
    $values["sup"] = ">";
    $values["inf"] = "<";
    $values["equal"] = "=";
    if (isset($_GET["contains"][1])) {
        if (strstr($_GET["contains"][1], "lt;")) {
            $_GET["dropdown_sup_inf"] = "inf";
            $_GET["dropdown_calendar"] = str_replace("lt;", "", $_GET["contains"][1]);
            $_GET["dropdown_calendar"] = str_replace("&", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("\\", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("'", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace(" 00:00:00", "", $_GET["dropdown_calendar"]);
            $_GET["contains"][1] = "<" . $_GET["dropdown_calendar"];
        }
        if (strstr($_GET["contains"][1], "gt;")) {
            $_GET["dropdown_sup_inf"] = "sup";
            $_GET["dropdown_calendar"] = str_replace("gt;", "", $_GET["contains"][1]);
            $_GET["dropdown_calendar"] = str_replace("&", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("\\", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("'", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace(" 00:00:00", "", $_GET["dropdown_calendar"]);
            $_GET["contains"][1] = ">" . $_GET["dropdown_calendar"];
        }
        if (strstr($_GET["contains"][1], "LIKE")) {
            $_GET["dropdown_sup_inf"] = "equal";
            $_GET["dropdown_calendar"] = str_replace("=", "", $_GET["contains"][1]);
            $_GET["dropdown_calendar"] = str_replace("&", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("\\", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("'", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("%", "", $_GET["dropdown_calendar"]);
            $_GET["dropdown_calendar"] = str_replace("LIKE ", "", $_GET["dropdown_calendar"]);
            $_GET["contains"][1] = "LIKE '" . $_GET["dropdown_calendar"] . "%'";
        }
    }
    Dropdown::showFromArray("dropdown_sup_inf", $values, array('value' => isset($_GET["dropdown_sup_inf"]) ? $_GET["dropdown_sup_inf"] : "sup"));
    echo "</td>\n\t\t<td width='120'>";
    showDateFormItem("dropdown_calendar", isset($_GET["dropdown_calendar"]) ? $_GET["dropdown_calendar"] : 0);
    echo "</td>";
    echo "<td>" . $LANG["common"][15] . "</td>";
    echo "<td>";
    Dropdown::show("Location", array('name' => "location", 'value' => isset($_GET["location"]) ? $_GET["location"] : ""));
    echo "</td>";
    // Display Reset search
    echo "<td>";
    echo "<a href='" . $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/report/ports_date_connections.php?reset_search=reset_search' ><img title=\"" . $LANG["buttons"][16] . "\" alt=\"" . $LANG["buttons"][16] . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/reset.png' class='calendrier'></a>";
    echo "</td>";
    echo "<td>";
    //Add parameters to uri to be saved as bookmarks
    $_SERVER["REQUEST_URI"] = buildBookmarkUrl($_SERVER["REQUEST_URI"], $_GET);
    showSaveBookmarkButton(BOOKMARK_SEARCH, PLUGIN_FUSIONINVENTORY_SNMP_NETWORKING_PORTS2);
    echo "</td>";
    echo "<td>";
    echo "<input type='submit' value='Valider' class='submit' />";
    echo "</td>";
    echo "</tr>";
    echo "</table>";
    echo "</form>";
}
コード例 #25
0
 /**
  * Print the search config form
  *
  * @param $target    form target
  * @param $itemtype  item type
  *
  * @return nothing
  **/
 function showFormGlobal($target, $itemtype)
 {
     global $CFG_GLPI, $DB;
     $searchopt = Search::getOptions($itemtype);
     if (!is_array($searchopt)) {
         return false;
     }
     $IDuser = 0;
     $item = NULL;
     if ($itemtype != 'AllAssets') {
         $item = getItemForItemtype($itemtype);
     }
     $global_write = Session::haveRight(self::$rightname, self::GENERAL);
     echo "<div class='center' id='tabsbody' >";
     // Defined items
     $query = "SELECT *\n                FROM `" . $this->getTable() . "`\n                WHERE `itemtype` = '{$itemtype}'\n                      AND `users_id` = '{$IDuser}'\n                ORDER BY `rank`";
     $result = $DB->query($query);
     $numrows = $DB->numrows($result);
     echo "<table class='tab_cadre_fixehov'><tr><th colspan='4'>";
     echo __('Select default items to show') . "</th></tr>\n";
     if ($global_write) {
         $already_added = self::getForTypeUser($itemtype, $IDuser);
         echo "<tr class='tab_bg_1'><td colspan='4' class='center'>";
         echo "<form method='post' action='{$target}'>";
         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
         $group = '';
         $values = array();
         $searchopt = Search::getCleanedOptions($itemtype);
         foreach ($searchopt as $key => $val) {
             if (!is_array($val)) {
                 $group = $val;
             } else {
                 if ($key != 1 && !in_array($key, $already_added) && (!isset($val['nodisplay']) || !$val['nodisplay'])) {
                     $values[$group][$key] = $val["name"];
                 }
             }
         }
         if ($values) {
             Dropdown::showFromArray('num', $values);
             echo "<span class='small_space'>";
             echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
             echo "</span>";
         }
         Html::closeForm();
         echo "</td></tr>";
     }
     // print first element
     echo "<tr class='tab_bg_2'>";
     echo "<td class='center' width='50%'>" . $searchopt[1]["name"];
     if ($global_write) {
         echo "</td><td colspan='3'>&nbsp;";
     }
     echo "</td></tr>";
     // print entity
     if (Session::isMultiEntitiesMode() && (isset($CFG_GLPI["union_search_type"][$itemtype]) || $item && $item->maybeRecursive() || count($_SESSION["glpiactiveentities"]) > 1) && isset($searchopt[80])) {
         echo "<tr class='tab_bg_2'>";
         echo "<td class='center' width='50%'>" . $searchopt[80]["name"] . "</td>";
         echo "<td colspan='3'>&nbsp;</td>";
         echo "</tr>";
     }
     $i = 0;
     if ($numrows) {
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["num"] != 1 && isset($searchopt[$data["num"]])) {
                 echo "<tr class='tab_bg_2'><td class='center' width='50%'>";
                 echo $searchopt[$data["num"]]["name"];
                 echo "</td>";
                 if ($global_write) {
                     if ($i != 0) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='up' value=\"" . __s('Bring up') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-up.png' alt=\"" . __s('Bring up') . "\"  title=\"" . __s('Bring up') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     if ($i != $numrows - 1) {
                         echo "<td class='center middle'>";
                         echo "<form method='post' action='{$target}'>";
                         echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                         echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                         echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                         echo "<input type='image' name='down' value=\"" . __s('Bring down') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/puce-down.png' alt=\"" . __s('Bring down') . "\" title=\"" . __s('Bring down') . "\" class='pointer'>";
                         Html::closeForm();
                         echo "</td>";
                     } else {
                         echo "<td>&nbsp;</td>\n";
                     }
                     echo "<td class='center middle'>";
                     echo "<form method='post' action='{$target}'>";
                     echo "<input type='hidden' name='id' value='" . $data["id"] . "'>";
                     echo "<input type='hidden' name='users_id' value='{$IDuser}'>";
                     echo "<input type='hidden' name='itemtype' value='{$itemtype}'>";
                     echo "<input type='image' name='purge' value=\"" . _sx('button', 'Delete permanently') . "\" src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png' alt=\"" . __s('Delete permanently') . "\" title=\"" . __s('Delete permanently') . "\"  class='pointer'>";
                     Html::closeForm();
                     echo "</td>\n";
                 }
                 echo "</tr>";
                 $i++;
             }
         }
     }
     echo "</table>";
     echo "</div>";
 }
コード例 #26
0
 /**
  * show actor add div
  *
  * @param $type         string   actor type
  * @param $rand_type    integer  rand value of div to use
  * @param $entities_id  integer  entity ID
  * @param $is_hidden    array    of hidden fields (if empty consider as not hidden)
  * @param $withgroup    boolean  allow adding a group (true by default)
  * @param $withsupplier boolean  allow adding a supplier (only one possible in ASSIGN case)
  *                               (false by default)
  * @param $inobject     boolean  display in ITIL object ? (true by default)
  *
  * @return nothing display
  **/
 function showActorAddForm($type, $rand_type, $entities_id, $is_hidden = array(), $withgroup = true, $withsupplier = false, $inobject = true)
 {
     global $CFG_GLPI;
     $types = array('' => Dropdown::EMPTY_VALUE, 'user' => __('User'));
     if ($withgroup) {
         $types['group'] = __('Group');
     }
     if ($withsupplier && $type == CommonITILActor::ASSIGN) {
         $types['supplier'] = __('Supplier');
     }
     $typename = self::getActorFieldNameType($type);
     switch ($type) {
         case CommonITILActor::REQUESTER:
             if (isset($is_hidden['_users_id_requester']) && $is_hidden['_users_id_requester']) {
                 unset($types['user']);
             }
             if (isset($is_hidden['_groups_id_requester']) && $is_hidden['_groups_id_requester']) {
                 unset($types['group']);
             }
             break;
         case CommonITILActor::OBSERVER:
             if (isset($is_hidden['_users_id_observer']) && $is_hidden['_users_id_observer']) {
                 unset($types['user']);
             }
             if (isset($is_hidden['_groups_id_observer']) && $is_hidden['_groups_id_observer']) {
                 unset($types['group']);
             }
             break;
         case CommonITILActor::ASSIGN:
             if (isset($is_hidden['_users_id_assign']) && $is_hidden['_users_id_assign']) {
                 unset($types['user']);
             }
             if (isset($is_hidden['_groups_id_assign']) && $is_hidden['_groups_id_assign']) {
                 unset($types['group']);
             }
             if (isset($types['supplier']) && isset($is_hidden['_suppliers_id_assign']) && $is_hidden['_suppliers_id_assign']) {
                 unset($types['supplier']);
             }
             break;
         default:
             return false;
     }
     echo "<div " . ($inobject ? "style='display:none'" : '') . " id='itilactor{$rand_type}'>";
     $rand = Dropdown::showFromArray("_itil_" . $typename . "[_type]", $types);
     $params = array('type' => '__VALUE__', 'actortype' => $typename, 'itemtype' => $this->getType(), 'allow_email' => $type == CommonITILActor::OBSERVER || $type == CommonITILActor::REQUESTER, 'entity_restrict' => $entities_id, 'use_notif' => Entity::getUsedConfig('is_notif_enable_default', $entities_id, '', 1));
     Ajax::updateItemOnSelectEvent("dropdown__itil_" . $typename . "[_type]{$rand}", "showitilactor" . $typename . "_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/dropdownItilActors.php", $params);
     echo "<span id='showitilactor" . $typename . "_{$rand}'>&nbsp;</span>";
     if ($inobject) {
         echo "<hr>";
     }
     echo "</div>";
 }
コード例 #27
0
 /**
  * @since version 0.84
  *
  * @see Rule::displayAdditionalRuleCondition()
  **/
 function displayAdditionalRuleCondition($condition, $criteria, $name, $value, $test = false)
 {
     global $PLUGIN_HOOKS;
     if ($criteria['field'] == '_source') {
         $tab = array();
         foreach ($PLUGIN_HOOKS['import_item'] as $plug => $types) {
             $tab[$plug] = Plugin::getInfo($plug, 'name');
         }
         Dropdown::showFromArray($name, $tab);
         return true;
     }
     return false;
 }
コード例 #28
0
 static function displayDropdownType($config, $request_data, $rand, $mode)
 {
     global $CFG_GLPI;
     /*
      * Build dropdown options
      */
     $dropdown_options['rand'] = $rand;
     if ($mode === 'edit') {
         $dropdown_options['value'] = $config['type'];
         $dropdown_options['readonly'] = true;
     }
     /*
      * Build actions types list
      */
     $file_types = self::getTypes();
     array_unshift($file_types, "---");
     /*
      * Display dropdown html
      */
     $style = "";
     if (isset($datas['edit'])) {
         $style = "style='display:none'";
     }
     echo "<table class='package_item' {$style}>";
     echo "<tr>";
     echo "<th>" . __("Source", 'fusioninventory') . "</th>";
     echo "<td>";
     Dropdown::showFromArray("deploy_filetype", $file_types, $dropdown_options);
     echo "</td>";
     echo "</tr></table>";
     //ajax update of file value span
     if ($mode === 'create') {
         $params = array('value' => '__VALUE__', 'rand' => $rand, 'myname' => 'method', 'type' => "file", 'mode' => $mode);
         Ajax::updateItemOnEvent("dropdown_deploy_filetype" . $rand, "show_file_value{$rand}", $CFG_GLPI["root_doc"] . "/plugins/fusioninventory/" . "ajax/deploy_displaytypevalue.php", $params, array("change", "load"));
     }
 }
コード例 #29
0
 public function displayDropdownCriteria()
 {
     Dropdown::showFromArray($this->getName(), $this->choice, array('value' => $this->getParameterValue()));
 }
コード例 #30
0
ファイル: html.class.php プロジェクト: OlivierLM/glpi
 /**
  * Print the form used to select profile if several are available
  *
  * @param $target target of the form
  *
  * @return nothing
  **/
 static function showProfileSelecter($target)
 {
     global $CFG_GLPI;
     if (count($_SESSION["glpiprofiles"]) > 1) {
         echo '<li class="profile-selector"><form name="form" method="post" action="' . $target . '">';
         $values = array();
         foreach ($_SESSION["glpiprofiles"] as $key => $val) {
             $values[$key] = $val['name'];
         }
         Dropdown::showFromArray('newprofile', $values, array('value' => $_SESSION["glpiactiveprofile"]["id"], 'width' => '150px', 'on_change' => 'submit()'));
         Html::closeForm();
         echo '</li>';
     }
     if (Session::isMultiEntitiesMode()) {
         echo "<li class='profile-selector'>";
         Ajax::createModalWindow('entity_window', $CFG_GLPI['root_doc'] . "/ajax/entitytree.php", array('title' => __('Select the desired entity'), 'extraparams' => array('target' => $target)));
         echo "<a onclick='entity_window.dialog(\"open\");' href='#modal_entity_content' title=\"" . addslashes($_SESSION["glpiactive_entity_name"]) . "\" class='entity_select' id='global_entity_select'>" . $_SESSION["glpiactive_entity_shortname"] . "</a>";
         echo "</li>";
     }
 }