ldc-crm/resources/views/customer/index.blade.php
Jérémy Munsch f4c60bf6f7
Ticket 698 :
- Npm audit Fix + update
- Fix filter search and reset on customers.index
2022-03-28 16:22:33 +02:00

103 lines
4.8 KiB
PHP

@extends('layouts.app')
@section('title', sprintf('%s - %s', Str::ucfirst(Str::plural(trans('models.classes.customers'))), __('crud-policies::crud.viewAny')))
@section('description', sprintf('%s %s', __('crud-policies::crud.viewAny'), Str::ucfirst(Str::plural(trans('models.classes.customers')))))
@section('metaIndex', 'noindex,nofollow')
@section('content')
<div class="card">
@include('crud-policies::crud.modules.flashMessage')
<div class="card-header">
@include('crud-policies::crud.modules.breadcrumb', ['action' => CrudAction::viewAny()])
@include('crud-policies::crud.modules.actionbar.bar', ['action' => CrudAction::viewAny()])
</div>
<div class="card-body">
<div class="row justify-content-center">
<div class="col">
<form action="{{ request()->fullUrlWithQuery(['rst' => null]) }}">
<div class="input-group mb-3">
<label class="input-group-text" for="brandSelect">{{ __('Filter par Marque') }}</label>
<select class="form-select" id="brandSelect">
<option value="0" @if(!request()->brand) selected @endif>{{ __('Sélectionnez une marque..') }}</option>
@foreach(Brand::all() as $brand)
<option value="{{ $brand->id }}" @if(request()->brand == "$brand->id" or Session::get("crud.$modelTable.brand") == $brand->id) selected @endif>{{ $brand->name }}</option>
@endforeach
</select>
<label class="input-group-text bg-warning" for="searchField">🔍🠚</label>
<input type="search" id="searchField" name="search" class="form-control" value="{{ request()->search ?? Session::get("crud.$modelTable.search") }}" placeholder="Recherche.."/>
<input type="text" name="sort_col" class="d-none" value="{{ request()->sort_col }}"/>
<input type="text" name="sort_way" class="d-none" value="{{ request()->sort_way }}"/>
@if(request()->brand)
<input type="hidden" name="brand" class="d-none" value="{{ request()->brand }}"/>
@endif
<a class="btn btn-danger" href="{{ request()->fullUrlWithQuery(['rst' => 'true', 'search' => null, 'brand' => null]) }}">{{ __('crud-policies::crud.reset') }}</a>
<button type="submit" class="btn btn-primary">
{{ __('crud-policies::crud.search') }}
</button>
</div>
</form>
</div>
</div>
{{ $customers->appends(Request::except('rst'))->links() }}
<table class="table text-center">
<thead class="thead-dark">
<tr>
@include('customer.index-tableHeaders')
</tr>
</thead>
<tbody>
@if(count($customers))
{{-- DISPLAY MODELS --}}
@foreach($customers as $customerInfo)
<tr>
<td>
{{ $customerInfo->customer->email }}
</td>
<td>
{{ $customerInfo->firstname }}
</td>
<td>
{{ $customerInfo->lastname }}
</td>
<td>
{{ $customerInfo->opt_in ? 'Oui' :'Non' }}
</td>
<td>
{{ $customerInfo->brand->name }}
</td>
<td>
{{ $customerInfo->status ? 'Oui' :'Non' }}
</td>
<td>
{{ $customerInfo->last_connection }}
</td>
{{-- MODEL ACTIONS --}}
<td>
<div class="btn-group" role="group" aria-label="{{ Str::plural(__('crud-policies::crud.action')) }}">
@can('view', $customerInfo->customer)
<a href="{{ CrudController::getRoutePrefixed("customers.show", [
'customer' => $customerInfo->customer_id,
'brand' => $customerInfo->brand_id
]) }}" class="btn btn-sm btn-primary">{{ __('crud-policies::crud.view') }}</a>
@endcan
</div>
</td>
</tr>
@endforeach
@else
<tr>
<td colspan="5">
{{ __('crud-policies::crud.nothingtoshow') }}
</td>
</tr>
@endif
</tbody>
</table>
{{ $customers->appends(Request::except('rst'))->links() }}
</div>
</div>
@include('crud-policies::crud.modules.scriptConstants')
@endsection