chat functions

This commit is contained in:
abdul-wahab12345 2024-08-01 17:26:06 +00:00
parent 6b51f6a402
commit 412ffc0e87
19 changed files with 26214 additions and 265 deletions

View File

@ -0,0 +1,86 @@
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Models\ChatGroup;
use App\Models\Ticket;
use App\Models\Response;
use App\Models\Message; // Assuming Message is the model for your messages table
use Illuminate\Support\Facades\DB;
class CheckChatGroupStatus extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'chatgroup:check-status';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Check ChatGroup status and create tickets if status is closed';
/**
* Execute the console command.
*
* @return int
*/
public function handle()
{
// Fetch all closed chat groups
$closedChatGroups = ChatGroup::where('status', 'closed')->get();
foreach ($closedChatGroups as $chatGroup) {
DB::transaction(function () use ($chatGroup) {
$company = get_company('id',$chatGroup->company_id);
$ticket = insertTicket($chatGroup->email, $company->email, $chatGroup->subject, '','chat',$chatGroup->name,$chatGroup->user_id,'done',true );
// Fetch all messages from the chat group
$messages = $chatGroup->messages;
// Insert each message as a response to the ticket
foreach ($messages as $message) {
// Create a new Response instance
$response = new Response;
$html = $message->message;
if($message->type == 'image'){
$html = "<img src='{$message->message}' />";
}
if($message->type == 'file'){
$html = "<a target='_blank' href='{$message->message}'>View File</a>";
}
// Set the properties of the Response
$response->message = $html;
$response->ticket_id = $ticket->id;
$response->user_id = $message->from == 'user'?0:1; // You may want to dynamically set the user_id based on the authenticated user
$response->created_at = $message->created_at;
$response->updated_at = $message->updated_at;
// Save the response to the database
$response->save();
}
// Optionally update the chat group status to indicate a ticket has been created
$chatGroup->update(['status' => 'ticket_created']);
});
}
$this->info('Chat groups checked and tickets created for closed statuses.');
return 0;
}
}

View File

@ -12,6 +12,7 @@ class Kernel extends ConsoleKernel
*/
protected function schedule(Schedule $schedule): void
{
$schedule->command('chatgroup:check-status')->everyMinute();
// $schedule->command('inspire')->hourly();
}

View File

