/**
  * Display a list of computers to add or to link
  *
  * @param plugin_ocsinventoryng_ocsservers_id the ID of the ocs server
  * @param advanced display detail about the computer import or not (target entity, matched rules, etc.)
  * @param check indicates if checkboxes are checked or not
  * @param start display a list of computers starting at rowX
  * @param entity a list of entities in which computers can be added or linked
  * @param tolinked false for an import, true for a link
  *
  * @return nothing
  **/
 static function showComputersToAdd($serverId, $advanced, $check, $start, $entity = 0, $tolinked = false)
 {
     global $DB, $CFG_GLPI;
     if (!Session::haveRight("plugin_ocsinventoryng", UPDATE)) {
         return false;
     }
     $title = __('Import new computers', 'ocsinventoryng');
     if ($tolinked) {
         $title = __('Link new OCSNG computers to existing GLPI computers', 'ocsinventoryng');
     }
     $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.import.php';
     if ($tolinked) {
         $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.link.php';
     }
     // Get all links between glpi and OCS
     $query_glpi = "SELECT ocsid\n                     FROM `glpi_plugin_ocsinventoryng_ocslinks`\n                     WHERE `plugin_ocsinventoryng_ocsservers_id` = '{$serverId}'";
     $result_glpi = $DB->query($query_glpi);
     $already_linked = array();
     if ($DB->numrows($result_glpi) > 0) {
         while ($data = $DB->fetch_array($result_glpi)) {
             $already_linked[] = $data["ocsid"];
         }
     }
     $cfg_ocs = self::getConfig($serverId);
     $computerOptions = array('OFFSET' => $start, 'MAX_RECORDS' => $_SESSION['glpilist_limit'], 'ORDER' => 'LASTDATE', 'FILTER' => array('EXCLUDE_IDS' => $already_linked), 'DISPLAY' => array('CHECKSUM' => PluginOcsinventoryngOcsClient::CHECKSUM_BIOS), 'ORDER' => 'NAME');
     if ($cfg_ocs["tag_limit"] and $tag_limit = explode("\$", trim($cfg_ocs["tag_limit"]))) {
         $computerOptions['FILTER']['TAGS'] = $tag_limit;
     }
     if ($cfg_ocs["tag_exclude"] and $tag_exclude = explode("\$", trim($cfg_ocs["tag_exclude"]))) {
         $computerOptions['FILTER']['EXCLUDE_TAGS'] = $tag_exclude;
     }
     $ocsClient = self::getDBocs($serverId);
     $ocsResult = $ocsClient->getComputers($computerOptions);
     if (isset($ocsResult['COMPUTERS'])) {
         $computers = $ocsResult['COMPUTERS'];
         if (count($computers)) {
             // Get all hardware from OCS DB
             $hardware = array();
             foreach ($computers as $data) {
                 $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
                 $id = $data['META']['ID'];
                 $hardware[$id]["date"] = $data['META']["LASTDATE"];
                 $hardware[$id]["name"] = $data['META']["NAME"];
                 $hardware[$id]["TAG"] = $data['META']["TAG"];
                 $hardware[$id]["id"] = $data['META']["ID"];
                 if (isset($data['BIOS']) && count($data['BIOS'])) {
                     $hardware[$id]["serial"] = $data['BIOS']["SSN"];
                     $hardware[$id]["model"] = $data['BIOS']["SMODEL"];
                     $hardware[$id]["manufacturer"] = $data['BIOS']["SMANUFACTURER"];
                 } else {
                     $hardware[$id]["serial"] = '';
                     $hardware[$id]["model"] = '';
                     $hardware[$id]["manufacturer"] = '';
                 }
             }
             if ($tolinked && count($hardware)) {
                 echo "<div class='center b'>" . __('Caution! The imported data (see your configuration) will overwrite the existing one', 'ocsinventoryng') . "</div>";
             }
             echo "<div class='center'>";
             if ($numrows = $ocsResult['TOTAL_COUNT']) {
                 $parameters = "check={$check}";
                 Html::printPager($start, $numrows, $target, $parameters);
                 //Show preview form only in import even in multi-entity mode because computer import
                 //can be refused by a rule
                 if (!$tolinked) {
                     echo "<div class='firstbloc'>";
                     echo "<form method='post' name='ocsng_import_mode' id='ocsng_import_mode'\n                         action='{$target}'>\n";
                     echo "<table class='tab_cadre_fixe'>";
                     echo "<tr><th>" . __('Manual import mode', 'ocsinventoryng') . "</th></tr>\n";
                     echo "<tr class='tab_bg_1'><td class='center'>";
                     if ($advanced) {
                         Html::showSimpleForm($target, 'change_import_mode', __('Disable preview', 'ocsinventoryng'), array('id' => 'false'));
                     } else {
                         Html::showSimpleForm($target, 'change_import_mode', __('Enable preview', 'ocsinventoryng'), array('id' => 'true'));
                     }
                     echo "</td></tr>";
                     echo "<tr class='tab_bg_1'><td class='center b'>" . __('Check first that duplicates have been correctly managed in OCSNG', 'ocsinventoryng') . "</td>";
                     echo "</tr></table>";
                     Html::closeForm();
                     echo "</div>";
                 }
                 echo "<form method='post' name='ocsng_form' id='ocsng_form' action='{$target}'>";
                 if (!$tolinked) {
                     self::checkBox($target);
                 }
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
                 echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">";
                 echo "</td></tr>\n";
                 echo "<tr><th>" . __('Name') . "</th>\n";
                 echo "<th>" . __('Manufacturer') . "</th>\n";
                 echo "<th>" . __('Model') . "</th>\n";
                 echo "<th>" . __('Serial number') . "</th>\n";
                 echo "<th>" . __('Date') . "</th>\n";
                 echo "<th>" . __('OCSNG TAG', 'ocsinventoryng') . "</th>\n";
                 if ($advanced && !$tolinked) {
                     echo "<th>" . __('Match the rule ?', 'ocsinventoryng') . "</th>\n";
                     echo "<th>" . __('Destination entity') . "</th>\n";
                     echo "<th>" . __('Target location', 'ocsinventoryng') . "</th>\n";
                 }
                 echo "<th width='20%'>&nbsp;</th></tr>\n";
                 $rule = new RuleImportEntityCollection();
                 foreach ($hardware as $ID => $tab) {
                     $comp = new Computer();
                     $comp->fields["id"] = $tab["id"];
                     $data = array();
                     if ($advanced && !$tolinked) {
                         $data = $rule->processAllRules(array('ocsservers_id' => $serverId, '_source' => 'ocsinventoryng'), array(), array('ocsid' => $tab["id"]));
                     }
                     echo "<tr class='tab_bg_2'><td>" . $tab["name"] . "</td>\n";
                     echo "<td>" . $tab["manufacturer"] . "</td><td>" . $tab["model"] . "</td>";
                     echo "<td>" . $tab["serial"] . "</td>\n";
                     echo "<td>" . Html::convDateTime($tab["date"]) . "</td>\n";
                     echo "<td>" . $tab["TAG"] . "</td>\n";
                     if ($advanced && !$tolinked) {
                         if (!isset($data['entities_id']) || $data['entities_id'] == -1) {
                             echo "<td class='center'><img src=\"" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png\"></td>\n";
                             $data['entities_id'] = -1;
                         } else {
                             echo "<td class='center'>";
                             $tmprule = new RuleImportEntity();
                             if ($tmprule->can($data['_ruleid'], READ)) {
                                 echo "<a href='" . $tmprule->getLinkURL() . "'>" . $tmprule->getName() . "</a>";
                             } else {
                                 echo $tmprule->getName();
                             }
                             echo "</td>\n";
                         }
                         echo "<td width='30%'>";
                         $ent = "toimport_entities[" . $tab["id"] . "]";
                         Entity::dropdown(array('name' => $ent, 'value' => $data['entities_id'], 'comments' => 0));
                         echo "</td>\n";
                         echo "<td width='30%'>";
                         if (!isset($data['locations_id'])) {
                             $data['locations_id'] = 0;
                         }
                         $loc = "toimport_locations[" . $tab["id"] . "]";
                         Location::dropdown(array('name' => $loc, 'value' => $data['locations_id'], 'comments' => 0));
                         echo "</td>\n";
                     }
                     echo "<td>";
                     if (!$tolinked) {
                         echo "<input type='checkbox' name='toimport[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . ">";
                     } else {
                         $tab['entities_id'] = $entity;
                         $rulelink = new RuleImportComputerCollection();
                         $rulelink_results = array();
                         $params = array('entities_id' => $entity, 'plugin_ocsinventoryng_ocsservers_id' => $serverId);
                         $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab), array(), $params);
                         //Look for the computer using automatic link criterias as defined in OCSNG configuration
                         $options = array('name' => "tolink[" . $tab["id"] . "]");
                         $show_dropdown = true;
                         //If the computer is not explicitly refused by a rule
                         if (!isset($rulelink_results['action']) || $rulelink_results['action'] != self::LINK_RESULT_NO_IMPORT) {
                             if (!empty($rulelink_results['found_computers'])) {
                                 $options['value'] = $rulelink_results['found_computers'][0];
                                 $options['entity'] = $entity;
                             }
                             $options['width'] = "100%";
                             Computer::dropdown($options);
                         } else {
                             echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'>";
                         }
                     }
                     echo "</td></tr>\n";
                 }
                 echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
                 echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">\n";
                 echo "<input type=hidden name='plugin_ocsinventoryng_ocsservers_id' " . "value='{$serverId}'>";
                 echo "</td></tr>";
                 echo "</table>\n";
                 Html::closeForm();
                 if (!$tolinked) {
                     self::checkBox($target);
                 }
                 Html::printPager($start, $numrows, $target, $parameters);
             } else {
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . $title . "</th></tr>\n";
                 echo "<tr class='tab_bg_1'>";
                 echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
                 echo "</table>";
             }
             echo "</div>";
         } else {
             echo "<div class='center'>";
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . $title . "</th></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
             echo "</table></div>";
         }
     } else {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . $title . "</th></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
         echo "</table></div>";
     }
 }
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     switch ($ma->getAction()) {
         case 'import_email':
             Entity::dropdown();
             echo "<br><br>";
             echo Html::submit(_x('button', 'Import'), array('name' => 'massiveaction'));
             return true;
     }
     return parent::showMassiveActionsSubForm($ma);
 }
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     switch ($input['action']) {
         case "import_email":
             Entity::dropdown();
             echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Import') . "'>";
             return true;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
 static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0)
 {
     if (in_array(get_class($item), array("AuthLDAP"))) {
         $AuthLDAP = new PluginMoreldapAuthLDAP();
         if (!$AuthLDAP->getFromDB($item->fields['id'])) {
             //The directory exists in GLPI but there is no data in the plugin
             $AuthLDAP->preconfig();
         }
         $location_enabled = $AuthLDAP->fields['location_enabled'] == 'Y' ? ' checked' : '';
         echo '<div class="spaced">';
         echo '<form id="items" name="items" method="post" action="' . Toolbox::getItemTypeFormURL(__CLASS__) . '">';
         echo '<table class="tab_cadre_fixehov">';
         echo '<tr class="tab_bg_2">';
         echo '<th colspan="2">' . __("MoreLDAP", "moreldap") . '</th>';
         echo '</tr>';
         echo '<tr class="tab_bg_1">';
         echo '<td>' . __("LDAP attribute : location of users", "moreldap") . '</td>';
         echo '<td>' . __("Enabled", "moreldap") . '&nbsp;<input type="checkbox" name="location_enabled"' . $location_enabled . ' value="location_enabled"><br />';
         echo '<input size="72" type="text" name="location" value="' . $AuthLDAP->fields['location'] . '"> ';
         echo '<br />';
         Entity::dropdown(array('value' => $AuthLDAP->fields['entities_id']));
         echo '&nbsp;' . __("recursive", "moreldap") . "&nbsp;";
         Dropdown::showYesNo('is_recursive', $AuthLDAP->fields['is_recursive']);
         echo ' </td>';
         echo '</tr>';
         echo '<tr class="tab_bg_1">';
         echo '<td colspan="2" class="center">';
         echo '<input type="hidden" value="' . $item->fields['id'] . '" name="id">';
         echo '<input type="submit" class="submit" name="update" value="' . _sx('button', 'Save') . '">';
         echo '</td>';
         echo '</tr>';
         echo '</table>';
         Html::closeForm();
         echo "</div>";
     }
     return true;
 }
