Merge branch 'develop' into trunk

This commit is contained in:
Noah Lancien 2025-10-07 12:49:01 +02:00
commit de20063c5f
24 changed files with 291 additions and 228 deletions

View file

@ -47,7 +47,7 @@ class AnswerController extends Controller
$this->sortQuery($query);
$searchFields = trans('Réponse');
$answerModels = $this->paginate($this->getPagination());
$answerModels = $query->paginate($this->getPagination());
return view('bo.pages.answers.index', compact('answerModels', 'questionModel', 'searchFields'));
}

View file

@ -16,6 +16,7 @@ use App\Models\Claim;
use App\Models\ClaimMailTemplate;
use App\Models\ClaimMessage;
use App\Models\ClaimSubject;
use App\Models\CustomerInfo;
use App\Traits\Controllers\UpdateModelPublished;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
@ -92,12 +93,12 @@ class ClaimController extends Controller
*/
public function edit(Claim $claim): \Illuminate\Contracts\View\View
{
$customerClaimModels = !is_null($claim->customer) ? $this->paginate(Claim::query()
$customerClaimModels = !is_null($claim->customer) ? Claim::query()
->whereNotNull('customer_id')
->whereHas('brand', fn($q) => $q->whereKey($claim->brand->getKey()))
->whereHas('customer', fn($q) => $q->whereKey($claim->customer->getKey()))
->whereNot('id', $claim->getKey())
->whereNot('status', ClaimStatus::treated)) : collect();
->whereNot('status', ClaimStatus::treated)->paginate($this->jsonItemPerPagination) : collect();
$brandModels = CollectionHelper::paginate(
Brand::getUserAssociatedBrands(),
$this->jsonItemPerPagination,
@ -111,6 +112,7 @@ class ClaimController extends Controller
ClaimMailTemplate::getAllModelsFromBrand($claim->brand->getKey()),
$this->jsonItemPerPagination,
);
$customerModel = CustomerInfo::query()->where('hashcode', $claim->hashcode)->first();
return view('bo.pages.claims.edit', [
'claimModel' => $claim->load(['brand', 'claimSubject']),
@ -119,6 +121,7 @@ class ClaimController extends Controller
'claimMessageModels' => $claimMessageModels,
'claimSubjectModels' => $claimSubjectModels,
'claimTemplateModels' => $claimTemplateModels,
'customerModel' => $customerModel,
]);
}
@ -168,7 +171,7 @@ class ClaimController extends Controller
"<b>%s %s</b> %s <i class='badge' style='background-color:{$enum->color()}'>%s</i><hr class='my-2'>%s",
$userModel->first_name,
$userModel->last_name,
trans('a modifié le :field en', ['field' => trans('validation.custom.response_type')]),
trans('a modifié :field en', ['field' => trans('validation.custom.response_type')]),
$claim->response_type->label(),
clean($request->validated()['content']),
);

View file

@ -82,7 +82,7 @@ class SendClaimRequest extends BaseApiRequest
'message' => 'required|string|min:3',
'brand_id' => 'required|integer|exists:brands,id',
'subject_id' => 'required|integer|exists:claim_subjects,id',
'customer_id' => 'sometimes|nullable|integer|exists:customers,id',
'hashcode' => 'sometimes|nullable|string|size:36',
];
}
}

View file

@ -38,7 +38,7 @@ class ClaimSubjectRequest extends FormRequest
{
return [
'brand_id' => trans('models.classes.brands'),
'label' => trans('validation.attributes.label'),
'label' => trans('validation.custom.label'),
];
}
}

View file

@ -68,7 +68,7 @@ class AddClaimMessageSystem
{
$enumLabel = $event->claim->{$event->field}->label();
$enumColor = $event->claim->{$event->field}->color();
$baseMessage = trans(':field est passé à', ['field' => $event->label]);
$baseMessage = trans('Modification :field en', ['field' => $event->label]);
// If the user is available, include user details in the message.
if ($event->user) {
@ -76,7 +76,7 @@ class AddClaimMessageSystem
"<b>%s %s</b> %s <i class='badge' style='background-color:%s'>%s</i>",
$event->user->first_name,
$event->user->last_name,
trans('a modifié le :field en', ['field' => $event->label]),
trans('a modifié :field en', ['field' => $event->label]),
$enumColor,
$enumLabel,
);
@ -101,7 +101,7 @@ class AddClaimMessageSystem
{
$field = $event->claim->{$event->field};
$label = Str::of($event->label)->lower()->singular();
$baseMessage = trans(':field est passé à', ['field' => $label]);
$baseMessage = trans('Modification :field en', ['field' => $label]);
$fieldLabel = $field->label ?? $field->name;
// If the user is available, include user details in the message.
@ -110,7 +110,7 @@ class AddClaimMessageSystem
"<b>%s %s</b> %s <b>%s</b>",
$event->user->first_name,
$event->user->last_name,
trans('a modifié le :field en', ['field' => $label]),
trans('a modifié :field en', ['field' => $label]),
$fieldLabel,
);
}

