Merge remote-tracking branch 'origin/master'

This commit is contained in:
merdan 2022-12-07 13:29:43 +05:00
commit 6f55777b14
16 changed files with 455 additions and 44 deletions

View File

@ -15,7 +15,9 @@
use App\Models\Status;
use App\Models\Ticket;
use App\Models\User;
use App\Notifications\NewTicket;
use App\Notifications\ApplicationApproved;
use App\Notifications\TicketMessage;
use App\Notifications\TicketPosted;
use Illuminate\Contracts\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Notification;
@ -25,7 +27,7 @@ class TicketController extends Controller
public function chat(Request $request)
{
$ticket = Ticket::with(['account','category'])->find($request->ticket_id);
$ticket = Ticket::with(['account.profile','category'])->find($request->ticket_id);
//todo send email to admin
return view('admin.messages',[
'ticket' => $ticket
@ -60,11 +62,11 @@ public function postMessage(MessageRequest $request)
$message['client_id'] = $request->user()->id;
$message->save();
$ticket = Ticket::find($request->ticket_id);
if($ticket->last_sender == 'client'){
$users = User::with('permissions')->whereHas("permissions", function($q) {
if($ticket->last_sender == 'admin'){
$users = User::with(['permissions' => function($q) {
$q->whereIn("name", ["tickets"]);
})->get();
Notification::send($users, new NewTicket());
}])->get();
Notification::send($users, new TicketMessage());
}
$ticket['last_sender'] = 'client';
$ticket->save();
@ -84,9 +86,9 @@ public function postMessageAdmin(MessageRequest $request)
$message['is_client'] = false;
$message->save();
$ticket = Ticket::find($request->ticket_id);
if($ticket->last_sender == 'admin'){
$user = Client::find($ticket->client_id);
$user->notify(new NewTicket());
if($ticket->last_sender == 'client'){
$account = Account::with('clients')->find($ticket->client_id);
Notification::send($account->clients()->where('is_suspended', 0)->get(), new TicketMessage());
}
$ticket['last_sender'] = 'admin';
$ticket->save();
@ -111,27 +113,26 @@ public function postTicket(TicketRequest $request)
{
$ticket = new Ticket($request->only('content', 'title','category_id'));
$client = $request->user();
$ticket['client_id'] = $client->id;
$ticket['account_id'] = $client->account_id;
$ticket['client_id'] = $client->account_id;
$status = Status::where('name', 'Open')->firstOrFail();
$ticket['status_id'] = $status->id;
$ticket['last_sender'] = 'client';
$ticket->save();
$users = User::with('permissions')->whereHas("permissions", function($q) {
$users = User::with(["permissions" => function($q) {
$q->whereIn("name", ["tickets"]);
})->get();
Notification::send($users, new NewTicket());
}])->get();
Notification::send($users, new TicketPosted());
return TicketResource::make($ticket);
}
public function createAppTicket(Request $request){
$ticket = new Ticket($request->only('content', 'title','category_id', 'client_id', 'account_id', 'application_id'));
$ticket = new Ticket($request->only('content', 'title','category_id', 'account_id', 'application_id'));
$ticket['status_id'] = 1;
$ticket['client_id'] = $request->account_id;
$ticket->save();
$users = Client::where('account_id', $request->account_id)->get();
Notification::send($users, new NewTicket());
return redirect()->route('chat',['ticket_id' => $ticket->id]);
$not_suspended_clients = Client::where('is_suspended', 0)->where('account_id', $request->account_id)->get();
Notification::send($not_suspended_clients, new TicketPosted());
return redirect(route('chat',['ticket_id' => $ticket->id]));
}
public function accountForTicketsAjax(Request $request){

View File

@ -22,8 +22,6 @@
class ApplicationCrudController extends CrudController
{
use \Backpack\CRUD\app\Http\Controllers\Operations\ListOperation;
// use \Backpack\CRUD\app\Http\Controllers\Operations\CreateOperation;
// use \Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use \Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
/**

View File

@ -0,0 +1,33 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class ApplicationApproved extends Mailable
{
use Queueable, SerializesModels;
/**
* Create a new message instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
return $this->view('view.name');
}
}

View File

@ -0,0 +1,33 @@
<?php
namespace App\Mail;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;
class ApplicationRefined extends Mailable
{
use Queueable, SerializesModels;
public $name;
public function __construct($name)
{
$this->name = $name;
}
/**
* Build the message.
*
* @return $this
*/
public function build()
{
$user['name'] = $this->name;
return $this->subject('Your application has been refined!')
->view('emails.notifications.application_refined', ['user' => $user]);
}
}

View File

@ -40,10 +40,7 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{
return (new MailMessage)
->from(config('settings.smtp_username'), env('MAIL_FROM_NAME', 'Birzha legalizasia'))
->greeting('Hello!')
->line('Your application has been approved!');
return (new MailMessage)->view('emails.notifications.application_approved');
}
/**

View File

@ -40,10 +40,7 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{
return (new MailMessage)
->from(config('settings.smtp_username'), env('MAIL_FROM_NAME', 'Birzha legalizasia'))
->greeting('Hello!')
->line('Your application has been refined!');
return (new MailMessage)->view('emails.notifications.application_refined');
}
/**

View File

@ -7,7 +7,7 @@
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class NewTicket extends Notification
class TicketMessage extends Notification
{
use Queueable;
@ -40,10 +40,7 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{
return (new MailMessage)
->from(config('settings.smtp_username'), env('MAIL_FROM_NAME', 'Birzha legalizasia'))
->greeting('Hello!')
->line('You have new ticket!');
return (new MailMessage)->view('emails.notifications.new_message');
}
/**

View File

@ -7,7 +7,7 @@
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Notification;
class NewMessage extends Notification
class TicketPosted extends Notification
{
use Queueable;
@ -40,10 +40,7 @@ public function via($notifiable)
*/
public function toMail($notifiable)
{
return (new MailMessage)
->from(config('settings.smtp_username'), env('MAIL_FROM_NAME', 'Birzha legalizasia'))
->greeting('Hello!')
->line('You have new message!');
return (new MailMessage)->view('emails.notifications.new_ticket');
}
/**

View File

@ -36,8 +36,8 @@
'mailers' => [
'smtp' => [
'transport' => 'smtp',
'host' => config('settings.smtp_host'),
'port' => config('settings.smtp_port'),
'host' => config('settings.smtp_host') ?? 'smtp.yandex.ru',
'port' => config('settings.smtp_port') ?? 465,
'encryption' => config('settings.smtp_encryption'),
'username' => config('settings.smtp_username'),
'password' => config('settings.smtp_password'),

BIN
public/img/mini-logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 900 B

View File

@ -157,7 +157,7 @@ class="bi bi-ticket-perforated" viewBox="0 0 16 16">
<form method="post" action="{{backpack_url('create-application-ticket')}}" method="POST">
@csrf
<input type="hidden" name="application_id" value="{{ $application->id }}">
<input type="hidden" name="client_id" value={{ $application->account_id }}>
<input type="hidden" name="account_id" value={{ $application->account_id }}>
<input type="hidden" name="status_id" value="1">
<input type="hidden" name="category_id" value="2">
<input type="hidden" name="last_sender" value="admin">

View File

@ -76,7 +76,12 @@
<div class="" style="height: 68vh; overflow-y: auto;">
<div class="chat-log" id="chat-log">
@if($ticket->last_sender != 'admin')
<div class="chat-log__item client"><h3 class="chat-log__author">{{ $ticket->account->profile->name }} <small class="small-date">{{ $ticket->created_at }}</small></h3><div class="chat-log__message"><p>{{ $ticket->content }}</p></div></div>
<div class="chat-log__item client">
<h3 class="chat-log__author">{{ $ticket->account->profile->name ?? 'user' }}
<small class="small-date">{{ $ticket->created_at }}</small>
</h3>
<div class="chat-log__message"><p>{{ $ticket->content }}</p></div>
</div>
@else
<div class="chat-log__item admin bg-gray-200"><h3 class="chat-log__author">{{backpack_user()->name}} <small class="small-date">{{ $ticket->created_at }}</small></h3><div class="chat-log__message">{{ $ticket->content }}</div></div>
@endif
@ -110,7 +115,7 @@
var m = new Date(element.created_at);
var dateString = m.getUTCDate() + "." + (m.getUTCMonth()+1) + "." + m.getUTCFullYear() + " " + m.getUTCHours() + ":" + m.getUTCMinutes();
if(element.is_client === 1){
$('#chat-messages').append('<div class="chat-log__item client"><h3 class="chat-log__author">{{ $ticket->account->profile->name }} <small class="small-date">' + dateString + '</small></h3><div class="chat-log__message"><p>' + element.content + '</p></div></div>');
$('#chat-messages').append('<div class="chat-log__item client"><h3 class="chat-log__author">{{ $ticket->account->profile->name ?? "user" }} <small class="small-date">' + dateString + '</small></h3><div class="chat-log__message"><p>' + element.content + '</p></div></div>');
}
else{
$('#chat-messages').append('<div class="chat-log__item admin bg-gray-200"><h3 class="chat-log__author">{{backpack_user()->name}} <small class="small-date">' + dateString + '</small></h3><div class="chat-log__message">' + element.content + '</div></div>');

View File

@ -0,0 +1,83 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
<title>Email template</title>
<style type="text/css">
@media screen and (max-width: 450px) {
.title {
width: calc(100% - 54px);
font-size: 14px;
}
}
</style>
</head>
<body style="font-family: 'Poppins', sans-serif;
font-size: 14px;
color: #000;
line-height: 1.4;
font-weight: 400;
background: #fff;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;">
<div id="wrapper" style=" margin: 10px;">
<div class="inner">
<table class="mail"
style="border: 1px solid #003197; border-radius: 5px; overflow: hidden; width: 100%; border-spacing: 0;">
<thead style="background-color: #003197;">
<tr>
<th class="header" style="padding: 0; position: relative;">
<div class="header_row" style=" display: flex; align-items: center; padding: 10px 20px;">
<div class="logo" style="width: 44px; height: 44px; margin-right: 20px; position: relative; z-index: 2;">
<img style=" width: 100%; height: 100%; object-fit: contain; -o-object-fit: contain;" src="https://panel.exchange.gov.tm/img/mini-logo.png" alt="logo">
</div>
<h1 class="title" style="font-size: 16px; text-align: left; font-weight: 700; line-height: 1.5; color: #fff; width: calc(100% - 60px);">
Ваша заявка на легализацию принята.
</h1>
</div>
</th>
</tr>
</thead>
<tbody class="content">
<tr>
<td style="padding: 30px 0 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Здравствуйте!
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Статус вашей заявки изменён на ««Зарегистрировано»».
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 30px 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4;">
С уважением, <br>
отдел фин. мониторинга ГТСБТ.
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
<title>Email template</title>
<style type="text/css">
@media screen and (max-width: 450px) {
.title {
width: calc(100% - 54px);
font-size: 14px;
}
}
</style>
</head>
<body style="font-family: 'Poppins', sans-serif;
font-size: 14px;
color: #000;
line-height: 1.4;
font-weight: 400;
background: #fff;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;">
<div id="wrapper" style=" margin: 10px;">
<div class="inner">
<table class="mail"
style="border: 1px solid #003197; border-radius: 5px; overflow: hidden; width: 100%; border-spacing: 0;">
<thead style="background-color: #003197;">
<tr>
<th class="header" style="padding: 0; position: relative;">
<div class="header_row" style=" display: flex; align-items: center; padding: 10px 20px;">
<div class="logo" style="width: 44px; height: 44px; margin-right: 20px; position: relative; z-index: 2;">
<img style=" width: 100%; height: 100%; object-fit: contain; -o-object-fit: contain;" src="https://panel.exchange.gov.tm/img/mini-logo.png" alt="logo">
</div>
<h1 class="title" style="font-size: 16px; text-align: left; font-weight: 700; line-height: 1.5; color: #fff; width: calc(100% - 60px);">
Статус вашей заявки изменён!
</h1>
</div>
</th>
</tr>
</thead>
<tbody class="content">
<tr>
<td style="padding: 30px 0 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Здравствуйте!
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Статус вашей заявки изменён на «Отправлено на доработку».
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 30px 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4;">
Вы также получили новое сообщение с описанием проблемы. Чтобы просмотреть его, войдите в личный кабинет в раздел «Список обращений».
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 30px 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4;">
С уважением, <br>
отдел фин. мониторинга ГТСБТ.
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
<title>Email template</title>
<style type="text/css">
@media screen and (max-width: 450px) {
.title {
width: calc(100% - 54px);
font-size: 14px;
}
}
</style>
</head>
<body style="font-family: 'Poppins', sans-serif;
font-size: 14px;
color: #000;
line-height: 1.4;
font-weight: 400;
background: #fff;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;">
<div id="wrapper" style=" margin: 10px;">
<div class="inner">
<table class="mail"
style="border: 1px solid #003197; border-radius: 5px; overflow: hidden; width: 100%; border-spacing: 0;">
<thead style="background-color: #003197;">
<tr>
<th class="header" style="padding: 0; position: relative;">
<div class="header_row" style=" display: flex; align-items: center; padding: 10px 20px;">
<div class="logo" style="width: 44px; height: 44px; margin-right: 20px; position: relative; z-index: 2;">
<img style=" width: 100%; height: 100%; object-fit: contain; -o-object-fit: contain;" src="https://panel.exchange.gov.tm/img/mini-logo.png" alt="logo">
</div>
<h1 class="title" style="font-size: 16px; text-align: left; font-weight: 700; line-height: 1.5; color: #fff; width: calc(100% - 60px);">
Вы получили новое сообщение.
</h1>
</div>
</th>
</tr>
</thead>
<tbody class="content">
<tr>
<td style="padding: 30px 0 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Здравствуйте!
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Вы получили новое сообщение.
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 30px 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4;">
Чтобы просмотреть его, войдите в личный кабинет в раздел «Список обращений».
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 30px 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4;">
С уважением, <br>
отдел фин. мониторинга ГТСБТ.
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>

View File

@ -0,0 +1,90 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
<title>Email template</title>
<style type="text/css">
@media screen and (max-width: 450px) {
.title {
width: calc(100% - 54px);
font-size: 14px;
}
}
</style>
</head>
<body style="font-family: 'Poppins', sans-serif;
font-size: 14px;
color: #000;
line-height: 1.4;
font-weight: 400;
background: #fff;
position: relative;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;">
<div id="wrapper" style=" margin: 10px;">
<div class="inner">
<table class="mail"
style="border: 1px solid #003197; border-radius: 5px; overflow: hidden; width: 100%; border-spacing: 0;">
<thead style="background-color: #003197;">
<tr>
<th class="header" style="padding: 0; position: relative;">
<div class="header_row" style=" display: flex; align-items: center; padding: 10px 20px;">
<div class="logo" style="width: 44px; height: 44px; margin-right: 20px; position: relative; z-index: 2;">
<img style=" width: 100%; height: 100%; object-fit: contain; -o-object-fit: contain;" src="https://panel.exchange.gov.tm/img/mini-logo.png" alt="logo">
</div>
<h1 class="title" style="font-size: 16px; text-align: left; font-weight: 700; line-height: 1.5; color: #fff; width: calc(100% - 60px);">
Вы получили новое сообщение.
</h1>
</div>
</th>
</tr>
</thead>
<tbody class="content">
<tr>
<td style="padding: 30px 0 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Здравствуйте!
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 0 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4; margin-bottom: 15px;">
Вы получили новое сообщение.
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 30px 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4;">
Чтобы просмотреть его, войдите в личный кабинет в раздел «Список обращений».
</p>
</td>
</tr>
<tr>
<td style="padding: 0 20px 30px 20px;">
<p class="content_txt" style="font-size: 14px; font-weight: 400; line-height: 1.4;">
С уважением, <br>
отдел фин. мониторинга ГТСБТ.
</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>