Skip to content

Commit

Permalink
Merge branch 'release/1.4.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
cedric-anne committed Sep 10, 2018
2 parents 90eff18 + 60d998c commit fa824a2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 2 deletions.
26 changes: 26 additions & 0 deletions hook.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,3 +79,29 @@ function plugin_credit_getDropdown() {
Session::getPluralNumber(),
'credit')];
}

function plugin_credit_get_datas(NotificationTargetTicket $target) {

global $DB;

$target->data['##lang.credit.voucher##'] = __('Credit voucher', 'credit');
$target->data['##lang.credit.used##'] = __('Quantity consumed', 'credit');
$target->data['##lang.credit.left##'] = __('Quantity remaining', 'credit');

$id = $target->data['##ticket.id##'];

$query = "SELECT
`glpi_plugin_credit_entities`.`name`,
`glpi_plugin_credit_entities`.`quantity`,
(SELECT SUM(`glpi_plugin_credit_tickets`.`consumed`) FROM `glpi_plugin_credit_tickets` WHERE `glpi_plugin_credit_tickets`.`plugin_credit_entities_id` = `glpi_plugin_credit_entities`.`id` AND `glpi_plugin_credit_tickets`.`tickets_id` = {$id}) AS `consumed_on_ticket`,
(SELECT SUM(`glpi_plugin_credit_tickets`.`consumed`) FROM `glpi_plugin_credit_tickets` WHERE `glpi_plugin_credit_tickets`.`plugin_credit_entities_id` = `glpi_plugin_credit_entities`.`id`) AS `consumed_total`
FROM `glpi_plugin_credit_entities`";

foreach ($DB->request($query) as $credit) {
$target->data["credit.ticket"][] = [
'##credit.voucher##' => $credit['name'],
'##credit.used##' => (int)$credit['consumed_on_ticket'],
'##credit.left##' => (int)$credit['quantity'] - (int)$credit['consumed_total'],
];
}
}
Binary file modified locales/zh_CN.mo
Binary file not shown.
2 changes: 1 addition & 1 deletion locales/zh_CN.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-06-22 12:21+0000\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: 杜哥 <[email protected]>, 2018\n"
"Last-Translator: liAnGjiA <[email protected]>, 2018\n"
"Language-Team: Chinese (China) (https://www.transifex.com/pluginsGLPI/teams/73419/zh_CN/)\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
Expand Down
4 changes: 4 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<author>TECLIB'</author>
</authors>
<versions>
<version>
<num>1.4.0</num>
<compatibility>9.3</compatibility>
</version>
<version>
<num>1.3.2</num>
<compatibility>9.3</compatibility>
Expand Down
3 changes: 2 additions & 1 deletion setup.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* -------------------------------------------------------------------------
*/

define('PLUGIN_CREDIT_VERSION', '1.3.2');
define('PLUGIN_CREDIT_VERSION', '1.4.0');

// Minimal GLPI version, inclusive
define("PLUGIN_CREDIT_MIN_GLPI", "9.3");
Expand Down Expand Up @@ -68,6 +68,7 @@ function plugin_init_credit() {
'TicketTask' => ['PluginCreditTicket', 'consumeVoucher'],
];
}
$PLUGIN_HOOKS['item_get_datas']['credit'] = ['NotificationTargetTicket' => 'plugin_credit_get_datas'];
}
}

Expand Down

0 comments on commit fa824a2

Please sign in to comment.