View file

@ -26,7 +26,7 @@ use Illuminate\Support\Str;
* @property \App\Enums\Claims\ClaimType $type Claim type (ClaimType enum).
* @property \App\Models\Brand $brand_id Claim associated Brand.
* @property \App\Models\ClaimSubject $subject_id Claim associated Subject.
* @property \App\Models\Customer|null $customer_id Claim associated Customer.
* @property string|null $hashcode Claim associated Customer hashcode.
* @property-read \Illuminate\Support\Carbon $created_at Claim created date.
* @property-read \Illuminate\Support\Carbon $updated_at Claim updated date.
*/
@ -54,7 +54,7 @@ class Claim extends Model
'type',
'brand_id',
'subject_id',
'customer_id',
'hashcode',
];
/**
@ -153,16 +153,6 @@ class Claim extends Model
return $this->belongsTo(ClaimSubject::class, 'subject_id');
}
/**
* Customer subject belongs to relation.
*
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo
*/
public function customer(): \Illuminate\Database\Eloquent\Relations\BelongsTo
{
return $this->belongsTo(Customer::class);
}
/**
* ClaimMessage has many relation.
*

View file

@ -3,6 +3,7 @@
namespace App\Policies;
use App\Enums\Users\RoleEnum;
use App\Models\Claim;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
use App\Policies\Rules\UserStaticRules as USR;
@ -12,16 +13,6 @@ class ClaimPolicy
{
use HandlesAuthorization;
/**
* View a Claim.
*
* @return boolean
*/
public function view(): bool
{
return USR::everyOne();
}
/**
* View any a Claim.
*
@ -35,21 +26,25 @@ class ClaimPolicy
/**
* Preview a Claim.
*
* @param \App\Models\User $authUser
* @param \App\Models\Claim $claim
* @return boolean
*/
public function preview(): bool
public function preview(User $authUser, Claim $claim): bool
{
return USR::everyOne();
return $this->checkOnlyMinAdminOrInUserBrands($authUser, $claim);
}
/**
* Update a Claim.
*
* @param \App\Models\User $authUser
* @param \App\Models\Claim $claim
* @return boolean
*/
public function update(): bool
public function update(User $authUser, Claim $claim): bool
{
return USR::everyOne();
return $this->checkOnlyMinAdminOrInUserBrands($authUser, $claim);
}
/**
@ -66,40 +61,65 @@ class ClaimPolicy
/**
* Determine whether the user can update the associated subject of the model.
*
* @param \App\Models\User $authUser
* @param \App\Models\Claim $claim
* @return boolean
*/
public function updateSubject(): bool
public function updateSubject(User $authUser, Claim $claim): bool
{
return USR::everyOne();
return $this->checkOnlyMinAdminOrInUserBrands($authUser, $claim);
}
/**
* Update a Claim.
*
* @param \App\Models\User $authUser
* @param \App\Models\Claim $claim
* @return boolean
*/
public function updateType(): bool
public function updateType(User $authUser, Claim $claim): bool
{
return USR::everyOne();
return $this->checkOnlyMinAdminOrInUserBrands($authUser, $claim);
}
/**
* Update a Claim.
*
* @param \App\Models\User $authUser
* @param \App\Models\Claim $claim
* @return boolean
*/
public function updateStatus(): bool
public function updateStatus(User $authUser, Claim $claim): bool
{
return USR::everyOne();
return $this->checkOnlyMinAdminOrInUserBrands($authUser, $claim);
}
/**
* Update a Claim.
*
* @param \App\Models\User $authUser
* @param \App\Models\Claim $claim
* @return boolean
*/
public function updateResponseType(): bool
public function updateResponseType(User $authUser, Claim $claim): bool
{
return USR::everyOne();
return $this->checkOnlyMinAdminOrInUserBrands($authUser, $claim);
}
/**
* Check if the user an access a specific resource.
*
* @param \App\Models\User $authUser
* @param \App\Models\Claim $claim
* @return boolean
*/
private function checkOnlyMinAdminOrInUserBrands(User $authUser, Claim $claim): bool
{
$userBrandModelKeys = $authUser->brands->modelKeys();
$claimModelKey = $claim->brand->getKey();
return UserStaticRules::atLeastRole($authUser, RoleEnum::admin) || (
UserStaticRules::atLeastRole($authUser, RoleEnum::marketing)
&& \in_array($claimModelKey, $userBrandModelKeys)
);
}
}

