Merge branch 'trunk'

This commit is contained in:
Noah Lancien 2026-03-25 11:52:33 +01:00
commit ef57fe9fe5
22 changed files with 453 additions and 98 deletions

View file

@ -2,14 +2,16 @@
namespace App\Console\Commands;
use Carbon\Carbon;
use App\Models\Ticket;
use App\Models\GitlabIssues;
use App\Models\GitlabLabels;
use App\Models\GitlabMilestones;
use App\Models\GitlabProjects;
use Carbon\Carbon;
use GrahamCampbell\GitLab\Facades\GitLab;
use Illuminate\Console\Command;
use App\Models\GitlabMilestones;
use Illuminate\Support\Facades\Cache;
use App\Enums\Tickets\TicketStatusEnum;
use GrahamCampbell\GitLab\Facades\GitLab;
class UpdateGitlabDatas extends Command
{
@ -48,6 +50,8 @@ class UpdateGitlabDatas extends Command
$this->updateMilestonesByProject($project);
$this->updateIssuesByProject($project, $isCron);
}
$this->syncTicketStatus();
}
/**
@ -191,6 +195,7 @@ class UpdateGitlabDatas extends Command
);
$issueModel = GitlabIssues::where('gitlab_id', $issue['id'])->firstOrFail();
$labelIds = [];
foreach ($issue['labels'] as $labelName) {
$label = Cache::remember("gitlab_label_{$labelName}", 300, function () use ($labelName) {
@ -198,9 +203,11 @@ class UpdateGitlabDatas extends Command
});
if ($label) {
$issueModel->gitlabLabels()->syncWithoutDetaching($label);
$labelIds[] = $label;
}
}
$issueModel->gitlabLabels()->sync($labelIds);
}//end foreach
$this->info("Gitlab issues upsert complete.");
@ -257,4 +264,44 @@ class UpdateGitlabDatas extends Command
$this->info("Gitlab milestones upsert complete.");
}
/**
* Synchronizes ticket statuses based on GitLab issue labels.
*
* @return void
*/
private function syncTicketStatus(): void
{
$tickets = Ticket::whereNotNull('gitlab_issue')->whereNot('status', TicketStatusEnum::archived)->get();
foreach ($tickets as $ticket) {
$gitlabIssue = GitlabIssues::where('url', $ticket->gitlab_issue)->with('gitlabLabels')->first();
$gitlabIssueLabels = $gitlabIssue ? $gitlabIssue->gitlabLabels->pluck('name') : [];
if ($gitlabIssueLabels) {
match (true) {
$gitlabIssueLabels->contains('g-wip') => $this->updateTicketStatus($ticket, TicketStatusEnum::inDev),
$gitlabIssueLabels->contains('g-production') => $this->updateTicketStatus($ticket, TicketStatusEnum::production),
default => null,
};
}
}
}
/**
* Updates the ticket status only if it has changed.
*
* @param Ticket $ticket The ticket to update.
* @param TicketStatusEnum $status The new status to apply.
*
* @return void
*/
private function updateTicketStatus(Ticket $ticket, TicketStatusEnum $status): void
{
if ($ticket->status !== $status && $ticket->status !== TicketStatusEnum::waiting) {
$ticket->status = $status;
$ticket->saveOrFail();
}
}
}

View file

