InfotelGLPI / printercounters

Plugin Printercounters for GLPI
http://blogglpi.infotel.com
GNU General Public License v2.0
14 stars 9 forks source link

New pt-BR translation and Bugfixes #85

Closed eduardomozart closed 2 years ago

eduardomozart commented 3 years ago

Update search.class.php: See #69

Bugfix and pt-BR Translation: A pt_BR translation was added to the columns title of reports. There was a bug at printercountersreport4.en_GB.php that shows the title of the report as "Array" because it's translation variables was defined as an Array instead of Strings. The "%s1" and "%s2" variables was replaced by "%s" and "%s" because it was printing something like "Page number from 11-18-20201 to 11-18-20202" (note the "1" and "2" after "2020").

Update printercountersreport5.php: (Replaced by "Fix for getting IP address for printers without a Networkname") The printercountersreport5.php report was failing to generate when a printer has 2 or more Network Ports with the SQL error: "Subquery returns more than 1 row in query". It's possible a printer have 2 or more Network Ports. This bugfix uses the 'mainitemtype' column from 'glpi_ipaddresses' table instead of 'itemtype' from 'glpi_networkports' to select the row with the IP address of the printer.

New translations: Translated to pt_BR missing columns from reports.

Fix for no "Records amount" into Complementary Report: This is a complementary fix for #69. When generating the report "Complementary report", it didn't calculate the "Records amount" when a printer is into "Root Entity" because the $budget['entities_id'] value is stored as an integer into report/printercountersreport3/printercountersreport3.php. The entity ID from "Root Entity" is 0. The script printercountersreport3.php calls the function $budget->getRecordsAmountForBudget from inc\budget.class.php that calls this->getRecordAmount. The getRecordAmount function from budget.class.php checks if the $budget['entity_id'] is empty (line 556) through $budget['entities_id'] != null, but this also considerates 0 ("Root Entity" ID) as null. Changing it to !is_null($budget['entities_id']]) checks if entities_id is not null and consider the "Root Entity" ID (0) as not null. The budget button at the plug-in menu (Tools > Printer counters) and the "Complementary report" are working normally with this fix.

Fix for getting IP address for printers without a Networkname: Fix to get IP address from printers that has no entry in "glpi_networknames" table.

Fix for HP M551: See #81

Fix bugs for PHP 7.2+ and GLPI 9.5.4+:

PHP 7.2+ throws a warning if the count() function is called with non-array items, so the reports code was updated to check if $tab is an array before counting it, or returns 0 if it's not an array.

The function num_fields was deprecated with GLPI 9.5.4 and was throwing a warning into GLPI debug mode.

The "Counter records by printer" was updated to include the "Serial", "Inventory/Asset Number" and "Location" of the printer, so now it's matches PrintWayy reports style and makes it easier to identify each printer. The default filter date range was changed from 1 year to 1 month to avoid confusion for people that do tenancy of printers and pay monthly invoices, e.g. it was easier to select 01-02-2020 to 28-02-2021 (notice the Start date is 2020) instead of 01-02-2021 to 28-02-2021 (now a month was selected).