[WIP] Finish the order process

This commit is contained in:
Ludovic CANDELLIER
2022-08-18 18:20:44 +02:00
parent 01f56204b7
commit 1880b25407
28 changed files with 375 additions and 245 deletions

View File

@@ -12,13 +12,21 @@ class CustomersDataTable extends DataTable
public function query(Customer $model) public function query(Customer $model)
{ {
$model = $model->with('addresses');
return $this->buildQuery($model); return $this->buildQuery($model);
} }
protected function getColumns() protected function getColumns()
{ {
return [ return [
Column::make('company')->title('Société'),
Column::make('last_name')->title('Nom'), Column::make('last_name')->title('Nom'),
Column::make('first_name')->title('Prénom'),
Column::make('address')->title('Adresse'),
Column::make('zipcode')->title('Code postal'),
Column::make('city')->title('Ville'),
Column::make('phone')->title('Téléphone'),
Column::make('email')->title('Email'),
$this->makeColumnButtons(), $this->makeColumnButtons(),
]; ];
} }

View File

@@ -37,9 +37,9 @@ class CustomerController extends Controller
public function edit($id) public function edit($id)
{ {
$data['customer'] = Customers::edit($id); $data['customer'] = Customers::edit($id);
dump($data['customer']);
exit;
$data['deliveries'] = Deliveries::getOptions(); $data['deliveries'] = Deliveries::getOptions();
// dump($data);
// exit;
return view('Admin.Shop.Customers.edit', $data); return view('Admin.Shop.Customers.edit', $data);
} }

View File

@@ -37,7 +37,7 @@ class LoginController extends Controller
if ($this->guard()->attempt($credentials, $request->get('remember'))) { if ($this->guard()->attempt($credentials, $request->get('remember'))) {
$request->session()->regenerate(); $request->session()->regenerate();
return (back()->getTargetUrl() == route('Shop.login')) ? redirect()->intended(route('home')) : back(); return (back()->getTargetUrl() == route('Shop.login')) ? redirect()->intended(route('home')) : back();
} }
return back()->withInput($request->only('email', 'remember')); return back()->withInput($request->only('email', 'remember'));
} }

View File

@@ -29,8 +29,8 @@ class CustomerController extends Controller
// //
} }
public function profile($id) public function profile($id = false)
{ {
// return view('Shop.Profile.profile');
} }
} }

View File

@@ -16,17 +16,29 @@ class OrderController extends Controller
{ {
public function order() public function order()
{ {
$data['customer'] = Customers::getWithAddresses(); $data['customer'] = Customers::getWithAddresses()->toArray();
$data['basket'] = ShopCart::getSummary(); $data['basket'] = ShopCart::getSummary();
$data['deliveries'] = Deliveries::getAllWithSaleChannel()->toArray(); $data['deliveries'] = Deliveries::getAllWithSaleChannel()->toArray();
$data['sale_channel'] = SaleChannels::getDefault(); $data['sale_channel'] = SaleChannels::getDefault()->toArray();
return view('Shop.Orders.order', $data); return view('Shop.Orders.order', $data);
} }
public function store(Request $request) public function store(Request $request)
{ {
$data = $request->all(); $data = $request->all();
$data['customer_id'] = Customers::getId();
$data['basket'] = ShopCart::getSummary();
dump($data); dump($data);
exit; exit;
$order = Orders::saveOrder($data);
if ($order) {
if (intval($data['payment']) === 1) {
return redirect('Shop.Payments.online');
} else {
return redirect('Shop.Orders.confirmed');
}
} else {
return view('Shop.Orders.order');
}
} }
} }

View File

@@ -9,7 +9,7 @@ class Delivery extends Model
protected $guarded = ['id']; protected $guarded = ['id'];
protected $table = 'shop_deliveries'; protected $table = 'shop_deliveries';
public function Customers() public function customers()
{ {
return $this->hasMany(Customer::class); return $this->hasMany(Customer::class);
} }

View File

