Skip to content

Commit 0dde280

Browse files
trasherorthagh
authored andcommitted
Display OS infos in its own tab (glpi-project#921)
* Drop executable bit * Ignore coverage directory * Move operating system in its own tab; refs glpi-project#919
1 parent f538b51 commit 0dde280

File tree

3 files changed

+111
-85
lines changed

3 files changed

+111
-85
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
/vendor/
1515
/nbproject/private/
1616
phpunit.xml
17+
/coverage/

inc/computer.class.php

+110-85
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,20 @@ static function getTypeName($nb=0) {
6767
}
6868

6969

70+
/**
71+
* @see CommonGLPI::getTabNameForItem()
72+
**/
73+
function getTabNameForItem(CommonGLPI $item, $withtemplate=0) {
74+
if (static::canView()) {
75+
switch ($item->getType()) {
76+
case __CLASS__ :
77+
$ong = array(1 => __('Operating System'));
78+
return $ong;
79+
}
80+
}
81+
}
82+
83+
7084
/**
7185
* @see CommonDBTM::useDeletedToLockIfDynamic()
7286
*
@@ -94,6 +108,7 @@ function defineTabs($options=array()) {
94108

95109
$ong = array();
96110
$this->addDefaultFormTab($ong)
111+
->addStandardTab(__CLASS__, $ong, $options)
97112
->addStandardTab('Item_Devices', $ong, $options)
98113
->addStandardTab('ComputerDisk', $ong, $options)
99114
->addStandardTab('Computer_SoftwareVersion', $ong, $options)
@@ -117,6 +132,88 @@ function defineTabs($options=array()) {
117132
}
118133

119134

135+
/**
136+
* @param $item CommonGLPI object
137+
* @param $tabnum (default 1)
138+
* @param $withtemplate (default 0)
139+
**/
140+
static function displayTabContentForItem(CommonGLPI $item, $tabnum=1, $withtemplate=0) {
141+
142+
self::showOperatingSystem($item);
143+
return true;
144+
}
145+
146+
/**
147+
* Print the computer's operating system form
148+
*
149+
* @param $comp Computer object
150+
*
151+
* @return Nothing (call to classes members)
152+
**/
153+
static function showOperatingSystem(Computer $comp) {
154+
global $DB;
155+
156+
$ID = $comp->fields['id'];
157+
$colspan = 4;
158+
159+
echo "<div class='center'>";
160+
161+
$comp->initForm($ID);
162+
$comp->showFormHeader();
163+
164+
echo "<table class='tab_cadre_fixe'>";
165+
166+
echo "<tr class='headerRow'><th colspan='".$colspan."'>";
167+
echo __('Operating system');
168+
echo "</th></tr>";
169+
170+
echo "<tr class='tab_bg_1'>";
171+
echo "<td>".__('Name')."</td>";
172+
echo "<td>";
173+
OperatingSystem::dropdown(array('value' => $comp->fields["operatingsystems_id"]));
174+
echo "</td>";
175+
176+
echo "<td>".__('Version')."</td>";
177+
echo "<td >";
178+
OperatingSystemVersion::dropdown(array('value' => $comp->fields["operatingsystemversions_id"]));
179+
echo "</td>";
180+
echo "</tr>";
181+
182+
echo "<tr class='tab_bg_1'>";
183+
echo "<td>".__('Architecture')."</td>";
184+
echo "<td >";
185+
OperatingSystemArchitecture::dropdown(array('value'
186+
=> $comp->fields["operatingsystemarchitectures_id"]));
187+
echo "</td>";
188+
189+
echo "<td>".__('Service pack')."</td>";
190+
echo "<td >";
191+
OperatingSystemServicePack::dropdown(array('value'
192+
=> $comp->fields["operatingsystemservicepacks_id"]));
193+
echo "</td></tr>";
194+
195+
echo "<tr class='tab_bg_1'>";
196+
echo "<td>".__('Kernel version')."</td>";
197+
echo "<td >";
198+
Html::autocompletionTextField($comp, 'os_kernel_version');
199+
echo "</td>";
200+
201+
echo "<td>".__('Product ID')."</td>";
202+
echo "<td >";
203+
Html::autocompletionTextField($comp, 'os_licenseid');
204+
echo "</td></tr>";
205+
206+
echo "<tr class='tab_bg_1'>";
207+
echo "<td>".__('Serial number')."</td>";
208+
echo "<td >";
209+
Html::autocompletionTextField($comp, 'os_license_number');
210+
echo "</td></tr>";
211+
212+
$comp->showFormButtons();
213+
214+
echo "</table>";
215+
echo "</div>";
216+
}
120217
function post_restoreItem() {
121218

122219
$comp_softvers = new Computer_SoftwareVersion();
@@ -528,14 +625,13 @@ function showForm($ID, $options=array()) {
528625
echo "</td>";
529626

530627
// Display auto inventory informations
531-
$rowspan = 7;
628+
$rowspan = 4;
532629
$inventory_show = false;
533630

534631
if (!empty($ID)
535632
&& Plugin::haveImport()
536633
&& $this->fields["is_dynamic"]) {
537634
$inventory_show = true;
538-
$rowspan -= 5;
539635
}
540636

541637
echo "<td rowspan='$rowspan'>".__('Comments')."</td>";
@@ -552,89 +648,6 @@ function showForm($ID, $options=array()) {
552648
'entity' => $this->fields["entities_id"]));
553649
echo "</td></tr>";
554650

555-
echo "<tr class='tab_bg_1'>";
556-
echo "<td>".__('Operating system')."</td>";
557-
echo "<td>";
558-
OperatingSystem::dropdown(array('value' => $this->fields["operatingsystems_id"]));
559-
echo "<br /><a href='#' id='toggle_os_information'>".__("More information")."</a>";
560-
echo "</td>";
561-
if ($inventory_show) {
562-
echo "<td rowspan='5' colspan='2'>";
563-
Plugin::doHook("autoinventory_information", $this);
564-
echo "</td>";
565-
}
566-
echo "</tr>";
567-
568-
echo "<tr class='tab_bg_1'>";
569-
echo "<td>".__('Version of the operating system')."</td>";
570-
echo "<td >";
571-
OperatingSystemVersion::dropdown(array('value' => $this->fields["operatingsystemversions_id"]));
572-
echo "</td>";
573-
echo "</tr>";
574-
575-
echo "<tr class='tab_bg_1'><td colspan='2'>";
576-
echo Html::scriptBlock("
577-
$(document).ready(function(){
578-
$('#os_information').hide();
579-
580-
$('#toggle_os_information').on('click',function() {
581-
$('#os_information').dialog({
582-
width:'auto',
583-
resizable: false,
584-
appendTo: '#os_information_parent',
585-
position: {
586-
my : 'left top',
587-
at : 'left bottom',
588-
of: $('#toggle_os_information')
589-
}
590-
})
591-
})
592-
});");
593-
594-
// group os advanced information in a single bloc (who can be toggled)
595-
echo "<div id='os_information_parent'>";
596-
echo "<div id='os_information' title=\"".__('Operating system')."\">";
597-
echo "<table>";
598-
echo "<tr class='tab_bg_1'>";
599-
600-
echo "<td>".__('Service pack')."</td>";
601-
echo "<td >";
602-
OperatingSystemServicePack::dropdown(array('value'
603-
=> $this->fields["operatingsystemservicepacks_id"]));
604-
echo "</td></tr>";
605-
606-
echo "<tr class='tab_bg_1'>";
607-
echo "<td>".__('Operating system architecture')."</td>";
608-
echo "<td >";
609-
OperatingSystemArchitecture::dropdown(array('value'
610-
=> $this->fields["operatingsystemarchitectures_id"]));
611-
echo "</td></tr>";
612-
613-
echo "<tr class='tab_bg_1'>";
614-
echo "<td>".__('Kernel version of the operating system')."</td>";
615-
echo "<td >";
616-
Html::autocompletionTextField($this, 'os_kernel_version');
617-
echo "</td></tr>";
618-
619-
echo "<tr class='tab_bg_1'>";
620-
echo "<td>".__('Product ID of the operating system')."</td>";
621-
echo "<td >";
622-
Html::autocompletionTextField($this, 'os_licenseid');
623-
echo "</td></tr>";
624-
625-
echo "<tr class='tab_bg_1'>";
626-
echo "<td>".__('Serial of the operating system')."</td>";
627-
echo "<td >";
628-
Html::autocompletionTextField($this, 'os_license_number');
629-
echo "</td>";
630-
631-
632-
echo "</table>";
633-
echo "</div>";
634-
echo "</div>";
635-
echo "</td>";
636-
echo "</tr>";
637-
638651
echo "<tr class='tab_bg_1'>";
639652
echo "<td>".__('UUID')."</td>";
640653
echo "<td >";
@@ -648,6 +661,18 @@ function showForm($ID, $options=array()) {
648661
AutoUpdateSystem::dropdown(array('value' => $this->fields["autoupdatesystems_id"]));
649662
echo "</td></tr>";
650663

664+
665+
if (Plugin::haveImport() && $inventory_show) {
666+
//echo "<td>".__('Automatic inventory')."</td>";
667+
echo '<tr><td colspan="4">';
668+
if ($ID && $this->fields['is_dynamic']) {
669+
Plugin::doHook("autoinventory_information", $this);
670+
} else {
671+
_e('No');
672+
}
673+
echo "</td></tr>";
674+
}
675+
651676
$this->showFormButtons($options);
652677

653678
return true;

inc/tasktemplate.class.php

100755100644
File mode changed.

0 commit comments

Comments
 (0)