@ -28,7 +28,7 @@ class Kernel extends ConsoleKernel
$schedule->job(ExportTicketsState::class)->weekly()->mondays()->at('07:00');
$schedule->job(AutoCloseOldTickets::class)->dailyAt('08:00');
$schedule->job(WarnBeforeAutoCloseTicket::class)->dailyAt('08:05');
$schedule->command('app:update-gitlab-datas --is-cron')->twiceDaily(1, 13);
$schedule->command('app:update-gitlab-datas --is-cron')->hourly()->between('7:00', '19:00');
}
/**

View file

@ -8,10 +8,12 @@ enum InvoiceStatusEnum: int
{
use BaseEnum;
case opened = 1;
case refused = 2;
case canceled = 3;
case archived = 4;
case opened = 1;
case refused = 2;
case canceled = 3;
case archived = 4;
case awaiting_signature = 5;
case awaiting_invoicing = 6;
/**
* Optionnal labels definition.
@ -21,5 +23,7 @@ enum InvoiceStatusEnum: int
self::refused->name => "Refusé (par le client ou aucune réponse de sa part)",
self::canceled->name => "Annulé (supprimé)",
self::archived->name => "Archivé (validé et envoyé à la comptabilité)",
self::awaiting_signature->name => "En attente de signature",
self::awaiting_invoicing->name => "En attente de facturation",
];
}

View file

@ -17,6 +17,7 @@ enum TicketStatusEnum: int
case recetteValidated = 7;
case production = 8;
case archived = 9;
case inDev = 10;
/**
* Optionnal labels definition
@ -24,13 +25,14 @@ enum TicketStatusEnum: int
private const LABELS = [
self::new->name => "Nouveau",
self::estimateTodo->name => "Étude chef(s) de projet",
self::takenInAccount->name => "Pris en compte",
self::takenInAccount->name => "À planifier",
self::waiting->name => "En attente de réponse",
self::waitingValidation->name => "En attente de validation",
self::recette->name => "En recettage",
self::recetteValidated->name => "Recettage validé",
self::production->name => "En production",
self::archived->name => "Archivé",
self::inDev->name => "En cours de développement",
];
/**
@ -46,6 +48,7 @@ enum TicketStatusEnum: int
self::recetteValidated->name => 'text-success',
self::production->name => 'text-success',
self::archived->name => 'text-secondary',
self::inDev->name => 'text-discovery',
];
/**

View file

@ -1,24 +0,0 @@
<?php
namespace App\Enums\Users;
use App\Traits\Enums\BaseEnum;
enum GitlabUsersEnum: int
{
use BaseEnum;
/**
* Each user is associated to his ID on gitlab.
*
* 24 is Nicolas Demangeat
*/
case default = 24;
/**
* Optionnal labels definition
*/
private const LABELS = [
self::default->name => "Default",
];
}

View file

@ -31,10 +31,21 @@ class InvoiceController extends Controller
? Invoice::query()->orderByDesc('created_at')
: Invoice::query();
$status = intval($request->status);
$invoiceModels = $invoiceModels->when($status, function ($query) use ($status) {
$query->where('status', $status);
});
$status = intval($request->status);
switch ($status) {
case InvoiceStatusEnum::awaiting_signature->value:
$invoiceModels->whereNotNull('sent_client_date')->whereNull('signed_date');
break;
case InvoiceStatusEnum::awaiting_invoicing->value:
$invoiceModels->whereNotNull('sent_client_date')->whereNotNull('signed_date')->whereNull('sent_accounting_date');
break;
default:
if ($status !== 0) {
$invoiceModels->where('status', $status);
}
break;
}
/** @var string $search Search field */
$search = $request->search;
@ -79,7 +90,7 @@ class InvoiceController extends Controller
*/
public function create(Invoice $invoice): \Illuminate\Contracts\View\View
{
$packageModels = Package::get();
$packageModels = Package::where('published', true)->get();
$taskRowModel = Invoice::getTaskStructure();
$siteModels = Site::orderBy('name', 'ASC')->get();
$companyModels = Company::get();

View file

@ -23,6 +23,15 @@ class PackageController extends Controller
/** @var \Illuminate\Database\Eloquent\Builder $packageModels */
$packageModels = Package::query();
$status = $request->status;
if ($status === null) {
$packageModels->where('published', true);
} elseif ($status === '0') {
$packageModels->where('published', false);
} elseif ($status === '1') {
$packageModels->where('published', true);
}
/** @var string $search Search field */
$search = $request->search;
if ($search) {
@ -42,7 +51,7 @@ class PackageController extends Controller
/** Custom pagination */
$packageModels = $this->customPaginate($packageModels, $request->pagination);
return view('bo.pages.packages.index', compact('packageModels', 'search', 'searchFields'));
return view('bo.pages.packages.index', compact('packageModels', 'search', 'searchFields', 'status'));
}
/**
@ -153,4 +162,16 @@ class PackageController extends Controller
));
});
}
/**
* Change model published.
*
* @param \App\Models\Package $package
* @return \Illuminate\Http\RedirectResponse
*/
public function changePublished(Package $package)
{
$package->update(['published' => !$package->getOriginal('published')]);
return redirect()->back()->with('success', trans(__('crud.messages.publish_status_saved')));
}
}

View file