@ -3,6 +3,7 @@
use App\Models\CompanyMeta;
use App\Models\Settings;
use App\Models\Ticket;
use App\Models\TicketMeta;
use App\Models\Response;
use App\Models\TicketNote;
use Illuminate\Support\Facades\Session;
@ -92,7 +93,7 @@ function verifyMailgunSignature($token, $timestamp, $signature)
}
//Insert Ticket
if (!function_exists('insertTicket')) {
function insertTicket($from_email, $to_email, $subject, $content, $type, $sender_name) {
function insertTicket($from_email, $to_email, $subject, $content, $type, $sender_name,$user_assigned = 0,$status = 'waiting',$force = false) {
$check = Ticket::where(function ($query) use ($from_email, $to_email) {
$query->where('from_email', $from_email)
@ -107,7 +108,7 @@ function insertTicket($from_email, $to_email, $subject, $content, $type, $sender
if(!$check){
if(!$check || $force){
$ticket = new Ticket;
$ticket->from_email = $from_email;
@ -117,9 +118,9 @@ function insertTicket($from_email, $to_email, $subject, $content, $type, $sender
$ticket->subject = $subject;
$ticket->content = $content;
$ticket->priority = 'low';
$ticket->status = 'waiting';
$ticket->status = $status;
$ticket->parent_id = 0;
$ticket->user_assigned = 0;
$ticket->user_assigned = $user_assigned;
$ticket->save();
}else{
@ -277,3 +278,32 @@ function getMessagesByChatId($chatId)
}
function setTicketMeta(int $ticketId, string $key, $value, string $type = 'string')
{
return TicketMeta::updateOrCreate(
['ticket_id' => $ticketId, 'key' => $key],
['value' => json_encode($value), 'type' => $type]
);
}
/**
* Get a meta value for a ticket.
*
* @param int $ticketId
* @param string $key
* @return string|null
*/
function getTicketMeta(int $ticketId, string $key)
{
$meta = TicketMeta::where('ticket_id', $ticketId)->where('key', $key)->first();
return $meta ? json_decode($meta->value) : null;
}
function getChatSetting($key)
{
$companyId = getSelectedCompany();
$get_chat_setting = CompanyMeta::where('company_id', $companyId)->where('key', $key)->where('type', 'Chat Setting')->first();
return $get_chat_setting;
}

View File

@ -4,15 +4,30 @@
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
use App\Models\Company;
use App\Models\ChatGroup;
use App\Models\Message;
use Illuminate\Support\Facades\Validator;
use Illuminate\Support\Facades\Storage;
class ChatController extends Controller
{
public function CloseChat(Request $request){
$chat_id = $request->chat_id;
$chat = ChatGroup::find($chat_id);
if($chat){
$chat->status = 'closed';
$chat->save();
return true;
}else{
return false;
}
}
public function getChat(Request $request){
$chat_id = $request->chat_id;
@ -83,20 +98,27 @@ public function sendMessage(Request $request)
'chat_id' => 'required|integer|exists:chat_group,id',
'from' => 'required|string|max:255',
//'to' => 'required|string|max:255',
'message' => 'required|string',
//'message' => 'required|string',
'type' => 'required|string|max:255'
]);
if ($validator->fails()) {
return response()->json(['errors' => $validator->errors()], 422);
}
$fileUrl = '';
if ($request->hasFile('file')) {
$file = $request->file('file');
$filePath = $file->store('chat', 'public'); // Store in the 'public/uploads' directory
$fileUrl = url(Storage::url($filePath)); // Generate the file URL
}
$data = [
'chat_id' => $request->chat_id,
'from' => $request->from,
'to' => $request->from == 'user'?'company':'user',
'message' => $request->message,
'message' => $request->hasFile('file')? $fileUrl: $request->message,
'type' => $request->type,
@ -129,8 +151,41 @@ public function getChatGroupsByCompany(Request $request)
{
$companyId = getSelectedCompany();
$chatGroups = ChatGroup::where('company_id', $companyId)->get();
$chatGroups = ChatGroup::where('company_id', $companyId)
->where(function($query) {
$query->where('status', '!=', 'ticket_created')
->where('status', '!=', 'closed');
})
->get();
return response()->json($chatGroups);
}
public function checkChat(Request $request){
$company_id = $request->company_id;
$domain = $request->domain;
$company = get_company('id',$company_id);
if($company){
// Str::contains('This is my name', 'my')
if( $company->domain == $domain ){
$user_id = $this->select_user($company_id);
if($user_id){
return response()->json(['status' => 'success']);
}else{
return response()->json(['status' => 'error', 'message' => "No user is availble right now!"]);
}
}else{
return response()->json(['status' => 'error', 'message' => "You are not authorized!"]);
}
}
return response()->json(['status' => 'error', 'message' => "You are not authorized!"]);
}
}

View File

@ -0,0 +1,293 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Models\CompanyMeta;
class ChatSettingController extends Controller
{
public function chatSetting()
{
$display_chats = CompanyMeta::where('key', 'Display Chat')->where('type', 'Chat Setting')->get();
$hide_chats = CompanyMeta::where('key', 'Hide Chat')->where('type', 'Chat Setting')->first();
$canned_responses = CompanyMeta::where('key', 'Chat Canned Responses')->where('type', 'Chat Setting')->get();
return view('chat-setting', ['display_chats' => $display_chats, 'hide_chats' => $hide_chats, 'canned_responses' => $canned_responses]);
}
public function storeFlowSetting(Request $request)
{
$companyId = getSelectedCompany();
//Update Company Meta
$flow_setting = [
'show_profile_image_of_editors' => $request->show_profile_image_of_editors,
'allow_visitor_to_send_messages' => $request->allow_visitor_to_send_messages,
'max_number_of_chats_per_editor' => $request->max_number_of_chats_per_editor,
'save_email_address_for_anonymous_chat' => $request->save_email_address_for_anonymous_chat,
'delete_chat_data_automatically' => $request->delete_chat_data_automatically,
'delay_for_automatic_deletion' => $request->delay_for_automatic_deletion,
'allow_users_to_join_queue' => $request->allow_users_to_join_queue,
'show_chat_button' => $request->show_chat_button,
'visitor_can_send_images' => $request->visitor_can_send_images,
'guest_must_write_name_and_email_to_chat' => $request->guest_must_write_name_and_email_to_chat,
'logout_editor_who_missed_chat' => $request->logout_editor_who_missed_chat,
'logout_everyone_automatically' => $request->logout_everyone_automatically,
'chat_assistant_show_suggestion_form' => $request->chat_assistant_show_suggestion_form,
];
foreach($flow_setting as $key => $value) {
if(!is_null($value)) {
CompanyMeta::updateOrCreate([
'key' => $key,
'value' => $value
],[
'company_id' => $companyId,
'key' => $key,
'value' => $value,
'type' => 'Chat Setting'
]);
} else {
CompanyMeta::where('key', $key)->where('company_id', $companyId)->where('type', 'Chat Setting')->delete();
}
}
return redirect()->back()->with('success', 'Flow Setting Updated Successfully');
}
public function storeDisplayChat(Request $request)
{
$this->validate($request, [
'path' => 'required',
'start_chat_after' => 'required'
]);
$companyId = getSelectedCompany();
// Collect data into an array
$display_data = [
'path' => $request->path,
'start_chat_after' => $request->start_chat_after,
];
CompanyMeta::create([
'company_id' => $companyId,
'key' => 'Display Chat',
'value' =>json_encode($display_data),
'type' => 'Chat Setting'
]);
return redirect()->back()->with('success', 'Chat Setting Updated Successfully');
}
public function deleteDisplayChat($id)
{
$display_chat = CompanyMeta::find($id);
$display_chat->delete();
return redirect()->back()->with('success', 'Chat Setting Updated Successfully');
}
public function storeHideChat(Request $request)
{
$this->validate($request, [
'hide_chat_path' => 'required',
]);
$companyId = getSelectedCompany();
CompanyMeta::updateOrCreate([
'company_id' => $companyId,
'key' => 'Hide Chat',
],[
'company_id' => $companyId,
'key' => 'Hide Chat',
'value' => $request->hide_chat_path,
'type' => 'Chat Setting'
]);
return redirect()->back()->with('success', 'Chat Setting Updated Successfully');
}
public function storeText(Request $request)
{
$companyId = getSelectedCompany();
//Update Company Meta
$text_data = [
'public_name' => $request->public_name,
'internal_name' => $request->internal_name,
'wellcome_text' => $request->wellcome_text,
'wellcome_text_at_queue' => $request->wellcome_text_at_queue,
'start_message' => $request->start_message,
'text_in_message_box' => $request->text_in_message_box,
'message_when_chat_is_closed' => $request->message_when_chat_is_closed
];
foreach($text_data as $key => $value) {
if(!is_null($value)) {
CompanyMeta::updateOrCreate([
'key' => $key,
'company_id' => $companyId,
],[
'company_id' => $companyId,
'key' => $key,
'value' => $value,
'type' => 'Chat Setting'
]);
} else {
CompanyMeta::where('key', $key)->where('company_id', $companyId)->where('type', 'Chat Setting')->delete();
}
}
return response()->json(['success' => 'Text Setting Updated Successfully']);
}
public function storeStyle(Request $request)
{
$companyId = getSelectedCompany();
//Update Company Meta
$style_data = [
'text_theme_color' => $request->text_theme_color,
'background_theme_color' => $request->background_theme_color,
'text_color_for_sent_message' => $request->text_color_for_sent_message,
'background_color_of_sent_message' => $request->background_color_of_sent_message,
'text_color_of_received_message' => $request->text_color_of_received_message,
'text_color_of_notification' => $request->text_color_of_notification,
'text_color_of_error_message' => $request->text_color_of_error_message,
'background_color_of_error_message' => $request->background_color_of_error_message,
'link_color' => $request->link_color
];
foreach($style_data as $key => $value) {
if(!is_null($value)) {
CompanyMeta::updateOrCreate([
'key' => $key,
'company_id' => $companyId,
],[
'company_id' => $companyId,
'key' => $key,
'value' => $value,
'type' => 'Chat Setting'
]);
} else {
CompanyMeta::where('key', $key)->where('company_id', $companyId)->where('type', 'Chat Setting')->delete();
}
}
return redirect()->back()->with('success', 'Style Setting Updated Successfully');
}
public function storeChatCannedResponses(Request $request)
{
$this->validate($request, [
'name' => 'required',
'text' => 'required'
]);
$companyId = getSelectedCompany();
// Collect data into an array
$canned_data = [
'name' => $request->name,
'text' => $request->text,
];
// Encode the data array as JSON
$jsonData = json_encode($canned_data);
CompanyMeta::create([
'company_id' => $companyId,
'key' => 'Chat Canned Responses',
'value' => $jsonData,
'type' => 'Chat Setting'
]);
return redirect()->back()->with('success', 'Canned Response Setting Updated Successfully');
}
public function deleteChatCannedResponses($id)
{
$get_chat_canned_response = CompanyMeta::find($id);
$get_chat_canned_response->delete();
return redirect()->back()->with('success', 'Canned Response Deleted Successfully.');
}
public function storePersonalData(Request $request)
{
$companyId = getSelectedCompany();
//Update Company Meta
$personal_data = [
'name' => $request->name,
'link_text' => $request->link_text,
'preview' => $request->preview,
'active_approval' => $request->active_approval,
];
foreach($personal_data as $key => $value) {
if(!is_null($value)) {
CompanyMeta::updateOrCreate([
'key' => $key,
'company_id' => $companyId,
],[
'company_id' => $companyId,
'key' => $key,
'value' => $value,
'type' => 'Chat Setting'
]);
} else {
CompanyMeta::where('key', $key)->where('company_id', $companyId)->where('type', 'Chat Setting')->delete();
}
}
return redirect()->back()->with('success', 'Personal Data Updated Successfully');
}
public function storeTags(Request $request)
{
$companyId = getSelectedCompany();
//Update Company Meta
$tags_data = [
'new_tags_to_be_created_when_tagging' => $request->new_tags_to_be_created_when_tagging,
];
foreach($tags_data as $key => $value) {
if(!is_null($value)) {
CompanyMeta::updateOrCreate([
'key' => $key,
'company_id' => $companyId,
],[
'company_id' => $companyId,
'key' => $key,
'value' => $value,
'type' => 'Chat Setting'
]);
} else {
CompanyMeta::where('key', $key)->where('company_id', $companyId)->where('type', 'Chat Setting')->delete();
}
}
return redirect()->back()->with('success', 'Tags Updated Successfully');
}
public function settingAllChat(Request $request)
{
$this->validate($request, [
'heading_for_chat_flow' => 'required'
]);
$companyId = getSelectedCompany();
CompanyMeta::updateOrCreate([
'key' => 'heading_for_chat_flow',
'company_id' => $companyId,
],[
'company_id' => $companyId,
'key' => 'heading_for_chat_flow',
'value' => $request->heading_for_chat_flow,
'type' => 'Chat Setting'
]);
return redirect()->back()->with('success', 'Chat Setting Updated Successfully');
}
}

View File

@ -85,7 +85,10 @@ public function updateTicket(Request $request, $ticketId)
public function storeTags(Request $request)
{
$company = getSelectedCompany();
$ticket_id = $request->ticket_id;
$tags = json_decode($request->tags);
setTicketMeta($ticket_id,'tags',$tags);
foreach($tags as $tag)
{
//Update Tags Table
@ -99,15 +102,18 @@ public function storeTags(Request $request)
]);
//Update Company Meta Table
CompanyMeta::updateOrCreate([
'company_id' => $company,
'value' => $tag->value
],[
'company_id' => $company,
'value' => $tag->value,
'key' => 'tag',
'type' => 'tags'
]);
// CompanyMeta::updateOrCreate([
// 'company_id' => $company,
// 'value' => $tag->value
// ],[
// 'company_id' => $company,
// 'value' => $tag->value,
// 'key' => 'tag',
// 'type' => 'tags'
// ]);
}
return response()->json(['success' => true, 'message' => 'Tags Added Successfully']);

25122
error_log

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -7,8 +7,7 @@
<div class="content-wrapper">
<div class="dev-chat-tabs">
<div class="dev-tabs">
<button type="button" id="defaultOpenTab">User</button>
<button type="button">Flow Setting</button>
<button type="button" id="defaultOpenTab">Flow Setting</button>
<button type="button">Display</button>
<button type="button">Text</button>
<button type="button">Style</button>
@ -18,68 +17,7 @@
<button type="button">Tags</button>
<button type="button">Chat Button</button>
</div>
<!-- -->
<div class="dev-tabcontent dev-tabcontent-users">
<div class="dev-tabcontent-outers">
<div class="dev-title-row">
<h2>Add a new user</h2>
</div>
<form>
<div class="dev-input-group">
<label for="name">Name</label>
<input type="text" placeholder="Enter your name">
</div>
<div class="dev-input-group">
<label for="name">Language</label>
<div class="dev-custom-select">
<select>
<option value="0">Select your language</option>
<option value="1">Audi</option>
<option value="2">BMW</option>
</select>
</div>
</div>
<div class="dev-input-group">
<label for="email">Email</label>
<input type="email" placeholder="Enter your email">
</div>
<button type="submit">Send Activation Email </button>
</form>
<div class="dev-title-row">
<h2>Users</h2>
</div>
<div class="dev-users-boxs">
<div class="dev-users-box">
<img src="{{ asset('images/Avatar.png') }}">
<div class="dev-box">
<h3>Leslie Alexander</h3>
<span>user1@gmail.com</span>
</div>
<div class="dev-icon">
<img src="{{ asset('images/settingss.svg') }}" alt="">
</div>
<div class="dev-icon">
<img src="{{ asset('images/binn.svg') }}" alt="">
</div>
</div>
<div class="dev-users-box">
<img src="{{ asset('images/Avatar.png') }}">
<div class="dev-box">
<h3>Leslie Alexander</h3>
<span>user1@gmail.com</span>
</div>
<div class="dev-icon">
<img src="{{ asset('images/settingss.svg') }}" alt="">
</div>
<div class="dev-icon">
<img src="{{ asset('images/binn.svg') }}" alt="">
</div>
</div>
</div>
</div>
</div>
<!-- -->
<div class="dev-tabcontent dev-tabcontent-flow">
<div class="dev-tabcontent-outers">
<div class="dev-title-row">
@ -88,11 +26,15 @@
</div>
<div class="dev-content-inner">
<h2>When do you want to have notifications via email?</h2>
<form>
<form method="POST" action="{{ route('store.flow.setting') }}">
@csrf
<div class="col col-left">
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Show profile image of editors
<input type="checkbox" checked="checked">
@php
$show_profile_image_of_editors = getChatSetting('show_profile_image_of_editors')
@endphp
<input type="checkbox" name="show_profile_image_of_editors" @if($show_profile_image_of_editors) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -103,7 +45,10 @@
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Allow users to join the queue
<input type="checkbox">
@php
$allow_users_to_join_queue = getChatSetting('allow_users_to_join_queue')
@endphp
<input type="checkbox" name="allow_users_to_join_queue" @if($allow_users_to_join_queue) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -116,7 +61,10 @@
<label class="dev-checkbox-wrapper"> Show the chat button even when no
editor is
available.
<input type="checkbox">
@php
$show_chat_button = getChatSetting('show_chat_button')
@endphp
<input type="checkbox" name="show_chat_button" @if($show_chat_button) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -128,7 +76,10 @@
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Allow visitors to send messages
<input type="checkbox" checked="checked">
@php
$allow_visitor_to_send_messages = getChatSetting('allow_visitor_to_send_messages')
@endphp
<input type="checkbox" name="allow_visitor_to_send_messages" @if($allow_visitor_to_send_messages) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -139,14 +90,20 @@
</div>
<div class="dev-input-group">
<label>Email address that messages should be sent to</label>
<input type="email" placeholder="Please enter your email">
@php
$message_sent_to = getChatSetting('message_sent_to')
@endphp
<input type="email" name"message_sent_to" placeholder="Please enter your email" value="{{$message_sent_to->value ?? ''}}">
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Max number of chats per editor</label>
<input type="text" placeholder="Type here...">
@php
$max_number_of_chats_per_editor = getChatSetting('max_number_of_chats_per_editor')
@endphp
<input type="text" name="max_number_of_chats_per_editor" placeholder="Type here..." value="{{$max_number_of_chats_per_editor->value ?? ''}}">
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Editors can always send images and files.Editors can always
@ -160,11 +117,13 @@
<div class="dev-input-group dev-input-group-input-info">
<label>Log everyone out automatically</label>
@php
$logout_everyone_automatically = getChatSetting('logout_everyone_automatically')
@endphp
<div class="dev-custom-select">
<select>
<option value="0">Never</option>
<option value="1">Audi</option>
<option value="2">BMW</option>
<select name="logout_everyone_automatically">
<option value="Yes" @if($logout_everyone_automatically?->value == 'Yes') selected @endif>Yes</option>
<option value="No" @if($logout_everyone_automatically?->value == 'No') selected @endif>No</option>
</select>
</div>
<div class="dev-input-info">
@ -178,7 +137,10 @@
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Log out editor who has missed a
chat
<input type="checkbox">
@php
$logout_editor_who_missed_chat = getChatSetting('logout_editor_who_missed_chat')
@endphp
<input type="checkbox" name="logout_editor_who_missed_chat" @if($logout_editor_who_missed_chat) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -193,7 +155,10 @@
<div class="col col-right">
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Vistors can send images and files
<input type="checkbox">
@php
$visitor_can_send_images = getChatSetting('visitor_can_send_images')
@endphp
<input type="checkbox" name="visitor_can_send_images" @if($visitor_can_send_images) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -204,7 +169,10 @@
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Guest must write Name and Email to
chat
<input type="checkbox">
@php
$guest_must_write_name_and_email_to_chat = getChatSetting('guest_must_write_name_and_email_to_chat')
@endphp
<input type="checkbox" name="guest_must_write_name_and_email_to_chat" @if($guest_must_write_name_and_email_to_chat) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -219,7 +187,10 @@
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Save email address for anonymous
chats
<input type="checkbox" checked="checked">
@php
$save_email_address_for_anonymous_chat = getChatSetting('save_email_address_for_anonymous_chat')
@endphp
<input type="checkbox" name="save_email_address_for_anonymous_chat" @if($save_email_address_for_anonymous_chat) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -234,7 +205,10 @@
</div>
<div class="dev-input-group">
<label class="dev-checkbox-wrapper"> Delete chat data automatically
<input type="checkbox" checked="checked">
@php
$delete_chat_data_automatically = getChatSetting('delete_chat_data_automatically')
@endphp
<input type="checkbox" name="delete_chat_data_automatically" @if($delete_chat_data_automatically) checked @endif>
<span class="checkmark"></span>
</label>
<div class="dev-input-info">
@ -255,11 +229,13 @@
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>The chat assistant shows suggestions from:</label>
@php
$chat_assistant_show_suggestion_form = getChatSetting('chat_assistant_show_suggestion_form')
@endphp
<div class="dev-custom-select">
<select>
<option value="0">None</option>
<option value="1">Audi</option>
<option value="2">BMW</option>
<select name="chat_assistant_show_suggestion_form">
<option value="Yes" @if($chat_assistant_show_suggestion_form?->value == 'Yes') selected @endif>Yes</option>
<option value="No" @if($chat_assistant_show_suggestion_form?->value == 'No') selected @endif>No</option>
</select>
</div>
<div class="dev-input-info">
@ -274,7 +250,10 @@
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Delay for automatic deletion</label>
<input type="text" placeholder="Type here...">
@php
$delay_for_automatic_deletion = getChatSetting('delay_for_automatic_deletion')
@endphp
<input type="text" name="delay_for_automatic_deletion" placeholder="Type here..." value="{{$delay_for_automatic_deletion->value ?? '' }}">
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>The number of days a conversation should be stored in Kundo
@ -285,9 +264,9 @@
</div>
</div>
</div>
</form>
<button type="submit" class="dev-form-submit-btn">Save Changes</button>
</div>
<button type="submit" class="dev-form-submit-btn">Save Changes</button>
</form>
</div>
</div>
<!-- -->
@ -300,11 +279,15 @@
</div>
<div class="dev-title-copy">
<h2>When do you want to have notifications via email? </h2>
@foreach($display_chats as $display_chat)
<div class="dev-title-copy-inner">
<p>
Display chat when on
@php
$decode_data = json_decode($display_chat->value)
@endphp
<a href="#">
chat.kundo.se/chat/demo/chat-y9oc0g5n/
{{$decode_data->path}}
</a>
</p>
<div class="dev-thumbnail-wrapper">
@ -312,26 +295,11 @@
<img src="{{ asset('images/editt.svg') }}" alt="">
</div>
<div class="dev-thumbnail dev-thumbnail2">
<img src="{{ asset('images/binn-white.svg') }}" alt="">
</div>
</div>
</div>
<div class="dev-title-copy-inner">
<p>
Display chat when on
<a href="#">
chat.kundo.se/chat/demo/chat-y9oc0g5n/
</a>
</p>
<div class="dev-thumbnail-wrapper">
<div class="dev-thumbnail dev-thumbnail1 ">
<img src="{{ asset('images/editt.svg') }}" alt="">
</div>
<div class="dev-thumbnail dev-thumbnail2">
<img src="{{ asset('images/binn-white.svg') }}" alt="">
<a class="delete-display-chat" href="{{ route('delete.display.chat', $display_chat->id) }}"><img src="{{ asset('images/binn-white.svg') }}" alt=""></a>
</div>
</div>
</div>
@endforeach
</div>
</div>
@ -340,11 +308,12 @@
<h2>Display chat when on</h2>
</div>
<div class="dev-content-inner">
<form>
<form method="POST" action="{{ route('store.display.chat') }}">
@csrf
<div class="col col-left">
<div class="dev-input-group dev-input-group-input-info">
<label>Path</label>
<input type="text" placeholder="Type here...">
<input type="text" placeholder="Type here..." name="path" required>
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>http://example.com/* - means all subpages to example.com
@ -354,10 +323,9 @@
<div class="dev-input-group dev-input-group-input-info">
<label>Automatically start the chat after:</label>
<div class="dev-custom-select">
<select>
<option value="0">Never</option>
<option value="1">Audi</option>
<option value="2">BMW</option>
<select name="start_chat_after" required>
<option value="Yes">Yes</option>
<option value="No">No</option>
</select>
</div>
<div class="dev-input-info">
@ -368,7 +336,7 @@
</span>
</div>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<button type="submit" class="dev-form-submit-btn">Save</button>
</div>
<div class="col col-right">
<div class="dev-input-info-fill">
@ -394,18 +362,19 @@
should not be shown.</p>
</div>
<div class="dev-content-inner">
<form>
<form method="POST" action="{{ route('store.hide.chat') }}">
@csrf
<div class="col col-left">
<div class="dev-input-group dev-input-group-input-info">
<label>Path</label>
<input type="text" placeholder="Type here...">
<input type="text" placeholder="Type here..." name="hide_chat_path" required value="{{$hide_chats->value ?? ''}}">
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>http://example.com/* - means all subpages to example.com
</span>
</div>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<button type="submit" class="dev-form-submit-btn">Save</button>
</div>
<div class="col col-right">
<div class="dev-input-info-fill">
@ -432,7 +401,10 @@
<div class="col col-left">
<div class="dev-input-group dev-input-group-input-info">
<label>Internal name of chat flow</label>
<input type="text" placeholder="Chat">
@php
$internal_name = getChatSetting('internal_name')
@endphp
<input type="text" placeholder="Chat" name="internal_name" class="internal_name" value="{{ $internal_name->value ?? '' }}">
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Internal name that only editors see.</span>
@ -440,7 +412,11 @@
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Company name</label>
<input type="text" placeholder="Type here">
@php
$companyId = getSelectedCompany();
$company = \App\Models\Company::find($companyId);
@endphp
<input type="text" placeholder="Type here" value="{{ $company->name }}" readonly>
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Or other official sender. This name is displayed in e-mails
@ -451,8 +427,10 @@
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Welcome text</label>
<textarea rows="6">Hi! Feel free to contact us via chat if you are wondering about anything.
</textarea>
@php
$wellcome_text = getChatSetting('wellcome_text')
@endphp
<textarea rows="6" name="wellcome_text" class="wellcome_text">{{$wellcome_text->value ?? ''}}</textarea>
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Displayed when the chat is opened and there is a user in the
@ -464,7 +442,10 @@
<div class="col col-right">
<div class="dev-input-group dev-input-group-input-info">
<label>Public name of chat flow</label>
<input type="text" placeholder="Limon Media">
@php
$public_name = getChatSetting('public_name')
@endphp
<input type="text" placeholder="Limon Media" name="public_name" class="public_name" value="{{$public_name->value ?? ''}}">
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Internal name that only editors see.</span>
@ -472,8 +453,11 @@
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Welcome text at the queue</label>
@php
$wellcome_text_at_queue = getChatSetting('wellcome_text_at_queue')
@endphp
<textarea
rows="6">Hi! We will be chatting with you soon, but there are some people in front of you in the queue. </textarea>
rows="6" name="wellcome_text_at_queue" class="wellcome_text_at_queue">{{$wellcome_text_at_queue->value ?? ''}}</textarea>
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Displayed when the chat is opened.</span>
@ -483,24 +467,17 @@
</form>
<div class="dev-input-group dev-input-group-input-info">
<label>Message when the chat is closed</label>
@php
$message_when_chat_is_closed = getChatSetting('message_when_chat_is_closed')
@endphp
<div class="input-box-row">
<div class="ui card inbox-send-message-card w-100">
<div class="content input-options bg-dark-green-color">
<div class="input-option-row ">
<img src="{{ asset('images/icons/B.png') }}" alt="">
<img src="{{ asset('images/icons/I.png') }}" alt="">
<img src="{{ asset('images/icons/Vector (5).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (6).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (8).png') }}" alt="">
<img src="{{ asset('images/icons/drive.png') }}" alt="">
<img src="{{ asset('images/icons/Vector (5).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (6).png') }}" alt="">
</div>
</div>
<div
class="content d-flex align-items-end flex-column message-writing-content-area">
<textarea rows="5" placeholder="Your Message"
class="form-control input-reply-textarea"></textarea>
class="content d-flex flex-column message-writing-content-area">
<textarea rows="10" id="editor1" name="message_when_chat_is_closed" placeholder="Your Message"
class="form-control input-reply-textarea message_when_chat_is_closed">{!! $message_when_chat_is_closed->value ?? '' !!}</textarea>
</div>
</div>
</div>
@ -513,11 +490,17 @@ class="form-control input-reply-textarea"></textarea>
<div class="col col-left">
<div class="dev-input-group dev-input-group-input-info">
<label>Test in the answer box</label>
<input type="text" placeholder="What can i help you with!">
@php
$test_in_answer_box = getChatSetting('test_in_answer_box')
@endphp
<input type="text" placeholder="What can i help you with!" name="test_in_answer_box" class="test_in_answer_box" value="{{$test_in_answer_box->value ?? ''}}">
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Start message</label>
<input type="text" placeholder="What can i help you with!">
@php
$start_message = getChatSetting('start_message')
@endphp
<input type="text" placeholder="What can i help you with!" name="start_message" class="start_message" value="{{$start_message->value ?? ''}}">
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Message that is automatically sent as the first message when
@ -527,59 +510,63 @@ class="form-control input-reply-textarea"></textarea>
</div>
<div class="col col-right"></div>
</form>
<div class="dev-input-group dev-input-group-input-info dev-spacer">
<label>Message when the chat is closed</label>
<div class="input-box-row">
<div class="ui card inbox-send-message-card w-100">
<div class="content input-options bg-dark-green-color">
<div class="input-option-row ">
<img src="{{ asset('images/icons/B.png') }}" alt="">
<img src="{{ asset('images/icons/I.png') }}" alt="">
<img src="{{ asset('images/icons/Vector (5).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (6).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (8).png') }}" alt="">
<img src="{{ asset('images/icons/drive.png') }}" alt="">
<img src="{{ asset('images/icons/Vector (5).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (6).png') }}" alt="">
</div>
</div>
<div
class="content d-flex align-items-end flex-column message-writing-content-area">
<textarea rows="7" placeholder="Feel free to send a masseage"
class="form-control input-reply-textarea"></textarea>
</div>
</div>
</div>
</div>
<div class="dev-input-group dev-input-group-input-info dev-spacer">
<label>Message when the chat is closed</label>
<div class="input-box-row">
<div class="ui card inbox-send-message-card w-100">
<div class="content input-options bg-dark-green-color">
<div class="input-option-row ">
<img src="{{ asset('images/icons/B.png') }}" alt="">
<img src="{{ asset('images/icons/I.png') }}" alt="">
<img src="{{ asset('images/icons/Vector (5).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (6).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (8).png') }}" alt="">
<img src="{{ asset('images/icons/drive.png') }}" alt="">
<img src="{{ asset('images/icons/Vector (5).png') }}" alt="">
<img src="{{ asset('images/icons/Vector (6).png') }}" alt="">
</div>
</div>
<div
class="content d-flex align-items-end flex-column message-writing-content-area">
<textarea rows="7" placeholder="Thank you for your message!"
class="form-control input-reply-textarea"></textarea>
</div>
</div>
</div>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<!--<div class="dev-input-group dev-input-group-input-info dev-spacer">-->
<!-- <label>Message when the chat is closed</label>-->
<!-- <div class="input-box-row">-->
<!-- <div class="ui card inbox-send-message-card w-100">-->
<!-- <div class="content input-options bg-dark-green-color">-->
<!-- <div class="input-option-row ">-->
<!-- <img src="{{ asset('images/icons/B.png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/I.png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (5).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (6).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (8).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/drive.png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (5).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (6).png') }}" alt="">-->
<!-- </div>-->
<!-- </div>-->
<!-- <div-->
<!-- class="content d-flex align-items-end flex-column message-writing-content-area">-->
<!-- <textarea rows="7" placeholder="Feel free to send a masseage"-->
<!-- class="form-control input-reply-textarea"></textarea>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!--</div>-->
<!--<div class="dev-input-group dev-input-group-input-info dev-spacer">-->
<!-- <label>Message when the chat is closed</label>-->
<!-- <div class="input-box-row">-->
<!-- <div class="ui card inbox-send-message-card w-100">-->
<!-- <div class="content input-options bg-dark-green-color">-->
<!-- <div class="input-option-row ">-->
<!-- <img src="{{ asset('images/icons/B.png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/I.png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (5).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (6).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (8).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/drive.png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (5).png') }}" alt="">-->
<!-- <img src="{{ asset('images/icons/Vector (6).png') }}" alt="">-->
<!-- </div>-->
<!-- </div>-->
<!-- <div-->
<!-- class="content d-flex align-items-end flex-column message-writing-content-area">-->
<!-- <textarea rows="7" placeholder="Thank you for your message!"-->
<!-- class="form-control input-reply-textarea"></textarea>-->
<!-- </div>-->
<!-- </div>-->
<!-- </div>-->
<!--</div>-->
<button type="button" class="dev-form-submit-btn submit-text">Save</button>
</div>
</div>
</div>
<script src="https://cdn.ckeditor.com/4.16.0/standard/ckeditor.js"></script>
<script>
CKEDITOR.replace('editor1');
</script>
<!-- -->
<div class="dev-tabcontent dev-tabcontent-style">
<div class="dev-tabcontent-outers">
@ -587,72 +574,109 @@ class="form-control input-reply-textarea"></textarea>
<h2>Style</h2>
</div>
<div class="dev-content-inner">
<form>
<form method="POST" action="{{ route('store.style') }}">
@csrf
<div class="col-left">
<div class="dev-box">
<h3>Text theme color</h3>
@php
$text_theme_color = getChatSetting('text_theme_color');
$text_theme_color_value = $text_theme_color->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="text_theme_color" readonly placeholder="#020400" value="{{ $text_theme_color_value }}">
<span style="background-color: {{ $text_theme_color_value }};"></span>
</div>
</div>
<div class="dev-box">
<h3>Background theme color</h3>
@php
$background_theme_color = getChatSetting('background_theme_color');
$background_theme_color_value = $background_theme_color->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="background_theme_color" readonly placeholder="#020400" value="{{$background_theme_color_value}}">
<span style="background-color: {{ $background_theme_color_value }};"></span>
</div>
</div>
<div class="dev-box">
<h3>Text color for sent messages</h3>
@php
$text_color_for_sent_message = getChatSetting('text_color_for_sent_message');
$text_color_for_sent_message_value = $text_color_for_sent_message->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="text_color_for_sent_message" readonly placeholder="#020400" value="{{$text_color_for_sent_message_value}}">
<span style="background-color: {{ $text_color_for_sent_message_value }};"></span>
</div>
</div>
<div class="dev-box">
<h3>Background color of sent messages</h3>
@php
$background_color_of_sent_message = getChatSetting('background_color_of_sent_message');
$background_color_of_sent_message_value = $background_color_of_sent_message->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="background_color_of_sent_message" readonly placeholder="#020400" value="{{$background_color_of_sent_message_value}}">
<span style="background-color: {{ $background_color_of_sent_message_value }};"></span>
</div>
</div>
<div class="dev-box">
<h3>Text color of received messages</h3>
@php
$text_color_of_received_message = getChatSetting('text_color_of_received_message');
$text_color_of_received_message_value = $text_color_of_received_message->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="text_color_of_received_message" readonly placeholder="#020400" value="{{$text_color_of_received_message_value}}">
<span style="background-color: {{ $text_color_of_received_message_value }};"></span>
</div>
</div>
<div class="dev-box">
<h3>Text color of notification icon</h3>
@php
$text_color_of_notification = getChatSetting('text_color_of_notification');
$text_color_of_notification_value = $text_color_of_notification->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="text_color_of_notification" readonly placeholder="#020400" value="{{$text_color_of_notification_value}}">
<span style="background-color: {{ $text_color_of_notification_value }};"></span>
</div>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<button type="submit" class="dev-form-submit-btn">Save</button>
</div>
<div class="col-right">
<div class="dev-box">
<h3>Text color of error messages</h3>
@php
$text_color_of_error_message = getChatSetting('text_color_of_error_message');
$text_color_of_error_message_value = $text_color_of_error_message->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="text_color_of_error_message" readonly placeholder="#020400" value="{{$text_color_of_error_message_value}}">
<span style="background-color: {{ $text_color_of_error_message_value }};"></span>
</div>
</div>
<div class="dev-box">
<h3>Background color of error messages</h3>
@php
$background_color_of_error_message = getChatSetting('background_color_of_error_message');
$background_color_of_error_message_value = $background_color_of_error_message->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="background_color_of_error_message" readonly placeholder="#020400" value="{{$background_color_of_error_message_value}}">
<span style="background-color: {{ $background_color_of_error_message_value }};"></span>
</div>
</div>
<div class="dev-box">
<h3>Link color</h3>
@php
$link_color = getChatSetting('link_color');
$link_color_value = $link_color->value ?? '#020400';
@endphp
<div class="dev-box-inner">
<input type="text" readonly placeholder="#020400">
<span></span>
<input type="color" name="link_color" readonly placeholder="#020400" value="{{$link_color_value}}">
<span style="background-color: {{ $link_color_value }};"></span>
</div>
</div>
</div>
@ -698,21 +722,51 @@ class="form-control input-reply-textarea"></textarea>
<h2>Create a new canned response</h2>
</div>
<div class="dev-content-inner">
<form>
<form method="POST" action="{{ route('store.chat.canned.responses') }}">
@csrf
<div class="dev-input-group dev-input-group-input-info">
<label>Name</label>
<input type="text" placeholder="Type here">
<input type="text" placeholder="Type here" name="name" required>
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Text</label>
<textarea rows="6">Hi! Feel free to contact us via chat if you are wondering about anything.
</textarea>
<textarea rows="6" name="text" required></textarea>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<button type="submit" class="dev-form-submit-btn">Save</button>
</form>
</div>
</div>
<div class="dev-tabcontent-outers">
<div class="dev-title-row">
<h2>Canned responses</h2>
<div class="dev-users-boxs">
@if(count($canned_responses) > 0)
@foreach($canned_responses as $index => $value)
@php
$result = json_decode($value->value);
@endphp
<div class="dev-users-box">
<div class="dev-box">
<h3>{{ $result->name }}</h3>
<span>{{ $result->text }}</span>
</div>
<div class="dev-icon">
<img src="{{ asset('images/settingss.svg') }}" alt="">
</div>
<div class="dev-icon">
<a style="cursor:pointer;" href="{{ route('delete.chat.canned.responses', $value->id) }}" class="delete-display-chat"><img src="{{ asset('images/binn.svg') }}" alt=""></a>
</div>
</div>
@endforeach
@endif
</div>
</div>
</div>
</div>
<!-- -->
<div class="dev-tabcontent dev-tabcontent-policy">
@ -725,31 +779,44 @@ class="form-control input-reply-textarea"></textarea>
<p>Select if users must click on a checkbox to approve policy before they can
contact
you.</p>
<form>
<form method="POST" action="{{ route('store.personal.data') }}">
@csrf
<div class="dev-input-group">
<label class="dev-checkbox-wrapper">Require active approval (check box)
<input type="checkbox">
@php
$active_approval = getChatSetting('active_approval')
@endphp
<input type="checkbox" name="active_approval" @if($active_approval) checked @endif>
<span class="checkmark"></span>
</label>
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Text</label>
<input type="text" placeholder="Type here">
@php
$name = getChatSetting('name')
@endphp
<input type="text" placeholder="Type here" name="name" required value="{{ $name->value ?? '' }}">
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Link text</label>
<input type="text" placeholder="Type here">
@php
$link_text = getChatSetting('link_text')
@endphp
<input type="text" placeholder="Type here" name="link_text" required value="{{ $link_text->value ?? '' }}">
</div>
<div class="dev-input-group dev-input-group-input-info">
<label>Preview</label>
<input type="text">
@php
$preview = getChatSetting('preview')
@endphp
<input type="text" name="preview" value="{{ $preview->value ?? '' }}">
</div>
<div class="dev-input-group dev-input-group-input-info dev-custom-input-group">
<label>Policy for personal data</label>
<p>Custom policy</p>
<button type="button" class="dev-form-submit-btn">Edit</button>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<button type="submit" class="dev-form-submit-btn">Save</button>
</form>
</div>
@ -762,15 +829,19 @@ class="form-control input-reply-textarea"></textarea>
<h2>Tags</h2>
</div>
<div class="dev-content-inner">
<form>
<form method="POST" action="{{ route('store.tags') }}">
@csrf
<div class="dev-input-group">
<label class="dev-checkbox-wrapper">Allow new tags to be created when
tagging
<input type="checkbox">
@php
$new_tags_to_be_created_when_tagging = getChatSetting('new_tags_to_be_created_when_tagging')
@endphp
<input type="checkbox" name="new_tags_to_be_created_when_tagging" @if($new_tags_to_be_created_when_tagging) checked @endif>
<span class="checkmark"></span>
</label>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<button type="submit" class="dev-form-submit-btn">Save</button>
</form>
</div>
@ -783,18 +854,21 @@ class="form-control input-reply-textarea"></textarea>
<h2>Settings for all chats</h2>
</div>
<div class="dev-content-inner">
<form>
<form method="POST" action="{{ route('setting.all.chat') }}">
@csrf
<div class="dev-input-group dev-input-group-input-info">
<label>Heading when selecting chat flow</label>
<textarea rows="6">
</textarea>
@php
$heading_for_chat_flow = getChatSetting('heading_for_chat_flow');
@endphp
<textarea rows="6" required name="heading_for_chat_flow">{{$heading_for_chat_flow->value ?? ''}}</textarea>
<div class="dev-input-info">
<img src="{{ asset('images/info.svg') }}" alt="info">
<span>Displayed when the visitor can choose between different chat
flows.</span>
</div>
</div>
<button type="button" class="dev-form-submit-btn">Save</button>
<button type="submit" class="dev-form-submit-btn">Save</button>
</form>
</div>
</div>
@ -879,4 +953,80 @@ class="form-control input-reply-textarea"></textarea>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!--Store Text Route-->
<script>
$(document).ready(function() {
const csrfToken = $('meta[name="csrf-token"]').attr('content');
$('.submit-text').on('click', function() {
console.log('test')
// Collect data from inputs
const public_name = $('.public_name').val();
const internal_name = $('.internal_name').val();
const wellcome_text = $('.wellcome_text').val();
const wellcome_text_at_queue = $('.wellcome_text_at_queue').val();
const start_message = $('.start_message').val();
const test_in_answer_box = $('.test_in_answer_box').val();
// Get the value from CKEditor
const message_when_chat_is_closed = CKEDITOR.instances.editor1.getData();
$.ajax({
url: '/store/text',
type: 'POST',
headers: {
'X-CSRF-TOKEN': csrfToken // Correct CSRF token syntax
},
data: {
public_name: public_name,
internal_name: internal_name,
wellcome_text: wellcome_text,
wellcome_text_at_queue: wellcome_text_at_queue,
start_message: start_message,
test_in_answer_box: test_in_answer_box,
message_when_chat_is_closed: message_when_chat_is_closed
},
success: function(response) {
if(response.success) {
toastr.success('Chat Setting Updated Successfully');
} else {
toastr.error('Failed To Update: ' + response.message);
}
},
error: function(jqXHR, textStatus, errorThrown) {
toastr.error('Failed To Update: ' + errorThrown);
}
});
});
});
</script>
<script defer>
document.addEventListener('DOMContentLoaded', function () {
const deleteLinks = document.querySelectorAll('.delete-display-chat');
deleteLinks.forEach(function (link) {
link.addEventListener('click', function (event) {
event.preventDefault(); // Prevent the default link click behavior
const url = this.href;
Swal.fire({
title: 'Are you sure?',
text: "You won't be able to revert this!",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes, delete it!'
}).then((result) => {
if (result.isConfirmed) {
// If the user confirms, redirect to the delete URL
window.location.href = url;
}
});
});
});
});
</script>
@endsection

View File

@ -4,6 +4,10 @@
cursor:pointer;
}
.scrollhint .item .single-user-content img,.scrollhint .item .sender-message-box img{
width:100%;
}
</style>
<!-- Support and Chat Fixed Buttons -->
@ -202,12 +206,8 @@
}
});
console.log(socket);
document.addEventListener('DOMContentLoaded', (event) => {
$.ajax({
function loadChats(){
$.ajax({
url: "{{route('chatgroups.get')}}",
method: 'GET',
success: function(response) {
@ -226,7 +226,7 @@
html += ` <div class="item open-inbox" data-chat="${chat.id}" data-customer="${chat.customer_id}" data-subject="${chat.subject}" data-user="${chat.user_id}">
<div class="single-user-content d-flex">
<div class="chat-user-img-box">
<img src="{{ asset('images/Avatar.png') }}" alt="Dummy User">
<img src="{{ asset('images/Avatar.png') }}" class="aw-avatar" alt="Dummy User">
</div>
<div class="user-message-detail">
<p class="recepient-message-detail">${chat.name} <span>Sep 27</span></p>
@ -248,13 +248,76 @@
}
});
}
console.log(socket);
document.addEventListener('DOMContentLoaded', (event) => {
loadChats()
var activeChat = false;
var inbox = $('#inbox .scrollhint');
$('#close-chat').click(function(){
Swal.fire({
title: 'Are you sure?',
text: "Do you want to close this chat?",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Yes'
}).then((result) => {
if (result.isConfirmed && activeChat) {
$.ajax({
url: '{{ route("CloseChat") }}',
type: 'POST',
data: {
_token: '{{csrf_token()}}',
chat_id: activeChat.id
},
success: function(response) {
console.log(response);
Swal.fire({
title: 'Success',
text: "Chat is closed.",
icon: 'success',
showCancelButton: false,
confirmButtonColor: '#3085d6',
//cancelButtonColor: '#d33',
confirmButtonText: 'OK'
}).then((result) => {
if (result.isConfirmed) {
loadChats();
$('#back-to-users').click();
}
});
},
error: function(xhr, status, error) {
console.log(xhr.responseText);
}
});
console.log('chat closed');
}
});
});
$(document).on('click', '.open-inbox', async function() {
inbox.html(null);
var chat = customers[$(this).data('chat')];
@ -266,19 +329,32 @@
for(var i=0;i<messages.length;i++){
var sms = messages[i];
var content = sms.message;
if(sms.type == 'image'){
content = '<img src="'+sms.message+'"/>';
}
if(sms.type == 'file'){
content = '<a target="_blank" href="'+sms.message+'"> View File </a>';
}
if(sms.from == "user"){
//<img src="{{ asset('images/Avatar.png') }}" class="aw-avatar" alt="Dummy User">
inbox.append(` <div class="item">
<div class="single-user-content d-flex">
<div class="chat-user-img-box receiver-message-box d-flex">
<img src="{{ asset('images/Avatar.png') }}" alt="Dummy User">
<p>${sms.message}</p>
<p>${content}</p>
</div>
</div>
</div>`);
}else{
inbox.append(` <div class="item d-flex justify-content-end">
<div class="sender-message-box text-white">
<p>${sms.message}</p>
<p>${content}</p>
</div>
</div>`);
}
@ -305,14 +381,33 @@
var sms = $('#aw-sms').val();
if(sms != ""){
const fileInput = document.getElementById("file-picker");
const file = fileInput.files[0];
var type = "text";
if(sms != "" || file){
console.log(activeChat.id);
const formData = new FormData();
if (file) {
formData.append("file", file); // Append the selected file
// Check the file type
const fileType = file.type;
if (fileType.startsWith("image/")) {
console.log("This is an image file.");
type = "image";
} else {
type = "file";
}
}
formData.append('chat_id', activeChat.id); // Static value as per your example
formData.append('from', 'company'); // Assuming a static value for simplicity
formData.append('message', sms);
formData.append('type', 'text');
formData.append('type', type);
// API endpoint
@ -325,13 +420,41 @@
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
socket.emit('chat message',{sms:sms,id:activeChat.id},activeChat.customer_id);
var sms = data.data;
var content = sms.message;
console.log('Success:', data,'chat message',{
sms:content,
id:activeChat.id,
type:sms.type
},
activeChat.customer_id);
socket.emit('chat message',
{
sms:content,
id:activeChat.id,
type:sms.type
},
activeChat.customer_id
);
if(sms.type == 'image'){
content = '<img src="'+content+'"/>';
}
if(sms.type == 'file'){
content = '<a target="_blank" href="'+content+'"> View File </a>';
}
inbox.append(` <div class="item d-flex justify-content-end">
<div class="sender-message-box text-white">
<p>${sms}</p>
<p>${content}</p>
</div>
</div>`);
@ -379,11 +502,11 @@
playMessageSound();
if(msg.id == activeChat.id){
//<img class="align-self-end" src="{{ asset('images/Avatar.png') }}" alt="Dummy User">
inbox.append(` <div class="item">
<div class="single-user-content d-flex">
<div class="chat-user-img-box receiver-message-box d-flex">
<img class="align-self-end" src="{{ asset('images/Avatar.png') }}" alt="Dummy User">
<p>${msg.sms}</p>
</div>
</div>
@ -409,7 +532,7 @@
function scrollToBottom() {
var $div = $('#scrollhint');
var $div = $('.scrollhint');
$div.scrollTop($div.prop("scrollHeight"));
}

View File

@ -1,3 +1,4 @@
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<header>
<div class="row">
<div class="col-sm-4 user-name-nav-area d-flex align-content-center">

View File

@ -898,7 +898,7 @@ class="form-control input-reply-textarea">{!! $automatic_reply_text->value ?? ''
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script defer>
document.addEventListener('DOMContentLoaded', function () {
const deleteLinks = document.querySelectorAll('.delete-user');

View File

@ -4,6 +4,8 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- CSRF Token Meta Tag -->
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>Inbox</title>
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.min.js"></script>

View File

@ -127,11 +127,23 @@
new Tagify(input);
</script>
<input type="text" name="tags" id="tags" placeholder="Type and press Enter"
<?php
$tags = [];
$db_tags = getTicketMeta($ticket->id,'tags');
foreach($db_tags as $tag){
$tags[] = $tag->value;
}
?>
<input type="text" name="tags" id="tags" value="{{implode(',',$tags)}}" placeholder="Type and press Enter"
class="form-control input-reply-textarea input-comment-textarea" required/>
<button class="ui button bg-light-green-color mt-4 color-light" id="save-tags">
<button data-ticket_id="{{$ticket->id}}" class="ui button bg-light-green-color mt-4 color-light" id="save-tags">
Save
</button>
@ -141,6 +153,7 @@ class="form-control input-reply-textarea input-comment-textarea" required/>
event.preventDefault();
var tags = $('#tags').val();
var ticketId = $(this).data('ticket_id');
// Check if the input field is not empty
if (tags === '') {
@ -154,6 +167,7 @@ class="form-control input-reply-textarea input-comment-textarea" required/>
type: 'POST',
data: {
tags: tags,
ticket_id:ticketId,
_token: '{{ csrf_token() }}'
},
success: function(response) {

View File

@ -61,7 +61,7 @@
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<script defer>
document.addEventListener('DOMContentLoaded', function () {
const deleteLinks = document.querySelectorAll('.delete-user');

View File

@ -14,6 +14,8 @@
}
</style>
<input type="hidden" value="{{$single_ticket->id}}" id="aw-ticket_id"/>
<div class="inbox-content-wrapper w-100 ">
<div class="inbox-inner-wrapper w-100 d-flex">
@ -72,6 +74,9 @@
<!-- <img src="{{ asset('images/icons/Vector (6).png') }}" alt="">-->
<!-- </div>-->
<!--</div>-->
@if($single_ticket->status != 'done')
<div class="content d-flex align-items-end flex-column message-writing-content-area">
<textarea rows="7" placeholder="Your Message"
class="form-control input-reply-textarea" id="editor1" required></textarea>
@ -79,6 +84,9 @@ class="form-control input-reply-textarea" id="editor1" required></textarea>
Reply
</button>
</div>
@endif
</div>
</div>
</div>
@ -292,7 +300,8 @@ class="form-control input-reply-textarea" id="editor1" required></textarea>
<!--Script Tag-->
<script>
$(document).ready(function(){
var activeTicketId = $('.chat-detail-item.active').data('ticket-id');
// var activeTicketId = $('.chat-detail-item.active').data('ticket-id');
var activeTicketId = $('#aw-ticket_id').val();
// Load chat messages for the active ticket on page load
loadChatMessages(activeTicketId);
@ -313,6 +322,7 @@ function loadChatMessages(ticketId) {
url: '/fetch-chat-messages/' + ticketId,
method: 'GET',
success: function(response) {
console.log(response);
// Update chat box with fetched messages
$('.chat-content-wrapper').html(response);
},

View File

@ -25,6 +25,8 @@
Route::post('/chat/get', [ChatController::class, 'getChat']);
Route::post('/chat/getMessages', [ChatController::class, 'getMessages']);
Route::post('/chat/check', [ChatController::class, 'checkChat']);

View File

@ -7,6 +7,7 @@
use App\Http\Controllers\UserController;
use App\Http\Controllers\DashboardController;
use App\Http\Controllers\TicketController;
use App\Http\Controllers\ChatSettingController;
use App\Http\Controllers\Mailgun\MailgunController;
use App\Http\Controllers\Chat\ChatController;
@ -37,6 +38,7 @@
// In routes/web.php
Route::get('/chatgroups', [ChatController::class, 'getChatGroupsByCompany'])->name('chatgroups.get');
Route::post('/close-chat', [ChatController::class, 'CloseChat'])->name('CloseChat');
Route::get('/test', [MailgunController::class, 'test'])->name('test');
@ -78,9 +80,20 @@
//Spam Handling
Route::post('inbox/spam-handling', [InboxController::class, 'spamHandling'])->name('inbox.spam.handling');
Route::get('spam-handling/{index}', [InboxController::class, 'deleteSpamHandling'])->name('delete.spam.handling');
Route::get('/chat-setting', function(){
return view('chat-setting');
})->name('chat.setting');
//Chat Setting Routes
Route::get('/chat-setting', [ChatSettingController::class, 'chatSetting'])->name('chat.setting');
Route::post('store/flow-setting', [ChatSettingController::class, 'storeFlowSetting'])->name('store.flow.setting');
Route::post('store/display-chat', [ChatSettingController::class, 'storeDisplayChat'])->name('store.display.chat');
Route::get('delete/display-chat/{id}', [ChatSettingController::class, 'deleteDisplayChat'])->name('delete.display.chat');
Route::post('store/hide-chat', [ChatSettingController::class, 'storeHideChat'])->name('store.hide.chat');
Route::post('store/text', [ChatSettingController::class, 'storeText'])->name('store.text');
Route::post('store/style', [ChatSettingController::class, 'storeStyle'])->name('store.style');
Route::post('store/chat-canned-responses', [ChatSettingController::class, 'storeChatCannedResponses'])->name('store.chat.canned.responses');
Route::get('delete/chat-canned-responses/{id}', [ChatSettingController::class, 'deleteChatCannedResponses'])->name('delete.chat.canned.responses');
Route::post('store/personal-data', [ChatSettingController::class, 'storePersonalData'])->name('store.personal.data');
Route::post('store/tags', [ChatSettingController::class, 'storeTags'])->name('store.tags');
Route::post('setting/all-chat', [ChatSettingController::class, 'settingAllChat'])->name('setting.all.chat');
Route::get('/home', [App\Http\Controllers\HomeController::class, 'index'])->name('home');
Route::post('logout', [LoginController::class, 'logout'])->name('logout');
});