summaryrefslogtreecommitdiffstats
path: root/modules/monitoring/application/views/scripts/show/components/notifications.phtml
blob: 3e8c665840f89090bc59cafed6d1a35c07405c7d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<tr>
    <th><?= $this->translate('Notifications') ?></th>
    <td>
        <?php
        /** @var \Icinga\Module\Monitoring\Object\MonitoredObject $object */
        if ($this->hasPermission('monitoring/command/send-custom-notification')) {
            if ($object->getType() === $object::TYPE_HOST) {
                /** @var \Icinga\Module\Monitoring\Object\Host $object */
                echo $this->qlink(
                    $this->translate('Send notification'),
                    'monitoring/host/send-custom-notification',
                    array('host' => $object->getName()),
                    array(
                        'class'             => 'action-link',
                        'data-base-target'  => '_self',
                        'icon'              => 'bell',
                        'title'             => $this->translate(
                            'Send a custom notification to contacts responsible for this host'
                        )
                    )
                );
            } else {
                /** @var \Icinga\Module\Monitoring\Object\Service $object */
                echo $this->qlink(
                    $this->translate('Send notification'),
                    'monitoring/service/send-custom-notification',
                    array('host' => $object->getHost()->getName(), 'service' => $object->getName()),
                    array(
                        'class'             => 'action-link',
                        'data-base-target'  => '_self',
                        'icon'              => 'bell',
                        'title'             => $this->translate(
                            'Send a custom notification to contacts responsible for this service'
                        )
                    )
                );
            }
            if (! in_array((int) $object->state, array(0, 99))) {
                echo '<br>';
            }
        } elseif (in_array((int) $object->state, array(0, 99))) {
            echo '&#45;';
        }
        // We are not interested in notifications for OK or pending objects
        if (! in_array((int) $object->state, array(0, 99))) {
            if ($object->current_notification_number > 0) {
                if ((int) $object->current_notification_number === 1) {
                    $msg = sprintf(
                        $this->translate('A notification has been sent for this issue %s.'),
                        $this->timeAgo($object->last_notification)
                    );
                } else {
                    $msg = sprintf(
                        $this->translate('%d notifications have been sent for this issue.'),
                        $object->current_notification_number
                    ) . '<br>' . sprintf(
                        $this->translate('The last one was sent %s.'),
                        $this->timeAgo($object->last_notification)
                    );
                }
            } else {
                $msg = $this->translate('No notification has been sent for this issue.');
            }
            echo $msg;
        }
        ?>
    </td>
</tr>