Ignore:
Timestamp:
Oct 26, 2015, 12:27:20 AM (9 years ago)
Author:
chronos
Message:
  • Modified: Notification about network state should send only state changes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Modules/Notify/Notify.php

    r754 r757  
    5151      {
    5252        if($Category['SysName'] == 'NetworkReachability') {
    53           $DbResult3 = $this->Database->query('SELECT `Id`, `Name`, `Online`, `LastOnline` FROM `NetworkDevice` WHERE
    54             (`LastOnline` > "'.$User['LastTime'].'") AND (`LastOnline` <= "'.TimeToMysqlDateTime($Time).'") '.
    55             'AND (`PermanentOnline` = 1)');
     53          $DbResult3 = $this->Database->query('SELECT CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) AS `Name`, '.
     54            '`NetworkInterfaceUpDown`.`State`, `NetworkInterfaceUpDown`.`Duration`, `NetworkInterfaceUpDown`.`Time` FROM `NetworkInterfaceUpDown` '.
     55            'LEFT JOIN `NetworkInterface` ON `NetworkInterface`.`Id` = `NetworkInterfaceUpDown`.`Interface` '.
     56            'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
     57            'WHERE (`Time` > "'.$User['LastTime'].'") AND (`Time` <= "'.TimeToMysqlDateTime($Time).'") AND (`NetworkDevice`.`PermanentOnline`=1)');
    5658          if($DbResult3->num_rows > 0) {
    5759            $Output .= 'Category '.$Category['Name'].":\n";
    5860            $Content .= 'Category '.$Category['Name']."<br>\n";
    59             $Content .= '<table><tr><th>Jméno</th><th>Stav</th><th>Čas</th></tr>'."\n";
     61            $Content .= '<table><tr><th align="center">Jméno</th><th align="center">Stav</th><th align="center">Čas</th><th align="center">Trvání</th></tr>'."\n";
    6062            while($Item = $DbResult3->fetch_assoc())
    6163            {
    62               $Content .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].'</td><td>'.$Item['LastOnline'].'</td></tr>'."\n";
     64              $Duration = sprintf('%02d', floor($Item['Duration'] / 3600 % 24)).':'.
     65                sprintf('%02d', floor($Item['Duration'] / 60 % 60)).':'.
     66                sprintf('%02d', floor($Item['Duration'] % 60));
     67              $Days = floor($Item['Duration'] / (60 * 60 * 24));
     68              if($Days > 0) $Duration = $Days.' dnů '.$Duration;
     69
     70              $Content .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['State']].
     71                '</td><td>'.$Item['Time'].'</td><td>'.$Duration.'</td></tr>'."\n";
    6372            }
    6473            $Content .= '</table>'."\n";
Note: See TracChangeset for help on using the changeset viewer.