Beispiel #1
0
 /**
  * Print the Software form
  *
  * @param $ID        integer  ID of the item
  * @param $options   array    of possible options:
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  *@return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showTabs($options);
     $this->showFormHeader($options);
     $canedit = $this->can($ID, 'w');
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Publisher') . "</td><td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td><td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Category') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $this->fields["softwarecategories_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td><td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td rowspan='5' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='5'>";
     echo "<textarea cols='45' rows='8' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . __('User') . "</td>";
     echo "<td >";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td><td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>";
     if ((!isset($options['withtemplate']) || $options['withtemplate'] == 0) && !empty($this->fields['template_name'])) {
         echo "<span class='small_space'>";
         printf(__('Created from the template %s'), $this->fields['template_name']);
         echo "</span>";
     } else {
         echo "&nbsp;";
     }
     echo "</td><td>";
     if (isset($options['withtemplate']) && $options['withtemplate']) {
         //TRANS: %s is the datetime of insertion
         printf(__('Created on %s'), Html::convDateTime($_SESSION["glpi_currenttime"]));
     } else {
         //TRANS: %s is the datetime of insertion
         printf(__('Last update on %s'), Html::convDateTime($this->fields["date_mod"]));
     }
     echo "</td></tr>\n";
     // UPDATE
     echo "<tr class='tab_bg_1'>";
     //TRANS: a noun, (ex : this software is an upgrade of..)
     echo "<td>" . __('Upgrade') . "</td><td>";
     Dropdown::showYesNo("is_update", $this->fields['is_update']);
     echo "&nbsp;" . __('from') . "&nbsp;";
     Software::dropdown(array('value' => $this->fields["softwares_id"]));
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     $this->addDivForTabs();
     return true;
 }
 static function pdfForComputer(PluginPdfSimplePDF $pdf, Computer $comp)
 {
     global $DB;
     $ID = $comp->getField('id');
     // From Computer_SoftwareVersion::showForComputer();
     $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_computers_softwareversions`.`id`,\n                       `glpi_states`.`name` AS state,\n                       `glpi_softwareversions`.`id` AS verid,\n                       `glpi_softwareversions`.`softwares_id`,\n                       `glpi_softwareversions`.`name` AS version\n                FROM `glpi_computers_softwareversions`\n                LEFT JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                           = `glpi_softwareversions`.`id`)\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_softwares`\n                     ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                WHERE `glpi_computers_softwareversions`.`computers_id` = '{$ID}'\n                ORDER BY `softwarecategories_id`, `softname`, `version`";
     $output = array();
     $software_category = new SoftwareCategory();
     $software_version = new SoftwareVersion();
     foreach ($DB->request($query) as $softwareversion) {
         $output[] = $softwareversion;
     }
     $installed = array();
     if (count($output)) {
         $pdf->setColumnsSize(100);
         $pdf->displayTitle('<b>' . _n('Installed software', 'Installed software', 2, 'pdf') . '</b>');
         $cat = -1;
         foreach ($output as $soft) {
             if ($soft["softwarecategories_id"] != $cat) {
                 $cat = $soft["softwarecategories_id"];
                 if ($cat && $software_category->getFromDB($cat)) {
                     $catname = $software_category->getName();
                 } else {
                     $catname = __('Uncategorized software');
                 }
                 $pdf->setColumnsSize(100);
                 $pdf->displayTitle('<b>' . $catname . '</b>');
                 $pdf->setColumnsSize(50, 13, 13, 24);
                 $pdf->displayTitle('<b>' . __('Name'), __('Status'), __('Version'), __('License') . '</b>');
             }
             // From Computer_SoftwareVersion::displaySoftsByCategory()
             $verid = $soft['verid'];
             $query = "SELECT `glpi_softwarelicenses`.*,\n                             `glpi_softwarelicensetypes`.`name` AS type\n                      FROM `glpi_computers_softwarelicenses`\n                      INNER JOIN `glpi_softwarelicenses`\n                           ON (`glpi_computers_softwarelicenses`.`softwarelicenses_id`\n                                    = `glpi_softwarelicenses`.`id`)\n                      LEFT JOIN `glpi_softwarelicensetypes`\n                           ON (`glpi_softwarelicenses`.`softwarelicensetypes_id`\n                                    =`glpi_softwarelicensetypes`.`id`)\n                      WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}'\n                            AND (`glpi_softwarelicenses`.`softwareversions_id_use` = '{$verid}'\n                                 OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                                     AND `glpi_softwarelicenses`.`softwareversions_id_buy` = '{$verid}'))";
             $lic = '';
             foreach ($DB->request($query) as $licdata) {
                 $installed[] = $licdata['id'];
                 $lic .= (empty($lic) ? '' : ', ') . '<b>' . $licdata['name'] . '</b> ' . $licdata['serial'];
                 if (!empty($licdata['type'])) {
                     $lic = sprintf(__('%1$s (%2$s)'), $lic, $licdata['type']);
                 }
             }
             $pdf->displayLine($soft['softname'], $soft['state'], $soft['version'], $lic);
         }
         // Each version
     } else {
         $pdf->displayTitle('<b>' . __('No installed software', 'pdf') . '</b>');
     }
     // Affected licenses NOT installed
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_states`.`name` AS state\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_computers_softwarelicenses`\n                      ON (`glpi_computers_softwarelicenses`.softwarelicenses_id\n                              = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_softwares`\n                      ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                LEFT JOIN `glpi_softwareversions`\n                      ON (`glpi_softwarelicenses`.`softwareversions_id_use`\n                              = `glpi_softwareversions`.`id`\n                           OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                               AND `glpi_softwarelicenses`.`softwareversions_id_buy`\n                                       = `glpi_softwareversions`.`id`))\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$ID}' ";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $req = $DB->request($query);
     if ($req->numrows()) {
         $pdf->setColumnsSize(100);
         $pdf->displayTitle('<b>' . __('Affected licenses of not installed software') . '</b>');
         $pdf->setColumnsSize(50, 13, 13, 24);
         $pdf->displayTitle('<b>' . __('Name'), __('Status'), __('Version'), __('License') . '</b>');
         $lic = '';
         foreach ($req as $data) {
             $lic .= '<b>' . $data['name'] . '</b> ' . $data['serial'];
             if (!empty($data['softwarelicensetypes_id'])) {
                 $lic = sprintf(__('%1$s (%2$s)'), $lic, Html::Clean(Dropdown::getDropdownName('glpi_softwarelicensetypes', $data['softwarelicensetypes_id'])));
             }
             $pdf->displayLine($data['softname'], $data['state'], $data['version'], $lic);
         }
     }
     $pdf->displaySpace();
 }
 /**
  * Print the config form for restrictions
  *
  * @return Nothing (display)
  **/
 function showFormInventory()
 {
     global $DB, $CFG_GLPI;
     if (!self::canView()) {
         return false;
     }
     $canedit = Config::canUpdate();
     if ($canedit) {
         echo "<form name='form' action=\"" . Toolbox::getItemTypeFormURL(__CLASS__) . "\" method='post'>";
     }
     echo "<div class='center' id='tabsbody'>";
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr><th colspan='4'>" . __('Assets') . "</th></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td width='30%'>" . __('Enable the financial and administrative information by default') . "</td>";
     echo "<td  width='20%'>";
     Dropdown::ShowYesNo('auto_create_infocoms', $CFG_GLPI["auto_create_infocoms"]);
     echo "</td><td width='20%'> " . __('Restrict monitor management') . "</td>";
     echo "<td width='30%'>";
     $this->dropdownGlobalManagement("monitors_management_restrict", $CFG_GLPI["monitors_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'><td>" . __('Software category deleted by the dictionary rules') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $CFG_GLPI["softwarecategories_id_ondelete"], 'name' => "softwarecategories_id_ondelete"));
     echo "</td><td> " . __('Restrict device management') . "</td><td>";
     $this->dropdownGlobalManagement("peripherals_management_restrict", $CFG_GLPI["peripherals_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Beginning of fiscal year') . "</td><td>";
     Html::showDateField("date_tax", array('value' => $CFG_GLPI["date_tax"], 'maybeempty' => false, 'canedit' => true, 'min' => '', 'max' => '', 'showyear' => false));
     echo "</td><td> " . __('Restrict phone management') . "</td><td>";
     $this->dropdownGlobalManagement("phones_management_restrict", $CFG_GLPI["phones_management_restrict"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td>" . __('Automatic fields (marked by *)') . "</td><td>";
     $tab = array(0 => __('Global'), 1 => __('By entity'));
     Dropdown::showFromArray('use_autoname_by_entity', $tab, array('value' => $CFG_GLPI["use_autoname_by_entity"]));
     echo "</td><td> " . __('Restrict printer management') . "</td><td>";
     $this->dropdownGlobalManagement("printers_management_restrict", $CFG_GLPI["printers_management_restrict"]);
     echo "</td></tr>";
     echo "</table>";
     if (Session::haveRightsOr("transfer", array(CREATE, UPDATE)) && Session::isMultiEntitiesMode()) {
         echo "<br><table class='tab_cadre_fixe'>";
         echo "<tr><th colspan='2'>" . __('Automatic transfer of computers') . "</th></tr>";
         echo "<tr class='tab_bg_2'>";
         echo "<td>" . __('Template for the automatic transfer of computers in another entity') . "</td><td>";
         Transfer::dropdown(array('value' => $CFG_GLPI["transfers_id_auto"], 'name' => "transfers_id_auto", 'emptylabel' => __('No automatic transfer')));
         echo "</td></tr>";
         echo "</table>";
     }
     echo "<br><table class='tab_cadre_fixe'>";
     echo "<tr>";
     echo "<th colspan='4'>" . __('Automatically update of the elements related to the computers');
     echo "</th><th colspan='2'>" . __('Unit management') . "</th></tr>";
     echo "<tr><th>&nbsp;</th>";
     echo "<th>" . __('Alternate username') . "</th>";
     echo "<th>" . __('User') . "</th>";
     echo "<th>" . __('Group') . "</th>";
     echo "<th>" . __('Location') . "</th>";
     echo "<th>" . __('Status') . "</th>";
     echo "</tr>";
     $fields = array("contact", "user", "group", "location");
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When connecting or updating') . "</td>";
     $values[0] = __('Do not copy');
     $values[1] = __('Copy');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoupdate";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoupdate_mode", __('Copy computer status'), $CFG_GLPI["state_autoupdate_mode"]);
     echo "</td></tr>";
     echo "<tr class='tab_bg_2'>";
     echo "<td> " . __('When disconnecting') . "</td>";
     $values[0] = __('Do not delete');
     $values[1] = __('Clear');
     foreach ($fields as $field) {
         echo "<td>";
         $fieldname = "is_" . $field . "_autoclean";
         Dropdown::showFromArray($fieldname, $values, array('value' => $CFG_GLPI[$fieldname]));
         echo "</td>";
     }
     echo "<td>";
     State::dropdownBehaviour("state_autoclean_mode", __('Clear status'), $CFG_GLPI["state_autoclean_mode"]);
     echo "</td></tr>";
     if ($canedit) {
         echo "<tr class='tab_bg_2'>";
         echo "<td colspan='6' class='center'>";
         echo "<input type='submit' name='update' class='submit' value=\"" . _sx('button', 'Save') . "\">";
         echo "</td></tr>";
     }
     echo "</table></div>";
     Html::closeForm();
 }
/** Generate bigdump : generate global dropdowns
**/
function generateGlobalDropdowns() {
   global $MAX, $DB;

   $items = array("CD", "CD-RW", "DVD-R", "DVD+R", "DVD-RW", "DVD+RW", "ramette papier",
                  "disk'ette", "ZIP");

   $dp = new ConsumableItemType();
   for ($i=0 ; $i<$MAX['consumable_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' consommable $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("phone d'power");
   $dp    = new PhonePowerSupply();
   for ($i=0 ; $i<$MAX['phone_power'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "power ' $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Grand", "Moyen", "Mic'ro", "1U", "5U");
   $dp    = new DeviceCaseType();
   for ($i=0 ; $i<$MAX['case_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "power ' $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Laser", "Jet d'Encre", "Encre Solide");
   $dp    = new CartridgeItemType();
   for ($i=0 ; $i<$MAX['cartridge_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' cartouche $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Technicien", "Commercial", "Technico-Commercial", "President", "Secretaire",
                  "Directeur d'agence");
   $dp    = new ContactType();
   for ($i=0 ; $i<$MAX['contact_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' contact $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }

   $items = array("Maintenance", "Support", "Location", "Adhesion");
   $dp    = new ContractType();
   for ($i=0 ; $i<$MAX['contract_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' crontact $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Fournisseur", "Transporteur", "SSII", "Revendeur d'", "Assembleur", "SSLL",
                  "Financeur", "Assureur");
   $dp    = new SupplierType();
   for ($i=0 ; $i<$MAX['enttype'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d'entreprise $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("H.07.02", "I.07.56", "P51", "P52", "1.60", "4.06", "43-4071299", "1.0.14",
                  "3.0.1", "rev 1.0", "rev 1.1", "rev 1.2", "rev 1.2.1", "rev 2.0", "rev 3.0");
   $dp    = new NetworkEquipmentFirmware();
   for ($i=0 ; $i<$MAX['firmware'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "firmware  $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Fire'wire");
   $dp    = new InterfaceType();
   for ($i=0 ; $i<$MAX['interface'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d' disque dur $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("100 Base TX", "100 Base T4", "10 base T", "1000 Base SX", "1000 Base LX",
                  "1000 Base T", "ATM", "802.3 10 Base 2", "IEEE 803.3 10 Base 5");
   $dp    = new NetworkInterface();
   for ($i=0 ; $i<$MAX['iface'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type carte reseau $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Non", "Oui - generique", "Oui - specifique d'entite");
   $dp    = new AutoUpdateSystem();
   for ($i=0 ; $i<$MAX['auto_update'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de mise a jour '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Assemble", "Latitude C600", "Latitude C700", "VAIO FX601", "VAIO FX905P",
                  "VAIO TR5MP", "L5000C", "A600K", "PowerBook G4");
   $dp    = new ComputerModel();
   for ($i=0 ; $i<$MAX['model'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "Modele $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment' $val")));
   }


   $items = array("4200 DTN", "4200 DN", "4200 N", "8400 ADP", "7300 ADP", "5550 DN",
                  "PIXMA iP8500", "Stylus Color 3000", "DeskJet 5950");
   $dp    = new PrinterModel();
   for ($i=0 ; $i<$MAX['model_printers'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele imprimante $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("LS902UTG", "MA203DT", "P97F+SB", "G220F", "10-30-75", "PLE438S-B0S",
                  "PLE481S-W", "L1740BQ", "L1920P", "SDM-X73H");
   $dp    = new MonitorModel();
   for ($i=0 ; $i<$MAX['model_monitors'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele moniteur $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("HP 4108GL", "HP 2524", "HP 5308", "7600", "Catalyst 4500", "Catalyst 2950",
                  "Catalyst 3750", "Catalyst 6500");
   $dp    = new NetworkEquipmentModel();
   for ($i=0 ; $i<$MAX['model_networking'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele materiel reseau $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("DCS-2100+", "DCS-2100G", "KD-P35B", "Optical 5000", "Cordless", "ASR 600",
                  "ASR 375", "CS21", "MX5020", "VS4121", "T3030", "T6060");
   $dp    = new PeripheralModel();
   for ($i=0 ; $i<$MAX['model_peripherals'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele peripherique $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Alcatel Temporis 22", "Aastra 5370ip", "Alcatel-Lucent 400 DECT Handset",
                  "BlackBerry Curve 9300");
   $dp    = new PhoneModel();
   for ($i=0 ; $i<$MAX['model_phones'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "modele phone $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment' $val")));
   }


   $items = array("SIC", "LMS", "LMP", "LEA", "SP2MI", "STIC", "MATH", "ENS-MECA", "POUBELLE",
                  "WIFI");
   $dp    = new Network();
   for ($i=0 ; $i<$MAX['network'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "reseau $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Windows XP Pro SP2", "Linux (Debian)", "Mac OS X", "Linux (Mandriva 2006)",
                  "Linux (Redhat)", "Windows 98", "Windows 2000", "Windows XP Pro SP1",
                  "LINUX (Suse)", "Linux (Mandriva 10.2)");
   $dp    = new OperatingSystem();
   for ($i=0 ; $i<$MAX['os'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "os $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("XP Pro", "XP Home", "10.0", "10.1", "10.2", "2006", "Sarge");
   $dp    = new operatingSystemVersion();
   for ($i=0 ; $i<$MAX['os_version'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "osversion $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Service Pack 1", "Service Pack 2", "Service Pack 3", "Service Pack 4");
   $dp    = new OperatingSystemServicePack();
   for ($i=0 ; $i<$MAX['os_sp'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "ossp $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("DDR2");
   $dp    = new DeviceMemoryType();
   for ($i=0 ; $i<$MAX['ram_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de ram $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment' $val")));
   }

   $items = array('Bureautique', 'Calcul', "logiciel d'antivirus", 'Multimédia');
   $dp    = new SoftwareCategory();
   for ($i=0 ; $i<max(1,pow($MAX['softwarecategory'],1/2)) ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "category $i";
      }
      $newID = $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                                       'comment' => "comment $val")));

      for ($j=0 ; $j<mt_rand(0,pow($MAX['softwarecategory'],1/2)) ; $j++) {
         $newID2 = $dp->add(toolbox::addslashes_deep(array('name'    => "s-category '$j",
                                                           'comment' => "comment d' $val s-category $j",
                                                           'softwarecategories_id'
                                                                     => $newID)));
      }
   }
   $MAX['rubdocs'] = getMaxItem('glpi_softwarecategories');

   $dp = new SoftwareLicenseType();
   for ($i=0 ; $i<$MAX['licensetype'] ; $i++) {
      $val = "type ' $i";
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("SIC", "LMS", "LMP", "LEA", "SP2MI", "STIC", "MATH", "ENS-MECA", "POUBELLE",
                  "WIFI");
   $dp    = new Vlan();
   for ($i=0 ; $i<$MAX['vlan'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "VLAN $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val",
                                              'tag'     => $i)));
   }


   $items = array("Portable", "Desktop", "Tour");
   $dp    = new ComputerType();
   for ($i=0 ; $i<$MAX['type_computers'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type ordinateur $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Laser A4", "Jet d'Encre", "Laser A3", "Encre Solide A4", "Encre Solide A3");
   $dp    = new PrinterType();
   for ($i=0 ; $i<$MAX['type_printers'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type d'imprimante $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("TFT 17", "TFT 19", "TFT 21", "CRT 17", "CRT 19", "CRT 21", "CRT 15");
   $dp    = new MonitorType();
   for ($i=0 ; $i<$MAX['type_monitors'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type ecran $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Switch", "Routeur", "Hub", "Borne Wifi", "borne d'accueil");
   $dp    = new NetworkEquipmentType();
   for ($i=0 ; $i<$MAX['type_networking'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de materiel reseau '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Clavier", "Souris", "Webcam", "Enceintes", "Scanner", "Clef USB", "d'autres");
   $dp    = new PeripheralType();
   for ($i=0 ; $i<$MAX['type_peripherals'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de peripheriques '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Analogique", "IP", );
   $dp    = new PhoneType();
   for ($i=0 ; $i<$MAX['type_phones'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "type de phone $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("DELL", "HP", "IIYAMA", "CANON", "EPSON", "LEXMARK", "ASUS", "MSI");
   $dp    = new Manufacturer();
   for ($i=0 ; $i<$MAX['manufacturer'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "manufacturer $i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment '$val")));
   }


   $items = array("Ingénieur", "Stagiaire", "Secrétaire", "ouvrier d'atelier");
   $dp    = new UserCategory();
   for ($i=0 ; $i<$MAX['user_type'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "user type d'$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }


   $items = array("Président", "Agent Comptable", "Directeur d'agence");
   $dp    = new UserTitle();
   for ($i=0 ; $i<$MAX['user_title'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "user type '$i";
      }
      $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                              'comment' => "comment $val")));
   }

   $items = array("Documentation", "Facture", "Bon Livraison", "Bon commande", "Capture d'Ecran",
                  "Dossier Technique");
   $dp    = new DocumentCategory();
   for ($i=0 ; $i<max(1,pow($MAX['rubdocs'],1/2)) ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "category $i";
      }
      $newID = $dp->add(toolbox::addslashes_deep(array('name'    => $val,
                                                       'comment' => "comment $val")));

      for ($j=0 ; $j<mt_rand(0,pow($MAX['rubdocs'],1/2)) ; $j++) {
         $newID2 = $dp->add(toolbox::addslashes_deep(
                            array('name'                        => "s-category '$j",
                                  'comment'                     => "comment d' $val s-category $j",
                                  'documentcategories_id'       => $newID)));
      }
   }
   $MAX['rubdocs'] = getMaxItem('glpi_documentcategories');

   $dp = new ItilCategory();
   // GLobal ticket categories : also specific ones by entity
   for ($i=0 ; $i<max(1,pow($MAX['tracking_category'],1/3)) ; $i++) {
      $newID = $dp->add(toolbox::addslashes_deep(
                        array('name'                        => "category '$i",
                              'comment'                     => "comment ' category $i",
                              'is_recursive'                => 1,
                              'tickettemplates_id_incident' => 1,
                              'tickettemplates_id_demand'   => 1)));

      for ($j=0 ; $j<mt_rand(0,pow($MAX['tracking_category'],1/2)) ; $j++) {
         $newID2 = $dp->add(toolbox::addslashes_deep(
                            array('name'                        => "s-category '$j",
                                  'comment'                     => "comment 'category $i s-category $j",
                                  'is_recursive'                => 1,
                                  'tickettemplates_id_incident' => 1,
                                  'tickettemplates_id_demand'   => 1,
                                  'itilcategories_id'           => $newID)));

         for ($k=0 ; $k<mt_rand(0,pow($MAX['tracking_category'],1/2)) ; $k++) {
            $newID3 = $dp->add(toolbox::addslashes_deep(
                               array('name'                        => "ss-category' $k",
                                     'comment'      => "comment ' category $i s-category $j ss-category $k",
                                     'is_recursive'                => 1,
                                     'tickettemplates_id_incident' => 1,
                                     'tickettemplates_id_demand'   => 1,
                                     'itilcategories_id'           => $newID2)));
         }
      }
   }

   $query = "OPTIMIZE TABLE `glpi_itilcategories`";
   $DB->query($query) or die("PB REQUETE ".$query);

   regenerateTreeCompleteName("glpi_itilcategories");

   $MAX['tracking_category'] = getMaxItem('glpi_itilcategories');

   // DEVICE
   $items = array("Textorm 6A19", "ARIA", "SLK3000B-EU", "Sonata II", "TA-212", "TA-551", "TA-581",
                  "TAC-T01", "CS-512", "Li PC-60891", "STT-TJ02S");
   $dp    = new DeviceCase();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "case $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'devicecasetypes_id' => mt_rand(0,$MAX["case_type"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("Escalade 8006-2LP", "Escalade 8506-4LP", "2810SA", "1210SA", "DuoConnect",
                  "DU-420", "DUB-A2", "FastTrak SX4100B", "DC-395U", "TFU-H33PI");
   $dp    = new DeviceControl();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "control $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment ' $val",
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("DUW1616", "DRW-1608P", "DW1625", "GSA-4160B", "GSA-4165B", "GSA-4167RBB",
                  "SHW-16H5S", "SOHW-1673SX", "DVR-110D", "PX-716AL", "PX-755A");
   $dp    = new DeviceDrive();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "drive $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'is_writer'          => mt_rand(0,1),
                     'speed'              => mt_rand(0,60),
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("A9250/TD", "AX550/TD", "Extreme N5900", "V9520-X/TD", "All-In-Wonder X800 GT",
                  "GV-NX66256D", "GV-RX80256DE", "Excalibur 9600XT", "X1300 IceQ",
                  "WinFast PX6200 TD", "Millenium 750","NX6600GT");
   $dp    = new DeviceGraphicCard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "gfxcard $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment ' $val",
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'memory_default'     => 256*mt_rand(0,8))));
   }


   $items = array("Deskstar 7K500", "Deskstar T7K250", "Atlas 15K II", "DiamondMax Plus",
                  "SpinPoint P - SP2514N", "Barracuda 7200.9", "WD2500JS", "WD1600JB", "WD1200JD");
   $dp    = new DeviceHardDrive();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "hdd  $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'interfacetypes_id'  => mt_rand(0,$MAX["interface"]),
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'capacity_default'   => mt_rand(0,300),
                     'rpm'                => mt_rand(0,15000),
                     'cache'              => 51200*mt_rand(0,10))));
   }


   $items = array("DFE-530TX", "DFE-538TX", "PWLA8492MF", "PWLA8492MT", "USBVPN1", "GA311", "FA511",
                  "TEG-PCBUSR", "3C996-SX", "3C996B-T", "3C905C-TX-M");
   $dp    = new DeviceNetworkCard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "iface  $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'bandwidth'          => mt_rand(0,1000))));
   }


   $items = array("AW8-MAX", "NV8", "AK86-L", "P4V88", "A8N-SLI", "A8N-VM", "K8V-MX", "K8N4-E",
                  "P5LD2", "GA-K8NE", "GA-8I945P Pro", "D945PBLL", "SE7525GP2", "865PE Neo3-F",
                  "K8N Neo4-F", "Thunder i7520 (S5360G2NR)", "Thunder K8SR - S2881UG2NR",
                  "Tiger K8QS Pro - S4882UG2NR", "Tomcat i875PF (S5105G2NR)");
   $dp    = new DeviceMotherBoard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "moboard $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'chipset'            => 'chipset '.mt_rand(0,1000))));
   }


   $items = array("Instant TV Cardbus", "WinTV Express", "WinTV-NOVA-S-Plus", "WinTV-NOVA-T",
                  "WinTV-PVR-150");
   $dp    = new DevicePci();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "pci $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']))));
   }


   $items = array("DB-Killer PW335", "DB-Killer PW385", "NeoHE 380", "NeoHE 450", "Phantom 500-PEC",
                  "TruePower 2.0 550", "Master RS-380", "EG375AX-VE-G-SFMA", "EG495AX");
   $dp    = new DevicePowerSupply();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "power $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment '$val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'power'              => mt_rand(0,500).'W',
                     'is_atx'             => mt_rand(0,1))));
   }


   $items = array("Athlon 64 FX-57", "Athlon 64 FX-55", "Sempron 2400+", "Sempron 2600+",
                  "Celeron D 325", "Celeron D 330J", "Pentium 4 530J", "Pentium 4 631",
                  "Pentium D 830", "Pentium D 920");
   $dp    = new DeviceProcessor();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "processor $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'        => $val,
                     'is_recursive'       => 1,
                     'comment'            => "comment' $val",
                     'manufacturers_id'   => mt_rand(1,$MAX['manufacturer']),
                     'frequence'          => mt_rand(1000,3000),
                     'frequency_default'  => 1000+200*mt_rand(0,10),
                     'nbcores_default'    => mt_rand(1,8),
                     'nbthreads_default'  => mt_rand(1,4),
                     )));
   }


   $items = array("CM2X256A-5400C4", "CMX1024-3200C2", "CMXP512-3200XL", "TWIN2X1024-4300C3PRO",
                  "KTD-DM8400/1G", "KTH8348/1G", "KTD4400/256", "D6464D30A", "KTA-G5400/512",
                  "KVR667D2N5/1G", "KVR133X64C3/256");
   $dp    = new DeviceMemory();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "ram $i";
      }
      $dp->add(toolbox::addslashes_deep(
               array('designation'          => $val,
                     'is_recursive'         => 1,
                     'comment'              => "comment' $val",
                     'manufacturers_id'     => mt_rand(1,$MAX['manufacturer']),
                     'frequence'            => 100*mt_rand(0,10),
                     'size_default'         => 1024*mt_rand(0,6),
                     'devicememorytypes_id' => mt_rand(1,$MAX['ram_type']))));
   }


   $items = array("DDTS-100", "Audigy 2 ZS Platinum", "Audigy SE", "DJ Console Mk2",
                  "Gamesurround Muse Pocket USB", "Phase 22", "X-Fi Platinum", "Live! 24-bit",
                  "X-Fi Elite Pro");
   $dp    = new DeviceSoundCard();
   for ($i=0 ; $i<$MAX['device'] ; $i++) {
      if (isset($items[$i])) {
         $val = $items[$i];
      } else {
         $val = "sndcard $i";
      }
       $dp->add(toolbox::addslashes_deep(
                array('designation'         => $val,
                     'is_recursive'         => 1,
                     'comment'              => "comment '$val",
                     'manufacturers_id'     => mt_rand(1,$MAX['manufacturer']),
                     'type'                 => 'type '.mt_rand(0,100))));
   }

} // Fin generation global dropdowns
 /**
  * Show software installed on a computer
  *
  * @param $comp            Computer object
  * @param $withtemplate    template case of the view process (default '')
  *
  * @return nothing
  **/
 static function showForComputer(Computer $comp, $withtemplate = '')
 {
     global $DB, $CFG_GLPI;
     if (!Software::canView()) {
         return false;
     }
     $computers_id = $comp->getField('id');
     $rand = mt_rand();
     $canedit = Session::haveRightsOr("software", array(CREATE, UPDATE, DELETE, PURGE));
     $entities_id = $comp->fields["entities_id"];
     $crit = Session::getSavedOption(__CLASS__, 'criterion', -1);
     $where = '';
     if ($crit > -1) {
         $where = " AND `glpi_softwares`.`softwarecategories_id` = {$crit}";
     }
     $add_dynamic = '';
     if (Plugin::haveImport()) {
         $add_dynamic = "`glpi_computers_softwareversions`.`is_dynamic`,";
     }
     $query = "SELECT `glpi_softwares`.`softwarecategories_id`,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_computers_softwareversions`.`id`,\n                       {$add_dynamic}\n                       `glpi_states`.`name` AS state,\n                       `glpi_softwareversions`.`id` AS verid,\n                       `glpi_softwareversions`.`softwares_id`,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_softwares`.`is_valid` AS softvalid\n                FROM `glpi_computers_softwareversions`\n                LEFT JOIN `glpi_softwareversions`\n                     ON (`glpi_computers_softwareversions`.`softwareversions_id`\n                           = `glpi_softwareversions`.`id`)\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                LEFT JOIN `glpi_softwares`\n                     ON (`glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`)\n                WHERE `glpi_computers_softwareversions`.`computers_id` = '{$computers_id}'\n                      AND `glpi_computers_softwareversions`.`is_deleted` = '0'\n                      {$where}\n                ORDER BY `softname`, `version`";
     $result = $DB->query($query);
     $i = 0;
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwareversion.form.php'>";
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'><td class='center'>";
         echo _n('Software', 'Software', Session::getPluralNumber()) . "&nbsp;&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownSoftwareToInstall("softwareversions_id", $entities_id);
         echo "</td><td width='20%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Install') . "\"\n                class='submit'>";
         echo "</td>";
         echo "</tr>\n";
         echo "</table></div>\n";
         Html::closeForm();
     }
     echo "<div class='spaced'>";
     $cat = -1;
     Session::initNavigateListItems('Software', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
     Session::initNavigateListItems('SoftwareLicense', sprintf(__('%1$s = %2$s'), Computer::getTypeName(1), $comp->getName()));
     // Mini Search engine
     echo "<table class='tab_cadre_fixe'>";
     echo "<tr class='tab_bg_1'><th colspan='2'>" . Software::getTypeName(Session::getPluralNumber()) . "</th></tr>";
     echo "<tr class='tab_bg_1'><td class='center'>";
     echo __('Category') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $crit, 'toadd' => array('-1' => __('All categories')), 'emptylabel' => __('Uncategorized software'), 'on_change' => 'reloadTab("start=0&criterion="+this.value)'));
     echo "</td></tr></table></div>";
     $number = $DB->numrows($result);
     $start = isset($_REQUEST['start']) ? intval($_REQUEST['start']) : 0;
     if ($start >= $number) {
         $start = 0;
     }
     $installed = array();
     if ($number) {
         echo "<div class='spaced'>";
         Html::printAjaxPager('', $start, $number);
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $massiveactionparams = array('num_displayed' => $number, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         $header_begin = "<tr>";
         $header_top = '';
         $header_bottom = '';
         $header_end = '';
         if ($canedit) {
             $header_begin .= "<th width='10'>";
             $header_top .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_bottom .= Html::getCheckAllAsCheckbox('mass' . __CLASS__ . $rand);
             $header_end .= "</th>";
         }
         $header_end .= "<th>" . __('Name') . "</th><th>" . __('Status') . "</th>";
         $header_end .= "<th>" . __('Version') . "</th><th>" . __('License') . "</th>";
         if (Plugin::haveImport()) {
             $header_end .= "<th>" . __('Automatic inventory') . "</th>";
         }
         $header_end .= "<th>" . SoftwareCategory::getTypeName(1) . "</th>";
         $header_end .= "<th>" . __('Valid license') . "</th>";
         $header_end .= "</tr>\n";
         echo $header_begin . $header_top . $header_end;
         for ($row = 0; $data = $DB->fetch_assoc($result); $row++) {
             if ($row >= $start && $row < $start + $_SESSION['glpilist_limit']) {
                 $licids = self::softsByCategory($data, $computers_id, $withtemplate, $canedit, true);
             } else {
                 $licids = self::softsByCategory($data, $computers_id, $withtemplate, $canedit, false);
             }
             Session::addToNavigateListItems('Software', $data["softwares_id"]);
             foreach ($licids as $licid) {
                 Session::addToNavigateListItems('SoftwareLicense', $licid);
                 $installed[] = $licid;
             }
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
     } else {
         echo "<p class='center b'>" . __('No item found') . "</p>";
     }
     echo "</div>\n";
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit) {
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
         echo "<div class='spaced'><table class='tab_cadre_fixe'>";
         echo "<tr class='tab_bg_1'>";
         echo "<td class='center'>";
         echo _n('License', 'Licenses', Session::getPluralNumber()) . "&nbsp;&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownLicenseToInstall("softwarelicenses_id", $entities_id);
         echo "</td><td width='20%'>";
         echo "<input type='submit' name='add' value=\"" . _sx('button', 'Add') . "\" class='submit'>";
         echo "</td></tr>\n";
         echo "</table></div>\n";
         Html::closeForm();
     }
     echo "<div class='spaced'>";
     // Affected licenses NOT installed
     $query = "SELECT `glpi_softwarelicenses`.*,\n                       `glpi_computers_softwarelicenses`.`id` AS linkID,\n                       `glpi_softwares`.`name` AS softname,\n                       `glpi_softwareversions`.`name` AS version,\n                       `glpi_states`.`name` AS state\n                FROM `glpi_softwarelicenses`\n                LEFT JOIN `glpi_computers_softwarelicenses`\n                      ON (`glpi_computers_softwarelicenses`.softwarelicenses_id\n                              = `glpi_softwarelicenses`.`id`)\n                INNER JOIN `glpi_softwares`\n                      ON (`glpi_softwarelicenses`.`softwares_id` = `glpi_softwares`.`id`)\n                LEFT JOIN `glpi_softwareversions`\n                      ON (`glpi_softwarelicenses`.`softwareversions_id_use`\n                              = `glpi_softwareversions`.`id`\n                           OR (`glpi_softwarelicenses`.`softwareversions_id_use` = '0'\n                               AND `glpi_softwarelicenses`.`softwareversions_id_buy`\n                                       = `glpi_softwareversions`.`id`))\n                LEFT JOIN `glpi_states`\n                     ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n                WHERE `glpi_computers_softwarelicenses`.`computers_id` = '{$computers_id}'\n                      AND `glpi_computers_softwarelicenses`.`is_deleted` = '0'\n                      {$where}";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $query .= " ORDER BY `softname`, `version`;";
     $req = $DB->request($query);
     if ($number = $req->numrows()) {
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('massSoftwareLicense' . $rand);
             $actions = array('Computer_SoftwareLicense' . MassiveAction::CLASS_ACTION_SEPARATOR . 'install' => _x('button', 'Install'));
             if (SoftwareLicense::canUpdate()) {
                 $actions['purge'] = _x('button', 'Delete permanently');
             }
             $massiveactionparams = array('num_displayed' => $number, 'container' => 'massSoftwareLicense' . $rand, 'specific_actions' => $actions);
             Html::showMassiveActions($massiveactionparams);
         }
         echo "<table class='tab_cadre_fixehov'>";
         $header_begin = "<tr>";
         $header_top = '';
         $header_bottom = '';
         $header_end = '';
         if ($canedit) {
             $header_begin .= "<th width='10'>";
             $header_top .= Html::getCheckAllAsCheckbox('massSoftwareLicense' . $rand);
             $header_bottom .= Html::getCheckAllAsCheckbox('massSoftwareLicense' . $rand);
             $header_end .= "</th>";
         }
         $header_end .= "<th>" . __('Name') . "</th><th>" . __('Status') . "</th>";
         $header_end .= "<th>" . __('Version') . "</th><th>" . __('License') . "</th>";
         $header_end .= "</tr>\n";
         echo $header_begin . $header_top . $header_end;
         $cat = true;
         foreach ($req as $data) {
             self::displaySoftsByLicense($data, $computers_id, $withtemplate, $canedit);
             Session::addToNavigateListItems('SoftwareLicense', $data["id"]);
         }
         echo $header_begin . $header_bottom . $header_end;
         echo "</table>";
         if ($canedit) {
             $massiveactionparams['ontop'] = false;
             Html::showMassiveActions($massiveactionparams);
             Html::closeForm();
         }
     }
     echo "</div>\n";
 }
Beispiel #6
0
 /**
  * Print the Software form
  *
  * @param $ID        integer  ID of the item
  * @param $options   array    of possible options:
  *     - target filename : where to go when done.
  *     - withtemplate boolean : template or basic item
  *
  *@return boolean item found
  **/
 function showForm($ID, $options = array())
 {
     $this->initForm($ID, $options);
     $this->showFormHeader($options);
     $canedit = $this->canEdit($ID);
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Name') . "</td>";
     echo "<td>";
     Html::autocompletionTextField($this, "name");
     echo "</td>";
     echo "<td>" . __('Publisher') . "</td><td>";
     Manufacturer::dropdown(array('value' => $this->fields["manufacturers_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Location') . "</td><td>";
     Location::dropdown(array('value' => $this->fields["locations_id"], 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Category') . "</td><td>";
     SoftwareCategory::dropdown(array('value' => $this->fields["softwarecategories_id"]));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Technician in charge of the hardware') . "</td><td>";
     User::dropdown(array('name' => 'users_id_tech', 'value' => $this->fields["users_id_tech"], 'right' => 'own_ticket', 'entity' => $this->fields["entities_id"]));
     echo "</td>";
     echo "<td>" . __('Associable to a ticket') . "</td><td>";
     Dropdown::showYesNo('is_helpdesk_visible', $this->fields['is_helpdesk_visible']);
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group in charge of the hardware') . "</td>";
     echo "<td>";
     Group::dropdown(array('name' => 'groups_id_tech', 'value' => $this->fields['groups_id_tech'], 'entity' => $this->fields['entities_id'], 'condition' => '`is_assign`'));
     echo "</td>";
     echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>";
     echo "<td class='center middle' rowspan='4'>";
     echo "<textarea cols='45' rows='8' name='comment' >" . $this->fields["comment"] . "</textarea>";
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td >" . __('User') . "</td>";
     echo "<td >";
     User::dropdown(array('value' => $this->fields["users_id"], 'entity' => $this->fields["entities_id"], 'right' => 'all'));
     echo "</td></tr>\n";
     echo "<tr class='tab_bg_1'>";
     echo "<td>" . __('Group') . "</td><td>";
     Group::dropdown(array('value' => $this->fields["groups_id"], 'entity' => $this->fields["entities_id"], 'condition' => '`is_itemgroup`'));
     echo "</td></tr>\n";
     // UPDATE
     echo "<tr class='tab_bg_1'>";
     //TRANS: a noun, (ex : this software is an upgrade of..)
     echo "<td>" . __('Upgrade') . "</td><td>";
     Dropdown::showYesNo("is_update", $this->fields['is_update']);
     echo "&nbsp;" . __('from') . "&nbsp;";
     Software::dropdown(array('value' => $this->fields["softwares_id"]));
     echo "</td></tr>\n";
     $this->showFormButtons($options);
     return true;
 }