@@ -245,23 +245,34 @@ public function showAgentOnlineStats() {
245245 INNER JOIN " . $ FlyvemdmAgent . " AS f ON l.`items_id` = f.`id`
246246 WHERE l.`itemtype`='PluginFlyvemdmAgent' AND l.`id_search_option`='8'
247247 ORDER BY agent_id ASC, online_date ASC " ;
248- $ result = $ DB ->query ($ query );
249- if ($ result && $ DB ->numrows ($ result ) > 0 ) {
250- $ currentId = $ currentDate = null ;
251- while ($ row = $ DB ->fetch_assoc ($ result )) {
252- list ($ date , $ time ) = explode (' ' , $ row ['online_date ' ]);
253- //$domain[] = $date;
254- //$serie[] = strtotime($time);
255- if ($ currentId != $ row ['agent_id ' ]) {
256- $ currentId = $ row ['agent_id ' ];
257- $ range [$ currentId ]['name ' ] = $ row ['agent_name ' ] . ' (ID: ' . $ currentId . ') ' ;
258- $ range [$ currentId ]['data ' ] = [];
259- }
260- $ jsTime = strtotime ($ row ['online_date ' ]) * 1000 ;
261- $ range [$ currentId ]['data ' ][] = "{x: $ jsTime, y: $ jsTime} " ;
248+ $ request = [
249+ 'FIELDS ' => [$ logTable => ['new_value ' ], $ FlyvemdmAgent => ['id ' , 'name ' ]],
250+ 'FROM ' => $ logTable ,
251+ 'INNER JOIN ' => [
252+ $ FlyvemdmAgent => [
253+ 'FKEY ' => [
254+ $ FlyvemdmAgent => 'id ' ,
255+ $ logTable => 'items_id ' ,
256+ ],
257+ ],
258+ ],
259+ 'WHERE ' => ['itemtype ' => 'PluginFlyvemdmAgent ' , 'id_search_option ' => 8 ],
260+ 'ORDER ' => ['id ASC ' , 'new_value ASC ' ],
261+ ];
262+ $ currentId = $ currentDate = null ;
263+ foreach ($ DB ->request ($ request ) as $ data ) {
264+ list ($ date , $ time ) = explode (' ' , $ data ['new_value ' ]);
265+ //$domain[] = $date;
266+ //$serie[] = strtotime($time);
267+ if ($ currentId != $ data ['id ' ]) {
268+ $ currentId = $ data ['id ' ];
269+ $ range [$ currentId ]['name ' ] = $ data ['name ' ] . ' (ID: ' . $ currentId . ') ' ;
270+ $ range [$ currentId ]['data ' ] = [];
262271 }
263- //$domain = array_unique($domain);
272+ $ jsTime = strtotime ($ data ['new_value ' ]) * 1000 ;
273+ $ range [$ currentId ]['data ' ][] = "{x: $ jsTime, y: $ jsTime} " ;
264274 }
275+ //$domain = array_unique($domain);
265276
266277 $ out = $ this ->displayLineGraph (
267278 __ ('Online Agents ' , 'flyvemdm ' ),
0 commit comments