Skip to content

Commit

Permalink
add new notification target plugin credit tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bessantoy authored and cedric-anne committed Nov 10, 2023
1 parent 8feba9a commit 9d937b9
Showing 1 changed file with 25 additions and 4 deletions.
29 changes: 25 additions & 4 deletions inc/notificationtargetentity.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public function addDataForTemplate($event, $options = [])

$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');
$this->data['##credit.enddate##'] = $this->obj->getField('end_date');
$this->data['##credit.overconsumption_allowed##'] = Dropdown::getYesNo($this->obj->getField('overconsumption_allowed'));
$this->data['##credit.child_entities##'] = Dropdown::getYesNo($this->obj->getField('is_recursive'));

$req = $DB->request(
[
Expand All @@ -60,11 +63,23 @@ 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.entity##'] = Dropdown::getDropdownName(
'glpi_entities',
$this->obj->getField('entities_id')
);
$this->data['##credit.type##'] = Dropdown::getDropdownName('glpi_plugin_credit_types', $this->obj->getField('plugin_credit_types_id'));
$this->data['##lang.credit.begindate##'] = __('Begin date');
$this->data['##lang.credit.enddate##'] = __('End date', 'credit');
$this->data['##lang.credit.quantity_remaining##'] = __('Quantity remaining', 'credit');
$this->data['##lang.credit.quantity_sold##'] = __('Quantity sold', 'credit');
$this->data['##lang.credit.name##'] = PluginCreditEntity::getTypeName();
$this->data['##lang.credit.overconsumption_allowed##'] = __('Allow overconsumption', 'credit');
$this->data['##lang.credit.child_entities##'] = __('Child entities');
$this->data['##lang.credit.quantity_consumed##'] = __('Quantity consumed', 'credit');
$this->data['##lang.credit.entity##'] = Entity::getTypeName(1);
$this->data['##lang.credit.type##'] = __('Type');

$this->getTags();
foreach ($this->tag_descriptions[NotificationTarget::TAG_LANGUAGE] as $tag => $values) {
Expand All @@ -77,10 +92,16 @@ public function addDataForTemplate($event, $options = [])
public function getTags()
{
$tags = [
'credit.name' => PluginCreditEntity::getTypeName(),
'credit.quantity_sold' => __('Quantity sold', 'credit'),
'credit.enddate' => __('End date', 'credit'),
'credit.quantity_remaining' => __('Quantity remaining', 'credit'),
'credit.name' => PluginCreditEntity::getTypeName(),
'credit.quantity_sold' => __('Quantity sold', 'credit'),
'credit.begindate' => __('Begin date'),
'credit.enddate' => __('End date', 'credit'),
'credit.quantity_remaining' => __('Quantity remaining', 'credit'),
'credit.quantity_consumed' => __('Quantity consumed', 'credit'),
'credit.child_entities' => __('Child entities'),
'credit.entity' => Entity::getTypeName(1),
'credit.overconsumption_allowed' => __('Allow overconsumption', 'credit'),
'credit.type' => __('Type'),
];

foreach ($tags as $tag => $label) {
Expand Down

0 comments on commit 9d937b9

Please sign in to comment.