Merge branch 'develop' into trunk
This commit is contained in:
commit
a6d0e1ae2d
14 changed files with 284 additions and 29 deletions
|
|
@ -40,6 +40,8 @@ class MagasinsController extends Controller
|
|||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email_contact' => 'required|email:rfc,dns,spoof|max:255',
|
||||
'email_confirm' => 'nullable|email:rfc,dns,spoof|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'postcode' => 'required',
|
||||
'city' => 'required|string|max:255',
|
||||
|
|
@ -73,6 +75,8 @@ class MagasinsController extends Controller
|
|||
{
|
||||
$request->validate([
|
||||
'name' => 'required|string|max:255',
|
||||
'email_contact' => 'required|email:rfc,dns,spoof|max:255',
|
||||
'email_confirm' => 'nullable|email:rfc,dns,spoof|max:255',
|
||||
'address' => 'required|string|max:255',
|
||||
'postcode' => 'required',
|
||||
'city' => 'required|string|max:255',
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ use App\Mail\OrderConfirmMail;
|
|||
use App\Mail\OrderConfirmAdminMail;
|
||||
use App\Jobs\CsvOrderWrite;
|
||||
use App\Models\Customers;
|
||||
use App\Models\OrdersStatus;
|
||||
use App\Models\Setting;
|
||||
use Carbon\Carbon;
|
||||
use Carbon\CarbonImmutable;
|
||||
use Carbon\CarbonInterval;
|
||||
use Gloudemans\Shoppingcart\Facades\Cart;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
|
|
@ -37,9 +39,33 @@ class OrdersController extends Controller
|
|||
{
|
||||
$orders = $this->filterOrders($request);
|
||||
|
||||
$status_orders = OrdersStatus::all();
|
||||
$magasins = Magasin::all();
|
||||
|
||||
$filter_status_order = $request->query('filter_status_order');
|
||||
$filter_magasin = $request->query('filter_magasin');
|
||||
$filter_reference = $request->query('filter_reference');
|
||||
|
||||
if (!empty($filter_status_order)) {
|
||||
$orders = $orders->where('status_id', $filter_status_order);
|
||||
}
|
||||
if (!empty($filter_magasin)) {
|
||||
$orders = $orders->whereHas(
|
||||
'timeslot',
|
||||
function (Builder $q) use ($filter_magasin) {
|
||||
$q->where('timeslots.magasin_id', $filter_magasin);
|
||||
}
|
||||
);
|
||||
}
|
||||
if (!empty($filter_reference)) {
|
||||
$orders = $orders->where('reference', 'like', "%{$filter_reference}%");
|
||||
}
|
||||
$orders = $orders->paginate(10);
|
||||
|
||||
return view('bo.orders.index', compact('orders'));
|
||||
return view(
|
||||
'bo.orders.index',
|
||||
compact('orders', 'status_orders', 'magasins', 'filter_status_order', 'filter_magasin', 'filter_reference')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -73,7 +99,6 @@ class OrdersController extends Controller
|
|||
{
|
||||
$orders = Order::query();
|
||||
|
||||
|
||||
if ($request->rst) {
|
||||
Session::remove('orders.sort_col');
|
||||
Session::remove('orders.sort_way');
|
||||
|
|
@ -110,7 +135,9 @@ class OrdersController extends Controller
|
|||
case 'customer_id':
|
||||
$orders = $orders->orderBy('customer_id', Session::get('orders.sort_way'));
|
||||
break;
|
||||
}//end switch
|
||||
} //end switch
|
||||
} else {
|
||||
$orders->orderByDesc('date');
|
||||
}//end if
|
||||
|
||||
return $orders;
|
||||
|
|
@ -486,6 +513,7 @@ class OrdersController extends Controller
|
|||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException If email missing.
|
||||
*/
|
||||
public function setTimeSlot(Request $request)
|
||||
{
|
||||
|
|
@ -495,7 +523,6 @@ class OrdersController extends Controller
|
|||
'ok_cgv' => 'accepted',
|
||||
]);
|
||||
|
||||
$time_slot = Carbon::createFromFormat('d/m/Y-H:i', $request->selectedcreneau);
|
||||
$tsday = explode('-', $request->selectedcreneau)[0];
|
||||
$tstime = explode('-', $request->selectedcreneau)[1];
|
||||
$magasin_id = $request->selectedmagasin;
|
||||
|
|
@ -520,12 +547,25 @@ class OrdersController extends Controller
|
|||
Mail::to($order->customer->email)->queue(new OrderConfirmMail($order));
|
||||
|
||||
// Envoi du mail de confirmation aux admins site.
|
||||
$toMailSetting = Setting::where('key', 'send_order_confirm_mail_to')->first();
|
||||
if (empty($toMailSetting->value)) {
|
||||
$toMail = config('mail.from.address');
|
||||
/** @var \App\Model\Magasin|null */
|
||||
$shop = Magasin::where('id', $magasin_id)->first();
|
||||
|
||||
if ($shop and $shop->email_confirm) {
|
||||
/** @var string */
|
||||
$toMail = $shop->email_confirm;
|
||||
} else {
|
||||
$toMail = $toMailSetting->value;
|
||||
/** @var string|null */
|
||||
$toMail = \optional(Setting::where('key', 'send_order_confirm_mail_to')->first())->value;
|
||||
if (!$toMail) {
|
||||
/** @var string|null */
|
||||
$toMail = config('mail.from.address');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$toMail) {
|
||||
throw new \RuntimeException('Impossible de trouver un mail');
|
||||
}
|
||||
|
||||
Mail::to($toMail)->queue(new OrderConfirmAdminMail($order));
|
||||
|
||||
// Export commande.
|
||||
|
|
|
|||
|
|
@ -25,11 +25,12 @@ class ContactController extends Controller
|
|||
// @phpcs:enable
|
||||
$status = $request->session()->get('status');
|
||||
|
||||
// 1er magasin en base pour le moment
|
||||
$magasin = Magasin::first();
|
||||
$magasin = Magasin::first();
|
||||
$magasins = Magasin::all();
|
||||
|
||||
$content = Content::where('key', 'contact')->first();
|
||||
|
||||
return view('contact', compact('status', 'magasin', 'content'));
|
||||
return view('contact', compact('status', 'magasins', 'magasin', 'content'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -37,17 +38,29 @@ class ContactController extends Controller
|
|||
*
|
||||
* @param ContactFormRequest $request
|
||||
* @return \Illuminate\Http\Response
|
||||
* @throws \RuntimeException If email missing.
|
||||
*/
|
||||
public function contactSubmit(ContactFormRequest $request)
|
||||
{
|
||||
$data = $request->all();
|
||||
/** @var \App\Model\Magasin|null */
|
||||
$shop = Magasin::where('name', $request->shop)->first();
|
||||
|
||||
$toMailSetting = Setting::where('key', 'send_contact_mail_to')->first();
|
||||
if (empty($toMailSetting->value)) {
|
||||
$toMail = config('mail.from.address');
|
||||
if ($shop and $shop->email_contact) {
|
||||
/** @var string */
|
||||
$toMail = $shop->email_contact;
|
||||
} else {
|
||||
$toMail = $toMailSetting->value;
|
||||
/** @var string|null */
|
||||
$toMail = \optional(Setting::where('key', 'send_contact_mail_to')->first())->value;
|
||||
if (!$toMail) {
|
||||
/** @var string|null */
|
||||
$toMail = config('mail.from.address');
|
||||
}
|
||||
}
|
||||
|
||||
if (!$toMail) {
|
||||
throw new \RuntimeException('Impossible de trouver un mail');
|
||||
}
|
||||
|
||||
// Envoi du mail d'alerte.
|
||||
Mail::to($toMail)->send(new SendContactMail($request));
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
|||
use App\Http\Requests\CustomerRegisterRequest;
|
||||
use App\Http\Requests\LoginRequest;
|
||||
use App\Http\Requests\UpdateInfosRequest;
|
||||
use App\Mail\OrderCanceledConfirmMail;
|
||||
use App\Mail\PasswordResetMail;
|
||||
use App\Mail\RegisterConfirmMail;
|
||||
use App\Models\Customers;
|
||||
|
|
@ -12,6 +13,7 @@ use App\Models\Magasin;
|
|||
use App\Models\Order;
|
||||
use App\Models\PasswordReset;
|
||||
use App\Models\Salarie;
|
||||
use App\Models\Setting;
|
||||
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
|
@ -455,6 +457,40 @@ class CustomerController extends Controller
|
|||
return view('customer.order-detail', compact('order', 'magasin'));
|
||||
}
|
||||
|
||||
/**
|
||||
* mise au statut annulé d'une commande
|
||||
*
|
||||
* @param string $reference
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* @throws \RuntimeException If email missing.
|
||||
*/
|
||||
public function cancelOrder(string $reference)
|
||||
{
|
||||
/** @var \App\Models\Order|null */
|
||||
$order = Order::where('reference', $reference)->first();
|
||||
if (!$order) {
|
||||
throw new \RuntimeException('Impossible de trouver un enregistrement Order');
|
||||
}
|
||||
$order->status_id = 7;
|
||||
$order->save();
|
||||
|
||||
// Envoi du mail d'annulation aux admins site.
|
||||
/** @var string|null */
|
||||
$toMail = \optional(Setting::where('key', 'send_order_confirm_mail_to')->first())->value;
|
||||
if (!$toMail) {
|
||||
/** @var string|null */
|
||||
$toMail = config('mail.from.address');
|
||||
}
|
||||
|
||||
if (!$toMail) {
|
||||
throw new \RuntimeException('Impossible de trouver un mail');
|
||||
}
|
||||
|
||||
Mail::to($toMail)->queue(new OrderCanceledConfirmMail($order));
|
||||
|
||||
return back()->with('success', "La commande " . $order->reference . " à été annulée.");
|
||||
}
|
||||
|
||||
/**
|
||||
* delete customers
|
||||
*
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ class ContactFormRequest extends FormRequest
|
|||
'last_name' => 'required|min:2',
|
||||
'first_name' => 'required|min:2',
|
||||
'email' => 'required|email:rfc,dns,spoof',
|
||||
'shop' => 'present|nullable|string|exists:magasins,name',
|
||||
'subject' => 'required|min:2',
|
||||
'order_ref' => 'sometimes',
|
||||
'message' => 'required|min:20|max:1900',
|
||||
|
|
@ -46,6 +47,7 @@ class ContactFormRequest extends FormRequest
|
|||
'ok_cgv.accepted' => __('You must accept the terms and conditions and the privacy policy'),
|
||||
'file.max' => __('La taille du fichier ne peut pas dépasser :max kilo-octets.'),
|
||||
'file.mimes' => __('Le fichier doit être de type : :values.'),
|
||||
'shop.exists' => __('Le magasin :exists est introuvable.')
|
||||
];
|
||||
}
|
||||
}
|
||||
|
|
|
|||
47
app/Mail/OrderCanceledConfirmMail.php
Normal file
47
app/Mail/OrderCanceledConfirmMail.php
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use App\Models\Order;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Mail\Mailable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class OrderCanceledConfirmMail extends Mailable
|
||||
{
|
||||
use Queueable;
|
||||
use SerializesModels;
|
||||
|
||||
/**
|
||||
* The Order
|
||||
*
|
||||
* @var \App\Models\Order
|
||||
*/
|
||||
private $order;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*
|
||||
* @param \App\Models\Order $order
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(Order $order)
|
||||
{
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the message.
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function build()
|
||||
{
|
||||
$order = $this->order;
|
||||
|
||||
return $this->subject(
|
||||
"Commande " . config('theme.site_name') . " n°" . $order->reference . " a été annulée."
|
||||
)->view('mails.order-canceled-confirm', compact('order'));
|
||||
}
|
||||
}
|
||||
|
|
@ -15,7 +15,7 @@ class Magasin extends Model
|
|||
* @var array
|
||||
*/
|
||||
protected $fillable = [
|
||||
'name', 'address', 'postcode', 'city', 'phone',
|
||||
'name', 'email_contact', 'email_confirm', 'address', 'postcode', 'city', 'phone',
|
||||
'latitude', 'longitude',
|
||||
'gmaps_placeid', 'gmaps_embed_href', 'gmaps_link_href',
|
||||
];
|
||||
|
|
|
|||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
class AddFieldToMagasins extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('magasins', function (Blueprint $table) {
|
||||
$table->string('email_contact')->after('name');
|
||||
$table->string('email_confirm')->nullable()->after('email_contact');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('magasins', function (Blueprint $table) {
|
||||
$table->dropColumn('email_contact');
|
||||
$table->dropColumn('email_confirm');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -14,13 +14,14 @@ class MagasinsSeeder extends Seeder
|
|||
*/
|
||||
public function run()
|
||||
{
|
||||
$shop = new Magasin();
|
||||
$shop->name = 'Point de retrait';
|
||||
$shop->address = 'l\'adresse';
|
||||
$shop->postcode = '72000';
|
||||
$shop->city = 'Le Mans';
|
||||
$shop = new Magasin();
|
||||
$shop->name = 'Point de retrait';
|
||||
$shop->email_contact = 'adresse@domaine.fr';
|
||||
$shop->address = 'l\'adresse';
|
||||
$shop->postcode = '72000';
|
||||
$shop->city = 'Le Mans';
|
||||
$shop->gmaps_embed_href = "https://www.google.com/maps/embed?pb=!1m18!1m12!1m3!1d5338.425979915083!2d0.1977634707405403!3d48.00959481914027!2m3!1f0!2f0!3f0!3m2!1i1024!2i768!4f13.1!3m3!1m2!1s0x47e288cfcdc1a263%3A0x7acf6d8dc923c25a!2zQ2l0w6kgUGxhbnRhZ2Vuw6p0!5e0!3m2!1sfr!2sfr!4v1619612657653!5m2!1sfr!2sfr";
|
||||
$shop->gmaps_link_href = 'https://goo.gl/maps/sxuj7FevRSHsDb8MA';
|
||||
$shop->gmaps_link_href = 'https://goo.gl/maps/sxuj7FevRSHsDb8MA';
|
||||
$shop->save();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,20 @@
|
|||
<label for="name">Nom *</label>
|
||||
<input type="text" id="name" name="name" class="form-control" placeholder="Nom *" value="{{ old('name') }}" required>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label>Email de contact *</label>
|
||||
<input type="email" id="email_contact" name="email_contact" class="form-control" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="adresse@pole-sbv.fr *" value="{{ old('email_contact') }}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label>Email de confirmation de commande</label>
|
||||
<input type="email" id="email_confirm" name="email_confirm" class="form-control" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="adresse@pole-sbv.fr" value="{{ old('email_confirm') }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Adresse *</label>
|
||||
<input type="text" id="address" name="address" class="form-control" placeholder="Adresse *" value="{{ old('address') }}" required>
|
||||
|
|
|
|||
|
|
@ -31,6 +31,20 @@
|
|||
<a class="btn btn-sm btn-primary" href="{{route('bo.creneaux.settings', $magasin->id)}}">Editer Créneaux de collecte</a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label>Email de contact *</label>
|
||||
<input type="email" id="email_contact" name="email_contact" class="form-control" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="adresse@pole-sbv.fr *" value="{{ old('email_contact',$magasin->email_contact) }}" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<div class="form-group">
|
||||
<label>Email de confirmation de commande</label>
|
||||
<input type="email" id="email_confirm" name="email_confirm" class="form-control" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$" placeholder="adresse@pole-sbv.fr" value="{{ old('email_confirm',$magasin->email_confirm) }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Adresse *</label>
|
||||
<input type="text" id="address" name="address" class="form-control" placeholder="Adresse *" value="{{ old('address',$magasin->address) }}" required>
|
||||
|
|
|
|||
|
|
@ -14,9 +14,11 @@
|
|||
<table class="table">
|
||||
<thead>
|
||||
<th scope="col"></th>
|
||||
<th scope="col">Nom</th>
|
||||
<th scope="col">Adresse</th>
|
||||
<th scope="col">Téléphone</th>
|
||||
<th scope="col">{{ __('Nom') }}</th>
|
||||
<th scope="col">{{ __('Email de contact') }}</th>
|
||||
<th scope="col">{{ __('Email de confirmation') }}<br>{{ __('de commande') }}</th>
|
||||
<th scope="col">{{ __('Adresse') }}</th>
|
||||
<th scope="col">{{ __('Téléphone') }}</th>
|
||||
<th scope="col"></th>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
|
@ -24,6 +26,8 @@
|
|||
<tr>
|
||||
<td></td>
|
||||
<td>{{$magasin->name}}</td>
|
||||
<td>{{$magasin->email_contact}}</td>
|
||||
<td>{{$magasin->email_confirm}}</td>
|
||||
<td>{{$magasin->address}}, {{$magasin->postcode}} {{$magasin->city}}</td>
|
||||
<td>{{$magasin->phone}}</td>
|
||||
<td class="text-center">
|
||||
|
|
|
|||
|
|
@ -1,10 +1,55 @@
|
|||
@extends('layouts.bo-layout')
|
||||
|
||||
@section('content')
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">Commandes @if (isset($today)) à retirer aujourd'hui @endif</h1>
|
||||
<div class="d-flex flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2 pe-5">{{ __('Commandes') }} @if (isset($today)) <br>{{ __('à retirer aujourd\'hui') }} @endif</h1>
|
||||
|
||||
<form method="GET">
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<label for="filter_status_order" class="col-form-label">Etat de commande</label>
|
||||
<div class="col">
|
||||
<select class="form-control" id="filter_status_order" name="filter_status_order">
|
||||
<option value="" @if ($filter_status_order == '') selected @endif>Tous</option>
|
||||
@foreach($status_orders as $status_order)
|
||||
<option value="{{$status_order->id}}" @if ($status_order->id == $filter_status_order) selected @endif>{{$status_order->label}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<label for="filter_magasin" class="col-form-label">Lieu de retrait</label>
|
||||
<div class="col">
|
||||
<select class="form-control" id="filter_magasin" name="filter_magasin">
|
||||
<option value="" @if ($filter_magasin == '') selected @endif>Tous</option>
|
||||
@foreach($magasins as $magasin)
|
||||
<option value="{{$magasin->id}}" @if ($magasin->id == $filter_magasin) selected @endif>{{$magasin->name}}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<div class="row align-items-end">
|
||||
<div class="col-6">
|
||||
<label for="filter_reference" class="col-form-label">Référence commande</label>
|
||||
<div class="col">
|
||||
<input class="form-control" type="text"
|
||||
placeholder="Référence commande"
|
||||
id="filter_reference" name="filter_reference"
|
||||
value="{{ $filter_reference ?? ''}}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<button class="btn btn-primary">Filtrer</button>
|
||||
<a class="btn btn-info" href="{{ route('bo.orders') }}">Effacer le filtre</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@if (session('success'))
|
||||
<span class="float-center text-success">{{ session('success') }}</span>
|
||||
<span class="float-center text-success ms-3">{{ session('success') }}</span>
|
||||
@endif
|
||||
</div>
|
||||
<table class="table">
|
||||
|
|
|
|||
|
|
@ -222,6 +222,7 @@ Route::name('account.')
|
|||
)->name('change-password');
|
||||
Route::get('/commandes', [CustomerController::class, 'myOrders'])->name('my-orders');
|
||||
Route::get('/commandes/{reference}', [CustomerController::class, 'orderDetail'])->name('order-detail');
|
||||
Route::get('/commandes/{reference}/annuler', [CustomerController::class, 'cancelOrder'])->name('cancel-order');
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue