Software::showMergeCandidates PHP Method

showMergeCandidates() public method

Show softwares candidates to be merged with the current
public showMergeCandidates ( ) : nothing
return nothing
    function showMergeCandidates()
    {
        global $DB, $CFG_GLPI;
        $ID = $this->getField('id');
        $this->check($ID, UPDATE);
        $rand = mt_rand();
        echo "<div class='center'>";
        $sql = "SELECT `glpi_softwares`.`id`,\n                     `glpi_softwares`.`name`,\n                     `glpi_entities`.`completename` AS entity\n              FROM `glpi_softwares`\n              LEFT JOIN `glpi_entities` ON (`glpi_softwares`.`entities_id` = `glpi_entities`.`id`)\n              WHERE (`glpi_softwares`.`id` != '{$ID}'\n                     AND `glpi_softwares`.`name` = '" . addslashes($this->fields["name"]) . "'\n                     AND `glpi_softwares`.`is_deleted` = '0'\n                     AND `glpi_softwares`.`is_template` = '0' " . getEntitiesRestrictRequest('AND', 'glpi_softwares', 'entities_id', getSonsOf("glpi_entities", $this->fields["entities_id"]), false) . ")\n              ORDER BY `entity`";
        $req = $DB->request($sql);
        if ($nb = $req->numrows()) {
            $link = Toolbox::getItemTypeFormURL('Software');
            Html::openMassiveActionsForm('mass' . __CLASS__ . $rand);
            $massiveactionparams = array('num_displayed' => $nb, 'container' => 'mass' . __CLASS__ . $rand, 'specific_actions' => array(__CLASS__ . MassiveAction::CLASS_ACTION_SEPARATOR . 'merge' => __('Merge')), 'item' => $this);
            Html::showMassiveActions($massiveactionparams);
            echo "<table class='tab_cadre_fixehov'>";
            echo "<tr><th width='10'>";
            echo Html::checkAllAsCheckbox('mass' . __CLASS__ . $rand);
            echo "</th>";
            echo "<th>" . __('Name') . "</th>";
            echo "<th>" . __('Entity') . "</th>";
            echo "<th>" . _n('Installation', 'Installations', Session::getPluralNumber()) . "</th>";
            echo "<th>" . _n('License', 'Licenses', Session::getPluralNumber()) . "</th></tr>";
            foreach ($req as $data) {
                echo "<tr class='tab_bg_2'>";
                echo "<td>" . Html::getMassiveActionCheckBox(__CLASS__, $data["id"]) . "</td>";
                echo "<td><a href='" . $link . "?id=" . $data["id"] . "'>" . $data["name"] . "</a></td>";
                echo "<td>" . $data["entity"] . "</td>";
                echo "<td class='right'>" . Computer_SoftwareVersion::countForSoftware($data["id"]) . "</td>";
                echo "<td class='right'>" . SoftwareLicense::countForSoftware($data["id"]) . "</td></tr>\n";
            }
            echo "</table>\n";
            $massiveactionparams['ontop'] = false;
            Html::showMassiveActions($massiveactionparams);
            Html::closeForm();
        } else {
            _e('No item found');
        }
        echo "</div>";
    }