From 89c5f19dfa1ece87ebda4ade084598b7985a082b Mon Sep 17 00:00:00 2001 From: Noah Lancien Date: Wed, 23 Aug 2023 10:38:11 +0000 Subject: [PATCH] Updated Settings Controller/Request/Blade and winnersList --- .../Controllers/Bo/SettingsController.php | 118 ++-- .../Controllers/Bo/WinnersListController.php | 117 +--- .../Bo/Settings/UpdateSettingsRequest.php | 105 ++++ app/Models/Settings.php | 30 + .../2020_10_12_123129_create_settings.php | 3 - ...020_10_28_091935_create_participations.php | 2 +- resources/lang/fr/models.php | 2 + resources/lang/fr/validation.php | 22 +- .../ts/bo/components/WebCouponsComponent.vue | 20 +- .../ts/bo/components/WinNotification.vue | 23 +- .../views/bo/instant-win/index.blade.php | 2 +- resources/views/bo/layouts/nav-menu.blade.php | 28 +- .../views/bo/pages/settings/edit.blade.php | 48 ++ .../bo/pages/settings/form-inputs.blade.php | 538 ++++++++++++++++++ .../views/bo/pages/settings/manage.blade.php | 350 ++++++++++++ .../bo/pages/winners-list/index.blade.php | 72 +++ .../bo/partials/inputs/int-number.blade.php | 3 + .../views/bo/winners-list/arcadia.blade.php | 31 - .../views/bo/winners-list/index.blade.php | 60 -- routes/breadcrumbs-bo.php | 10 + routes/web-bo.php | 11 +- 21 files changed, 1267 insertions(+), 328 deletions(-) create mode 100644 app/Http/Requests/Bo/Settings/UpdateSettingsRequest.php create mode 100644 resources/views/bo/pages/settings/edit.blade.php create mode 100644 resources/views/bo/pages/settings/form-inputs.blade.php create mode 100644 resources/views/bo/pages/settings/manage.blade.php create mode 100644 resources/views/bo/pages/winners-list/index.blade.php delete mode 100644 resources/views/bo/winners-list/arcadia.blade.php delete mode 100644 resources/views/bo/winners-list/index.blade.php diff --git a/app/Http/Controllers/Bo/SettingsController.php b/app/Http/Controllers/Bo/SettingsController.php index c193f18..2e3fff9 100644 --- a/app/Http/Controllers/Bo/SettingsController.php +++ b/app/Http/Controllers/Bo/SettingsController.php @@ -3,89 +3,55 @@ namespace App\Http\Controllers\Bo; use App\Http\Controllers\Controller; +use App\Http\Requests\Bo\Settings\UpdateSettingsRequest; use App\Models\Settings; -use Illuminate\Http\Request; -use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Cache; +use Illuminate\Support\Facades\DB; +use Illuminate\Support\Str; class SettingsController extends Controller { - public function manage(Request $request) + /** + * Show the form for editing the specified resource. + * + * @param \App\Models\Settings $settings + * @return \Illuminate\Contracts\View\View + */ + public function edit(Settings $settings): \Illuminate\Contracts\View\View { - /** @var \App\Models\Settings $settings */ - $settings = app(Settings::class); + return view('bo.pages.settings.edit', [ + 'settingsModel' => $settings + ]); + } - if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $name = $request->name; - $startDate = $request->start_date; - $endDate = $request->end_date; - $nbParticipationPlayer = $request->nb_participation_player; - $nbParticipationIp = $request->nb_participation_ip; - $nbUniqueCodeUse = $request->nb_unique_code_use; - $useEanCodes = $request->use_ean_codes === null ? 0 : 1; - $activatedTeaser = $request->activated_teaser === null ? 0 : 1; - $teaserEndActivity = $request->teaser_end_activity; - $activatedClosePage = $request->activated_close_page === null ? 0 : 1; - $closePageActiveDate = $request->close_page_active_date; - $redirectClose = $request->redirect_close; - $reductionsActivated = $request->reductions_activated === null ? 0 : 1; - $reductionsSite = $request->reductions_site; - $reductionsCampaign = $request->reductions_campaign; - $webCoupons = $request->web_coupons; - $facebookActivated = $request->facebook_activated === null ? 0 : 1; - $facebookAppId = $request->facebook_app_id; - $facebookSecret = $request->facebook_secret; - $notificationEmails = $request->notification_emails; - $winningProof = $request->winning_proof === null ? 0 : 1; - $company = $request->company; - $analytics = $request->analytics; - - // Check du lien de redirection après fermeture. - if (strpos($redirectClose, 'https://') === false && strpos($redirectClose, 'http://') === false) { - $redirectClose = 'https://' . $redirectClose; + /** + * Update the specified resource in storage. + * + * @param \App\Http\Requests\Bo\Settings\UpdateSettingsRequest $request + * @param \App\Models\Settings $settings + * @return \Illuminate\Http\RedirectResponse + */ + public function update(UpdateSettingsRequest $request, Settings $settings): \Illuminate\Http\RedirectResponse + { + return DB::transaction(function () use ($request, $settings) { + $settings->fill($request->validated()); + if ($settings->saveOrFail()) { + $settingsGlobal = app(Settings::class) + ->select('name', 'company', 'analytics', 'start_date', 'end_date')->first(); + Cache::put('settingsGlobal', $settingsGlobal); + return redirect() + ->route('bo.settings.edit', $settings) + ->with('success', trans( + 'crud.messages.has_been_updated', + ['model' => Str::singular(__('models.classes.settings'))] + )); } - - $settings->name = $name; - $settings->start_date = $startDate; - $settings->end_date = $endDate; - $settings->nb_participation_player = $nbParticipationPlayer; - $settings->nb_participation_ip = $nbParticipationIp; - $settings->nb_unique_code_use = $nbUniqueCodeUse; - $settings->use_ean_codes = $useEanCodes; - $settings->activated_teaser = $activatedTeaser; - if ($activatedTeaser === 1) { - $settings->teaser_end_activity = Carbon::parse($teaserEndActivity); - } - $settings->activated_close_page = $activatedClosePage; - if ($activatedClosePage === 1) { - $settings->close_page_active_date = Carbon::parse($closePageActiveDate); - } - $settings->redirect_close = $redirectClose; - $settings->reductions_activated = $reductionsActivated; - if ($reductionsActivated === 1) { - $settings->reductions_site = $reductionsSite; - $settings->reductions_campaign = $reductionsCampaign; - $settings->web_coupons = $webCoupons; - } - $settings->facebook_activated = $facebookActivated; - $settings->facebook_app_id = $facebookAppId; - $settings->facebook_secret = $facebookSecret; - $settings->notification_emails = $notificationEmails; - $settings->winning_proof = $winningProof; - $settings->company = $company; - $settings->analytics = $analytics; - - $settings->save(); - - $settingsGlobal = app(Settings::class) - ->select('name', 'company', 'analytics', 'start_date', 'end_date')->first(); - Cache::put('settingsGlobal', $settingsGlobal); - - $success = "Modifications enregistrés !"; - - return view('bo.settings.manage', compact('settings', 'success')); - }//end if - - return view('bo.settings.manage', compact('settings')); + return redirect() + ->back() + ->with('error', trans( + 'crud.messages.cannot_be_updated', + ['model' => Str::singular(__('models.classes.settings'))] + )); + }); } } diff --git a/app/Http/Controllers/Bo/WinnersListController.php b/app/Http/Controllers/Bo/WinnersListController.php index e464db4..d4dd72b 100644 --- a/app/Http/Controllers/Bo/WinnersListController.php +++ b/app/Http/Controllers/Bo/WinnersListController.php @@ -3,115 +3,34 @@ namespace App\Http\Controllers\Bo; use App\Http\Controllers\Controller; -use App\Mail\CourrierArcadiaError; use App\Models\Participation; use App\Models\Settings; use Illuminate\Http\Request; -use Illuminate\Support\Facades\Mail; class WinnersListController extends Controller { - private $apiCrm; - - public function __construct() + /** + * Display a listing of the resource. + * + * @param \Illuminate\Http\Request $request + * @return \Illuminate\Contracts\View\View + */ + public function index(Request $request): \Illuminate\Contracts\View\View { - $this->apiCrm = new \LDCCRM\ApiV1(config('crm.endpoint'), config('crm.token')); - } + /** @var \Illuminate\Database\Eloquent\Builder $rangeModels */ + $participationModels = Participation::has('instantWin'); - public function index() - { - $winnersList = Participation::has('instantWin')->get(); - $settings = Settings::select('use_ean_codes', 'winning_proof')->first(); - return view('bo.winners-list.index', compact('winnersList', 'settings')); - } + /** Sort columns with a query */ + $this->sortQuery($participationModels); - public function courrierArcadia($id) - { - $participation = Participation::findOrFail($id); + /** Custom pagination */ + $participationModels = $this->customPaginate($participationModels, $request->pagination); - $crmUser = $this->apiCrm->getCustomer($participation->user->crm_id); - if ($crmUser->status === 'NOK') { - return back()->withErrors("Erreur lors de la récupération de l'utilisateur dans la CRM : Code : " . - $crmUser->code . " Message : " . $crmUser->message); - } + $settings = Settings::select('use_ean_codes', 'winning_proof')->first(); - $crmId = $participation->user->crm_id; - - $crmUser = $crmUser->user; - - $corps = '' . "\n"; - $corps .= ' ' . "\n"; - $corps .= "\t" . '' . "\n"; - $corps .= "\t" . '' . date('d/m/Y') . '' . "\n"; - $corps .= "\t" . ' ' . "\n"; - $corps .= "\t" . '' . "\n"; - $corps .= "\t" . 'firstname) . ']]>' . "\n"; - $corps .= "\t" . 'lastname) . ']]>' . "\n"; - $corps .= "\t" . 'address) . ']]>' . "\n"; - $corps .= "\t" . 'address2) . ']]>' . "\n"; - $corps .= "\t" . 'postcode) . ']]>' . "\n"; - $corps .= "\t" . 'city) . ']]>' . "\n"; - $corps .= '' . "\n"; - $corps .= "\t" . ' ' . "\n"; - $corps .= "\t" . ' ' . "\n"; - $corps .= "\t" . '1' . "\n"; - $corps .= "\t" . '' . "\n"; - $corps .= '' . "\n"; - $corps .= ' ' . "\n"; - $corps .= ''; - - return view('bo.winners-list.arcadia', compact('participation', 'corps', 'crmId')); - } - - public function createCourrierArcadia(Request $request, $id) - { - $participation = Participation::findOrFail($id); - $instantWin = $participation->instantWin; - - if ($instantWin->prize->arcadia_operation_code !== 0 && $instantWin->prize->arcadia_support_code !== 0) { - $fields = [ - 'root' => [ - [ - 'fieldName' => 'order_date', - 'fieldValue' => date('d/m/Y') - ], - [ - 'fieldName' => 'operation', - 'fieldValue' => $instantWin->prize->arcadia_operation_code - ] - ], - 'orderLine' => [ - [ - 'fieldName' => 'code_unique', - 'fieldValue' => $participation->code->code_unique - ], - [ - 'fieldName' => 'support_code', - 'fieldValue' => $instantWin->prize->arcadia_support_code - ], - [ - 'fieldName' => 'label_type_support', - 'fieldValue' => 'Gain du lot : ' . $instantWin->prize->label_one - ] - ] - ]; - - /** @var \App\Models\Settings $settings */ - $settings = app(Settings::class); - if ($settings->use_ean_codes === 1) { - $fields['orderLine'][] = [ - 'fieldName' => 'code_on_pack', - 'fieldValue' => $participation->codeEan->code - ]; - } - - $arcadiaMail = $this->apiCrm->ArcadiaOutgoingMail($participation->user->crm_id, $fields, 'game'); - if ($arcadiaMail->status === 'NOK') { - Mail::to(config('mail.MAIL_ADMIN'))->send(new CourrierArcadiaError($participation->user)); - return back()->withErrors("Erreur lors de l'envoi du courrier Arcadia. Code : " . - $arcadiaMail->code . " Message : " . $arcadiaMail->message); - } - }//end if - return back()->with('success', 'Courrier envoyé !'); + return view('bo.pages.winners-list.index', compact( + 'participationModels', + 'settings' + )); } } diff --git a/app/Http/Requests/Bo/Settings/UpdateSettingsRequest.php b/app/Http/Requests/Bo/Settings/UpdateSettingsRequest.php new file mode 100644 index 0000000..c5c4521 --- /dev/null +++ b/app/Http/Requests/Bo/Settings/UpdateSettingsRequest.php @@ -0,0 +1,105 @@ +check(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation() + { + $this->merge([ + // Checkboxes. + 'use_ean_codes' => $this->use_ean_codes ? true : false, + 'activated_teaser' => $this->activated_teaser ? true : false, + 'activated_close_page' => $this->activated_close_page ? true : false, + 'reductions_activated' => $this->reductions_activated ? true : false, + 'winning_proof' => $this->winning_proof ? true : false, + // Arrays. + 'notification_emails' => $this->notification_emails ? json_decode($this->notification_emails, true) : [], + // Remove some dates if the checkbox is uncheck. + 'teaser_end_activity' => $this->activated_teaser ? $this->teaser_end_activity : null, + 'close_page_active_date' => $this->activated_close_page ? $this->close_page_active_date : null, + // Remove reductions datas if the reduction checkbox is uncheck. + 'reductions_site' => $this->reductions_activated ? $this->reductions_site : null, + 'reductions_campaign' => $this->reductions_activated ? $this->reductions_campaign : null, + 'web_coupons' => $this->reductions_activated ? + ($this->web_coupons ? json_decode($this->web_coupons, true) : []) : + [], + ]); + } + + /** + * Get the validation rules that apply to the request. + * + * @return array + */ + public function rules() + { + return [ + 'name' => 'required|string|min:3|max:255', + 'start_date' => 'required|date', + 'end_date' => 'required|date', + 'nb_participation_player' => 'required|numeric|min:0', + 'nb_participation_ip' => 'required|numeric|min:0', + 'nb_unique_code_use' => 'required|numeric|min:0', + 'use_ean_codes' => 'required|boolean', + 'activated_teaser' => 'required|boolean', + 'teaser_end_activity' => 'nullable|required_if:activated_teaser,true,1|date|after_or_equal:today', + 'activated_close_page' => 'required|boolean', + 'close_page_active_date' => 'nullable|required_if:activated_close_page,true,1|date|after_or_equal:today', + 'redirect_close' => 'required|url:http,https', + 'reductions_activated' => 'required|boolean', + 'reductions_site' => 'nullable|required_if:reductions_activated,true,1|string|min:3|max:255', + 'reductions_campaign' => 'nullable|required_if:reductions_activated,true,1|string|min:3|max:255', + 'web_coupons' => [ + 'nullable', + 'required_if:reductions_activated,true,1', + 'present', + // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInExtendedClassBeforeLastUsed + 'array', + ], + 'web_coupons.*' => 'nullable|array', + 'web_coupons.*.web_coupon_identifiant' => 'required|string|min:3|max:255', + 'web_coupons.*.percentage' => 'required|numeric|min:0|max:100', + 'web_coupons.*.face_value' => 'required|string|min:3|max:255', + 'web_coupons.*.valid_on' => 'required|string|min:3|max:255', + 'web_coupons.*.img_name' => 'required|string|min:3|max:255', + 'notification_emails' => 'nullable|array', + 'notification_emails.*' => 'nullable|array', + 'notification_emails.*.email' => 'required|email', + 'winning_proof' => 'required|boolean', + 'company' => 'required|string|min:3|max:255', + 'analytics' => 'nullable|numeric|min:1', + + ]; + } + + /** + * Get custom attributes for validator errors. + * + * @return array + */ + public function attributes(): array + { + return [ + 'name' => trans('Nom de la page de gain'), + 'file_name' => trans('Nom du fchier'), + ]; + } +} diff --git a/app/Models/Settings.php b/app/Models/Settings.php index b8da128..de0e8bd 100644 --- a/app/Models/Settings.php +++ b/app/Models/Settings.php @@ -6,6 +6,34 @@ use Illuminate\Database\Eloquent\Model; class Settings extends Model { + /** + * The attributes that are mass assignable. + * + * @var array + */ + protected $fillable = [ + 'name', + 'start_date', + 'end_date', + 'nb_participation_player', + 'nb_participation_ip', + 'nb_unique_code_use', + 'use_ean_codes', + 'activated_teaser', + 'teaser_end_activity', + 'activated_close_page', + 'close_page_active_date', + 'redirect_close', + 'reductions_activated', + 'reductions_site', + 'reductions_campaign', + 'web_coupons', + 'notification_emails', + 'winning_proof', + 'company', + 'analytics', + ]; + /** * The attributes that should be cast to native types. * @@ -14,5 +42,7 @@ class Settings extends Model protected $casts = [ 'start_date' => 'datetime', 'end_date' => 'datetime', + 'teaser_end_activity' => 'datetime', + 'close_page_active_date' => 'datetime', ]; } diff --git a/database/migrations/2020_10_12_123129_create_settings.php b/database/migrations/2020_10_12_123129_create_settings.php index f735076..8b3e7bf 100644 --- a/database/migrations/2020_10_12_123129_create_settings.php +++ b/database/migrations/2020_10_12_123129_create_settings.php @@ -33,9 +33,6 @@ class CreateSettings extends Migration $table->string('reductions_site')->nullable(); $table->string('reductions_campaign')->nullable(); $table->text('web_coupons')->nullable(); - $table->boolean('facebook_activated'); - $table->string('facebook_app_id')->nullable(); - $table->string('facebook_secret')->nullable(); $table->text('notification_emails')->nullable(); $table->boolean('winning_proof'); $table->string('company'); diff --git a/database/migrations/2020_10_28_091935_create_participations.php b/database/migrations/2020_10_28_091935_create_participations.php index fff21fe..fd83496 100644 --- a/database/migrations/2020_10_28_091935_create_participations.php +++ b/database/migrations/2020_10_28_091935_create_participations.php @@ -19,7 +19,7 @@ class CreateParticipations extends Migration $table->string('sticker')->nullable(); $table->string('ticket')->nullable(); $table->string('barcode')->nullable(); - $table->foreignId('user_id')->constrained('users'); + $table->foreignId('customer_id')->constrained('customers'); $table->foreignId('code_unique_id')->constrained('codes'); $table->foreignId('code_ean_id')->nullable()->constrained('code_eans'); $table->foreignId('reduction_id')->nullable()->constrained('reductions'); diff --git a/resources/lang/fr/models.php b/resources/lang/fr/models.php index b3fdc9e..cee0fc1 100644 --- a/resources/lang/fr/models.php +++ b/resources/lang/fr/models.php @@ -11,5 +11,7 @@ return [ 'prizes' => 'Lots', 'ranges' => 'Gammes', 'products' => 'Produits', + 'winners' => 'Gagnants', + 'settings' => 'Réglages', ] ]; diff --git a/resources/lang/fr/validation.php b/resources/lang/fr/validation.php index 6f30112..7a9f93a 100644 --- a/resources/lang/fr/validation.php +++ b/resources/lang/fr/validation.php @@ -192,7 +192,25 @@ return [ 'pdf_winning_proof' => 'pdf preuve de gain', 'need_proof' => 'preuve de gain obligatoire', 'picture' => 'illustration', - 'no_art' => 'Numéro d\'article', - 'ean_code' => 'Code EAN', + 'no_art' => 'numéro d\'article', + 'ean_code' => 'code EAN', + 'start_date' => 'date de début', + 'end_date' => 'date de fin', + 'nb_participation_player' => 'nombre de participation par joueur ', + 'nb_participation_ip' => 'nombre de participation par adresse IP', + 'nb_unique_code_use' => 'nombre d\'utilisation du code unique', + 'code_length' => 'longueur des code uniques', + 'use_ean_codes' => 'activer les codes EAN', + 'activated_teaser' => 'activation du teaser', + 'teaser_end_activity' => 'teaser actif jusqu\'au', + 'activated_close_page' => 'activation page de fermeture', + 'close_page_active_date' => 'page active jusqu\'au', + 'redirect_close' => 'url de redirection après la date de fin du jeu', + 'winning_proof' => 'activer les preuves de gain', + 'company' => 'société', + 'reductions_activated' => 'activer les bons de réduction', + 'reductions_site' => 'référence du site', + 'reductions_campaign' => 'référence de la campagne', + 'analytics' => 'analytics' ], ]; diff --git a/resources/ts/bo/components/WebCouponsComponent.vue b/resources/ts/bo/components/WebCouponsComponent.vue index fde4157..fe043c3 100644 --- a/resources/ts/bo/components/WebCouponsComponent.vue +++ b/resources/ts/bo/components/WebCouponsComponent.vue @@ -25,7 +25,7 @@ {{ index + 1 }} @@ -84,7 +84,8 @@ Poucentage total > 100% + > + Poucentage total › 100% ; + name: string, } { return { - datas: [] + datas: [], + name: "", }; }, watch: { @@ -139,7 +137,7 @@ export default defineComponent({ computed: { totalPercentage() { let total = 0; - this.datas.forEach(element => total += parseInt(String(element.percentage))); + this.datas.forEach((element: Record) => total += parseInt(String(element.percentage))); return total; } } diff --git a/resources/ts/bo/components/WinNotification.vue b/resources/ts/bo/components/WinNotification.vue index c3e68e0..8e87f92 100644 --- a/resources/ts/bo/components/WinNotification.vue +++ b/resources/ts/bo/components/WinNotification.vue @@ -67,28 +67,23 @@ diff --git a/resources/views/bo/instant-win/index.blade.php b/resources/views/bo/instant-win/index.blade.php index dfe98db..e8c7557 100644 --- a/resources/views/bo/instant-win/index.blade.php +++ b/resources/views/bo/instant-win/index.blade.php @@ -7,5 +7,5 @@ 'instantwin' => $instant_win ] @endphp -
+
@endsection diff --git a/resources/views/bo/layouts/nav-menu.blade.php b/resources/views/bo/layouts/nav-menu.blade.php index 7a023ec..d07c47b 100644 --- a/resources/views/bo/layouts/nav-menu.blade.php +++ b/resources/views/bo/layouts/nav-menu.blade.php @@ -10,11 +10,11 @@ @superadmin
@endsuperadmin - @endsuperadmin - @endauth - - {{-- FIXME A REMOVE ? --}} - {{-- {{ __('Social share') }} --}} diff --git a/resources/views/bo/pages/settings/edit.blade.php b/resources/views/bo/pages/settings/edit.blade.php new file mode 100644 index 0000000..1ea32e7 --- /dev/null +++ b/resources/views/bo/pages/settings/edit.blade.php @@ -0,0 +1,48 @@ +@extends('bo.layout', ['brParam' => $settingsModel]) + +@section('title', __('Édition d\'une :model', ['model' => Str::singular(__('models.classes.settings'))])) +@section('description', __('Édition d\'une :model déjà existante', ['model' => Str::singular(__('models.classes.settings'))])) +@section('breadcrumb', request()->route()->getName()) + +@section('content') +
+
+ @include('breadcrumbs.breadcrumb-body', ['brParam' => $settingsModel]) +
+
+
+ @csrf + @method('PUT') +
+ +
+
+
+
+
+ @csrf + @method('PUT') + @include('bo.pages.settings.form-inputs') +
+
+ +
+
+
+@endsection diff --git a/resources/views/bo/pages/settings/form-inputs.blade.php b/resources/views/bo/pages/settings/form-inputs.blade.php new file mode 100644 index 0000000..620b289 --- /dev/null +++ b/resources/views/bo/pages/settings/form-inputs.blade.php @@ -0,0 +1,538 @@ +
+ {{ __('Général') }}
+ {{ __('Paramètres généraux du jeu') }} +
+ +
+ {{-- NAME --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.name')) }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'settingsName', + 'label' => Str::ucfirst(__('validation.attributes.name')), + 'hasWordCounter' => true, + 'name' => 'name', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __(':field du jeu', [ + 'field' => Str::ucfirst(__('validation.attributes.name')), + ]), + 'min' => 3, + 'max' => 255 + ]), + 'placeholder' => __(':field du jeu', [ + 'field' => Str::ucfirst(__('validation.attributes.name')), + ]), + ]) +
+
+
+
+ {{-- START_DATE --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.start_date')) }} +
+
+ @include('bo.partials.inputs.timestamp-datetime', [ + 'id' => 'settingsStartDate', + 'label' => Str::ucfirst(__('validation.attributes.start_date')), + 'name' => 'start_date', + 'defaultValue' => true, + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('La date doit être supérieure ou égale à aujourd\'hui.'), + ]) +
+
+
+
+ {{-- END_DATE --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.end_date')) }} +
+
+ @include('bo.partials.inputs.timestamp-datetime', [ + 'id' => 'settingsEndDate', + 'label' => Str::ucfirst(__('validation.attributes.end_date')), + 'name' => 'end_date', + 'defaultValue' => true, + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('La date doit être supérieure ou égale à aujourd\'hui.'), + ]) +
+
+
+
+ {{-- NB_PARTICIPATION_PLAYER --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.nb_participation_player')) }} +
+
+ @include('bo.partials.inputs.int-number', [ + 'id' => 'settingsNbParticipationPlayer', + 'label' => Str::ucfirst(__('validation.attributes.nb_participation_player')), + 'name' => 'nb_participation_player', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.min.numeric', [ + 'attribute' => Str::ucfirst(__('validation.attributes.nb_participation_player')), + 'min' => 0 + ]), + 'min' => 0 + ]) +
+
+
+
+ {{-- NB_PARTICIPATION_IP --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.nb_participation_ip')) }} +
+
+ @include('bo.partials.inputs.int-number', [ + 'id' => 'settingsNbParticipationIp', + 'label' => Str::ucfirst(__('validation.attributes.nb_participation_ip')), + 'name' => 'nb_participation_ip', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.min.numeric', [ + 'attribute' => Str::ucfirst(__('validation.attributes.nb_participation_ip')), + 'min' => 0 + ]), + 'min' => 0 + ]) +
+
+
+
+ {{-- NB_UNIQUE_CODE_USE --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.nb_unique_code_use')) }} +
+
+ @include('bo.partials.inputs.int-number', [ + 'id' => 'settingsNbUniqueCodeUse', + 'label' => Str::ucfirst(__('validation.attributes.nb_unique_code_use')), + 'name' => 'nb_unique_code_use', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.min.numeric', [ + 'attribute' => Str::ucfirst(__('validation.attributes.nb_unique_code_use')), + 'min' => 0 + ]), + 'min' => 0 + ]) +
+
+
+
+ {{-- CODE_LENGTH --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.code_length')) }} +
+
+ @include('bo.partials.inputs.int-number', [ + 'id' => 'settingsCodeLength', + 'label' => Str::ucfirst(__('validation.attributes.code_length')), + 'name' => 'code_length', + 'required' => false, + 'disabled' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('Cette valeur ne doit pas varier en cours de jeu.'), + 'min' => 0 + ]) +
+
+
+
+ {{-- USE_EAN_CODES --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.use_ean_codes')) }} +
+
+ @include('bo.partials.inputs.tinyint-boolean', [ + 'id' => 'settingsUseEANCodes', + 'label' => Str::ucfirst(__('validation.attributes.use_ean_codes')), + 'name' => 'use_ean_codes', + 'required' => false, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.boolean', [ + 'attribute' => Str::ucfirst(__('validation.attributes.use_ean_codes')), + ]), + ]) +
+
+
+
+ {{-- ACTIVATED_TEASER --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.activated_teaser')) }} +
+
+ @include('bo.partials.inputs.tinyint-boolean', [ + 'id' => 'settingsActivatedTeaser', + 'label' => Str::ucfirst(__('validation.attributes.activated_teaser')), + 'name' => 'activated_teaser', + 'required' => false, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.boolean', [ + 'attribute' => Str::ucfirst(__('validation.attributes.activated_teaser')), + ]), + ]) +
+
+
+
+ {{-- TEASER_END_ACTIVITY --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.teaser_end_activity')) }} +
+
+ @include('bo.partials.inputs.timestamp-datetime', [ + 'id' => 'settingsTeaserEndActivity', + 'label' => Str::ucfirst(__('validation.attributes.teaser_end_activity')), + 'name' => 'teaser_end_activity', + 'defaultValue' => false, + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('La date doit être supérieure ou égale à aujourd\'hui.'), + ]) +
+
+
+
+ {{-- ACTIVATED_CLOSE_PAGE --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.activated_close_page')) }} +
+
+ @include('bo.partials.inputs.tinyint-boolean', [ + 'id' => 'settingsActivatedClosePage', + 'label' => Str::ucfirst(__('validation.attributes.activated_close_page')), + 'name' => 'activated_close_page', + 'required' => false, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.boolean', [ + 'attribute' => Str::ucfirst(__('validation.attributes.activated_close_page')), + ]), + ]) +
+
+
+
+ {{-- CLOSE_PAGE_ACTIVE_DATE --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.close_page_active_date')) }} +
+
+ @include('bo.partials.inputs.timestamp-datetime', [ + 'id' => 'settingsClosePageActiveDate', + 'label' => __('Page active jusqu\'au'), + 'name' => 'close_page_active_date', + 'defaultValue' => false, + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('La date doit être supérieure ou égale à aujourd\'hui.'), + ]) +
+
+
+
+ {{-- REDIRECT_CLOSE --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.redirect_close')) }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'settingsRedirectClose', + 'label' => __('URL de redirection après la date de fin du jeu'), + 'hasWordCounter' => true, + 'name' => 'redirect_close', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('crud.minicrud.url'), + 'placeholder' => 'https://example.test', + ]) +
+
+
+
+ {{-- WINNING_PROOF --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.winning_proof')) }} +
+
+ @include('bo.partials.inputs.tinyint-boolean', [ + 'id' => 'settingsReductionsActivated', + 'label' => Str::ucfirst(__('validation.attributes.winning_proof')), + 'name' => 'winning_proof', + 'required' => false, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.boolean', [ + 'attribute' => Str::ucfirst(__('validation.attributes.winning_proof')), + ]), + ]) +
+
+
+
+ {{-- COMPANY --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.company')) }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'settingsCompany', + 'label' => __('Nom de la :field', [ + 'field' => Str::ucfirst(__('validation.attributes.company')), + ]), + 'hasWordCounter' => true, + 'name' => 'company', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __('Nom de la :field', [ + 'field' => Str::ucfirst(__('validation.attributes.company')), + ]), + 'min' => 3, + 'max' => 255 + ]), + 'placeholder' => __(':field', [ + 'field' => Str::ucfirst(__('validation.attributes.company')), + ]), + ]) +
+
+
+
+
+ +
+
+ {{ __('Les réductions') }}
+ {{ __('Paramétrages des bons de réduction MLDC') }} +
+ +
+ {{-- REDUCTIONS_ACTIVATED --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.reductions_activated')) }} +
+
+ @include('bo.partials.inputs.tinyint-boolean', [ + 'id' => 'settingsReductionsActivated', + 'label' => Str::ucfirst(__('validation.attributes.reductions_activated')), + 'name' => 'reductions_activated', + 'required' => false, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.boolean', [ + 'attribute' => Str::ucfirst(__('validation.attributes.reductions_activated')), + ]), + ]) +
+
+
+
+ {{-- REDUCTIONS_SITE --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.reductions_site')) }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'settingsReductionsSite', + 'label' => __('validation.attributes.reductions_site'), + 'hasWordCounter' => true, + 'name' => 'reductions_site', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __('validation.attributes.reductions_site'), + 'min' => 3, + 'max' => 255 + ]), + 'placeholder' => __('validation.attributes.reductions_site'), + ]) +
+
+
+
+ {{-- REDUCTIONS_CAMPAIGN --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.reductions_campaign')) }} +
+
+ @include('bo.partials.inputs.varchar', [ + 'id' => 'settingsReductionsCampaign', + 'label' => __('validation.attributes.reductions_campaign'), + 'hasWordCounter' => true, + 'name' => 'reductions_campaign', + 'required' => true, + 'model' => $settingsModel ?? null, + 'helper' => __('validation.between.string', [ + 'attribute' => __('validation.attributes.reductions_campaign'), + 'min' => 3, + 'max' => 255 + ]), + 'placeholder' => __('validation.attributes.reductions_campaign'), + ]) +
+
+
+
+ {{-- WEB_COUPONS --}} + @php + $data = [ + 'dbdatas' => $settingsModel->web_coupons, + 'name' => 'web_coupons' + ] + @endphp +
+
+ +
+
+ {{ __('Destinataires des notifications de gain') }}
+ {{ __('Ces mails recevront toutes les notifications de gain.') }} +
+ +
+ {{-- NOTIFICATION_EMAILS --}} + @php + $data = [ + 'dbdatas' => $settingsModel->notification_emails, + 'name' => 'notification_emails' + ] + @endphp +
+
+ +
+
+ {{ __('Analytics') }}
+ {{ __('Saississez les informations permettant d\'établir des statistiques pour le jeu.') }} +
+ +
+ {{-- ANALYTICS --}} +
+
+ {{ Str::ucfirst(__('validation.attributes.analytics')) }} +
+
+ @include('bo.partials.inputs.int-number', [ + 'id' => 'settingsanalytics', + 'label' => Str::ucfirst(__('Site ID')), + 'name' => 'analytics', + 'required' => false, + 'model' => $settingsModel ?? null, + 'helper' => __('Insérer ici l\'id du site pour Matomo'), + 'min' => 0 + ]) +
+
+
+
+
+ +@push('scripts') + +@endpush diff --git a/resources/views/bo/pages/settings/manage.blade.php b/resources/views/bo/pages/settings/manage.blade.php new file mode 100644 index 0000000..67d6f81 --- /dev/null +++ b/resources/views/bo/pages/settings/manage.blade.php @@ -0,0 +1,350 @@ +@extends('bo.layout') + +@section('content') +
+
+ Règlages du jeu +
+ +
+ @method('PUT') + @csrf +
+
+
+
+ + +
+
+
+ Générale
+ Paramétres généraux du jeu +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + + +
+ + +
+ @if ($settings->use_ean_codes === 1) + + @else + + @endif + +
+
+ + +
+ @if ($settings->activated_teaser === 1) + + @else + + @endif + +
+
+ + + +
+ + +
+ @if ($settings->activated_close_page === 1) + + @else + + @endif + +
+
+ + + +
+ + + +
+ + +
+ @if ($settings->winning_proof === 1) + + @else + + @endif + +
+
+ + + +
+
+
+ Les réductions
+ Paramétrages des bons de réduction MLDC +
+
+ + + + + + + + + + + + + + + + + + +
+ + +
+ @if ($settings->reductions_activated === 1) + + @else + + @endif + +
+
+ + + +
+ + + +
+ +
+
+
+ Destinataires des notifications de gain
+ Ces mails recevront toutes les notifications de gain. +
+
+ +
+
+ Google analytics
+ Insérer ici la clé analytics pour le jeu. +
+ + + + + +
Clé analytics (eg: UA-XX196604-1)
+
+
+
+ +
+
+@endsection + +@push('scripts') + +@endpush diff --git a/resources/views/bo/pages/winners-list/index.blade.php b/resources/views/bo/pages/winners-list/index.blade.php new file mode 100644 index 0000000..3b2b745 --- /dev/null +++ b/resources/views/bo/pages/winners-list/index.blade.php @@ -0,0 +1,72 @@ +@extends('bo.layout') + +@section('title', __('models.classes.winners')) +@section('description', __('Liste de tous les :model', ['model' => __('models.classes.winners')])) + +@section('content') +
+ @include('breadcrumbs.breadcrumb-body') +
+ + @if (count($participationModels) > 0) + + @php + $cols = [ + 'created_at' => __('Date participation'), + 'prize' => __('Lot'), + 'email' => __('Email') + ]; + if ($settings->use_ean_codes === 1) { + $cols['code_ean_id'] = __('Code EAN'); + } + $cols['code_unique_id'] = __('Code unique'); + if ($settings->winning_proof === 1) { + $cols['sticker'] = __('Sticker'); + $cols['barcode'] = __('Code barre'); + $cols['ticket'] = __('Ticket'); + } + @endphp + @include('bo.modules.table-col-sorter', [ + 'cols' => $cols, + 'ignore' => ['sticker', 'barcode', 'ticket'] + ]) + + + @foreach ($participationModels as $participationModel) + + + + + @if ($settings->use_ean_codes) + + @endif + + @if ($settings->winning_proof === 1) + @if ($participationModel->sticker !== null) + + @else + + @endif + @if ($participationModel->barcode !== null) + + @else + + @endif + @if ($participationModel->ticket !== null) + + @else + + @endif + @endif + + + @endforeach + + @else + + + + @endif +
{{ \Carbon\Carbon::parse($participationModel->created_at)->format('d/m/Y à H:i') }}{{$participationModel->instantWin()->first()->prize->label_one}}{{$participationModel->user->email}}{{$participationModel->codeEan->code}}{{$participationModel->code->code_unique}}Voir-Voir-Voir-
{{ __('crud.other.no_model_found', ['model' => Str::singular(__('models.classes.winners'))]) }}
+{!! $participationModels->links() !!} +@endsection diff --git a/resources/views/bo/partials/inputs/int-number.blade.php b/resources/views/bo/partials/inputs/int-number.blade.php index cd2236b..efd20bd 100644 --- a/resources/views/bo/partials/inputs/int-number.blade.php +++ b/resources/views/bo/partials/inputs/int-number.blade.php @@ -32,6 +32,9 @@ @endif @if(!empty($required)) required + @endif + @if(!empty($disabled)) + disabled @endif> @if(isset($appendText)) diff --git a/resources/views/bo/winners-list/arcadia.blade.php b/resources/views/bo/winners-list/arcadia.blade.php deleted file mode 100644 index 4e73077..0000000 --- a/resources/views/bo/winners-list/arcadia.blade.php +++ /dev/null @@ -1,31 +0,0 @@ -@extends('bo.layout') - -@section('content') -
-
- Envoyer le courrier à Arcadia pour {{ $participation->user->lastname }} {{ $participation->user->firstname }} - Retour -
- -
-
- @csrf -
-
- ID CRM de l'utilisateur : {{ $crmId }} - -
-
-
- - -
- - -
-
-
-@endsection diff --git a/resources/views/bo/winners-list/index.blade.php b/resources/views/bo/winners-list/index.blade.php deleted file mode 100644 index 610daa8..0000000 --- a/resources/views/bo/winners-list/index.blade.php +++ /dev/null @@ -1,60 +0,0 @@ -@extends('bo.layout') - -@section('content') -
-
- Liste des gagnants -
- -
- - - - - - @if ($settings->use_ean_codes === 1) - - @endif - - @if ($settings->winning_proof === 1) - - - - @endif - - - - @foreach($winnersList as $winner) - - - - - @if ($settings->use_ean_codes) - - @endif - - @if ($settings->winning_proof === 1) - @if ($winner->sticker !== null) - - @else - - @endif - @if ($winner->barcode !== null) - - @else - - @endif - @if ($winner->ticket !== null) - - @else - - @endif - @endif - - - @endforeach - -
Date participationLotEmailCode EANCode uniqueStickerCode barreTicketArcadia
{{ \Carbon\Carbon::parse($winner->created_at)->format('d/m/Y à H:i') }}{{$winner->instantWin()->first()->prize->label_one}}{{$winner->user->email}}{{$winner->codeEan->code}}{{$winner->code->code_unique}}Voir-Voir-Voir-Envoyer
-
-
-@endsection diff --git a/routes/breadcrumbs-bo.php b/routes/breadcrumbs-bo.php index 9e538b4..638ac4f 100644 --- a/routes/breadcrumbs-bo.php +++ b/routes/breadcrumbs-bo.php @@ -124,3 +124,13 @@ Breadcrumbs::for('bo.products.edit', function (Generator $trail, Product $produc $trail->parent('bo.products.index'); $trail->push(__('crud.actions.edit'), route('bo.products.edit', $product->id)); }); + +// * SETTINGS +Breadcrumbs::for('bo.settings.edit', function (Generator $trail) { + $trail->push(__('models.classes.settings'), route('bo.products.index')); +}); + +// * WINNERS LIST +Breadcrumbs::for('bo.winners-list', function (Generator $trail) { + $trail->push(__('models.classes.winners'), route('bo.winners-list')); +}); diff --git a/routes/web-bo.php b/routes/web-bo.php index 86abfcb..8697449 100644 --- a/routes/web-bo.php +++ b/routes/web-bo.php @@ -66,6 +66,11 @@ Route::prefix('bo') Route::resource('products', ProductsController::class) ->except('show') ->withoutMiddleware('is-super-admin'); + // * SETTINGS. + Route::resource('/settings', SettingsController::class) + ->only(['edit', 'update']); + // * WINNERS LIST + Route::get('/winners-list', [WinnersListController::class, 'index'])->name('winners-list'); // TODO RESTE A FAIRE :. Route::get('/', [DashboardController::class, 'index']) @@ -81,11 +86,5 @@ Route::prefix('bo') Route::post('/codes', [CodesController::class, 'generate'])->name('generate-codes'); Route::get('/codes/search', [CodesController::class, 'search'])->name('codes.search'); Route::post('/codes/export', [CodesController::class, 'export'])->name('export-codes'); - // Liste des gagnants. - Route::get('/winners-list', [WinnersListController::class, 'index'])->name('winners-list'); - Route::get('/winners-list/arcadia/{id}', [WinnersListController::class, 'courrierArcadia']) - ->name('winners-arcadia'); - Route::post('/winners-list/arcadia/{id}/send', [WinnersListController::class, 'createCourrierArcadia']) - ->name('courrier-arcadia'); }); });