View file

@ -126,4 +126,17 @@ class UserPolicy
UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) and
UserStaticRules::atLeastRole($authUser, $user->role);
}
/**
* Determine whether the user can update associated brands to the model.
*
* @param \App\Models\User $authUser
* @param \App\Models\User $user
* @return booleanean
*/
public function changeBrands(User $authUser, User $user): bool
{
return UserStaticRules::atLeastRole($authUser, RoleEnum::conceptor) &&
$user->role->equals(RoleEnum::marketing);
}
}

View file

@ -1,11 +1,11 @@
{
"name": "ldc/ldccrm",
"version": "4.1.6",
"version": "4.1.7",
"type": "project",
"description": "LDC CRM",
"license": "MIT",
"support": {
"email": "equipe.web@ldc.fr"
"email": "digital@ldc.fr"
},
"keywords": [
"framework",

View file

@ -0,0 +1,36 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up(): void
{
Schema::table('claims', function (Blueprint $table) {
$table->dropForeign('claims_customer_id_foreign');
$table->dropColumn('customer_id');
$table->string('hashcode')->nullable()->unique()->after('id');
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down(): void
{
Schema::table('claims', function (Blueprint $table) {
$table->dropColumn('hashcode');
$table->foreignId('customer_id')->nullable()->comment('Claim associated Customer.')
->constrained('customers')->onUpdate('cascade')->onDelete('set null');
});
}
};

View file

@ -5,7 +5,7 @@
>
<tbody>
<!-- Brand -->
<tr class="border-bottom list-item">
<tr class="border-bottom">
<td
class="align-middle pb-3"
colspan="2"
@ -38,7 +38,7 @@
</small>
</td>
<template v-else>
<td class="align-middle fw-bold">
<td class="align-middle text-capitalize fw-bold">
{{ brandLabel }}
</td>
<td
@ -50,7 +50,7 @@
</template>
</tr>
<!-- Subject -->
<tr class="border-bottom list-item">
<tr class="border-bottom">
<td
class="align-middle pb-3"
colspan="2"
@ -84,7 +84,7 @@
</small>
</td>
<template v-else>
<td class="align-middle fw-bold">
<td class="align-middle text-capitalize fw-bold">
{{ claimsubjectLabel }}
</td>
<td class="align-middle">
@ -96,7 +96,6 @@
<tr
v-for="(enumField, enumFieldIndex) in enumFields"
:key="enumFieldIndex"
class="list-item"
:class="{'border-0': enumFieldIndex === Object.keys(enumFields).length - 1}"
>
<td
@ -111,7 +110,10 @@
>
<b>{{ trans.methods.__('Modifier le :label', { label: trans.methods.__(`validation.custom.${enumField.name}`) }) }} *</b>
</label>
<div class="d-flex justify-content-center align-items-center">
<div
:key="localVersion"
class="d-flex justify-content-center align-items-center"
>
<select
:id="enumField.name"
class="form-select"
@ -138,6 +140,8 @@
class="btn btn-primary ms-1"
data-bs-toggle="modal"
data-bs-target="#manualResponseModal"
data-bs-tooltip="tooltip"
:title="trans.methods.__('Répondre au client')"
>
<FontAwesomeIcon icon="fa-solid fa-comment-dots" />
</button>
@ -257,6 +261,7 @@ const enumFields = ref<Record<number, {
associatedEnum: Array<Enum>,
}>>({});
const allErrors = ref<LaravelValidationErrors>(props.allErrors);
const localVersion = ref<number>(1);
/** Enum parameters. */
const enumParameters = reactive<{
@ -468,6 +473,7 @@ function checkIsManualResponseType(fieldName: string): boolean {
*/
function updateMessages(value: Array<LaravelModel & LaravelModelUserRelation>): void {
selectParameters.enums["status"] = "4";
localVersion.value = localVersion.value + 1;
emits("updateMessages", value);
}

View file

@ -35,7 +35,7 @@
size="2xl"
/>
<p class="my-3">
{{ trans.methods.__('Aucune activité enregistré à ce jour') }}
{{ trans.methods.__('Aucune activité enregistrée à ce jour') }}
</p>
</div>
</div>

View file

@ -14,7 +14,7 @@
class="modal-title fs-5"
id="manualResponseModalLabel"
>
{{ trans.methods.__('Votre réponse') }}
{{ trans.methods.__('Votre réponse au client') }}
</p>
<button
type="button"
@ -83,7 +83,7 @@
type="button"
class="btn btn-primary"
data-bs-tooltip="tooltip"
:title="trans.methods.__('Envoyer votre réponse')"
:title="trans.methods.__('Répondre au client')"
@click="sendResponse()"
:disabled="loading"
>
@ -95,7 +95,7 @@
<span class="visually-hidden">{{ trans.methods.__('Chargement...') }}</span>
</div>
<div v-show="!loading">
{{ trans.methods.__('Envoyer votre réponse') }}
{{ trans.methods.__('Envoyer votre réponse au client') }}
</div>
</button>
</div>

View file

@ -91,7 +91,7 @@
}) }}
</span>
<span
v-if="isAuthenticableUser && (showDates || claimMessageModel.created_at !== claimMessageModel.updated_at)"
v-if="showDates || claimMessageModel.created_at !== claimMessageModel.updated_at"
class="ms-1"
>
{{ trans.methods.__('- Mis à jour le :date', {

View file

@ -89,9 +89,10 @@
</div>
</fieldset>
</div>
{{-- IMAGE --}}
<div class="col-12 mb-3">
<fieldset class="h-100 border p-3">
<legend>{{ str(__('validation.custom.url_claim'))->ucfirst() }}</legend>
<legend>{{ str(__('validation.attributes.image'))->ucfirst() }}</legend>
<div class="row">
<div class="col-12">
@include('bo.partials.inputs.varchar-picture', [

View file

@ -5,90 +5,101 @@
@section('breadcrumb', request()->route()->getName())
@section('content')
<div class="row w-100 mx-auto">
{{-- TITLE --}}
<div class="col-12">
<div class="d-flex align-items-start flex-row">
<a class="btn btn-primary text-decoration-none m-0" data-bs-tooltip="tooltip" href="{{ route('bo.claims.index') }}"
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.claims')]) }}">
<i class="fa-solid fa-arrow-left"></i>
</a>
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $claimModel])
<div class="card border-0">
<div class="card-header">
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap">
<div class="d-flex align-items-start flex-row">
@can('viewAny', $claimModel)
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" data-bs-placement="top"
data-bs-tooltip="tooltip" href="{{ route('bo.claims.index') }}"
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.claims')]) }}">
<i class="fa-solid fa-arrow-left"></i>
</a>
@endcan
@include('modules.breadcrumbs.breadcrumb-body', ['brParam' => $claimModel])
</div>
</div>
</div>
{{-- CLAIM AUTHOR --}}
<div class="col-12 mt-3">
<div class="card shadow-sm w-100">
<div class="card-body">
<div class="row">
<div class="col-12 col-lg-4 text-center">
<h5 class="card-title mb-1">{{ trim(sprintf('%s %s', $claimModel->first_name, $claimModel->last_name)) }}</h5>
<p class="text-muted mb-2">{{ e($claimModel->email) }}</p>
@if ($claimModel->customer && auth()->user()->can('view', $claimModel->customer))
<a href="{{ route('bo.customers.show', [
'customer' => $claimModel->customer,
'brand' => $claimModel->brand,
]) }}" target="_blank" rel="noopener">
{{ __('Lien vers la fiche client') }}
<i class="fas fa-arrow-up-right-from-square ms-1"></i>
</a>
@endif
@if ($claimModel->getFormatedAddress())
<p class="mb-0">{{ $claimModel->getFormatedAddress() ? e($claimModel->getFormatedAddress()) : null }}</p>
@endif
</div>
<div class="col-12 col-lg-8 border-top border-lg-top-0 border-lg-start border-lg-3 border-lg-primary mt-2 pt-2 mt-lg-0 pt-lg-0">
<div class="claim-message-collapse" data-json='@json(['message' => $claimModel->message])'></div>
@if($claimModel->file)
<div class="d-flex flex-row justify-content-start align-items-center">
<p class="m-0 me-2">Fichier:</p>
<a class="btn btn-sm btn-primary" href="{{ asset($claimModel->file) }}" target="_blank"
data-bs-tooltip="tooltip" title="{{ __('Ouvrir le fichier associé à cette réclamation') }}">
{{ __('Voir la pièce jointe associée') }}
<div class="card-body">
{{-- CLAIM AUTHOR --}}
<div class="col-12 mt-3">
<div class="card shadow-sm w-100">
<div class="card-body">
<div class="row">
<div class="col-12 col-lg-4 text-center">
<h5 class="card-title mb-1">
{{ trim(sprintf('%s %s', $claimModel->first_name, $claimModel->last_name)) }}
</h5>
<p class="text-muted mb-2">{{ e($claimModel->email) }}</p>
@if ($customerModel && auth()->user()->can('view', \App\Models\Customer::class))
<a href="{{ route('bo.customers.show', [
'customer' => $customerModel,
'brand' => $customerModel->brand,
]) }}" target="_blank" rel="noopener">
{{ __('Lien vers la fiche client') }}
<i class="fas fa-arrow-up-right-from-square ms-1"></i>
</a>
</div>
@endif
@endif
@if ($claimModel->getFormatedAddress())
<p class="mb-0">
{{ $claimModel->getFormatedAddress() ? e($claimModel->getFormatedAddress()) : null }}
</p>
@endif
</div>
<div class="col-12 col-lg-8 border-top border-lg-top-0 border-lg-start border-lg-3 border-lg-primary mt-2 pt-2 mt-lg-0 pt-lg-0">
<div class="claim-message-collapse" data-json='@json(['message' => $claimModel->message])'></div>
@if ($claimModel->file)
<div class="d-flex flex-row justify-content-start align-items-center">
<p class="m-0 me-2">Fichier:</p>
<a class="btn btn-sm btn-primary" href="{{ asset($claimModel->file) }}"
target="_blank" data-bs-tooltip="tooltip"
title="{{ __('Ouvrir le fichier associé à cette réclamation') }}">
{{ __('Voir la pièce jointe associée') }}
</a>
</div>
@endif
</div>
</div>
</div>
</div>
</div>
</div>
{{-- ACTIONS / CONVERSATION--}}
<div class="col-12 px-0 py-3">
@php
$data = [
'authUserId' => auth('backend')->user()->getKey(),
'claimModel' => $claimModel,
'brandModels' => $brandModels ?? [],
'claimSubjectModels' => $claimSubjectModels ?? [],
'claimMessageModels' => $claimMessageModels,
'claimTemplateModels' => $claimTemplateModels,
'enums' => [
'claimType' => \App\Enums\Claims\ClaimType::toArray(),
'claimStatus' => \App\Enums\Claims\ClaimStatus::toArray(),
'claimResponseType' => \App\Enums\Claims\ClaimResponseType::toArray(),
],
'can' => [
'updateBrand' => Gate::check('updateBrand', \App\Models\Claim::class),
'updateSubject' => Gate::check('updateSubject', \App\Models\Claim::class),
'updateType' => Gate::check('updateType', \App\Models\Claim::class),
'updateStatus' => Gate::check('updateStatus', \App\Models\Claim::class),
'updateResponseType' => Gate::check('updateResponseType', \App\Models\Claim::class),
],
'allErrors' => $errors->getBag('default')->getMessages() ?? [],
];
@endphp
<div class="claim-wrapper" data-json='@json($data)'></div>
</div>
{{-- OTHER CUSTOMER CLAIMS --}}
@if ($customerClaimModels->count())
<div class="col-12 py-3">
<h3 class="h3 fw-bold">{{ __('Autres réclas du même demandeur') }}</h3>
<div class="table-responsive mb-2">
@include('bo.pages.claims.index-list', ['claimModels' => $customerClaimModels])
</div>
{!! $customerClaimModels->links() !!}
{{-- ACTIONS / CONVERSATION --}}
<div class="col-12 px-0 py-3">
@php
$data = [
'authUserId' => auth('backend')->user()->getKey(),
'claimModel' => $claimModel,
'brandModels' => $brandModels ?? [],
'claimSubjectModels' => $claimSubjectModels ?? [],
'claimMessageModels' => $claimMessageModels,
'claimTemplateModels' => $claimTemplateModels,
'enums' => [
'claimType' => \App\Enums\Claims\ClaimType::toArray(),
'claimStatus' => \App\Enums\Claims\ClaimStatus::toArray(),
'claimResponseType' => \App\Enums\Claims\ClaimResponseType::toArray(),
],
'can' => [
'updateBrand' => Gate::check('updateBrand', $claimModel),
'updateSubject' => Gate::check('updateSubject', $claimModel),
'updateType' => Gate::check('updateType', $claimModel),
'updateStatus' => Gate::check('updateStatus', $claimModel),
'updateResponseType' => Gate::check('updateResponseType', $claimModel),
],
'allErrors' => $errors->getBag('default')->getMessages() ?? [],
];
@endphp
<div class="claim-wrapper" data-json='@json($data)'></div>
</div>
@endif
{{-- OTHER CUSTOMER CLAIMS --}}
@if ($customerClaimModels->count())
<div class="col-12 py-3">
<h3 class="h3 fw-bold">{{ __('Autres réclas du même demandeur') }}</h3>
<div class="table-responsive mb-2">
@include('bo.pages.claims.index-list', ['claimModels' => $customerClaimModels])
</div>
{!! $customerClaimModels->links() !!}
</div>
@endif
</div>
</div>
@endsection