Beispiel #5
0
 /**
  * Print the transfer form
  *
  * @param $ID        integer : Id of the contact to print
  * @param $options   array
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  * @return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     global $CFG_GLPI;
     $edit_form = true;
     if (!strpos($_SERVER['PHP_SELF'], "transfer.form.php")) {
         $edit_form = false;
     }
     $this->initForm($ID, $options);
     $params = array();
     if (!Session::haveRight("transfer", "w")) {
         $params['readonly'] = true;
     }
     if ($edit_form) {
         $this->showTabs($options);
         $this->showFormHeader($options);
     } else {
         echo "<form method='post' name=form action='" . $options['target'] . "'>";
         echo "<div class='center' id='tabsbody' >";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><td class='tab_bg_2 top' colspan='4'>";
         echo "<div class='center'>";
         Entity::dropdown(array('name' => 'to_entity'));
         echo "&nbsp;<input type='submit' name='transfer' value=\"" . __s('Execute') . "\"\n                      class='submit'></div>";
         echo "</td></tr>";
     }
     if ($edit_form) {
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Name') . "</td><td>";
         Html::autocompletionTextField($this, "name");
         echo "</td>";
         echo "<td rowspan='3' class='middle right'>" . __('Comments') . "</td>";
         echo "<td class='center middle' rowspan='3'>\n               <textarea cols='45' rows='3' name='comment' >" . $this->fields["comment"] . "</textarea>";
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         echo "<td>" . __('Last update') . "</td>";
         echo "<td>" . ($this->fields["date_mod"] ? Html::convDateTime($this->fields["date_mod"]) : __('Never'));
         echo "</td></tr>";
     }
     $keep = array(0 => _x('button', 'Delete permanently'), 1 => __('Preserve'));
     $clean = array(0 => __('Preserve'), 1 => _x('button', 'Put in dustbin'), 2 => _x('button', 'Delete permanently'));
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Historical') . "</td><td>";
     $params['value'] = $this->fields['keep_history'];
     Dropdown::showFromArray('keep_history', $keep, $params);
     echo "</td>";
     if (!$edit_form) {
         echo "<td colspan='2'>&nbsp;</td>";
     }
     echo "</tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . __('Assets') . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Network port', 'Network ports', 2) . "</td><td>";
     $options = array(0 => _x('button', 'Delete permanently'), 1 => __('Disconnect'), 2 => __('Keep'));
     $params['value'] = $this->fields['keep_networklink'];
     Dropdown::showFromArray('keep_networklink', $options, $params);
     echo "</td>";
     echo "<td>" . _n('Ticket', 'Tickets', 2) . "</td><td>";
     $options = array(0 => _x('button', 'Delete permanently'), 1 => __('Disconnect'), 2 => __('Keep'));
     $params['value'] = $this->fields['keep_ticket'];
     Dropdown::showFromArray('keep_ticket', $options, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Software of computers') . "</td><td>";
     $params['value'] = $this->fields['keep_software'];
     Dropdown::showFromArray('keep_software', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If software are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_software'];
     Dropdown::showFromArray('clean_software', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Reservation', 'Reservations', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_reservation'];
     Dropdown::showFromArray('keep_reservation', $keep, $params);
     echo "</td>";
     echo "<td>" . __('Components of computers') . "</td><td>";
     $params['value'] = $this->fields['keep_device'];
     Dropdown::showFromArray('keep_device', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Links between printers and cartridge types and cartridges');
     echo "</td><td>";
     $params['value'] = $this->fields['keep_cartridgeitem'];
     Dropdown::showFromArray('keep_cartridgeitem', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If the cartridge types are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_cartridgeitem'];
     Dropdown::showFromArray('clean_cartridgeitem', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Links between cartridge types and cartridges') . "</td><td>";
     $params['value'] = $this->fields['keep_cartridge'];
     Dropdown::showFromArray('keep_cartridge', $keep, $params);
     echo "</td>";
     echo "<td>" . __('Financial and administrative information') . "</td><td>";
     $params['value'] = $this->fields['keep_infocom'];
     Dropdown::showFromArray('keep_infocom', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Links between consumable types and consumables') . "</td><td>";
     $params['value'] = $this->fields['keep_consumable'];
     Dropdown::showFromArray('keep_consumable', $keep, $params);
     echo "</td>";
     echo "<td>" . __('Links between computers and volumes') . "</td><td>";
     $params['value'] = $this->fields['keep_disk'];
     Dropdown::showFromArray('keep_disk', $keep, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . __('Direct connections') . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Monitor', 'Monitors', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_dc_monitor'];
     Dropdown::showFromArray('keep_dc_monitor', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If monitors are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_dc_monitor'];
     Dropdown::showFromArray('clean_dc_monitor', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Printer', 'Printers', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_dc_printer'];
     Dropdown::showFromArray('keep_dc_printer', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If printers are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_dc_printer'];
     Dropdown::showFromArray('clean_dc_printer', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Device', 'Devices', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_dc_peripheral'];
     Dropdown::showFromArray('keep_dc_peripheral', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If devices are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_dc_peripheral'];
     Dropdown::showFromArray('clean_dc_peripheral', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Phone', 'Phones', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_dc_phone'];
     Dropdown::showFromArray('keep_dc_phone', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If phones are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_dc_phone'];
     Dropdown::showFromArray('clean_dc_phone', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td colspan='4' class='center b'>" . __('Management') . "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Supplier', 'Suppliers', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_supplier'];
     Dropdown::showFromArray('keep_supplier', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If suppliers are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_supplier'];
     Dropdown::showFromArray('clean_supplier', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Links between suppliers and contacts') . "&nbsp;:</td><td>";
     $params['value'] = $this->fields['keep_contact'];
     Dropdown::showFromArray('keep_contact', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If contacts are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_contact'];
     Dropdown::showFromArray('clean_contact', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Document', 'Documents', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_document'];
     Dropdown::showFromArray('keep_document', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If documents are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_document'];
     Dropdown::showFromArray('clean_document', $clean, $params);
     echo "</td></tr>";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . _n('Contract', 'Contracts', 2) . "</td><td>";
     $params['value'] = $this->fields['keep_contract'];
     Dropdown::showFromArray('keep_contract', $keep, $params);
     echo "</td>";
     echo "<td>" . __('If contracts are no longer used') . "</td><td>";
     $params['value'] = $this->fields['clean_contract'];
     Dropdown::showFromArray('clean_contract', $clean, $params);
     echo "</td></tr>";
     if ($edit_form) {
         $this->showFormButtons($options);
         $this->addDivForTabs();
     } else {
         echo "</table></div>";
         Html::closeForm();
     }
 }
Beispiel #6
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     global $UNINSTALL_TYPES;
     switch ($ma->getAction()) {
         case 'transfert':
             Entity::dropdown();
             echo "&nbsp;" . Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
         case 'copy_reference':
             //useless ?
             echo "&nbsp;<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . _sx('button', 'Post') . "\" >";
             return true;
     }
     return "";
 }
Beispiel #7
0
    include '../inc/includes.php';
    header("Content-Type: text/html; charset=UTF-8");
    Html::header_nocache();
}
Session::checkLoginUser();
if (isset($_POST['type']) && !empty($_POST['type']) && isset($_POST['items_id']) && $_POST['items_id'] > 0) {
    $prefix = '';
    $suffix = '';
    if (isset($_POST['prefix']) && !empty($_POST['prefix'])) {
        $prefix = $_POST['prefix'] . '[';
        $suffix = ']';
    }
    switch ($_POST['type']) {
        case 'Group':
        case 'Profile':
            $params = array('value' => $_SESSION['glpiactive_entity'], 'name' => $prefix . 'entities_id' . $suffix);
            if (Session::isViewAllEntities()) {
                $params['toadd'] = array(-1 => __('No restriction'));
            }
            echo "<table class='tab_format'><tr><td>";
            _e('Entity');
            echo "</td><td>";
            Entity::dropdown($params);
            echo "</td><td>";
            _e('Child entities');
            echo "</td><td>";
            Dropdown::showYesNo($prefix . 'is_recursive' . $suffix);
            echo "</td></tr></table>";
            break;
    }
}
 /**
  * @param $authldap  AuthLDAP object
  **/
 static function showUserImportForm(AuthLDAP $authldap)
 {
     global $DB;
     //Get data related to entity (directory and ldap filter)
     $authldap->getFromDB($_SESSION['ldap_import']['authldaps_id']);
     echo "<div class='center'>";
     echo "<form method='post' action='" . $_SERVER['PHP_SELF'] . "'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4' class='middle'><div class='relative'>";
     echo "<span>" . ($_SESSION['ldap_import']['mode'] ? __('Synchronizing already imported users') : __('Import new users'));
     // Expert interface allow user to override configuration.
     // If not coming from the ticket form, then give expert/simple link
     if ((Config::canUpdate() || Entity::canUpdate()) && !isset($_SESSION['ldap_import']['no_expert_mode'])) {
         echo "</span>&nbsp;<span class='floatright'><a href='" . $_SERVER['PHP_SELF'] . "?action=" . $_SESSION['ldap_import']['action'] . "&amp;mode=" . $_SESSION['ldap_import']['mode'];
         if ($_SESSION['ldap_import']['interface'] == self::SIMPLE_INTERFACE) {
             echo "&amp;interface=" . self::EXPERT_INTERFACE . "'>" . __('Expert mode') . "</a>";
         } else {
             echo "&amp;interface=" . self::SIMPLE_INTERFACE . "'>" . __('Simple mode') . "</a>";
         }
     } else {
         $_SESSION['ldap_import']['interface'] = self::SIMPLE_INTERFACE;
     }
     echo "</span></div>";
     echo "</th></tr>";
     switch ($_SESSION['ldap_import']['interface']) {
         case self::EXPERT_INTERFACE:
             //If more than one directory configured
             //Display dropdown ldap servers
             if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
                 if (self::getNumberOfServers() > 1) {
                     echo "<tr class='tab_bg_2'><td>" . __('LDAP directory choice') . "</td>";
                     echo "<td colspan='3'>";
                     self::dropdown(array('name' => 'authldaps_id', 'value' => $_SESSION['ldap_import']['authldaps_id'], 'condition' => "`is_active` = '1'", 'display_emptychoice' => false));
                     echo "&nbsp;<input class='submit' type='submit' name='change_directory'\n                        value=\"" . _sx('button', 'To change') . "\">";
                     echo "</td></tr>";
                 }
                 echo "<tr class='tab_bg_2'><td>" . __('BaseDN') . "</td><td colspan='3'>";
                 echo "<input type='text' class='form-control' name='basedn' value=\"" . $_SESSION['ldap_import']['basedn'] . "\" size='90' " . (!$_SESSION['ldap_import']['basedn'] ? "disabled" : "") . ">";
                 echo "</td></tr>";
                 echo "<tr class='tab_bg_2'><td>" . __('Search filter for users') . "</td><td colspan='3'>";
                 echo "<input type='text' class='form-control' name='ldap_filter' value=\"" . $_SESSION['ldap_import']['ldap_filter'] . "\" size='90'>";
                 echo "</td></tr>";
             }
             break;
             //case self::SIMPLE_INTERFACE :
         //case self::SIMPLE_INTERFACE :
         default:
             //If multi-entity mode and more than one entity visible
             //else no need to select entity
             if (Session::isMultiEntitiesMode() && count($_SESSION['glpiactiveentities']) > 1) {
                 echo "<tr class='tab_bg_2'><td>" . __('Select the desired entity') . "</td>" . "<td colspan='3'>";
                 Entity::dropdown(array('value' => $_SESSION['ldap_import']['entities_id'], 'entity' => $_SESSION['glpiactiveentities'], 'on_change' => 'submit()'));
                 echo "</td></tr>";
             } else {
                 //Only one entity is active, store it
                 echo "<tr><td><input type='hidden' name='entities_id' value='" . $_SESSION['glpiactive_entity'] . "'></td></tr>";
             }
             if (isset($_SESSION['ldap_import']['begin_date']) && !empty($_SESSION['ldap_import']['begin_date']) || isset($_SESSION['ldap_import']['end_date']) && !empty($_SESSION['ldap_import']['end_date'])) {
                 $enabled = 1;
             } else {
                 $enabled = 0;
             }
             Dropdown::showAdvanceDateRestrictionSwitch($enabled);
             echo "<table class='tab_cadre_fixe'>";
             if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
                 $field_counter = 0;
                 $fields = array('login_field' => __('Login'), 'email1_field' => __('Email'), 'email2_field' => sprintf(__('%1$s %2$s'), _n('Email', 'Emails', 1), '2'), 'email3_field' => sprintf(__('%1$s %2$s'), _n('Email', 'Emails', 1), '3'), 'email4_field' => sprintf(__('%1$s %2$s'), _n('Email', 'Emails', 1), '4'), 'realname_field' => __('Surname'), 'firstname_field' => __('First name'), 'phone_field' => __('Phone'), 'phone2_field' => __('Phone 2'), 'mobile_field' => __('Mobile phone'), 'title_field' => _x('person', 'Title'), 'category_field' => __('Category'), 'picture_field' => __('Picture'));
                 $available_fields = array();
                 foreach ($fields as $field => $label) {
                     if (isset($authldap->fields[$field]) && $authldap->fields[$field] != '') {
                         $available_fields[$field] = $label;
                     }
                 }
                 echo "<tr><th colspan='4'>" . __('Search criteria for users') . "</th></tr>";
                 foreach ($available_fields as $field => $label) {
                     if ($field_counter == 0) {
                         echo "<tr class='tab_bg_1'>";
                     }
                     echo "<td>{$label}</td><td>";
                     $field_counter++;
                     echo "<input type='text' class='form-control' name='criterias[{$field}]' value='" . (isset($_SESSION['ldap_import']['criterias'][$field]) ? $_SESSION['ldap_import']['criterias'][$field] : '') . "'>";
                     echo "</td>";
                     if ($field_counter == 2) {
                         echo "</tr>";
                         $field_counter = 0;
                     }
                 }
                 if ($field_counter > 0) {
                     while ($field_counter < 2) {
                         echo "<td colspan='2'></td>";
                         $field_counter++;
                     }
                     $field_counter = 0;
                     echo "</tr>";
                 }
             }
             break;
     }
     if ($_SESSION['ldap_import']['authldaps_id'] != NOT_AVAILABLE && $_SESSION['ldap_import']['authldaps_id'] > 0) {
         if ($_SESSION['ldap_import']['authldaps_id']) {
             echo "<tr class='tab_bg_2'><td colspan='4' class='center'>";
             echo "<input class='submit' type='submit' name='search' value=\"" . _sx('button', 'Search') . "\">";
             echo "</td></tr>";
         } else {
             echo "<tr class='tab_bg_2'><" . "td colspan='4' class='center'>" . __('No directory selected') . "</td></tr>";
         }
     } else {
         echo "<tr class='tab_bg_2'><td colspan='4' class='center'>" . __('No directory associated to entity: impossible search') . "</td></tr>";
     }
     echo "</table>";
     Html::closeForm();
     echo "</div>";
 }
