Get number of bought licenses of a version
static public countForVersion ( $softwareversions_id, $entity = '' ) : number | ||
$softwareversions_id | version ID | |
$entity | to search for licenses in (default = all active entities) (default '') | |
리턴 | number | of installations |
/** * Print the Software / version form * * @param $ID Integer : Id of the version or the template to print * @param $options array * - target form target * - softwares_id ID of the software for add process * * @return true if displayed false if item not found or not right to display * **/ function showForm($ID, $options = array()) { global $CFG_GLPI, $LANG; $softwares_id = -1; if (isset($options['softwares_id'])) { $softwares_id = $options['softwares_id']; } if (!haveRight("software", "r")) { return false; } if ($ID > 0) { $this->check($ID, 'r'); } else { $soft = new Software(); $soft->getFromDB($softwares_id); // Create item $input = array('entities_id' => $soft->getEntityID(), 'is_recursive' => $soft->isRecursive()); $this->check(-1, 'w', $input); } $this->showTabs($options); $this->showFormHeader($options); echo "<tr class='tab_bg_1'><td>" . $LANG['help'][31] . " :</td>"; echo "<td>"; if ($ID > 0) { $softwares_id = $this->fields["softwares_id"]; } else { echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>"; } echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>"; echo "</td>"; echo "<td rowspan='4' class='middle'>" . $LANG['common'][25] . " :</td>"; echo "<td class='center middle' rowspan='4'>"; echo "<textarea cols='45' rows='3' name='comment' >" . $this->fields["comment"]; echo "</textarea></td></tr>\n"; echo "<tr class='tab_bg_1'><td>" . $LANG['common'][16] . " :</td>"; echo "<td>"; autocompletionTextField($this, "name"); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td>" . $LANG['setup'][5] . " :</td><td>"; Dropdown::show('OperatingSystem', array('value' => $this->fields["operatingsystems_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td>" . $LANG['state'][0] . " :</td><td>"; Dropdown::show('State', array('value' => $this->fields["states_id"])); echo "</td></tr>\n"; // Only count softwareversions_id_buy (don't care of softwareversions_id_use if no installation) if (SoftwareLicense::countForVersion($ID) > 0 || Computer_SoftwareVersion::countForVersion($ID) > 0) { $options['candel'] = false; } $this->showFormButtons($options); $this->addDivForTabs(); return true; }
/** * Print the Software / version form * * @param $ID integer Id of the version or the template to print * @param $options array of possible options: * - target form target * - softwares_id ID of the software for add process * * @return true if displayed false if item not found or not right to display * **/ function showForm($ID, $options = array()) { global $CFG_GLPI; if ($ID > 0) { $this->check($ID, READ); $softwares_id = $this->fields['softwares_id']; } else { $softwares_id = $options['softwares_id']; $this->check(-1, CREATE, $options); } $this->showFormHeader($options); echo "<tr class='tab_bg_1'><td>" . _n('Software', 'Software', Session::getPluralNumber()) . "</td>"; echo "<td>"; if ($this->isNewID($ID)) { echo "<input type='hidden' name='softwares_id' value='{$softwares_id}'>"; } echo "<a href='software.form.php?id=" . $softwares_id . "'>" . Dropdown::getDropdownName("glpi_softwares", $softwares_id) . "</a>"; echo "</td>"; echo "<td rowspan='4' class='middle'>" . __('Comments') . "</td>"; echo "<td class='center middle' rowspan='4'>"; echo "<textarea cols='45' rows='3' name='comment' class='form-control'>" . $this->fields["comment"]; echo "</textarea></td></tr>\n"; echo "<tr class='tab_bg_1'><td>" . __('Name') . "</td>"; echo "<td>"; Html::autocompletionTextField($this, "name"); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td>" . __('Operating system') . "</td><td>"; OperatingSystem::dropdown(array('value' => $this->fields["operatingsystems_id"])); echo "</td></tr>\n"; echo "<tr class='tab_bg_1'><td>" . __('Status') . "</td><td>"; State::dropdown(array('value' => $this->fields["states_id"], 'entity' => $this->fields["entities_id"], 'condition' => "`is_visible_softwareversion`")); echo "</td></tr>\n"; // Only count softwareversions_id_buy (don't care of softwareversions_id_use if no installation) if (SoftwareLicense::countForVersion($ID) > 0 || Computer_SoftwareVersion::countForVersion($ID) > 0) { $options['candel'] = false; } $this->showFormButtons($options); return true; }