4 Copyright (C) 2014 AUF -- www.auf.org
6 if (!defined('GLPI_ROOT')) {
7 die("Sorry. You can't access directly to this file");
10 class PluginAufComputer
extends CommonDBTM
{
12 static function canCreate() {
13 if (isset($_SESSION["glpi_plugin_auf_profile"])) {
14 return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w');
19 static function canView() {
20 if (isset($_SESSION["glpi_plugin_auf_profile"])) {
21 return ($_SESSION["glpi_plugin_auf_profile"]['auf'] == 'w'
22 ||
$_SESSION["glpi_plugin_auf_profile"]['auf'] == 'r');
27 function createInfos($ID) {
28 $this->add(array('id' => $ID));
31 function getTabNameForItem(CommonGLPI
$item, $withtemplate=0) {
32 if ($item->getType() == 'Computer') {
38 static function displayTabContentForItem(CommonGLPI
$item, $tabnum=1, $withtemplate=0) {
39 if ($item->getType() == 'Computer') {
41 $computer = new self();
42 // si la machine n'existe pas dans la base, je l'ajoute
43 if (!$computer->GetfromDB($ID)) {
44 $computer->createInfos($ID);
46 $computer->showForm($ID);
51 function showForm($id, $options=array()) {
52 $target = $this->getFormURL();
53 if (isset($options['target'])) {
54 $target = $options['target'];
57 if (!Session
::haveRight("computer", "r")) {
61 $canedit = Session
::haveRight("computer", "w");
62 $computer = new Computer();
64 $this->getFromDB($id);
65 $computer->getFromDB($id);
68 echo "<form action='".$target."' method='post'>";
69 echo "<table class='tab_cadre_fixe'>";
70 echo "<tr><th colspan='4'>Infos AUF</th></tr>";
72 echo "<tr class='tab_bg_1'>";
73 echo "<td>Catégorie</td><td>";
74 // $elements = getDataFromTable("glpi_plugin_auf_categories");
75 $elements = array("0"=>"-----", "1"=>"Infrastructure", "2"=>"Poste interne", "3"=>"Poste public");
76 Dropdown
::showFromArray("auf_categories_id", $elements,
77 array("value" => $this->fields
["auf_categories_id"]));
79 echo "<td>Utilisation</td><td>";
80 // $elements = getDataFromTable("glpi_plugin_auf_utilisations");
81 $elements = array("0"=>"-----", "1"=>"Production", "2"=>"Test", "3"=>"Réserve (stock, mission, formation, …)");
82 Dropdown
::showFromArray("auf_utilisations_id", $elements,
83 array("value" => $this->fields
["auf_utilisations_id"]));
87 echo "<tr class='tab_bg_1'>";
88 echo "<td>Machine virtuelle</td><td>";
89 Dropdown
::showYesNo('est_virtuel', $this->fields
["est_virtuel"]);
91 echo "<td>Année d'acquisition</td><td>";
92 echo "<input size='4' name='annee_acquisition' value='".$this->fields
["annee_acquisition"]."' />";
97 echo "<tr class='tab_bg_1'>";
98 echo "<td class='center' colspan='4'>";
99 echo "<input type='hidden' name='id' value=$id>";
100 echo "<input type='submit' name='update_computer' value='Mettre à jour' class='submit'>";