@@ -8,12 +8,12 @@ class Order extends Model
{ {
protected $guarded = ['id']; protected $guarded = ['id'];
public function Customer() public function customer()
{ {
return $this->belongsTo(Customer::class); return $this->belongsTo(Customer::class);
} }
public function Payments() public function payments()
{ {
return $this->hasMany(OrderPayment::class); return $this->hasMany(OrderPayment::class);
} }

View File

@@ -0,0 +1,15 @@
<?php
namespace App\Models\Shop;
use Illuminate\Database\Eloquent\Model;
class OrderDetail extends Model
{
protected $guarded = ['id'];
public function order()
{
return $this->belongsTo(Order::class);
}
}

View File

@@ -8,7 +8,7 @@ class OrderPayment extends Model
{ {
protected $guarded = ['id']; protected $guarded = ['id'];
public function Order() public function order()
{ {
return $this->belongsTo(Order::class); return $this->belongsTo(Order::class);
} }

View File

@@ -283,36 +283,7 @@ class Articles
public static function getInherited($id) public static function getInherited($id)
{ {
$article = Article::with('product.tags.tag_group')->findOrFail($id); $article = Article::with('product.tags.tag_group')->findOrFail($id);
$product_type = $article->product_type; return self::getInheritedByProduct($article->product_id, $article->product_type);
switch ($product_type) {
case 'App\Models\Botanic\Variety':
$data[] = [
'name' => 'Espèces',
'description' => Species::getDescription($article->product->specie_id),
'tags' => Species::getTags($article->product->specie_id),
];
$data[] = [
'name' => 'Variétés',
'description' => $article->product->description,
'tags' => $article->product->tags->toArray()
];
break;
case 'App\Models\Botanic\Specie':
$data[] = [
'name' => 'Espèces',
'description' => $article->product->description,
'tags' => $article->product->tags->toArray()
];
break;
case 'App\Models\Shop\Merchandise':
$data[] = [
'name' => 'Marchandise',
'description' => $article->product->description,
'tags' => $article->product->tags->toArray(),
];
break;
}
return $data ?? [];
} }
public static function getInheritedByProduct($product_id, $product_type) public static function getInheritedByProduct($product_id, $product_type)

View File

@@ -29,10 +29,11 @@ class Customers
$name = $customer->first_name . ' ' . $customer->last_name; $name = $customer->first_name . ' ' . $customer->last_name;
$avatar = new Avatar(); $avatar = new Avatar();
$ret = $avatar->create($name) $ret = $avatar->create($name)
->setBackground($bgColor) ->setBackground('#F2B90F')
->setBorder(1, '#29292e') ->setForeground('#335012')
->setBorder(1, '#28a745')
->setFontFamily('Roboto Condensed') ->setFontFamily('Roboto Condensed')
->setDimension(40) ->setDimension(36)
->setFontSize(16) ->setFontSize(16)
->save($filename); ->save($filename);
return $ret; return $ret;
@@ -42,7 +43,7 @@ class Customers
{ {
$path = storage_path(self::getStorage()); $path = storage_path(self::getStorage());
if (File::checkDirOrCreate($path)) { if (File::checkDirOrCreate($path)) {
$filename = $path . 'user-' . $customer->uuid . '.png'; $filename = $path . self::getAvatarFilename($customer);
} }
return $filename ?? false; return $filename ?? false;
} }
@@ -55,58 +56,44 @@ class Customers
public static function getAddresses($id = false) public static function getAddresses($id = false)
{ {
$customer = self::getWithAddresses($id); $customer = self::getWithAddresses($id);
return $customer ? $customer->addresses : false;
} }
public static function getWithAddresses($id = false) public static function getWithAddresses($id = false)
{ {
$id = $id ? $id : self::getId(); return self::get($id, 'addresses');
return Customer::with('addresses')->find($id);
} }
public static function getName() public static function getName($id = false)
{ {
$user = self::getAuth(); $user = $id ? self::get($id) : self::getAuth();
return $user ? $user->first_name : ''; return $user ? $user->first_name . ' ' . $user->last_name : '';
} }
public static function getAuth() public static function getAuth()
{ {
return Auth::guard('customer')->user(); return self::guard()->user();
} }
public static function getId() public static function getId()
{ {
return Auth::guard('customer')->id(); return self::guard()->id();
} }
public static function isConnected() public static function isConnected()
{ {
return Auth::guard('customer')->check(); return self::guard()->check();
} }
public static function getOptions() public static function get($id = false, $relations = false)
{ {
return Customer::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray(); $id = $id ? $id : self::getId();
} return $id ? ($relations ? Customer::with($relations)->findOrFail($id) : Customer::findOrFail($id)) : false;
public static function getOptionsByPackage($package_id)
{
return Customer::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray();
}
public static function getAll()
{
return Customer::orderBy('value', 'asc')->get();
}
public static function get($id)
{
return Customer::find($id);
} }
public static function edit($id) public static function edit($id)
{ {
$customer = Customer::with(['addresses'])->find($id); $customer = self::get($id, 'addresses');
$data = $customer->toArray(); $data = $customer->toArray();
$data['deliveries'] = $customer->deliveries->pluck('id')->toArray(); $data['deliveries'] = $customer->deliveries->pluck('id')->toArray();
return $data; return $data;
@@ -126,9 +113,7 @@ class Customers
public static function store($data) public static function store($data)
{ {
$id = $data['id'] ?? false; return ($data['id'] ?? false) ? self::update($data) : self::create($data);
$item = $id ? self::update($data, $id) : self::create($data);
return $item;
} }
public static function storeDeliveries($customer, $deliveries) public static function storeDeliveries($customer, $deliveries)
@@ -166,7 +151,7 @@ class Customers
return $customer; return $customer;
} }
public static function destroy($id) public static function delete($id)
{ {
return Customer::destroy($id); return Customer::destroy($id);
} }
@@ -182,4 +167,9 @@ class Customers
$path = '/storage/Customers/'; $path = '/storage/Customers/';
return $filename ? $path . $filename : $path; return $filename ? $path . $filename : $path;
} }
public static function guard()
{
return Auth::guard('customer');
}
} }