Beispiel #9
0
 /**
  * @since version 0.85
  *
  * @see CommonDBRelation::showRelationMassiveActionsSubForm()
  **/
 static function showRelationMassiveActionsSubForm(MassiveAction $ma, $peer_number)
 {
     if ($ma->getAction() == 'add' && $peer_number == 2) {
         echo "<br><br>" . sprintf(__('%1$s: %2$s'), _n('Entity', 'Entities', 1), '');
         Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities']));
         echo "<br><br>" . sprintf(__('%1$s: %2$s'), __('Recursive'), '');
         Html::showCheckbox(array('name' => 'is_recursive'));
     }
 }
Beispiel #10
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     global $UNINSTALL_TYPES;
     switch ($ma->getAction()) {
         case 'transfert':
             Entity::dropdown();
             echo "&nbsp;" . Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
     }
     return "";
 }
Beispiel #11
0
 /**
  * Show rights of a user
  *
  * @param $user User object
  **/
 static function showForUser(User $user)
 {
     global $DB, $CFG_GLPI;
     $ID = $user->getField('id');
     if (!$user->can($ID, 'r')) {
         return false;
     }
     $canedit = $user->can($ID, 'w');
     $strict_entities = self::getUserEntities($ID, false);
     if (!Session::haveAccessToOneOfEntities($strict_entities) && !Session::isViewAllEntities()) {
         $canedit = false;
     }
     $canshowentity = Session::haveRight("entity", "r");
     $rand = mt_rand();
     if ($canedit) {
         echo "<div class='firstbloc'>";
         echo "<form name='entityuser_form{$rand}' id='entityuser_form{$rand}' method='post' action='";
         echo Toolbox::getItemTypeFormURL(__CLASS__) . "'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><th colspan='6'>" . __('Add an authorization to a user') . "</tr>";
         echo "<tr class='tab_bg_2'><td class='center'>";
         echo "<input type='hidden' name='users_id' value='{$ID}'>";
         Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities']));
         echo "</td><td class='center'>" . self::getTypeName(1) . "</td><td>";
         Profile::dropdownUnder(array('value' => Profile::getDefault()));
         echo "</td><td>" . __('Recursive') . "</td><td>";
         Dropdown::showYesNo("is_recursive", 0);
         echo "</td><td class='center'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
     }
     $query = "SELECT DISTINCT `glpi_profiles_users`.`id` AS linkID,\n                       `glpi_profiles`.`id`,\n                       `glpi_profiles`.`name`,\n                       `glpi_profiles_users`.`is_recursive`,\n                       `glpi_profiles_users`.`is_dynamic`,\n                       `glpi_entities`.`completename`,\n                       `glpi_profiles_users`.`entities_id`\n                FROM `glpi_profiles_users`\n                LEFT JOIN `glpi_profiles`\n                     ON (`glpi_profiles_users`.`profiles_id` = `glpi_profiles`.`id`)\n                LEFT JOIN `glpi_entities`\n                     ON (`glpi_profiles_users`.`entities_id` = `glpi_entities`.`id`)\n                WHERE `glpi_profiles_users`.`users_id` = '{$ID}'\n                ORDER BY `glpi_profiles`.`name`, `glpi_entities`.`completename`";
     $result = $DB->query($query);
     $num = $DB->numrows($result);
     echo "<div class='spaced'>";
     Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
     if ($canedit && $num) {
         $paramsma = array('num_displayed' => $num);
         Html::showMassiveActions(__CLASS__, $paramsma);
     }
     if ($num > 0) {
         echo "<table class='tab_cadre_fixehov'>";
         echo "<tr>";
         if ($canedit) {
             echo "<th>";
             Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
             echo "</th>";
         }
         echo "<th>" . _n('Entity', 'Entities', 2) . "</th>";
         echo "<th>" . sprintf(__('%1$s (%2$s)'), self::getTypeName(2), __('D=Dynamic, R=Recursive'));
         echo "</th></tr>";
         while ($data = $DB->fetch_assoc($result)) {
             echo "<tr class='tab_bg_1'>";
             if ($canedit) {
                 echo "<td width='10'>";
                 if (in_array($data["entities_id"], $_SESSION['glpiactiveentities'])) {
                     Html::showMassiveActionCheckBox(__CLASS__, $data["linkID"]);
                 } else {
                     echo "&nbsp;";
                 }
                 echo "</td>";
             }
             echo "<td>";
             $link = $data["completename"];
             if ($_SESSION["glpiis_ids_visible"]) {
                 $link = sprintf(__('%1$s (%2$s)'), $link, $data["entities_id"]);
             }
             if ($canshowentity) {
                 echo "<a href='" . Toolbox::getItemTypeFormURL('Entity') . "?id=" . $data["entities_id"] . "'>";
             }
             echo $link . ($canshowentity ? "</a>" : '');
             echo "</td>";
             if (Session::haveRight('profile', 'r')) {
                 $entname = "<a href='" . Toolbox::getItemTypeFormURL('Profile') . "?id=" . $data["id"] . "'>" . $data["name"] . "</a>";
             } else {
                 $entname = $data["name"];
             }
             if ($data["is_dynamic"] || $data["is_recursive"]) {
                 $entname = sprintf(__('%1$s %2$s'), $entname, "<span class='b'>(");
                 if ($data["is_dynamic"]) {
                     //TRANS: letter 'D' for Dynamic
                     $entname = sprintf(__('%1$s%2$s'), $entname, __('D'));
                 }
                 if ($data["is_dynamic"] && $data["is_recursive"]) {
                     $entname = sprintf(__('%1$s%2$s'), $entname, ", ");
                 }
                 if ($data["is_recursive"]) {
                     //TRANS: letter 'R' for Recursive
                     $entname = sprintf(__('%1$s%2$s'), $entname, __('R'));
                 }
                 $entname = sprintf(__('%1$s%2$s'), $entname, ")</span>");
             }
             echo "<td>" . $entname . "</td>";
             echo "</tr>";
         }
         echo "</table>";
     } else {
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('No item found') . "</th></tr>";
         echo "</table>\n";
     }
     if ($canedit && $num) {
         $paramsma['ontop'] = false;
         Html::showMassiveActions(__CLASS__, $paramsma);
     }
     Html::closeForm();
     echo "</div>";
 }
Beispiel #12
0
/**
 * @param $options   array
*/
function plugin_ocsinventoryng_MassiveActionsDisplay($options = array())
{
    switch ($options['itemtype']) {
        case 'PluginOcsinventoryngNotimportedcomputer':
            switch ($options['action']) {
                case "plugin_ocsinventoryng_import":
                    Entity::dropdown(array('name' => 'entity'));
                    break;
                case "plugin_ocsinventoryng_link":
                    Computer::dropdown(array('name' => 'computers_id'));
                    break;
                case "plugin_ocsinventoryng_replayrules":
                case "plugin_ocsinventoryng_delete":
                    break;
            }
            echo "&nbsp;<input type='submit' name='massiveaction' class='submit' " . "value='" . _sx('button', 'Post') . "'>";
            break;
        case 'Computer':
            switch ($options['action']) {
                case "plugin_ocsinventoryng_force_ocsng_update":
                    echo "<input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Post') . "'>\n";
                    break;
                case "plugin_ocsinventoryng_unlock_ocsng_field":
                    $fields['all'] = __('All');
                    $fields += PluginOcsinventoryngOcsServer::getLockableFields();
                    Dropdown::showFromArray("field", $fields);
                    echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Post') . "'>";
                    break;
            }
    }
    return "";
}
Beispiel #13
0
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     switch ($input['action']) {
         case "duplicate":
             if ($item->isEntityAssign()) {
                 Entity::dropdown();
             }
             echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Duplicate') . "'>";
             return true;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
Beispiel #14
0
     echo "</td>";
     $display = true;
     break;
 case 'Group':
     echo "<td>";
     $params = array('rand' => $rand, 'name' => $prefix . 'groups_id' . $suffix);
     $params['toupdate'] = array('value_fieldname' => 'value', 'to_update' => "subvisibility{$rand}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/subvisibility.php", 'moreparams' => array('items_id' => '__VALUE__', 'type' => $_POST['type'], 'prefix' => $_POST['prefix']));
     Group::dropdown($params);
     echo "</td><td>";
     echo "<span id='subvisibility{$rand}'></span>";
     echo "</td>";
     $display = true;
     break;
 case 'Entity':
     echo "<td>";
     Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities'], 'value' => $_SESSION['glpiactive_entity'], 'name' => $prefix . 'entities_id' . $suffix));
     echo "</td><td>";
     _e('Child entities');
     echo "</td><td>";
     Dropdown::showYesNo($prefix . 'is_recursive' . $suffix);
     echo "</td>";
     $display = true;
     break;
 case 'Profile':
     echo "<td>";
     $checkright = READ | CREATE | UPDATE | PURGE;
     $righttocheck = $_POST['right'];
     if ($_POST['right'] == 'faq') {
         $righttocheck = 'knowbase';
         $checkright = KnowbaseItem::READFAQ;
     }
Beispiel #15
0
function plugin_appliances_MassiveActionsDisplay($options)
{
    switch ($options['itemtype']) {
        case 'PluginAppliancesAppliance':
            switch ($options['action']) {
                // No case for add_document : use GLPI core one
                case "plugin_appliances_install":
                    Dropdown::showAllItems("item_item", 0, 0, -1, PluginAppliancesAppliance::getTypes());
                    echo "<input type='submit' name='massiveaction' class='submit' " . "value='" . _x('button', 'Post') . "'>";
                    break;
                case "plugin_appliances_desinstall":
                    Dropdown::showAllItems("item_item", 0, 0, -1, PluginAppliancesAppliance::getTypes());
                    echo "<input type='submit' name='massiveaction' class='submit' " . "value='" . _x('button', 'Post') . "'>";
                    break;
                case "plugin_appliances_transfert":
                    Entity::dropdown();
                    echo "&nbsp;<input type='submit' name='massiveaction' class='submit' " . "value='" . _x('button', 'Post') . "'>";
                    break;
            }
            break;
        default:
            if (in_array($options['itemtype'], PluginAppliancesAppliance::getTypes(true))) {
                Dropdown::show('PluginAppliancesAppliance');
                echo "<input type='submit' name='massiveaction' class='submit\\' " . "value='" . _x('button', 'Post') . "'>";
            }
    }
    return "";
}
Beispiel #16
0
function plugin_connections_MassiveActionsDisplay($options = array())
{
    $PluginConnectionsConnection = new PluginConnectionsConnection();
    switch ($options['itemtype']) {
        case 'PluginConnectionsConnection':
            switch ($options['action']) {
                // No case for add_document : use GLPI core one
                case "plugin_connections_install":
                    Dropdown::showAllItems("item_item", 0, 0, -1, PluginConnectionsConnection_Item::getClasses(true));
                    echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >";
                    break;
                case "plugin_connections_desinstall":
                    Dropdown::showAllItems("item_item", 0, 0, -1, PluginConnectionsConnection_Item::getClasses(true));
                    echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >";
                    break;
                case "plugin_connections_transfert":
                    Entity::dropdown();
                    echo "&nbsp;<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >";
                    break;
            }
            break;
    }
    if (in_array($options['itemtype'], PluginConnectionsConnection_Item::getClasses(true))) {
        $PluginConnectionsConnection->dropdownConnections("plugin_connections_connections_id");
        echo "<input type=\"submit\" name=\"massiveaction\" class=\"submit\" value=\"" . __('Post') . "\" >";
    }
    return "";
}
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  * @param MassiveAction $ma
  * @return bool|false
  */
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     switch ($ma->getAction()) {
         case 'plugin_ocsinventoryng_import':
             Entity::dropdown(array('name' => 'entity'));
             echo "&nbsp;" . Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
             /*case 'plugin_ocsinventoryng_link':
               Computer::dropdown(array('name' => 'computers_id'));
               echo "&nbsp;".
                    Html::submit(_x('button','Post'), array('name' => 'massiveaction'));
               return true;*/
         /*case 'plugin_ocsinventoryng_link':
           Computer::dropdown(array('name' => 'computers_id'));
           echo "&nbsp;".
                Html::submit(_x('button','Post'), array('name' => 'massiveaction'));
           return true;*/
         case 'plugin_ocsinventoryng_replayrules':
         case 'plugin_ocsinventoryng_delete':
             echo "&nbsp;" . Html::submit(_x('button', 'Post'), array('name' => 'massiveaction'));
             return true;
     }
     return parent::showMassiveActionsSubForm($ma);
 }
Beispiel #18
0
if (isset($_POST['is_private'])) {
    Session::checkLoginUser();
    switch ($_POST['is_private']) {
        case true:
            echo "<input type='hidden' name='is_private' value='1'>\n";
            echo "<input type='hidden' name='entities_id' value='-1'>\n";
            echo "<input type='hidden' name='is_recursive' value='0'>\n";
            $private = __('Personal');
            $link = "<a onClick='setPublic" . $_POST['rand'] . "()'>" . __('Set public') . "</a>";
            printf(__('%1$s - %2$s'), $private, $link);
            break;
        case false:
            if (isset($_POST['entities_id']) && in_array($_POST['entities_id'], $_SESSION['glpiactiveentities'])) {
                $val = $_POST['entities_id'];
            } else {
                $val = $_SESSION['glpiactive_entity'];
            }
            echo "<table width='100%'>";
            echo "<tr><td>";
            echo "<input type='hidden' name='is_private' value='0'>\n";
            _e('Public');
            echo "</td><td>";
            Entity::dropdown(array('value' => $val));
            echo "</td><td>" . __('Child entities') . "</td><td>";
            Dropdown::showYesNo('is_recursive', $_POST["is_recursive"]);
            echo "</td><td>";
            echo "<a onClick='setPrivate" . $_POST['rand'] . "()'>" . __('Set personal') . "</a>";
            echo "</td></tr></table>";
            break;
    }
}
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     switch ($ma->getAction()) {
         case 'duplicate':
             Entity::dropdown();
             echo "<br><br>";
             echo Html::submit(_x('button', 'Duplicate'), array('name' => 'massiveaction')) . "</span>";
             return true;
     }
     return parent::showMassiveActionsSubForm($ma);
 }
