Skip to content
Merged
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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion inc/entity.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -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')],
],
);

Expand Down
39 changes: 37 additions & 2 deletions inc/notificationtargetentity.class.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
<?php

/**
* -------------------------------------------------------------------------
* Credit plugin for GLPI
* -------------------------------------------------------------------------
*
* LICENSE
*
* This file is part of Credit.
*
* Credit is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Credit is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Credit. If not, see <http://www.gnu.org/licenses/>.
* -------------------------------------------------------------------------
* @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
* -------------------------------------------------------------------------
*/



/**
* -------------------------------------------------------------------------
* Credit plugin for GLPI
Expand Down Expand Up @@ -44,6 +75,10 @@ public function addDataForTemplate($event, $options = [])
/** @var DBmysql $DB */
global $DB;

if (!($this->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');
Expand All @@ -63,8 +98,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',
Expand Down