コード例 #1
0
 /**
  * Print the printer form
  *
  * @param $ID integer ID of the item
  * @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;
     $target = $this->getFormURL();
     $withtemplate = '';
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (isset($options['withtemplate'])) {
         $withtemplate = $options['withtemplate'];
     }
     if (!haveRight("printer", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = $LANG['computers'][14] . " : ";
         $date = convDateTime($_SESSION["glpi_currenttime"]);
     } else {
         if (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
             $template = "newtemplate";
             $datestring = $LANG['computers'][14] . " : ";
             $date = convDateTime($_SESSION["glpi_currenttime"]);
         } else {
             $datestring = $LANG['common'][26] . " : ";
             $date = convDateTime($this->fields["date_mod"]);
             $template = false;
         }
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . ($template ? "*" : "") . "&nbsp;:</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>\n";
     echo "<td>" . $LANG['state'][0] . "&nbsp;:</td>\n";
     echo "<td>";
     Dropdown::show('State', array('value' => $this->fields["states_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][15] . "&nbsp;: </td>\n";
     echo "<td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . $LANG['common'][17] . "&nbsp;:</td>\n";
     echo "<td>";
     Dropdown::show('PrinterType', array('value' => $this->fields["printertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][10] . "&nbsp;:</td>\n";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . $LANG['common'][5] . "&nbsp;:</td>\n";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][21] . "&nbsp;:</td>\n";
     echo "<td>";
     autocompletionTextField($this, "contact_num");
     echo "</td>\n";
     echo "<td>" . $LANG['common'][22] . "&nbsp;:</td>\n";
     echo "<td>";
     Dropdown::show('PrinterModel', array('value' => $this->fields["printermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][18] . "&nbsp;:</td>\n";
     echo "<td>";
     autocompletionTextField($this, "contact");
     echo "</td>\n";
     echo "<td>" . $LANG['common'][19] . "&nbsp;:</td>\n";
     echo "<td>";
     autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][34] . "&nbsp;:</td>\n";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>\n";
     echo "<td>" . $LANG['common'][20] . ($template ? "*" : "") . "&nbsp;:</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][35] . "&nbsp;:</td>\n";
     echo "<td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . $LANG['peripherals'][33] . "&nbsp;:</td>";
     echo "<td>";
     if ($this->can($ID, 'w')) {
         Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["printers_management_restrict"], 'target' => $target));
     } else {
         Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'target' => $target));
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][89] . "&nbsp;:</td>\n";
     echo "<td>";
     Dropdown::show('Domain', array('value' => $this->fields["domains_id"]));
     echo "</td>";
     echo "<td>" . $LANG['setup'][88] . "&nbsp;:</td>\n";
     echo "<td>";
     Dropdown::show('Network', array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['devices'][6] . "&nbsp;:</td>\n";
     echo "<td>";
     autocompletionTextField($this, "memory_size");
     echo "</td>";
     echo "<td rowspan='4'>";
     echo $LANG['common'][25] . "&nbsp;:</td>\n";
     echo "<td rowspan='4'><textarea cols='45' rows='8' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['printers'][30] . "&nbsp;:</td>\n";
     echo "<td>";
     autocompletionTextField($this, "init_pages_counter");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['printers'][18] . "&nbsp;: </td>";
     echo "<td>\n<table>";
     // serial interface
     echo "<tr><td>" . $LANG['printers'][14] . "</td><td>";
     Dropdown::showYesNo("have_serial", $this->fields["have_serial"]);
     echo "</td></tr>";
     // parallel interface?
     echo "<tr><td>" . $LANG['printers'][15] . "</td><td>";
     Dropdown::showYesNo("have_parallel", $this->fields["have_parallel"]);
     echo "</td></tr>";
     // USB interface?
     echo "<tr><td>" . $LANG['printers'][27] . "</td><td>";
     Dropdown::showYesNo("have_usb", $this->fields["have_usb"]);
     echo "</td></tr>";
     // ethernet interface?
     echo "<tr><td>" . $LANG['printers'][28] . "</td><td>";
     Dropdown::showYesNo("have_ethernet", $this->fields["have_ethernet"]);
     echo "</td></tr>";
     // wifi ?
     echo "<tr><td>" . $LANG['printers'][29] . "</td><td>";
     Dropdown::showYesNo("have_wifi", $this->fields["have_wifi"]);
     echo "</td></tr></table>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center' height='30'>" . $datestring . "&nbsp;" . $date;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         echo "(" . $LANG['common'][13] . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
コード例 #2
0
 function showForm($ID, $options = array())
 {
     $PluginRacksConfig = new PluginRacksConfig();
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     //ligne 1
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td><td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Size') . "</td><td>";
     Dropdown::showInteger("rack_size", $this->fields["rack_size"], 1, 100, 1);
     echo " " . __('U', 'racks') . "</td>";
     echo "</tr>";
     //ligne 2
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Manufacturer') . "</td><td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td>";
     echo "<td >" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . __('Technician in charge of the hardware') . "</td>";
     echo "<td >";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Place', 'racks');
     echo "</td><td>";
     $PluginRacksRoomLocation = new PluginRacksRoomLocation();
     $PluginRacksRoomLocation->dropdownRoomLocations("plugin_racks_roomlocations_id", $this->fields["plugin_racks_roomlocations_id"], $this->fields["entities_id"]);
     echo "</td>";
     echo "</tr>";
     //ligne 4
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td><td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Width', 'racks') . "</td><td>";
     echo "<input type='text' name='width' \n                              value=\"" . Html::formatNumber($this->fields["width"], true) . "\" size='10'> ";
     $PluginRacksConfig->getUnit("size");
     echo "</td>";
     echo "</tr>";
     //ligne 5
     echo "<tr class='tab_bg_1'>";
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'serial');
     echo "</td>";
     echo "<td>" . __('Height', 'racks') . "</td><td>";
     echo "<input type='text' name='height' \n                              value=\"" . Html::formatNumber($this->fields["height"], true) . "\" size='10'> ";
     $PluginRacksConfig->getUnit("size");
     echo "</td>";
     echo "</tr>";
     //ligne 6
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Inventory number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'otherserial');
     echo "</td>";
     echo "<td>" . __('Weight', 'racks') . "</td><td>";
     echo "<input type='text' name='weight' \n                              value=\"" . Html::formatNumber($this->fields["weight"], true) . "\" size='10'> ";
     $PluginRacksConfig->getUnit("weight");
     echo "</td>";
     echo "</tr>";
     //ligne 7
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     Dropdown::show('PluginRacksRackModel', array('name' => "plugin_racks_rackmodels_id", 'value' => $this->fields["plugin_racks_rackmodels_id"]));
     echo "</td>";
     echo "<td>" . __('Depth', 'racks') . "</td><td>";
     echo "<input type='text' name='depth' \n                              value=\"" . Html::formatNumber($this->fields["depth"], true) . "\" size='10'> ";
     $PluginRacksConfig->getUnit("size");
     echo "</td>";
     echo "</tr>";
     //ligne 8
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . __('Type') . "</td><td>";
     Dropdown::show('PluginRacksRackType', array('value' => $this->fields["plugin_racks_racktypes_id"]));
     echo "</td>";
     echo "<td >" . __('Status') . "</td><td>";
     Dropdown::show('PluginRacksRackState', array('value' => $this->fields["plugin_racks_rackstates_id"]));
     echo "</td>";
     echo "</tr>";
     //ligne 9
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2'>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td colspan='2'>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of update
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     if (!$this->isNewID($this->getID())) {
         $this->showTotal();
     }
     return true;
 }
コード例 #3
0
 /**
  * Print the Software / license form
  *
  * @param $ID        integer  Id of the version or the template to print
  * @param $options   array    of possible options:
  *     - target form target
  *     - softwares_id ID of the software for add process
  *
  * @return true if displayed  false if item not found or not right to display
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $softwares_id = -1;
     if (isset($options['softwares_id'])) {
         $softwares_id = $options['softwares_id'];
     }
     if ($ID < 0) {
         // Create item
         $this->fields['softwares_id'] = $softwares_id;
         $this->fields['number'] = 1;
         $soft = new Software();
         if ($soft->getFromDB($softwares_id) && in_array($_SESSION['glpiactive_entity'], getAncestorsOf('glpi_entities', $soft->getEntityID()))) {
             $options['entities_id'] = $soft->getEntityID();
         }
     }
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     // Restore saved value or override with page parameter
     if (!isset($options['template_preview'])) {
         if (isset($_REQUEST)) {
             $saved = Html::cleanPostForTextArea($_REQUEST);
         }
     }
     foreach ($this->fields as $name => $value) {
         if (isset($saved[$name]) && empty($this->fields[$name])) {
             $this->fields[$name] = $saved[$name];
         }
     }
     echo "<input type='hidden' name='withtemplate' value='" . $options['withtemplate'] . "'>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . Software::getTypeName(1) . "</td>";
     echo "<td>";
     if ($ID > 0) {
         $softwares_id = $this->fields["softwares_id"];
         echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>";
         echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>";
     } else {
         Dropdown::show('Software', array('condition' => "`is_template`='0' AND `is_deleted`='0'", 'entity' => $_SESSION['glpiactive_entity'], 'entity_sons' => $_SESSION['glpiactive_entity_recursive'], 'on_change' => 'this.form.submit()', 'value' => $softwares_id));
     }
     echo "</td>";
     echo "<td colspan='2'>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_softwarelicense`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td><td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     SoftwareLicenseType::dropdown(array('value' => $this->fields["softwarelicensetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Publisher') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . __('User') . "</td>";
     echo "<td >";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "");
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td><td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='4'>";
     echo "<textarea cols='45' rows='4' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version in use') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdownForOneSoftware(array('name' => "softwareversions_id_use", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_use"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Purchase version') . "</td>";
     echo "<td>";
     SoftwareVersion::dropdownForOneSoftware(array('name' => "softwareversions_id_buy", 'softwares_id' => $this->fields["softwares_id"], 'value' => $this->fields["softwareversions_id_buy"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('quantity', 'Number') . "</td>";
     echo "<td>";
     Dropdown::showNumber("number", array('value' => $this->fields["number"], 'min' => 1, 'max' => 10000, 'step' => 1, 'toadd' => array(-1 => __('Unlimited'))));
     if ($ID > 0) {
         echo "&nbsp;";
         if ($this->fields['is_valid']) {
             echo "<span class='green'>" . _x('adjective', 'Valid') . '<span>';
         } else {
             echo "<span class='red'>" . _x('adjective', 'Invalid') . '<span>';
         }
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Expiration') . "</td>";
     echo "<td>";
     Html::showDateField('expire', array('value' => $this->fields["expire"]));
     if ($ID && is_null($this->fields["expire"])) {
         echo "<br>" . __('Never expire') . "&nbsp;";
         Html::showToolTip(__('On search engine, use "Expiration contains NULL" to search licenses with no expiration date'));
     }
     Alert::displayLastAlert('SoftwareLicense', $ID);
     echo "</td><td colspan='2'></td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
コード例 #4
0
ファイル: printer.class.php プロジェクト: pvasener/glpi
 /**
  * Print the printer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array of possible options:
  *     - 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;
     $target = $this->getFormURL();
     $withtemplate = $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>\n";
     echo "<td>" . __('Status') . "</td>\n";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_printer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>\n";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . __('Type') . "</td>\n";
     echo "<td>";
     PrinterType::dropdown(array('value' => $this->fields["printertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>\n";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . __('Manufacturer') . "</td>\n";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>\n";
     echo "<td>";
     PrinterModel::dropdown(array('value' => $this->fields["printermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>\n";
     echo "<td>" . __('Serial number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>\n";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>\n";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>\n";
     echo "<td>" . __('Management type') . "</td>";
     echo "<td>";
     $globalitem = array();
     $globalitem['withtemplate'] = $withtemplate;
     $globalitem['value'] = $this->fields["is_global"];
     $globalitem['target'] = $target;
     if ($this->can($ID, UPDATE)) {
         $globalitem['management_restrict'] = $CFG_GLPI["printers_management_restrict"];
     }
     Dropdown::showGlobalSwitch($this->fields["id"], $globalitem);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>\n";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>\n";
     echo "<td>" . __('Network') . "</td>\n";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     // Display auto inventory informations
     $rowspan = 6;
     $inventory_show = false;
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 2;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>\n";
     echo "<td>";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>\n";
     echo "<td rowspan='{$rowspan}'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Memory') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "memory_size");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Initial page counter') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "init_pages_counter", array('size' => 10));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Current counter of pages') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "last_pages_counter", array('size' => 10));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Port', 'Ports', Session::getPluralNumber()) . "</td>";
     echo "<td>\n<table>";
     // serial interface
     echo "<tr><td>" . __('Serial') . "</td><td width='80'>";
     Dropdown::showYesNo("have_serial", $this->fields["have_serial"]);
     echo "</td>";
     // parallel interface?
     echo "<td>" . __('Parallel') . "</td><td width='80'>";
     Dropdown::showYesNo("have_parallel", $this->fields["have_parallel"]);
     echo "</td></tr>";
     // USB interface?
     echo "<tr><td>" . __('USB') . "</td><td>";
     Dropdown::showYesNo("have_usb", $this->fields["have_usb"]);
     echo "</td>";
     // ethernet interface?
     echo "<td>" . __('Ethernet') . "</td><td>";
     Dropdown::showYesNo("have_ethernet", $this->fields["have_ethernet"]);
     echo "</td></tr>";
     // wifi ?
     echo "<tr><td>" . __('Wifi') . "</td><td colspan='3'>";
     Dropdown::showYesNo("have_wifi", $this->fields["have_wifi"]);
     echo "</td></tr></table>\n";
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='2'>" . __('Automatic inventory') . "</td>";
         echo "<td rowspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of insertion
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
コード例 #5
0
ファイル: monitor.class.php プロジェクト: pvasener/glpi
 /**
  * Print the monitor form
  *
  * @param $ID        integer  ID of the item
  * @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;
     $target = $this->getFormURL();
     $withtemplate = $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "");
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "name", array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_monitor`"));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     MonitorType::dropdown(array('value' => $this->fields["monitortypes_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     MonitorModel::dropdown(array('value' => $this->fields["monitormodels_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "otherserial", array('value' => $objectName));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Management type') . "</td>";
     echo "<td>";
     Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["monitors_management_restrict"], 'target' => $target));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='4'>" . __('Comments') . "</td>";
     echo "<td rowspan='4'>\n            <textarea cols='45' rows='10' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Size') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "size");
     echo "\"</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . 'Flags' . "</td>";
     echo "<td><table>";
     // micro?
     echo "<tr><td width='20%'>" . __('Microphone') . "</td><td width='30%'>";
     Dropdown::showYesNo("have_micro", $this->fields["have_micro"]);
     // speakers?
     echo "</td><td width='20%'>" . __('Speakers') . "</td><td width='30%'>";
     Dropdown::showYesNo("have_speaker", $this->fields["have_speaker"]);
     echo "</td></tr>";
     // sub-d?
     echo "<tr><td width='20%'>" . __('Sub-D') . "</td><td width='30%'>";
     Dropdown::showYesNo("have_subd", $this->fields["have_subd"]);
     // bnc?
     echo "</td><td width='20%'>" . __('BNC') . "</td><td width='30%'>";
     Dropdown::showYesNo("have_bnc", $this->fields["have_bnc"]);
     echo "</td></tr>";
     // dvi?
     echo "<tr><td>" . __('DVI') . "</td><td>";
     Dropdown::showYesNo("have_dvi", $this->fields["have_dvi"]);
     // pivot ?
     echo "</td><td>" . __('Pivot') . "</td><td>";
     Dropdown::showYesNo("have_pivot", $this->fields["have_pivot"]);
     echo "</td></tr>";
     // hdmi?
     echo "<tr><td>" . __('HDMI') . "</td><td>";
     Dropdown::showYesNo("have_hdmi", $this->fields["have_hdmi"]);
     //Displayport
     echo "</td><td>" . __('DisplayPort') . "</td><td>";
     Dropdown::showYesNo("have_displayport", $this->fields["have_displayport"]);
     echo "</td></tr>";
     echo "</table></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of insertion
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
コード例 #6
0
   function showForm($items_id, $options=array(), $services_id='') {
      $pMonitoringCommand = new PluginMonitoringCommand();
      $pMonitoringServicedef = new PluginMonitoringServicedef();

      if (isset($_GET['withtemplate']) AND ($_GET['withtemplate'] == '1')) {
         $options['withtemplate'] = 1;
      } else {
         $options['withtemplate'] = 0;
      }

      if ($services_id!='') {
         $this->getEmpty();
      } else {
         $this->getFromDB($items_id);
      }
      $this->showTabs($options);
      $this->showFormHeader($options);
      if (!isset($this->fields['plugin_monitoring_servicedefs_id'])
              OR empty($this->fields['plugin_monitoring_servicedefs_id'])) {
         $pMonitoringServicedef->getEmpty();
      } else {
         $pMonitoringServicedef->getFromDB($this->fields['plugin_monitoring_servicedefs_id']);
      }
      $template = false;


      echo "<tr>";
      echo "<td>";
      if ($services_id!='') {
         echo "<input type='hidden' name='plugin_monitoring_services_id' value='".$services_id."' />";
      }
      echo __('Name')."&nbsp;:";
      echo "</td>";
      echo "<td>";
      $objectName = autoName($this->fields["name"], "name", ($template === "newcomp"),
                             $this->getType());
      Html::autocompletionTextField($this, 'name', array('value' => $objectName));
      echo "</td>";
      echo "<td>";
      echo __('Template')."&nbsp;:";
      echo "</td>";
      echo "<td>";
      if ($items_id != '0') {
         echo "<input type='hidden' name='update' value='update'>\n";
      }
      echo "<input type='hidden' name='plugin_monitoring_servicedefs_id_s' value='".$this->fields['plugin_monitoring_servicedefs_id']."'>\n";
      if ($pMonitoringServicedef->fields['is_template'] == '0') {
         $this->fields['plugin_monitoring_servicedefs_id'] = 0;
      }
      Dropdown::show("PluginMonitoringServicetemplate", array(
            'name' => 'plugin_monitoring_servicetemplates_id',
            'value' => $this->fields['plugin_monitoring_servicetemplates_id'],
            'auto_submit' => true
      ));
      echo "</td>";
      echo "<td>";
      if ($this->fields["items_id"] == '') {

      } else {
         echo "<input type='hidden' name='items_id' value='".$this->fields["items_id"]."'>\n";
         echo "<input type='hidden' name='itemtype' value='".$this->fields["itemtype"]."'>\n";
      }
      echo "</td>";
      echo "</tr>";

      echo "<tr>";
      echo "<th colspan='4'>&nbsp;</th>";
      echo "</tr>";

      echo "<tr>";
      // * itemtype link
      if ($this->fields['itemtype'] != '') {
         $itemtype = $this->fields['itemtype'];
         $item = new $itemtype();
         $item->getFromDB($this->fields['items_id']);
         echo "<td>";
         echo __('Item Type')." <i>".$item->getTypeName()."</i>";
         echo "&nbsp;:</td>";
         echo "<td>";
         echo $item->getLink(1);
         echo "</td>";
      } else {
         echo "<td colspan='2' align='center'>";
         echo __('No type associated', 'monitoring');
         echo "</td>";
      }
      // * command
      echo "<td>";
      echo __('Command', 'monitoring')."&nbsp;:";
      echo "</td>";
      echo "<td align='center'>";
      if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
         $pMonitoringServicetemplate = new PluginMonitoringServicetemplate();
         $pMonitoringServicetemplate->getFromDB($this->fields['plugin_monitoring_servicetemplates_id']);
         $pMonitoringCommand->getFromDB($pMonitoringServicetemplate->fields['plugin_monitoring_commands_id']);
         echo $pMonitoringCommand->getLink(1);
      } else {
         $pMonitoringCommand->getFromDB($pMonitoringServicedef->fields['plugin_monitoring_commands_id']);
         Dropdown::show("PluginMonitoringCommand", array(
                              'name' =>'plugin_monitoring_commands_id',
                              'value'=>$pMonitoringServicedef->fields['plugin_monitoring_commands_id']
                              ));
      }
      echo "</td>";
      echo "</tr>";

      echo "<tr>";
      // * checks
      echo "<td>".__('Check definition', 'monitoring')."&nbsp;:</td>";
      echo "<td align='center'>";
      if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
         $pMonitoringCheck = new PluginMonitoringCheck();
         $pMonitoringCheck->getFromDB($pMonitoringServicetemplate->fields['plugin_monitoring_checks_id']);
         echo $pMonitoringCheck->getLink(1);
      } else {
         Dropdown::show("PluginMonitoringCheck",
                        array('name'=>'plugin_monitoring_checks_id',
                              'value'=>$pMonitoringServicedef->fields['plugin_monitoring_checks_id']));
      }
      echo "</td>";
      // * active check
      echo "<td>";
      echo __('Active check', 'monitoring')."&nbsp;:";
      echo "</td>";
      echo "<td align='center'>";
      if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
         echo Dropdown::getYesNo($pMonitoringServicetemplate->fields['active_checks_enabled']);
      } else {
         Dropdown::showYesNo("active_checks_enabled", $pMonitoringServicedef->fields['active_checks_enabled']);
      }
      echo "</td>";
      echo "</tr>";

      echo "<tr>";
      // * passive check
      echo "<td>";
      echo __('Passive check', 'monitoring')."&nbsp;:";
      echo "</td>";
      echo "<td align='center'>";
      if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
         echo Dropdown::getYesNo($pMonitoringServicetemplate->fields['passive_checks_enabled']);
      } else {
         Dropdown::showYesNo("passive_checks_enabled", $pMonitoringServicedef->fields['passive_checks_enabled']);
      }
      echo "</td>";
      // * calendar
      echo "<td>".__('Check period', 'monitoring')."&nbsp;:</td>";
      echo "<td align='center'>";
      if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
         $calendar = new Calendar();
         $calendar->getFromDB($pMonitoringServicetemplate->fields['calendars_id']);
         echo $calendar->getLink(1);
      } else {
         dropdown::show("Calendar", array('name'=>'calendars_id',
                                 'value'=>$pMonitoringServicedef->fields['calendars_id']));
      }
      echo "</td>";
      echo "</tr>";

      if (!($this->fields['plugin_monitoring_servicetemplates_id'] > 0
              AND $pMonitoringServicetemplate->fields['remotesystem'] == '')) {

         echo "<tr>";
         echo "<th colspan='4'>".__('Remote check', 'monitoring')."</th>";
         echo "</tr>";

         echo "<tr>";
         // * remotesystem
         echo "<td>";
         echo __('Utility used for remote check', 'monitoring')."&nbsp;:";
         echo "</td>";
         echo "<td>";
         $input = array();
         $input[''] = '------';
         $input['byssh'] = 'byssh';
         $input['nrpe'] = 'nrpe';
         $input['nsca'] = 'nsca';
         if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
            echo $input[$pMonitoringServicetemplate->fields['remotesystem']];
         } else {
            Dropdown::showFromArray("remotesystem",
                                 $input,
                                 array('value'=>$pMonitoringServicedef->fields['remotesystem']));
         }
         echo "</td>";
         // * is_argument
         echo "<td>";
         echo __('Use arguments (NRPE only)', 'monitoring')."&nbsp;:";
         echo "</td>";
         echo "<td>";
         if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
            echo Dropdown::getYesNo($pMonitoringServicetemplate->fields['is_arguments']);
         } else {
            Dropdown::showYesNo("is_arguments", $pMonitoringServicedef->fields['is_arguments']);
         }
         echo "</td>";
         echo "</tr>";

         echo "<tr>";
         // alias command
         echo "<td>";
         echo __('Alias command if required (NRPE only)', 'monitoring')."&nbsp;:";
         echo "</td>";
         echo "<td>";
         if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
            echo "<input type='text' name='alias_commandservice' value='".$this->fields['alias_command']."' />";
         } else {
            echo "<input type='text' name='alias_command' value='".$pMonitoringServicedef->fields['alias_command']."' />";
         }
         echo "</td>";

         echo "<td>";
         echo __('Template (for graphs generation)', 'monitoring')."&nbsp;:GHJKL";
         echo "</td>";
         echo "<td>";
         if ($this->fields['plugin_monitoring_servicetemplates_id'] > 0) {
            $pMonitoringCommand->getEmpty();
            $pMonitoringCommand->getFromDB($pMonitoringServicetemplate->fields['aliasperfdata_commands_id']);
            echo $pMonitoringCommand->getLink(1);
         } else {
            $pMonitoringCommand->getFromDB($pMonitoringServicedef->fields['aliasperfdata_commands_id']);
            Dropdown::show("PluginMonitoringCommand", array(
                                 'name' =>'aliasperfdata_commands_id',
                                 'value'=>$pMonitoringServicedef->fields['aliasperfdata_commands_id']
                                 ));
         }
         echo "</td>";
         echo "</tr>";
      }

      // * Manage arguments
      $array = array();
      $a_displayarg = array();
      if (isset($pMonitoringCommand->fields['command_line'])) {
         preg_match_all("/\\$(ARG\d+)\\$/", $pMonitoringCommand->fields['command_line'], $array);
         $a_arguments = importArrayFromDB($this->fields['arguments']);
         foreach ($array[0] as $arg) {
            if (strstr($arg, "ARG")) {
               $arg = str_replace('$', '', $arg);
               if (!isset($a_arguments[$arg])) {
                  $a_arguments[$arg] = '';
               }
               $a_displayarg[$arg] = $a_arguments[$arg];

            }
         }
      }
      if (count($a_displayarg) > 0) {
         $a_argtext = importArrayFromDB($pMonitoringCommand->fields['arguments']);
         echo "<tr>";
         echo "<th colspan='4'>".__('Argument ([text:text] is used to get values dynamically)', 'monitoring')."&nbsp;</th>";
         echo "</tr>";

         foreach ($a_displayarg as $key=>$value) {
         echo "<tr>";
         echo "<th>".$key."</th>";
         echo "<td colspan='2'>";
            if (isset($a_argtext[$key])) {
               echo nl2br($a_argtext[$key])."&nbsp;:";
            } else {
               echo __('Argument', 'monitoring')."&nbsp;:";
            }

            if ($value == '') {
               $matches = array();
               preg_match('/(\[\w+\:\w+\])/',
                              nl2br($a_argtext[$key]), $matches);
               if (isset($matches[0])) {
                  $value = $matches[0];
               }
            }

            echo "</td>";
            echo "<td>";
            echo "<input type='text' name='arg[".$key."]' value='".$value."'/><br/>";
            echo "</td>";
            echo "</tr>";
         }
      }

      $this->showFormButtons($options);
      return true;
   }
コード例 #7
0
 /**
  * Display form for agent configuration
  *
  * @param $computers_id integer ID of the agent
  * @param $options array
  *
  * @return bool TRUE if form is ok
  *
  **/
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Comments') . "</td>";
     echo "<td class='middle'>";
     echo "<textarea cols='45' rows='4' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     $this->showFormButtons($options);
     if ($ID > 0) {
         $pf = new PluginFusioninventoryTimeslotEntry();
         $pf->formEntry($ID);
     }
     return true;
 }
