public function __get($var) { switch ($var) { case 'time_created_front': $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time); return $this->time_created_front; break; case 'user_closed_ts_front': $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts); return $this->user_closed_ts_front; break; case 'is_operator_typing': $this->is_operator_typing = $this->operator_typing > time() - 60; // typing is considered if status did not changed for 30 seconds return $this->is_operator_typing; break; case 'is_user_typing': $this->is_user_typing = $this->user_typing > time() - 10; // typing is considered if status did not changed for 30 seconds return $this->is_user_typing; break; case 'wait_time_seconds': $this->wait_time_seconds = time() - $this->time; return $this->wait_time_seconds; case 'wait_time_front': $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time); return $this->wait_time_front; break; case 'wait_time_pending': $this->wait_time_pending = erLhcoreClassChat::formatSeconds(time() - $this->time); return $this->wait_time_pending; break; case 'chat_duration_front': $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration); return $this->chat_duration_front; break; case 'user_name': return $this->user_name = (string) $this->user; break; case 'plain_user_name': $this->plain_user_name = false; if ($this->user !== false) { $this->plain_user_name = (string) $this->user->name_support; } return $this->plain_user_name; break; case 'user': $this->user = false; if ($this->user_id > 0) { try { $this->user = erLhcoreClassModelUser::fetch($this->user_id, true); } catch (Exception $e) { $this->user = false; } } return $this->user; break; case 'operator_typing_user': $this->operator_typing_user = false; if ($this->operator_typing_id > 0) { try { $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id); } catch (Exception $e) { $this->operator_typing_user = false; } } return $this->operator_typing_user; break; case 'online_user': $this->online_user = false; if ($this->online_user_id > 0) { try { $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id); } catch (Exception $e) { $this->online_user = false; } } return $this->online_user; break; case 'department': $this->department = false; if ($this->dep_id > 0) { try { $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true); } catch (Exception $e) { } } return $this->department; break; case 'product': $this->product = false; if ($this->product_id > 0) { try { $this->product = erLhAbstractModelProduct::fetch($this->product_id, true); } catch (Exception $e) { } } return $this->product; break; case 'product_name': $this->product_name = (string) $this->product; return $this->product_name; break; case 'department_name': return $this->department_name = (string) $this->department; break; case 'number_in_queue': $this->number_in_queue = 1; if ($this->status == self::STATUS_PENDING_CHAT) { $this->number_in_queue = erLhcoreClassChat::getCount(array('filterlt' => array('id' => $this->id), 'filter' => array('dep_id' => $this->dep_id, 'status' => self::STATUS_PENDING_CHAT))) + 1; } return $this->number_in_queue; break; case 'screenshot': $this->screenshot = false; if ($this->screenshot_id > 0) { try { $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id); } catch (Exception $e) { } } return $this->screenshot; break; case 'unread_time': $diff = time() - $this->last_user_msg_time; $hours = floor($diff / 3600); $minits = floor(($diff - $hours * 3600) / 60); $seconds = $diff - $hours * 3600 - $minits * 60; $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds); return $this->unread_time; break; case 'user_tz_identifier_time': $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier)); $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat); return $this->user_tz_identifier_time; break; case 'additional_data_array': $jsonData = json_decode($this->additional_data); if ($jsonData !== null) { $this->additional_data_array = $jsonData; } else { $this->additional_data_array = $this->additional_data; } return $this->additional_data_array; break; case 'chat_variables_array': if (!empty($this->chat_variables)) { $jsonData = json_decode($this->chat_variables, true); if ($jsonData !== null) { $this->chat_variables_array = $jsonData; } else { $this->chat_variables_array = $this->chat_variables; } } else { $this->chat_variables_array = $this->chat_variables; } return $this->chat_variables_array; break; case 'user_status_front': if ($this->online_user !== false) { $this->user_status_front = erLhcoreClassChat::setActivityByChatAndOnlineUser($this, $this->online_user); } else { $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1; } return $this->user_status_front; break; default: break; } }
public function __get($var) { switch ($var) { case 'time_created_front': $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time); return $this->time_created_front; break; case 'user_closed_ts_front': $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts); return $this->user_closed_ts_front; break; case 'is_operator_typing': $this->is_operator_typing = $this->operator_typing > time() - 60; // typing is considered if status did not changed for 30 seconds return $this->is_operator_typing; break; case 'is_user_typing': $this->is_user_typing = $this->user_typing > time() - 10; // typing is considered if status did not changed for 30 seconds return $this->is_user_typing; break; case 'wait_time_front': $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time); return $this->wait_time_front; break; case 'chat_duration_front': $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration); return $this->chat_duration_front; break; case 'user_name': return $this->user_name = (string) $this->user; break; case 'user': $this->user = false; if ($this->user_id > 0) { try { $this->user = erLhcoreClassModelUser::fetch($this->user_id, true); } catch (Exception $e) { $this->user = false; } } return $this->user; break; case 'operator_typing_user': $this->operator_typing_user = false; if ($this->operator_typing_id > 0) { try { $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id); } catch (Exception $e) { $this->operator_typing_user = false; } } return $this->operator_typing_user; break; case 'online_user': $this->online_user = false; if ($this->online_user_id > 0) { try { $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id); } catch (Exception $e) { $this->online_user = false; } } return $this->online_user; break; case 'department': $this->department = false; if ($this->dep_id > 0) { try { $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true); } catch (Exception $e) { } } return $this->department; break; case 'department_name': return $this->department_name = (string) $this->department; break; case 'screenshot': $this->screenshot = false; if ($this->screenshot_id > 0) { try { $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id); } catch (Exception $e) { } } return $this->screenshot; break; case 'unread_time': $diff = time() - $this->last_user_msg_time; $hours = floor($diff / 3600); $minits = floor(($diff - $hours * 3600) / 60); $seconds = $diff - $hours * 3600 - $minits * 60; $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds); return $this->unread_time; break; case 'user_tz_identifier_time': $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier)); $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat); return $this->user_tz_identifier_time; break; case 'additional_data_array': $jsonData = json_decode($this->additional_data); if ($jsonData !== null) { $this->additional_data_array = $jsonData; } else { $this->additional_data_array = $this->additional_data; } return $this->additional_data_array; break; case 'chat_variables_array': if (!empty($this->chat_variables)) { $jsonData = json_decode($this->chat_variables, true); if ($jsonData !== null) { $this->chat_variables_array = $jsonData; } else { $this->chat_variables_array = $this->chat_variables; } } else { $this->chat_variables_array = $this->chat_variables; } return $this->chat_variables_array; break; default: break; } }
foreach ($numberOfChatsPerHour as $hour => $chatsNumber) { ?> <?php echo ',[\'' . $hour . '\',' . $chatsNumber . ']'; ?> <?php } ?> ]); var view = new google.visualization.DataView(data); var options = { title: '<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Number of chats per hour, average chat duration'); ?> <?php echo $averageChatTime != null ? erLhcoreClassChat::formatSeconds($averageChatTime) : '(-)'; ?> ', width: '100%', height: '100%', isStacked: true }; var chartUp = new google.visualization.ColumnChart(document.getElementById('chart_div_per_hour')); chartUp.draw(view, options); } $(window).on("resize", function (event) { redrawAllCharts(100); }); $( document ).ready(function() { redrawAllCharts(100);
foreach ($numberOfChatsPerHour as $hour => $chatsNumber) { ?> <?php echo ',[\'' . $hour . '\',' . $chatsNumber . ']'; ?> <?php } ?> ]); var view = new google.visualization.DataView(data); var options = { title: '<?php echo erTranslationClassLhTranslation::getInstance()->getTranslation('chat/statistic', 'Number of chats per hour, average chat duration'); ?> <?php echo erLhcoreClassChat::formatSeconds(erLhcoreClassChatStatistic::getAverageChatduration()); ?> ', width: '100%', height: '100%', isStacked: true }; var chartUp = new google.visualization.ColumnChart(document.getElementById('chart_div_per_hour')); chartUp.draw(view, options); } $(window).on("resize", function (event) { redrawAllCharts(100); }); $( document ).ready(function() { redrawAllCharts(100);
public function __get($var) { switch ($var) { case 'time_created_front': $this->time_created_front = date('Ymd') == date('Ymd', $this->time) ? date(erLhcoreClassModule::$dateHourFormat, $this->time) : date(erLhcoreClassModule::$dateDateHourFormat, $this->time); return $this->time_created_front; break; case 'user_closed_ts_front': $this->user_closed_ts_front = date('Ymd') == date('Ymd', $this->user_closed_ts) ? date(erLhcoreClassModule::$dateHourFormat, $this->user_closed_ts) : date(erLhcoreClassModule::$dateDateHourFormat, $this->user_closed_ts); return $this->user_closed_ts_front; break; case 'is_operator_typing': $this->is_operator_typing = $this->operator_typing > time() - 60; // typing is considered if status did not changed for 30 seconds return $this->is_operator_typing; break; case 'is_user_typing': $this->is_user_typing = $this->user_typing > time() - 10; // typing is considered if status did not changed for 30 seconds return $this->is_user_typing; break; case 'wait_time_seconds': $this->wait_time_seconds = time() - $this->time; return $this->wait_time_seconds; case 'wait_time_front': $this->wait_time_front = erLhcoreClassChat::formatSeconds($this->wait_time); return $this->wait_time_front; break; case 'wait_time_pending': $this->wait_time_pending = erLhcoreClassChat::formatSeconds(time() - $this->time); return $this->wait_time_pending; break; case 'chat_duration_front': $this->chat_duration_front = erLhcoreClassChat::formatSeconds($this->chat_duration); return $this->chat_duration_front; break; case 'user_name': return $this->user_name = (string) $this->user; break; case 'plain_user_name': $this->plain_user_name = false; if ($this->user !== false) { $this->plain_user_name = (string) $this->user->name_support; } return $this->plain_user_name; break; case 'user': $this->user = false; if ($this->user_id > 0) { try { $this->user = erLhcoreClassModelUser::fetch($this->user_id, true); } catch (Exception $e) { $this->user = false; } } return $this->user; break; case 'operator_typing_user': $this->operator_typing_user = false; if ($this->operator_typing_id > 0) { try { $this->operator_typing_user = erLhcoreClassModelUser::fetch($this->operator_typing_id); } catch (Exception $e) { $this->operator_typing_user = false; } } return $this->operator_typing_user; break; case 'online_user': $this->online_user = false; if ($this->online_user_id > 0) { try { $this->online_user = erLhcoreClassModelChatOnlineUser::fetch($this->online_user_id); } catch (Exception $e) { $this->online_user = false; } } return $this->online_user; break; case 'department': $this->department = false; if ($this->dep_id > 0) { try { $this->department = erLhcoreClassModelDepartament::fetch($this->dep_id, true); } catch (Exception $e) { } } return $this->department; break; case 'department_name': return $this->department_name = (string) $this->department; break; case 'number_in_queue': $this->number_in_queue = 1; if ($this->status == self::STATUS_PENDING_CHAT) { $this->number_in_queue = erLhcoreClassChat::getCount(array('filterlt' => array('id' => $this->id), 'filter' => array('dep_id' => $this->dep_id, 'status' => self::STATUS_PENDING_CHAT))) + 1; } return $this->number_in_queue; break; case 'screenshot': $this->screenshot = false; if ($this->screenshot_id > 0) { try { $this->screenshot = erLhcoreClassModelChatFile::fetch($this->screenshot_id); } catch (Exception $e) { } } return $this->screenshot; break; case 'unread_time': $diff = time() - $this->last_user_msg_time; $hours = floor($diff / 3600); $minits = floor(($diff - $hours * 3600) / 60); $seconds = $diff - $hours * 3600 - $minits * 60; $this->unread_time = array('hours' => $hours, 'minits' => $minits, 'seconds' => $seconds); return $this->unread_time; break; case 'user_tz_identifier_time': $date = new DateTime(null, new DateTimeZone($this->user_tz_identifier)); $this->user_tz_identifier_time = $date->format(erLhcoreClassModule::$dateHourFormat); return $this->user_tz_identifier_time; break; case 'additional_data_array': $jsonData = json_decode($this->additional_data); if ($jsonData !== null) { $this->additional_data_array = $jsonData; } else { $this->additional_data_array = $this->additional_data; } return $this->additional_data_array; break; case 'chat_variables_array': if (!empty($this->chat_variables)) { $jsonData = json_decode($this->chat_variables, true); if ($jsonData !== null) { $this->chat_variables_array = $jsonData; } else { $this->chat_variables_array = $this->chat_variables; } } else { $this->chat_variables_array = $this->chat_variables; } return $this->chat_variables_array; break; /** * @desc Returns user status based on the following logic * 1. Green - if widget is not closed * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes * * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site * 5. Yellow - from last user message has passed 5 minutes but user still on site * * 6. Widget is closed and we could not determine online user || None of above conditions are met. * * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout * * @param array $params * * 1 GREEN user has activity in last 5 minutes and ping respond * 2 ORANGE user has no activity in last 5 minutes and ping respond * 3 GREY Offline user fails to respond pings for X number of times in a row * * @return int */ /** * @desc Returns user status based on the following logic * 1. Green - if widget is not closed * 2. Green - if widget is closed and user activity tracking enabled and user still on site and he is active * 3. Green - if widget is closed and user activity tracking is disabled, but we still receive pings and from last user message has not passed 5 minutes * * 4. Yellow - if widget is closed and user activity tracking enabled, but user is not active but he is still on site * 5. Yellow - from last user message has passed 5 minutes but user still on site * * 6. Widget is closed and we could not determine online user || None of above conditions are met. * * If user activity tracking is enabled but status checking not we default to 10 seconds status checks timeout * * @param array $params * * 1 GREEN user has activity in last 5 minutes and ping respond * 2 ORANGE user has no activity in last 5 minutes and ping respond * 3 GREY Offline user fails to respond pings for X number of times in a row * * @return int */ case 'user_status_front': $this->user_status_front = $this->user_status == self::USER_STATUS_JOINED_CHAT ? 0 : 1; if ($this->user_status_front == self::USER_STATUS_CLOSED_CHAT && $this->online_user !== false || erLhcoreClassChat::$onlineCondition == 1 && $this->online_user !== false) { $timeout = (int) erLhcoreClassChat::$trackTimeout || 10; if (erLhcoreClassChat::$trackActivity == true) { if ($this->online_user->last_check_time_ago < $timeout + 10 && $this->online_user->user_active == 1) { //User still on site, it does not matter that he have closed widget. $this->user_status_front = 0; } elseif ($this->online_user->user_active == 0 && $this->online_user->last_check_time_ago < $timeout + 10) { $this->user_status_front = 2; } } else { if ($this->online_user->last_check_time_ago < $timeout + 10 && time() - $this->last_user_msg_time < 300) { //User still on site, it does not matter that he have closed widget. $this->user_status_front = 0; } elseif (time() - $this->last_user_msg_time >= 300 && $this->online_user->last_check_time_ago < $timeout + 10) { $this->user_status_front = 2; } } } return $this->user_status_front; break; default: break; } }