View File

@@ -0,0 +1,46 @@
<?php
namespace App\Repositories\Shop;
use App\Models\Shop\OrderDetail;
class OrderDetails
{
public static function saveBasket($order_id, $data)
{
foreach ($data as $item) {
$item['order_id'] = $order_id;
$detail = self::store($item);
}
return true;
}
public static function get($id, $relations = false)
{
return $relations ? OrderDetail::with($relations)->findOrFail($id) : OrderDetail::findOrFail($id);
}
public static function store($data)
{
return ($data['id'] ?? false) ? self::update($data) : self::create($data);
}
public static function create($data)
{
return OrderDetail::create($data);
}
public static function update($data, $id = false)
{
$id = $id ? $id : $data['id'];
$item = self::get($id);
$item->update($data);
return $item;
}
public static function delete($id)
{
return OrderDetail::destroy($id);
}
}

View File

@@ -6,31 +6,23 @@ use App\Models\Shop\Order;
class Orders class Orders
{ {
public static function getOptions()
public static function saveOrder($data)
{ {
return Order::orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray(); $basket = $data['basket'];
unset($data['basket']);
$order = self::store($data);
return $order ? OrderDetails::saveBasket($order->id, $basket) : false;
} }
public static function getOptionsByPackage($package_id) public static function get($id, $relations = false)
{ {
return Order::byPackage($package_id)->orderBy('value', 'asc')->get()->pluck('value', 'id')->toArray(); return $relations ? Order::with($relations)->findOrFail($id) : Order::findOrFail($id);
}
public static function getAll()
{
return Order::orderBy('value', 'asc')->get();
}
public static function get($id)
{
return Order::findOrFail($id);
} }
public static function store($data) public static function store($data)
{ {
$id = isset($data['id']) ? $data['id'] : false; return ($data['id'] ?? false) ? self::update($data) : self::create($data);
$item = $id ? self::update($data, $id) : self::create($data);
return $item->id;
} }
public static function create($data) public static function create($data)
@@ -46,7 +38,7 @@ class Orders
return $item; return $item;
} }
public static function destroy($id) public static function delete($id)
{ {
return Order::destroy($id); return Order::destroy($id);
} }

View File