コード例 #8
0
 /**
  * Print the networking form
  *
  * @param $ID        integer ID of the item
  * @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())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "name", array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_networkequipment`"));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     NetworkEquipmentType::dropdown(array('value' => $this->fields["networkequipmenttypes_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     NetworkEquipmentModel::dropdown(array('value' => $this->fields["networkequipmentmodels_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "otherserial", array('value' => $objectName));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>";
     $rowspan = 5;
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}'>\n            <textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td>";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan=2>" . __('The MAC address and the IP of the equipment are included in an aggregated network port') . "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Firmware', 'Firmwares', 1) . "</td>";
     echo "<td>";
     NetworkEquipmentFirmware::dropdown(array('value' => $this->fields["networkequipmentfirmwares_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . sprintf(__('%1$s (%2$s)'), __('Memory'), __('Mio')) . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "ram");
     echo "</td></tr>";
     // Display auto inventory informations
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         echo "<tr class='tab_bg_1'><td colspan='4'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
コード例 #9
0
 /**
  * Display form for agent configuration
  *
  * @param $items_id integer ID 
  * @param $options array
  *
  *@return bool true if form is ok
  *
  **/
 function showForm($items_id, $options = array())
 {
     global $DB, $CFG_GLPI, $LANG;
     if ($items_id == '') {
         if (isset($_POST['id'])) {
             $a_list = $this->find("`users_id`='" . $_POST['id'] . "'", '', 1);
             if (count($a_list)) {
                 $array = current($a_list);
                 $items_id = $array['id'];
             }
         }
     }
     if ($items_id != '') {
         $this->getFromDB($items_id);
     } else {
         $this->getEmpty();
     }
     $this->showFormHeader($options);
     $this->getFromDB($items_id);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . "&nbsp;:</td>";
     echo "<td align='center'>";
     $objectName = autoName($this->fields["name"], "name", false, $this->getType());
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contacttemplate'][1] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("is_default", $this->fields['is_default']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='2'>" . $LANG['plugin_monitoring']['contact'][3] . "</th>";
     echo "<th colspan='2'>" . $LANG['plugin_monitoring']['contact'][4] . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][5] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notifications_enabled', $this->fields['host_notifications_enabled']);
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][5] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notifications_enabled', $this->fields['service_notifications_enabled']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][19] . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("PluginMonitoringNotificationcommand", array('name' => 'host_notification_commands', 'value' => $this->fields['host_notification_commands']));
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][19] . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("PluginMonitoringNotificationcommand", array('name' => 'service_notification_commands', 'value' => $this->fields['service_notification_commands']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][6] . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("Calendar", array('name' => 'host_notification_period', 'value' => $this->fields['host_notification_period']));
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][6] . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("Calendar", array('name' => 'service_notification_period', 'value' => $this->fields['service_notification_period']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][7] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_d', $this->fields['host_notification_options_d']);
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][8] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_w', $this->fields['service_notification_options_w']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][9] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_u', $this->fields['host_notification_options_u']);
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][10] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_u', $this->fields['service_notification_options_u']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][11] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_r', $this->fields['host_notification_options_r']);
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][12] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_c', $this->fields['service_notification_options_c']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][13] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_f', $this->fields['host_notification_options_f']);
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][14] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_r', $this->fields['service_notification_options_r']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][15] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_s', $this->fields['host_notification_options_s']);
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][16] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_f', $this->fields['service_notification_options_f']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][17] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_n', $this->fields['host_notification_options_n']);
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['contact'][18] . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_n', $this->fields['service_notification_options_n']);
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
コード例 #10
0
ファイル: simcard.class.php プロジェクト: NandyJoshu/simcard
 /**
  * Print the simcard form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic simcard
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB, $LANG;
     if (!$this->canView()) {
         return false;
     }
     $target = $this->getFormURL();
     $withtemplate = '';
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (isset($options['withtemplate'])) {
         $withtemplate = $options['withtemplate'];
     }
     $this->showFormHeader($options);
     if (isset($options['itemtype']) && isset($options['items_id'])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __s('Associated element') . "</td>";
         echo "<td>";
         $item = new $options['itemtype']();
         $item->getFromDB($options['items_id']);
         echo $item->getLink(1);
         echo "</td>";
         echo "<td colspan='2'></td></tr>\n";
         echo "<input type='hidden' name='_itemtype' value='" . $options['itemtype'] . "'>";
         echo "<input type='hidden' name='_items_id' value='" . $options['items_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('Name') . (isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __s('Status') . "</td>";
     echo "<td>";
     Dropdown::show('State', array('value' => $this->fields["states_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('Location') . "</td>";
     echo "<td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __s('Type of SIM card', 'simcard') . "</td>";
     echo "<td>";
     Dropdown::show('PluginSimcardSimcardType', array('value' => $this->fields["plugin_simcard_simcardtypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __s('Size', 'simcard') . "</td>";
     echo "<td>";
     Dropdown::show('PluginSimcardSimcardSize', array('value' => $this->fields["plugin_simcard_simcardsizes_id"]));
     echo "</td></tr>\n";
     //       TODO : Add group in charge of hardware
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __s('Voltage', 'simcard') . "</td>";
     echo "<td>";
     Dropdown::show('PluginSimcardSimcardVoltage', array('value' => $this->fields["plugin_simcard_simcardvoltages_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('Provider', 'simcard') . "</td>";
     echo "<td>";
     Dropdown::show('PluginSimcardPhoneOperator', array('value' => $this->fields["plugin_simcard_phoneoperators_id"]));
     echo "</td>";
     echo "<td>" . __s('Associable items to a ticket') . "&nbsp;:</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<input type='hidden' name='is_global' value='1'>";
     echo "<td>" . __s("Inventory number") . (isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('Group') . "</td>";
     echo "<td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('Phone number', 'simcard') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'phonenumber');
     echo "</td>";
     echo "<td rowspan='6'>" . __s('Comments') . "</td>";
     echo "<td rowspan='6' class='middle'>";
     echo "<textarea cols='45' rows='15' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __s('IMSI', 'simcard') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     //Only show PIN and PUK code to users who can write (theses informations are highly sensible)
     if (PluginSimcardSimcard::canUpdate()) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __s('Pin 1', 'simcard') . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'pin');
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __s('Pin 2', 'simcard') . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'pin2');
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __s('Puk 1', 'simcard') . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'puk');
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __s('Puk 2', 'simcard') . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'puk2');
         echo "</td></tr>\n";
     }
     $this->showFormButtons($options);
     //$this->addDivForTabs();
     return true;
 }
コード例 #11
0
 /**
  * Print the computer form
  *
  * @param $ID integer ID of the item
  * @param $options array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  *
  **/
 function showForm($ID, $options = array())
 {
     global $LANG, $CFG_GLPI, $DB;
     if (!haveRight("computer", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = $LANG['computers'][14] . " : ";
         $date = convDateTime($_SESSION["glpi_currenttime"]);
     } else {
         if (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
             $template = "newtemplate";
             $datestring = $LANG['computers'][14] . " : ";
             $date = convDateTime($_SESSION["glpi_currenttime"]);
         } else {
             $datestring = $LANG['common'][26] . ": ";
             $date = convDateTime($this->fields["date_mod"]);
             $template = false;
         }
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . $LANG['state'][0] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('State', array('value' => $this->fields["states_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][15] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][17] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('ComputerType', array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][10] . "&nbsp;: </td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][5] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][21] . "&nbsp;: </td>";
     echo "<td >";
     autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . $LANG['common'][22] . "&nbsp;: </td>";
     echo "<td>";
     Dropdown::show('ComputerModel', array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][18] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . $LANG['common'][19] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][34] . "&nbsp;: </td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . $LANG['common'][20] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][35] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['setup'][88] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Network', array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][89] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('Domain', array('value' => $this->fields["domains_id"]));
     echo "</td>";
     echo "<td rowspan='8'>" . $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td rowspan='8' class='middle'>";
     echo "<textarea cols='45' rows='11' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][9] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('OperatingSystem', array('value' => $this->fields["operatingsystems_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][53] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('OperatingSystemServicePack', array('value' => $this->fields["operatingsystemservicepacks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][52] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('OperatingSystemVersion', array('value' => $this->fields["operatingsystemversions_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][11] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'os_licenseid');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][10] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'os_license_number');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['computers'][58] . "&nbsp;:</td>";
     echo "<td >";
     autocompletionTextField($this, 'uuid');
     echo "</td></tr>\n";
     // Get OCS Datas :
     $dataocs = array();
     if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r")) {
         $query = "SELECT *\n                   FROM `glpi_ocslinks`\n                   WHERE `computers_id` = '{$ID}'";
         $result = $DB->query($query);
         if ($DB->numrows($result) == 1) {
             $dataocs = $DB->fetch_array($result);
         }
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center'>" . $datestring . $date;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>(" . $LANG['common'][13] . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r") && count($dataocs)) {
         echo "<br>";
         echo $LANG['ocsng'][14] . "&nbsp;: " . convDateTime($dataocs["last_ocs_update"]);
         echo "<br>";
         echo $LANG['ocsng'][13] . "&nbsp;: " . convDateTime($dataocs["last_update"]);
         echo "<br>";
         if (haveRight("ocsng", "r")) {
             echo $LANG['common'][52] . " <a href='" . $CFG_GLPI["root_doc"] . "/front/ocsserver.form.php?id=" . OcsServer::getByMachineID($ID) . "'>" . OcsServer::getServerNameByID($ID) . "</a>";
             $query = "SELECT `ocs_agent_version`, `ocsid`\n                      FROM `glpi_ocslinks`\n                      WHERE `computers_id` = '{$ID}'";
             $result_agent_version = $DB->query($query);
             $data_version = $DB->fetch_array($result_agent_version);
             $ocs_config = OcsServer::getConfig(OcsServer::getByMachineID($ID));
             //If have write right on OCS and ocsreports url is not empty in OCS config
             if (haveRight("ocsng", "w") && $ocs_config["ocs_url"] != '') {
                 echo ", " . OcsServer::getComputerLinkToOcsConsole(OcsServer::getByMachineID($ID), $data_version["ocsid"], $LANG['ocsng'][57]);
             }
             if ($data_version["ocs_agent_version"] != NULL) {
                 echo " , " . $LANG['ocsng'][49] . "&nbsp;: " . $data_version["ocs_agent_version"];
             }
         } else {
             echo $LANG['common'][52] . " " . OcsServer::getServerNameByID($ID);
         }
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     if (!empty($ID) && $this->fields["is_ocs_import"] && haveRight("view_ocsng", "r") && haveRight("sync_ocsng", "w") && count($dataocs)) {
         echo "<td >" . $LANG['ocsng'][6] . " " . $LANG['Menu'][33] . "&nbsp;:</td>";
         echo "<td >";
         Dropdown::showYesNo("_auto_update_ocs", $dataocs["use_auto_update"]);
         echo "</td>";
     } else {
         echo "<td colspan=2></td>";
     }
     echo "<td>" . $LANG['computers'][51] . "&nbsp;:</td>";
     echo "<td >";
     Dropdown::show('AutoUpdateSystem', array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
コード例 #12
0
ファイル: computer.class.php プロジェクト: stweil/glpi
 /**
  * Print the computer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_computer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ComputerType::dropdown(array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     ComputerModel::dropdown(array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     //TRANS: Number of the alternate username
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     // Display auto inventory informations
     $rowspan = 7;
     $inventory_show = false;
     if (!empty($ID) && Plugin::haveImport() && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 5;
     }
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td >";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Operating system') . "</td>";
     echo "<td>";
     OperatingSystem::dropdown(array('value' => $this->fields["operatingsystems_id"]));
     echo "<br /><a href='#' id='toggle_os_information'>" . __("More information") . "</a>";
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='4' colspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version of the operating system') . "</td>";
     echo "<td >";
     OperatingSystemVersion::dropdown(array('value' => $this->fields["operatingsystemversions_id"]));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'><td colspan='2'>";
     echo Html::scriptBlock("\n      \$(document).ready(function(){\n         \$('#os_information').hide();\n\n         \$('#toggle_os_information').on('click',function() {\n            \$('#os_information').dialog({\n               width:'auto',\n               resizable: false,\n               appendTo: '#os_information_parent',\n               position: {\n                  my : 'left top',\n                  at : 'left bottom',\n                  of: \$('#toggle_os_information')\n               }\n            })\n         })\n      });");
     // group os advanced information in a single bloc (who can be toggled)
     echo "<div id='os_information_parent'>";
     echo "<div id='os_information' title=\"" . __('Operating system') . "\">";
     echo "<table>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Service pack') . "</td>";
     echo "<td >";
     OperatingSystemServicePack::dropdown(array('value' => $this->fields["operatingsystemservicepacks_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Operating system architecture') . "</td>";
     echo "<td >";
     OperatingSystemArchitecture::dropdown(array('value' => $this->fields["operatingsystemarchitectures_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Kernel version of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_kernel_version');
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Product ID of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_licenseid');
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Serial of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_license_number');
     echo "</td>";
     echo "</table>";
     echo "</div>";
     echo "</div>";
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'uuid');
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Update Source') . "</td>";
     echo "<td >";
     AutoUpdateSystem::dropdown(array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
コード例 #13
0
ファイル: order.class.php プロジェクト: geldarr/hack-space
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $config = PluginOrderConfig::getConfig();
     $user = new User();
     if (!self::canView()) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
         $this->getEmpty();
     }
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         if (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
             $template = "newtemplate";
             $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
         } else {
             $datestring = sprintf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
             $template = false;
         }
     }
     $canedit = $this->canUpdateOrder() && $this->can($ID, 'w') && !$this->isCanceled();
     $cancancel = self::canCancel() && $this->can($ID, 'w') && $this->isCanceled();
     $options['canedit'] = $canedit;
     $options['candel'] = $cancancel;
     if ($template) {
         $this->fields['order_date'] = NULL;
     }
     // Displaying OVER BUDGET ALERT
     if ($this->fields['budgets_id'] > 0) {
         self::displayAlertOverBudget(self::isOverBudget($ID));
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     //Display without inside table
     /* title */
     echo "<tr class='tab_bg_1'><td>" . __("Order name", "order") . "*: </td>";
     echo "<td>";
     if ($canedit) {
         $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
         Html::autocompletionTextField($this, "name", array('value' => $objectName));
     } else {
         echo $this->fields["name"];
     }
     echo "</td>";
     /* date of order */
     echo "<td>" . __("Date of order", "order") . ":</td><td>";
     if ($canedit) {
         if ($this->fields["order_date"] == NULL) {
             Html::showDateFormItem("order_date", date("Y-m-d"), true, true);
         } else {
             Html::showDateFormItem("order_date", $this->fields["order_date"], true, true);
         }
     } else {
         echo Html::convDate($this->fields["order_date"]);
     }
     echo "</td></tr>";
     /* num order */
     echo "<tr class='tab_bg_1'><td>" . __("Order number", "order") . "*: </td>";
     echo "<td>";
     if ($canedit) {
         $objectOrder = autoName($this->fields["num_order"], "num_order", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
         Html::autocompletionTextField($this, "num_order", array('value' => $objectOrder));
     } else {
         echo $this->fields["num_order"];
     }
     echo "</td>";
     /* type order */
     echo "<td>" . __("Type") . ": </td><td>";
     if ($canedit) {
         PluginOrderOrderType::Dropdown(array('name' => "plugin_order_ordertypes_id", 'value' => $this->fields["plugin_order_ordertypes_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_ordertypes", $this->fields["plugin_order_ordertypes_id"]);
     }
     echo "</td></tr>";
     /* state */
     echo "<tr class='tab_bg_1'><td>" . __("Order status", "order") . ": </td>";
     echo "<td>";
     if (!$this->getID()) {
         $state = $config->getDraftState();
     } else {
         $state = $this->fields["plugin_order_orderstates_id"];
     }
     if ($canedit) {
         PluginOrderOrderState::Dropdown(array('name' => "plugin_order_orderstates_id", 'value' => $state));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_orderstates", $this->getState());
     }
     echo "</td>";
     /* budget */
     echo "<td>" . __("Budget") . ": </td><td>";
     if ($canedit) {
         Budget::Dropdown(array('name' => "budgets_id", 'value' => $this->fields["budgets_id"], 'entity' => $this->fields["entities_id"], 'comments' => true));
     } else {
         $budget = new Budget();
         if ($this->fields["budgets_id"] > 0 && $budget->can($this->fields["budgets_id"], 'r')) {
             echo "<a href='" . $budget->getLinkURL() . "'>" . $budget->getName(1) . "</a>";
         } else {
             echo Dropdown::getDropdownName("glpi_budgets", $this->fields["budgets_id"]);
         }
     }
     echo "</td></tr>";
     /* location */
     echo "<tr class='tab_bg_1'><td>" . __("Delivery location", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         Location::Dropdown(array('name' => "locations_id", 'value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_locations", $this->fields["locations_id"]);
     }
     echo "</td>";
     /* payment */
     echo "<td>" . __("Payment conditions", "order") . ": </td><td>";
     if ($canedit) {
         PluginOrderOrderPayment::Dropdown(array('name' => "plugin_order_orderpayments_id", 'value' => $this->fields["plugin_order_orderpayments_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_orderpayments", $this->fields["plugin_order_orderpayments_id"]);
     }
     echo "</td>";
     echo "</tr>";
     /* supplier of order */
     echo "<tr class='tab_bg_1'><td>" . __("Supplier") . ": </td>";
     echo "<td>";
     if ($canedit && !$this->checkIfDetailExists($ID)) {
         $this->dropdownSuppliers("suppliers_id", $this->fields["suppliers_id"], $this->fields["entities_id"]);
     } else {
         $supplier = new Supplier();
         if ($supplier->can($this->fields['suppliers_id'], 'r')) {
             echo $supplier->getLink();
         } else {
             echo Dropdown::getDropdownName("glpi_suppliers", $this->fields["suppliers_id"]);
         }
     }
     echo "</td>";
     /* port price */
     echo "<td>" . __("Postage", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         echo "<input type='text' name='port_price' value=\"" . Html::formatNumber($this->fields["port_price"], true) . "\" size='5'>";
     } else {
         echo Html::formatNumber($this->fields["port_price"]);
     }
     echo "</td>";
     echo "</tr>";
     /* linked contact of the supplier of order */
     echo "<tr class='tab_bg_1'><td>" . __("Contact") . ": </td>";
     echo "<td><span id='show_contacts_id'>";
     if ($canedit && $ID > 0) {
         $this->dropdownContacts($this->fields["suppliers_id"], $this->fields["contacts_id"], $this->fields["entities_id"]);
     } else {
         echo Dropdown::getDropdownName("glpi_contacts", $this->fields["contacts_id"]);
     }
     echo "</span></td>";
     /* tva port price */
     echo "<td>" . __("VAT", "order") . " " . __("Postage", "order") . ": </td><td>";
     $PluginOrderConfig = new PluginOrderConfig();
     $default_taxes = $PluginOrderConfig->getDefaultTaxes();
     if (empty($ID) || $ID < 0) {
         $taxes = $default_taxes;
     } else {
         $taxes = $this->fields["plugin_order_ordertaxes_id"];
     }
     if ($canedit) {
         PluginOrderOrderTaxe::Dropdown(array('name' => "plugin_order_ordertaxes_id", 'value' => $taxes, 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order")));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $taxes);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Associable to a ticket") . "&nbsp;:</td><td>";
     if ($canedit) {
         Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     } else {
         echo Dropdown::getYesNo($this->fields['is_helpdesk_visible']);
     }
     echo "</td>";
     echo "<td>";
     echo __("Estimated due date", "order") . ":";
     if ($this->isDelivered() && $this->fields['deliverydate']) {
         echo "<br/>" . __("Delivery date") . ":";
     }
     echo " </td><td>";
     if ($canedit) {
         if ($this->fields["duedate"] == NULL) {
             Html::showDateFormItem("duedate", '', true, true);
         } else {
             Html::showDateFormItem("duedate", $this->fields["duedate"], true, true);
         }
     } else {
         echo Html::convDate($this->fields["duedate"]);
     }
     if ($this->shouldBeAlreadyDelivered()) {
         echo "<br/><span class='red'>" . __("Due date overtaken", "order") . "</span>";
     }
     if ($this->isDelivered() && $this->fields['deliverydate']) {
         echo "<br/>" . Html::convDate($this->fields['deliverydate']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center'>" . $datestring;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>(" . __("Template name") . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     echo "</td><td colspan='2'></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     //comments of order
     echo "<td>" . __("Comments") . ":  </td>";
     echo "<td colspan='3' align='center'>";
     if ($canedit) {
         echo "<textarea cols='40' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>";
     } else {
         echo $this->fields["comment"];
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='2'>" . __("Actor") . "</th>";
     if ($ID > 0 && !$template) {
         echo "<th colspan='2'>" . __("Cost") . "</th></tr>";
     } else {
         echo "<th colspan='2'></th>";
     }
     echo "</tr><tr class='tab_bg_1'>";
     echo "<td colspan='2'>";
     echo "<table class='format'>";
     echo "<tr class='tab_bg_1'><td>" . __("Author") . ":</td><td>";
     if ($canedit) {
         if ($template == 'newcomp') {
             $value = Session::getLoginUserID();
         } else {
             $value = $this->fields['users_id'];
         }
         User::Dropdown(array('name' => 'users_id', 'value' => $value, 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     } else {
         if ($this->fields['users_id']) {
             $user->getFromDB($this->fields['users_id']);
             $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']);
             echo $output;
         }
     }
     echo "</td>";
     echo "<td>" . __("Author group", "order") . ":</td><td>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             $groups_id = $config->getDefaultAuthorGroup();
         } else {
             $groups_id = $this->fields['groups_id'];
         }
         Group::Dropdown(array('value' => $groups_id));
     } else {
         echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id']);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'><td>" . __("Recipient") . ":</td><td>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             $users_id = $config->getDefaultRecipient();
         } else {
             $users_id = 0;
         }
         User::Dropdown(array('name' => 'users_id_delivery', 'value' => $users_id, 'right' => 'all', 'entity' => $this->fields["entities_id"]));
     } else {
         if ($this->fields['users_id_delivery']) {
             $user->getFromDB($this->fields['users_id_delivery']);
             $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']);
             echo $output;
         }
     }
     echo "</td>";
     echo "<td>" . __("Recipient group", "order") . ":</td><td>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             $groups_id = $config->getDefaultRecipientGroup();
         } else {
             $groups_id = $this->fields['groups_id_delivery'];
         }
         Group::Dropdown(array('name' => 'groups_id_delivery', 'value' => $groups_id));
     } else {
         echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id_delivery']);
     }
     echo "</td>";
     echo "</tr></table></td>";
     echo "<td colspan='2'>";
     if ($ID > 0 && !$template) {
         echo "<table class='format'>";
         $PluginOrderOrder_Item = new PluginOrderOrder_Item();
         $prices = $PluginOrderOrder_Item->getAllPrices($ID);
         echo "<tr><td>" . __("Price tax free", "order") . "</td>";
         echo "<td>" . Html::formatNumber($prices["priceHT"]) . "</td></tr>";
         // total price (with postage)
         $postagewithTVA = $PluginOrderOrder_Item->getPricesATI($this->fields["port_price"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $this->fields["plugin_order_ordertaxes_id"]));
         echo "<tr><td>" . __("Price tax free with postage", "order") . "</td>";
         $priceHTwithpostage = $prices["priceHT"] + $this->fields["port_price"];
         echo "<td>" . Html::formatNumber($priceHTwithpostage) . "</td></tr>";
         // total price (with taxes)
         echo "<tr><td>" . __("Price ATI", "order") . "</td>";
         $total = $prices["priceTTC"] + $postagewithTVA;
         echo "<td>" . Html::formatNumber($total) . "</td></tr>";
         // total TVA
         echo "<tr><td>" . __("VAT", "order") . "</td>";
         echo "<td>";
         $total_tva = $prices["priceTVA"] + ($postagewithTVA - $this->fields["port_price"]);
         echo Html::formatNumber($total_tva) . "</td></tr>";
         echo "</table>";
     }
     echo "</td></tr>";
     if ($canedit || $cancancel) {
         $this->showFormButtons($options);
     } else {
         echo "</table></div>";
         Html::closeForm();
     }
     $this->addDivForTabs();
     return true;
 }
コード例 #14
0
 /**
  * Display form for service configuration
  *
  * @param $items_id integer ID
  * @param $options array
  *
  *@return bool true if form is ok
  *
  **/
 function showForm($items_id, $options = array(), $copy = array())
 {
     global $DB, $CFG_GLPI;
     $pMonitoringCommand = new PluginMonitoringCommand();
     if (count($copy) > 0) {
         foreach ($copy as $key => $value) {
             $this->fields[$key] = stripslashes($value);
         }
     }
     $this->initForm($items_id, $options);
     if ($this->fields['id'] == 0) {
         $this->fields['active_checks_enabled'] = 1;
         $this->fields['passive_checks_enabled'] = 1;
     }
     $this->showFormHeader($options);
     if (isset($_SESSION['plugin_monitoring_components'])) {
         $this->fields = $_SESSION['plugin_monitoring_components'];
         if (!isset($this->fields["id"])) {
             $this->fields["id"] = '';
         }
         if (!isset($this->fields["arguments"])) {
             $this->fields["arguments"] = '';
         }
         unset($_SESSION['plugin_monitoring_components']);
     }
     echo "<tr>";
     echo "<td>";
     echo __('Name') . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='hidden' name='is_template' value='1' />";
     $objectName = autoName($this->fields["name"], "name", 1, $this->getType());
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     // * checks
     echo "<td>" . __('Check definition', 'monitoring') . "<font class='red'>*</font>&nbsp;:</td>";
     echo "<td>";
     Dropdown::show("PluginMonitoringCheck", array('name' => 'plugin_monitoring_checks_id', 'value' => $this->fields['plugin_monitoring_checks_id']));
     echo "</td>";
     echo "</tr>";
     // * Link
     echo "<tr>";
     echo "<td>";
     echo __('Alias (Shinken service_description)', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $objectDescription = autoName($this->fields["description"], "name", 1, $this->getType());
     Html::autocompletionTextField($this, 'description', array('value' => $objectDescription));
     echo "</td>";
     /*
           echo "<td>";
     //      echo "Type of template&nbsp;:";
           echo "</td>";
           echo "<td>";
     //      $a_types = array();
     //      $a_types[''] = Dropdown::EMPTY_VALUE;
     //      $a_types['partition'] = "Partition";
     //      $a_types['processor'] = "Processor";
     //      Dropdown::showFromArray("link", $a_types, array('value'=>$this->fields['link']));
           echo "</td>";
     */
     // * active check
     echo "<td>";
     echo __('Active check', 'monitoring') . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("active_checks_enabled", $this->fields['active_checks_enabled']);
     echo "</td>";
     echo "</tr>";
     // * command
     echo "<tr>";
     echo "<td>";
     echo __('Command', 'monitoring') . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     $pMonitoringCommand->getFromDB($this->fields['plugin_monitoring_commands_id']);
     Dropdown::show("PluginMonitoringCommand", array('name' => 'plugin_monitoring_commands_id', 'value' => $this->fields['plugin_monitoring_commands_id']));
     echo "</td>";
     // * passive check
     echo "<td>";
     echo __('Passive check', 'monitoring') . "<font class='red'>*</font>&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("passive_checks_enabled", $this->fields['passive_checks_enabled']);
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>";
     echo __('Template (for graphs generation)', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::show('PluginMonitoringPerfdata', array('name' => 'graph_template', 'value' => $this->fields['graph_template']));
     echo "</td>";
     // * freshness
     echo "<td>" . __('Freshness (for passive mode)', 'monitoring') . "&nbsp;:</td>";
     echo "<td>";
     if ($this->fields['freshness_count'] == '') {
         $this->fields['freshness_count'] = 0;
     }
     Dropdown::showNumber("freshness_count", array('value' => $this->fields['freshness_count'], 'min' => 0, 'max' => 300));
     $a_time = array();
     $a_time['seconds'] = __('Second(s)', 'monitoring');
     $a_time['minutes'] = __('Minute(s)', 'monitoring');
     $a_time['hours'] = __('Hour(s)', 'monitoring');
     $a_time['days'] = __('Day(s)', 'monitoring');
     Dropdown::showFromArray("freshness_type", $a_time, array('value' => $this->fields['freshness_type']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>";
     echo __('Event handler', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     dropdown::show("PluginMonitoringEventhandler", array('name' => 'plugin_monitoring_eventhandlers_id', 'value' => $this->fields['plugin_monitoring_eventhandlers_id']));
     echo "</td>";
     // * calendar
     echo "<td>" . __('Check period', 'monitoring') . "<font class='red'>*</font>&nbsp;:</td>";
     echo "<td>";
     dropdown::show("Calendar", array('name' => 'calendars_id', 'value' => $this->fields['calendars_id']));
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th colspan='4'>" . __('Remote check', 'monitoring') . "</th>";
     echo "</tr>";
     echo "<tr>";
     // * remotesystem
     echo "<td>";
     echo __('Utility used for remote check', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $input = array();
     $input[''] = '------';
     $input['byssh'] = 'byssh';
     $input['nrpe'] = 'nrpe';
     $input['nsca'] = 'nsca';
     Dropdown::showFromArray("remotesystem", $input, array('value' => $this->fields['remotesystem']));
     echo "</td>";
     // * is_argument
     echo "<td>";
     echo __('Use arguments (NRPE only)', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     Dropdown::showYesNo("is_arguments", $this->fields['is_arguments']);
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     // alias command
     echo "<td>";
     echo __('Alias command if required (NRPE only)', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='text' name='alias_command' value='" . $this->fields['alias_command'] . "' size='35' />";
     echo "</td>";
     echo "<td colspan='2'></td>";
     echo "</tr>";
     // * Manage arguments
     $array = array();
     $a_displayarg = array();
     if (isset($pMonitoringCommand->fields['command_line'])) {
         preg_match_all("/\\\$(ARG\\d+)\\\$/", $pMonitoringCommand->fields['command_line'], $array);
         $a_arguments = importArrayFromDB($this->fields['arguments']);
         foreach ($array[0] as $arg) {
             if (strstr($arg, "ARG")) {
                 $arg = str_replace('$', '', $arg);
                 if (!isset($a_arguments[$arg])) {
                     $a_arguments[$arg] = '';
                 }
                 $a_displayarg[$arg] = $a_arguments[$arg];
             }
         }
     }
     if (count($a_displayarg) > 0) {
         $a_tags = $this->tagsAvailable();
         $a_argtext = importArrayFromDB($pMonitoringCommand->fields['arguments']);
         echo "<tr>";
         echo "<th colspan='4'>" . __('Arguments', 'monitoring') . "&nbsp;</th>";
         echo "</tr>";
         foreach ($a_displayarg as $key => $value) {
             echo "<tr>";
             echo "<td>";
             if (isset($a_argtext[$key]) and $a_argtext[$key] != '') {
                 echo nl2br($a_argtext[$key]) . "&nbsp;:";
             } else {
                 echo __('Argument', 'monitoring') . " (" . $key . ")&nbsp;:";
             }
             echo "</td>";
             echo "<td>";
             echo "<input type='text' name='arg[" . $key . "]' value='" . $value . "' size='35' /><br/>";
             echo "</td>";
             if (count($a_tags) > 0) {
                 foreach ($a_tags as $key => $value) {
                     echo "<td class='tab_bg_3'>";
                     echo "<strong>" . $key . "</strong>&nbsp;:";
                     echo "</td>";
                     echo "<td class='tab_bg_3'>";
                     echo $value;
                     echo "</td>";
                     unset($a_tags[$key]);
                     break;
                 }
             } else {
                 echo "<td colspan='2'></td>";
             }
             echo "</tr>";
         }
         foreach ($a_tags as $key => $value) {
             echo "<tr>";
             echo "<td colspan='2'></td>";
             echo "<td class='tab_bg_3'>";
             echo "<strong>" . $key . "</strong>&nbsp;:";
             echo "</td>";
             echo "<td class='tab_bg_3'>";
             echo $value;
             echo "</td>";
             echo "</tr>";
         }
     }
     if (Session::haveRight("plugin_monitoring_weathermap", READ)) {
         echo "<tr>";
         echo "<th colspan='4'>" . __('Weathermap', 'monitoring') . "&nbsp;</th>";
         echo "</tr>";
         echo "<tr>";
         echo "<td>";
         echo __('Use this component for Weathermap', 'monitoring') . "&nbsp;:";
         echo "</td>";
         echo "<td>";
         Dropdown::showYesNo("is_weathermap", $this->fields['is_weathermap']);
         echo "</td>";
         echo "<td>";
         $tooltip = __('Example', 'monitoring') . " :<br/><br/>";
         $tooltip .= "perfdata : <i>inUsage=0.00%;85;98 outUsage=0.00%;85;98 inBandwidth=<strong>789944</strong>.00bps outBandwidth=486006.00bps inAbsolut=0 outAbsolut=12665653</i><br/><br/>";
         $tooltip .= __('Regex bandwidth input', 'monitoring') . " : <i><strong>(?:.*)inBandwidth=(\\d+)(?:.*)</strong></i><br/><br/>";
         $tooltip .= __('Assign the value from regular expression') . " : <strong>789944</strong>";
         echo __('Regex bandwidth input', 'monitoring') . "&nbsp;";
         Html::showToolTip($tooltip, array('autoclose' => false));
         echo "&nbsp;:";
         echo "</td>";
         echo "<td>";
         echo "<input type='text' name='weathermap_regex_in' value='" . $this->fields['weathermap_regex_in'] . "' size='40' />";
         echo "</td>";
         echo "</tr>";
         echo "<tr>";
         echo "<td colspan='2'>";
         echo "</td>";
         echo "<td>";
         $tooltip = __('Example', 'monitoring') . " :<br/><br/>";
         $tooltip .= "perfdata : <i>inUsage=0.00%;85;98 outUsage=0.00%;85;98 inBandwidth=789944.00bps outBandwidth=<strong>486006</strong>.00bps inAbsolut=0 outAbsolut=12665653</i><br/><br/>";
         $tooltip .= __('Regex bandwidth output', 'monitoring') . " : <i><strong>(?:.*)outBandwidth=(\\d+)(?:.*)</strong></i><br/><br/>";
         $tooltip .= __('Assign the value from regular expression') . " : <strong>789944</strong>";
         echo __('Regex bandwidth output', 'monitoring') . "&nbsp;";
         Html::showToolTip($tooltip, array('autoclose' => false));
         echo "&nbsp;:";
         echo "</td>";
         echo "<td>";
         echo "<input type='text' name='weathermap_regex_out' value='" . $this->fields['weathermap_regex_out'] . "' size='40' />";
         echo "</td>";
         echo "</tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
コード例 #15
0
ファイル: link.class.php プロジェクト: pluginsGLPI/order
 public function generateNewItem($params)
 {
     global $DB;
     // Retrieve plugin configuration
     $config = new PluginOrderConfig();
     $reference = new PluginOrderReference();
     foreach ($params["id"] as $tmp => $values) {
         //If itemtype cannot be generated, go to the new occurence
         if (in_array($values['itemtype'], self::getTypesThanCannotBeGenerared())) {
             continue;
         }
         $entity = $values["entities_id"];
         //------------- Template management -----------------------//
         //Look for a template in the entity
         $templateID = $reference->checkIfTemplateExistsInEntity($values["id"], $values["itemtype"], $entity);
         $item = new $values["itemtype"]();
         if ($values['itemtype']) {
             $order = new PluginOrderOrder();
         }
         $order->getFromDB($values["plugin_order_orders_id"]);
         $reference->getFromDB($params["plugin_order_references_id"]);
         if ($templateID) {
             $item->getFromDB($templateID);
             unset($item->fields["is_template"]);
             unset($item->fields["date_mod"]);
             $fields = array();
             foreach ($item->fields as $key => $value) {
                 if ($value != '' && (!isset($fields[$key]) || $fields[$key] == '' || $fields[$key] == 0)) {
                     $input[$key] = $value;
                 }
             }
             if ($config->getGeneratedAssetState()) {
                 $input["states_id"] = $config->getGeneratedAssetState();
             }
             $input["entities_id"] = $entity;
             $input["serial"] = $values["serial"];
             if ($item->fields['name']) {
                 $input["name"] = autoName($item->fields["name"], "name", $templateID, $values["itemtype"], $entity);
             } else {
                 $input["name"] = $values["name"];
             }
             if ($item->getField('otherserial') != NOT_AVAILABLE) {
                 if ($item->fields['otherserial']) {
                     $input["otherserial"] = autoName($item->fields["otherserial"], "otherserial", $templateID, $values["itemtype"], $entity);
                 } else {
                     $input["otherserial"] = $values["otherserial"];
                 }
             }
             if ($config->canAddLocation()) {
                 $input['locations_id'] = $order->fields['locations_id'];
             }
         } elseif ($values["itemtype"] == 'Contract') {
             $input["name"] = $values["name"];
             $input["entities_id"] = $entity;
             $input['contracttypes_id'] = $reference->fields['types_id'];
         } else {
             if ($config->getGeneratedAssetState()) {
                 $input["states_id"] = $config->getGeneratedAssetState();
             } else {
                 $input["states_id"] = 0;
             }
             $input["entities_id"] = $entity;
             $input["serial"] = $values["serial"];
             $input["otherserial"] = $values["otherserial"];
             $input["name"] = $values["name"];
             // Get bill data
             if ($config->canAddLocation()) {
                 $input['locations_id'] = $order->fields['locations_id'];
             }
             $input["manufacturers_id"] = $reference->fields["manufacturers_id"];
             $typefield = getForeignKeyFieldForTable(getTableForItemType($values["itemtype"] . "Type"));
             $input[$typefield] = $reference->fields["types_id"];
             $modelfield = getForeignKeyFieldForTable(getTableForItemType($values["itemtype"] . "Model"));
             $input[$modelfield] = $reference->fields["models_id"];
         }
         $input = Toolbox::addslashes_deep($input);
         $newID = $item->add($input);
         // Attach new ticket if option is on
         if (isset($params['generate_ticket'])) {
             $tkt = new TicketTemplate();
             if ($tkt->getFromDB($params['generate_ticket']['tickettemplates_id'])) {
                 $input = array();
                 $input = Ticket::getDefaultValues($entity);
                 $ttp = new TicketTemplatePredefinedField();
                 $predefined = $ttp->getPredefinedFields($params['generate_ticket']['tickettemplates_id'], true);
                 if (count($predefined)) {
                     foreach ($predefined as $predeffield => $predefvalue) {
                         $input[$predeffield] = $predefvalue;
                     }
                 }
                 $input['entities_id'] = $entity;
                 $input['_users_id_requester'] = empty($order->fields['users_id']) ? Session::getLoginUserID() : $order->fields['users_id'];
                 $input['items_id'] = $newID;
                 $input['itemtype'] = $values["itemtype"];
                 $ticket = new Ticket();
                 $ticketID = $ticket->add($input);
             }
         }
         //-------------- End template management ---------------------------------//
         $result = $this->createLinkWithItem($values["id"], $newID, $values["itemtype"], $values["plugin_order_orders_id"], $entity, $templateID, false, false);
         //Add item's history
         $new_value = __("Item generated by using order", "order") . ' : ' . $order->fields["name"];
         $order->addHistory($values["itemtype"], '', $new_value, $newID);
         //Add order's history
         $new_value = __("Item generated by using order", "order") . ' : ';
         $new_value .= $item->getTypeName() . " -> " . $item->getField("name");
         $order->addHistory('PluginOrderOrder', '', $new_value, $values["plugin_order_orders_id"]);
         //Copy order documents if needed
         self::copyDocuments($values['itemtype'], $newID, $values["plugin_order_orders_id"], $entity);
         Session::addMessageAfterRedirect(__("Item successfully selected", "order"), true);
     }
 }
コード例 #16
0
ファイル: computer.class.php プロジェクト: glpi-project/glpi
 /**
  * Print the computer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_computer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ComputerType::dropdown(array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     ComputerModel::dropdown(array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     //TRANS: Number of the alternate username
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     // Display auto inventory informations
     $rowspan = 4;
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td >";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'uuid');
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Update Source') . "</td>";
     echo "<td >";
     AutoUpdateSystem::dropdown(array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     // Display auto inventory informations
     if (!empty($ID) && Plugin::haveImport() && $this->fields["is_dynamic"]) {
         echo "<tr class='tab_bg_1'><td colspan='4'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td></tr>";
     }
     $this->showFormButtons($options);
     return true;
 }
コード例 #17
0
 /**
  * Display form for agent configuration
  *
  * @param $items_id integer ID 
  * @param $options array
  *
  *@return bool true if form is ok
  *
  **/
 function showForm($items_id, $options = array())
 {
     global $DB, $CFG_GLPI;
     if ($items_id == '') {
         if (isset($_POST['id'])) {
             $a_list = $this->find("`users_id`='" . $_POST['id'] . "'", '', 1);
             if (count($a_list)) {
                 $array = current($a_list);
                 $items_id = $array['id'];
             }
         }
     }
     if ($items_id != '') {
         $this->getFromDB($items_id);
     } else {
         $this->getEmpty();
     }
     $this->showFormHeader($options);
     $this->getFromDB($items_id);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "&nbsp;:</td>";
     echo "<td align='center'>";
     $objectName = autoName($this->fields["name"], "name", false, $this->getType());
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Default template', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo("is_default", $this->fields['is_default']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='2'>" . __('Hosts', 'monitoring') . "</th>";
     echo "<th colspan='2'>" . __('Services', 'monitoring') . "</th>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notifications', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notifications_enabled', $this->fields['host_notifications_enabled']);
     echo "</td>";
     echo "<td>" . __('Notifications', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notifications_enabled', $this->fields['service_notifications_enabled']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notification command', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("PluginMonitoringNotificationcommand", array('name' => 'host_notification_commands', 'value' => $this->fields['host_notification_commands']));
     echo "</td>";
     echo "<td>" . __('Notification command', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("PluginMonitoringNotificationcommand", array('name' => 'service_notification_commands', 'value' => $this->fields['service_notification_commands']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Period', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("Calendar", array('name' => 'host_notification_period', 'value' => $this->fields['host_notification_period']));
     echo "</td>";
     echo "<td>" . __('Period', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     dropdown::show("Calendar", array('name' => 'service_notification_period', 'value' => $this->fields['service_notification_period']));
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notify on DOWN host states', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_d', $this->fields['host_notification_options_d']);
     echo "</td>";
     echo "<td>" . __('Notify on WARNING service states', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_w', $this->fields['service_notification_options_w']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notify on UNREACHABLE host states', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_u', $this->fields['host_notification_options_u']);
     echo "</td>";
     echo "<td>" . __('Notify on UNKNOWN service states', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_u', $this->fields['service_notification_options_u']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notify on host recoveries (UP states)', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_r', $this->fields['host_notification_options_r']);
     echo "</td>";
     echo "<td>" . __('Notify on CRITICAL service states', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_c', $this->fields['service_notification_options_c']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Notify when the host starts and stops flapping', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_f', $this->fields['host_notification_options_f']);
     echo "</td>";
     echo "<td>" . __('Notify on service recoveries (OK states)', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_r', $this->fields['service_notification_options_r']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Send notifications when host or service scheduled downtime starts and ends', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_s', $this->fields['host_notification_options_s']);
     echo "</td>";
     echo "<td>" . __('Notify when the service starts and stops flapping', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_f', $this->fields['service_notification_options_f']);
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('The contact will not receive any type of host notifications', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('host_notification_options_n', $this->fields['host_notification_options_n']);
     echo "</td>";
     echo "<td>" . __('The contact will not receive any type of service notifications', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     Dropdown::showYesNo('service_notification_options_n', $this->fields['service_notification_options_n']);
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     return true;
 }
コード例 #18
0
ファイル: peripheral.class.php プロジェクト: stweil/glpi
 /**
  * Print the peripheral form
  *
  * @param $ID integer ID of the item
  * @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;
     $target = $this->getFormURL();
     $withtemplate = $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "");
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "name", array('value' => $objectName));
     echo "</td>\n";
     echo "<td>" . __('Status') . "</td>\n";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_peripheral`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>\n";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>\n";
     echo "<td>" . __('Type') . "</td>\n";
     echo "<td>";
     PeripheralType::dropdown(array('value' => $this->fields["peripheraltypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>\n";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>\n";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>\n";
     echo "<td>";
     PeripheralModel::dropdown(array('value' => $this->fields["peripheralmodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>\n";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>\n";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, "otherserial", array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>\n";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>\n";
     echo "<td>" . __('Management type') . "</td>\n";
     echo "<td>";
     Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["peripherals_management_restrict"], 'target' => $target));
     echo "</td></tr>\n";
     // Display auto inventory informations
     $rowspan = 2;
     $inventory_show = false;
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 1;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>\n";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>\n";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>\n";
     echo "<td rowspan='{$rowspan}'>\n            <textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Brand') . "</td>\n";
     echo "<td>";
     Html::autocompletionTextField($this, "brand");
     echo "</td></tr>\n";
     if ($inventory_show) {
         echo "<tr class='tab_bg_1'>";
         echo "<td rowspan='1'>" . __('Automatic inventory') . "</td>";
         echo "<td rowspan='1'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
         echo "</tr>\n";
     }
     $this->showFormButtons($options);
     return true;
 }
コード例 #19
0
ファイル: object.class.php プロジェクト: geldarr/hack-space
 function post_addItem()
 {
     global $DB;
     // Manage add from template
     if (isset($this->input["_oldID"])) {
         // ADD Infocoms
         $ic = new Infocom();
         if ($this->canUseInfocoms() && $ic->getFromDBforDevice($this->type, $this->input["_oldID"])) {
             $ic->fields["items_id"] = $this->fields['id'];
             unset($ic->fields["id"]);
             if (isset($ic->fields["immo_number"])) {
                 $ic->fields["immo_number"] = autoName($ic->fields["immo_number"], "immo_number", 1, 'Infocom', $this->input['entities_id']);
             }
             if (empty($ic->fields['use_date'])) {
                 unset($ic->fields['use_date']);
             }
             if (empty($ic->fields['buy_date'])) {
                 unset($ic->fields['buy_date']);
             }
             $ic->addToDB();
         }
         foreach (array('Document_Item' => 'documents_id', 'Contract_Item' => 'contracts_id') as $type => $fk) {
             $item = new $type();
             foreach ($item->find("items_id='" . $this->input["_oldID"] . "'\n                                 AND itemtype='" . $this->type . "'") as $tmpid => $data) {
                 $tmp = array();
                 $tmp['items_id'] = $this->input["_oldID"];
                 $tmp['itemtype'] = $type;
                 $tmp[$fk] = $data[$fk];
                 $item->add($tmp);
             }
         }
         if ($this->canUseNetworkPorts()) {
             // ADD Ports
             $query = "SELECT `id`\n                       FROM `glpi_networkports`\n                       WHERE `items_id` = '" . $this->input["_oldID"] . "'\n                          AND `itemtype` = '" . get_called_class() . "';";
             $result = $DB->query($query);
             if ($DB->numrows($result) > 0) {
                 while ($data = $DB->fetch_array($result)) {
                     $np = new NetworkPort();
                     $npv = new NetworkPort_Vlan();
                     $np->getFromDB($data["id"]);
                     unset($np->fields["id"]);
                     unset($np->fields["ip"]);
                     unset($np->fields["mac"]);
                     unset($np->fields["netpoints_id"]);
                     $np->fields["items_id"] = $this->fields['id'];
                     $portid = $np->addToDB();
                     foreach ($DB->request('glpi_networkports_vlans', array('networkports_id' => $data["id"])) as $vlan) {
                         $npv->assignVlan($portid, $vlan['vlans_id']);
                     }
                 }
             }
         }
     }
 }
コード例 #20
0
 function showForm($items_id, $options = array())
 {
     global $DB, $CFG_GLPI, $LANG;
     if ($items_id == '0') {
         $this->getEmpty();
     } else {
         $this->getFromDB($items_id);
     }
     $this->showTabs($options);
     $options['formoptions'] = " enctype='multipart/form-data'";
     $this->showFormHeader($options);
     echo "<tr>";
     echo "<td>";
     echo $LANG['common'][16] . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", 1, $this->getType());
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['weathermap'][3] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showInteger("width", $this->fields['width'], 100, 3000, 20);
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<td>";
     echo $LANG['plugin_monitoring']['weathermap'][5] . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     if ($this->fields['background'] == '') {
         echo "<input type='file' size='25' value='' name='background'/>";
     } else {
         echo $this->fields['background'];
         echo "&nbsp;";
         echo "<input type='image' name='deletepic' value='deletepic' class='submit' src='" . $CFG_GLPI["root_doc"] . "/pics/delete.png' >";
     }
     echo "</td>";
     echo "<td>" . $LANG['plugin_monitoring']['weathermap'][4] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showInteger("height", $this->fields['height'], 100, 3000, 20);
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
コード例 #21
0
   function showForm($items_id, $options=array()) {
      global $DB,$CFG_GLPI;

      $this->initForm($items_id, $options);
      $options['formoptions'] = " enctype='multipart/form-data'";
      $this->showFormHeader($options);

      echo "<tr>";
      echo "<td>";
      echo __('Name')."&nbsp;:";
      echo "</td>";
      echo "<td>";
      $objectName = autoName($this->fields["name"], "name", 1,
                             $this->getType());
      Html::autocompletionTextField($this, 'name', array('value' => $objectName));
      echo "</td>";
      echo "<td>".__('Width', 'monitoring')."&nbsp;:</td>";
      echo "<td>";
      Dropdown::showNumber("width", array(
                'value' => $this->fields['width'],
                'min'   => 100,
                'max'   => 3000,
                'step'  => 20)
      );
      echo "</td>";
      echo "</tr>";

      echo "<tr>";
      echo "<td>";
      echo __('Background image', 'monitoring')."&nbsp;:";
      echo "</td>";
      echo "<td>";
      if ($this->fields['background'] == '') {
         echo "<input type='file' size='25' value='' name='background'/>";
      } else {
         echo $this->fields['background'];
         echo "&nbsp;";
         echo "<input type='image' name='deletepic' value='deletepic' class='submit' src='".$CFG_GLPI["root_doc"]."/pics/delete.png' >";

      }
      echo "</td>";
      echo "<td>".__('Height', 'monitoring')."&nbsp;:</td>";
      echo "<td>";
      Dropdown::showNumber("height", array(
                'value' => $this->fields['height'],
                'min'   => 100,
                'max'   => 3000,
                'step'  => 20)
      );
      echo "</td>";
      echo "</tr>";


      $this->showFormButtons($options);

      PluginMonitoringToolbox::loadLib();

      return true;
   }
コード例 #22
0
 /**
  * Print the phone form
  *
  * @param $ID integer ID of the item
  * @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;
     $target = $this->getFormURL();
     $withtemplate = '';
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (isset($options['withtemplate'])) {
         $withtemplate = $options['withtemplate'];
     }
     if (!haveRight("phone", "r")) {
         return false;
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = $LANG['computers'][14] . "&nbsp;: ";
         $date = convDateTime($_SESSION["glpi_currenttime"]);
     } else {
         if (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
             $template = "newtemplate";
             $datestring = $LANG['computers'][14] . "&nbsp;: ";
             $date = convDateTime($_SESSION["glpi_currenttime"]);
         } else {
             $datestring = $LANG['common'][26] . "&nbsp;: ";
             $date = convDateTime($this->fields["date_mod"]);
             $template = false;
         }
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][16] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . $LANG['state'][0] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('State', array('value' => $this->fields["states_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][15] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][17] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('PhoneType', array('value' => $this->fields["phonetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][10] . "&nbsp;:</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['common'][5] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Manufacturer', array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][21] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . $LANG['common'][22] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('PhoneModel', array('value' => $this->fields["phonemodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][18] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "contact");
     echo "</td>";
     echo "<td>" . $LANG['common'][19] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][34] . "&nbsp;:</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . $LANG['common'][20] . ($template ? "*" : "") . "&nbsp;:</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
     autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['common'][35] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['peripherals'][33] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["phones_management_restrict"], 'target' => $target));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['peripherals'][18] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "brand");
     echo "</td>";
     echo "<td rowspan='6'>";
     echo $LANG['common'][25] . "&nbsp;:</td>";
     echo "<td rowspan='6'>\n            <textarea cols='45' rows='9' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['phones'][36] . "&nbsp;:</td>";
     echo "<td>";
     Dropdown::show('PhonePowerSupply', array('value' => $this->fields["phonepowersupplies_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['setup'][71] . "&nbsp;:</td>";
     echo "<td>";
     autocompletionTextField($this, "firmware");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['phones'][40] . "&nbsp;:</td><td>";
     autocompletionTextField($this, "number_line");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['monitors'][18] . "&nbsp;:</td>";
     echo "<td>";
     // micro?
     echo "\n<table><tr><td>" . $LANG['phones'][38] . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_headset", $this->fields["have_headset"]);
     echo "</td></tr>";
     // hp?
     echo "<tr><td>" . $LANG['phones'][39] . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_hp", $this->fields["have_hp"]);
     echo "</td></tr></table>\n";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center' height='30'>" . $datestring . "&nbsp;" . $date;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         echo "(" . $LANG['common'][13] . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
コード例 #23
0
ファイル: order.class.php プロジェクト: pluginsGLPI/order
 public function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     $rand = mt_rand();
     $config = PluginOrderConfig::getConfig();
     $user = new User();
     if (isset($options['withtemplate']) && $options['withtemplate'] == 2) {
         $template = "newcomp";
         $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } elseif (isset($options['withtemplate']) && $options['withtemplate'] == 1) {
         $template = "newtemplate";
         $datestring = sprintf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         $template = false;
         $datestring = sprintf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     $canedit = $this->canUpdateOrder() && $this->canUpdate() && !$this->isCanceled();
     $cancancel = self::canCancel() && $this->can($ID, UPDATE) && $this->isCanceled();
     $options['canedit'] = $canedit;
     $options['candel'] = $cancancel;
     if ($template) {
         $this->fields['order_date'] = NULL;
     }
     // Displaying OVER BUDGET ALERT
     if ($this->fields['budgets_id'] > 0) {
         self::displayAlertOverBudget(self::isOverBudget($ID));
     }
     //Display without inside table
     /* title */
     echo "<tr class='tab_bg_1'><td>" . __("Order name", "order") . "*: </td>";
     echo "<td>";
     if ($canedit) {
         $objectName = autoName($this->fields["name"], "name", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
         Html::autocompletionTextField($this, "name", array('value' => $objectName));
     } else {
         echo $this->fields["name"];
     }
     echo "</td>";
     /* date of order */
     echo "<td>" . __("Date of order", "order") . ":</td><td>";
     if ($canedit) {
         if ($this->fields["order_date"] == NULL) {
             Html::showDateFormItem("order_date", date("Y-m-d"), true, true);
         } else {
             Html::showDateFormItem("order_date", $this->fields["order_date"], true, true);
         }
     } else {
         echo Html::convDate($this->fields["order_date"]);
     }
     echo "</td></tr>";
     /* num order */
     echo "<tr class='tab_bg_1'><td>" . __("Order number", "order");
     if ($ID > 0) {
         echo "*";
     } else {
         echo " <span class='red'>*</span>";
     }
     echo ": </td>";
     echo "<td>";
     if ($canedit) {
         $objectOrder = autoName($this->fields["num_order"], "num_order", $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
         Html::autocompletionTextField($this, "num_order", array('value' => $objectOrder));
     } else {
         echo $this->fields["num_order"];
     }
     echo "</td>";
     /* type order */
     echo "<td>" . __("Type") . ": </td><td>";
     if ($canedit) {
         PluginOrderOrderType::Dropdown(array('name' => "plugin_order_ordertypes_id", 'value' => $this->fields["plugin_order_ordertypes_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_ordertypes", $this->fields["plugin_order_ordertypes_id"]);
     }
     echo "</td></tr>";
     /* state */
     echo "<tr class='tab_bg_1'><td>" . __("Order status", "order") . ": </td>";
     echo "<td>";
     if (!$this->getID()) {
         $state = $config->getDraftState();
     } else {
         $state = $this->fields["plugin_order_orderstates_id"];
     }
     if ($canedit) {
         PluginOrderOrderState::Dropdown(array('name' => "plugin_order_orderstates_id", 'value' => $state));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_orderstates", $this->getState());
     }
     echo "</td>";
     /* budget */
     echo "<td>" . __("Budget") . ": </td>";
     echo "<td>";
     if ($canedit) {
         if ($config->canHideInactiveBudgets()) {
             $restrict = " (`end_date` IS NULL) OR (`end_date`> '" . date("Y-m-d") . "')";
         } else {
             $restrict = "";
         }
         Budget::Dropdown(array('name' => "budgets_id", 'value' => $this->fields["budgets_id"], 'entity' => $this->fields["entities_id"], 'comments' => true, 'condition' => $restrict, 'width' => '150px'));
     } else {
         $budget = new Budget();
         if ($this->fields["budgets_id"] > 0 && $budget->can($this->fields["budgets_id"], READ)) {
             echo $budget->getLink();
         } else {
             echo Dropdown::getDropdownName("glpi_budgets", $this->fields["budgets_id"]);
         }
     }
     echo "</td></tr>";
     /* location */
     echo "<tr class='tab_bg_1'><td>" . __("Delivery location", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         Location::Dropdown(array('name' => "locations_id", 'value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_locations", $this->fields["locations_id"]);
     }
     echo "</td>";
     /* payment */
     echo "<td>" . __("Payment conditions", "order") . ": </td><td>";
     if ($canedit) {
         PluginOrderOrderPayment::Dropdown(array('name' => "plugin_order_orderpayments_id", 'value' => $this->fields["plugin_order_orderpayments_id"]));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_orderpayments", $this->fields["plugin_order_orderpayments_id"]);
     }
     echo "</td>";
     echo "</tr>";
     /* supplier of order */
     echo "<tr class='tab_bg_1'><td>" . __("Supplier") . ": </td>";
     echo "<td>";
     if ($canedit && !$this->checkIfDetailExists($ID)) {
         $rand = mt_rand();
         Supplier::dropdown(array('name' => "suppliers_id", 'rand' => $rand, 'value' => $this->fields["suppliers_id"], 'entity' => $this->fields["entities_id"]));
         $params = array('suppliers_id' => '__VALUE__', 'fieldname' => 'contacts_id');
         Ajax::updateItemOnSelectEvent("dropdown_suppliers_id{$rand}", "show_contacts_id{$rand}", "../ajax/dropdownSupplier.php", $params);
     } else {
         $supplier = new Supplier();
         if ($supplier->can($this->fields['suppliers_id'], READ)) {
             echo $supplier->getLink();
         } else {
             echo Dropdown::getDropdownName("glpi_suppliers", $this->fields["suppliers_id"]);
         }
     }
     echo "</td>";
     /* port price */
     echo "<td>" . __("Postage", "order") . ": </td>";
     echo "<td>";
     if ($canedit) {
         echo "<input type='number' step='" . PLUGIN_ORDER_NUMBER_STEP . "' name='port_price' size='5'" . " value=\"" . Html::formatNumber($this->fields["port_price"], true) . "\">";
     } else {
         echo Html::formatNumber($this->fields["port_price"]);
     }
     echo "</td>";
     echo "</tr>";
     /* linked contact of the supplier of order */
     echo "<tr class='tab_bg_1'><td>" . __("Contact") . ": </td>";
     echo "<td><span id='show_contacts_id'>";
     if ($canedit) {
         echo "<span id='show_contacts_id{$rand}'>";
         // Make a select box
         $query = "SELECT c.`id`, c.`name`, c.`firstname`\n                   FROM `glpi_contacts` c\n                   LEFT JOIN `glpi_contacts_suppliers` s ON (s.`contacts_id` = c.`id`)\n                   WHERE s.`suppliers_id` = '{$this->fields['suppliers_id']}'\n                   ORDER BY c.`name`";
         $result = $DB->query($query);
         $number = $DB->numrows($result);
         $values = array(0 => Dropdown::EMPTY_VALUE);
         if ($number) {
             while ($data = $DB->fetch_assoc($result)) {
                 $values[$data['id']] = formatUserName('', '', $data['name'], $data['firstname']);
             }
         }
         Dropdown::showFromArray("contacts_id", $values, array('value' => $this->fields['contacts_id'], 'rand' => $rand));
         echo "</span>\n";
     } else {
         echo Dropdown::getDropdownName("glpi_contacts", $this->fields["contacts_id"]);
     }
     echo "</span></td>";
     /* tva port price */
     echo "<td>" . __("VAT", "order") . " " . __("Postage", "order") . ": </td><td>";
     $PluginOrderConfig = new PluginOrderConfig();
     $default_taxes = $PluginOrderConfig->getDefaultTaxes();
     $taxes = empty($ID) || $ID < 0 ? $default_taxes : $this->fields["plugin_order_ordertaxes_id"];
     if ($canedit) {
         PluginOrderOrderTax::Dropdown(array('name' => "plugin_order_ordertaxes_id", 'value' => $taxes, 'display_emptychoice' => true, 'emptylabel' => __("No VAT", "order")));
     } else {
         echo Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $taxes);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Associable to a ticket") . "&nbsp;:</td><td>";
     if ($canedit) {
         Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     } else {
         echo Dropdown::getYesNo($this->fields['is_helpdesk_visible']);
     }
     echo "</td>";
     echo "<td>";
     echo __("Estimated due date", "order") . ":";
     if ($this->isDelivered() && $this->fields['deliverydate']) {
         echo "<br/>" . __("Delivery date") . ":";
     }
     echo " </td><td>";
     if ($canedit) {
         if ($this->fields["duedate"] == NULL) {
             Html::showDateFormItem("duedate", '', true, true);
         } else {
             Html::showDateFormItem("duedate", $this->fields["duedate"], true, true);
         }
     } else {
         echo Html::convDate($this->fields["duedate"]);
     }
     if ($this->shouldBeAlreadyDelivered()) {
         echo "<br/><span class='red'>" . __("Due date overtaken", "order") . "</span>";
     }
     if ($this->isDelivered() && $this->fields['deliverydate']) {
         echo "<br/>" . Html::convDate($this->fields['deliverydate']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2' class='center'>" . $datestring;
     if (!$template && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>(" . __("Template name") . "&nbsp;: " . $this->fields['template_name'] . ")</span>";
     }
     echo "</td><td colspan='2'></td>";
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     //comments of order
     echo "<td>" . __("Comments") . ":  </td>";
     echo "<td colspan='3' align='center'>";
     if ($canedit) {
         echo "<textarea cols='40' rows='3' name='comment'>" . $this->fields["comment"] . "</textarea>";
     } else {
         echo $this->fields["comment"];
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<th colspan='2'>" . __("Actor") . "</th>";
     if ($ID > 0 && !$template) {
         echo "<th colspan='2'>" . __("Cost") . "</th></tr>";
     } else {
         echo "<th colspan='2'></th>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td colspan='2'>";
     echo "<table class='format'>";
     echo "<tr class='tab_bg_1'><td>" . __("Author") . ":</td><td style='width: 170px;'>";
     if ($canedit) {
         if ($template == 'newcomp') {
             $value = Session::getLoginUserID();
         } else {
             $value = $this->fields['users_id'];
         }
         User::Dropdown(array('name' => 'users_id', 'value' => $value, 'right' => 'interface', 'entity' => $this->fields["entities_id"], 'width' => '150px'));
     } else {
         if ($this->fields['users_id']) {
             $output = "";
             if ($user->getFromDB($this->fields['users_id'])) {
                 $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']);
             }
             echo $output;
         }
     }
     echo "</td>";
     echo "<td>" . __("Author group", "order") . ":</td>";
     echo "<td style='width: 180px;'>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             if (!empty($this->fields['groups_id'])) {
                 $groups_id = $this->fields['groups_id'];
             } else {
                 $groups_id = $config->getDefaultAuthorGroup();
             }
         } else {
             $groups_id = $this->fields['groups_id'];
         }
         Group::Dropdown(array('value' => $groups_id, 'width' => '150px'));
     } else {
         echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id']);
     }
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __("Recipient") . ":</td>";
     echo "<td style='width: 170px;'>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             if (!empty($this->fields['users_id_delivery'])) {
                 $users_id = $this->fields['users_id_delivery'];
             } else {
                 $users_id = $config->getDefaultRecipient();
             }
         } else {
             $users_id = $this->fields['users_id_delivery'];
         }
         User::Dropdown(array('name' => 'users_id_delivery', 'value' => $users_id, 'right' => 'all', 'entity' => $this->fields["entities_id"], 'width' => '150px'));
     } else {
         if ($this->fields['users_id_delivery']) {
             $user->getFromDB($this->fields['users_id_delivery']);
             $output = formatUserName($this->fields['users_id'], $user->fields['name'], $user->fields['realname'], $user->fields['firstname']);
             echo $output;
         }
     }
     echo "</td>";
     echo "<td>" . __("Recipient group", "order") . ":</td>";
     echo "<td style='width: 180px;'>";
     if ($canedit) {
         if (empty($ID) || $ID < 0) {
             if (!empty($this->fields['groups_id_delivery'])) {
                 $groups_id = $this->fields['groups_id_delivery'];
             } else {
                 $groups_id = $config->getDefaultRecipientGroup();
             }
         } else {
             $groups_id = $this->fields['groups_id_delivery'];
         }
         Group::Dropdown(array('name' => 'groups_id_delivery', 'value' => $groups_id, 'width' => '150px'));
     } else {
         echo Dropdown::getDropdownName('glpi_groups', $this->fields['groups_id_delivery']);
     }
     echo "</td>";
     echo "</tr></table></td>";
     echo "<td colspan='2'>";
     if ($ID > 0 && !$template) {
         $PluginOrderOrder_Item = new PluginOrderOrder_Item();
         $prices = $PluginOrderOrder_Item->getAllPrices($ID);
         echo "<table class='format'>";
         echo "<tr>";
         echo "<td>" . __("Price tax free", "order") . "</td>";
         echo "<td>" . Html::formatNumber($prices["priceHT"]) . "</td>";
         echo "</tr>";
         // total price (with postage)
         $postagewithTVA = $PluginOrderOrder_Item->getPricesATI($this->fields["port_price"], Dropdown::getDropdownName("glpi_plugin_order_ordertaxes", $this->fields["plugin_order_ordertaxes_id"]));
         $priceHTwithpostage = $prices["priceHT"] + $this->fields["port_price"];
         echo "<tr>";
         echo "<td>" . __("Price tax free with postage", "order") . "</td>";
         echo "<td>" . Html::formatNumber($priceHTwithpostage) . "</td>";
         echo "</tr>";
         // total price (with taxes)
         $total = $prices["priceTTC"] + $postagewithTVA;
         echo "<tr>";
         echo "<td>" . __("Price ATI", "order") . "</td>";
         echo "<td>" . Html::formatNumber($total) . "</td>";
         echo "</tr>";
         // total TVA
         $total_tva = $prices["priceTVA"] + ($postagewithTVA - $this->fields["port_price"]);
         echo "<tr>";
         echo "<td>" . __("VAT", "order") . "</td>";
         echo "<td>" . Html::formatNumber($total_tva) . "</td>";
         echo "</tr>";
         echo "</table>";
     }
     echo "</td>";
     echo "</tr>";
     if ($canedit || $cancancel) {
         $this->showFormButtons($options);
     } else {
         echo "</table></div>";
         Html::closeForm();
     }
     return true;
 }
コード例 #24
0
 /**
  * Display form for perfdata
  *
  * @param $items_id integer ID
  * @param $options array
  *
  *@return bool true if form is ok
  *
  **/
 function showForm($items_id, $options = array())
 {
     $this->initForm($items_id, $options);
     $this->showFormHeader($options);
     echo "<tr>";
     echo "<td>";
     echo __('Name') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", 1, $this->getType());
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     // * perfdata
     echo "<td>" . __('A perfdata for this check', 'monitoring') . "&nbsp;:</td>";
     echo "<td>";
     echo "<input type='name' name='perfdata' value=\"" . $this->fields['perfdata'] . "\" size='80'/>";
     echo "</td>";
     echo "</tr>";
     $this->showFormButtons($options);
     if ($this->fields['id'] > 0) {
         $pmPerfdataDetail = new PluginMonitoringPerfdataDetail();
         $pmPerfdataDetail->showDetails($this->fields['id']);
         $pmPerfdataDetail->updateDetailForPerfdata($this->fields['perfdata'], $this->fields['id']);
     }
     return true;
 }
コード例 #25
0
ファイル: infocom.class.php プロジェクト: gaforeror/glpi
 /**
  * Duplicate infocoms from an item template to its clone
  *
  * @param $itemtype     itemtype of the item
  * @param $oldid        ID of the item to clone
  * @param $newid        ID of the item cloned
  * @param $newitemtype  itemtype of the new item (= $itemtype if empty) (default '')
  **/
 static function cloneItem($itemtype, $oldid, $newid, $newitemtype = '')
 {
     global $DB;
     $ic = new self();
     if ($ic->getFromDBforDevice($itemtype, $oldid)) {
         $input = $ic->fields;
         $input = Toolbox::addslashes_deep($input);
         $input['items_id'] = $newid;
         if (!empty($newitemtype)) {
             $input['itemtype'] = $newitemtype;
         }
         unset($input["id"]);
         if (isset($input["immo_number"])) {
             $input["immo_number"] = autoName($input["immo_number"], "immo_number", 1, 'Infocom', $input['entities_id']);
         }
         $date_fields = array('buy_date', 'delivery_date', 'inventory_date', 'order_date', 'use_date', 'warranty_date');
         foreach ($date_fields as $f) {
             if (empty($input[$f])) {
                 unset($input[$f]);
             }
         }
         $ic2 = new self();
         $ic2->add($input);
     }
 }
コード例 #26
0
 /**
  * Display form for service configuration
  *
  * @param $items_id integer ID
  * @param $options array
  *
  *@return bool true if form is ok
  *
  **/
 function showForm($items_id, $options = array())
 {
     $pMonitoringCommand = new PluginMonitoringCommand();
     if ($items_id == '0') {
         $this->getEmpty();
     } else {
         $this->getFromDB($items_id);
     }
     $this->showFormHeader($options);
     echo "<tr>";
     echo "<td>";
     echo __('Template name') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     echo "<input type='hidden' name='is_template' value='1' />";
     $objectName = autoName($this->fields["name"], "name", 1, $this->getType());
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     // * commande
     echo "<td>";
     echo __('Command', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td align='center'>";
     if ($this->fields['is_template'] == '1') {
         $pMonitoringCommand->getFromDB($this->fields['plugin_monitoring_commands_id']);
         echo $pMonitoringCommand->getLink(1);
     } else {
         $pMonitoringCommand->getFromDB($this->fields['plugin_monitoring_commands_id']);
         Dropdown::show("PluginMonitoringCommand", array('name' => 'plugin_monitoring_commands_id', 'value' => $this->fields['plugin_monitoring_commands_id']));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     // * checks
     echo "<td>" . __('Check definition', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     if ($this->fields['is_template'] == '1') {
         $pMonitoringCheck = new PluginMonitoringCheck();
         $pMonitoringCheck->getFromDB($this->fields['plugin_monitoring_checks_id']);
         echo $pMonitoringCheck->getLink(1);
     } else {
         Dropdown::show("PluginMonitoringCheck", array('name' => 'plugin_monitoring_checks_id', 'value' => $this->fields['plugin_monitoring_checks_id']));
     }
     echo "</td>";
     // * active check
     echo "<td>";
     echo __('Active checks enable', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td align='center'>";
     if ($this->fields['is_template'] == '1') {
         echo Dropdown::getYesNo($this->fields['active_checks_enabled']);
     } else {
         Dropdown::showYesNo("active_checks_enabled", $this->fields['active_checks_enabled']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     // * passive check
     echo "<td>";
     echo __('Passive checks enable', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td align='center'>";
     if ($this->fields['is_template'] == '1') {
         echo Dropdown::getYesNo($this->fields['passive_checks_enabled']);
     } else {
         Dropdown::showYesNo("passive_checks_enabled", $this->fields['passive_checks_enabled']);
     }
     echo "</td>";
     // * calendar
     echo "<td>" . __('Check period', 'monitoring') . "&nbsp;:</td>";
     echo "<td align='center'>";
     if ($this->fields['is_template'] == '1') {
         $calendar = new Calendar();
         $calendar->getFromDB($this->fields['calendars_id']);
         echo $calendar->getLink(1);
     } else {
         dropdown::show("Calendar", array('name' => 'calendars_id', 'value' => $this->fields['calendars_id']));
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     echo "<th colspan='4'>" . __('Remote check', 'monitoring') . "</th>";
     echo "</tr>";
     echo "<tr>";
     // * remotesystem
     echo "<td>";
     echo __('Utility used for remote check', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     $input = array();
     $input[''] = '------';
     $input['byssh'] = __('By ssh', 'monitoring');
     $input['nrpe'] = 'nrpe';
     $input['nsca'] = 'nsca';
     if ($this->fields['is_template'] == '1') {
         echo $input[$this->fields['remotesystem']];
     } else {
         Dropdown::showFromArray("remotesystem", $input, array('value' => $this->fields['remotesystem']));
     }
     echo "</td>";
     // * is_argument
     echo "<td>";
     echo __('Use arguments (Only for NRPE)', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     if ($this->fields['is_template'] == '1') {
         echo Dropdown::getYesNo($this->fields['is_arguments']);
     } else {
         Dropdown::showYesNo("is_arguments", $this->fields['is_arguments']);
     }
     echo "</td>";
     echo "</tr>";
     echo "<tr>";
     // alias command
     echo "<td>";
     echo __('Alias command if required (Only for NRPE)', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     if ($this->fields['is_template'] == '1') {
         echo "<input type='text' name='alias_commandservice' value='" . $this->fields['alias_command'] . "' />";
     } else {
         echo "<input type='text' name='alias_command' value='" . $this->fields['alias_command'] . "' />";
     }
     echo "</td>";
     echo "<td>";
     echo __('Command link (used for graphs generation)', 'monitoring') . "&nbsp;:";
     echo "</td>";
     echo "<td>";
     if ($this->fields['is_template'] == '1') {
         $pMonitoringCommand->getFromDB($this->fields['aliasperfdata_commands_id']);
         echo $pMonitoringCommand->getLink(1);
     } else {
         $pMonitoringCommand->getFromDB($this->fields['aliasperfdata_commands_id']);
         Dropdown::show("PluginMonitoringCommand", array('name' => 'aliasperfdata_commands_id', 'value' => $this->fields['aliasperfdata_commands_id']));
     }
     echo "</td>";
     echo "</tr>";
     // * Manage arguments
     $array = array();
     $a_displayarg = array();
     if (isset($pMonitoringCommand->fields['command_line'])) {
         preg_match_all("/\\\$(ARG\\d+)\\\$/", $pMonitoringCommand->fields['command_line'], $array);
         $a_arguments = importArrayFromDB($this->fields['arguments']);
         foreach ($array[0] as $arg) {
             if (strstr($arg, "ARG")) {
                 $arg = str_replace('$', '', $arg);
                 if (!isset($a_arguments[$arg])) {
                     $a_arguments[$arg] = '';
                 }
                 $a_displayarg[$arg] = $a_arguments[$arg];
             }
         }
     }
     if (count($a_displayarg) > 0) {
         $a_argtext = importArrayFromDB($pMonitoringCommand->fields['arguments']);
         echo "<tr>";
         echo "<th colspan='4'>" . __('Arguments', 'monitoring') . "&nbsp;</th>";
         echo "</tr>";
         foreach ($a_displayarg as $key => $value) {
             echo "<tr>";
             echo "<th>" . $key . "</th>";
             echo "<td colspan='2'>";
             if (isset($a_argtext[$key])) {
                 echo nl2br($a_argtext[$key]) . "&nbsp;:";
             } else {
                 echo __('Argument', 'monitoring') . "&nbsp;:";
             }
             echo "</td>";
             echo "<td>";
             echo "<input type='text' name='arg[" . $key . "]' value='" . $value . "'/><br/>";
             echo "</td>";
             echo "</tr>";
         }
     }
     $this->showFormButtons($options);
     return true;
 }
コード例 #27
0
ファイル: computer.class.php プロジェクト: pvasener/glpi
 /**
  * Print the computer form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic computer
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB;
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_computer`"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     ComputerType::dropdown(array('value' => $this->fields["computertypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     ComputerModel::dropdown(array('value' => $this->fields["computermodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     //TRANS: Number of the alternate username
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'contact_num');
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'contact');
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Network') . "</td>";
     echo "<td>";
     Network::dropdown(array('value' => $this->fields["networks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     // Display auto inventory informations
     $rowspan = 10;
     $inventory_show = false;
     if (!empty($ID) && Plugin::haveImport() && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 4;
     }
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}' class='middle'>";
     echo "<textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Domain') . "</td>";
     echo "<td >";
     Domain::dropdown(array('value' => $this->fields["domains_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Operating system') . "</td>";
     echo "<td>";
     OperatingSystem::dropdown(array('value' => $this->fields["operatingsystems_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Service pack') . "</td>";
     echo "<td >";
     OperatingSystemServicePack::dropdown(array('value' => $this->fields["operatingsystemservicepacks_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Version of the operating system') . "</td>";
     echo "<td >";
     OperatingSystemVersion::dropdown(array('value' => $this->fields["operatingsystemversions_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Product ID of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_licenseid');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Serial of the operating system') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'os_license_number');
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='4' colspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('UUID') . "</td>";
     echo "<td >";
     Html::autocompletionTextField($this, 'uuid');
     echo "</td>";
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of update
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Update Source') . "</td>";
     echo "<td >";
     AutoUpdateSystem::dropdown(array('value' => $this->fields["autoupdatesystems_id"]));
     echo "</td></tr>";
     $this->showFormButtons($options);
     return true;
 }
コード例 #28
0
ファイル: object.class.php プロジェクト: btry/genericobject
 function displayField($canedit, $name, $value, $template, $description = array())
 {
     global $GO_BLACKLIST_FIELDS;
     $searchoption = PluginGenericobjectField::getFieldOptions($name, get_called_class());
     if (!empty($searchoption) && !in_array($name, self::getFieldsToHide())) {
         $this->startColumn();
         echo $searchoption['name'];
         if (isset($searchoption['autoname']) && $searchoption['autoname'] && $template) {
             echo "*&nbsp;";
         }
         $this->endColumn();
         $this->startColumn();
         switch ($description['Type']) {
             case "int(11)":
                 $fk_table = getTableNameForForeignKeyField($name);
                 if ($fk_table != '') {
                     $itemtype = getItemTypeForTable($fk_table);
                     $dropdown = new $itemtype();
                     $parameters = array('name' => $name, 'value' => $value, 'comments' => true);
                     if ($dropdown->isEntityAssign()) {
                         $parameters["entity"] = $this->fields['entities_id'];
                     }
                     if ($dropdown->maybeRecursive()) {
                         $parameters['entity_sons'] = true;
                     }
                     if (isset($searchoption['condition'])) {
                         $parameters['condition'] = $searchoption['condition'];
                     }
                     if ($dropdown instanceof User) {
                         $parameters['entity'] = $this->fields["entities_id"];
                         $parameters['right'] = 'all';
                         User::dropdown($parameters);
                     } else {
                         Dropdown::show($itemtype, $parameters);
                     }
                 } else {
                     $min = $max = $step = 0;
                     if (isset($searchoption['min'])) {
                         $min = $searchoption['min'];
                     } else {
                         $min = 0;
                     }
                     if (isset($searchoption['max'])) {
                         $max = $searchoption['max'];
                     } else {
                         $max = 100;
                     }
                     if (isset($searchoption['step'])) {
                         $step = $searchoption['step'];
                     } else {
                         $step = 1;
                     }
                     Dropdown::showInteger($name, $value, $min, $max, $step);
                 }
                 break;
             case "tinyint(1)":
                 Dropdown::showYesNo($name, $value);
                 break;
             case "varchar(255)":
                 if (isset($searchoption['autoname']) && $searchoption['autoname']) {
                     $objectName = autoName($this->fields[$name], $name, $template === "newcomp", $this->getType(), $this->fields["entities_id"]);
                 } else {
                     $objectName = $this->fields[$name];
                 }
                 Html::autocompletionTextField($this, $name, array('value' => $objectName));
                 break;
             case "longtext":
             case "text":
                 echo "<textarea cols='40' rows='4' name='" . $name . "'>" . $value . "</textarea>";
                 break;
             case "date":
                 Html::showDateFormItem($name, $value, true, true);
                 break;
             case "datetime":
                 Html::showDateTimeFormItem($name, $value, true, true);
                 break;
             default:
             case "float":
                 echo "<input type='text' name='{$name}' value='{$value}'>";
                 break;
             case 'decimal':
                 echo "<input type='text' name='{$name}' value='" . Html::formatNumber($value) . "'>";
                 break;
         }
         $this->endColumn();
     }
 }
コード例 #29
0
 /**
  * Print the phone form
  *
  * @param $ID integer ID of the item
  * @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;
     $target = $this->getFormURL();
     $withtemplate = $this->initForm($ID, $options);
     $this->showFormHeader($options);
     echo "<tr class='tab_bg_1'>";
     //TRANS: %1$s is a string, %2$s a second one without spaces between them : to change for RTL
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Name'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('Status') . "</td>";
     echo "<td>";
     State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_phone`='1'"));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td>";
     echo "<td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Type') . "</td>";
     echo "<td>";
     PhoneType::dropdown(array('value' => $this->fields["phonetypes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Manufacturer') . "</td>";
     echo "<td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td>" . __('Model') . "</td>";
     echo "<td>";
     PhoneModel::dropdown(array('value' => $this->fields["phonemodels_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "contact_num");
     echo "</td>";
     echo "<td>" . __('Serial number') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "serial");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Alternate username') . "</td><td>";
     Html::autocompletionTextField($this, "contact");
     echo "</td>";
     echo "<td>" . sprintf(__('%1$s%2$s'), __('Inventory number'), isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('User') . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<td>" . __('Management type') . "</td>";
     echo "<td>";
     Dropdown::showGlobalSwitch($this->fields["id"], array('withtemplate' => $withtemplate, 'value' => $this->fields["is_global"], 'management_restrict' => $CFG_GLPI["phones_management_restrict"], 'target' => $target));
     echo "</td></tr>\n";
     // Display auto inventory informations
     $rowspan = 7;
     $inventory_show = false;
     if (!empty($ID) && $this->fields["is_dynamic"]) {
         $inventory_show = true;
         $rowspan -= 2;
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td>";
     echo "<td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td>";
     echo "<td rowspan='{$rowspan}'>" . __('Comments') . "</td>";
     echo "<td rowspan='{$rowspan}'>\n            <textarea cols='45' rows='" . ($rowspan + 3) . "' name='comment' class='form-control' >" . $this->fields["comment"];
     echo "</textarea></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Brand') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "brand");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Power supply') . "</td>";
     echo "<td>";
     PhonePowerSupply::dropdown(array('value' => $this->fields["phonepowersupplies_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Firmware', 'Firmwares', 1) . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "firmware");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _x('quantity', 'Number of lines') . "</td><td>";
     Html::autocompletionTextField($this, "number_line");
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Flags') . "</td>";
     echo "<td>";
     // micro?
     echo "\n<table><tr><td>" . __('Headset') . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_headset", $this->fields["have_headset"]);
     echo "</td></tr>";
     // hp?
     echo "<tr><td>" . __('Speaker') . "</td>";
     echo "<td>&nbsp;";
     Dropdown::showYesNo("have_hp", $this->fields["have_hp"]);
     echo "</td></tr></table>\n";
     echo "</td>";
     if ($inventory_show) {
         echo "<td rowspan='2'>" . __('Automatic inventory') . "</td>";
         echo "<td rowspan='2'>";
         Plugin::doHook("autoinventory_information", $this);
         echo "</td>";
     }
     echo "</tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of insertion
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }
コード例 #30
0
ファイル: simcard.class.php プロジェクト: geldarr/hack-space
 /**
  * Print the simcard form
  *
  * @param $ID        integer ID of the item
  * @param $options   array
  *     - target for the Form
  *     - withtemplate template or basic simcard
  *
  *@return Nothing (display)
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI, $DB, $LANG;
     $target = $this->getFormURL();
     $withtemplate = '';
     if (isset($options['target'])) {
         $target = $options['target'];
     }
     if (isset($options['withtemplate'])) {
         $withtemplate = $options['withtemplate'];
     }
     if ($ID > 0) {
         $this->check($ID, 'r');
     } else {
         // Create item
         $this->check(-1, 'w');
     }
     $this->showTabs($options);
     $this->showFormHeader($options);
     if (isset($options['itemtype']) && isset($options['items_id'])) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['document'][14] . "</td>";
         echo "<td>";
         $item = new $options['itemtype']();
         $item->getFromDB($options['items_id']);
         echo $item->getLink(1);
         echo "</td>";
         echo "<td colspan='2'></td></tr>\n";
         echo "<input type='hidden' name='_itemtype' value='" . $options['itemtype'] . "'>";
         echo "<input type='hidden' name='_items_id' value='" . $options['items_id'] . "'>";
     }
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Nom') . (isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["name"], "name", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'name', array('value' => $objectName));
     echo "</td>";
     echo "<td>" . __('statut') . "</td>";
     echo "<td>";
     Dropdown::show('State', array('value' => $this->fields["states_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . 'Lieu' . "</td>";
     echo "<td>";
     Dropdown::show('Location', array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['plugin_simcard'][6] . "</td>";
     echo "<td>";
     Dropdown::show('PluginSimcardSimcardSize', array('value' => $this->fields["plugin_simcard_simcardsizes_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . 'Responsable Technique' . "</td>";
     echo "<td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'interface', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . $LANG['plugin_simcard'][9] . "</td>";
     echo "<td>";
     Dropdown::show('PluginSimcardSimcardVoltage', array('value' => $this->fields["plugin_simcard_simcardvoltages_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_simcard'][7] . "</td>";
     echo "<td>";
     Dropdown::show('PluginSimcardPhoneOperator', array('value' => $this->fields["plugin_simcard_phoneoperators_id"]));
     echo "</td>";
     echo "<td>" . 'Associable à un ticket' . "&nbsp;:</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . 'Utilisateur' . "</td>";
     echo "<td>";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td>";
     echo "<input type='hidden' name='is_global' value='1'>";
     echo "<td></td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . 'Groupe' . "</td>";
     echo "<td>";
     Dropdown::show('Group', array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td rowspan='7'>" . 'common' . "</td>";
     echo "<td rowspan='7' class='middle'>";
     echo "<textarea cols='45' rows='15' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_simcard'][1] . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'phonenumber');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . $LANG['plugin_simcard'][8] . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, 'serial');
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . "Numéro d'inventaire" . (isset($options['withtemplate']) && $options['withtemplate'] ? "*" : "") . "</td>";
     echo "<td>";
     $objectName = autoName($this->fields["otherserial"], "otherserial", isset($options['withtemplate']) && $options['withtemplate'] == 2, $this->getType(), $this->fields["entities_id"]);
     Html::autocompletionTextField($this, 'otherserial', array('value' => $objectName));
     echo "</td></tr>\n";
     //Only show PIN and PUK code to users who can write (theses informations are highly sensible)
     if (Session::haveRight('simcard', 'w')) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['plugin_simcard'][3] . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'pin');
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['plugin_simcard'][5] . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'pin2');
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['plugin_simcard'][4] . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'puk');
         echo "</td></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . $LANG['plugin_simcard'][2] . "</td>";
         echo "<td>";
         Html::autocompletionTextField($this, 'puk2');
         echo "</td></tr>\n";
     }
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }