eqeqwan21

get_outlog

Aug 24th, 2025
354
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.77 KB | None | 0 0
  1. private function get_outlog()
  2.  {
  3.     $where = "where OutgoingLog.queued >=from_unixtime(?)";
  4.     $param = array($_GET['start']);
  5.     if(isset($_GET['end'])) {
  6.         $where = "where OutgoingLog.queued between from_unixtime(?) and from_unixtime(?)";
  7.         $param = array($_GET['start'],$_GET['end']);
  8.     }
  9.    
  10.     if(isset($_GET['device'])) {
  11.         $where .= " and OutgoingLog.Devices_id=?";
  12.         $param[] = $_GET['device'];
  13.     }
  14. //v13_фильтрация по городу
  15.      if(isset($_GET['town'])) {
  16.          $where .= " and Town.Name=?";
  17.          $param[] = $_GET['town'];
  18.      }
  19.  
  20.     if(isset($_GET['type']) && $_GET['type']>0) {
  21.         $where .= " and Devices.Type=?";
  22.         $param[] = $_GET['type'];
  23.     }
  24. //v13_фильтрация по городу
  25.     $sql =
  26.     "SELECT
  27.     UNIX_TIMESTAMP(OutgoingLog.queued) as unixqueued,
  28.    UNIX_TIMESTAMP(OutgoingLog.pbxtime) as unixpbxtime,
  29.    UNIX_TIMESTAMP(OutgoingLog.finished) as unixfinished,
  30.    TIME_FORMAT( TIMEDIFF(NOW(), UTC_TIMESTAMP),'%H:%i' ) as tz, OutgoingLog.*,
  31.    Devices.Name, Devices.CustomNum, Devices.sn, Devices.Location, ServerCommand.Name as ServerCommandName, ServerCommand.Letter,
  32.      IF(ServerCommand.label IS NULL or ServerCommand.label = '', ServerCommand.Name, ServerCommand.label) as label, ServerCommand.type,
  33.    CASE
  34.        WHEN OutgoingLog.errortext LIKE 'user:%'
  35.          THEN SUBSTRING(OutgoingLog.errortext, 6)
  36.        ELSE OutgoingLog.DeviceNUM
  37.      END AS DeviceNUM
  38.    FROM OutgoingLog
  39.    left join Devices on Devices.id = OutgoingLog.Devices_id
  40.    left join Town on Town.id = Devices.Town_id
  41.    left join ServerCommand on ServerCommand.id = OutgoingLog.ServerCommand_id
  42.    $where
  43.     order by OutgoingLog.id desc limit {$this->cnf['default_query_limit']}";
  44.    
  45.     $this->run_query($sql, $param, ['OutgoingLog', 'Devices']);
  46.  }
Advertisement
Add Comment
Please, Sign In to add comment