/** * Show Versions of a software * * @param $soft Software object * * @return nothing **/ static function showForSoftware(Software $soft) { global $DB, $CFG_GLPI; $softwares_id = $soft->getField('id'); if (!$soft->can($softwares_id, READ)) { return false; } $canedit = $soft->canEdit($softwares_id); echo "<div class='spaced'>"; if ($canedit) { echo "<div class='center firstbloc'>"; echo "<a class='vsubmit' href='softwareversion.form.php?softwares_id={$softwares_id}'>" . _x('button', 'Add a version') . "</a>"; echo "</div>"; } $query = "SELECT `glpi_softwareversions`.*,\n `glpi_states`.`name` AS sname\n FROM `glpi_softwareversions`\n LEFT JOIN `glpi_states` ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n WHERE `softwares_id` = '{$softwares_id}'\n ORDER BY `name`"; Session::initNavigateListItems('SoftwareVersion', sprintf(__('%1$s = %2$s'), Software::getTypeName(1), $soft->getName())); if ($result = $DB->query($query)) { if ($DB->numrows($result)) { echo "<table class='tab_cadre_fixehov'><tr>"; echo "<th>" . self::getTypeName(Session::getPluralNumber()) . "</th>"; echo "<th>" . __('Status') . "</th>"; echo "<th>" . __('Operating system') . "</th>"; echo "<th>" . _n('Installation', 'Installations', Session::getPluralNumber()) . "</th>"; echo "<th>" . __('Comments') . "</th>"; echo "</tr>\n"; for ($tot = $nb = 0; $data = $DB->fetch_assoc($result); $tot += $nb) { Session::addToNavigateListItems('SoftwareVersion', $data['id']); $nb = Computer_SoftwareVersion::countForVersion($data['id']); echo "<tr class='tab_bg_2'>"; echo "<td><a href='softwareversion.form.php?id=" . $data['id'] . "'>"; echo $data['name'] . (empty($data['name']) ? "(" . $data['id'] . ")" : "") . "</a></td>"; echo "<td>" . $data['sname'] . "</td>"; echo "<td class='right'>" . Dropdown::getDropdownName('glpi_operatingsystems', $data['operatingsystems_id']); echo "</td>"; echo "<td class='numeric'>{$nb}</td>"; echo "<td>" . $data['comment'] . "</td></tr>\n"; } echo "<tr class='tab_bg_1 noHover'><td class='right b' colspan='3'>" . __('Total') . "</td>"; echo "<td class='numeric b'>{$tot}</td><td></td></tr>"; echo "</table>\n"; } else { echo "<table class='tab_cadre_fixe'>"; echo "<tr><th>" . __('No item found') . "</th></tr>"; echo "</table>\n"; } } echo "</div>"; }