View file

@ -1,18 +1,18 @@
<table class="table table-hover table-fix-action m-0">
@if (count($claimModels) > 0)
<thead>
@include('bo.modules.table-col-sorter', [
'cols' => [
'reference' => str(__('validation.custom.reference'))->ucfirst(),
'email' => str(__('models.classes.customers'))->ucfirst(),
'brand_id' => str(__('models.classes.brands'))->singular()->ucfirst(),
'type' => str(__('validation.custom.type'))->ucfirst(),
'status' => str(__('validation.custom.status'))->ucfirst(),
'updated_at' => str(__('validation.attributes.updated_at'))->ucfirst(),
],
])
</thead>
<tbody>
<thead class="border-top-0 border-start-0 border-end-0 border border-2">
@include('bo.modules.table-col-sorter', [
'cols' => [
'reference' => str(__('validation.custom.reference'))->ucfirst(),
'email' => str(__('models.classes.customers'))->ucfirst(),
'brand_id' => str(__('models.classes.brands'))->singular()->ucfirst(),
'type' => str(__('validation.custom.type'))->ucfirst(),
'status' => str(__('validation.custom.status'))->ucfirst(),
'updated_at' => str(__('validation.attributes.updated_at'))->ucfirst(),
],
])
</thead>
<tbody>
@if ($claimModels->count())
@foreach ($claimModels as $claimModel)
<tr class="border-bottom list-item">
<td class="text-center align-middle">{{ $claimModel->reference }}</td>
@ -61,12 +61,16 @@
</td>
</tr>
@endforeach
</tbody>
@else
<tr>
<td class="border-0">{{ __('crud.other.no_model_found', ['model' => str(__('models.classes.claims'))->singular()]) }}</td>
</tr>
@endif
@else
<tr>
<td class="text-center" colspan="7">
<span class="h3">
{{ __('Aucun résultat pour les :models', ['models' => __('models.classes.claims')]) }}
</span>
</td>
</tr>
@endif
</tbody>
</table>
{{-- PREVIEW MODAL --}}