@ -2,37 +2,37 @@
namespace App\Http\Controllers\Bo;
use App\Enums\Tickets\TicketStatusEnum;
use App\Enums\Tickets\TicketTypeEnum;
use App\Enums\Users\GitlabUsersEnum;
use App\Models\Site;
use App\Models\User;
use App\Models\Ticket;
use App\Mail\NewTicket;
use App\Models\Message;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Jobs\UpdateIssueLabels;
use App\Lib\Helpers\ToolboxHelper;
use Illuminate\Support\Facades\DB;
use App\Events\NotifySubscriptions;
use App\Events\TicketStatusChanged;
use App\Http\Controllers\Controller;
use App\Http\Requests\Bo\AssignTicketToUserRequest;
use App\Http\Requests\Bo\ChangeTicketStatus;
use App\Http\Requests\Bo\CreateMessage;
use App\Http\Requests\Bo\LinkTicket;
use Illuminate\Support\Facades\Mail;
use App\Enums\Tickets\TicketTypeEnum;
use App\Http\Requests\Bo\SortTickets;
use App\Http\Requests\Bo\StoreTicket;
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
use App\Http\Requests\Bo\UpdateMessage;
use App\Http\Requests\Bo\UpdateTicket;
use App\Http\Requests\Bo\LinkTicket;
use App\Http\Requests\Bo\UpdateTicketPriorityRequest;
use App\Lib\Helpers\FileStorageHelper;
use App\Lib\Helpers\ToolboxHelper;
use App\Mail\NewTicket;
use App\Models\Message;
use App\Models\Site;
use App\Models\Ticket;
use App\Models\User;
use App\Enums\Tickets\TicketStatusEnum;
use App\Http\Requests\Bo\CreateMessage;
use App\Http\Requests\Bo\UpdateMessage;
use Illuminate\Support\Facades\Session;
use GrahamCampbell\GitLab\Facades\GitLab;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Session;
use Illuminate\Support\Str;
use App\Http\Requests\Bo\ChangeTicketStatus;
use App\Http\Requests\Bo\UpdateChangeOrderRequest;
use App\Http\Requests\Bo\AssignTicketToUserRequest;
use App\Http\Requests\Bo\UpdateTicketPriorityRequest;
class TicketController extends Controller
{
@ -313,6 +313,10 @@ class TicketController extends Controller
*/
public function changeStatus(ChangeTicketStatus $request, Ticket $ticket)
{
if ($ticket->gitlab_issue) {
\dispatch(new UpdateIssueLabels($ticket, $request->status));
}
$ticket->fill($request->validated());
$ticket->saveOrFail();
@ -745,17 +749,19 @@ class TicketController extends Controller
*/
public function createGitlabIssue(Ticket $ticket)
{
$userGitlabId = auth()->user()->gitlab_id;
$gitlabRepoId = $ticket->site->gitlab_project_id;
$description = \sprintf("%s<br>", $ticket->text);
$cLabel = match ($ticket->type) {
TicketTypeEnum::bug => 'c-bug',
TicketTypeEnum::evolution, TicketTypeEnum::newsletter => 'c-feature',
TicketTypeEnum::bug => 'c-bug,to-dispatch',
TicketTypeEnum::evolution => 'c-feature',
TicketTypeEnum::newsletter => 'c-feature,g-to-estimate',
};
$assigneeId = match ($ticket->type) {
TicketTypeEnum::bug => GitlabUsersEnum::default->value,
TicketTypeEnum::bug => $userGitlabId,
TicketTypeEnum::evolution,
TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id ?? GitlabUsersEnum::default->value
TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id
};
try {
@ -766,7 +772,7 @@ class TicketController extends Controller
}
}
$issue = GitLab::issues()->create($gitlabRepoId, [
$data = [
'title' => sprintf(
'ts-%s : %s',
$ticket->id,
@ -777,8 +783,13 @@ class TicketController extends Controller
'c-support',
$cLabel
]),
'assignee_id' => $assigneeId,
]);
];
if ($assigneeId) {
$data['assignee_id'] = $assigneeId;
}
$issue = GitLab::issues()->create($gitlabRepoId, $data);
} catch (\Exception $e) {
\report($e);
return back()->with('error', \trans("Une erreur est survenue"));

View file

@ -17,6 +17,18 @@ class StorePackageRequest extends FormRequest
return Gate::allows('isAdmin');
}
/**
* Prepare the data for validation.
*
* @return void
*/
protected function prepareForValidation(): void
{
$this->merge([
'published' => $this->boolean('published'),
]);
}
/**
* Get the validation rules that apply to the request.
*
@ -27,6 +39,7 @@ class StorePackageRequest extends FormRequest
return [
'name' => 'required|string|min:3|max:255',
'amount' => 'required|numeric|min:0|regex:/^\d+(\.\d{1,2})?$/',
'published' => 'required|boolean',
];
}
@ -40,6 +53,7 @@ class StorePackageRequest extends FormRequest
return [
'name' => trans('Nom'),
'amount' => trans('Montant (par jour)'),
'published' => trans('Publication')
];
}
}

View file

@ -0,0 +1,85 @@
<?php
namespace App\Jobs;
use App\Models\Ticket;
use App\Enums\Tickets\TicketStatusEnum;
use Illuminate\Foundation\Queue\Queueable;
use App\Traits\Controllers\HasGitlabIssue;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Http\Requests\Bo\ChangeTicketStatus;
class UpdateIssueLabels implements ShouldQueue
{
use Queueable;
use HasGitlabIssue;
/** @var Ticket */
protected $ticket;
/** @var requestStatus */
protected $requestStatus;
/**
* Create a new job instance.
*
* @param \App\Models\Ticket $ticket
* @param string $request
*
* @return void
*/
public function __construct(Ticket $ticket, string $requestStatus)
{
$this->ticket = $ticket;
$this->requestStatus = $requestStatus;
}
/**
* Execute the job.
*/
public function handle(): void
{
$oldStatus = $this->ticket->status;
$requestStatus = (int) $this->requestStatus;
$gitlabIssue = $this->getGitlabIssue($this->ticket->site->gitlab_project_id, $this->ticket->gitlab_issue);
$issueLabels = $gitlabIssue['labels'];
if ($oldStatus === TicketStatusEnum::waiting && $requestStatus !== TicketStatusEnum::waiting->value) {
$issueLabels = array_values(array_diff($issueLabels, ['g-wait']));
}
switch ($requestStatus) {
case TicketStatusEnum::takenInAccount->value:
$newLabels = ['g-to-dispatch'];
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::waiting->value:
$newLabels = ['g-wait'];
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::waitingValidation->value:
$removeLabels = ['g-to-estimate'];
$updatedLabels = array_diff($issueLabels, $removeLabels);
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::recetteValidated->value:
$newLabels = ['g-re7-ok', 'to-prod'];
$updatedLabels = array_unique(array_merge($issueLabels, $newLabels));
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $updatedLabels);
break;
case TicketStatusEnum::archived->value:
$updatedIssue = $this->closeGitlabIssue($gitlabIssue['project_id'], $gitlabIssue['iid'], $issueLabels);
break;
default:
$updatedIssue = $this->updateGitlabIssueLabels($gitlabIssue['project_id'], $gitlabIssue['iid'], $issueLabels);
break;
}
}
}

