├── locales
├── cs_CZ.mo
├── en_GB.mo
├── es_ES.mo
├── et_EE.mo
├── fr_FR.mo
├── hu_HU.mo
├── it_IT.mo
├── ms_MY.mo
├── pl_PL.mo
├── pt_BR.mo
├── pt_PT.mo
├── ro_RO.mo
├── ru_RU.mo
├── tr_TR.mo
├── glpi.pot
├── et_EE.po
├── pt_BR.po
├── ms_MY.po
├── tr_TR.po
├── it_IT.po
├── pt_PT.po
├── es_EC.po
├── es_ES.po
├── hu_HU.po
├── pl_PL.po
├── en_GB.po
├── fr_FR.po
├── ru_RU.po
├── ro_RO.po
└── cs_CZ.po
├── sql
├── update-3.0.3.sql
├── update-3.0.0.sql
├── update-1.5.0.sql
├── update-3.0.2.sql
├── update-1.2.0.sql
├── update-1.8.0.sql
├── update-1.7.1.sql
├── empty-1.7.0.sql
├── empty-1.0.sql
├── empty-1.5.0.sql
├── empty-1.2.0.sql
├── empty-3.0.0.sql
├── empty-1.3.0.sql
├── empty-2.1.2.sql
├── update-1.3.0.sql
├── empty-2.4.0.sql
├── empty-1.7.1.sql
├── empty-1.8.0.sql
├── empty-1.9.0.sql
└── empty-2.1.0.sql
├── additionalalerts.png
├── tools
├── extract_template.sh
├── update_mo.pl
└── update_po.pl
├── ISSUE_TEMPLATE.md
├── .github
└── workflows
│ ├── updatepot.yml
│ ├── generatemo.yml
│ └── release.yml
├── README.md
├── front
├── additionalalert.form.php
├── config.form.php
├── infocomalert.form.php
├── ticketunresolved.form.php
└── inkalert.form.php
├── src
├── Menu.php
├── InkThreshold.php
├── InkPrinterState.php
├── NotificationState.php
├── NotificationTargetTicketUnresolved.php
├── NotificationTargetInkAlert.php
├── Config.php
├── NotificationTargetInfocomAlert.php
├── NotificationType.php
├── AdditionalAlert.php
├── Profile.php
└── TicketUnresolved.php
├── setup.php
└── additionalalerts.xml
/locales/cs_CZ.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/cs_CZ.mo
--------------------------------------------------------------------------------
/locales/en_GB.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/en_GB.mo
--------------------------------------------------------------------------------
/locales/es_ES.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/es_ES.mo
--------------------------------------------------------------------------------
/locales/et_EE.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/et_EE.mo
--------------------------------------------------------------------------------
/locales/fr_FR.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/fr_FR.mo
--------------------------------------------------------------------------------
/locales/hu_HU.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/hu_HU.mo
--------------------------------------------------------------------------------
/locales/it_IT.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/it_IT.mo
--------------------------------------------------------------------------------
/locales/ms_MY.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/ms_MY.mo
--------------------------------------------------------------------------------
/locales/pl_PL.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/pl_PL.mo
--------------------------------------------------------------------------------
/locales/pt_BR.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/pt_BR.mo
--------------------------------------------------------------------------------
/locales/pt_PT.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/pt_PT.mo
--------------------------------------------------------------------------------
/locales/ro_RO.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/ro_RO.mo
--------------------------------------------------------------------------------
/locales/ru_RU.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/ru_RU.mo
--------------------------------------------------------------------------------
/locales/tr_TR.mo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/locales/tr_TR.mo
--------------------------------------------------------------------------------
/sql/update-3.0.3.sql:
--------------------------------------------------------------------------------
1 | DELETE FROM `glpi_crontasks` WHERE `itemtype` LIKE 'PluginAdditionalalerts%';
2 |
--------------------------------------------------------------------------------
/additionalalerts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InfotelGLPI/additionalalerts/master/additionalalerts.png
--------------------------------------------------------------------------------
/sql/update-3.0.0.sql:
--------------------------------------------------------------------------------
1 | ALTER TABLE `glpi_plugin_additionalalerts_inkthresholds` CHANGE `cartridges_id` `printers_id` INT UNSIGNED NOT NULL DEFAULT '0';
2 |
--------------------------------------------------------------------------------
/sql/update-1.5.0.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_reminderalerts`;
2 | ALTER TABLE `glpi_plugin_additionalalerts_configs` DROP `delay_reminder`;
--------------------------------------------------------------------------------
/sql/update-3.0.2.sql:
--------------------------------------------------------------------------------
1 | UPDATE `glpi_crontasks` SET `itemtype` = 'GlpiPlugin\\Additionalalerts\\TicketUnresolved' WHERE `itemtype` = 'PluginAdditionalalertsTicketUnresolved';
2 | UPDATE `glpi_crontasks` SET `itemtype` = 'GlpiPlugin\\Additionalalerts\\InkAlert' WHERE `itemtype` = 'PluginAdditionalalertsInkAlert';
3 | UPDATE `glpi_crontasks` SET `itemtype` = 'GlpiPlugin\\Additionalalerts\\InfocomAlert' WHERE `itemtype` = 'PluginAdditionalalertsInfocomAlert';
4 |
--------------------------------------------------------------------------------
/tools/extract_template.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | # Only strings with domain specified are extracted (use Xt args of keyword param to set number of args needed)
4 |
5 | xgettext *.php */*.php --copyright-holder='Additionalalerts Development Team' --package-name='GLPI - Additionalalerts plugin' -o locales/glpi.pot -L PHP --add-comments=TRANS --from-code=UTF-8 --force-po \
6 | --keyword=_n:1,2,4t --keyword=__s:1,2t --keyword=__:1,2t --keyword=_e:1,2t --keyword=_x:1c,2,3t \
7 | --keyword=_ex:1c,2,3t --keyword=_nx:1c,2,3,5t --keyword=_sx:1c,2,3t
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/ISSUE_TEMPLATE.md:
--------------------------------------------------------------------------------
1 | Dear GLPi user.
2 |
3 | BEFORE SUBMITTING YOUR ISSUE, please make sure to read and follow these steps :
4 |
5 | * Verify that your question has not already been asked
6 | * Please use the below template.
7 | * Delete this text before submiting your issue.
8 |
9 | The Plugin team.
10 |
11 | ------------
12 | * Version of the plugin :
13 |
14 |
15 | * Version of your GLPI :
16 |
17 |
18 | * Steps to reproduce (which actions have you made) :
19 |
20 |
21 | * Expected result :
22 |
23 |
24 | * Actual result :
25 |
26 |
27 | * URL of the page :
28 |
29 |
30 | * Screenshot of the problem (if pertinent) :
31 |
32 |
--------------------------------------------------------------------------------
/sql/update-1.2.0.sql:
--------------------------------------------------------------------------------
1 | ALTER TABLE `glpi_plugin_alerting_profiles` DROP COLUMN `interface` , DROP COLUMN `is_default`;
2 | INSERT INTO glpi_plugin_alerting_mailing VALUES ('5','newocs','1','1');
3 | ALTER TABLE `glpi_plugin_alerting_config` ADD `alerting_new_ocs` SMALLINT( 6 ) NOT NULL AFTER `delay_ocs`;
4 | INSERT INTO glpi_plugin_alerting_mailing VALUES ('6','notinfocom','1','1');
5 | ALTER TABLE `glpi_plugin_alerting_config` ADD `alerting_not_infocom` SMALLINT( 6 ) NOT NULL AFTER `alerting_new_ocs`;
6 |
7 | CREATE TABLE `glpi_plugin_alerting_type` (
8 | `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
9 | `type` INT( 11 ) NOT NULL
10 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
--------------------------------------------------------------------------------
/sql/update-1.8.0.sql:
--------------------------------------------------------------------------------
1 | ALTER TABLE `glpi_plugin_additionalalerts_configs` ADD `delay_ticket_alert` int(11) NOT NULL DEFAULT '0';
2 |
3 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_ticketunresolveds`;
4 | CREATE TABLE `glpi_plugin_additionalalerts_ticketunresolveds` (
5 | `id` int(11) NOT NULL auto_increment,
6 | `entities_id` int(11) NOT NULL default '0',
7 | `delay_ticket_alert` int(11) NOT NULL DEFAULT '-1',
8 | PRIMARY KEY (`id`)
9 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
10 |
11 | INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert Ticket Unresolved', 'PluginAdditionalalertsTicketUnresolved', '2010-03-13 10:44:46','',NULL, '2010-03-13 10:44:46');
12 |
--------------------------------------------------------------------------------
/tools/update_mo.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #!/usr/bin/perl -w
3 |
4 | if (@ARGV!=0){
5 | print "USAGE update_mo.pl\n\n";
6 |
7 | exit();
8 | }
9 |
10 |
11 | opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n";
12 | foreach (readdir(DIRHANDLE)){
13 | if ($_ ne '..' && $_ ne '.'){
14 |
15 | if(!(-l "$dir/$_")){
16 | if (index($_,".po",0)==length($_)-3) {
17 | $lang=$_;
18 | $lang=~s/\.po//;
19 |
20 | `msgfmt locales/$_ -o locales/$lang.mo`;
21 | }
22 | }
23 |
24 | }
25 | }
26 | closedir DIRHANDLE;
27 |
28 | #
29 | #
30 |
--------------------------------------------------------------------------------
/.github/workflows/updatepot.yml:
--------------------------------------------------------------------------------
1 | name: Update POT
2 | on:
3 | push:
4 | branches: [ master ]
5 | paths-ignore:
6 | - 'locales/**'
7 |
8 | env:
9 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
10 | jobs:
11 | run:
12 |
13 | name: Update POT
14 |
15 | runs-on: ubuntu-latest
16 | steps:
17 | - name: Checkout repo
18 | uses: actions/checkout@v2
19 |
20 | - name: install xgettext
21 |
22 | run: sudo apt-get install gettext;
23 | - name: Update POT
24 | run: sh tools/extract_template.sh;
25 |
26 |
27 | - name: Commit changes
28 | uses: EndBug/add-and-commit@v5.1.0
29 | with:
30 | message: "Update POT"
31 | - name: Push changes
32 |
33 | uses: actions-go/push@v1
34 |
35 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # additionalalerts
2 |
3 | Plugin Additionalalerts pour GLPI
4 |
5 | Ce plugin est sur Transifex - Aidez-nous à le traduire :
6 | https://www.transifex.com/infotelGLPI/GLPI_additionalalerts/
7 |
8 | This plugin is on Transifex - Help us to translate :
9 | https://www.transifex.com/infotelGLPI/GLPI_additionalalerts/
10 |
11 | ### Français
12 |
13 | Ce plugin vous permet d'envoyer les alertes email supplémentaires
14 | * Matériels ayant une date d'achat vide (Choix des types pris en charge : pour ne pas prendre en compte les matériels non achetés),
15 | * Niveaux des cartouches bas (information provenant de Fusion Inventory).
16 |
17 | ### English
18 |
19 | This plugin enables you to send email supplementary alerts
20 | * Items with empty buy date (Choice of supported types : for not taking into account the equipment not purchased),
21 | * Cartridges whose level is low (fusion Inventory information)
22 |
--------------------------------------------------------------------------------
/tools/update_po.pl:
--------------------------------------------------------------------------------
1 | #!/usr/bin/perl
2 | #!/usr/bin/perl -w
3 |
4 | if (@ARGV!=2){
5 | print "USAGE update_po.pl transifex_login transifex_password\n\n";
6 |
7 | exit();
8 | }
9 | $user = $ARGV[0];
10 | $password = $ARGV[1];
11 |
12 | opendir(DIRHANDLE,'locales')||die "ERROR: can not read current directory\n";
13 | foreach (readdir(DIRHANDLE)){
14 | if ($_ ne '..' && $_ ne '.'){
15 |
16 | if(!(-l "$dir/$_")){
17 | if (index($_,".po",0)==length($_)-3) {
18 | $lang=$_;
19 | $lang=~s/\.po//;
20 |
21 | `wget --user=$user --password=$password --output-document=locales/$_ http://www.transifex.com/api/2/project/GLPI_additionalalerts/resource/glpi/translation/$lang/?file=$_`;
22 | }
23 | }
24 |
25 | }
26 | }
27 | closedir DIRHANDLE;
28 |
29 | #
30 | #
31 |
--------------------------------------------------------------------------------
/.github/workflows/generatemo.yml:
--------------------------------------------------------------------------------
1 | name: Generate MO
2 | on:
3 | push:
4 | branches: [ master ]
5 | paths:
6 | - '**.po'
7 | env:
8 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
9 | jobs:
10 | run:
11 |
12 | name: Generate mo
13 | runs-on: ubuntu-latest
14 | steps:
15 | - name: Checkout repo
16 | uses: actions/checkout@v2
17 |
18 | - name: Setup Perl environment
19 | # You may pin to the exact commit or the version.
20 | # uses: shogo82148/actions-setup-perl@8d2e3d59a9516b785ed32169d48a4888eaa9b514
21 | uses: shogo82148/actions-setup-perl@v1.7.2
22 | - name: msgfmt
23 | # You may pin to the exact commit or the version.
24 | # uses: whtsky/msgfmt-action@6b2181f051b002182d01a1e1f1aff216230c5a4d
25 | uses: whtsky/msgfmt-action@20190305
26 | - name: Generate mo
27 | run: perl tools/update_mo.pl;
28 |
29 | - name: Commit changes
30 | uses: EndBug/add-and-commit@v5.1.0
31 | with:
32 |
33 | message: "Generate mo"
34 | - name: Push changes
35 |
36 | uses: actions-go/push@v1
37 |
38 |
--------------------------------------------------------------------------------
/sql/update-1.7.1.sql:
--------------------------------------------------------------------------------
1 | ALTER TABLE `glpi_plugin_additionalalerts_configs` ADD `use_ink_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1';
2 |
3 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_inkalerts`;
4 | CREATE TABLE `glpi_plugin_additionalalerts_inkalerts` (
5 | `id` int(11) NOT NULL auto_increment,
6 | `entities_id` int(11) NOT NULL default '0',
7 | `use_ink_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
8 | PRIMARY KEY (`id`)
9 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
10 |
11 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_inkthresholds`;
12 | CREATE TABLE `glpi_plugin_additionalalerts_inkthresholds` (
13 | `id` int(11) NOT NULL AUTO_INCREMENT,
14 | `cartridges_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_cartridgeitems (id)',
15 | `threshold` int(3) NOT NULL default '10',
16 | PRIMARY KEY (`id`)
17 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
18 |
19 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_inkprinterstates`;
20 | CREATE TABLE `glpi_plugin_additionalalerts_inkprinterstates` (
21 | `id` INT( 11 ) NOT NULL AUTO_INCREMENT,
22 | `states_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_states (id)',
23 | PRIMARY KEY (`id`)
24 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
25 |
26 | INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert ink level', 'PluginAdditionalalertsInkAlert', '2010-03-13 10:44:46','',NULL, '2010-03-13 10:44:46');
--------------------------------------------------------------------------------
/front/additionalalert.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | use Glpi\Exception\Http\AccessDeniedHttpException;
31 | use GlpiPlugin\Additionalalerts\AdditionalAlert;
32 | use GlpiPlugin\Additionalalerts\Menu;
33 |
34 |
35 | Html::header(AdditionalAlert::getTypeName(2), '', "admin", Menu::class);
36 |
37 | $alert = new AdditionalAlert();
38 | if (Session::haveRight("plugin_additionalalerts", READ)
39 | || Session::haveRight("config", CREATE)) {
40 |
41 | AdditionalAlert::displayAlerts();
42 |
43 | } else {
44 | throw new AccessDeniedHttpException();
45 | }
46 |
47 | Html::footer();
48 |
--------------------------------------------------------------------------------
/front/config.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | use GlpiPlugin\Additionalalerts\AdditionalAlert;
31 | use GlpiPlugin\Additionalalerts\Config;
32 | use GlpiPlugin\Additionalalerts\Menu;
33 |
34 | if (Plugin::isPluginActive("additionalalerts")) {
35 |
36 | $config = new Config();
37 | if (isset($_POST["update"])) {
38 | $config->update($_POST);
39 | Html::back();
40 | } else {
41 | Html::header(AdditionalAlert::getTypeName(2), '', "admin", Menu::class);
42 | $config = new Config();
43 | $config->showConfigForm();
44 | Html::footer();
45 | }
46 | } else {
47 | Html::header(__('Setup'), '', "config", "plugins");
48 | echo "
";
49 | echo "" . __('Please activate the plugin', 'additionalalerts') . "
";
50 | Html::footer();
51 | }
52 |
--------------------------------------------------------------------------------
/front/infocomalert.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | use GlpiPlugin\Additionalalerts\InfocomAlert;
31 | use GlpiPlugin\Additionalalerts\NotificationType;
32 |
33 | $type = new NotificationType();
34 | $infocom = new InfocomAlert();
35 |
36 | if (isset($_POST["add"])) {
37 |
38 | if ($infocom->canUpdate()) {
39 | $newID = $infocom->add($_POST);
40 | }
41 | Html::back();
42 |
43 | } else if (isset($_POST["update"])) {
44 |
45 | if ($infocom->canUpdate()) {
46 | $infocom->update($_POST);
47 | }
48 | Html::back();
49 |
50 | } else if (isset($_POST["add_type"])) {
51 |
52 | if ($infocom->canUpdate()) {
53 | $newID = $type->add($_POST);
54 | }
55 | Html::back();
56 |
57 | } else if (isset($_POST["delete_type"])) {
58 |
59 | if ($infocom->canUpdate()) {
60 | $type->getFromDB($_POST["id"]);
61 | foreach ($_POST["item"] as $key => $val) {
62 | if ($val == 1) {
63 | $type->delete(['id' => $key]);
64 | }
65 | }
66 | }
67 | Html::back();
68 |
69 | }
70 |
--------------------------------------------------------------------------------
/front/ticketunresolved.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 |
31 | use GlpiPlugin\Additionalalerts\NotificationType;
32 | use GlpiPlugin\Additionalalerts\TicketUnresolved;
33 |
34 | $type = new NotificationType();
35 | $ticket = new TicketUnresolved();
36 |
37 | if (isset($_POST["add"])) {
38 |
39 | if ($ticket->canUpdate()) {
40 | $newID = $ticket->add($_POST);
41 | }
42 | Html::back();
43 |
44 | } else if (isset($_POST["update"])) {
45 |
46 | if ($ticket->canUpdate()) {
47 | $ticket->update($_POST);
48 | }
49 | Html::back();
50 |
51 | } else if (isset($_POST["add_type"])) {
52 |
53 | if ($ticket->canUpdate()) {
54 | $newID = $type->add($_POST);
55 | }
56 | Html::back();
57 |
58 | } else if (isset($_POST["delete_type"])) {
59 |
60 | if ($ticket->canUpdate()) {
61 | $type->getFromDB($_POST["id"]);
62 | foreach ($_POST["item"] as $key => $val) {
63 | if ($val == 1) {
64 | $type->delete(['id' => $key]);
65 | }
66 | }
67 | }
68 | Html::back();
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/sql/empty-1.7.0.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_configs`;
2 | CREATE TABLE `glpi_plugin_additionalalerts_configs` (
3 | `id` int(11) NOT NULL auto_increment,
4 | `delay_ocs` int(11) NOT NULL default '-1',
5 | `use_infocom_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
6 | `use_newocs_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
7 | PRIMARY KEY (`id`)
8 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9 |
10 | INSERT INTO `glpi_plugin_additionalalerts_configs` ( `id`,`delay_ocs`,`use_infocom_alert`,`use_newocs_alert`) VALUES ('1','-1','-1','-1');
11 |
12 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_ocsalerts`;
13 | CREATE TABLE `glpi_plugin_additionalalerts_ocsalerts` (
14 | `id` int(11) NOT NULL auto_increment,
15 | `entities_id` int(11) NOT NULL default '0',
16 | `delay_ocs` int(11) NOT NULL default '-1',
17 | `use_newocs_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
18 | PRIMARY KEY (`id`)
19 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
20 |
21 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_infocomalerts`;
22 | CREATE TABLE `glpi_plugin_additionalalerts_infocomalerts` (
23 | `id` int(11) NOT NULL auto_increment,
24 | `entities_id` int(11) NOT NULL default '0',
25 | `use_infocom_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
26 | PRIMARY KEY (`id`)
27 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
28 |
29 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_notificationstates`;
30 | CREATE TABLE `glpi_plugin_additionalalerts_notificationstates` (
31 | `id` int(11) NOT NULL auto_increment,
32 | `states_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_states (id)',
33 | PRIMARY KEY (`id`)
34 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
35 |
36 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_notificationtypes`;
37 | CREATE TABLE `glpi_plugin_additionalalerts_notificationtypes` (
38 | `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
39 | `types_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_computertypes (id)',
40 | PRIMARY KEY (`id`)
41 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
42 |
43 |
44 | INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert infocoms', 'PluginAdditionalalertsInfocomAlert', '2010-03-13 10:44:46','',NULL);
45 | INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert machines ocs', 'PluginAdditionalalertsOcsAlert', '2010-03-13 10:44:46','',NULL);
--------------------------------------------------------------------------------
/front/inkalert.form.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | use Glpi\Exception\Http\AccessDeniedHttpException;
31 | use GlpiPlugin\Additionalalerts\InkAlert;
32 | use GlpiPlugin\Additionalalerts\InkPrinterState;
33 | use GlpiPlugin\Additionalalerts\InkThreshold;
34 |
35 |
36 | $state = new InkPrinterState();
37 | $alert = new InkAlert();
38 |
39 | if (isset($_POST["add"])) {
40 | if ($alert->canUpdate()) {
41 | $newID = $alert->add($_POST);
42 | }
43 | } else if (isset($_POST["update"])) {
44 | if ($alert->canUpdate()) {
45 | $alert->update($_POST);
46 | }
47 | } else if (isset($_POST["add_state"])) {
48 | if ($alert->canUpdate()) {
49 | $newID = $state->add($_POST);
50 | }
51 | } else if (isset($_POST["delete_state"])) {
52 | if ($alert->canUpdate()) {
53 | $state->getFromDB($_POST["id"]);
54 |
55 | foreach ($_POST["item"] as $key => $val) {
56 | if ($val == 1) {
57 | $state->delete(['id' => $key]);
58 | }
59 | }
60 | }
61 |
62 | } else if (isset($_POST["update_threshold"])) {
63 |
64 | $InkThreshold = new InkThreshold();
65 | if ($alert->canUpdate()) {
66 | $InkThreshold->update($_POST);
67 | } else {
68 | throw new AccessDeniedHttpException();
69 |
70 | }
71 | }
72 | Html::back();
73 |
--------------------------------------------------------------------------------
/sql/empty-1.0.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS `glpi_plugin_alerting_config`;
2 | CREATE TABLE `glpi_plugin_alerting_config` (
3 | `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
4 | `alerting_tickets` smallint(6) NOT NULL default '0',
5 | `delay_tickets` int(11) NOT NULL default '30',
6 | `alerting_reservations` smallint(6) NOT NULL default '0',
7 | `delay_reminder` int(11) NOT NULL default '5',
8 | `alerting_reminder` smallint(6) NOT NULL default '0',
9 | `delay_reservations` int(11) NOT NULL default '5',
10 | `alerting_ocs` smallint(6) NOT NULL default '0',
11 | `delay_ocs` int(11) NOT NULL default '90'
12 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
13 |
14 | INSERT INTO `glpi_plugin_alerting_config` ( `ID`, `alerting_tickets`, `delay_tickets`,`alerting_reservations`,`delay_reservations`,`alerting_reminder`,`delay_reminder`,`alerting_ocs`, `delay_ocs`) VALUES ('1','0','30','0','5','0','5','0','90');
15 |
16 | DROP TABLE IF EXISTS `glpi_plugin_alerting_state`;
17 | CREATE TABLE `glpi_plugin_alerting_state` (
18 | `ID` INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
19 | `state` INT( 11 ) NOT NULL
20 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
21 |
22 | DROP TABLE IF EXISTS `glpi_plugin_alerting_profiles`;
23 | CREATE TABLE `glpi_plugin_alerting_profiles` (
24 | `ID` int(11) NOT NULL auto_increment,
25 | `name` varchar(255) default NULL,
26 | `interface` varchar(50) NOT NULL default 'alerting',
27 | `is_default` smallint(6) NOT NULL default '0',
28 | `alerting` char(1) default NULL,
29 | PRIMARY KEY (`ID`),
30 | KEY `interface` (`interface`)
31 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
32 |
33 | DROP TABLE IF EXISTS `glpi_plugin_alerting_mailing`;
34 | CREATE TABLE `glpi_plugin_alerting_mailing` (
35 | `ID` int(11) NOT NULL auto_increment,
36 | `type` varchar(255) collate utf8_unicode_ci default NULL,
37 | `FK_item` int(11) NOT NULL default '0',
38 | `item_type` int(11) NOT NULL default '0',
39 | PRIMARY KEY (`ID`),
40 | UNIQUE KEY `mailings` (`type`,`FK_item`,`item_type`),
41 | KEY `type` (`type`),
42 | KEY `FK_item` (`FK_item`),
43 | KEY `item_type` (`item_type`),
44 | KEY `items` (`item_type`,`FK_item`)
45 | ) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
46 |
47 | INSERT INTO glpi_plugin_alerting_mailing VALUES ('1','tickets','1','1');
48 | INSERT INTO glpi_plugin_alerting_mailing VALUES ('2','ocs','1','1');
49 | INSERT INTO glpi_plugin_alerting_mailing VALUES ('3','reservations','1','1');
50 | INSERT INTO glpi_plugin_alerting_mailing VALUES ('4','reminder','1','1');
--------------------------------------------------------------------------------
/src/Menu.php:
--------------------------------------------------------------------------------
1 | .
28 | --------------------------------------------------------------------------
29 | */
30 |
31 | namespace GlpiPlugin\Additionalalerts;
32 |
33 | use CommonGLPI;
34 |
35 | /**
36 | * Class Menu
37 | */
38 | class Menu extends CommonGLPI {
39 | static $rightname = 'plugin_additionalalerts';
40 |
41 | /**
42 | * @return string
43 | */
44 | static function getMenuName() {
45 | return _n('Other alert', 'Others alerts', 2, 'additionalalerts');
46 | }
47 |
48 | /**
49 | * @return array
50 | */
51 | static function getMenuContent() {
52 |
53 | $menu = [];
54 | $menu['title'] = self::getMenuName();
55 | $menu['page'] = PLUGIN_ADDITIONALALERTS_WEBDIR."/front/additionalalert.form.php";
56 | $menu['links']['search'] = AdditionalAlert::getFormURL(false);
57 |
58 | $menu['links']['config'] = PLUGIN_ADDITIONALALERTS_WEBDIR.'/front/config.form.php';
59 | $menu['icon'] = self::getIcon();
60 | return $menu;
61 | }
62 |
63 | static function getIcon() {
64 | return "ti ti-bell-ringing";
65 | }
66 |
67 | static function removeRightsFromSession() {
68 | if (isset($_SESSION['glpimenu']['admin']['types'][Menu::class])) {
69 | unset($_SESSION['glpimenu']['admin']['types'][Menu::class]);
70 | }
71 | if (isset($_SESSION['glpimenu']['admin']['content'][Menu::class])) {
72 | unset($_SESSION['glpimenu']['admin']['content'][Menu::class]);
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/locales/glpi.pot:
--------------------------------------------------------------------------------
1 | # SOME DESCRIPTIVE TITLE.
2 | # Copyright (C) YEAR Additionalalerts Development Team
3 | # This file is distributed under the same license as the GLPI - Additionalalerts plugin package.
4 | # FIRST AUTHOR , YEAR.
5 | #
6 | #, fuzzy
7 | msgid ""
8 | msgstr ""
9 | "Project-Id-Version: GLPI - Additionalalerts plugin\n"
10 | "Report-Msgid-Bugs-To: \n"
11 | "POT-Creation-Date: 2025-12-05 11:18+0000\n"
12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13 | "Last-Translator: FULL NAME \n"
14 | "Language-Team: LANGUAGE \n"
15 | "Language: \n"
16 | "MIME-Version: 1.0\n"
17 | "Content-Type: text/plain; charset=CHARSET\n"
18 | "Content-Transfer-Encoding: 8bit\n"
19 | "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
20 |
21 | #: setup.php:96 src/AdditionalAlert.php:58 src/Menu.php:45 src/Profile.php:116
22 | msgid "Other alert"
23 | msgid_plural "Others alerts"
24 | msgstr[0] ""
25 | msgstr[1] ""
26 |
27 | #: front/config.form.php:49
28 | msgid "Please activate the plugin"
29 | msgstr ""
30 |
31 | #: src/AdditionalAlert.php:120
32 | msgid "No used alerts"
33 | msgstr ""
34 |
35 | #: src/AdditionalAlert.php:149
36 | msgid "No computers with no buy date"
37 | msgstr ""
38 |
39 | #: src/AdditionalAlert.php:167 src/Config.php:135 src/InkAlert.php:68
40 | #: src/InkAlert.php:125 src/InkAlert.php:305 src/InkAlert.php:376
41 | #: src/NotificationTargetInkAlert.php:54 src/NotificationTargetInkAlert.php:124
42 | msgid "Cartridges whose level is low"
43 | msgstr ""
44 |
45 | #: src/AdditionalAlert.php:174
46 | msgid "Ink level"
47 | msgstr ""
48 |
49 | #: src/AdditionalAlert.php:181
50 | msgid "No cartridge is below the threshold"
51 | msgstr ""
52 |
53 | #: src/AdditionalAlert.php:197
54 | msgid "Tickets unresolved since more"
55 | msgstr ""
56 |
57 | #: src/AdditionalAlert.php:213
58 | msgid "No tickets unresolved since more"
59 | msgstr ""
60 |
61 | #: src/Config.php:56 src/InfocomAlert.php:84 src/InkAlert.php:86
62 | msgid "Plugin setup"
63 | msgstr ""
64 |
65 | #: src/Config.php:141
66 | msgid "Unresolved Ticket Alerts"
67 | msgstr ""
68 |
69 | #: src/InfocomAlert.php:66
70 | msgid "Computer with no buy date"
71 | msgid_plural "Computers with no buy date"
72 | msgstr[0] ""
73 | msgstr[1] ""
74 |
75 | #: src/InkPrinterState.php:59 src/NotificationType.php:64
76 | msgid "Parameter"
77 | msgstr ""
78 |
79 | #: src/InkPrinterState.php:60
80 | msgid "Statutes used for the ink level"
81 | msgstr ""
82 |
83 | #: src/InkThreshold.php:62 src/InkThreshold.php:64
84 | msgid "Ink level alerts"
85 | msgstr ""
86 |
87 | #: src/NotificationType.php:65
88 | msgid "Type not used for check of buy date"
89 | msgstr ""
90 |
91 | #: src/TicketUnresolved.php:65
92 | msgid "Ticket unresolved"
93 | msgid_plural "Tickets unresolved"
94 | msgstr[0] ""
95 | msgstr[1] ""
96 |
--------------------------------------------------------------------------------
/sql/empty-1.5.0.sql:
--------------------------------------------------------------------------------
1 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_configs`;
2 | CREATE TABLE `glpi_plugin_additionalalerts_configs` (
3 | `id` int(11) NOT NULL auto_increment,
4 | `delay_ocs` int(11) NOT NULL default '-1',
5 | `use_infocom_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
6 | `use_newocs_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
7 | PRIMARY KEY (`id`)
8 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
9 |
10 | INSERT INTO `glpi_plugin_additionalalerts_configs` ( `id`,`delay_ocs`,`use_infocom_alert`,`use_newocs_alert`) VALUES ('1','-1','-1','-1');
11 |
12 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_ocsalerts`;
13 | CREATE TABLE `glpi_plugin_additionalalerts_ocsalerts` (
14 | `id` int(11) NOT NULL auto_increment,
15 | `entities_id` int(11) NOT NULL default '0',
16 | `delay_ocs` int(11) NOT NULL default '-1',
17 | `use_newocs_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
18 | PRIMARY KEY (`id`)
19 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
20 |
21 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_infocomalerts`;
22 | CREATE TABLE `glpi_plugin_additionalalerts_infocomalerts` (
23 | `id` int(11) NOT NULL auto_increment,
24 | `entities_id` int(11) NOT NULL default '0',
25 | `use_infocom_alert` TINYINT( 1 ) NOT NULL DEFAULT '-1',
26 | PRIMARY KEY (`id`)
27 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
28 |
29 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_notificationstates`;
30 | CREATE TABLE `glpi_plugin_additionalalerts_notificationstates` (
31 | `id` int(11) NOT NULL auto_increment,
32 | `states_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_states (id)',
33 | PRIMARY KEY (`id`)
34 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
35 |
36 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_notificationtypes`;
37 | CREATE TABLE `glpi_plugin_additionalalerts_notificationtypes` (
38 | `id` INT( 11 ) NOT NULL AUTO_INCREMENT ,
39 | `types_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_computertypes (id)',
40 | PRIMARY KEY (`id`)
41 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
42 |
43 | DROP TABLE IF EXISTS `glpi_plugin_additionalalerts_profiles`;
44 | CREATE TABLE `glpi_plugin_additionalalerts_profiles` (
45 | `id` int(11) NOT NULL auto_increment,
46 | `profiles_id` int(11) NOT NULL default '0' COMMENT 'RELATION to glpi_profiles (id)',
47 | `additionalalerts` char(1) collate utf8_unicode_ci default NULL,
48 | PRIMARY KEY (`id`),
49 | KEY `profiles_id` (`profiles_id`)
50 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
51 |
52 | INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert infocoms', 'PluginAdditionalalertsInfocomAlert', '2010-03-13 10:44:46','',NULL);
53 | INSERT INTO `glpi_notificationtemplates` VALUES(NULL, 'Alert machines ocs', 'PluginAdditionalalertsOcsAlert', '2010-03-13 10:44:46','',NULL);
--------------------------------------------------------------------------------
/.github/workflows/release.yml:
--------------------------------------------------------------------------------
1 |
2 | on:
3 | push:
4 | # Sequence of patterns matched against refs/tags
5 | tags:
6 | - '*.*.*' # Push events to matching ex:20.15.10
7 |
8 | name: Create release with tag
9 | env:
10 | TAG_VALUE: ${GITHUB_REF/refs\/tags\//}
11 | jobs:
12 | build:
13 | name: Upload Release Asset
14 | runs-on: ubuntu-latest
15 | steps:
16 | - name: Checkout code
17 | uses: actions/checkout@v2
18 | - name: Build project # This would actually build your project, using zip for an example artifact
19 | id: build_
20 | env:
21 | GITHUB_NAME: ${{ github.event.repository.name }}
22 |
23 |
24 | run: sudo apt-get install libxml-xpath-perl;echo $(xpath -e '/root/versions/version[num="'${GITHUB_REF/refs\/tags\//}'"]/compatibility/text()' $GITHUB_NAME.xml);echo ::set-output name=version_glpi::$(xpath -e '/root/versions/version[num="'${GITHUB_REF/refs\/tags\//}'"]/compatibility/text()' $GITHUB_NAME.xml); rm -rf $GITHUB_NAME.xml tools wiki screenshots test .git .github ISSUE_TEMPLATE.md TODO.txt $GITHUB_NAME.png;cd ..; tar jcvf glpi-$GITHUB_NAME-${GITHUB_REF/refs\/tags\//}.tar.bz2 $GITHUB_NAME;ls -al;echo ::set-output name=tag::${GITHUB_REF/refs\/tags\//};echo ${{ steps.getxml.outputs.info }};
25 | # run: rm -rf $GITHUB_NAME.xml tools wiki screenshots test ISSUE_TEMPLATE.md TODO.txt $GITHUB_NAME.png; tar -zcvf glpi-$GITHUB_NAME-$GITHUB_TAG.tar.gz $GITHUB_NAME
26 | - name: Create Release
27 | id: create_release
28 | uses: actions/create-release@v1
29 | env:
30 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 | with:
32 | tag_name: ${{ github.ref }}
33 | release_name: |
34 | GLPI ${{ steps.build_.outputs.version_glpi }} : Version ${{ github.ref }} disponible / available
35 | body : Version ${{ steps.build_.outputs.tag }} released for GLPI ${{ steps.build_.outputs.version_glpi }}
36 | draft: false
37 | prerelease: true
38 | - name: Upload Release Asset
39 | id: upload-release-asset
40 | uses: actions/upload-release-asset@v1
41 | env:
42 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
43 | GITHUB_NAME: ${{ github.event.repository.name }}
44 | with:
45 | upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps
46 | asset_path: /home/runner/work/${{ github.event.repository.name }}/glpi-${{ github.event.repository.name }}-${{ steps.build_.outputs.tag }}.tar.bz2
47 | asset_name: glpi-${{ github.event.repository.name }}-${{ steps.build_.outputs.tag }}.tar.bz2
48 | asset_content_type: application/zip
49 |
50 |
--------------------------------------------------------------------------------
/src/InkThreshold.php:
--------------------------------------------------------------------------------
1 | .
27 | --------------------------------------------------------------------------
28 | */
29 |
30 | namespace GlpiPlugin\Additionalalerts;
31 |
32 | use CommonDBTM;
33 | use Html;
34 |
35 | if (!defined('GLPI_ROOT')) {
36 | die("Sorry. You can't access directly to this file");
37 | }
38 |
39 | /**
40 | * Class InkThreshold
41 | */
42 | class InkThreshold extends CommonDBTM
43 | {
44 | /**
45 | * @param $target
46 | * @param $id
47 | */
48 | function showSetupForm($target, $id)
49 | {
50 |
51 | $threshold = new InkThreshold();
52 | $inkthresholds = $threshold->find(["printers_id" => $id]);
53 |
54 | if (count($inkthresholds) == 0) {
55 | $this->add(["printers_id" => $id]);
56 | }
57 | $threshold = new InkThreshold();
58 | $threshold->getFromDBByCrit(["printers_id" => $id]);
59 |
60 | echo "