@@ -23,7 +23,7 @@ class TagGroups
$data[$tag['tag_group_id']]['name'] = $tag_groups[$tag['tag_group_id']]; $data[$tag['tag_group_id']]['name'] = $tag_groups[$tag['tag_group_id']];
if (!$tag['articles_count']) { if (!$tag['articles_count']) {
continue; continue;
} }
$data[$tag['tag_group_id']]['tags'][] = [ $data[$tag['tag_group_id']]['tags'][] = [
'id' => $tag['id'], 'id' => $tag['id'],
'name' => $tag['name'], 'name' => $tag['name'],
@@ -72,8 +72,7 @@ class TagGroups
public static function store($data) public static function store($data)
{ {
$id = isset($data['id']) ? $data['id'] : false; $item = ($data['id'] ?? false) ? self::update($data) : self::create($data);
$item = $id ? self::update($data) : self::create($data);
return $item->id; return $item->id;
} }

View File

@@ -1,26 +1,73 @@
<div class="row"> <div class="row">
<div class="col-md-8"> <div class="col-md-8">
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6">
{{ Form::label('first_name', 'Prénom') }}
@include('components.form.input', ['name' => 'first_name', 'value' => $customer['first_name'] ?? null, 'required' => true])
</div>
<div class="col-6"> <div class="col-6">
{{ Form::label('last_name', 'Nom') }} {{ Form::label('last_name', 'Nom') }}
@include('components.form.input', ['name' => 'last_name', 'value' => $customer['last_name'] ?? null, 'required' => true]) @include('components.form.input', ['name' => 'last_name', 'value' => $customer['last_name'] ?? null, 'required' => true])
</div> </div>
<div class="col-6"> </div>
{{ Form::label('first_name', 'Prénom') }} <div class="row mb-3">
@include('components.form.input', ['name' => 'first_name', 'value' => $customer['first_name'] ?? null, 'required' => true]) <div class="col-12">
{{ Form::label('company', 'Société') }}
@include('components.form.input', ['name' => 'company', 'value' => $customer['company'] ?? null])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('tva', 'TVA') }}
@include('components.form.input', ['name' => 'tva', 'value' => $customer['tva'] ?? null])
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-6">
{{ Form::label('email', 'Email') }} {{ Form::label('email', 'Email') }}
@include('components.form.inputs.email', ['name' => 'email', 'value' => $customer['email'] ?? null, 'required' => true]) @include('components.form.input', ['name' => 'email', 'value' => $customer['email'] ?? null, 'required' => true])
</div> </div>
<div class="col-6">
{{ Form::label('phone', 'Téléphone') }}
@include('components.form.input', ['name' => 'phone', 'value' => $customer['phone'] ?? null])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('address', 'Adresse') }}
@include('components.form.input', ['name' => 'address', 'value' => $customer['address'] ?? null, 'required' => true])
</div>
</div>
<div class="row">
<div class="col-12">
{{ Form::label('address2', 'Adresse complémentaire') }}
@include('components.form.input', ['name' => 'address2', 'value' => $customer['address2'] ?? null])
</div>
</div>
<div class="row mb-3">
<div class="col-4">
{{ Form::label('zipcode', 'Code postal') }}
@include('components.form.input', ['name' => 'zipcode', 'value' => $customer['zipcode'] ?? null, 'required' => true])
</div>
<div class="col-8">
{{ Form::label('city', 'Ville') }}
@include('components.form.input', ['name' => 'city', 'value' => $customer['city'] ?? null, 'required' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-6"> <div class="col-6">
{{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }} {{ Form::label('sale_delivery_id', __('shop.deliveries.name')) }}
@include('components.form.select', ['name' => 'deliveries[]', 'list' => $deliveries ?? [], 'values' => $customer['deliveries'] ?? null, 'with_empty' => '', 'class' => 'select2', 'multiple' => true]) @include('components.form.select', ['name' => 'deliveries[]', 'list' => $deliveries ?? [], 'values' => $customer['deliveries'] ?? null, 'with_empty' => '', 'class' => 'select2', 'multiple' => true])
</div> </div>
</div> </div>
@include('components.address', ['with_country' => false, 'prefix' => 'addresses[0]', 'with_tab' => true, 'item' => $customer['addresses'][0]])
@if ($customer['addresses'])
@include('components.address', ['with_country' => false, 'prefix' => 'addresses[0]', 'with_tab' => true, 'item' => $customer['addresses'][0]])
@endif
</div> </div>
</div> </div>

View File

@@ -44,7 +44,7 @@
label: '{{ __('Commander') }}', label: '{{ __('Commander') }}',
className: 'btn-success', className: 'btn-success',
callback: function() { callback: function() {
// submitModal(form_id); window.location = "{{ route('Shop.Orders.order') }}";
} }
}, },
}; };

View File

@@ -6,11 +6,13 @@
Quantité : 1 Quantité : 1
</div> </div>
@include('components.form.button', [ @include('components.form.button', [
'class' => 'btn-green-dark basket semences mb-3 mt-2 shadow', 'class' => 'btn-green-dark basket semences mb-3 mt-2 shadow',
'txt' => 'Ajouter au panier', 'txt' => 'Ajouter au panier',
'data_id' => $article['semences']['offer_id'] ?? null,
]) ])
</div> </div>
@endif @endif
@if ($article['plants'] ?? false) @if ($article['plants'] ?? false)
<div class="w-100 mt-3 p-1 bg-yellow-light yellow-dark border border-warning text-center"> <div class="w-100 mt-3 p-1 bg-yellow-light yellow-dark border border-warning text-center">
<span style="font-size: 1.4em; font-weight: bold;">{{ $article['plants']['price'] ?? null }}</span> <br> <span style="font-size: 1.4em; font-weight: bold;">{{ $article['plants']['price'] ?? null }}</span> <br>
@@ -19,8 +21,9 @@
Quantité : 1 Quantité : 1
</div> </div>
@include('components.form.button', [ @include('components.form.button', [
'class' => 'btn-success basket semences mb-3 mt-2 shadow', 'class' => 'btn-success basket plants mb-3 mt-2 shadow',
'txt' => 'Ajouter au panier', 'txt' => 'Ajouter au panier',
'data_id' => $article['plants']['offer_id'] ?? null,
]) ])
</div> </div>
@endif @endif