View file

@ -111,6 +111,10 @@ class Invoice extends Model
->reduce(function ($previous, array $task) {
return \floatval($task['amount']) + \floatval($previous);
});
if($model->sent_accounting_date && $model->status !== InvoiceStatusEnum::archived->value) {
$model->status = InvoiceStatusEnum::archived;
}
});
static::deleting(function () {
throw new \Error('Action impossible');

View file

@ -28,5 +28,16 @@ class Package extends Model
protected $fillable = [
'name',
'amount',
'published'
];
/**
* The attributes that should be cast.
*
* @var array<string, string>
*/
protected $casts = [
'published' => 'boolean',
];
}

View file

@ -2,23 +2,25 @@
namespace App\Models;
use App\Enums\Users\RoleEnum;
use App\Enums\Tickets\TicketStatusEnum;
use App\Enums\Tickets\TicketTypeEnum;
use App\Events\NotifyAdmin;
use App\Events\NotifySubscriptions;
use App\Events\TicketStatusChanged;
use App\Jobs\SendTicketMentionMail;
use App\Mail\TicketMention;
use Illuminate\Support\Str;
use App\Models\GitlabIssues;
use App\Enums\Users\RoleEnum;
use App\Models\Credit\Account;
use App\Models\Credit\Estimation;
use App\Models\Ticket\TicketType;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use App\Events\NotifySubscriptions;
use App\Events\TicketStatusChanged;
use App\Jobs\SendTicketMentionMail;
use App\Enums\Tickets\TicketTypeEnum;
use App\Enums\Tickets\TicketStatusEnum;
use Illuminate\Database\Eloquent\Model;
use GrahamCampbell\GitLab\Facades\GitLab;
use Illuminate\Database\Eloquent\SoftDeletes;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\ModelNotFoundException;
class Ticket extends Model
{
@ -75,23 +77,20 @@ class Ticket extends Model
if (
!$ticket->original['status'] !== $ticket->status->value && $ticket->original['order'] === $ticket->order
) {
$user = auth()->user();
event(new TicketStatusChanged(
$ticket,
TicketStatusEnum::make($ticket->original['status']),
auth()->user(),
$user,
null,
false
));
event(new NotifySubscriptions($ticket, sprintf(
'<b>%s</b> a modifié le statut en <b>%s</b>',
auth()->user()->name,
$ticket->status->label()
)));
event(new NotifyAdmin($ticket, sprintf(
'<b>%s</b> a modifié le statut en <b>%s</b>',
auth()->user()->name,
$ticket->status->label()
)));
$message = $user ? sprintf('<b>%s</b> a modifié le statut en <b>%s</b>', $user->name, $ticket->status->label()) : sprintf('Le statut a été modifié en <b>%s</b>', $ticket->status->label());
event(new NotifySubscriptions($ticket, $message));
event(new NotifyAdmin($ticket, $message));
}
if ($ticket->status->equals(TicketStatusEnum::archived)) {
self::setOrder($ticket, true);

View file

@ -0,0 +1,59 @@
<?php
namespace App\Traits\Controllers;
use App\Models\GitlabIssues;
use GrahamCampbell\GitLab\Facades\GitLab;
trait HasGitlabIssue
{
/**
* Retrieves a GitLab issue id from its URL.
*
* @param int $projectId
* @param string $issueUrl
*
* @return array
*/
public function getGitlabIssue(int $projectId, string $issueUrl): array
{
if (!preg_match('/\/issues\/(\d+)/', $issueUrl, $matches)) { return []; }
$gitlabIssue = GitLab::issues()->show($projectId, (int) $matches[1]);
return $gitlabIssue;
}
/**
* Update labels for a GitLab issue.
*
* @param int|string $projectId
* @param int $issueId
* @param array $labels
*
* @return array
*/
public function updateGitlabIssueLabels($projectId, int $issueId, array $labels): array
{
return GitLab::issues()->update($projectId, $issueId, [
'labels' => implode(',', $labels),
]);
}
/**
* Close a GitLab issue.
*
* @param int|string $projectId
* @param int $issueId
* @param array $labels
*
* @return array
*/
public function closeGitlabIssue($projectId, int $issueId, array $labels): array
{
return GitLab::issues()->update($projectId, $issueId, [
'state_event' => 'close',
'labels' => implode(',', $labels),
]);
}
}

View file

@ -0,0 +1,28 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('packages', function (Blueprint $table) {
$table->boolean('published')->after('amount');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('packages', function (Blueprint $table) {
$table->dropColumn('published');
});
}
};

View file

@ -221,6 +221,9 @@ return [
'order' => 'order',
'priority' => 'priority',
'default' => 'default',
'date_mep' => 'Desired Launch'
'date_mep' => 'Desired Launch',
'published' => 'Publication',
'all' => 'All',
'estimate' => 'estimate',
]
];

View file

@ -257,6 +257,9 @@ return [
'order' => 'ordre',
'priority' => 'priorité',
'default' => 'défaut',
'date_mep' => 'MEP souhaitée'
'date_mep' => 'MEP souhaitée',
'published' => 'publication',
'all' => 'Tout',
'estimate' => 'estimation',
]
];

View file

@ -0,0 +1,14 @@
<td class="text-center align-middle">
<form action="{{ route('bo.' . $routeName . '.change-published', $model->getRouteKey()) }}" method="POST">
@csrf
@method('PATCH')
<button class="btn btn-sm @if ($model->published) btn-primary @else btn-danger @endif" data-bs-toggle="tooltip"
type="submit" title="{{ __($model->published ? __('crud.other.unpublish') : __('crud.other.publish')) }}">
@if ($model->published)
<i class="fa-solid fa-circle-check"></i>
@else
<i class="fa-solid fa-circle-xmark"></i>
@endif
</button>
</form>
</td>

View file

@ -61,6 +61,28 @@
</div>
</fieldset>
</div>
{{-- PUBLISHED --}}
<div class="col-12 col-md-6 mb-3">
<fieldset class="h-100 border bg-white p-3">
<legend>{{ Str::ucfirst(__('validation.custom.published')) }}</legend>
<div class="row">
<div class="col-12 mb-3">
@include('bo.partials.inputs.tinyint-boolean', [
'id' => 'packagePublished',
'label' => __(':field du :model', [
'field' => str(__('validation.custom.published'))->ucFirst(),
'model' => __('models.classes.packages'),
]),
'name' => 'published',
'model' => $packageModel ?? null,
'helper' => __('validation.boolean', [
'attribute' => str(__('validation.custom.published'))->ucFirst()
]),
])
</div>
</div>
</fieldset>
</div>
</div>
@push('scripts')

View file

@ -6,10 +6,32 @@
@section('content')
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
@include('breadcrumbs.breadcrumb-body')
<a class="btn btn-primary float-right" data-bs-toggle="tooltip" data-bs-placement="top" href="{{ route('bo.packages.create') }}"
title="{{ __('crud.helpers.create_model', ['model' => Str::singular(__('models.classes.packages'))]) }}">
<i class="fa-solid fa-plus"></i>
</a>
<form id="packageStatus" action="{{ route('bo.packages.index') }}">
<div class="input-group justify-content-end">
<select class="form-select w-fit" id="selectpackageStatus" name="status">
<option value="-1" @if ($status === '-1') selected @endif>
{{ __('validation.custom.all') }}
</option>
<option value="1" @if ($status === null || $status === '1') selected @endif>
{{ __('crud.other.publish') }}
</option>
<option value="0" @if ($status === '0') selected @endif>
{{ __('crud.other.unpublish') }}
</option>
</select>
@push('scripts')
<script nonce="{{ $nonce }}">
document.getElementById('selectpackageStatus').addEventListener('change', function(e) {
document.getElementById('packageStatus').submit();
});
</script>
@endpush
<a class="btn btn-primary float-right" data-bs-toggle="tooltip" data-bs-placement="top" href="{{ route('bo.packages.create') }}"
title="{{ __('crud.helpers.create_model', ['model' => Str::singular(__('models.classes.packages'))]) }}">
<i class="fa-solid fa-plus"></i>
</a>
</div>
</form>
</div>
@include('bo.modules.search-bar')
<table class="table-hover table">
@ -19,6 +41,7 @@
'cols' => [
'name' => Str::ucfirst(__('validation.attributes.name')),
'amount' => Str::ucfirst(__('validation.attributes.day')),
'published' => Str::ucfirst(__('validation.custom.published')),
],
])
</thead>
@ -27,6 +50,10 @@
<tr class="border-bottom list-item">
<td class="text-center align-middle">{{ $packageModel->name }}</td>
<td class="text-center align-middle">{{ $packageModel->amount }}</td>
@include('bo.modules.change-published-status', [
'routeName' => 'packages',
'model' => $packageModel,
])
<td class="text-end align-middle">
<form class="btn-group confirmDeleteTS" action="{{ route('bo.packages.destroy', $packageModel->id) }}"
method="POST" novalidate>