View file

@ -1,7 +1,8 @@
@extends('bo.layout')
@section('title', __('models.classes.claims'))
@section('description', __('Liste de toutes les :model', ['model' => __('models.classes.claims')]))
@section('title', sprintf('%s - %s', __('models.classes.claims'), str(__('liste'))->ucfirst()))
@section('description', __('Listage de toutes les :model', ['model' => __('models.classes.claims')]))
@section('metaIndex', 'noindex,nofollow')
@section('content')
<div class="row w-100 mx-auto">
@ -12,16 +13,6 @@
<div class="col p-0">
@include('modules.breadcrumbs.breadcrumb-body')
</div>
<div class="col-md-3 d-flex align-items-center p-0">
<div class="input-group justify-content-end">
@can('create', \App\Models\Claim::class)
<a class="btn btn-primary" data-bs-tooltip="tooltip" href="{{ route('bo.claims.create') }}"
title="{{ __('Ajouter une :model', ['model' => Str::singular(__('models.classes.claims'))]) }}">
<i class="fa-solid fa-plus"></i>
</a>
@endcan
</div>
</div>
</div>
</div>
<div class="card-body">

View file

@ -7,7 +7,7 @@
@section('content')
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
<div class="d-flex align-items-start flex-row">
<a class="btn btn-primary text-decoration-none m-0" data-bs-tooltip="tooltip" href="{{ route('bo.users.index') }}"
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" href="{{ route('bo.users.index') }}"
title="{{ __('crud.helpers.list_all', ['model' => __('models.classes.user')]) }}">
<i class="fa-solid fa-arrow-left"></i>
</a>

