Merge branch 'issue-2' into 'develop'

Issue 2

Closes #2

See merge request ldc-web/projets/support-web!12
This commit is contained in:
Vincent BRIDIER 2023-04-11 15:15:31 +00:00
commit 1a3f3d57ce
5 changed files with 67 additions and 38 deletions

View file

@ -7,14 +7,9 @@ use Kwaadpepper\Enum\BaseEnumRoutable;
/**
* @method static self new()
* @method static self estimateTodo()
* @method static self estimateValidated()
* @method static self estimateDone()
* @method static self toPlan()
* @method static self planned()
* @method static self inprogress()
* @method static self takenInAccount()
* @method static self waiting()
* @method static self waitingValidation()
* @method static self processed()
* @method static self recette()
* @method static self production()
* @method static self archived()
@ -31,17 +26,12 @@ class TicketStatus extends BaseEnumRoutable
return [
'new' => 1,
'estimateTodo' => 2,
'estimateValidated' => 3,
'toPlan' => 4,
'planned' => 5,
'inprogress' => 7,
'waiting' => 9,
'processed' => 10,
'recette' => 12,
'production' => 13,
'archived' => 15,
'estimateDone' => 16,
'waitingValidation' => 17,
'takenInAccount' => 3,
'waiting' => 4,
'waitingValidation' => 5,
'recette' => 6,
'production' => 7,
'archived' => 8,
];
}
@ -55,14 +45,9 @@ class TicketStatus extends BaseEnumRoutable
return [
'new' => trans('Nouveau'),
'estimateTodo' => trans('Devis à faire'),
'estimateValidated' => trans('Devis validé'),
'estimateDone' => trans('Devis réalisé'),
'toPlan' => trans('À planifier'),
'planned' => trans('Planifié'),
'inprogress' => trans('En cours'),
'waiting' => trans('En attente'),
'waitingValidation' => trans('En attente validation'),
'processed' => trans('Traité'),
'takenInAccount' => trans('Pris en compte'),
'waiting' => trans('En attente de réponse'),
'waitingValidation' => trans('En attente de validation'),
'recette' => trans('En recettage'),
'production' => trans('En production'),
'archived' => trans('Archivé'),
@ -79,14 +64,9 @@ class TicketStatus extends BaseEnumRoutable
return [
'new' => 'text-danger',
'estimateTodo' => 'text-info',
'estimateValidated' => 'text-info',
'estimateDone' => 'text-info',
'toPlan' => 'text-info',
'planned' => 'text-info',
'inprogress' => 'text-dark',
'takenInAccount' => 'text-info',
'waiting' => 'text-white bg-danger',
'waitingValidation' => 'text-warning bg-danger',
'processed' => trans('Traité'),
'recette' => 'text-primary',
'production' => 'text-success',
'archived' => 'text-secondary',

View file

@ -44,12 +44,10 @@ class Controller extends BaseController
[
TicketStatus::new(),
TicketStatus::estimateTodo(),
TicketStatus::estimateValidated(),
TicketStatus::toPlan(),
TicketStatus::planned(),
TicketStatus::waiting(),
TicketStatus::production(),
TicketStatus::archived()
TicketStatus::archived(),
TicketStatus::takenInAccount()
]
);

View file

@ -77,7 +77,7 @@ class EstimationController extends Controller
/** @var \App\Models\Credit\Estimation */
$estimation = $ticket->estimation;
if ($request->answer) {
$ticket->status = TicketStatus::toPlan();
$ticket->status = TicketStatus::takenInAccount();
$estimation->status = EstimationStatus::accepted();
} else {
$ticket->status = TicketStatus::archived();

View file

@ -63,8 +63,10 @@ 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())) {
// If bug force the ticket status on new. All the others are estimateTodo.
if ($ticket->type->equals(TicketType::bug())) {
$ticket->status = TicketStatus::new();
} else {
$ticket->status = TicketStatus::estimateTodo();
}
});

View file

@ -0,0 +1,49 @@
<?php
use App\Models\Ticket;
use Illuminate\Database\Migrations\Migration;
class ChangeTicketsStatus extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Ticket::whereIn('status', [4, 5, 7, 10])
->update(['status' => 3]);
Ticket::where('status', 9)
->update(['status' => 4]);
Ticket::where('status', 17)
->update(['status' => 5]);
Ticket::where('status', 12)
->update(['status' => 6]);
Ticket::where('status', 13)
->update(['status' => 7]);
Ticket::where('status', 15)
->update(['status' => 8]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Ticket::where('status', 3)
->update(['status' => 10]);
Ticket::where('status', 4)
->update(['status' => 9]);
Ticket::where('status', 5)
->update(['status' => 17]);
Ticket::where('status', 6)
->update(['status' => 12]);
Ticket::where('status', 7)
->update(['status' => 13]);
Ticket::where('status', 8)
->update(['status' => 15]);
}
}