View File

@@ -20,19 +20,22 @@
</x-layout.collapse> </x-layout.collapse>
@endif @endif
{{ Form::open(['route' => 'Admin.Shop.Orders.store', 'id' => 'order-form', 'autocomplete' => 'off']) }} {{ Form::open(['route' => 'Shop.Orders.store', 'id' => 'order-form', 'autocomplete' => 'off']) }}
<x-layout.collapse id="adresses" title="Adresses"> <div id="registred" @if (!App\Repositories\Shop\Customers::isConnected()) class="d-none" @endif>
<x-layout.collapse id="adresses" title="Adresses">
</x-layout.collapse> @include('Shop.Orders.partials.addresses')
</x-layout.collapse>
<x-layout.collapse id="delivery_mode" title="Mode de livraison"> <x-layout.collapse id="delivery_mode" title="Mode de livraison">
@include('Shop.Orders.partials.deliveries') @include('Shop.Orders.partials.deliveries')
</x-layout.collapse> </x-layout.collapse>
<x-layout.collapse id="payment" title="Paiement">
@include('Shop.Orders.partials.payments')
</x-layout.collapse>
</div>
<x-layout.collapse id="payment" title="Paiement">
@include('Shop.Orders.partials.payments')
</x-layout.collapse>
{!! Form::close() !!} {!! Form::close() !!}
</div> </div>

View File

@@ -0,0 +1,10 @@
@foreach ($addresses ?? [] as $address)
<div class="row">
<div class="col-1">
<x-form.radios.icheck name="address_id" val="{{ $address['id'] }}" id="address_{{ $address['id'] }}"/>
</div>
<div class="col-11">
</div>
</div>
@endforeach

View File

@@ -1,6 +1,6 @@
<div class="row"> <div class="row">
<div class="col-1"> <div class="col-1">
<x-form.radios.icheck name="payment" val="card" id="payment_card"/> <x-form.radios.icheck name="payment" val="1" id="payment_card"/>
</div> </div>
<div class="col-11"> <div class="col-11">
PAIEMENT PAR CARTE BANCAIRE PAIEMENT PAR CARTE BANCAIRE
@@ -9,7 +9,7 @@
<div class="row"> <div class="row">
<div class="col-1"> <div class="col-1">
<x-form.radios.icheck name="payment" val="check" id="payment_check"/> <x-form.radios.icheck name="payment" val="2" id="payment_check"/>
</div> </div>
<div class="col-11"> <div class="col-11">
PAIEMENT PAR CHEQUE PAIEMENT PAR CHEQUE
@@ -18,7 +18,7 @@
<div class="row"> <div class="row">
<div class="col-1"> <div class="col-1">
<x-form.radios.icheck name="payment" val="transfer" id="payment_transfer"/> <x-form.radios.icheck name="payment" val="3" id="payment_transfer"/>
</div> </div>
<div class="col-11"> <div class="col-11">
PAIEMENT PAR VIREMENT BANCAIRE PAIEMENT PAR VIREMENT BANCAIRE
@@ -27,7 +27,7 @@
<div class="row pt-5"> <div class="row pt-5">
<div class="col-1"> <div class="col-1">
<x-form.checkboxes.icheck name="agree" val="1"/> <x-form.checkboxes.icheck name="agree" val="1" required=true/>
</div> </div>
<div class="col-11"> <div class="col-11">
J'ai lu les conditions générales de vente et j'y adhère sans réserve J'ai lu les conditions générales de vente et j'y adhère sans réserve

View File

@@ -0,0 +1,8 @@
<div class="row">
<div class="col-4">
Livraison
</div>
<div class="col-8">
Mon nom
</div>
</div>

View File