View file

@ -7,7 +7,7 @@
@section('content')
<div class="d-flex justify-content-between flex-md-nowrap align-items-center flex-wrap pb-3">
<div class="d-flex align-items-start flex-row">
<a class="btn btn-primary text-decoration-none m-0" data-bs-tooltip="tooltip" href="{{ route('bo.users.index') }}"
<a class="btn btn-primary text-decoration-none me-2" data-bs-tooltip="tooltip" href="{{ route('bo.users.index') }}"
title="{{ __('crud.helpers.list_all', ['model' => Str::plural(__('models.classes.user'))]) }}">
<i class="fa-solid fa-arrow-left"></i>
</a>

View file

@ -108,35 +108,37 @@
</fieldset>
</div>
{{-- BRAND --}}
<div class="col-12 col-md-6 pb-3">
<fieldset class="h-100 border p-3" id="userRoleFieldset">
<legend>{{ str(__('models.classes.brands'))->ucfirst() }}</legend>
<div class="row">
@include('bo.partials.inputs.search-belongs-to-dropdown', [
'id' => 'questionBrand',
'label' => __(':model associées', [
'model' => str(__('models.classes.brands'))->ucfirst(),
]),
'name' => 'brand_id',
'relation' => 'brands',
'model' => $userModel,
'targetClass' => 'App\Models\Brand',
'modelListPaginate' => $brandModels ?? [],
'constructedRoute' => route('bo.brands.json-paginate'),
'fieldName' => 'name',
'multiple' => true,
'required' => true,
'disabled' => false,
'placeholder' => __('Rechercher une :model', [
'model' => str(__('models.classes.brands'))->singular(),
]),
'helper' => __('Sélectionner des :model qui seront associées parmis la liste.', [
'model' => __('models.classes.brands'),
]),
])
</div>
</fieldset>
</div>
@can('changeBrands', $userModel)
<div class="col-12 col-md-6 pb-3">
<fieldset class="h-100 border p-3">
<legend>{{ str(__('models.classes.brands'))->ucfirst() }}</legend>
<div class="row">
@include('bo.partials.inputs.search-belongs-to-dropdown', [
'id' => 'userBrand',
'label' => __(':model associées', [
'model' => str(__('models.classes.brands'))->ucfirst(),
]),
'name' => 'brand_id',
'relation' => 'brands',
'model' => $userModel,
'targetClass' => 'App\Models\Brand',
'modelListPaginate' => $brandModels ?? [],
'constructedRoute' => route('bo.brands.json-paginate'),
'fieldName' => 'name',
'multiple' => true,
'required' => true,
'disabled' => false,
'placeholder' => __('Rechercher une :model', [
'model' => str(__('models.classes.brands'))->singular(),
]),
'helper' => __('Sélectionner des :model qui seront associées parmis la liste.', [
'model' => __('models.classes.brands'),
]),
])
</div>
</fieldset>
</div>
@endcan
<div class="row">
<div class="col text-center">
<p><b>{{ __('* Champs obligatoires') }}</b></p>
@ -154,20 +156,6 @@
event.preventDefault();
submit.click();
});
// If the role is marketing, need brands associated.
const selectRole = document.getElementById('userRole');
const userRoleFieldset = document.getElementById('userRoleFieldset');
selectRole.addEventListener('change', (event) => {
updateBrandsFieldsetStatus(Number(event.target.value));
});
updateBrandsFieldsetStatus(Number("{{ $userModel->role?->value() ?? \App\Enums\Users\RoleEnum::conceptor->value() }}"));
function updateBrandsFieldsetStatus(value) {
const marketingValue = {{ \App\Enums\Users\RoleEnum::marketing->value() }};
const condition = value !== marketingValue;
userRoleFieldset.disabled = condition;
userRoleFieldset.className = `h-100 border p-3 ${condition ? 'd-none' : ''}`;
}
});
</script>
@endpush

