static function pdfForSoftware(PluginPdfSimplePDF $pdf, Software $item) { global $DB; $sID = $item->getField('id'); $query = "SELECT `glpi_softwareversions`.*,\n `glpi_states`.`name` AS sname,\n `glpi_operatingsystems`.`name` AS osname\n FROM `glpi_softwareversions`\n LEFT JOIN `glpi_states`\n ON (`glpi_states`.`id` = `glpi_softwareversions`.`states_id`)\n LEFT JOIN `glpi_operatingsystems`\n ON (`glpi_operatingsystems`.`id` = `glpi_softwareversions`.`operatingsystems_id`)\n WHERE (`softwares_id` = '" . $sID . "')\n ORDER BY `name`"; $pdf->setColumnsSize(100); $pdf->displayTitle('<b>' . SoftwareVersion::getTypeName(2) . '</b>'); if ($result = $DB->query($query)) { if ($DB->numrows($result) > 0) { $pdf->setColumnsSize(13, 13, 30, 14, 30); $pdf->displayTitle('<b><i>' . SoftwareVersion::getTypeName(2) . '</i></b>', '<b><i>' . __('Status') . '</i></b>', '<b><i>' . __('Operating system') . '</i></b>', '<b><i>' . _n('Installation', 'Installations', 2) . '</i></b>', '<b><i>' . __('Comments') . '</i></b>'); $pdf->setColumnsAlign('left', 'left', 'left', 'right', 'left'); for ($tot = $nb = 0; $data = $DB->fetch_assoc($result); $tot += $nb) { $nb = Computer_SoftwareVersion::countForVersion($data['id']); $pdf->displayLine(empty($data['name']) ? "(" . $data['id'] . ")" : $data['name'], $data['sname'], $data['osname'], $nb, str_replace(array("\r", "\n"), " ", $data['comment'])); } $pdf->setColumnsAlign('left', 'right', 'left', 'right', 'left'); $pdf->displayTitle('', '', "<b>" . sprintf(__('%1$s: %2$s'), __('Total') . "</b>", ''), $tot, ''); } else { $pdf->displayLine(__('No item found')); } } else { $pdf->displayLine(__('No item found')); } $pdf->displaySpace(); }
/** * Get search function for the class * * @since version 0.85 * * @return array of search option **/ function getSearchOptions() { $tab = parent::getSearchOptions(); $tab[21]['table'] = $this->getTable(); $tab[21]['field'] = 'is_visible_computer'; $tab[21]['name'] = sprintf(__('%1$s - %2$s'), __('Visibility'), Computer::getTypeName(Session::getPluralNumber())); $tab[21]['datatype'] = 'bool'; $tab[22]['table'] = $this->getTable(); $tab[22]['field'] = 'is_visible_softwareversion'; $tab[22]['name'] = sprintf(__('%1$s - %2$s'), __('Visibility'), SoftwareVersion::getTypeName(Session::getPluralNumber())); $tab[22]['datatype'] = 'bool'; $tab[23]['table'] = $this->getTable(); $tab[23]['field'] = 'is_visible_monitor'; $tab[23]['name'] = sprintf(__('%1$s - %2$s'), __('Visibility'), Monitor::getTypeName(Session::getPluralNumber())); $tab[23]['datatype'] = 'bool'; $tab[24]['table'] = $this->getTable(); $tab[24]['field'] = 'is_visible_printer'; $tab[24]['name'] = sprintf(__('%1$s - %2$s'), __('Visibility'), Printer::getTypeName(Session::getPluralNumber())); $tab[24]['datatype'] = 'bool'; $tab[25]['table'] = $this->getTable(); $tab[25]['field'] = 'is_visible_peripheral'; $tab[25]['name'] = sprintf(__('%1$s - %2$s'), __('Visibility'), Peripheral::getTypeName(Session::getPluralNumber())); $tab[25]['datatype'] = 'bool'; $tab[26]['table'] = $this->getTable(); $tab[26]['field'] = 'is_visible_phone'; $tab[26]['name'] = sprintf(__('%1$s - %2$s'), __('Visibility'), Phone::getTypeName(Session::getPluralNumber())); $tab[26]['datatype'] = 'bool'; $tab[27]['table'] = $this->getTable(); $tab[27]['field'] = 'is_visible_networkequipment'; $tab[27]['name'] = sprintf(__('%1$s - %2$s'), __('Visibility'), NetworkEquipment::getTypeName(Session::getPluralNumber())); $tab[27]['datatype'] = 'bool'; return $tab; }
} if (!isset($_GET["softwares_id"])) { $_GET["softwares_id"] = ""; } $version = new SoftwareVersion(); if (isset($_POST["add"])) { $version->check(-1, CREATE, $_POST); if ($newID = $version->add($_POST)) { Event::log($_POST['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s adds the version %2$s'), $_SESSION["glpiname"], $newID)); Html::redirect($CFG_GLPI["root_doc"] . "/front/software.form.php?id=" . $version->fields['softwares_id']); } Html::back(); } else { if (isset($_POST["purge"])) { $version->check($_POST['id'], PURGE); $version->delete($_POST, 1); Event::log($version->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s purges the version %2$s'), $_SESSION["glpiname"], $_POST["id"])); $version->redirectToList(); } else { if (isset($_POST["update"])) { $version->check($_POST['id'], UPDATE); $version->update($_POST); Event::log($version->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s updates the version %2$s'), $_SESSION["glpiname"], $_POST["id"])); Html::back(); } else { Html::header(SoftwareVersion::getTypeName(Session::getPluralNumber()), $_SERVER['PHP_SELF'], "assets", "software"); $version->display(array('id' => $_GET["id"], 'softwares_id' => $_GET["softwares_id"])); Html::footer(); } } }
} if (!isset($_GET["softwares_id"])) { $_GET["softwares_id"] = ""; } $version = new SoftwareVersion(); if (isset($_POST["add"])) { $version->check(-1, 'w', $_POST); if ($newID = $version->add($_POST)) { Event::log($_POST['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s adds the version %2$s'), $_SESSION["glpiname"], $newID)); Html::redirect($CFG_GLPI["root_doc"] . "/front/software.form.php?id=" . $version->fields['softwares_id']); } Html::back(); } else { if (isset($_POST["delete"])) { $version->check($_POST['id'], 'd'); $version->delete($_POST); Event::log($version->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s deletes the version %2$s'), $_SESSION["glpiname"], $_POST["id"])); $version->redirectToList(); } else { if (isset($_POST["update"])) { $version->check($_POST['id'], 'w'); $version->update($_POST); Event::log($version->fields['softwares_id'], "software", 4, "inventory", sprintf(__('%1$s updates the version %2$s'), $_SESSION["glpiname"], $_POST["id"])); Html::back(); } else { Html::header(SoftwareVersion::getTypeName(2), $_SERVER['PHP_SELF'], "inventory", "software"); $version->showForm($_GET["id"], array('softwares_id' => $_GET["softwares_id"])); Html::footer(); } } }
/** * @see CommonGLPI::getTabNameForItem() **/ function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { switch ($item->getType()) { case 'Software': if (!$withtemplate) { if ($_SESSION['glpishow_count_on_tabs']) { return self::createTabEntry(self::getTypeName(2), self::countForSoftware($item->getID())); } return self::getTypeName(2); } break; case 'SoftwareVersion': if (!$withtemplate) { $nb = 0; if ($_SESSION['glpishow_count_on_tabs']) { $nb = self::countForVersion($item->getID()); } return array(1 => SoftwareVersion::getTypeName(1), 2 => self::createTabEntry(self::getTypeName(2), $nb)); } break; case 'Computer': // Installation allowed for template if (Session::haveRight("software", "r")) { if ($_SESSION['glpishow_count_on_tabs']) { return self::createTabEntry(Software::getTypeName(2), countElementsInTable('glpi_computers_softwareversions', "computers_id = '" . $item->getID() . "'\n AND `is_deleted`='0'")); } return Software::getTypeName(2); } break; } return ''; }