Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Manage the paperroll like a cartridge #2788

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions inc/formatconvert.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2321,6 +2321,18 @@ static function printerInventoryTransformation($array) {
$pfMapping = new PluginFusioninventoryMapping();

foreach ($array['CARTRIDGES'] as $name => $value) {
// Special case for paper roll
if (is_array($value)) {
if ($name == 'PAPERROLL') {
$plugin_fusioninventory_mappings = $pfMapping->get("Printer", 'paperrollinches');
$a_inventory['cartridge'][$plugin_fusioninventory_mappings['id']] = $value['INCHES'];

$plugin_fusioninventory_mappings = $pfMapping->get("Printer", 'paperrollcentimeters');
$a_inventory['cartridge'][$plugin_fusioninventory_mappings['id']] = $value['CENTIMETERS'];
}
continue;
}

$plugin_fusioninventory_mappings = $pfMapping->get("Printer", strtolower($name));
if ($plugin_fusioninventory_mappings) {
if (strstr($value, 'pages')) { // 30pages
Expand Down
6 changes: 6 additions & 0 deletions inc/mapping.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,12 @@ function getTranslation ($mapping) {
case 196:
return __('Grey ink cartridge', 'fusioninventory');

case 197:
return __('Paper roll in inches', 'fusioninventory');

case 198:
return __('Paper roll in centimeters', 'fusioninventory');

case 1423:
return __('Total number of printed pages (print)', 'fusioninventory');

Expand Down
4 changes: 4 additions & 0 deletions inc/printercartridge.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,10 @@ function showForm(Printer $item, $options = []) {
$a_cartridge['state'] = $a_cartridge['state'] * -1;
echo $a_cartridge['state'];
echo ' '.__('remaining pages', 'fusioninventory');
} else if ($mapping->fields['name'] == 'paperrollinches') {
echo $a_cartridge['state']." inches";
} else if ($mapping->fields['name'] == 'paperrollcentimeters') {
echo $a_cartridge['state']." centimeters";
} else {
PluginFusioninventoryDisplay::bar($a_cartridge['state']);
}
Expand Down
2 changes: 2 additions & 0 deletions install/mysql/plugin_fusioninventory-empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1351,6 +1351,8 @@ INSERT INTO `glpi_plugin_fusioninventory_mappings`
('Printer','drumyellowmax','','',187,187),
('Printer','drumyellowused','','',188,188),
('Printer','drumyellowremaining','','',189,189),
('Printer','paperrollinches','','',197,197),
('Printer','paperrollcentimeters','','',198,198),
-- Printers : Counter pages
('Printer','pagecountertotalpages','glpi_plugin_fusioninventory_printerlogs',
'pages_total',28,128),
Expand Down
17 changes: 17 additions & 0 deletions install/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -8174,6 +8174,23 @@ function pluginFusioninventoryUpdatemapping() {
$a_input['locale'] = 407;
$pfMapping->set($a_input);

$a_input = [];
$a_input['itemtype'] = 'Printer';
$a_input['name'] = 'paperrollinches';
$a_input['table'] = '';
$a_input['tablefield'] = '';
$a_input['locale'] = 197;
$a_input['shortlocale'] = 197;
$pfMapping->set($a_input);

$a_input = [];
$a_input['itemtype'] = 'Printer';
$a_input['name'] = 'paperrollcentimeters';
$a_input['table'] = '';
$a_input['tablefield'] = '';
$a_input['locale'] = 198;
$a_input['shortlocale'] = 198;
$pfMapping->set($a_input);
}


Expand Down