if ($chat->nick == '') { $chat->nick = erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Visitor'); } erLhcoreClassModelChat::detectLocation($chat); $chat->priority = is_numeric($Params['user_parameters_unordered']['priority']) ? (int) $Params['user_parameters_unordered']['priority'] : $chat->department->priority; $chat->chat_initiator = erLhcoreClassModelChat::CHAT_INITIATOR_PROACTIVE; // Store chat erLhcoreClassChat::getSession()->save($chat); // Mark as user has read message from operator. $userInstance->message_seen = 1; $userInstance->message_seen_ts = time(); $userInstance->chat_id = $chat->id; $userInstance->saveThis(); $chat->online_user_id = $userInstance->id; if (erLhcoreClassModelChatConfig::fetch('track_footprint')->current_value == 1) { erLhcoreClassModelChatOnlineUserFootprint::assignChatToPageviews($userInstance); } // Store Message from operator $msg = new erLhcoreClassModelmsg(); $msg->msg = trim($userInstance->operator_message); $msg->chat_id = $chat->id; $msg->name_support = $userInstance->operator_user !== false ? trim($userInstance->operator_user->name . ' ' . $userInstance->operator_user->surname) : (!empty($userInstance->operator_user_proactive) ? $userInstance->operator_user_proactive : erTranslationClassLhTranslation::getInstance()->getTranslation('chat/startchat', 'Live Support')); $msg->user_id = $userInstance->operator_user_id > 0 ? $userInstance->operator_user_id : 1; $msg->time = time() - 7; // Deduct 7 seconds so for user all looks more natural erLhcoreClassChat::getSession()->save($msg); // Store User Message $msg = new erLhcoreClassModelmsg(); $msg->msg = trim($inputData->question); $msg->chat_id = $chat->id; $msg->user_id = 0;