diff --git a/app/Enums/Users/GitlabUsersEnum.php b/app/Enums/Users/GitlabUsersEnum.php index 3a8730f..43cbcdd 100644 --- a/app/Enums/Users/GitlabUsersEnum.php +++ b/app/Enums/Users/GitlabUsersEnum.php @@ -8,13 +8,17 @@ enum GitlabUsersEnum: int { use BaseEnum; - // Each user is associated to his ID on gitlab. - case nicolas = 24; + /** + * Each user is associated to his ID on gitlab. + * + * 24 is Nicolas Demangeat + */ + case default = 24; /** * Optionnal labels definition */ private const LABELS = [ - self::nicolas->name => "Nicolas Demangeat", + self::default->name => "Default", ]; } diff --git a/app/Http/Controllers/Bo/DashboardController.php b/app/Http/Controllers/Bo/DashboardController.php deleted file mode 100644 index 0dcd653..0000000 --- a/app/Http/Controllers/Bo/DashboardController.php +++ /dev/null @@ -1,29 +0,0 @@ -', now()->modify('-1 day')) - ->orderBy('date', 'asc') - ->limit(10) - ->get(); - return view('home', compact('dutyhourModels')); - } -} diff --git a/app/Http/Controllers/Bo/DutyhourController.php b/app/Http/Controllers/Bo/DutyhourController.php deleted file mode 100644 index b936483..0000000 --- a/app/Http/Controllers/Bo/DutyhourController.php +++ /dev/null @@ -1,157 +0,0 @@ -search; - if ($search) { - $this->searchQuery( - $dutyhourModels, - $search, - null, - 'date', - 'person', - 'place' - ); - } - $searchFields = trans('Date, personne, lieu'); - - /** Sort columns with a query */ - $this->sortQuery($dutyhourModels); - - /** Custom pagination */ - $dutyhourModels = $this->customPaginate($dutyhourModels, $request->pagination); - - return view('bo.pages.dutyhours.index', compact('dutyhourModels', 'search', 'searchFields')); - } - - /** - * Show the form for creating a new resource. - * - * @param \App\Models\Dutyhour $dutyhour - * @return \Illuminate\Contracts\View\View - */ - public function create(Dutyhour $dutyhour): \Illuminate\Contracts\View\View - { - return view('bo.pages.dutyhours.create', [ - 'dutyhourModel' => $dutyhour - ]); - } - - /** - * Store a newly created resource in storage. - * - * @param \App\Http\Requests\Bo\Dutyhours\StoreDutyhourRequest $request - * @return \Illuminate\Http\RedirectResponse - */ - public function store(StoreDutyhourRequest $request): \Illuminate\Http\RedirectResponse - { - return DB::transaction(function () use ($request) { - $dutyhour = new Dutyhour(); - $dutyhour->fill($request->validated()); - - if ($dutyhour->saveOrFail()) { - return redirect() - ->route('bo.dutyhours.edit', $dutyhour) - ->with('success', trans( - 'crud.messages.has_been_created', - ['model' => Str::singular(trans('models.classes.dutyhours'))] - )); - } - return redirect() - ->back() - ->with('error', trans( - 'crud.messages.cannot_be_created', - ['model' => Str::singular(trans('models.classes.dutyhours'))] - )); - }); - } - - /** - * Show the form for editing the specified resource. - * - * @param \App\Models\Dutyhour $dutyhour - * @return \Illuminate\Contracts\View\View - */ - public function edit(Dutyhour $dutyhour): \Illuminate\Contracts\View\View - { - return view('bo.pages.dutyhours.edit', [ - 'dutyhourModel' => $dutyhour - ]); - } - - /** - * Update the specified resource in storage. - * - * @param \App\Http\Requests\Bo\Dutyhours\UpdateDutyhourRequest $request - * @param \App\Models\Dutyhour $dutyhour - * @return \Illuminate\Http\RedirectResponse - */ - public function update(UpdateDutyhourRequest $request, Dutyhour $dutyhour): \Illuminate\Http\RedirectResponse - { - return DB::transaction(function () use ($request, $dutyhour) { - $dutyhour->fill($request->validated()); - if ($dutyhour->saveOrFail()) { - return redirect() - ->route('bo.dutyhours.edit', $dutyhour) - ->with('success', trans( - 'crud.messages.has_been_updated', - ['model' => Str::singular(trans('models.classes.dutyhours'))] - )); - } //end if - return redirect() - ->back() - ->with('error', trans( - 'crud.messages.cannot_be_updated', - ['model' => Str::singular(trans('models.classes.dutyhours'))] - )); - }); - } - - /** - * Remove the specified resource from storage. - * - * @param \App\Models\Dutyhour $dutyhour - * @return \Illuminate\Http\RedirectResponse - */ - public function destroy(Dutyhour $dutyhour): \Illuminate\Http\RedirectResponse - { - return DB::transaction(function () use ($dutyhour) { - if ($dutyhour->deleteOrFail()) { - return redirect() - ->route('bo.dutyhours.index') - ->with('success', trans( - 'crud.messages.has_been_deleted', - ['model' => Str::singular(trans('models.classes.dutyhours'))] - )); - } - return redirect() - ->back() - ->with('error', trans( - ':crud.messages.cannot_be_deleted', - ['model' => Str::singular(trans('models.classes.dutyhours'))] - )); - }); - } -} diff --git a/app/Http/Controllers/Bo/SiteController.php b/app/Http/Controllers/Bo/SiteController.php index be3d5f5..de9e73e 100644 --- a/app/Http/Controllers/Bo/SiteController.php +++ b/app/Http/Controllers/Bo/SiteController.php @@ -9,6 +9,7 @@ use App\Lib\Helpers\ToolboxHelper; use App\Models\Site; use App\Models\User; use Illuminate\Http\Request; +use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; use Illuminate\Support\Str; @@ -23,7 +24,7 @@ class SiteController extends Controller public function index(Request $request): \Illuminate\Contracts\View\View { /** @var \App\Models\User $user */ - $user = \auth()->user(); + $user = Auth::user(); if ($user->isAdmin()) { /** @var \Illuminate\Database\Eloquent\Builder $siteModels */ diff --git a/app/Http/Controllers/Bo/TicketController.php b/app/Http/Controllers/Bo/TicketController.php index 9c21e39..e3b891b 100644 --- a/app/Http/Controllers/Bo/TicketController.php +++ b/app/Http/Controllers/Bo/TicketController.php @@ -13,8 +13,10 @@ use App\Http\Requests\Bo\ChangeTicketStatus; use App\Http\Requests\Bo\CreateMessage; 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\Lib\Helpers\FileStorageHelper; use App\Lib\Helpers\ToolboxHelper; use App\Mail\NewTicket; @@ -25,6 +27,7 @@ use App\Models\User; 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; @@ -74,7 +77,6 @@ class TicketController extends Controller })); } //end if - /** @var \App\Models\User */ $user = auth()->user(); $tickets = Ticket::with(['site', 'labels']); @@ -95,14 +97,28 @@ class TicketController extends Controller TicketStatusEnum::archived ); + if (!$user->isAdmin() && $user->sites->count() === 1) { + $request->merge([ + 'pr' => $user->sites->first()->id, + ]); + } + $tickets = $this->filterTickets($tickets, $request); $tickets = $this->searchTicket($tickets, $request); + + /** Sort columns with a query */ + $this->sortQuery($tickets); + /** Custom pagination */ $tickets = $this->customPaginate($tickets, $request->pagination); $sites = Site::select('id', 'name')->orderBy('name')->get(); - $status = TicketStatusEnum::cases(); - $types = TicketTypeEnum::cases(); + $status = Arr::sort(TicketStatusEnum::cases(), function (TicketStatusEnum $value) { + return $value->label(); + }); + $types = Arr::sort(TicketTypeEnum::cases(), function (TicketTypeEnum $value) { + return $value->label(); + }); return view('bo.pages.tickets.index', compact('tickets', 'sites', 'status', 'types')); } @@ -484,6 +500,48 @@ class TicketController extends Controller return back()->with('info', trans('Le ticket n\'est plus assigné à personne')); } + + /** + * Link two tickets. + * + * @param LinkTicket $request + * @param Ticket $ticket + * + * @return \Illuminate\Http\RedirectResponse + */ + public function linkTicket(LinkTicket $request, Ticket $ticket) + { + $linkedTicket = Ticket::findOrFail($request->validated())->first(); + + if ($ticket->site_id !== $linkedTicket->site_id) { + return back()->with('error', trans('Le ticket que vous avez renseigné ne fait pas partie du même site.')); + } + + if (!$ticket->linkedTicket()->where('linked_ticket_id', $linkedTicket->id)->exists()) { + $ticket->linkedTicket()->attach($linkedTicket->id); + $linkedTicket->linkedTicket()->attach($ticket->id); + return back()->with('success', trans('Les tickets ont été liés avec succès.')); + } + + return back()->with('error', trans('Les tickets sont déjà liés ensemble.')); + } + + /** + * Unlink two tickets. + * + * @param Ticket $ticket + * @param Ticket $linkedTicket + * + * @return \Illuminate\Http\RedirectResponse + */ + public function unlinkTicket(Ticket $ticket, Ticket $linkedTicket) + { + $ticket->linkedTicket()->detach($linkedTicket->id); + $linkedTicket->linkedTicket()->detach($ticket->id); + + return back()->with('warning', trans('Le lien entre les tickets à été supprimé.')); + } + // * PRIVATES /** @@ -504,6 +562,7 @@ class TicketController extends Controller Session::remove('tickets.ty'); Session::remove('tickets.sort_col'); Session::remove('tickets.sort_way'); + Session::remove('tickets.or'); Session::remove('tickets.search'); } if ($request->assr) { @@ -524,6 +583,9 @@ class TicketController extends Controller if ($request->sort_way) { Session::put('tickets.sort_way', $request->sort_way); } + if ($request->ord) { + Session::remove('tickets.or'); + } if ($request->pr) { Session::put('tickets.pr', $request->pr); } @@ -536,6 +598,19 @@ class TicketController extends Controller if ($request->ass) { Session::put('tickets.ass', $request->ass); } + if (Session::has('tickets.or')) { + Session::remove('tickets.ass'); + Session::remove('tickets.st'); + Session::remove('tickets.ty'); + Session::remove('tickets.sort_col'); + Session::remove('tickets.sort_way'); + Session::remove('tickets.search'); + } + + if ($request->or && Session::has('tickets.pr')) { + Session::put('tickets.or', $request->or); + } + Session::save(); if (Session::has('tickets.pr')) { @@ -556,18 +631,20 @@ class TicketController extends Controller $tickets->where('type', Session::get('tickets.ty')); } + if (Session::has('tickets.or')) { + $tickets->orderBy('order', 'ASC'); + } if ( Session::has('tickets.sort_col') and Session::has('tickets.sort_way') and in_array(Session::get('tickets.sort_col'), [ - 'id', - 'site_id', - 'created_at', - 'created_by', 'type', - 'status', - 'assigned_to' + 'title', + 'assigned_to', + 'date_mep', + 'created_at', + 'created_by' ]) ) { $tickets->orderBy( @@ -577,6 +654,7 @@ class TicketController extends Controller } else { $tickets->orderBy('last_activity', 'DESC'); } + return $tickets; } @@ -671,7 +749,13 @@ class TicketController extends Controller $description = \sprintf("%s
", $ticket->text); $cLabel = match ($ticket->type) { TicketTypeEnum::bug => 'c-bug', - TicketTypeEnum::evolution => 'c-feature', + TicketTypeEnum::evolution, TicketTypeEnum::newsletter => 'c-feature', + }; + + $assigneeId = match ($ticket->type) { + TicketTypeEnum::bug => GitlabUsersEnum::default->value, + TicketTypeEnum::evolution, + TicketTypeEnum::newsletter => $ticket->site->projectManager?->gitlab_id ?? GitlabUsersEnum::default->value }; try { @@ -683,13 +767,17 @@ class TicketController extends Controller } $issue = GitLab::issues()->create($gitlabRepoId, [ - 'title' => 'ts-' . $ticket->id, + 'title' => sprintf( + 'ts-%s : %s', + $ticket->id, + $ticket->title + ), 'description' => $description, 'labels' => \implode(",", [ 'c-support', $cLabel ]), - 'assignee_id' => GitlabUsersEnum::nicolas, + 'assignee_id' => $assigneeId, ]); } catch (\Exception $e) { \report($e); @@ -733,4 +821,62 @@ class TicketController extends Controller } return \sprintf("

Fichier %d :
%s
", $fileNb, $file); } + + /** + * Change order. + * + * @param \App\Http\Requests\Bo\UpdateChangeOrderRequest $request + * @param mixed ...$params + * @return \Illuminate\Http\RedirectResponse + * @throws \RuntimeException Si le nom du parametre de la route ne correspond pas au params utilisé. + */ + public function changeOrder(UpdateChangeOrderRequest $request, mixed ...$params): \Illuminate\Http\RedirectResponse + { + $paramNames = collect(request()->route()->parameterNames); + $className = Str::of($paramNames->get($paramNames->count() - 2))->lower()->studly(); + $className = "\\App\\Models\\{$className}"; + $model = Arr::get($params, $paramNames->count() - 2); + + if (!class_exists($className)) { + throw new \RuntimeException("The {$className} class doesn't exist."); + } + + if (!\is_object($model)) { + throw new \RuntimeException("The second last param isn't an object."); + } + + if (get_class($model) !== (string)Str::of($className)->replaceStart('\\', '')) { + throw new \RuntimeException("The {$className} doesn't match second last binded param."); + } + + /** @var \Illuminate\Database\Eloquent\Model|null */ + $model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first(); + + if (!$model) { + return back()->with('error', trans('crud.messages.order_not_changed')); + } + + return DB::transaction(function () use ($request, $className, $model) { + /** @var \Illuminate\Support\Collection $models */ + $models = $className::query() + ->orderBy('order', 'ASC') + ->where('site_id', $model->site_id) + ->where('status', '!=', TicketStatusEnum::archived) + ->where('id', '!=', $model->getKey()) + ->where('order', $request->direction ? '<' : '>', $model->order) + ->get(); + /** @var \Illuminate\Database\Eloquent\Model|null $tmp */ + $tmp = $request->direction ? $models->last() : $models->first(); + + if (!$tmp) { + return back()->with('error', trans('crud.messages.order_not_changed')); + } + + $newOrder = $tmp->getOriginal('order'); + $tmp->update(['order' => $model->getOriginal('order')]); + $model->update(['order' => $newOrder]); + + return redirect()->back()->with('success', trans('crud.messages.order_changed')); + }); + } } diff --git a/app/Http/Controllers/Controller.php b/app/Http/Controllers/Controller.php index ed2f0d8..5686abc 100644 --- a/app/Http/Controllers/Controller.php +++ b/app/Http/Controllers/Controller.php @@ -223,10 +223,6 @@ class Controller extends BaseController ) { $query = $query->orderBy(\sprintf("$table.%s", request()->sort_col), request()->sort_way); } - } elseif (Schema::hasColumn($table, 'order')) { - $query = $query->orderBy('order', 'ASC'); - Session::put("$rName.sort_col", 'order'); - Session::put("$rName.sort_way", 'asc'); } return $query; } diff --git a/app/Http/Middleware/RedirectIfAuthenticated.php b/app/Http/Middleware/RedirectIfAuthenticated.php index 7b41ae2..7b691f9 100644 --- a/app/Http/Middleware/RedirectIfAuthenticated.php +++ b/app/Http/Middleware/RedirectIfAuthenticated.php @@ -27,7 +27,7 @@ class RedirectIfAuthenticated if (Auth::guard($guard)->check()) { switch ($guard) { case 'backend': - if (!$request->routeIs('bo.*')) { + if (!$request->routeIs('bo.*') && !$request->routeIs('login')) { continue; } return \redirect()->route('bo.dashboard'); diff --git a/app/Http/Requests/Bo/Dutyhours/StoreDutyhourRequest.php b/app/Http/Requests/Bo/Dutyhours/StoreDutyhourRequest.php deleted file mode 100644 index d7751ab..0000000 --- a/app/Http/Requests/Bo/Dutyhours/StoreDutyhourRequest.php +++ /dev/null @@ -1,47 +0,0 @@ - 'required|date|after_or_equal:today', - 'person' => 'required|string|min:3|max:255', - 'place' => 'required|string|min:3|max:255', - ]; - } - - /** - * Get custom attributes for validator errors. - * - * @return array - */ - public function attributes(): array - { - return [ - 'date' => trans('Date de la permanence'), - 'person' => trans('Personne associée à la permanence'), - 'place' => trans('Lieu de la permanence'), - ]; - } -} diff --git a/app/Http/Requests/Bo/Dutyhours/UpdateDutyhourRequest.php b/app/Http/Requests/Bo/Dutyhours/UpdateDutyhourRequest.php deleted file mode 100644 index b82afda..0000000 --- a/app/Http/Requests/Bo/Dutyhours/UpdateDutyhourRequest.php +++ /dev/null @@ -1,7 +0,0 @@ -isAdmin(); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + $ticket = $this->route('ticket'); + return [ + 'linked_ticket_id' => [ + 'required', + 'numeric', + 'exists:tickets,id', + 'not_in:' . $ticket->id, + ] + ]; + } +} diff --git a/app/Http/Requests/Bo/Sites/StoreSiteRequest.php b/app/Http/Requests/Bo/Sites/StoreSiteRequest.php index de7035e..a55bf3c 100644 --- a/app/Http/Requests/Bo/Sites/StoreSiteRequest.php +++ b/app/Http/Requests/Bo/Sites/StoreSiteRequest.php @@ -29,6 +29,7 @@ class StoreSiteRequest extends FormRequest 'users' => 'nullable|array', 'users.*.id' => 'required|exists:users,id', 'gitlab_project_id' => 'nullable|unique:sites,gitlab_project_id', + 'project_manager_id' => 'nullable|exists:users,id', 'url_re7' => 'nullable|url', 'url_prod' => 'nullable|url' ]; @@ -46,6 +47,7 @@ class StoreSiteRequest extends FormRequest 'users' => trans('Utilisateurs associés au site'), 'users.*.id' => trans('Élément parmis les Utilisateurs associés au site'), 'gitlab_project_id' => trans('ID du dépôt Gitlab'), + 'project_manager_id' => trans('Chef de projet'), 'url_re7' => trans('Url de RECETTE'), 'url_prod' => trans('Url de prod') ]; diff --git a/app/Http/Requests/Bo/StoreTicket.php b/app/Http/Requests/Bo/StoreTicket.php index 41a512c..e6fa419 100644 --- a/app/Http/Requests/Bo/StoreTicket.php +++ b/app/Http/Requests/Bo/StoreTicket.php @@ -96,6 +96,7 @@ class StoreTicket extends FormRequest } } ], + 'date_mep' => 'nullable|date', 'text' => 'required|string|min:40', 'title' => 'required|string|between:3,255', 'file_tickets' => 'sometimes|array', diff --git a/app/Http/Requests/Bo/UpdateChangeOrderRequest.php b/app/Http/Requests/Bo/UpdateChangeOrderRequest.php new file mode 100644 index 0000000..d4829c7 --- /dev/null +++ b/app/Http/Requests/Bo/UpdateChangeOrderRequest.php @@ -0,0 +1,43 @@ +check(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation(): void + { + $this->merge([ + 'direction' => $this->route('direction') === 'up' ? true : false + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules(): array + { + return [ + 'direction' => 'required|boolean', + ]; + } + +} diff --git a/app/Http/Requests/Bo/Users/StoreUserRequest.php b/app/Http/Requests/Bo/Users/StoreUserRequest.php index ad54e3d..0faab0e 100644 --- a/app/Http/Requests/Bo/Users/StoreUserRequest.php +++ b/app/Http/Requests/Bo/Users/StoreUserRequest.php @@ -34,7 +34,8 @@ class StoreUserRequest extends FormRequest Rule::in(collect(RoleEnum::cases())->pluck('value')->all()), ], 'sites' => 'nullable|array', - 'sites.*.id' => 'required|exists:sites,id' + 'sites.*.id' => 'required|exists:sites,id', + 'gitlab_id' => 'nullable|integer|unique:users,gitlab_id' ]; } @@ -51,6 +52,7 @@ class StoreUserRequest extends FormRequest 'role' => trans('Rôle de l\'utilisateur'), 'sites' => trans('Sites associés à l\'utilisateur'), 'sites.*.id' => trans('Élément parmis les sites associés à l\'utilisateur'), + 'gitlab_id' => trans("ID de l'utilisateur Gitlab") ]; } } diff --git a/app/Listeners/AddStatusMessages.php b/app/Listeners/AddStatusMessages.php index 84d453b..1edf542 100644 --- a/app/Listeners/AddStatusMessages.php +++ b/app/Listeners/AddStatusMessages.php @@ -22,8 +22,7 @@ class AddStatusMessages $message = new Message(); $message->ticket_id = $event->ticket->id; // * Le message system est privé si demandé (eg: Assignation à une personne). - $message->type = $event->is_private ? - MessageTypeEnum::public : MessageTypeEnum::private; + $message->type = $event->is_private ? MessageTypeEnum::private : MessageTypeEnum::public; if ($event->message) { $message->message = $event->message; } elseif ($event->user) { diff --git a/app/Models/Dutyhour.php b/app/Models/Dutyhour.php deleted file mode 100644 index f615433..0000000 --- a/app/Models/Dutyhour.php +++ /dev/null @@ -1,43 +0,0 @@ - 'date' - ]; -} diff --git a/app/Models/Site.php b/app/Models/Site.php index 770064c..d8aa825 100644 --- a/app/Models/Site.php +++ b/app/Models/Site.php @@ -6,6 +6,7 @@ use App\Lib\Helpers\ToolboxHelper; use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Casts\Attribute; +use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\SoftDeletes; /** @@ -29,7 +30,8 @@ class Site extends Model 'name', 'url_re7', 'url_prod', - 'gitlab_project_id' + 'gitlab_project_id', + 'project_manager_id' ]; /** @@ -109,6 +111,17 @@ class Site extends Model return $this->belongsTo(Brand::class); } + /** + * BelongsTo User relation + * The project manager of the site + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsTo + */ + public function projectManager(): BelongsTo + { + return $this->belongsTo(User::class, 'project_manager_id'); + } + /** * BelongsTo Project relation * diff --git a/app/Models/Ticket.php b/app/Models/Ticket.php index 460ef6d..5eda697 100644 --- a/app/Models/Ticket.php +++ b/app/Models/Ticket.php @@ -32,6 +32,8 @@ class Ticket extends Model 'site_id', 'type', 'status', + 'order', + 'date_mep', 'text', 'title', 'is_internal', @@ -47,6 +49,7 @@ class Ticket extends Model 'is_internal' => 'bool', 'type' => TicketTypeEnum::class, 'status' => TicketStatusEnum::class, + 'date_mep' => 'date', 'last_activity' => 'timestamp', ]; @@ -59,6 +62,7 @@ class Ticket extends Model { static::creating(function (Ticket $ticket) { // If bug force the ticket status on new. All the others are estimateTodo. + self::setOrder($ticket); if ($ticket->type->equals(TicketTypeEnum::bug)) { $ticket->status = TicketStatusEnum::new; } else { @@ -66,7 +70,7 @@ class Ticket extends Model } }); static::updating(function (Ticket $ticket) { - if (!$ticket->original['status'] !== $ticket->status->value) { + if (!$ticket->original['status'] !== $ticket->status->value && $ticket->original['order'] === $ticket->order) { event(new TicketStatusChanged( $ticket, TicketStatusEnum::make($ticket->original['status']), @@ -85,9 +89,25 @@ class Ticket extends Model $ticket->status->label() ))); } + if ($ticket->status->equals(TicketStatusEnum::archived)) { + self::setOrder($ticket, true); + } }); } + /** + * Set order after the last element of the list. + * + * @param self $model + * @param boolean $isArchived + * @return void + */ + private static function setOrder(self $model, bool $isArchived = false): void + { + $model->order = \intval(self::query()->where('status', $isArchived ? '=' : '!=', TicketStatusEnum::archived)->max('order')) + 1; + } + + // * RELATIONSHIPS /** @@ -173,6 +193,16 @@ class Ticket extends Model return $this->belongsTo(TicketType::class, 'type', 'type'); } + /** + * BelongsToMany Linked Ticket + * + * @return \Illuminate\Database\Eloquent\Relations\BelongsToMany + */ + public function linkedTickets() + { + return $this->belongsToMany(Ticket::class, 'linked_tickets', 'ticket_id', 'linked_ticket_id'); + } + // * METHODS /** diff --git a/app/Models/User.php b/app/Models/User.php index 7967f02..4b1a499 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -45,7 +45,8 @@ class User extends Authenticatable 'email', 'password', 'role', - 'sites' + 'sites', + 'gitlab_id' ]; /** @@ -148,8 +149,8 @@ class User extends Authenticatable */ public static function adminUsers(): Collection { - return Cache::rememberForever('AdminUsers', function () { - return self::whereIn('role', [RoleEnum::admin, RoleEnum::developper])->get(); + return Cache::remember('AdminUsers', 86400, function () { + return self::whereIn('role', [RoleEnum::admin, RoleEnum::developper])->orderBy('name')->get(); }); } diff --git a/app/Policies/TicketPolicy.php b/app/Policies/TicketPolicy.php index bcb8074..506d58f 100644 --- a/app/Policies/TicketPolicy.php +++ b/app/Policies/TicketPolicy.php @@ -7,6 +7,7 @@ use App\Enums\Tickets\TicketTypeEnum; use App\Enums\Users\RoleEnum; use App\Models\Ticket; use App\Models\User; +use Error; use Illuminate\Auth\Access\HandlesAuthorization; class TicketPolicy @@ -67,6 +68,17 @@ class TicketPolicy return $user->isAdmin(); } + /** + * Determine if the user can link ticket . + * + * @param \App\Models\User $user + * @return boolean + */ + public function linkTicket(User $user) + { + return $user->isAdmin(); + } + /** * Determine if the user can change the internal status of a given ticket. * @@ -272,8 +284,21 @@ class TicketPolicy public function createGitlabIssue(User $user, Ticket $ticket) { return $user->role->equals(RoleEnum::developper) - && ($ticket->type->equals(TicketTypeEnum::bug) || $ticket->type->equals(TicketTypeEnum::evolution)) + && ($ticket->type->equals(TicketTypeEnum::bug) || $ticket->type->equals(TicketTypeEnum::evolution) || $ticket->type->equals(TicketTypeEnum::newsletter)) && !\is_null($ticket->site->gitlab_project_id) && \is_null($ticket->gitlab_issue); } + + /** + * Determine if the user can changeOrder + * + * @param User $user + * @return bool + * @throws Error + */ + public function changeOrder(User $user) + { + return $user->role->equals(RoleEnum::developper); + } + } diff --git a/app/Providers/RouteServiceProvider.php b/app/Providers/RouteServiceProvider.php index f89694d..56b3a6d 100644 --- a/app/Providers/RouteServiceProvider.php +++ b/app/Providers/RouteServiceProvider.php @@ -6,7 +6,6 @@ use App\Models\Brand; use App\Models\Company; use App\Models\Credit\Account; use App\Models\Credit\CreditLog; -use App\Models\Dutyhour; use App\Models\Information; use App\Models\Invoice; use App\Models\Label; @@ -91,7 +90,6 @@ class RouteServiceProvider extends ServiceProvider Route::model('label', Label::class); Route::model('marker', Marker::class); Route::model('package', Package::class); - Route::model('dutyhour', Dutyhour::class); Route::model('information', Information::class); Route::model('company', Company::class); Route::model('invoice', Invoice::class); diff --git a/app/Providers/TranslationServiceProvider.php b/app/Providers/TranslationServiceProvider.php index a042a23..7aa3b60 100644 --- a/app/Providers/TranslationServiceProvider.php +++ b/app/Providers/TranslationServiceProvider.php @@ -19,7 +19,7 @@ class TranslationServiceProvider extends ServiceProvider { foreach ($this->collectLocalesStrings() as $locale) { // * Supported locales - Cache::rememberForever(sprintf('translations.%s', $locale), function () use ($locale) { + Cache::remember(sprintf('translations.%s', $locale), 84600, function () use ($locale) { $translations = [ 'php' => $this->phpTranslations($locale), 'json' => $this->jsonTranslations($locale), diff --git a/app/Traits/Controllers/ChangesModelOrder.php b/app/Traits/Controllers/ChangesModelOrder.php new file mode 100644 index 0000000..f504823 --- /dev/null +++ b/app/Traits/Controllers/ChangesModelOrder.php @@ -0,0 +1,64 @@ +route()->parameterNames); + $className = Str::of($paramNames->get($paramNames->count() - 2))->lower()->studly(); + $className = "\\App\\Models\\{$className}"; + $model = Arr::get($params, $paramNames->count() - 2); + + if (!class_exists($className)) { + throw new \RuntimeException("The {$className} class doesn't exist."); + } + + if (!\is_object($model)) { + throw new \RuntimeException("The second last param isn't an object."); + } + + if (get_class($model) !== (string)Str::of($className)->replaceStart('\\', '')) { + throw new \RuntimeException("The {$className} doesn't match second last binded param."); + } + + /** @var \Illuminate\Database\Eloquent\Model|null */ + $model = $className::query()->where($model->getRouteKeyName(), $model->getRouteKey())->first(); + + if (!$model) { + return back()->with('error', trans('crud.messages.order_not_changed')); + } + + return DB::transaction(function () use ($request, $className, $model) { + /** @var \Illuminate\Database\Eloquent\Model|null */ + $tmp = $className::query() + ->where('order', $request->direction ? '<' : '>', $model->getOriginal('order')) + ->orderBy('order', $request->direction ? 'DESC' : 'ASC') + ->first(); + + if (!$tmp) { + return back()->with('error', trans('crud.messages.order_not_changed')); + } + + $newOrder = $tmp->getOriginal('order'); + $tmp->update(['order' => $model->getOriginal('order')]); + $model->update(['order' => $newOrder]); + + return redirect()->back()->with('success', trans('crud.messages.order_changed')); + }); + } +} diff --git a/database/migrations/2025_03_12_102925_change_order_to_tickets.php b/database/migrations/2025_03_12_102925_change_order_to_tickets.php new file mode 100644 index 0000000..3483b0a --- /dev/null +++ b/database/migrations/2025_03_12_102925_change_order_to_tickets.php @@ -0,0 +1,40 @@ +integer('order')->after('status')->comment('Ticket order.'); + }); + + Site::query()->get()->map(function ($site) { + $site->tickets->map(function ($ticket, $ticketIndex) { + $ticket->order = $ticketIndex + 1; + $ticket->saveQuietly(); + }); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('tickets', function (Blueprint $table) { + $table->dropColumn('order'); + }); + } +}; diff --git a/database/migrations/2025_03_13_094420_add_mep_date_on_tickets.php b/database/migrations/2025_03_13_094420_add_mep_date_on_tickets.php new file mode 100644 index 0000000..deb9c5b --- /dev/null +++ b/database/migrations/2025_03_13_094420_add_mep_date_on_tickets.php @@ -0,0 +1,32 @@ +date('date_mep')->nullable()->after('gitlab_issue')->comment('Date MEP souhaitée'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('tickets', function (Blueprint $table) { + $table->dropColumn('date_mep'); + }); + } +}; diff --git a/database/migrations/2025_03_13_151503_tickets_linking.php b/database/migrations/2025_03_13_151503_tickets_linking.php new file mode 100644 index 0000000..801bbb3 --- /dev/null +++ b/database/migrations/2025_03_13_151503_tickets_linking.php @@ -0,0 +1,35 @@ +unsignedBigInteger('ticket_id') + ->constrained()->cascadeOnDelete(); + $table->unsignedBigInteger('linked_ticket_id') + ->constrained()->cascadeOnDelete(); + $table->foreign('ticket_id')->references('id')->on('tickets'); + $table->foreign('linked_ticket_id')->references('id')->on('tickets'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::dropIfExists('linked_tickets'); + } +}; diff --git a/database/migrations/2025_04_11_183728_delete_dutyhours_table.php b/database/migrations/2025_04_11_183728_delete_dutyhours_table.php new file mode 100644 index 0000000..77d5818 --- /dev/null +++ b/database/migrations/2025_04_11_183728_delete_dutyhours_table.php @@ -0,0 +1,30 @@ +id(); + $table->date('date')->unique(); + $table->string('person'); + $table->string('place'); + $table->timestamps(); + }); + } +}; diff --git a/database/migrations/2025_04_17_112713_add_users_relation_on_sites_table.php b/database/migrations/2025_04_17_112713_add_users_relation_on_sites_table.php new file mode 100644 index 0000000..3712c0d --- /dev/null +++ b/database/migrations/2025_04_17_112713_add_users_relation_on_sites_table.php @@ -0,0 +1,38 @@ +unsignedBigInteger('project_manager_id') + ->nullable() + ->after('brand_id') + ->comment('Project manager relationship'); + + $table->foreign('project_manager_id')->references('id')->on('users')->nullOnDelete(); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('sites', function (Blueprint $table) { + $table->dropForeign(['project_manager_id']); + $table->dropColumn('project_manager_id'); + }); + } +}; diff --git a/database/migrations/2025_04_17_162711_add_gitlab_id_to_users_table.php b/database/migrations/2025_04_17_162711_add_gitlab_id_to_users_table.php new file mode 100644 index 0000000..f096889 --- /dev/null +++ b/database/migrations/2025_04_17_162711_add_gitlab_id_to_users_table.php @@ -0,0 +1,36 @@ +unsignedInteger('gitlab_id') + ->unique() + ->nullable() + ->comment("ID du user Gitlab") + ->after('remember_token'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down(): void + { + Schema::table('users', function (Blueprint $table) { + $table->dropColumn('gitlab_id'); + }); + } +}; diff --git a/manifest.yaml b/manifest.yaml index 7ee5e01..20845ca 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -10,7 +10,8 @@ data: APP_DEBUG: "${APP_APP_DEBUG}" APP_URL: "https://${APP_DOMAIN}" LOG_CHANNEL: "k8s" - DB_HOST: "mariadb.common-services" + DB_HOST: "${APP_DB_HOST}" + DB_PORT: "${APP_DB_PORT}" DB_DATABASE: "${APP_DB_DATABASE}" DB_USERNAME: "${APP_DB_USERNAME}" DB_PASSWORD: "${APP_DB_PASSWORD}" diff --git a/resources/lang/en.json b/resources/lang/en.json index d208ff2..714172c 100644 --- a/resources/lang/en.json +++ b/resources/lang/en.json @@ -50,5 +50,6 @@ "Verify Your Email Address": "Verify Your Email Address", "Whoops!": "Whoops!", "You are logged in!": "You are logged in!", - "You are receiving this email because we received a password reset request for your account.": "You are receiving this email because we received a password reset request for your account." -} \ No newline at end of file + "You are receiving this email because we received a password reset request for your account.": "You are receiving this email because we received a password reset request for your account.", + "see_mode": "see :mode mode" +} diff --git a/resources/lang/en/models.php b/resources/lang/en/models.php index 425de54..d659268 100644 --- a/resources/lang/en/models.php +++ b/resources/lang/en/models.php @@ -14,7 +14,6 @@ return [ 'packages' => 'Packages', 'invoices' => 'Invoices', 'companies' => 'Companies', - 'dutyhours' => 'Duty Hours', 'informations' => 'Informations', 'ticket_types' => 'Ticket types' ] diff --git a/resources/lang/en/validation.php b/resources/lang/en/validation.php index 2076bd3..add290c 100644 --- a/resources/lang/en/validation.php +++ b/resources/lang/en/validation.php @@ -214,4 +214,13 @@ return [ 'username' => 'username', 'year' => 'year', ], + 'custom' => [ + 'type' => 'type', + 'tickets' => 'tickets', + 'assigned_to' => 'assigned to', + 'order' => 'order', + 'priority' => 'priority', + 'default' => 'default', + 'date_mep' => 'Desired Launch' + ] ]; diff --git a/resources/lang/fr.json b/resources/lang/fr.json index 9c2ad17..b405e2f 100644 --- a/resources/lang/fr.json +++ b/resources/lang/fr.json @@ -55,5 +55,7 @@ "Verify Your Email Address": "Vérifiez votre adresse e-mail", "Whoops!": "Oups !", "You are logged in!": "Vous êtes connecté·e !", - "You are receiving this email because we received a password reset request for your account.": "Vous recevez cet e-mail car nous avons reçu une demande de réinitialisation de mot de passe pour votre compte." -} \ No newline at end of file + "You are receiving this email because we received a password reset request for your account.": "Vous recevez cet e-mail car nous avons reçu une demande de réinitialisation de mot de passe pour votre compte.", + "see_mode": "voir mode :mode", + "Website": "Site" +} diff --git a/resources/lang/fr/crud.php b/resources/lang/fr/crud.php index ddb1331..d219d12 100644 --- a/resources/lang/fr/crud.php +++ b/resources/lang/fr/crud.php @@ -89,5 +89,7 @@ return [ 'sort_delete' => 'Supprimer le tri', 'sort_arrow' => 'Ici, les flèches sont utilisées pour trier et non pour filtrer', 'right' => 'Vous n\'avez pas les droits', + 'view_linked_ticket' => 'voir le ticket :model', + 'unlink_ticket' => 'supprimer le lien avec le ticket :model' ] ]; diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index 314efcd..5d7e88b 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -13,7 +13,6 @@ return [ 'packages' => 'Forfaits', 'invoices' => 'Devis', 'companies' => 'Sociétés', - 'dutyhours' => 'Permanences', 'informations' => 'Informations', 'ticket_types' => 'Type de ticket|Types de tickets' ] diff --git a/resources/lang/fr/validation-inline.php b/resources/lang/fr/validation-inline.php deleted file mode 100644 index a06110a..0000000 --- a/resources/lang/fr/validation-inline.php +++ /dev/null @@ -1,131 +0,0 @@ - 'Ce champ doit être accepté.', - 'active_url' => 'Ce n\'est pas une URL valide', - 'after' => 'La date doit être postérieure au :date.', - 'after_or_equal' => 'La date doit être postérieure ou égale au :date.', - 'alpha' => 'Ce champ doit contenir uniquement des lettres', - 'alpha_dash' => 'Ce champ doit contenir uniquement des lettres, des chiffres et des tirets.', - 'alpha_num' => 'Ce champ doit contenir uniquement des chiffres et des lettres.', - 'array' => 'Ce champ doit être un tableau.', - 'attached' => 'Ce champ est déjà attaché.', - 'before' => 'Ce champ doit être une date antérieure au :date.', - 'before_or_equal' => 'Ce champ doit être une date antérieure ou égale au :date.', - 'between' => [ - 'array' => 'Le tableau doit contenir entre :min et :max éléments.', - 'file' => 'La taille du fichier doit être comprise entre :min et :max kilo-octets.', - 'numeric' => 'La valeur doit être comprise entre :min et :max.', - 'string' => 'Le texte doit contenir entre :min et :max caractères.', - ], - 'boolean' => 'Ce champ doit être vrai ou faux.', - 'confirmed' => 'Le champ de confirmation ne correspond pas.', - 'date' => 'Ce n\'est pas une date valide.', - 'date_equals' => 'La date doit être égale à :date.', - 'date_format' => 'Ce champ ne correspond pas au format :format.', - 'different' => 'Cette valeur doit être différente de :other.', - 'digits' => 'Ce champ doit contenir :digits chiffres.', - 'digits_between' => 'Ce champ doit contenir entre :min et :max chiffres.', - 'dimensions' => 'La taille de l\'image n\'est pas conforme.', - 'distinct' => 'Ce champ a une valeur en double.', - 'email' => 'Ce champ doit être une adresse email valide.', - 'ends_with' => 'Ce champ doit se terminer par une des valeurs suivantes : :values', - 'exists' => 'Ce champ sélectionné est invalide.', - 'file' => 'Ce champ doit être un fichier.', - 'filled' => 'Ce champ doit avoir une valeur.', - 'gt' => [ - 'array' => 'Le tableau doit contenir plus de :value éléments.', - 'file' => 'La taille du fichier doit être supérieure à :value kilo-octets.', - 'numeric' => 'La valeur doit être supérieure à :value.', - 'string' => 'Le texte doit contenir plus de :value caractères.', - ], - 'gte' => [ - 'array' => 'Le tableau doit contenir au moins :value éléments.', - 'file' => 'La taille du fichier doit être supérieure ou égale à :value kilo-octets.', - 'numeric' => 'La valeur doit être supérieure ou égale à :value.', - 'string' => 'Le texte doit contenir au moins :value caractères.', - ], - 'image' => 'Ce champ doit être une image.', - 'in' => 'Ce champ est invalide.', - 'in_array' => 'Ce champ n\'existe pas dans :other.', - 'integer' => 'Ce champ doit être un entier.', - 'ip' => 'Ce champ doit être une adresse IP valide.', - 'ipv4' => 'Ce champ doit être une adresse IPv4 valide.', - 'ipv6' => 'Ce champ doit être une adresse IPv6 valide.', - 'json' => 'Ce champ doit être un document JSON valide.', - 'lt' => [ - 'array' => 'Le tableau doit contenir moins de :value éléments.', - 'file' => 'La taille du fichier doit être inférieure à :value kilo-octets.', - 'numeric' => 'La valeur doit être inférieure à :value.', - 'string' => 'Le texte doit contenir moins de :value caractères.', - ], - 'lte' => [ - 'array' => 'Le tableau doit contenir au plus :value éléments.', - 'file' => 'La taille du fichier doit être inférieure ou égale à :value kilo-octets.', - 'numeric' => 'La valeur doit être inférieure ou égale à :value.', - 'string' => 'Le texte doit contenir au plus :value caractères.', - ], - 'max' => [ - 'array' => 'Le tableau ne peut contenir plus de :max éléments.', - 'file' => 'La taille du fichier ne peut pas dépasser :max kilo-octets.', - 'numeric' => 'La valeur ne peut être supérieure à :max.', - 'string' => 'Le texte ne peut contenir plus de :max caractères.', - ], - 'mimes' => 'Le fichier doit être de type : :values.', - 'mimetypes' => 'Le fichier doit être de type : :values.', - 'min' => [ - 'array' => 'Le tableau doit contenir au moins :min éléments.', - 'file' => 'La taille du fichier doit être supérieure à :min kilo-octets.', - 'numeric' => 'La valeur doit être supérieure ou égale à :min.', - 'string' => 'Le texte doit contenir au moins :min caractères.', - ], - 'multiple_of' => 'La valeur doit être un multiple de :value', - 'not_in' => 'Le champ sélectionné n\'est pas valide.', - 'not_regex' => 'Le format du champ n\'est pas valide.', - 'numeric' => 'Ce champ doit contenir un nombre.', - 'password' => 'Le mot de passe est incorrect', - 'present' => 'Ce champ doit être présent.', - 'prohibited' => 'Ce champ est interdit', - 'prohibited_if' => 'Ce champ est interdit quand :other a la valeur :value.', - 'prohibited_unless' => 'Ce champ est interdit à moins que :other ait l\'une des valeurs :values.', - 'regex' => 'Le format du champ est invalide.', - 'relatable' => 'Ce champ n\'est sans doute pas associé avec cette donnée.', - 'required' => 'Ce champ est obligatoire.', - 'required_if' => 'Ce champ est obligatoire quand la valeur de :other est :value.', - 'required_unless' => 'Ce champ est obligatoire sauf si :other est :values.', - 'required_with' => 'Ce champ est obligatoire quand :values est présent.', - 'required_with_all' => 'Ce champ est obligatoire quand :values sont présents.', - 'required_without' => 'Ce champ est obligatoire quand :values n\'est pas présent.', - 'required_without_all' => 'Ce champ est requis quand aucun de :values n\'est présent.', - 'same' => 'Ce champ doit être identique à :other.', - 'size' => [ - 'array' => 'Le tableau doit contenir :size éléments.', - 'file' => 'La taille du fichier doit être de :size kilo-octets.', - 'numeric' => 'La valeur doit être :size.', - 'string' => 'Le texte doit contenir :size caractères.', - ], - 'starts_with' => 'Ce champ doit commencer avec une des valeurs suivantes : :values', - 'string' => 'Ce champ doit être une chaîne de caractères.', - 'timezone' => 'Ce champ doit être un fuseau horaire valide.', - 'unique' => 'La valeur est déjà utilisée.', - 'uploaded' => 'Le fichier n\'a pu être téléversé.', - 'url' => 'Le format de l\'URL n\'est pas valide.', - 'uuid' => 'Ce champ doit être un UUID valide', - 'custom' => [ - 'attribute-name' => [ - 'rule-name' => 'custom-message', - ], - ], - 'attributes' => [], -]; diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index 21876b4..571fd1f 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -248,5 +248,15 @@ return [ 'url_re7' => 'Url de RECETTE', 'username' => 'nom d\'utilisateur', 'year' => 'année', + 'id' => 'identifiant' ], + 'custom' => [ + 'type' => 'type', + 'tickets' => 'étiquettes', + 'assigned_to' => 'assigné à', + 'order' => 'ordre', + 'priority' => 'priorité', + 'default' => 'défaut', + 'date_mep' => 'MEP souhaitée' + ] ]; diff --git a/resources/sass/bo/base/_common.scss b/resources/sass/bo/base/_common.scss index 5070921..9044e4f 100644 --- a/resources/sass/bo/base/_common.scss +++ b/resources/sass/bo/base/_common.scss @@ -1,5 +1,5 @@ .container-xxl { - max-width: 1340px !important; + max-width: 1600px !important; } #app { diff --git a/resources/ts/bo/utilities/fontawesome.ts b/resources/ts/bo/utilities/fontawesome.ts index 836339f..f3568c8 100644 --- a/resources/ts/bo/utilities/fontawesome.ts +++ b/resources/ts/bo/utilities/fontawesome.ts @@ -33,6 +33,7 @@ import { faDeleteLeft, faDiagramProject, faDownload, + faEquals, faEraser, faEye, faEyeSlash, @@ -60,10 +61,12 @@ import { faTicket, faTimes, faTrash, + faTriangleExclamation, faUndoAlt, faUsers, faWandMagic, - faXmark + faXmark, + faLinkSlash } from "@fortawesome/free-solid-svg-icons"; config.autoReplaceSvg = false; @@ -124,6 +127,7 @@ library.add(faCircleExclamation); library.add(faCircleInfo); library.add(faPaintRoller); library.add(faTicket); +library.add(faLinkSlash); // Front library.add(faChevronLeft); @@ -137,4 +141,6 @@ library.add(faCopy); library.add(faClipboard); library.add(faXmark); library.add(faArrowRightFromBracket); +library.add(faTriangleExclamation); +library.add(faEquals); dom.watch(); diff --git a/resources/views/bo/modules/change-model-order.blade.php b/resources/views/bo/modules/change-model-order.blade.php new file mode 100644 index 0000000..d5760bd --- /dev/null +++ b/resources/views/bo/modules/change-model-order.blade.php @@ -0,0 +1,40 @@ + + {{ $value ?? '' }} + @can('changeOrder', $model) +
+
$loop->first and $models->onFirstPage()]) + action="{{ route('bo.' . $routeName . '.change-order', [str($routeName)->singular()->value => $model, 'direction' => 'up']) }}" + method="POST"> + @csrf + @method('PATCH') + +
+
+ $loop->last and $models->currentPage() === $models->lastPage(), + ]) + action="{{ route('bo.' . $routeName . '.change-order', [str($routeName)->singular()->value => $model, 'direction' => 'down']) }}" + method="POST"> + @csrf + @method('PATCH') + +
+
+ @elseif(isset($noRightsVisible) && $noRightsVisible) + + + + @endcan + + diff --git a/resources/views/bo/modules/table-col-sorter-cell.blade.php b/resources/views/bo/modules/table-col-sorter-cell.blade.php new file mode 100644 index 0000000..d89d85d --- /dev/null +++ b/resources/views/bo/modules/table-col-sorter-cell.blade.php @@ -0,0 +1,54 @@ +@php + $iArgs = ['sort_col' => $col]; + if (request()->search) { + $iArgs['search'] = request()->search; + } +@endphp +{{-- NO Sort for order column --}} +@if ($col === 'order' or in_array($col, $ignore)) + + isset($mobileHide) and + is_array($mobileHide) and + in_array($col, $mobileHide), + ]) scope="col"> +
+ {{ $colname }} +
+ +@else + + isset($mobileHide) and + is_array($mobileHide) and + in_array($col, $mobileHide), + ]) scope="col"> +
+ + {{ $colname }} + + @if ( + !session("$routeName.sort_way") or + session("$routeName.sort_col") !== $col or + session("$routeName.sort_way") === 'desc' and session("$routeName.sort_col") === $col) + + + + @endif + @if ( + !session("$routeName.sort_way") or + session("$routeName.sort_col") !== $col or + session("$routeName.sort_way") === 'asc' and session("$routeName.sort_col") === $col) + + + + @endif +
+ +@endif diff --git a/resources/views/bo/modules/table-col-sorter.blade.php b/resources/views/bo/modules/table-col-sorter.blade.php index 6bae966..010e589 100644 --- a/resources/views/bo/modules/table-col-sorter.blade.php +++ b/resources/views/bo/modules/table-col-sorter.blade.php @@ -1,73 +1,31 @@ @php -$route = request()->route(); -$routeName = $route->getName(); -$rst = !is_null(request()->rst) || !Session::has("$routeName.sorted"); -$noOrder = !empty($noOrder); -$noOrder = $noOrder || (Session::get("$routeName.sort_col") !== 'order' and (Session::has("$routeName.sort_col") or Session::has("$routeName.sort_way"))); -$noOrder = $noOrder || !empty(request()->search); -$ignore = (isset($ignore) and is_array($ignore)) ? $ignore : []; + $route = request()->route(); + $routeName = $route->getName(); + $rst = !is_null(request()->rst) || !session()->has("$routeName.sorted"); + $noOrder = !empty($noOrder); + $noOrder = + $noOrder || + (session()->get("$routeName.sort_col") !== 'order' and + (session()->has("$routeName.sort_col") or session()->has("$routeName.sort_way"))); + $noOrder = $noOrder || !empty(request()->search); + $ignore = (isset($ignore) and is_array($ignore)) ? $ignore : []; @endphp - - @foreach($cols as $col => $colname) - @php - $iArgs = ['sort_col' => $col]; - if(request()->search) { - $iArgs['search'] = request()->search; - } - @endphp - {{-- NO Sort for order column --}} - @if($col === 'order' or in_array($col, $ignore)) - @if($noOrder and !in_array($col, $ignore)) @continue @endif - -
- {{ $colname }} -
- - @continue - @endif - -
- - {{ $colname }} - - @if(!session("$routeName.sort_way") or session("$routeName.sort_col") !== $col or (session("$routeName.sort_way") === 'desc' and session("$routeName.sort_col") === $col)) - - - - @endif - @if(!session("$routeName.sort_way") or session("$routeName.sort_col") !== $col or (session("$routeName.sort_way") === 'asc' and session("$routeName.sort_col") === $col)) - - - - @endif -
- + + @foreach ($cols as $col => $colname) + @include('bo.modules.table-col-sorter-cell') @endforeach {{-- Buttons Col --}} - - @if(!$rst) - - - + + @if (!$rst) + + + @else - - - + + + @endif diff --git a/resources/views/bo/pages/dutyhours/create.blade.php b/resources/views/bo/pages/dutyhours/create.blade.php deleted file mode 100644 index 0931033..0000000 --- a/resources/views/bo/pages/dutyhours/create.blade.php +++ /dev/null @@ -1,46 +0,0 @@ -@extends('layout.app', ['brParam' => $dutyhourModel]) - -@section('title', __('Création d\'une :model', ['model' => Str::singular(__('models.classes.dutyhours'))])) -@section('description', __('Création d\'une toute nouvelle :model', ['model' => Str::singular(__('models.classes.dutyhours'))])) -@section('breadcrumb', request()->route()->getName()) - -@section('content') -
-
- - - - @include('breadcrumbs.breadcrumb-body', ['brParam' => $dutyhourModel]) -
-
- -
-
-
- @csrf - @include('bo.pages.dutyhours.form-inputs') -
-
- -
-
-
-@endsection diff --git a/resources/views/bo/pages/dutyhours/edit.blade.php b/resources/views/bo/pages/dutyhours/edit.blade.php deleted file mode 100644 index 665f253..0000000 --- a/resources/views/bo/pages/dutyhours/edit.blade.php +++ /dev/null @@ -1,62 +0,0 @@ -@extends('layout.app', ['brParam' => $dutyhourModel]) - -@section('title', __('Édition d\'une :model', ['model' => Str::singular(__('models.classes.dutyhours'))])) -@section('description', __('Édition d\'une :model déjà existante', ['model' => Str::singular(__('models.classes.dutyhours'))])) -@section('breadcrumb', request()->route()->getName()) - -@section('content') -
-
- - - - @include('breadcrumbs.breadcrumb-body', ['brParam' => $dutyhourModel]) -
-
-
- @csrf - @method('DELETE') -
- - -
-
-
-
-
- @csrf - @method('PUT') - @include('bo.pages.dutyhours.form-inputs') -
-
- -
-
-
-@endsection diff --git a/resources/views/bo/pages/dutyhours/form-inputs.blade.php b/resources/views/bo/pages/dutyhours/form-inputs.blade.php deleted file mode 100644 index 1eff637..0000000 --- a/resources/views/bo/pages/dutyhours/form-inputs.blade.php +++ /dev/null @@ -1,98 +0,0 @@ -
- {{-- DATE --}} -
-
- {{ Str::ucfirst(__('validation.attributes.date')) }} -
-
- @include('bo.partials.inputs.date', [ - 'id' => 'dutyhourDate', - 'label' => __(':field de la :model', [ - 'field' => Str::ucfirst(__('validation.attributes.date')), - 'model' => Str::singular(__('models.classes.dutyhours')), - ]), - 'name' => 'date', - 'defaultValue' => true, - 'required' => true, - 'model' => $dutyhourModel ?? null, - 'helper' => __('La date doit être supérieure ou égale à aujourd\'hui.'), - ]) -
-
-
-
- {{-- PERSON --}} -
-
- {{ Str::ucfirst(__('validation.attributes.person')) }} -
-
- @include('bo.partials.inputs.varchar', [ - 'id' => 'dutyhourPerson', - 'label' => __('Nom de la personne présente lors de la :model', [ - 'model' => Str::singular(__('models.classes.dutyhours')), - ]), - 'hasWordCounter' => true, - 'name' => 'person', - 'required' => true, - 'model' => $dutyhourModel ?? null, - 'helper' => __('validation.between.string', [ - 'attribute' => __('Nom de la personne présente lors de la :model', [ - 'model' => Str::singular(__('models.classes.dutyhours')), - ]), - 'min' => 3, - 'max' => 255, - ]), - 'placeholder' => __(':field de la personne', [ - 'field' => Str::ucfirst(__('validation.attributes.name')), - ]), - ]) -
-
-
-
- {{-- PLACE --}} -
-
- {{ Str::ucfirst(__('validation.attributes.place')) }} -
-
- @include('bo.partials.inputs.varchar', [ - 'id' => 'dutyhourPlace', - 'label' => __('Endroit où se déroule la :model', [ - 'model' => Str::singular(__('models.classes.dutyhours')), - ]), - 'hasWordCounter' => true, - 'name' => 'place', - 'required' => true, - 'model' => $dutyhourModel ?? null, - 'helper' => __('validation.between.string', [ - 'attribute' => __('endroit où se déroule la :model', [ - 'model' => Str::singular(__('models.classes.dutyhours')), - ]), - 'min' => 3, - 'max' => 255, - ]), - 'placeholder' => __('Lieu de la :model', [ - 'model' => Str::singular(__('models.classes.dutyhours')), - ]), - ]) -
-
-
-
-
- -@push('scripts') - -@endpush diff --git a/resources/views/bo/pages/dutyhours/index.blade.php b/resources/views/bo/pages/dutyhours/index.blade.php deleted file mode 100644 index fce6170..0000000 --- a/resources/views/bo/pages/dutyhours/index.blade.php +++ /dev/null @@ -1,68 +0,0 @@ -@extends('layout.app') - -@section('title', __('models.classes.dutyhours')) -@section('description', __('Liste de toutes les :model', ['model' => __('models.classes.dutyhours')])) - -@section('content') -
- @include('breadcrumbs.breadcrumb-body') - - - -
-@include('bo.modules.search-bar') - - @if (count($dutyhourModels) > 0) - - @include('bo.modules.table-col-sorter', [ - 'cols' => [ - 'date' => Str::ucfirst(__('validation.attributes.date')), - 'person' => Str::ucfirst(__('validation.attributes.person')), - 'place' => Str::ucfirst(__('validation.attributes.place')), - ], - ]) - - - @foreach ($dutyhourModels as $dutyhourModel) - - - - - - - @endforeach - - @else - - - - @endif -
{{ $dutyhourModel->date->format('Y-m-d') }}{{ $dutyhourModel->person }}{{ $dutyhourModel->place }} -
- - - - @csrf - @method('DELETE') - -
-
{{ __('crud.other.no_model_found', ['model' => Str::singular(__('models.classes.dutyhours'))]) }}
-{!! $dutyhourModels->links() !!} -@endsection diff --git a/resources/views/bo/pages/sites/form-inputs.blade.php b/resources/views/bo/pages/sites/form-inputs.blade.php index 53a650f..c3b27fb 100644 --- a/resources/views/bo/pages/sites/form-inputs.blade.php +++ b/resources/views/bo/pages/sites/form-inputs.blade.php @@ -59,12 +59,14 @@ + +
{{-- GITLAB_PROJECT_ID --}}
{{ Str::ucfirst(__('validation.attributes.gitlab_project_id')) }}
-
+
@include('bo.partials.inputs.int-number', [ 'id' => 'siteGitlabProject', 'label' => __(':field du :model', [ @@ -86,6 +88,30 @@
+ {{-- PROJECT MANAGER --}} +
+
+ {{ __('Chef de projet') }} +
+
+ + +
+
+
+
+
+
{{-- SITE URLS --}}
diff --git a/resources/views/bo/pages/sites/index.blade.php b/resources/views/bo/pages/sites/index.blade.php index a187e11..8d7d3cd 100644 --- a/resources/views/bo/pages/sites/index.blade.php +++ b/resources/views/bo/pages/sites/index.blade.php @@ -25,6 +25,7 @@ 'name' => Str::ucfirst(__('validation.attributes.name')), 'url_re7' => Str::ucfirst(__('validation.attributes.url_re7')), 'url_prod' => Str::ucfirst(__('validation.attributes.url_prod')), + 'project_manager_id' => __("Chef de projet"), ], ]) @@ -46,6 +47,13 @@ - @endif + + @if ($siteModel->project_manager_id) + {{ $siteModel->projectManager->name }} + @else + - + @endif + @can('isAdmin')
+ + {{ __("Chef de projet") }} + + @if ($siteModel->project_manager_id) + {{ $siteModel->projectManager->name }} + @else + - + @endif + + {{ Str::ucfirst(__('validation.attributes.created_at')) }} {{ $siteModel->created_at }} diff --git a/resources/views/bo/pages/tickets/form-inputs.blade.php b/resources/views/bo/pages/tickets/form-inputs.blade.php index cbdeea1..4391a58 100644 --- a/resources/views/bo/pages/tickets/form-inputs.blade.php +++ b/resources/views/bo/pages/tickets/form-inputs.blade.php @@ -93,6 +93,11 @@
@endcan + +
+ + +
diff --git a/resources/views/bo/pages/tickets/index.blade.php b/resources/views/bo/pages/tickets/index.blade.php index b0ce53b..c8c4a40 100644 --- a/resources/views/bo/pages/tickets/index.blade.php +++ b/resources/views/bo/pages/tickets/index.blade.php @@ -9,51 +9,56 @@ $userPr = Auth::user()->sites ?? collect([]); @endphp
+
+
+

{{ __('Tickets') }} + @if (Session::get('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value) + (Archivés) + @endif +

+ @if (session('tickets.pr')) + @php + $projectManager = \App\Models\Site::query()->find(session('tickets.pr'))->projectManager; + @endphp + @if($projectManager) +

{{ __("Chef de projet") }} : {{ $projectManager->name; }}

+ @endif + @endif +
+ +
-

{{ __('Gestion des tickets') }} @if (Session::get('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value) - (Archivés) - @endif -

-
-
-
-
- @can('isAdmin') - - @endcan -   {{ __('ticket') }} - @if (session('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value) - - @else - - @endif -  {{ __(' le tri') }} -
-
+
+
+
+ {{-- All sites --}} +
- + - - @foreach ($status as $statut) - - @endforeach - - @push('scripts') - - @endpush -
-
-
-
-
- @can('assignTickets', App\Models\Ticket::class) + {{-- All types --}}
-
-
- - - @push('scripts') - - @endpush -
-
-
- @endcan -
-
- + @push('scripts') @endpush
-
-
- -
- - - + {{-- All status --}} +
+
+ + + @push('scripts') + + @endpush
- @push('scripts') - - @endpush - +
+ {{-- All assigned to --}} + @can('assignTickets', App\Models\Ticket::class) +
+
+ + + @push('scripts') + + @endpush +
+
+ @endcan + {{-- Search form --}} +
+
+
+ + + +
+ @push('scripts') + + @endpush +
+
+
+
+
+
+
+
+ @if (session('tickets.pr') && session('tickets.st') != \App\Enums\Tickets\TicketStatusEnum::archived->value) + @if (session('tickets.or')) + +   {{ __('see_mode', ['mode' => __('validation.custom.default')]) }} + + @else + +   {{ __('see_mode', ['mode' => __('validation.custom.priority')]) }} + + @endif + @endif + @if (session('tickets.st') == \App\Enums\Tickets\TicketStatusEnum::archived->value) + + + + @else + + + + @endif + +  {{ __(' le tri') }} +
- - - - - - - @can('assignLabels', App\Models\Ticket::class) - - @endcan - @if (Auth::user()->isAdmin()) - - @endif - - - - - - @if (!count($tickets)) - - - - @endif - @foreach ($tickets as $ticket) - - - - - @can('assignLabels', App\Models\Ticket::class) - + + @endforeach + +
- #  - @include('modules.sorter', ['colname' => 'id']) - - {{ __('Titre') }}  - @include('modules.sorter', ['colname' => 'title']) - - {{ __('Type') }}  - @include('modules.sorter', ['colname' => 'type']) - {{ __('Étiquettes') }} - {{ __('Assigné à') }}  - @include('modules.sorter', ['colname' => 'assigned_to']) - - {{ __('Le') }}  - @include('modules.sorter', ['colname' => 'created_at']) -
-

{{ __('Aucun ticket') }}

-
-
- {{ $ticket->id }}  @if ($ticket->is_internal) - - @endif - - - @if (Auth::user()->isAdmin()) - {{ $ticket->site->name }} - @else - {{ $ticket->site->name }} - @endif - {{ $ticket->status->label() }} - -
-
- {{ $ticket->title }} - - {{ $ticket->type->label() }} - - - @foreach ($ticket->labels as $label) - {{ $label->name }} - @endforeach - +
+ + + @php + $cols = []; + if (session('tickets.or')) { + $cols = array_merge($cols, [ + 'order' => Str::ucfirst(__('validation.custom.priority')), + ]); + } + $cols = array_merge($cols, [ + 'id' => '#', + ]); + if (!session()->has('tickets.pr') && !session('tickets.or')) { + $cols = array_merge($cols, [ + 'site' => Str::ucfirst(__('Website')), + ]); + } + $cols = array_merge($cols, [ + 'type' => Str::ucfirst(__('validation.custom.type')), + 'status' => Str::ucfirst(__('validation.attributes.status')), + 'title' => Str::ucfirst(__('validation.attributes.name')), + ]); + if (Auth::user()->isAdmin()) { + $cols = array_merge($cols, [ + 'tickets' => Str::ucfirst(__('validation.custom.tickets')), + 'assigned_to' => Str::ucfirst(__('validation.custom.assigned_to')), + ]); + } + $cols = array_merge($cols, [ + 'date_mep' => Str::ucfirst(__('validation.custom.date_mep')), + 'created_at' => Str::ucfirst(__('validation.attributes.created_at')), + ]); + @endphp + @include('bo.modules.table-col-sorter', [ + 'cols' => $cols, + 'ignore' => session('tickets.or') + ? array_keys($cols) + : ['id', 'site', 'status', 'tickets'], + ]) + + + @if (!count($tickets)) + + - @endcan - @if (Auth::user()->isAdmin()) - - @endif - - + @endif + @foreach ($tickets as $key => $ticket) + + {{-- order --}} + @if (session('tickets.or')) + @include('bo.modules.change-model-order', [ + 'routeName' => 'ticket', + 'model' => $ticket, + 'models' => $tickets, + 'value' => ($key + 1) + (($tickets->currentPage() - 1) * $tickets->perPage()), + 'noRightsVisible' => false, + ]) + @endif + {{-- id --}} + + @if (!session()->has('tickets.pr') && !session('tickets.or')) + {{-- site --}} + + @endif + {{-- type --}} + + {{-- status --}} + + {{-- title --}} + + {{-- tag --}} + @php + $routeName = request()->route()->getName(); + @endphp + @can('assignLabels', App\Models\Ticket::class) + + @endcan + {{-- assigned_to / date_mep --}} + @if (Auth::user()->isAdmin()) + + @endif + + + - - @endforeach - -
+

{{ __('Aucun ticket') }}

{{ $ticket->assignedUser ? $ticket->assignedUser->name : __('Personne') }}{{ Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }} -
-
-
- @php - $ticket_files = $ticket->getFiles(); - @endphp - @foreach ($ticket_files as $key => $file) - @if ($file !== null && (\App\Lib\Helpers\ToolboxHelper::isImageFile($file) || \App\Lib\Helpers\ToolboxHelper::isPdfFile($file))) - - - @break +
+
+ {{ $ticket->id }}   + @if ($ticket->is_internal) + @endif - @endforeach - {{-- Modal du ticket --}} - - - - @if (auth()->user()->isAdmin()) - - @endif - @can('changeStatus', $ticket) - @if (!$ticket->status->equals(\App\Enums\Tickets\TicketStatusEnum::archived)) -
- @method('PUT') - @csrf - -
- @endif - @endcan +
- - - -
+
+ @if (Auth::user()->isAdmin()) + {{ $ticket->site->name }} + @else + {{ $ticket->site->name }} + @endif +
+
+ {{ $ticket->type->label() }} + +
+ + + {{ $ticket->status->label() }} + + +
+
+ {{ $ticket->title }} + + + @foreach ($ticket->labels as $label) + {{ $label->name }} + @endforeach + + {{ $ticket->assignedUser ? $ticket->assignedUser->name : __('Personne') }} + + {{ is_null($ticket->date_mep) ? '-' : $ticket->date_mep->format('d/m/Y') }} + {{ Carbon\Carbon::parse($ticket->created_at)->format('d/m/Y à H:i') }} +
+
+
+ @php + $ticket_files = $ticket->getFiles(); + @endphp + @foreach ($ticket_files as $key => $file) + @if ( + $file !== null && + (\App\Lib\Helpers\ToolboxHelper::isImageFile($file) || \App\Lib\Helpers\ToolboxHelper::isPdfFile($file))) + + + @break @endif -  -  - - {{ $ticket->type->label() }} - - - + @endforeach + {{-- Modal du ticket --}} + + + + @if (auth()->user()->isAdmin()) + + @endif + @can('changeStatus', $ticket) + @if (!$ticket->status->equals(\App\Enums\Tickets\TicketStatusEnum::archived)) +
+ @method('PUT') + @csrf + +
+ @endif + @endcan +
- -
-
- {{ $tickets->withQueryString()->links() }} +
+
+ {{ $tickets->withQueryString()->links() }} +
-
+
@endsection diff --git a/resources/views/bo/pages/tickets/show.blade.php b/resources/views/bo/pages/tickets/show.blade.php index 4d590bb..8f61f7a 100644 --- a/resources/views/bo/pages/tickets/show.blade.php +++ b/resources/views/bo/pages/tickets/show.blade.php @@ -12,6 +12,11 @@ {{ $ticket->full_name }} @if ($ticket->is_internal)@endif {{ $ticket->type->label() }} + @if (auth()->user()->isAdmin()) + + @endif
@can('suscribeToTicket', $ticket) @@ -99,7 +104,9 @@ @endif

- {{ __('Suivi') }} + @if ($ticket->site->projectManager) + {{ __("Chef de projet") }} : {{ $ticket->site->projectManager->name }} + @endif @can('createMessage', $ticket)

@endif + @php + $linkedTickets = $ticket->linkedTickets; + @endphp + @if (!$linkedTickets->isEmpty() or auth()->user()->can('linkTicket', $ticket)) +
+
+
+

{{ __('Tickets liés') }}

+
+ @can('linkTicket', $ticket) +
+ +
+ @endcan +
+ @foreach ($linkedTickets as $linked) +
+ @can('linkTicket', $ticket) + + @endcan +
+ @endforeach +
+ @endif +

@can('createGitlabIssue', $ticket)
diff --git a/resources/views/bo/pages/users/form-inputs.blade.php b/resources/views/bo/pages/users/form-inputs.blade.php index 8bcb5a8..ee0e1e0 100644 --- a/resources/views/bo/pages/users/form-inputs.blade.php +++ b/resources/views/bo/pages/users/form-inputs.blade.php @@ -118,6 +118,25 @@
+ {{-- GITLAB_USER_ID --}} +
+
+ {{ __("ID de l'utilisateur Gitlab") }} +
+
+ @include('bo.partials.inputs.int-number', [ + 'id' => 'siteGitlabUserId', + 'label' => __("ID de l'utilisateur Gitlab"), + 'name' => 'gitlab_id', + 'required' => false, + 'model' => $userModel ?? null, + 'helper' => __("ID de l'utilisateur Gitlab"), + 'step' => 1, + ]) +
+
+
+
@push('scripts') diff --git a/resources/views/bo/partials/inputs/bigint-foreign-id.blade.php b/resources/views/bo/partials/inputs/bigint-foreign-id.blade.php index 00ae35a..dcf9d41 100644 --- a/resources/views/bo/partials/inputs/bigint-foreign-id.blade.php +++ b/resources/views/bo/partials/inputs/bigint-foreign-id.blade.php @@ -10,6 +10,6 @@ @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{{ $id }}Help", + 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/date.blade.php b/resources/views/bo/partials/inputs/date.blade.php index 652dede..d5a69c2 100644 --- a/resources/views/bo/partials/inputs/date.blade.php +++ b/resources/views/bo/partials/inputs/date.blade.php @@ -10,6 +10,6 @@ value="{{ old($name, ((isset($model) and $model->{$name}) ? ($model->{$name}->format('Y-m-d') ?? ($defaultValue ? Carbon\Carbon::today() : '')) : ($defaultValue ? Carbon\Carbon::today() : ''))) }}"> @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{$id}Help", + 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/int-color.blade.php b/resources/views/bo/partials/inputs/int-color.blade.php index b3b63f6..b42f1e9 100644 --- a/resources/views/bo/partials/inputs/int-color.blade.php +++ b/resources/views/bo/partials/inputs/int-color.blade.php @@ -24,7 +24,7 @@ @endif @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => '{{ $id }}Help', + 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/int-number.blade.php b/resources/views/bo/partials/inputs/int-number.blade.php index a42a331..7e1b841 100644 --- a/resources/views/bo/partials/inputs/int-number.blade.php +++ b/resources/views/bo/partials/inputs/int-number.blade.php @@ -3,9 +3,7 @@ {{ $label }} {{ $required ? '*' : '' }} @endif -@if(isset($appendText))
- @endif @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => '{{ $id }}Help', + 'helperId' => $id.'Help', 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/pivot-belongsToMany.blade.php b/resources/views/bo/partials/inputs/pivot-belongsToMany.blade.php index 0bbccd4..10f1ea4 100644 --- a/resources/views/bo/partials/inputs/pivot-belongsToMany.blade.php +++ b/resources/views/bo/partials/inputs/pivot-belongsToMany.blade.php @@ -16,6 +16,6 @@ $data = [
@include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{$id}Help", + 'helperId' => $id."Help", 'helper' => $helper, ]) diff --git a/resources/views/bo/partials/inputs/publish-dates.blade.php b/resources/views/bo/partials/inputs/publish-dates.blade.php index 4df46a2..cedd68e 100644 --- a/resources/views/bo/partials/inputs/publish-dates.blade.php +++ b/resources/views/bo/partials/inputs/publish-dates.blade.php @@ -11,6 +11,6 @@ value="{{ old($name, ((isset($model) and $model->{$name}) ? $model->{$name}->format('Y-m-d\TH:i') : '')) }}"> @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => $id . 'Help', + 'helperId' => $id."Help", 'helper' => (isset($model) and $model->{$name}) ? __('Leave empty for immediate display of the slider.') : __('Empty for immediate display of the slider.') ]) diff --git a/resources/views/bo/partials/inputs/search-belongs-to-dropdown.blade.php b/resources/views/bo/partials/inputs/search-belongs-to-dropdown.blade.php index 85d83d5..571de8e 100644 --- a/resources/views/bo/partials/inputs/search-belongs-to-dropdown.blade.php +++ b/resources/views/bo/partials/inputs/search-belongs-to-dropdown.blade.php @@ -23,6 +23,6 @@ $data = [
@include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{$id}Help", + 'helperId' => $id."Help", 'helper' => $helper, ]) diff --git a/resources/views/bo/partials/inputs/text-html.blade.php b/resources/views/bo/partials/inputs/text-html.blade.php index de91170..17b9af0 100644 --- a/resources/views/bo/partials/inputs/text-html.blade.php +++ b/resources/views/bo/partials/inputs/text-html.blade.php @@ -12,7 +12,7 @@ $data = [
@include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{$id}Help", + 'helperId' => $id."Help", 'helper' => $helper ?? __('crud.minicrud.text_warning', ['number' => 15]) . '. ' . __('validation.min.string', [ 'attribute' => $input['label'], 'min' => 15 diff --git a/resources/views/bo/partials/inputs/text-list-items.blade.php b/resources/views/bo/partials/inputs/text-list-items.blade.php index 6262b0b..5641ec9 100644 --- a/resources/views/bo/partials/inputs/text-list-items.blade.php +++ b/resources/views/bo/partials/inputs/text-list-items.blade.php @@ -23,7 +23,7 @@
@include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{$id}Help", + 'helperId' => $id."Help", 'helper' => $helper, ])
diff --git a/resources/views/bo/partials/inputs/timestamp-datetime.blade.php b/resources/views/bo/partials/inputs/timestamp-datetime.blade.php index bd1e4ca..ea9c701 100644 --- a/resources/views/bo/partials/inputs/timestamp-datetime.blade.php +++ b/resources/views/bo/partials/inputs/timestamp-datetime.blade.php @@ -10,6 +10,6 @@ value="{{ old($name, ((isset($model) and $model->{$name}) ? ($model->{$name}->format('Y-m-d\TH:i') ?? ($defaultValue ? Carbon\Carbon::today() : '')) : ($defaultValue ? Carbon\Carbon::today() : ''))) }}"> @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{$id}Help", + 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/tinyint-boolean.blade.php b/resources/views/bo/partials/inputs/tinyint-boolean.blade.php index a8fee20..5e4440d 100644 --- a/resources/views/bo/partials/inputs/tinyint-boolean.blade.php +++ b/resources/views/bo/partials/inputs/tinyint-boolean.blade.php @@ -10,5 +10,5 @@ @if(old($name, (old('_token') ? false : ($model->{$name} ?? false)))) checked @endif>
@include('modules.input-error', [ - 'inputName' => $name, 'helperId' => '{{ $id }}Help' , 'helper' => $helper + 'inputName' => $name, 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/tinyint-enum.blade.php b/resources/views/bo/partials/inputs/tinyint-enum.blade.php index 314fc7a..302f187 100644 --- a/resources/views/bo/partials/inputs/tinyint-enum.blade.php +++ b/resources/views/bo/partials/inputs/tinyint-enum.blade.php @@ -10,6 +10,6 @@ @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{{ $id }}Help", + 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/varchar-multiline.blade.php b/resources/views/bo/partials/inputs/varchar-multiline.blade.php index d1347db..6906f56 100644 --- a/resources/views/bo/partials/inputs/varchar-multiline.blade.php +++ b/resources/views/bo/partials/inputs/varchar-multiline.blade.php @@ -22,6 +22,6 @@ $data = [
@include('modules.input-error', [ 'inputName' => $name, - 'helperId' => "{$id}Help", + 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/bo/partials/inputs/varchar.blade.php b/resources/views/bo/partials/inputs/varchar.blade.php index 1cfd04d..fa79d0a 100644 --- a/resources/views/bo/partials/inputs/varchar.blade.php +++ b/resources/views/bo/partials/inputs/varchar.blade.php @@ -21,6 +21,6 @@ @endif> @include('modules.input-error', [ 'inputName' => $name, - 'helperId' => $id.'Help', + 'helperId' => $id."Help", 'helper' => $helper ]) diff --git a/resources/views/home.blade.php b/resources/views/home.blade.php deleted file mode 100644 index 76a16d6..0000000 --- a/resources/views/home.blade.php +++ /dev/null @@ -1,58 +0,0 @@ -@extends('layout.app') - -@section('title', __('Accueil')) -@section('description', __('Page d\'accueil du site :site', ['site' => config('app.name')])) - -@section('content') -
-
- -
-
-
-

- {{ __('models.classes.dutyhours') . __(' à venir') }} -

-
-
-
-
-
- - - - - - - - - - @if($dutyhourModels->count()) - @foreach ($dutyhourModels as $dutyhourModel) - - - - - - @endforeach - @else - - - - @endif - -
{{ __('Date') }}{{ __('Personne présente') }}{{ __('Lieu de la permanence') }}
{{ $dutyhourModel->date->formatLocalized('%d/%m/%Y') }}{{ $dutyhourModel->person }}{{ $dutyhourModel->place }}
- {{ __('Aucune :model prévue prochainement', ['model' => Str::singular(__('models.classes.dutyhours')) ])}} -
-
-
-
-
-@endsection diff --git a/resources/views/layout/nav.blade.php b/resources/views/layout/nav.blade.php index 05eb030..696d66e 100644 --- a/resources/views/layout/nav.blade.php +++ b/resources/views/layout/nav.blade.php @@ -40,14 +40,14 @@ {{ __('models.classes.packages') }} @endcan @can('isAdmin') - {{ __('models.classes.dutyhours') }} - @endcan - @can('isAdmin') {{ __('models.classes.informations') }} @endcan @can('isAdmin') {{ trans_choice('models.classes.ticket_types', 2) }} @endcan + @can('isAdmin') + {{ __('models.classes.labels') }} + @endcan @endcan @@ -108,7 +108,7 @@ {{ __('Identifiants') }} - + @csrf diff --git a/resources/views/modules/sorter.blade.php b/resources/views/modules/sorter.blade.php deleted file mode 100644 index b7ae505..0000000 --- a/resources/views/modules/sorter.blade.php +++ /dev/null @@ -1,6 +0,0 @@ -@if(!session('tickets.sort_way') or session('tickets.sort_col') !== $colname or (session('tickets.sort_way') === 'desc' and session('tickets.sort_col') === $colname)) - ↓  -@endif -@if(!session('tickets.sort_way') or session('tickets.sort_col') !== $colname or (session('tickets.sort_way') === 'asc' and session('tickets.sort_col') === $colname)) - ↑  -@endif diff --git a/routes/breadcrumbs-bo.php b/routes/breadcrumbs-bo.php index d07d24b..adab166 100644 --- a/routes/breadcrumbs-bo.php +++ b/routes/breadcrumbs-bo.php @@ -3,7 +3,6 @@ use App\Enums\Invoices\InvoiceStatusEnum; use App\Models\Brand; use App\Models\Company; -use App\Models\Dutyhour; use App\Models\Information; use App\Models\Invoice; use App\Models\Label; @@ -28,19 +27,6 @@ Breadcrumbs::for('bo.packages.edit', function (Generator $trail, Package $packag $trail->push(__('crud.actions.edit'), route('bo.packages.edit', $package->id)); }); -// * DUTYHOURS -Breadcrumbs::for('bo.dutyhours.index', function (Generator $trail) { - $trail->push(__('models.classes.dutyhours'), route('bo.dutyhours.index')); -}); -Breadcrumbs::for('bo.dutyhours.create', function (Generator $trail) { - $trail->parent('bo.dutyhours.index'); - $trail->push(__('crud.actions.create'), route('bo.dutyhours.create')); -}); -Breadcrumbs::for('bo.dutyhours.edit', function (Generator $trail, Dutyhour $dutyhour) { - $trail->parent('bo.dutyhours.index'); - $trail->push(__('crud.actions.edit'), route('bo.dutyhours.edit', $dutyhour->id)); -}); - // * INFORMATIONS Breadcrumbs::for('bo.informations.index', function (Generator $trail) { $trail->push(__('models.classes.informations'), route('bo.informations.index')); diff --git a/routes/web-bo.php b/routes/web-bo.php index fd29849..faca415 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -5,8 +5,6 @@ use App\Http\Controllers\Bo\CompanyController; use App\Http\Controllers\Bo\Credit\AccountController; use App\Http\Controllers\Bo\Credit\CreditLogController; use App\Http\Controllers\Bo\Credit\EstimationController; -use App\Http\Controllers\Bo\DashboardController; -use App\Http\Controllers\Bo\DutyhourController; use App\Http\Controllers\Bo\InformationController; use App\Http\Controllers\Bo\InvoiceController; use App\Http\Controllers\Bo\LabelController; @@ -43,7 +41,9 @@ Route::middleware('admin-secure') Route::middleware('auth:backend') ->group(function () { // * HOME - Route::get('/', [DashboardController::class, 'index'])->name('dashboard'); + Route::get('/', function(){ + return redirect()->route('bo.ticket.index'); + })->name('dashboard'); Route::middleware(['can:isAdmin']) ->group(function () { @@ -56,7 +56,6 @@ Route::middleware('admin-secure') ->middleware('htmlsanitize:template') ->parameters(['ticket_types' => 'ticket_type']); Route::resource('packages', PackageController::class)->except('show'); - Route::resource('dutyhours', DutyhourController::class)->except('show'); Route::resource('invoices', InvoiceController::class) ->withoutMiddleware('htmlsanitize') ->middleware(['htmlsanitize:comment']); @@ -95,6 +94,10 @@ Route::middleware('admin-secure') ) ->middleware('can:createGitlabIssue,ticket') ->name('ticket.create-issue'); + Route::patch('/tickets/{ticket}/change-order/{direction}', [ + TicketController::class, + 'changeOrder' + ])->where('direction', 'up|down')->name('ticket.change-order'); }); Route::resource('credit_accounts', AccountController::class) ->only(['index']) @@ -150,6 +153,12 @@ Route::middleware('admin-secure') Route::post('/{ticket}/subscribe', [TicketController::class, 'subscribe']) ->middleware('can:suscribeToTicket,ticket') ->name('subscribe'); + Route::post('/{ticket}/link', [TicketController::class, 'linkTicket']) + ->middleware('can:linkTicket,ticket') + ->name('link'); + Route::delete('/{ticket}/unlink/{linkedTicket}', [TicketController::class, 'unlinkTicket']) + ->middleware('can:linkTicket,ticket') + ->name('unlink'); Route::put('/{ticket}/archive', [TicketController::class, 'setToArchive']) ->middleware('can:changeStatus,ticket') ->name('archive');