dropdownSoftwareToInstall() static public method

Make a select box for software to install
static public dropdownSoftwareToInstall ( $myname, $entity_restrict ) : nothing
$myname select name
$entity_restrict restrict to a defined entity
return nothing (print out an HTML select box)
 /**
  * Show software installed on a computer
  *
  * @param $comp Computer object
  * @param $withtemplate template case of the view process
  *
  * @return nothing
  **/
 static function showForComputer(Computer $comp, $withtemplate = '')
 {
     global $DB, $CFG_GLPI, $LANG;
     if (!haveRight("software", "r")) {
         return false;
     }
     $computers_id = $comp->getField('id');
     $rand = mt_rand();
     $canedit = haveRight("software", "w");
     $entities_id = $comp->fields["entities_id"];
     $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` = '{$computers_id}'\n                ORDER BY `softwarecategories_id`, `softname`, `version`";
     $result = $DB->query($query);
     $i = 0;
     echo "<div class='spaced'><table class='tab_cadre_fixe'>";
     if ((empty($withtemplate) || $withtemplate != 2) && $canedit) {
         echo "<tr class='tab_bg_1'><td class='center' colspan='3'>";
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwareversion.form.php'>";
         echo $LANG['Menu'][4] . "&nbsp;:&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownSoftwareToInstall("softwareversions_id", $entities_id);
         echo "<input type='submit' name='install' value=\"" . $LANG['buttons'][4] . "\" class='submit'>";
         echo "</form>";
         echo "</td>";
         echo "<td class='cneter' clospan='2'>";
         echo "<form method='post' action='" . $CFG_GLPI["root_doc"] . "/front/computer_softwarelicense.form.php'>";
         echo $LANG['software'][11] . "&nbsp;:&nbsp;";
         echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         Software::dropdownLicenseToInstall("softwarelicenses_id", $entities_id);
         echo "<input type='submit' name='add' value=\"" . $LANG['buttons'][8] . "\" class='submit'>";
         echo "</form>";
         echo "</td></tr>\n";
     }
     echo "<tr><th colspan='5'>";
     if ($DB->numrows($result) == 1) {
         echo $LANG['software'][16];
     } else {
         echo $LANG['software'][17];
     }
     echo "</th></tr>";
     $cat = -1;
     initNavigateListItems('Software', $LANG['help'][25] . " = " . (empty($comp->fields["name"]) ? "(" . $comp->fields["id"] . ")" : $comp->fields["name"]));
     initNavigateListItems('SoftwareLicense', $LANG['help'][25] . " = " . (empty($comp->fields["name"]) ? "(" . $comp->fields["id"] . ")" : $comp->fields["name"]));
     $installed = array();
     if ($DB->numrows($result)) {
         while ($data = $DB->fetch_array($result)) {
             if ($data["softwarecategories_id"] != $cat) {
                 self::displayCategoryFooter($cat, $rand, $canedit);
                 $cat = self::displayCategoryHeader($computers_id, $data, $rand, $canedit);
             }
             $licids = self::displaySoftsByCategory($data, $computers_id, $withtemplate, $canedit);
             addToNavigateListItems('Software', $data["softwares_id"]);
             foreach ($licids as $licid) {
                 addToNavigateListItems('SoftwareLicense', $licid);
                 $installed[] = $licid;
             }
         }
         self::displayCategoryFooter($cat, $rand, $canedit);
     }
     // 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` = '{$computers_id}' ";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $req = $DB->request($query);
     if ($req->numrows()) {
         $cat = true;
         foreach ($req as $data) {
             if ($cat) {
                 self::displayCategoryHeader($computers_id, $data, $rand, $canedit);
                 $cat = false;
             }
             self::displaySoftsByLicense($data, $computers_id, $withtemplate, $canedit);
             addToNavigateListItems('SoftwareLicense', $data["id"]);
         }
         self::displayCategoryFooter(NULL, $rand, $canedit);
     }
     echo "</table></div>\n";
 }
 /**
  * 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";
 }
 case "unlock_ocsng_field":
     $fields['all'] = $LANG['common'][66];
     $fields += OcsServer::getLockableFields();
     Dropdown::showFromArray("field", $fields);
     echo "&nbsp;<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>";
     break;
 case "unlock_ocsng_monitor":
 case "unlock_ocsng_peripheral":
 case "unlock_ocsng_software":
 case "unlock_ocsng_printer":
 case "unlock_ocsng_disk":
 case "unlock_ocsng_ip":
     echo "<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>";
     break;
 case "install":
     Software::dropdownSoftwareToInstall("softwareversions_id", $_SESSION["glpiactive_entity"], 1);
     echo "&nbsp;<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][4] . "'>";
     break;
 case "connect":
     Computer_Item::dropdownConnect('Computer', $_POST["itemtype"], "connect_item");
     echo "&nbsp;<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>";
     break;
 case "connect_to_computer":
     Dropdown::showAllItems("connect_item", 0, 0, $_SESSION["glpiactive_entity"], array('Monitor', 'Peripheral', 'Phone', 'Printer'), true);
     echo "&nbsp;<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>";
     break;
 case "disconnect":
     echo "<input type='submit' name='massiveaction' class='submit' value='" . $LANG['buttons'][2] . "'>";
     break;
 case "add_group":
     Dropdown::show('Group');
Ejemplo n.º 4
0
 /**
  * @see CommonDBTM::showSpecificMassiveActionsParameters()
  **/
 function showSpecificMassiveActionsParameters($input = array())
 {
     switch ($input['action']) {
         case "install":
             Software::dropdownSoftwareToInstall("softwareversions_id", $_SESSION["glpiactive_entity"], 1);
             echo "<br><br><input type='submit' name='massiveaction' class='submit' value='" . __s('Install') . "'>";
             return true;
         case "connect":
             $ci = new Computer_Item();
             return $ci->showSpecificMassiveActionsParameters($input);
         default:
             return parent::showSpecificMassiveActionsParameters($input);
     }
     return false;
 }
 /**
  * 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 (!Session::haveRight("software", "r")) {
         return false;
     }
     $computers_id = $comp->getField('id');
     $rand = mt_rand();
     $canedit = Session::haveRight("software", "w");
     $entities_id = $comp->fields["entities_id"];
     $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                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                ORDER BY `softwarecategories_id`, `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', 2) . "&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()));
     $installed = array();
     if ($number = $DB->numrows($result)) {
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
             $paramsma = array('num_displayed' => $number, 'specific_actions' => array('purge' => _x('button', 'Delete permanently')));
             Html::showMassiveActions(__CLASS__, $paramsma);
         }
         echo "<table class='tab_cadre_fixe'>";
         while ($data = $DB->fetch_assoc($result)) {
             if ($data["softwarecategories_id"] != $cat) {
                 self::displayCategoryFooter($cat, $rand, $canedit);
                 $cat = self::displayCategoryHeader($computers_id, $data, $rand, $canedit);
             }
             $licids = self::displaySoftsByCategory($data, $computers_id, $withtemplate, $canedit);
             Session::addToNavigateListItems('Software', $data["softwares_id"]);
             foreach ($licids as $licid) {
                 Session::addToNavigateListItems('SoftwareLicense', $licid);
                 $installed[] = $licid;
             }
         }
         self::displayCategoryFooter($cat, $rand, $canedit);
         echo "</table>";
         if ($canedit) {
             $paramsma['ontop'] = false;
             Html::showMassiveActions(__CLASS__, $paramsma);
             Html::closeForm();
         }
     }
     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', 2) . "&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'";
     if (count($installed)) {
         $query .= " AND `glpi_softwarelicenses`.`id` NOT IN (" . implode(',', $installed) . ")";
     }
     $req = $DB->request($query);
     if ($number = $req->numrows()) {
         if ($canedit) {
             $rand = mt_rand();
             Html::openMassiveActionsForm('massSoftwareLicense' . $rand);
             $actions = array('install' => _x('button', 'Install'));
             if (SoftwareLicense::canUpdate()) {
                 $actions['purge'] = _x('button', 'Delete permanently');
             }
             $paramsma = array('num_displayed' => $number, 'specific_actions' => $actions);
             Html::showMassiveActions('Computer_SoftwareLicense', $paramsma);
             echo "<input type='hidden' name='computers_id' value='{$computers_id}'>";
         }
         echo "<table class='tab_cadre_fixe'>";
         $cat = true;
         foreach ($req as $data) {
             if ($cat) {
                 self::displayCategoryHeader($computers_id, $data, $rand, $canedit);
                 $cat = false;
             }
             self::displaySoftsByLicense($data, $computers_id, $withtemplate, $canedit);
             Session::addToNavigateListItems('SoftwareLicense', $data["id"]);
         }
         self::displayCategoryFooter(NULL, $rand, $canedit);
         echo "</table>";
         if ($canedit) {
             $paramsma['ontop'] = false;
             Html::showMassiveActions('Computer_SoftwareLicense', $paramsma);
             Html::closeForm();
         }
     }
     echo "</div>\n";
 }
 /**
  * Display all values available depending on field selected
  *
  * @static
  * @param $options
  * @param int $value
  */
 static function dropdownValues($options, $value = 0)
 {
     $itemtype = $options['itemtype'];
     $typocrit_id = $options['typocrit_id'];
     $field = $options['field'];
     $action = $options['action_type'];
     $item = new $itemtype();
     $test = explode(";", $field);
     $itemField = $test[0];
     $itemTable = $test[1];
     $itemDataType = $test[2];
     $typoCritDef = new PluginTypologyTypologyCriteriaDefinition();
     $typoCritDef->fields['plugin_typology_typologycriterias_id'] = $typocrit_id;
     $typoCritDef->fields['field'] = $field;
     $typoCrit = new PluginTypologyTypologyCriteria();
     $typoCrit->getFromDB($typocrit_id);
     if ($action == 'contains' || $action == 'notcontains' || $action == 'regex_match' || $action == 'regex_not_match') {
         Html::autocompletionTextField($typoCritDef, "value");
     } else {
         switch ($itemDataType) {
             case "bool":
                 Dropdown::showYesNo('value');
                 break;
             case "number":
                 Html::autocompletionTextField($typoCritDef, "value");
                 if ($itemField == 'size') {
                     echo "\"";
                 }
                 break;
             case "string":
                 Html::autocompletionTextField($typoCritDef, "value");
                 break;
             case "text":
                 Html::autocompletionTextField($typoCritDef, "value");
                 if ($itemtype == 'DeviceHardDrive') {
                     echo " " . __('Mio');
                 } else {
                     if ($itemField == 'frequence') {
                         echo " " . __('MHz');
                     } else {
                         if ($itemtype == 'DeviceMemory' && $itemField == 'specif_default') {
                             echo " " . __('Mio');
                         } else {
                             if ($itemtype == 'DeviceProcessor' && $itemField == 'specif_default') {
                                 echo " " . __('MHz');
                             }
                         }
                     }
                 }
                 break;
                 //            case "ip" :
                 //               Html::autocompletionTextField($typoCritDef, "value");
                 //               break;
             //            case "ip" :
             //               Html::autocompletionTextField($typoCritDef, "value");
             //               break;
             default:
                 switch ($itemTable) {
                     case "glpi_users":
                         User::dropdown(array('right' => 'all', 'name' => 'value'));
                         break;
                     case "glpi_softwareversions":
                         Software::dropdownSoftwareToInstall("value", $typoCrit->fields['entities_id']);
                         break;
                     default:
                         $itemclass = getItemTypeForTable($itemTable);
                         Dropdown::show($itemclass, array('name' => 'value', 'entity' => $typoCrit->fields['entities_id']));
                         break;
                 }
                 break;
         }
     }
     echo "</span></td>";
 }