From f8f67785ba85609fc5a5fd68b2a609cd1c139dfd Mon Sep 17 00:00:00 2001 From: Stanislas Kita Date: Thu, 18 Dec 2025 12:17:35 +0100 Subject: [PATCH 1/4] Fix(Cron): fix SQL query error --- CHANGELOG.md | 6 ++++++ inc/entity.class.php | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f2a2c23..fb77f34 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [UNRELEASED] + +### Fixed + +- Fix SQL error for `lowcredits` task + ## [1.15.1] - 2025-11-18 ### Fixed diff --git a/inc/entity.class.php b/inc/entity.class.php index 7918381..f67849f 100644 --- a/inc/entity.class.php +++ b/inc/entity.class.php @@ -457,7 +457,7 @@ public static function cronLowCredits($task) 'glpi_plugin_credit_entities.is_active' => 1, ], 'GROUPBY' => 'glpi_plugin_credit_entities.id', - 'HAVING' => new QueryExpression('glpi_plugin_credit_entities.quantity - quantity_consumed <= (glpi_plugin_credit_entities.quantity * glpi_plugin_credit_entities.low_credit_alert) / 100'), + 'HAVING' => [new QueryExpression('glpi_plugin_credit_entities.quantity - quantity_consumed <= (glpi_plugin_credit_entities.quantity * glpi_plugin_credit_entities.low_credit_alert) / 100')], ], ); From a0d383f774520671da50cf63b8e0f140d04507c4 Mon Sep 17 00:00:00 2001 From: Stanislas Kita Date: Fri, 19 Dec 2025 09:32:03 +0100 Subject: [PATCH 2/4] fix CS --- inc/notificationtargetentity.class.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/inc/notificationtargetentity.class.php b/inc/notificationtargetentity.class.php index b4ad989..7ec00a8 100644 --- a/inc/notificationtargetentity.class.php +++ b/inc/notificationtargetentity.class.php @@ -1,5 +1,7 @@ obj instanceof CommonDBTM)) { + return; + } + $this->data['##credit.name##'] = $this->obj->getField('name'); $this->data['##credit.quantity_sold##'] = $this->obj->getField('quantity'); $this->data['##credit.begindate##'] = $this->obj->getField('begin_date'); @@ -63,8 +69,8 @@ public function addDataForTemplate($event, $options = []) ], ); $data = $req->current(); - $this->data['##credit.quantity_remaining##'] = (int) $this->obj->getField('quantity') - (int) $data['consumed_total']; - $this->data['##credit.quantity_consumed##'] = (int) $data['consumed_total']; + $this->data['##credit.quantity_remaining##'] = (string) ((int) $this->obj->getField('quantity') - (int) $data['consumed_total']); + $this->data['##credit.quantity_consumed##'] = (string) $data['consumed_total']; $this->data['##credit.entity##'] = Dropdown::getDropdownName( 'glpi_entities', From 4727ff237b3269f0389b9dc351ab2953771feb32 Mon Sep 17 00:00:00 2001 From: Stanislas Kita Date: Fri, 19 Dec 2025 09:36:59 +0100 Subject: [PATCH 3/4] fix header --- inc/notificationtargetentity.class.php | 29 ++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/inc/notificationtargetentity.class.php b/inc/notificationtargetentity.class.php index 7ec00a8..7d46286 100644 --- a/inc/notificationtargetentity.class.php +++ b/inc/notificationtargetentity.class.php @@ -1,5 +1,34 @@ . + * ------------------------------------------------------------------------- + * @author François Legastelois + * @copyright Copyright (C) 2017-2023 by Credit plugin team. + * @license GPLv3 https://www.gnu.org/licenses/gpl-3.0.html + * @link https://github.com/pluginsGLPI/credit + * ------------------------------------------------------------------------- + */ + use Glpi\Plugin\Formcreator\Common; /** From 2f52f83f4306755e7f70ee7b54eadd95f2900999 Mon Sep 17 00:00:00 2001 From: Stanislas Kita Date: Fri, 19 Dec 2025 09:44:34 +0100 Subject: [PATCH 4/4] fixrector --- inc/notificationtargetentity.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/inc/notificationtargetentity.class.php b/inc/notificationtargetentity.class.php index 7d46286..44e839b 100644 --- a/inc/notificationtargetentity.class.php +++ b/inc/notificationtargetentity.class.php @@ -29,7 +29,7 @@ * ------------------------------------------------------------------------- */ -use Glpi\Plugin\Formcreator\Common; + /** * -------------------------------------------------------------------------