Merge branch 'develop' into trunk

This commit is contained in:
Jérémy Munsch 2021-05-21 14:35:26 +02:00
commit fe3a9c7dee
14 changed files with 154 additions and 9 deletions

View file

@ -32,6 +32,7 @@ MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
MAIL_LIST_SERVICEWEB=informatique.internet@ldc.fr
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=

View file

@ -6,6 +6,10 @@ use Kwaadpepper\Enum\BaseEnum;
/**
* @method static self new()
* @method static self estimateTodo()
* @method static self estimateValidated()
* @method static self toPlan()
* @method static self planned()
* @method static self inprogress()
* @method static self waiting()
* @method static self processed()
@ -19,12 +23,16 @@ class TicketStatus extends BaseEnum
{
return [
'new' => 1,
'inprogress' => 2,
'waiting' => 3,
'processed' => 4,
'recette' => 5,
'production' => 6,
'archived' => 9,
'estimateTodo' => 2,
'estimateValidated' => 3,
'toPlan' => 4,
'planned' => 5,
'inprogress' => 7,
'waiting' => 9,
'processed' => 10,
'recette' => 12,
'production' => 13,
'archived' => 15,
];
}
@ -32,6 +40,10 @@ class TicketStatus extends BaseEnum
{
return [
'new' => trans('Nouveau'),
'estimateTodo' => trans('Devis à faire'),
'estimateValidated' => trans('Devis validé'),
'toPlan' => trans('À planifier'),
'planned' => trans('Planifié'),
'inprogress' => trans('En cours'),
'waiting' => trans('En attente'),
'processed' => trans('Traité'),

View file

@ -3,9 +3,13 @@
namespace App\Exceptions;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Support\Facades\Mail;
use RuntimeException;
use Throwable;
class Handler extends ExceptionHandler
{
/**
* A list of the exception types that are not reported.
*
@ -25,6 +29,45 @@ class Handler extends ExceptionHandler
'password_confirmation',
];
/**
* Report or log an exception.
*
* @param \Throwable $exception
* @return void
*
* @throws \Exception
*/
public function report(Throwable $e)
{
if (get_class($e) == RedirectTo::class) {
abort(redirect($e->url));
}
try {
if (config('app.debug') === false) {
if ($this->shouldntReport($e)) {
return;
}
Mail::send([
'html' => 'emails.exception',
'text' => 'emails.exception-plain'
], [
'exception' => $e,
'appName' => config('app.name')
], function ($m) {
$m->to(
config('mail.contactsList.serviceweb'),
sprintf('%s Exception Handler', config('app.name'))
)->subject('Need help !, an error occured in your application, please check Logs ASAP');
});
}
// phpcs:ignore Generic.CodeAnalysis.EmptyStatement.DetectedCatch
} catch (RuntimeException $e) {
// do nothing, mail send error, let laravel only handle this
} finally {
parent::report($e);
}
}
/**
* Register the exception handling callbacks for the application.
*

View file

@ -31,6 +31,6 @@ class NewTicket extends Mailable
public function build()
{
$ticket = $this->ticket;
return $this->subject("[SupportWeb] Nouveau ticket n°" . $ticket->id)->view('mails.new-ticket', compact('ticket'));
return $this->subject("[SupportWeb] Nouveau ticket n°" . $ticket->id)->view('emails.new-ticket', compact('ticket'));
}
}

View file

@ -40,6 +40,6 @@ class TicketMention extends Mailable
$ticket = $this->ticket;
$corpsMaj = Utils::plainToHtml($this->corpsMaj);
return $this->subject("[SupportWeb] Vous avez été mentionné sur le ticket n° $ticket->id")
->view('mails.ticket-mention', compact('ticket', 'corpsMaj'));
->view('emails.ticket-mention', compact('ticket', 'corpsMaj'));
}
}

View file

@ -40,6 +40,6 @@ class TicketUpdate extends Mailable
{
$ticket = $this->ticket;
$corpsMaj = Utils::plainToHtml($this->corpsMaj);
return $this->subject("[SupportWeb] Le ticket n°" . $ticket->id . " à été mis à jour")->view('mails.ticket-update', compact('ticket', 'corpsMaj'));
return $this->subject("[SupportWeb] Le ticket n°" . $ticket->id . " à été mis à jour")->view('emails.ticket-update', compact('ticket', 'corpsMaj'));
}
}

View file

@ -30,6 +30,12 @@ class Ticket extends Model
protected static function booted()
{
static::creating(function (Ticket $ticket) {
// If evolution force the ticket status on estimateTodo
if ($ticket->type->equals(TicketType::evolution())) {
$ticket->status = TicketStatus::estimateTodo();
}
});
static::updating(function (Ticket $ticket) {
$oldStatus = Ticket::where('id', $ticket->id)->first()->status;
if (!$ticket->status->equals($oldStatus)) {

View file

@ -91,6 +91,10 @@ return [
'name' => env('MAIL_FROM_NAME', 'Example'),
],
'contactsList' => [
'serviceweb' => env('MAIL_LIST_SERVICEWEB', 'informatique.internet@ldc.fr')
],
/*
|--------------------------------------------------------------------------
| Markdown Mail Settings

View file

@ -0,0 +1,53 @@
<?php
use App\Enums\TicketStatus;
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
class UpdateTicketsStatusWithEnumStatus3 extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
foreach (Ticket::where('status', 2)->get() as $ticket) {
$ticket->status = TicketStatus::inprogress();
$ticket->save();
}
foreach (Ticket::where('status', 3)->get() as $ticket) {
$ticket->status = TicketStatus::waiting();
$ticket->save();
}
foreach (Ticket::where('status', 4)->get() as $ticket) {
$ticket->status = TicketStatus::processed();
$ticket->save();
}
foreach (Ticket::where('status', 5)->get() as $ticket) {
$ticket->status = TicketStatus::recette();
$ticket->save();
}
foreach (Ticket::where('status', 6)->get() as $ticket) {
$ticket->status = TicketStatus::production();
$ticket->save();
}
foreach (Ticket::where('status', 9)->get() as $ticket) {
$ticket->status = TicketStatus::archived();
$ticket->save();
}
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
//
}
}

View file

@ -0,0 +1,10 @@
{{ $appName }} Exception Handler
Une erreur est survenue sur le site {{ $appName }}
{{ $exception->getMessage() }}
date : {{ date('Y-m-d H:i:s') }}
code : {{$exception->getCode() }}
file : {{$exception->getFile() }}
line : {{$exception->getLine() }}
Veuillez vérifier les logs pour en voir la trace.

View file

@ -0,0 +1,16 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>{{ $appName }} Exception Handler</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<h1>Une erreur est survenue sur le site {{ $appName }}</h1>
<h2>{{ $exception->getMessage() }}</h2>
<p>date : {{ date('Y-m-d H:i:s') }}</p>
<p>code : {{$exception->getCode() }}</p>
<p>file : {{$exception->getFile() }}</p>
<p>line : {{$exception->getLine() }}</p>
<p>Veuillez vérifier les logs pour en voir la trace.</p>
</body>
</html>