Changeset 762


Ignore:
Timestamp:
Nov 5, 2015, 9:38:59 AM (9 years ago)
Author:
chronos
Message:
  • Modified: Notification of network interface state now show separate state table for "Now online", "Now offline", "Still offline".
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Application/Version.php

    r761 r762  
    11<?php
    22
    3 $Revision = 761; // Subversion revision
    4 $DatabaseRevision = 759; // SQL structure revision
    5 $ReleaseTime = strtotime('2015-10-26');
     3$Revision = 762; // Subversion revision
     4$DatabaseRevision = 762; // SQL structure revision
     5$ReleaseTime = strtotime('2015-11-05');
  • trunk/Common/Setup/Updates.php

    r761 r762  
    15921592}
    15931593*/
     1594
     1595function UpdateTo762($Manager)
     1596{
     1597  $Manager->Execute('ALTER TABLE `NetworkDevice` ADD `OnlineNotify` INT NOT NULL AFTER `API`;');
     1598}
     1599
     1600
    15941601
    15951602class Updates
     
    16681675      752 => array('Revision' => 755, 'Function' => 'UpdateTo755'),
    16691676      755 => array('Revision' => 759, 'Function' => 'UpdateTo759'),
     1677      759 => array('Revision' => 762, 'Function' => 'UpdateTo762'),
    16701678    ));
    16711679  }
  • trunk/Modules/Notify/Notify.php

    r758 r762  
    3535  }
    3636
     37  function OnlineList($Title, $OnlineNow, $OnlinePrevious)
     38  {
     39    $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
     40    $Output = '';
     41    $DbResult3 = $this->Database->query('SELECT CONCAT_WS("-", `NetworkDevice`.`Name`, NULLIF(`NetworkInterface`.`Name`, "")) AS `Name`, '.
     42      '`NetworkDevice`.`Online`, `NetworkDevice`.`LastOnline` FROM `NetworkInterface` '.
     43      'LEFT JOIN `NetworkDevice` ON `NetworkDevice`.`Id` = `NetworkInterface`.`Device` '.
     44      'WHERE (`NetworkDevice`.`Online` = '.$OnlineNow.') AND (`NetworkDevice`.`OnlineNotify` = '.$OnlinePrevious.') '.
     45      'AND (`NetworkDevice`.`PermanentOnline`=1) ORDER BY `Name` DESC');
     46    if($DbResult3->num_rows > 0) {
     47      $Output .= $Title.'<br/>';
     48      $Output .= '<table border="1" cellspacing="0" cellpadding="5">'.
     49      '<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";
     50      while($Item = $DbResult3->fetch_assoc())
     51      {
     52        $Duration = MysqlDateTimeToTime($Item['LastOnline']);
     53        $DurationText = sprintf('%02d', floor($Duration / 3600 % 24)).':'.
     54            sprintf('%02d', floor($Duration / 60 % 60)).':'.
     55            sprintf('%02d', floor($Duration % 60));
     56        $Days = floor($Duration / (60 * 60 * 24));
     57        if($Days > 0) $DurationText = $Days.' dnů '.$DurationText;
     58
     59        $Output .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['Online']].
     60        '</td><td>'.$Item['LastOnline'].'</td><td>'.$DurationText.'</td></tr>'."\n";
     61      }
     62      $Output .= '</table><br/>'."\n";
     63    }
     64    return $Output;
     65  }
     66
    3767  function Check()
    3868  {
    39     $OnlineText = array('<span style="color:red;">Nedostupný</span>', '<span style="color:green;">Dostupný</span>');
     69          echo('ss');
    4070    $Output = '';
    4171    $DbResult = $this->Database->query('SELECT `NotifyUser`.`Id`, `NotifyUser`.`LastTime`, `User`.`Name`, `Contact`.`Value`, `Contact`.`Category` FROM `NotifyUser` '.
     
    5181      {
    5282        if($Category['SysName'] == 'NetworkReachability') {
    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).'") '.
    58             'AND (`NetworkDevice`.`PermanentOnline`=1) ORDER BY `NetworkInterfaceUpDown`.`Time` DESC');
    59           if($DbResult3->num_rows > 0) {
     83          $List = $this->OnlineList('Nově online', 1, 0);
     84          $List .= $this->OnlineList('Nově offline', 0, 1);
     85          $List .= $this->OnlineList('Stále offline', 0, 0);
     86          if($List != '') {
    6087            $Output .= 'Category '.$Category['Name'].":\n";
    6188            $Content .= 'Category '.$Category['Name']."<br>\n";
    62             $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";
    63             while($Item = $DbResult3->fetch_assoc())
    64             {
    65               $Duration = sprintf('%02d', floor($Item['Duration'] / 3600 % 24)).':'.
    66                 sprintf('%02d', floor($Item['Duration'] / 60 % 60)).':'.
    67                 sprintf('%02d', floor($Item['Duration'] % 60));
    68               $Days = floor($Item['Duration'] / (60 * 60 * 24));
    69               if($Days > 0) $Duration = $Days.' dnů '.$Duration;
    70 
    71               $Content .= '<tr><td>'.$Item['Name'].'</td><td>'.$OnlineText[$Item['State']].
    72                 '</td><td>'.$Item['Time'].'</td><td>'.$Duration.'</td></tr>'."\n";
    73             }
    74             $Content .= '</table>'."\n";
     89            $Content .= $List;
    7590          }
    7691        }
    7792      }
     93      $this->Database->query('UPDATE `NetworkDevice` SET `OnlineNotify` = `Online` '.
     94        'WHERE `OnlineNotify` != `Online`');
    7895      $this->Database->update('NotifyUser', '`Id`='.$User['Id'], array('LastTime' => TimeToMysqlDateTime($Time)));
    7996
Note: See TracChangeset for help on using the changeset viewer.