View file

@ -22,9 +22,9 @@ Breadcrumbs::for('bo.users.edit', function (Generator $trail, User $user) {
$trail->parent('bo.users.index');
$trail->push(Str::ucfirst(trans('crud.actions.edit')), route('bo.users.edit', $user));
});
Breadcrumbs::for('bo.users.duplicate', function (Generator $trail, User $user) {
Breadcrumbs::for('bo.users.duplicate', function (Generator $trail) {
$trail->parent('bo.users.index');
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')), route('bo.users.duplicate', $user));
$trail->push(Str::ucfirst(trans('crud.actions.duplicate')));
});
// * ACTIVITY_LOGS

View file

@ -53,16 +53,16 @@ class ClaimTest extends ApiBase
$response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge(
$this->skeleton,
[
'brand_id' => $brand->getKey(),
'subject_id' => $subject->getKey(),
'customer_id' => $customer->getKey(),
'brand_id' => $brand->getKey(),
'subject_id' => $subject->getKey(),
'hashcode' => $customer->hashcode,
]
));
$claimModel = Claim::query()->where([
['email', 'claim@hotmail.fr'],
['brand_id', $brand->getKey()],
['subject_id', $subject->getKey()],
['customer_id', $customer->getKey()],
['hashcode', $customer->hashcode],
])->exists();
$json = $response->decodeResponseJson();
$this->assertApiResponseStatusIs($json, ApiStatus::OK);
@ -72,7 +72,7 @@ class ClaimTest extends ApiBase
$claimModel = Claim::query()->where('email', 'claim@hotmail.fr')->firstOrFail();
$this->assertNotEmpty($claimModel->file, 'The "file" field is empty on the Claim model.');
$this->assertTrue(
Storage::exists(ltrim($claimModel->file, '/')),
Storage::disk('public')->exists(str_replace('storage/', '', $claimModel->file)),
"The file does not exist: {$claimModel->file}"
);
}
@ -90,9 +90,9 @@ class ClaimTest extends ApiBase
$response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge(
$this->skeleton,
[
'brand_id' => 0,
'subject_id' => 0,
'customer_id' => 0,
'brand_id' => 0,
'subject_id' => 0,
'hashcode' => null,
]
));
$json = $response->decodeResponseJson();
@ -122,7 +122,7 @@ class ClaimTest extends ApiBase
['email', 'claim@hotmail.fr'],
['brand_id', $brand->getKey()],
['subject_id', $subject->getKey()],
['customer_id', null],
['hashcode', null],
])->exists();
$json = $response->decodeResponseJson();
$this->assertApiResponseStatusIs($json, ApiStatus::OK);
@ -147,10 +147,10 @@ class ClaimTest extends ApiBase
$response = $this->callApiWithToken($service, 'post', route('apiV4.claim.store'), \array_merge(
Arr::except($this->skeleton, ['address', 'city', 'postcode', 'file']),
[
'file' => $base64Gif,
'brand_id' => $brand->getKey(),
'subject_id' => $subject->getKey(),
'customer_id' => $customer->getKey(),
'file' => $base64Gif,
'brand_id' => $brand->getKey(),
'subject_id' => $subject->getKey(),
'hashcode' => $customer->hashcode,
]
));
$json = $response->decodeResponseJson();

View file

@ -36,7 +36,7 @@ class CrmClientClaimTest extends CrmClientTester
$claimModel = ModelsClaim::query()->where('email', 'claim@hotmail.fr')->firstOrFail();
$this->assertNotEmpty($claimModel->file, 'The "file" field is empty on the Claim model.');
$this->assertTrue(
Storage::exists(ltrim($claimModel->file, '/')),
Storage::disk('public')->exists(str_replace('storage/', '', $claimModel->file)),
"The file does not exist: {$claimModel->file}"
);
}