Skip to content

Commit

Permalink
добавлена возможность просмотра онлайн-пользователей
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroslav Snisar committed Sep 26, 2014
1 parent 340770c commit 73127e1
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 34 deletions.
1 change: 1 addition & 0 deletions DB/HD.db.sql
Expand Up @@ -343,6 +343,7 @@ CREATE TABLE `users` (
`lang` varchar(11) NOT NULL DEFAULT 'ru',
`priv_add_client` int(11) NOT NULL DEFAULT '1',
`priv_edit_client` int(11) NOT NULL DEFAULT '1',
`last_time` datetime DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=9 DEFAULT CHARSET=utf8;

Expand Down
5 changes: 4 additions & 1 deletion actions.php
Expand Up @@ -1399,7 +1399,10 @@

if (strtotime($current_ticket_update) > strtotime($lu)) {echo $current_ticket_update;}
if (strtotime($current_ticket_update) <= strtotime($lu)) {echo "no";}

//update
$stmt = $dbConnection->prepare('update users set last_time=now() where id=:cid');
$stmt->execute(array(':cid' => $uid));

}


Expand Down
18 changes: 18 additions & 0 deletions functions.inc.php
Expand Up @@ -534,6 +534,24 @@ function validate_user($user_id, $input) {
}
}

function get_user_status($in) {
global $dbConnection;

$stmt = $dbConnection->prepare('select last_time from users where id=:in');
$stmt->execute(array(':in' => $in));
$total_ticket = $stmt->fetch(PDO::FETCH_ASSOC);
$lt=$total_ticket['last_time'];
$d = time()-strtotime($lt);
if ($d > 20) {
$lt_tooltip="";
if ($lt) {$lt_tooltip=lang('stats_last_time')."<br>".$lt;}

$res="<span data-toggle=\"tooltip\" data-placement=\"bottom\" class=\"label label-default\" data-original-title=\"".$lt_tooltip."\" data-html=\"true\">offline</span>";}
else {$res="<span class=\"label label-success\">online</span>";}

return $res;
}

function get_ticket_id_by_hash($in) {
global $dbConnection;

Expand Down
4 changes: 3 additions & 1 deletion inc/all_stats.php
Expand Up @@ -74,6 +74,7 @@
<tbody>
<tr>
<td style="width: 200px;"> <strong><small><center><?=lang('ALLSTATS_user_fio');?> </center></small></strong></td>
<td style=""> <strong><small><center><?=lang('t_LIST_status');?> </center></small></strong></td>
<td style=""> <strong><small><center><?=lang('ALLSTATS_user_free');?> </center></small></strong></td>
<td style=""> <strong><small><center><?=lang('ALLSTATS_user_lock');?> </center></small></strong></td>
<td style=""> <strong><small><center><?=lang('ALLSTATS_user_ok');?> </center></small></strong></td>
Expand Down Expand Up @@ -101,12 +102,13 @@

<tr>
<td style="width: 200px;"><small><?=name_of_user_ret($row['id']);?></small></td>
<td style=""><small class="text-danger"><center><?=get_user_status($row['id']);?></center></small></td>
<td style=""><small class="text-danger"><center><?=get_total_tickets_free($row['id']);?></center></small></td>
<td style=""><small class="text-warning"><center><?=get_total_tickets_lock($row['id']);?></center></small></td>
<td style=""><small class="text-success"><center><?=get_total_tickets_ok($row['id']);?></center></small></td>
<td style=""><small class=""><center><?=get_total_tickets_out($row['id']);?></center></small></td>
<td style=""><small class=""><center><?=get_total_tickets_out_and_success($row['id']);?></center></small></td>
</tr>
</tr>



Expand Down
30 changes: 1 addition & 29 deletions js/core.js
Expand Up @@ -973,11 +973,7 @@ if (ispath('files')) {
check_update();
},5000);
}
if (ispath('main_stats')) {
setInterval(function(){
check_update();
},5000);
}




Expand Down Expand Up @@ -3239,30 +3235,6 @@ $(this).removeClass('fileupload-processing');









/*
if( $('tr#up_entry').length ) // use this if you are using id to check
{
$('#fileupload').fileupload('disable');
if (check_form_ticket() == 0 ) {
$('#fileupload').fileupload('enable');
$('#start_upload').click();
}
}
*/






Expand Down
2 changes: 1 addition & 1 deletion lang/lang.en.php
Expand Up @@ -15,7 +15,7 @@ function lang ($phrase) {
'ALLSTATS_user_ok' => 'Executed',
'ALLSTATS_user_out_all' => 'Create (of)',
'ALLSTATS_user_out_all_not' => 'Create (not performance)',

'stats_last_time'=>'Last login: ',



Expand Down
2 changes: 1 addition & 1 deletion lang/lang.ru.php
Expand Up @@ -148,7 +148,7 @@ function lang($phrase){
't_LIST_to'=>'Исполнитель',
't_LIST_status'=>'Статус',
't_LIST_action'=>'Действие',

'stats_last_time'=>'Последний вход: ',
't_list_a_nook'=>'отметить, как выполненное',
't_list_a_unlock'=>'разблокировать',
't_list_a_lock'=>'заблокировать',
Expand Down
2 changes: 1 addition & 1 deletion lang/lang.ua.php
Expand Up @@ -17,7 +17,7 @@ function lang($phrase){
'ALLSTATS_user_ok' => 'Виконаних',
'ALLSTATS_user_out_all' => 'Створенню (всього)',
'ALLSTATS_user_out_all_not' => 'Створенню (не виконання)',

'stats_last_time'=>'Останній вхід: ',

'NAVBAR_files'=>'Файли заявок',
'FILES_title' => 'Файли заявок',
Expand Down

2 comments on commit 73127e1

@lemial
Copy link

@lemial lemial commented on 73127e1 Sep 29, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$stats_last_time - нигде не использован? может не доделали что-то? проверьте плиз!

@dima-bzz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Такого нет в коде есть просто stats_last_time!

Please sign in to comment.