@@ -2,4 +2,44 @@
@foreach ($articles as $product_name => $article) @foreach ($articles as $product_name => $article)
@include('Shop.Articles.partials.article_rows') @include('Shop.Articles.partials.article_rows')
@endforeach @endforeach
@endif @endif
@push('js')
<script>
$('.basket').click(function() {
var offer_id = $(this).data('id');
var quantity = 1;
var data = {
'offer_id': offer_id,
'quantity': quantity,
};
var buttons = {
cancel: {
label: '{{ __('Continuer mes achats') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('Commander') }}',
className: 'btn-success',
callback: function() {
// submitModal(form_id);
}
},
};
openModal(
'Ajout dans le panier',
'basket-form',
"{{ route('Shop.Basket.modalBasket') }}/" + offer_id + '/' + quantity,
"{{ route('Shop.Orders.order') }}",
"",
false,
true,
buttons,
"refreshBasketTop()",
);
});
</script>
@endpush

View File

@@ -38,3 +38,5 @@
</form> </form>
@endsection @endsection
@include('load.layout.modal')

View File

@@ -1,117 +1,117 @@
{!! Form::open(['route' => 'Shop.register.post', 'method' => 'post', 'autocomplete'=> 'off']) !!} {!! Form::open(['route' => 'Shop.register.post', 'method' => 'post', 'autocomplete'=> 'off']) !!}
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<x-card title='Créez votre compte' class='mt-3 mb-3'> <x-card title='Créez votre compte' class='mt-3 mb-3'>
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-6">
<div class="form-group {{ $errors->has('first_name') ? 'has-error' : '' }}"> <div class="form-group {{ $errors->has('first_name') ? 'has-error' : '' }}">
{{ Form::text('first_name', old('first_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.first_name'), 'required', 'autofocus']) }} {{ Form::text('first_name', old('first_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.first_name'), 'required', 'autofocus']) }}
{!! $errors->first('first_name','<p class="text-danger"><strong>:message</strong></p>') !!} {!! $errors->first('first_name','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
<div class="col-6">
<div class="form-group {{ $errors->has('last_name') ? 'has-error' : '' }}">
{{ Form::text('last_name', old('last_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.last_name'), 'required']) }}
{!! $errors->first('last_name','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div> </div>
</div> </div>
<div class="col-6"> <div class="row">
<div class="form-group {{ $errors->has('last_name') ? 'has-error' : '' }}"> <div class="col-12">
{{ Form::text('last_name', old('last_name'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.last_name'), 'required']) }} <div class="form-group {{ $errors->has('company') ? 'has-error' : '' }}">
{!! $errors->first('last_name','<p class="text-danger"><strong>:message</strong></p>') !!} {{ Form::text('company', old('company'), ['class' => 'form-control', 'placeholder' => __('Société'), 'autofocus']) }}
{!! $errors->first('company','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div> </div>
</div> </div>
</div> <div class="row">
<div class="row"> <div class="col-12">
<div class="col-12"> <div class="form-group {{ $errors->has('tva') ? 'has-error' : '' }}">
<div class="form-group {{ $errors->has('company') ? 'has-error' : '' }}"> {{ Form::text('tva', old('tva'), ['class' => 'form-control', 'placeholder' => __('N° de TVA'), 'autofocus']) }}
{{ Form::text('company', old('company'), ['class' => 'form-control', 'placeholder' => __('Société'), 'autofocus']) }} {!! $errors->first('tva','<p class="text-danger"><strong>:message</strong></p>') !!}
{!! $errors->first('company','<p class="text-danger"><strong>:message</strong></p>') !!} </div>
</div> </div>
</div> </div>
</div> <div class="row">
<div class="row"> <div class="col-6">
<div class="col-12"> <div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}">
<div class="form-group {{ $errors->has('tva') ? 'has-error' : '' }}"> {{ Form::email('email', old('email'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.email'), 'required']) }}
{{ Form::text('tva', old('tva'), ['class' => 'form-control', 'placeholder' => __('N° de TVA'), 'autofocus']) }} {!! $errors->first('email','<p class="text-danger"><strong>:message</strong></p>') !!}
{!! $errors->first('tva','<p class="text-danger"><strong>:message</strong></p>') !!} </div>
</div>
<div class="col-6">
<div class="form-group {{ $errors->has('phone') ? 'has-error' : '' }}">
{{ Form::text('phone', old('phone'), ['class' => 'form-control', 'placeholder' => __('phone')]) }}
{!! $errors->first('phone','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div> </div>
</div> </div>
</div>
<div class="row"> <div class="row">
<div class="col-6"> <div class="col-12">
<div class="form-group {{ $errors->has('email') ? 'has-error' : '' }}"> <div class="form-group {{ $errors->has('address') ? 'has-error' : '' }}">
{{ Form::email('email', old('email'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.email'), 'required']) }} {{ Form::text('address', old('address'), ['class' => 'form-control', 'placeholder' => __('Adresse de livraison'), 'required']) }}
{!! $errors->first('email','<p class="text-danger"><strong>:message</strong></p>') !!} {!! $errors->first('address','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div> </div>
</div> </div>
<div class="col-6">
<div class="form-group {{ $errors->has('phone') ? 'has-error' : '' }}"> <div class="row">
{{ Form::text('phone', old('phone'), ['class' => 'form-control', 'placeholder' => __('phone')]) }} <div class="col-12">
{!! $errors->first('phone','<p class="text-danger"><strong>:message</strong></p>') !!} <div class="form-group {{ $errors->has('address2') ? 'has-error' : '' }}">
{{ Form::text('address2', old('address2'), ['class' => 'form-control', 'placeholder' => __('Complément d\'adresse'), 'required']) }}
{!! $errors->first('address2','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div> </div>
</div> </div>
<div class="row">
<div class="col-4">
<div class="form-group {{ $errors->has('zipcode') ? 'has-error' : '' }}">
{{ Form::text('zipcode', old('zipcode'), ['class' => 'form-control', 'placeholder' => __('zipcode'), 'required']) }}
{!! $errors->first('zipcode','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
<div class="col-8">
<div class="form-group {{ $errors->has('city') ? 'has-error' : '' }}">
{{ Form::text('city', old('city'), ['class' => 'form-control', 'placeholder' => __('city'), 'required']) }}
{!! $errors->first('city','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="form-group {{ $errors->has('password') ? 'has-error' : '' }}">
{{ Form::password('password', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password'), 'required']) }}
{!! $errors->first('password','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
<div class="col-6">
<div class="form-group {{ $errors->has('password_confirmation') ? 'has-error' : '' }}">
{{ Form::password('password_confirmation', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password_confirm'), 'required']) }}
{!! $errors->first('password_confirmation','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
</div>
<div class="row">
<div class="col-12">
@include('components.form.checkbox', ['name' => 'use_for_invoice', 'value' => false])
Utiliser aussi cette adresse pour la facturation
</div>
</div>
</x-card>
<div class="row mbm">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">
<button type="submit" class="btn btn-primary">
{{ __('boilerplate::auth.register.register_button') }}
</button>
</div>
</div> </div>
<div class="row">
<div class="col-12">
<div class="form-group {{ $errors->has('address') ? 'has-error' : '' }}">
{{ Form::text('address', old('address'), ['class' => 'form-control', 'placeholder' => __('Adresse de livraison'), 'required']) }}
{!! $errors->first('address','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
</div>
<div class="row">
<div class="col-12">
<div class="form-group {{ $errors->has('address2') ? 'has-error' : '' }}">
{{ Form::text('address2', old('address2'), ['class' => 'form-control', 'placeholder' => __('Complément d\'adresse'), 'required']) }}
{!! $errors->first('address2','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
</div>
<div class="row">
<div class="col-4">
<div class="form-group {{ $errors->has('zipcode') ? 'has-error' : '' }}">
{{ Form::text('zipcode', old('zipcode'), ['class' => 'form-control', 'placeholder' => __('zipcode'), 'required']) }}
{!! $errors->first('zipcode','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
<div class="col-8">
<div class="form-group {{ $errors->has('city') ? 'has-error' : '' }}">
{{ Form::text('city', old('city'), ['class' => 'form-control', 'placeholder' => __('city'), 'required']) }}
{!! $errors->first('city','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
</div>
<div class="row">
<div class="col-6">
<div class="form-group {{ $errors->has('password') ? 'has-error' : '' }}">
{{ Form::password('password', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password'), 'required']) }}
{!! $errors->first('password','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
<div class="col-6">
<div class="form-group {{ $errors->has('password_confirmation') ? 'has-error' : '' }}">
{{ Form::password('password_confirmation', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password_confirm'), 'required']) }}
{!! $errors->first('password_confirmation','<p class="text-danger"><strong>:message</strong></p>') !!}
</div>
</div>
</div>
<div class="row">
<div class="col-12">
@include('components.form.checkbox', ['name' => 'use_for_invoice', 'value' => false])
Utiliser aussi cette adresse pour la facturation
</div>
</div>
</x-card>
<div class="row mbm">
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 text-center">
<button type="submit" class="btn btn-primary">
{{ __('boilerplate::auth.register.register_button') }}
</button>
</div>
</div> </div>
</div> </div>
</div>
{!! Form::close() !!} {!! Form::close() !!}

View File

@@ -2,9 +2,9 @@
<div class="col-12 text-right p-2"> <div class="col-12 text-right p-2">
<button type="button" class="btn bg-green-dark light" data-toggle="dropdown"> <button type="button" class="btn bg-green-dark light" data-toggle="dropdown">
@if (App\Repositories\Shop\Customers::isConnected()) @if (App\Repositories\Shop\Customers::isConnected())
<img src="{{ App\Repositories\Shop\Customers::getAvatar() }}" class="img-fluid"> <img src="{{ App\Repositories\Shop\Customers::getAvatar() }}" class="img-fluid" title="{{ App\Repositories\Shop\Customers::getName() }}">
@else @else
<i class="fa fa-2x fa-fw fa-user mr-2"></i> <i class="fa fa-2x fa-fw fa-user"></i>
@endif @endif
</button> </button>

View File

@@ -1,6 +1,6 @@
<button type="{{ $type ?? 'button' }}" class="btn {{ $class ?? ''}}" <button type="{{ $type ?? 'button' }}" class="btn {{ $class ?? ''}}"
@if (isset($id)) id="{{ $id }}"@endif @isset($id) id="{{ $id }}" @endisset
@if (isset($data_id)) data-id="{{ $data_id }}"@endif @isset($data_id) data-id="{{ $data_id }}" @endisset
{{ $metadata ?? null }} {{ $metadata ?? null }}
> >
@if ($icon ?? false)<i class="fa fa-fw {{ $icon ?? '' }}"></i>@endif @if ($icon ?? false)<i class="fa fa-fw {{ $icon ?? '' }}"></i>@endif

View File

@@ -59,7 +59,7 @@
bootbox.setLocale('{{ App::getLocale() }}'); bootbox.setLocale('{{ App::getLocale() }}');
var bpRoutes = { var bpRoutes = {
settings: "{{ route('boilerplate.settings', null, false) }}", settings: "{{ route('boilerplate.user.settings', null, false) }}",
} }
var session = { var session = {

View File

@@ -10,25 +10,20 @@
message: '<p><i class="fa fa-spin fa-spinner"></i> {{ __('loading') }} ...</p>', message: '<p><i class="fa fa-spin fa-spinner"></i> {{ __('loading') }} ...</p>',
size: size ? size : 'large', size: size ? size : 'large',
scrollable: true, scrollable: true,
onHide: function(e) {
console.log(status);
},
buttons: buildModalButtons(form_id, no_confirm, buttons) buttons: buildModalButtons(form_id, no_confirm, buttons)
}); });
dialog.init(function() { dialog.init(function() {
$.get(url_open, function(data) { $.get(url_open, function(data) {
console.log("OpenModal init");
dialog.find('.bootbox-body').html(data); dialog.find('.bootbox-body').html(data);
if (callback_after_loaded) { if (callback_after_loaded) {
eval(callback_after_loaded); eval(callback_after_loaded);
} }
// if ( typeOf(url_save) !== 'undefined') { if (typeof(url_save) !== 'undefined') {
handlePostModal(form_id,url_save, callback); handlePostModal(form_id,url_save, callback);
// } }
}); });
}); });
} }
function changeModalContent(dialog, url, callback) { function changeModalContent(dialog, url, callback) {
@@ -77,26 +72,15 @@
} }
function submitModal(form_id) { function submitModal(form_id) {
/*
var data = $(form_id).serialize();
$.post(url_save, data)
.done(function(data) {
if (callback) {
eval(callback);
}
});
*/
if (typeof(tinyMCE) != 'undefined') { if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave(); tinyMCE.triggerSave();
} }
var oForm = 'form' + form_id; $('form ' + form_id).submit();
$(oForm).submit();
status = 1; status = 1;
} }
function handlePostModal(form_id, url_save, callback) { function handlePostModal(form_id, url_save, callback) {
var oForm = 'form' + form_id; $('form ' + form_id).submit(function(e) {
$(oForm).submit(function(e) {
e.preventDefault(); e.preventDefault();
var formData = new FormData(this); var formData = new FormData(this);
$.ajax({ $.ajax({