From a5d20daab31e940cf890ade75a44ffcaf3489693 Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Thu, 6 Apr 2023 08:54:23 +0000 Subject: [PATCH 1/9] Updated Enums --- app/Enums/TicketStatus.php | 32 ++++++-------------------------- 1 file changed, 6 insertions(+), 26 deletions(-) diff --git a/app/Enums/TicketStatus.php b/app/Enums/TicketStatus.php index d764208..08330fa 100644 --- a/app/Enums/TicketStatus.php +++ b/app/Enums/TicketStatus.php @@ -7,17 +7,12 @@ 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 waiting() * @method static self waitingValidation() - * @method static self processed() * @method static self recette() * @method static self production() * @method static self archived() + * @method static self takenInAccount() */ class TicketStatus extends BaseEnumRoutable { @@ -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' => 18, ]; } @@ -55,17 +45,12 @@ 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é'), + 'waiting' => trans('En attente de réponse'), + 'waitingValidation' => trans('En attente de validation'), 'recette' => trans('En recettage'), 'production' => trans('En production'), 'archived' => trans('Archivé'), + 'takenInAccount' => trans('Pris en compte'), ]; } @@ -79,17 +64,12 @@ 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', 'waiting' => 'text-white bg-danger', 'waitingValidation' => 'text-warning bg-danger', - 'processed' => trans('Traité'), 'recette' => 'text-primary', 'production' => 'text-success', 'archived' => 'text-secondary', + 'takenInAccount' => 'text-info', ]; } From 78c80b9b382157af3042c65e032965be5cf36dfe Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Thu, 6 Apr 2023 08:55:01 +0000 Subject: [PATCH 2/9] Updated ticket status when created --- app/Models/Ticket.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Models/Ticket.php b/app/Models/Ticket.php index a415e11..c5da69d 100644 --- a/app/Models/Ticket.php +++ b/app/Models/Ticket.php @@ -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 takenInAccount. All the others are estimateTodo. + if ($ticket->type->equals(TicketType::bug())) { + $ticket->status = TicketStatus::takenInAccount(); + } else { $ticket->status = TicketStatus::estimateTodo(); } }); From 4d37a18baeaa76468435606207a4dfa54ebed85e Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Thu, 6 Apr 2023 08:55:49 +0000 Subject: [PATCH 3/9] Updated ticket status when answer estimation is submitted --- app/Http/Controllers/Credit/EstimationController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Credit/EstimationController.php b/app/Http/Controllers/Credit/EstimationController.php index 73083cf..4a66963 100644 --- a/app/Http/Controllers/Credit/EstimationController.php +++ b/app/Http/Controllers/Credit/EstimationController.php @@ -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(); From 90d3a6f8e64ad2911530e2ea393cfab70746fcf7 Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Thu, 6 Apr 2023 08:56:20 +0000 Subject: [PATCH 4/9] Created migration to change actual status --- ...023_04_06_101917_change_tickets_status.php | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 database/migrations/2023_04_06_101917_change_tickets_status.php diff --git a/database/migrations/2023_04_06_101917_change_tickets_status.php b/database/migrations/2023_04_06_101917_change_tickets_status.php new file mode 100644 index 0000000..d3a685d --- /dev/null +++ b/database/migrations/2023_04_06_101917_change_tickets_status.php @@ -0,0 +1,53 @@ +get(); + collect($tickets)->map(function (object $ticket) { + switch ($ticket->status) { + case 3: + DB::table('tickets')->where('id', $ticket->id) + ->update(['status' => 18]); + break; + case 4: + DB::table('tickets')->where('id', $ticket->id) + ->update(['status' => 18]); + break; + case 5: + DB::table('tickets')->where('id', $ticket->id) + ->update(['status' => 18]); + break; + case 7: + DB::table('tickets')->where('id', $ticket->id) + ->update(['status' => 18]); + break; + case 10: + DB::table('tickets')->where('id', $ticket->id) + ->update(['status' => 13]); + break; + default: + break; + } //end switch + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + // + } +} From c1d5cb1dfcfc10c8a4686cccdc02465dc9e7dea5 Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Thu, 6 Apr 2023 09:09:13 +0000 Subject: [PATCH 5/9] Fixed deleted enums used in Controller --- app/Http/Controllers/Controller.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index a477dd0..efa4c3d 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -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() ] ); From aa381ac61b424800dde358b5377145f2caa1ee71 Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Tue, 11 Apr 2023 12:28:00 +0000 Subject: [PATCH 6/9] Re-ordered ticket status enums --- app/Enums/TicketStatus.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/app/Enums/TicketStatus.php b/app/Enums/TicketStatus.php index 08330fa..12f478e 100644 --- a/app/Enums/TicketStatus.php +++ b/app/Enums/TicketStatus.php @@ -7,12 +7,12 @@ use Kwaadpepper\Enum\BaseEnumRoutable; /** * @method static self new() * @method static self estimateTodo() + * @method static self takenInAccount() * @method static self waiting() * @method static self waitingValidation() * @method static self recette() * @method static self production() * @method static self archived() - * @method static self takenInAccount() */ class TicketStatus extends BaseEnumRoutable { @@ -26,12 +26,12 @@ class TicketStatus extends BaseEnumRoutable return [ 'new' => 1, 'estimateTodo' => 2, - 'waiting' => 9, - 'recette' => 12, - 'production' => 13, - 'archived' => 15, - 'waitingValidation' => 17, - 'takenInAccount' => 18, + 'takenInAccount' => 3, + 'waiting' => 4, + 'waitingValidation' => 5, + 'recette' => 6, + 'production' => 7, + 'archived' => 8, ]; } @@ -45,12 +45,12 @@ class TicketStatus extends BaseEnumRoutable return [ 'new' => trans('Nouveau'), 'estimateTodo' => trans('Devis à faire'), + '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é'), - 'takenInAccount' => trans('Pris en compte'), ]; } @@ -64,12 +64,12 @@ class TicketStatus extends BaseEnumRoutable return [ 'new' => 'text-danger', 'estimateTodo' => 'text-info', + 'takenInAccount' => 'text-info', 'waiting' => 'text-white bg-danger', 'waitingValidation' => 'text-warning bg-danger', 'recette' => 'text-primary', 'production' => 'text-success', 'archived' => 'text-secondary', - 'takenInAccount' => 'text-info', ]; } From 9a49686f93513792e109b597f2e412f7a16fe7cd Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Tue, 11 Apr 2023 12:28:33 +0000 Subject: [PATCH 7/9] Cleand migration and updated with new enums --- ...023_04_06_101917_change_tickets_status.php | 42 ++++++------------- 1 file changed, 13 insertions(+), 29 deletions(-) diff --git a/database/migrations/2023_04_06_101917_change_tickets_status.php b/database/migrations/2023_04_06_101917_change_tickets_status.php index d3a685d..9e3be7b 100644 --- a/database/migrations/2023_04_06_101917_change_tickets_status.php +++ b/database/migrations/2023_04_06_101917_change_tickets_status.php @@ -1,7 +1,7 @@ get(); - collect($tickets)->map(function (object $ticket) { - switch ($ticket->status) { - case 3: - DB::table('tickets')->where('id', $ticket->id) - ->update(['status' => 18]); - break; - case 4: - DB::table('tickets')->where('id', $ticket->id) - ->update(['status' => 18]); - break; - case 5: - DB::table('tickets')->where('id', $ticket->id) - ->update(['status' => 18]); - break; - case 7: - DB::table('tickets')->where('id', $ticket->id) - ->update(['status' => 18]); - break; - case 10: - DB::table('tickets')->where('id', $ticket->id) - ->update(['status' => 13]); - break; - default: - break; - } //end switch - }); + 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]); } /** @@ -48,6 +33,5 @@ class ChangeTicketsStatus extends Migration */ public function down() { - // } } From 1c361f504c2d68dff1dfc531fd3f6b07fafc4ae2 Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Tue, 11 Apr 2023 15:03:24 +0000 Subject: [PATCH 8/9] Added reverse migration --- .../2023_04_06_101917_change_tickets_status.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/database/migrations/2023_04_06_101917_change_tickets_status.php b/database/migrations/2023_04_06_101917_change_tickets_status.php index 9e3be7b..5b2aa0d 100644 --- a/database/migrations/2023_04_06_101917_change_tickets_status.php +++ b/database/migrations/2023_04_06_101917_change_tickets_status.php @@ -33,5 +33,17 @@ class ChangeTicketsStatus extends Migration */ 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]); } } From 16b2016c0e38716de4879b392b8013268992876d Mon Sep 17 00:00:00 2001 From: "noah.lancien" Date: Tue, 11 Apr 2023 15:05:29 +0000 Subject: [PATCH 9/9] Fixed status when creating a ticket --- app/Models/Ticket.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Models/Ticket.php b/app/Models/Ticket.php index c5da69d..dba2071 100644 --- a/app/Models/Ticket.php +++ b/app/Models/Ticket.php @@ -63,9 +63,9 @@ class Ticket extends Model protected static function booted() { static::creating(function (Ticket $ticket) { - // If bug force the ticket status on takenInAccount. All the others are estimateTodo. + // If bug force the ticket status on new. All the others are estimateTodo. if ($ticket->type->equals(TicketType::bug())) { - $ticket->status = TicketStatus::takenInAccount(); + $ticket->status = TicketStatus::new(); } else { $ticket->status = TicketStatus::estimateTodo(); }