View file

@ -228,6 +228,11 @@
'status' => Str::ucfirst(__('validation.attributes.status')),
'title' => Str::ucfirst(__('validation.attributes.name')),
]);
if (session()->has('tickets.ty') && intval(session('tickets.ty')) === \App\Enums\Tickets\TicketTypeEnum::evolution->value) {
$cols = array_merge($cols, [
'estimate' => Str::ucfirst(__('validation.custom.estimate')),
]);
}
if (Auth::user()->isAdmin()) {
$cols = array_merge($cols, [
'tickets' => Str::ucfirst(__('validation.custom.tickets')),
@ -241,7 +246,7 @@
@endphp
@include('bo.modules.table-col-sorter', [
'cols' => $cols,
'ignore' => session('tickets.or') ? array_keys($cols) : ['id', 'site', 'status', 'tickets'],
'ignore' => session('tickets.or') ? array_keys($cols) : ['id', 'site', 'status', 'tickets', 'estimate'],
])
</thead>
<tbody>
@ -304,6 +309,12 @@
<td>
<span class="me-1">{{ $ticket->title }}</span>
</td>
{{-- estimate --}}
@if (session()->has('tickets.ty') && intval(session('tickets.ty')) === \App\Enums\Tickets\TicketTypeEnum::evolution->value)
<td>
<span class="me-1">{{ $ticket->estimation?->amount ? sprintf('%sj', $ticket->estimation->amount) : 'En cours' }}</span>
</td>
@endif
{{-- tag --}}
@php
$routeName = request()->route()->getName();

View file

@ -58,6 +58,8 @@ Route::middleware('admin-secure')
->middleware('htmlsanitize:template')
->parameters(['ticket_types' => 'ticket_type']);
Route::resource('packages', PackageController::class)->except('show');
Route::patch('/packages/{package}/change-published', [PackageController::class, 'changePublished'])
->name('packages.change-published');
Route::resource('invoices', InvoiceController::class)
->withoutMiddleware('htmlsanitize')
->middleware(['htmlsanitize:comment']);