Skip to content

Commit 47d76df

Browse files
authored
fix(TCO): missing ticket_tco field in table object (#397)
* fix(TCO): missing ticket_tco field in table object * fix: remove TCO field in object form * fix lint * add migration infocoms * fix migration * Update CHANGELOG.md
1 parent 95527b8 commit 47d76df

File tree

5 files changed

+16
-3
lines changed

5 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1010
### Fixed
1111

1212
- Improve global performance when using many genericobject
13+
- The `TCO` (Total Cost of Ownership) is now correctly updated based on the costs associated with an item.
1314

1415
## [2.14.11] - 2024-12-27
1516

fields/field.constant.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@
116116
$GO_FIELDS['is_helpdesk_visible']['name'] = __("Associable to a ticket");
117117
$GO_FIELDS['is_helpdesk_visible']['input_type'] = 'bool';
118118

119+
$GO_FIELDS['ticket_tco']['name'] = __("TCO");
120+
$GO_FIELDS['ticket_tco']['input_type'] = 'decimal';
121+
119122
$GO_FIELDS['locations_id']['name'] = __("Item location");
120123
$GO_FIELDS['locations_id']['input_type'] = 'dropdown';
121124

inc/object.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ public function showForm($id, $options = [], $previsualisation = false)
649649
public static function getFieldsToHide()
650650
{
651651
return ['id', 'is_recursive', 'is_template', 'template_name', 'is_deleted',
652-
'entities_id', 'notepad', 'date_mod', 'date_creation'
652+
'entities_id', 'notepad', 'date_mod', 'date_creation', 'ticket_tco'
653653
];
654654
}
655655

inc/type.class.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,6 +1101,7 @@ public function checkNecessaryFieldsUpdate()
11011101
if ($this->canUseTickets()) {
11021102
//TODO rename is_helpdesk_visible into is_helpdeskvisible
11031103
PluginGenericobjectField::addNewField($table, 'is_helpdesk_visible', 'comment');
1104+
PluginGenericobjectField::addNewField($table, 'ticket_tco');
11041105
} else {
11051106
PluginGenericobjectField::deleteField($table, 'is_helpdesk_visible');
11061107
}
@@ -2485,6 +2486,14 @@ public static function install(Migration $migration)
24852486
$preference->add($tmp);
24862487
}
24872488
}
2489+
2490+
$types = new self();
2491+
$object_use_infocoms = $types->find(['use_infocoms' => 1]);
2492+
foreach ($object_use_infocoms as $object) {
2493+
$object_table = $object['itemtype']::getTable();
2494+
$migration->addField($object_table, "ticket_tco", "decimal");
2495+
$migration->migrationOneTable($object_table);
2496+
}
24882497
}
24892498

24902499

setup.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,12 @@ function plugin_init_genericobject()
117117
global $PLUGIN_HOOKS, $GO_BLACKLIST_FIELDS,
118118
$GENERICOBJECT_PDF_TYPES, $GO_LINKED_TYPES, $GO_READONLY_FIELDS, $CFG_GLPI;
119119

120-
$GO_READONLY_FIELDS = ["is_helpdesk_visible", "comment"];
120+
$GO_READONLY_FIELDS = ["is_helpdesk_visible", "comment", "ticket_tco"];
121121

122122
$GO_BLACKLIST_FIELDS = ["itemtype", "table", "is_deleted", "id", "entities_id",
123123
"is_recursive", "is_template", "notepad", "template_name",
124124
"date_mod", "name", "is_helpdesk_visible", "comment",
125-
"date_creation"
125+
"date_creation", "ticket_tco"
126126
];
127127

128128
$GO_LINKED_TYPES = ['Computer', 'Phone', 'Peripheral', 'Software', 'Monitor',

0 commit comments

Comments
 (0)