Beispiel #20
0
 $display = false;
 $rand = mt_rand();
 switch ($_POST['type']) {
     case 'User':
         User::dropdown(array('right' => $_POST['right']));
         $display = true;
         break;
     case 'Group':
         $params = array('rand' => $rand);
         $params['toupdate'] = array('value_fieldname' => 'value', 'to_update' => "subvisibility{$rand}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/subvisibility.php", 'moreparams' => array('items_id' => '__VALUE__', 'type' => $_POST['type']));
         Group::dropdown($params);
         echo "<span id='subvisibility{$rand}'></span>";
         $display = true;
         break;
     case 'Entity':
         Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities'], 'value' => $_SESSION['glpiactive_entity']));
         _e('Child entities');
         echo "&nbsp;";
         Dropdown::showYesNo('is_recursive');
         $display = true;
         break;
     case 'Profile':
         $params = array('rand' => $rand, 'condition' => "`" . $_POST['right'] . "` IN ('r','w')");
         $params['toupdate'] = array('value_fieldname' => 'value', 'to_update' => "subvisibility{$rand}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/subvisibility.php", 'moreparams' => array('items_id' => '__VALUE__', 'type' => $_POST['type']));
         Profile::dropdown($params);
         echo "<span id='subvisibility{$rand}'></span>";
         $display = true;
         break;
 }
 if ($display) {
     echo "&nbsp;<input type='submit' name='addvisibility' value=\"" . _sx('button', 'Add') . "\"\n                   class='submit'>";
Beispiel #21
0
 /**
  * Print the user preference form
  *
  * @param $target          form target
  * @param $ID     integer  Id of the user
  *
  * @return boolean : user found
  **/
 function showMyForm($target, $ID)
 {
     global $CFG_GLPI, $PLUGIN_HOOKS;
     // Affiche un formulaire User
     if ($ID != Session::getLoginUserID() && !$this->currentUserHaveMoreRightThan($ID)) {
         return false;
     }
     if ($this->getFromDB($ID)) {
         $rand = mt_rand();
         $authtype = $this->getAuthMethodsByID();
         $extauth = !($this->fields["authtype"] == Auth::DB_GLPI || $this->fields["authtype"] == Auth::NOT_YET_AUTHENTIFIED && !empty($this->fields["password"]));
         // No autocopletion :
         $save_autocompletion = $CFG_GLPI["use_ajax_autocompletion"];
         $CFG_GLPI["use_ajax_autocompletion"] = false;
         echo "<div class='center'>";
         echo "<form method='post' name='user_manager' enctype='multipart/form-data' action='" . $target . "' autocomplete='off'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='4'>" . sprintf(__('%1$s: %2$s'), __('Login'), $this->fields["name"]);
         echo "<input type='hidden' name='name' value='" . $this->fields["name"] . "'>";
         echo "<input type='hidden' name='id' value='" . $this->fields["id"] . "'>";
         echo "</th></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Surname') . "</td><td>";
         if ($extauth && isset($authtype['realname_field']) && !empty($authtype['realname_field'])) {
             echo $this->fields["realname"];
         } else {
             Html::autocompletionTextField($this, "realname");
         }
         echo "</td>";
         if (!empty($this->fields["name"])) {
             echo "<td rowspan='3'>" . __('Picture') . "</td>";
             echo "<td rowspan='3'>";
             echo "<div class='user_picture_border_small' id='picture{$rand}'>";
             echo "<img class='user_picture_small' alt=\"" . __s('Picture') . "\" src='" . User::getThumbnailURLForPicture($this->fields['picture']) . "'>";
             echo "</div>";
             $full_picture = "<div class='user_picture_border'>";
             $full_picture .= "<img class='user_picture' alt=\"" . __s('Picture') . "\" src='" . User::getURLForPicture($this->fields['picture']) . "'>";
             $full_picture .= "</div>";
             Html::showTooltip($full_picture, array('applyto' => "picture{$rand}"));
             echo "<input type='file' name='picture' accept='image/*'>";
             echo "&nbsp;";
             Html::showCheckbox(array('name' => '_blank_picture', 'title' => __('Clear')));
             echo "&nbsp;" . __('Clear');
             echo "</td>";
             echo "</tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('First name') . "</td><td>";
         if ($extauth && isset($authtype['firstname_field']) && !empty($authtype['firstname_field'])) {
             echo $this->fields["firstname"];
         } else {
             Html::autocompletionTextField($this, "firstname");
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'>";
         if (!GLPI_DEMO_MODE) {
             echo "<td>" . __('Language') . "</td><td>";
             // Use session variable because field in table may be null if same of the global config
             Dropdown::showLanguages("language", array('value' => $_SESSION["glpilanguage"]));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
         //do some rights verification
         if (!$extauth && Session::haveRight("password_update", "1")) {
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Password') . "</td>";
             echo "<td><input id='password' type='password' name='password' value='' size='30' autocomplete='off' onkeyup=\"return passwordCheck();\">";
             echo "</td>";
             echo "<td rowspan='2'>" . __('Password security policy') . "</td>";
             echo "<td rowspan='2'>";
             Config::displayPasswordSecurityChecks();
             echo "</td>";
             echo "</tr>";
             echo "<tr class='tab_bg_1'>";
             echo "<td>" . __('Password confirmation') . "</td>";
             echo "<td><input type='password' name='password2' value='' size='30' autocomplete='off'>";
             echo "</td></tr>";
         }
         echo "<tr class='tab_bg_1'><td>" . __('Phone') . "</td><td>";
         if ($extauth && isset($authtype['phone_field']) && !empty($authtype['phone_field'])) {
             echo $this->fields["phone"];
         } else {
             Html::autocompletionTextField($this, "phone");
         }
         echo "</td>";
         echo "<td class='top'>" . _n('Email', 'Emails', Session::getPluralNumber());
         UserEmail::showAddEmailButton($this);
         echo "</td><td>";
         UserEmail::showForUser($this);
         echo "</td>";
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Mobile phone') . "&nbsp;</td><td>";
         if ($extauth && isset($authtype['mobile_field']) && !empty($authtype['mobile_field'])) {
             echo $this->fields["mobile"];
         } else {
             Html::autocompletionTextField($this, "mobile");
         }
         echo "</td>";
         if (count($_SESSION['glpiprofiles']) > 1) {
             echo "<td>" . __('Default profile') . "</td><td>";
             $options = Dropdown::getDropdownArrayNames('glpi_profiles', Profile_User::getUserProfiles($this->fields['id']));
             Dropdown::showFromArray("profiles_id", $options, array('value' => $this->fields["profiles_id"], 'display_emptychoice' => true));
             echo "</td>";
         } else {
             echo "<td colspan='2'>&nbsp;</td>";
         }
         echo "</tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Phone 2') . "</td><td>";
         if ($extauth && isset($authtype['phone2_field']) && !empty($authtype['phone2_field'])) {
             echo $this->fields["phone2"];
         } else {
             Html::autocompletionTextField($this, "phone2");
         }
         echo "</td>";
         $entities = Profile_User::getUserEntities($this->fields['id'], 1);
         if (!GLPI_DEMO_MODE && count($_SESSION['glpiactiveentities']) > 1) {
             echo "<td>" . __('Default entity') . "</td><td>";
             Entity::dropdown(array('value' => $this->fields['entities_id'], 'entity' => $entities));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Administrative number') . "</td><td>";
         if ($extauth && isset($authtype['registration_number_field']) && !empty($authtype['registration_number_field'])) {
             echo $this->fields["registration_number"];
         } else {
             Html::autocompletionTextField($this, "registration_number");
         }
         echo "</td><td colspan='2'></td></tr>";
         echo "<tr class='tab_bg_1'><td>" . __('Location') . "</td><td>";
         $entities = Profile_User::getUserEntities($ID, true);
         Location::dropdown(array('value' => $this->fields['locations_id'], 'entity' => $entities));
         if (Config::canUpdate()) {
             echo "<td>" . __('Use GLPI in mode') . "</td><td>";
             $modes[Session::NORMAL_MODE] = __('Normal');
             //$modes[Session::TRANSLATION_MODE] = __('Translation');
             $modes[Session::DEBUG_MODE] = __('Debug');
             Dropdown::showFromArray('use_mode', $modes, array('value' => $this->fields["use_mode"]));
         } else {
             echo "<td colspan='2'>&nbsp;";
         }
         echo "</td></tr>";
         echo "<tr><td class='tab_bg_2 center' colspan='4'>";
         echo "<input type='submit' name='update' value=\"" . _sx('button', 'Save') . "\" class='submit'>";
         echo "</td></tr>";
         echo "</table>";
         Html::closeForm();
         echo "</div>";
         $CFG_GLPI["use_ajax_autocompletion"] = $save_autocompletion;
         return true;
     }
     return false;
 }
Beispiel #22
0
 /**
  * Display a list of computers to add or to link
  *
  * @param plugin_ocsinventoryng_ocsservers_id the ID of the ocs server
  * @param advanced display detail about the computer import or not (target entity, matched rules, etc.)
  * @param check indicates if checkboxes are checked or not
  * @param start display a list of computers starting at rowX
  * @param entity a list of entities in which computers can be added or linked
  * @param tolinked false for an import, true for a link
  *
  * @return nothing
  **/
 static function showComputersToAdd($plugin_ocsinventoryng_ocsservers_id, $advanced, $check, $start, $entity = 0, $tolinked = false)
 {
     global $DB, $PluginOcsinventoryngDBocs, $CFG_GLPI;
     if (!plugin_ocsinventoryng_haveRight("ocsng", "w")) {
         return false;
     }
     $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.import.php';
     if ($tolinked) {
         $target = $CFG_GLPI['root_doc'] . '/plugins/ocsinventoryng/front/ocsng.link.php';
     }
     $cfg_ocs = self::getConfig($plugin_ocsinventoryng_ocsservers_id);
     $WHERE = self::getTagLimit($cfg_ocs);
     $query_ocs = "SELECT `hardware`.*,\n                           `accountinfo`.`TAG` AS TAG,\n                           `bios`.`SSN` AS SERIAL,\n                           `bios`.`SMODEL`,\n                           `bios`.`SMANUFACTURER`\n                    FROM `hardware`\n                    INNER JOIN `accountinfo` ON (`hardware`.`id` = `accountinfo`.`HARDWARE_ID`)\n                    INNER JOIN `bios` ON (`hardware`.`id` = `bios`.`HARDWARE_ID`)" . (!empty($WHERE) ? "WHERE {$WHERE}" : "") . "\n                    ORDER BY `hardware`.`NAME`";
     $result_ocs = $PluginOcsinventoryngDBocs->query($query_ocs);
     // Existing OCS - GLPI link
     $query_glpi = "SELECT*\n                     FROM `glpi_plugin_ocsinventoryng_ocslinks`\n                     WHERE `plugin_ocsinventoryng_ocsservers_id`\n                              = '{$plugin_ocsinventoryng_ocsservers_id}'";
     $result_glpi = $DB->query($query_glpi);
     if ($PluginOcsinventoryngDBocs->numrows($result_ocs) > 0) {
         // Get all hardware from OCS DB
         $hardware = array();
         while ($data = $PluginOcsinventoryngDBocs->fetch_array($result_ocs)) {
             $data = Toolbox::clean_cross_side_scripting_deep(Toolbox::addslashes_deep($data));
             $hardware[$data["ID"]]["date"] = $data["LASTDATE"];
             $hardware[$data["ID"]]["name"] = $data["NAME"];
             $hardware[$data["ID"]]["TAG"] = $data["TAG"];
             $hardware[$data["ID"]]["id"] = $data["ID"];
             $hardware[$data["ID"]]["serial"] = $data["SERIAL"];
             $hardware[$data["ID"]]["model"] = $data["SMODEL"];
             $hardware[$data["ID"]]["manufacturer"] = $data["SMANUFACTURER"];
             $query_network = "SELECT*\n                              FROM `networks`\n                              WHERE `HARDWARE_ID` = '" . $data["ID"] . "'";
             //Get network informations for this computer
             //Ignore informations that contains "??"
             foreach ($PluginOcsinventoryngDBocs->request($query_network) as $network) {
                 if (isset($network['IPADDRESS']) && $network['IPADDRESS'] != '??') {
                     $hardware[$data["ID"]]['IPADDRESS'][] = $network['IPADDRESS'];
                 }
                 if (isset($network['IPSUBNET']) && $network['IPSUBNET'] != '??') {
                     $hardware[$data["ID"]]['IPSUBNET'][] = $network['IPSUBNET'];
                 }
                 if (isset($network['MACADDRESS']) && $network['MACADDR'] != '??') {
                     $hardware[$data["ID"]]['MACADDRESS'][] = $network['MACADDR'];
                 }
             }
         }
         // Get all links between glpi and OCS
         $already_linked = array();
         if ($DB->numrows($result_glpi) > 0) {
             while ($data = $PluginOcsinventoryngDBocs->fetch_array($result_glpi)) {
                 $already_linked[$data["ocsid"]] = $data["last_update"];
             }
         }
         // Clean $hardware from already linked element
         if (count($already_linked) > 0) {
             foreach ($already_linked as $ID => $date) {
                 if (isset($hardware[$ID]) && isset($already_linked[$ID])) {
                     unset($hardware[$ID]);
                 }
             }
         }
         if ($tolinked && count($hardware)) {
             echo "<div class='center b'>" . __('Caution! The imported data (see your configuration) will overwrite the existing one', 'ocsinventoryng') . "</div>";
         }
         echo "<div class='center'>";
         if (($numrows = count($hardware)) > 0) {
             $parameters = "check={$check}";
             Html::printPager($start, $numrows, $target, $parameters);
             // delete end
             array_splice($hardware, $start + $_SESSION['glpilist_limit']);
             // delete begin
             if ($start > 0) {
                 array_splice($hardware, 0, $start);
             }
             //Show preview form only in import even in multi-entity mode because computer import
             //can be refused by a rule
             if (!$tolinked) {
                 echo "<div class='firstbloc'>";
                 echo "<form method='post' name='ocsng_import_mode' id='ocsng_import_mode'\n                      action='{$target}'>\n";
                 echo "<table class='tab_cadre_fixe'>";
                 echo "<tr><th>" . __('Manual import mode', 'ocsinventoryng') . "</th></tr>\n";
                 echo "<tr class='tab_bg_1'><td class='center'>";
                 if ($advanced) {
                     Html::showSimpleForm($target, 'change_import_mode', __('Disable preview', 'ocsinventoryng'), array('id' => 'false'));
                 } else {
                     Html::showSimpleForm($target, 'change_import_mode', __('Enable preview', 'ocsinventoryng'), array('id' => 'true'));
                 }
                 echo "</td></tr>";
                 echo "<tr class='tab_bg_1'><td class='center b'>" . __('Check first that duplicates have been correctly managed in OCSNG', 'ocsinventoryng') . "</td>";
                 echo "</tr></table>";
                 Html::closeForm();
                 echo "</div>";
             }
             echo "<form method='post' name='ocsng_form' id='ocsng_form' action='{$target}'>";
             if (!$tolinked) {
                 self::checkBox($target);
             }
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
             echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">";
             echo "</td></tr>\n";
             echo "<tr><th>" . __('Name') . "</th>\n";
             echo "<th>" . __('Manufacturer') . "</th>\n";
             echo "<th>" . __('Model') . "</th>\n";
             echo "<th>" . __('Serial number') . "</th>\n";
             echo "<th>" . __('Date') . "</th>\n";
             echo "<th>" . __('OCSNG TAG', 'ocsinventoryng') . "</th>\n";
             if ($advanced && !$tolinked) {
                 echo "<th>" . __('Match the rule ?', 'ocsinventoryng') . "</th>\n";
                 echo "<th>" . __('Destination entity') . "</th>\n";
                 echo "<th>" . __('Target location', 'ocsinventoryng') . "</th>\n";
             }
             echo "<th>&nbsp;</th></tr>\n";
             $rule = new RuleImportEntityCollection();
             foreach ($hardware as $ID => $tab) {
                 $comp = new Computer();
                 $comp->fields["id"] = $tab["id"];
                 $data = array();
                 if ($advanced && !$tolinked) {
                     $data = $rule->processAllRules(array('ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id, '_source' => 'ocsinventoryng'), array(), array('ocsid' => $tab["id"]));
                 }
                 echo "<tr class='tab_bg_2'><td>" . $tab["name"] . "</td>\n";
                 echo "<td>" . $tab["manufacturer"] . "</td><td>" . $tab["model"] . "</td>";
                 echo "<td>" . $tab["serial"] . "</td>\n";
                 echo "<td>" . Html::convDateTime($tab["date"]) . "</td>\n";
                 echo "<td>" . $tab["TAG"] . "</td>\n";
                 if ($advanced && !$tolinked) {
                     if (!isset($data['entities_id']) || $data['entities_id'] == -1) {
                         echo "<td class='center'><img src=\"" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png\"></td>\n";
                         $data['entities_id'] = -1;
                     } else {
                         echo "<td class='center'>";
                         $tmprule = new RuleImportEntity();
                         if ($tmprule->can($data['_ruleid'], 'r')) {
                             echo "<a href='" . $tmprule->getLinkURL() . "'>" . $tmprule->getName() . "</a>";
                         } else {
                             echo $tmprule->getName();
                         }
                         echo "</td>\n";
                     }
                     echo "<td>";
                     Entity::dropdown(array('name' => "toimport_entities[" . $tab["id"] . "]=" . $data['entities_id'], 'value' => $data['entities_id'], 'comments' => 0));
                     echo "</td>\n";
                     echo "<td>";
                     if (!isset($data['locations_id'])) {
                         $data['locations_id'] = 0;
                     }
                     Location::dropdown(array('name' => "toimport_locations[" . $tab["id"] . "]=" . $data['locations_id'], 'value' => $data['locations_id'], 'comments' => 0));
                     echo "</td>\n";
                 }
                 echo "<td>";
                 if (!$tolinked) {
                     echo "<input type='checkbox' name='toimport[" . $tab["id"] . "]' " . ($check == "all" ? "checked" : "") . ">";
                 } else {
                     $rulelink = new RuleImportComputerCollection();
                     $rulelink_results = array();
                     $params = array('entities_id' => $entity, 'plugin_ocsinventoryng_ocsservers_id' => $plugin_ocsinventoryng_ocsservers_id);
                     $rulelink_results = $rulelink->processAllRules(Toolbox::stripslashes_deep($tab), array(), $params);
                     //Look for the computer using automatic link criterias as defined in OCSNG configuration
                     $options = array('name' => "tolink[" . $tab["id"] . "]");
                     $show_dropdown = true;
                     //If the computer is not explicitly refused by a rule
                     if (!isset($rulelink_results['action']) || $rulelink_results['action'] != self::LINK_RESULT_NO_IMPORT) {
                         if (!empty($rulelink_results['found_computers'])) {
                             $options['value'] = $rulelink_results['found_computers'][0];
                             $options['entity'] = $entity;
                         }
                         Computer::dropdown($options);
                     } else {
                         echo "<img src='" . $CFG_GLPI['root_doc'] . "/pics/redbutton.png'>";
                     }
                 }
                 echo "</td></tr>\n";
             }
             echo "<tr class='tab_bg_1'><td colspan='" . ($advanced || $tolinked ? 10 : 7) . "' class='center'>";
             echo "<input class='submit' type='submit' name='import_ok' value=\"" . _sx('button', 'Import', 'ocsinventoryng') . "\">\n";
             echo "<input type=hidden name='plugin_ocsinventoryng_ocsservers_id' " . "value='{$plugin_ocsinventoryng_ocsservers_id}'>";
             echo "</td></tr>";
             echo "</table>\n";
             Html::closeForm();
             if (!$tolinked) {
                 self::checkBox($target);
             }
             Html::printPager($start, $numrows, $target, $parameters);
         } else {
             echo "<table class='tab_cadre_fixe'>";
             echo "<tr><th>" . __('Import new computers') . "</th></tr>\n";
             echo "<tr class='tab_bg_1'>";
             echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
             echo "</table>";
         }
         echo "</div>";
     } else {
         echo "<div class='center'>";
         echo "<table class='tab_cadre_fixe'>";
         echo "<tr><th>" . __('Import new computers', 'ocsinventoryng') . "</th></tr>\n";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center b'>" . __('No new computer to be imported', 'ocsinventoryng') . "</td></tr>\n";
         echo "</table></div>";
     }
 }
 /**
  * show actor part in ITIL object form
  *
  * @param $ID        integer  ITIL object ID
  * @param $options   array    options for default values ($options of showForm)
  *
  * @return nothing display
  **/
 function showActorsPartForm($ID, array $options)
 {
     global $CFG_GLPI;
     $showuserlink = 0;
     if (User::canView()) {
         $showuserlink = 1;
     }
     $options['_default_use_notification'] = 1;
     if (isset($options['entities_id'])) {
         $options['_default_use_notification'] = Entity::getUsedConfig('is_notif_enable_default', $options['entities_id'], '', 1);
     }
     // check is_hidden fields
     foreach (array('_users_id_requester', '_groups_id_requester', '_users_id_observer', '_groups_id_observer', '_users_id_assign', '_groups_id_assign', '_suppliers_id_assign') as $f) {
         $is_hidden[$f] = false;
         if (isset($options['_tickettemplate']) && $options['_tickettemplate']->isHiddenField($f)) {
             $is_hidden[$f] = true;
         }
     }
     $can_admin = $this->canAdminActors();
     $can_assign = $this->canAssign();
     $can_assigntome = $this->canAssignToMe();
     if (isset($options['_noupdate']) && !$options['_noupdate']) {
         $can_admin = false;
         $can_assign = false;
         $can_assigntome = false;
     }
     // Manage actors : requester and assign
     echo "<table class='tab_cadre_fixe' id='mainformtable5'>";
     echo "<tr class='tab_bg_1'>";
     echo "<th rowspan='2' width='13%'>" . __('Actor') . "</th>";
     echo "<th width='29%'>";
     if (!$is_hidden['_users_id_requester'] || !$is_hidden['_groups_id_requester']) {
         _e('Requester');
     }
     $rand_requester = -1;
     $candeleterequester = false;
     if ($ID && $can_admin && (!$is_hidden['_users_id_requester'] || !$is_hidden['_groups_id_requester'])) {
         $rand_requester = mt_rand();
         echo "&nbsp;&nbsp;";
         echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                onClick=\"" . Html::jsShow("itilactor{$rand_requester}") . "\"\n                class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         $candeleterequester = true;
     }
     echo "</th>";
     echo "<th width='29%'>";
     if (!$is_hidden['_users_id_observer'] || !$is_hidden['_groups_id_observer']) {
         _e('Watcher');
     }
     $rand_observer = -1;
     $candeleteobserver = false;
     if ($ID && $can_admin && (!$is_hidden['_users_id_observer'] || !$is_hidden['_groups_id_observer'])) {
         $rand_observer = mt_rand();
         echo "&nbsp;&nbsp;";
         echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                onClick=\"" . Html::jsShow("itilactor{$rand_observer}") . "\"\n                class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
         $candeleteobserver = true;
     } else {
         if ($ID > 0 && !in_array($this->fields['status'], $this->getClosedStatusArray()) && !$is_hidden['_users_id_observer'] && !$this->isUser(CommonITILActor::OBSERVER, Session::getLoginUserID()) && !$this->isUser(CommonITILActor::REQUESTER, Session::getLoginUserID())) {
             echo "&nbsp;&nbsp;&nbsp;&nbsp;";
             Html::showSimpleForm($this->getFormURL(), 'addme_observer', __('Associate myself'), array($this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/addme.png");
         }
     }
     echo "</th>";
     echo "<th width='29%'>";
     if (!$is_hidden['_users_id_assign'] || !$is_hidden['_groups_id_assign'] || !$is_hidden['_suppliers_id_assign']) {
         _e('Assigned to');
     }
     $rand_assign = -1;
     $candeleteassign = false;
     if ($ID && ($can_assign || $can_assigntome) && (!$is_hidden['_users_id_assign'] || !$is_hidden['_groups_id_assign'] || !$is_hidden['_suppliers_id_assign']) && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
         $rand_assign = mt_rand();
         echo "&nbsp;&nbsp;";
         echo "<img title=\"" . __s('Add') . "\" alt=\"" . __s('Add') . "\"\n                onClick=\"" . Html::jsShow("itilactor{$rand_assign}") . "\"\n                class='pointer' src='" . $CFG_GLPI["root_doc"] . "/pics/add_dropdown.png'>";
     }
     if ($ID && $can_assigntome && !in_array($this->fields['status'], $this->getClosedStatusArray()) && !$is_hidden['_users_id_assign'] && !$this->isUser(CommonITILActor::ASSIGN, Session::getLoginUserID()) && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
         Html::showSimpleForm($this->getFormURL(), 'addme_assign', __('Associate myself'), array($this->getForeignKeyField() => $this->fields['id']), $CFG_GLPI["root_doc"] . "/pics/addme.png");
     }
     if ($ID && $can_assign) {
         $candeleteassign = true;
     }
     echo "</th></tr>";
     echo "<tr class='tab_bg_1 top'>";
     echo "<td>";
     if ($rand_requester >= 0) {
         $this->showActorAddForm(CommonITILActor::REQUESTER, $rand_requester, $this->fields['entities_id'], $is_hidden);
     }
     // Requester
     if (!$ID) {
         $reqdisplay = false;
         if ($can_admin && !$is_hidden['_users_id_requester']) {
             $this->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $options);
             $reqdisplay = true;
         } else {
             $delegating = User::getDelegateGroupsForUser($options['entities_id']);
             if (count($delegating) && !$is_hidden['_users_id_requester']) {
                 //$this->getDefaultActor(CommonITILActor::REQUESTER);
                 $options['_right'] = "delegate";
                 $this->showActorAddFormOnCreate(CommonITILActor::REQUESTER, $options);
                 $reqdisplay = true;
             } else {
                 // predefined value
                 if (isset($options["_users_id_requester"]) && $options["_users_id_requester"]) {
                     echo self::getActorIcon('user', CommonITILActor::REQUESTER) . "&nbsp;";
                     echo Dropdown::getDropdownName("glpi_users", $options["_users_id_requester"]);
                     echo "<input type='hidden' name='_users_id_requester' value=\"" . $options["_users_id_requester"] . "\">";
                     echo '<br>';
                     $reqdisplay = true;
                 }
             }
         }
         //If user have access to more than one entity, then display a combobox : Ticket case
         if ($this->userentity_oncreate && isset($this->countentitiesforuser) && $this->countentitiesforuser > 1) {
             echo "<br>";
             $rand = Entity::dropdown(array('value' => $this->fields["entities_id"], 'entity' => $this->userentities, 'on_change' => 'this.form.submit()'));
         } else {
             echo "<input type='hidden' name='entities_id' value='" . $this->fields["entities_id"] . "'>";
         }
         if ($reqdisplay) {
             echo '<hr>';
         }
     } else {
         if (!$is_hidden['_users_id_requester']) {
             $this->showUsersAssociated(CommonITILActor::REQUESTER, $candeleterequester, $options);
         }
     }
     // Requester Group
     if (!$ID) {
         if ($can_admin && !$is_hidden['_groups_id_requester']) {
             echo self::getActorIcon('group', CommonITILActor::REQUESTER);
             /// For ticket templates : mandatories
             if (isset($options['_tickettemplate'])) {
                 echo $options['_tickettemplate']->getMandatoryMark('_groups_id_requester');
             }
             echo "&nbsp;";
             Group::dropdown(array('name' => '_groups_id_requester', 'value' => $options["_groups_id_requester"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_requester`'));
         } else {
             // predefined value
             if (isset($options["_groups_id_requester"]) && $options["_groups_id_requester"]) {
                 echo self::getActorIcon('group', CommonITILActor::REQUESTER) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_requester"]);
                 echo "<input type='hidden' name='_groups_id_requester' value=\"" . $options["_groups_id_requester"] . "\">";
                 echo '<br>';
             }
         }
     } else {
         if (!$is_hidden['_groups_id_requester']) {
             $this->showGroupsAssociated(CommonITILActor::REQUESTER, $candeleterequester, $options);
         }
     }
     echo "</td>";
     echo "<td>";
     if ($rand_observer >= 0) {
         $this->showActorAddForm(CommonITILActor::OBSERVER, $rand_observer, $this->fields['entities_id'], $is_hidden);
     }
     // Observer
     if (!$ID) {
         if ($can_admin && !$is_hidden['_users_id_observer']) {
             $this->showActorAddFormOnCreate(CommonITILActor::OBSERVER, $options);
             echo '<hr>';
         } else {
             // predefined value
             if (isset($options["_users_id_observer"]) && $options["_users_id_observer"]) {
                 echo self::getActorIcon('user', CommonITILActor::OBSERVER) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_users", $options["_users_id_observer"]);
                 echo "<input type='hidden' name='_users_id_observer' value=\"" . $options["_users_id_observer"] . "\">";
                 echo '<hr>';
             }
         }
     } else {
         if (!$is_hidden['_users_id_observer']) {
             $this->showUsersAssociated(CommonITILActor::OBSERVER, $candeleteobserver, $options);
         }
     }
     // Observer Group
     if (!$ID) {
         if ($can_admin && !$is_hidden['_groups_id_observer']) {
             echo self::getActorIcon('group', CommonITILActor::OBSERVER);
             /// For ticket templates : mandatories
             if (isset($options['_tickettemplate'])) {
                 echo $options['_tickettemplate']->getMandatoryMark('_groups_id_observer');
             }
             echo "&nbsp;";
             Group::dropdown(array('name' => '_groups_id_observer', 'value' => $options["_groups_id_observer"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_requester`'));
         } else {
             // predefined value
             if (isset($options["_groups_id_observer"]) && $options["_groups_id_observer"]) {
                 echo self::getActorIcon('group', CommonITILActor::OBSERVER) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_observer"]);
                 echo "<input type='hidden' name='_groups_id_observer' value=\"" . $options["_groups_id_observer"] . "\">";
                 echo '<br>';
             }
         }
     } else {
         if (!$is_hidden['_groups_id_observer']) {
             $this->showGroupsAssociated(CommonITILActor::OBSERVER, $candeleteobserver, $options);
         }
     }
     echo "</td>";
     echo "<td>";
     if ($rand_assign >= 0) {
         $this->showActorAddForm(CommonITILActor::ASSIGN, $rand_assign, $this->fields['entities_id'], $is_hidden, $this->canAssign(), $this->canAssign());
     }
     // Assign User
     if (!$ID) {
         if ($can_assign && !$is_hidden['_users_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
             $this->showActorAddFormOnCreate(CommonITILActor::ASSIGN, $options);
             echo '<hr>';
         } else {
             if ($can_assigntome && !$is_hidden['_users_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                 echo self::getActorIcon('user', CommonITILActor::ASSIGN) . "&nbsp;";
                 User::dropdown(array('name' => '_users_id_assign', 'value' => $options["_users_id_assign"], 'entity' => $this->fields["entities_id"], 'ldap_import' => true));
                 echo '<hr>';
             } else {
                 // predefined value
                 if (isset($options["_users_id_assign"]) && $options["_users_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                     echo self::getActorIcon('user', CommonITILActor::ASSIGN) . "&nbsp;";
                     echo Dropdown::getDropdownName("glpi_users", $options["_users_id_assign"]);
                     echo "<input type='hidden' name='_users_id_assign' value=\"" . $options["_users_id_assign"] . "\">";
                     echo '<hr>';
                 }
             }
         }
     } else {
         if (!$is_hidden['_users_id_assign']) {
             $this->showUsersAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options);
         }
     }
     // Assign Groups
     if (!$ID) {
         if ($can_assign && !$is_hidden['_groups_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
             echo self::getActorIcon('group', CommonITILActor::ASSIGN);
             /// For ticket templates : mandatories
             if (isset($options['_tickettemplate'])) {
                 echo $options['_tickettemplate']->getMandatoryMark('_groups_id_assign');
             }
             echo "&nbsp;";
             $rand = mt_rand();
             $params = array('name' => '_groups_id_assign', 'value' => $options["_groups_id_assign"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_assign`', 'rand' => $rand);
             if ($this->getType() == 'Ticket') {
                 $params['toupdate'] = array('value_fieldname' => 'value', 'to_update' => "countgroupassign_{$rand}", 'url' => $CFG_GLPI["root_doc"] . "/ajax/ticketassigninformation.php", 'moreparams' => array('groups_id_assign' => '__VALUE__'));
             }
             Group::dropdown($params);
             echo "<span id='countgroupassign_{$rand}'>";
             echo "</span>";
             echo "<script type='text/javascript'>";
             Ajax::updateItemJsCode("countgroupassign_{$rand}", $CFG_GLPI["root_doc"] . "/ajax/ticketassigninformation.php", array('groups_id_assign' => '__VALUE__'), "dropdown__groups_id_assign{$rand}");
             echo "</script>";
             echo '<hr>';
         } else {
             // predefined value
             if (isset($options["_groups_id_assign"]) && $options["_groups_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                 echo self::getActorIcon('group', CommonITILActor::ASSIGN) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_groups", $options["_groups_id_assign"]);
                 echo "<input type='hidden' name='_groups_id_assign' value=\"" . $options["_groups_id_assign"] . "\">";
                 echo '<hr>';
             }
         }
     } else {
         if (!$is_hidden['_groups_id_assign']) {
             $this->showGroupsAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options);
         }
     }
     // Assign Suppliers
     if (!$ID) {
         if ($can_assign && !$is_hidden['_suppliers_id_assign'] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
             $this->showSupplierAddFormOnCreate($options);
         } else {
             // predefined value
             if (isset($options["_suppliers_id_assign"]) && $options["_suppliers_id_assign"] && $this->isAllowedStatus($this->fields['status'], CommonITILObject::ASSIGNED)) {
                 echo self::getActorIcon('supplier', CommonITILActor::ASSIGN) . "&nbsp;";
                 echo Dropdown::getDropdownName("glpi_suppliers", $options["_suppliers_id_assign"]);
                 echo "<input type='hidden' name='_suppliers_id_assign' value=\"" . $options["_suppliers_id_assign"] . "\">";
                 echo '<hr>';
             }
         }
     } else {
         if (!$is_hidden['_suppliers_id_assign']) {
             $this->showSuppliersAssociated(CommonITILActor::ASSIGN, $candeleteassign, $options);
         }
     }
     echo "</td>";
     echo "</tr>";
     echo "</table>";
 }
Beispiel #24
0
 /**
  * @since version 0.85
  *
  * @see CommonDBTM::showMassiveActionsSubForm()
  **/
 static function showMassiveActionsSubForm(MassiveAction $ma)
 {
     switch ($ma->getAction()) {
         case 'duplicate':
             $entity_assign = False;
             foreach ($ma->getitems() as $itemtype => $ids) {
                 if ($item = getItemForItemtype($itemtype)) {
                     if ($item->isEntityAssign()) {
                         $entity_assign = true;
                         break;
                     }
                 }
             }
             if ($entity_assign) {
                 Entity::dropdown();
             }
             echo "<br><br>" . Html::submit(_x('button', 'Duplicate'), array('name' => 'massiveaction'));
             return true;
         case 'move_rule':
             $input = $ma->getInput();
             $values = array('after' => __('After'), 'before' => __('Before'));
             Dropdown::showFromArray('move_type', $values, array('width' => '20%'));
             if (isset($input['entity'])) {
                 $entity = $input['entity'];
             } else {
                 $entity = "";
             }
             if (isset($input['condition'])) {
                 $condition = $input['condition'];
             } else {
                 $condition = 0;
             }
             echo Html::hidden('rule_class_name', array('value' => $input['rule_class_name']));
             Rule::dropdown(array('sub_type' => $input['rule_class_name'], 'name' => "ranking", 'condition' => $condition, 'entity' => $entity, 'width' => '50%'));
             echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Move') . "'>\n";
             return true;
     }
     return parent::showMassiveActionsSubForm($ma);
 }
Beispiel #25
0
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     global $CFG_GLPI;
     switch ($input['action']) {
         case "change_authtype":
             $rand = Auth::dropdown(array('name' => 'authtype'));
             $paramsmassaction = array('authtype' => '__VALUE__');
             Ajax::updateItemOnSelectEvent("dropdown_authtype{$rand}", "show_massiveaction_field", $CFG_GLPI["root_doc"] . "/ajax/dropdownMassiveActionAuthMethods.php", $paramsmassaction);
             echo "<span id='show_massiveaction_field'><br><br>";
             echo "<input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Post') . "'>";
             echo "</span>\n";
             return true;
         case "add_user_group":
             $gu = new Group_User();
             return $gu->showSpecificMassiveActionsParameters($input);
         case "add_userprofile":
             Entity::dropdown(array('entity' => $_SESSION['glpiactiveentities']));
             echo ".&nbsp;" . _n('Profile', 'Profiles', 1) . "&nbsp;";
             Profile::dropdownUnder();
             echo ".&nbsp;" . __('Recursive') . "&nbsp;";
             Dropdown::showYesNo("is_recursive", 0);
             echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . _sx('button', 'Add') . "'>";
             return true;
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
 /**
  * show  hardware to be identified, or identified and imported, or just the hardware with agents installed on them
  * @param type $hardware array
  * @param type $lim integer
  * @param int|type $start integer
  * @param type $ipAdress string
  * @param type $status string
  * @param $subnet
  * @param $action
  * @global type $CFG_GLPI
  */
 static function showHardware($hardware, $lim, $start = 0, $ipAdress, $status, $subnet, $action)
 {
     global $CFG_GLPI, $DB;
     $output_type = Search::HTML_OUTPUT;
     //0
     $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php";
     $return = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php";
     $returnargs = "subnetsChoice={$subnet}&action={$action}";
     $reload = "ip={$ipAdress}&status={$status}&action={$action}";
     $backValues = "?b[]={$ipAdress}&b[]={$status}";
     if ($status == "inventoried") {
         $status_name = __('Inventoried', 'ocsinventoryng');
     } elseif ($status == "imported") {
         $status_name = __('Imported / Linked', 'ocsinventoryng');
     } elseif ($status == "noninventoried") {
         $status_name = __('Non Inventoried', 'ocsinventoryng');
     } else {
         $status_name = __('Identified', 'ocsinventoryng');
     }
     $subnet_name = self::getSubnetNamebyIP($ipAdress);
     echo "<div class='center'>";
     echo "<h2>" . __('Subnet', 'ocsinventoryng') . " " . $subnet_name . " (" . $ipAdress . ") - " . $status_name;
     echo "&nbsp;";
     $refresh = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php?" . $reload;
     Html::showSimpleForm($refresh, 'refresh', _sx('button', 'Refresh'), array(), $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/pics/synchro.png");
     echo "</h2>";
     echo "</div>";
     if ($subnet >= 0) {
         $back = __('Back');
         echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>";
     }
     echo Html::printPager($start, count($hardware), $link, $reload);
     echo Search::showNewLine($output_type, true);
     if (empty($hardware)) {
         echo "<div class='center b'><br>" . __('No new IPDiscover device to import', 'ocsinventoryng') . "</div>";
         Html::displayBackLink();
     } else {
         $header_num = 1;
         switch ($status) {
             case "inventoried":
                 echo "<table width='100%'class='tab_cadrehov'>\n";
                 echo Search::showHeaderItem($output_type, __('User'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Name'), $header_num);
                 echo Search::showHeaderItem($output_type, __('System'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Version of the operating system'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Last OCSNG inventory date', 'ocsinventoryng'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         $item_num = 1;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         echo Search::showItem($output_type, $hardware[$i]["userid"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["name"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["osname"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["osversion"], $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["ipaddr"], $item_num, $row_num);
                         echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["lastdate"]), $item_num, $row_num);
                         echo Search::showEndLine($output_type);
                     }
                 }
                 echo "</table>\n";
                 break;
             case "imported":
                 $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues;
                 self::checkBox($target);
                 echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>";
                 echo "<div class='center' style=\"width=100%\">";
                 echo "<input type='submit' class='submit' name='deletelink'  value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>";
                 echo "<table width='100%'class='tab_cadrehov'>\n";
                 echo Search::showHeaderItem($output_type, __('Item'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Item type'), $header_num);
                 echo Search::showHeaderItem($output_type, __('MAC address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Location'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Import date in GLPI', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Subnet'), $header_num);
                 echo Search::showHeaderItem($output_type, __('&nbsp;'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         $item_num = 1;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         $class = getItemForItemtype($hardware[$i]["itemtype"]);
                         $class->getFromDB($hardware[$i]["items_id"]);
                         $iplist = "";
                         $ip = new IPAddress();
                         // Update IPAddress
                         foreach ($DB->request('glpi_networkports', array('itemtype' => $hardware[$i]["itemtype"], 'items_id' => $hardware[$i]["items_id"])) as $netname) {
                             foreach ($DB->request('glpi_networknames', array('itemtype' => 'NetworkPort', 'items_id' => $netname['id'])) as $dataname) {
                                 foreach ($DB->request('glpi_ipaddresses', array('itemtype' => 'NetworkName', 'items_id' => $dataname['id'])) as $data) {
                                     $ip->getFromDB($data['id']);
                                     $iplist .= $ip->getName() . "<br>";
                                 }
                             }
                         }
                         echo Search::showItem($output_type, $class->getLink(), $item_num, $row_num);
                         echo Search::showItem($output_type, $class->getTypeName(), $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["macaddress"], $item_num, $row_num);
                         echo Search::showItem($output_type, $iplist, $item_num, $row_num);
                         echo Search::showItem($output_type, Dropdown::getDropdownName("glpi_locations", $class->fields["locations_id"]), $item_num, $row_num);
                         echo Search::showItem($output_type, Html::convDateTime($hardware[$i]["last_update"]), $item_num, $row_num);
                         echo Search::showItem($output_type, $hardware[$i]["subnet"], $item_num, $row_num);
                         echo self::showItem($hardware[$i]["id"], "", "", "", true, "", $i);
                         echo Search::showEndLine($output_type);
                     }
                 }
                 echo "<tbody style=\"display:none\">";
                 echo "<tr><td><input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>";
                 echo "</tbody>";
                 echo "</table>\n";
                 echo "<div class='center' style=\"width=100%\">";
                 echo "<input type='submit' class='submit' name='deletelink'  value=\"" . _sx('button', 'Delete link', 'ocsinventoryng') . "\"></div>";
                 Html::closeForm();
                 self::checkBox($target);
                 break;
             case "noninventoried":
                 $ocsTypes = array("id" => array(Dropdown::EMPTY_VALUE), "name" => array(Dropdown::EMPTY_VALUE));
                 $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php";
                 $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues;
                 $macConstructor = "";
                 self::getOCSTypes($ocsTypes);
                 self::checkBox($target);
                 echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='IdentifyAndImport'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='IdentifyAndLink'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 echo "<table width='100%'class='tab_cadrehov'>\n";
                 echo Search::showHeaderItem($output_type, __('Date'), $header_num);
                 echo Search::showHeaderItem($output_type, __('MAC address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Subnet mask'), $header_num);
                 echo Search::showHeaderItem($output_type, __('DNS', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Description') . "<span class='red'>*</span>", $header_num);
                 echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num);
                 if ($action == "import") {
                     echo Search::showHeaderItem($output_type, __('Name'), $header_num);
                     if (Session::isMultiEntitiesMode()) {
                         echo Search::showHeaderItem($output_type, __('Entity'), $header_num);
                     }
                     echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num);
                 } else {
                     echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%');
                 }
                 echo Search::showHeaderItem($output_type, __('&nbsp;'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 $ocstypes = array();
                 foreach ($ocsTypes["name"] as $items) {
                     $ocstypes[$items] = $items;
                 }
                 $itemstypes = array(Dropdown::EMPTY_VALUE);
                 foreach (self::$hardwareItemTypes as $items) {
                     $class = getItemForItemtype($items);
                     $itemstypes[$items] = $class->getTypeName();
                 }
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         echo self::showItem(Html::convDateTime($hardware[$i]["date"]));
                         if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) {
                             $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]);
                             if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) {
                                 $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))];
                             } else {
                                 $macConstructor = __("unknow");
                             }
                         }
                         $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>";
                         echo self::showItem($mac);
                         echo self::showItem($ip = $hardware[$i]["ip"]);
                         echo self::showItem($hardware[$i]["mask"]);
                         echo self::showItem($hardware[$i]["DNS"]);
                         echo "<td><input type=\"text\" name='itemsdescription[" . $i . "]' value=\"\" ></td>";
                         echo "<td>";
                         Dropdown::showFromArray("ocsitemstype[{$i}]", $ocstypes);
                         echo "</td>";
                         if ($action == "import") {
                             echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>";
                             if (Session::isMultiEntitiesMode()) {
                                 echo "<td>";
                                 Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"]));
                                 echo "</td>";
                             }
                             echo "<td>";
                             Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes);
                             echo "</td>";
                         } else {
                             echo "<td width='10'>";
                             $mtrand = mt_rand();
                             $mynamei = "itemtype";
                             $myname = "tolink_items[" . $i . "]";
                             $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand));
                             $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname);
                             //print_r($p);
                             Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p);
                             echo "<span id='results_{$mynamei}{$rand}'>\n";
                             echo "</span>\n";
                             //}
                             echo "</td>";
                         }
                         echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i);
                         echo "<tbody style=\"display:none\">";
                         echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >\n                           <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></td></tr>";
                         echo "</tbody>";
                     }
                 }
                 echo "</table>\n";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='IdentifyAndImport'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='IdentifyAndLink'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 Html::closeForm();
                 self::checkBox($target);
                 break;
             default:
                 $link = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.php";
                 $target = $CFG_GLPI['root_doc'] . "/plugins/ocsinventoryng/front/ipdiscover.import.php" . $backValues;
                 $macConstructor = "";
                 self::checkBox($target);
                 echo "<form method='post' id='ipdiscover_form' name='ipdiscover_form' action='{$target}'>";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='Import'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='Link'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 echo "<table width='100%'class='tab_cadrehov'>";
                 echo Search::showHeaderItem($output_type, __('Date'), $header_num);
                 echo Search::showHeaderItem($output_type, __('Description'), $header_num);
                 echo Search::showHeaderItem($output_type, __('OCS Type', 'ocsinventoryng'), $header_num);
                 echo Search::showHeaderItem($output_type, __('IP address'), $header_num);
                 echo Search::showHeaderItem($output_type, __('MAC address'), $header_num);
                 if ($action == "import") {
                     if (Session::isMultiEntitiesMode()) {
                         echo Search::showHeaderItem($output_type, __('Entity'), $header_num);
                     }
                     echo Search::showHeaderItem($output_type, __('Name'), $header_num);
                     echo Search::showHeaderItem($output_type, __('GLPI Type', 'ocsinventoryng') . "<span class='red'>*</span>", $header_num);
                 } else {
                     echo Search::showHeaderItem($output_type, __('Item to link', 'ocsinventoryng'), $header_num, "", 0, "", 'width=15%');
                 }
                 echo Search::showHeaderItem($output_type, __('&nbsp;'), $header_num);
                 echo Search::showEndLine($output_type);
                 $row_num = 1;
                 $itemstypes = array(Dropdown::EMPTY_VALUE);
                 foreach (self::$hardwareItemTypes as $items) {
                     $class = getItemForItemtype($items);
                     $itemstypes[$items] = $class->getTypeName();
                 }
                 for ($i = $start; $i < $lim + $start; $i++) {
                     if (isset($hardware[$i])) {
                         $row_num++;
                         echo Search::showNewLine($output_type, $row_num % 2);
                         echo self::showItem(Html::convDateTime($hardware[$i]["date"]));
                         echo self::showItem($description = $hardware[$i]["description"]);
                         echo self::showItem($hardware[$i]["type"]);
                         echo self::showItem($ip = $hardware[$i]["ip"]);
                         if (isset($_SESSION["OCS"]["IpdiscoverMacConstructors"])) {
                             $macs = unserialize($_SESSION["OCS"]["IpdiscoverMacConstructors"]);
                             if (isset($macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))])) {
                                 $macConstructor = $macs[mb_strtoupper(substr($hardware[$i]["mac"], 0, 8))];
                             } else {
                                 $macConstructor = __("unknow");
                             }
                         }
                         $mac = $hardware[$i]["mac"] . "<small> ( " . $macConstructor . " )</small>";
                         echo self::showItem($mac);
                         if ($action == "import") {
                             if (Session::isMultiEntitiesMode()) {
                                 echo "<td>";
                                 Entity::dropdown(array('name' => "entities[{$i}]", 'entity' => $_SESSION["glpiactiveentities"]));
                                 echo "</td>";
                             }
                             echo "<td><input type=\"text\" name='itemsname[" . $i . "]' value=\"\"></td>";
                             echo "<td>";
                             Dropdown::showFromArray("glpiitemstype[{$i}]", $itemstypes);
                             echo "</td>";
                         } else {
                             echo "<td width='10'>";
                             $mtrand = mt_rand();
                             $mynamei = "itemtype";
                             $myname = "tolink_items[" . $i . "]";
                             $rand = Dropdown::showItemTypes($mynamei, self::$hardwareItemTypes, array('rand' => $mtrand));
                             $p = array('itemtype' => '__VALUE__', 'entity_restrict' => $_SESSION["glpiactiveentities"], 'id' => $i, 'rand' => $rand, 'myname' => $myname);
                             Ajax::updateItemOnSelectEvent("dropdown_{$mynamei}{$rand}", "results_{$mynamei}{$rand}", $CFG_GLPI["root_doc"] . "/plugins/ocsinventoryng/ajax/dropdownitems.php", $p);
                             echo "<span id='results_{$mynamei}{$rand}'>\n";
                             echo "</span>\n";
                             echo "</td>";
                         }
                         echo self::showItem($hardware[$i]["mac"], "", "", "", true, "", $i);
                         echo "<tbody style=\"display:none\">";
                         echo "<tr><td><input type=\"hidden\" name='itemsip[" . $i . "]' value=\"{$ip}\" >";
                         echo "<input type=\"hidden\" name='itemsdescription[" . $i . "]' value=\"{$description}\" >\n                             <input type=\"hidden\" name='subnet' value=\"{$ipAdress}\" ></tr>";
                         echo "</td></tr></tbody>";
                     }
                 }
                 echo "</table>";
                 echo "<div class='center' style=\"width=100%\">";
                 if ($action == "import") {
                     echo "<input type='submit' class='submit' name='Import'  value=\"" . _sx('button', 'Import') . "\">";
                     echo "&nbsp;";
                 } else {
                     echo "<input type='submit' class='submit' name='Link'  value=\"" . _sx('button', 'Link', 'ocsinventoryng') . "\">";
                     echo "&nbsp;";
                 }
                 echo "<input type='submit' class='submit' name='delete'  value=\"" . _sx('button', 'Delete from OCSNG', 'ocsinventoryng') . "\"></div>";
                 Html::closeForm();
                 self::checkBox($target);
                 break;
         }
     }
     if ($subnet >= 0) {
         $back = __('Back');
         echo "<div class='center'><a href='{$return}?{$returnargs}'>{$back}</div>";
     }
 }