fixes on mail templates, change order edit layout, add DeliveryTypes, DeliveryTypeCalculations & DeliveryPackages
This commit is contained in:
@@ -27,6 +27,8 @@ class Acheminement extends TemplateMailable
|
||||
|
||||
public $numero_suivi;
|
||||
|
||||
public $lien_suivi;
|
||||
|
||||
public $numero_commande;
|
||||
|
||||
public $adresse;
|
||||
@@ -49,6 +51,7 @@ class Acheminement extends TemplateMailable
|
||||
$this->societe = $order->customer->company;
|
||||
$this->email = $order->customer->email;
|
||||
$this->numero_suivi = $order->delivery_ref;
|
||||
$this->lien_suivi = $order->delivery_link;
|
||||
$this->numero_commande = $order->ref;
|
||||
$this->date_expedition = $order->updated_at;
|
||||
$this->facture = Invoices::getInvoiceHtml($order->invoice->id);
|
||||
|
||||
@@ -14,16 +14,45 @@ class ConfirmationCommande extends TemplateMailable
|
||||
|
||||
protected static $templateModelClass = MailTemplate::class;
|
||||
|
||||
public $user;
|
||||
public $email;
|
||||
|
||||
public $male;
|
||||
public $nom;
|
||||
|
||||
public $prenom;
|
||||
|
||||
public $societe;
|
||||
|
||||
public $subject;
|
||||
|
||||
public function __construct($user, $subject = '')
|
||||
public $numero_commande;
|
||||
|
||||
public $date_commande;
|
||||
|
||||
public $facturation_adresse;
|
||||
|
||||
public $facturation_cp;
|
||||
|
||||
public $facturation_ville;
|
||||
|
||||
public $livraison_adresse;
|
||||
|
||||
public $livraison_cp;
|
||||
|
||||
public $livraison_ville;
|
||||
|
||||
public function __construct($order)
|
||||
{
|
||||
$this->user = $user;
|
||||
$this->male = $user->gender == 1;
|
||||
$this->subject = $subject;
|
||||
$this->prenom = $order->customer->first_name;
|
||||
$this->nom = $order->customer->last_name;
|
||||
$this->facturation_adresse = $order->address->address;
|
||||
$this->facturation_cp = $order->address->zipcode;
|
||||
$this->facturation_ville = $order->address->city;
|
||||
$this->livraison_adresse = $order->delivery_address->address;
|
||||
$this->livraison_cp = $order->delivery_address->zipcode;
|
||||
$this->livraison_ville = $order->delivery_address->city;
|
||||
$this->societe = $order->customer->company;
|
||||
$this->email = $order->customer->email;
|
||||
$this->numero_commande = $order->ref;
|
||||
$this->date_commande = $order->created_at;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,5 @@ class Preparation extends TemplateMailable
|
||||
$this->nom = $order->customer->last_name;
|
||||
$this->societe = $order->customer->company;
|
||||
$this->email = $order->customer->email;
|
||||
$this->subject = $subject;
|
||||
}
|
||||
}
|
||||
|
||||
16
app/Models/Shop/DeliveryPackage.php
Normal file
16
app/Models/Shop/DeliveryPackage.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeliveryPackage extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_delivery_packages';
|
||||
|
||||
public function scopeByWeight($query, $weight)
|
||||
{
|
||||
return $query->orderBy('weight')->where($this->table . '.weight', '>=', $weight);
|
||||
}
|
||||
}
|
||||
11
app/Models/Shop/DeliveryType.php
Normal file
11
app/Models/Shop/DeliveryType.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeliveryType extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_delivery_types';
|
||||
}
|
||||
26
app/Models/Shop/DeliveryTypeCalculation.php
Normal file
26
app/Models/Shop/DeliveryTypeCalculation.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Shop;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class DeliveryTypeCalculation extends Model
|
||||
{
|
||||
protected $guarded = ['id'];
|
||||
protected $table = 'shop_delivery_type_calculations';
|
||||
|
||||
public function DeliveryType()
|
||||
{
|
||||
return $this->belongsTo(DeliveryType::class);
|
||||
}
|
||||
|
||||
public function scopeByDeliveryType($query, $id)
|
||||
{
|
||||
return $query->where($this->table . '.type_id', $id);
|
||||
}
|
||||
|
||||
public function scopeByWeight($query, $weight)
|
||||
{
|
||||
return $query->orderBy('weight')->where($this->table . '.weight', '>=', $weight);
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,11 @@ class Order extends Model
|
||||
return $this->belongsTo(CustomerAddress::class, 'customer_address_id');
|
||||
}
|
||||
|
||||
public function delivery_address()
|
||||
{
|
||||
return $this->belongsTo(CustomerAddress::class, 'customer_delivery_id');
|
||||
}
|
||||
|
||||
public function delivery()
|
||||
{
|
||||
return $this->belongsTo(Delivery::class);
|
||||
|
||||
@@ -10,6 +10,27 @@ use Symfony\Component\Process\Process;
|
||||
|
||||
class PDF
|
||||
{
|
||||
public function convertView($view, $data, $filename)
|
||||
{
|
||||
try {
|
||||
Browsershot::html(view($view, $data)->render())
|
||||
->noSandbox()
|
||||
->waitUntilNetworkIdle()
|
||||
->format('A4')
|
||||
->showBackground()
|
||||
->savePdf("temp.pdf");
|
||||
|
||||
$postRoute = URL::signedRoute('orderinvoices.store', ['order' => $this->order]);
|
||||
Http::attach('invoice', file_get_contents('temp.pdf'), $filename)
|
||||
->post($postRoute)
|
||||
->throw();
|
||||
}
|
||||
catch (\Exception $exception )
|
||||
{
|
||||
Log::error($exception);
|
||||
}
|
||||
}
|
||||
|
||||
public static function view($view, $data, $filename = 'file.pdf')
|
||||
{
|
||||
\Debugbar::disable();
|
||||
|
||||
18
app/Repositories/Shop/DeliveryTypeCalculations.php
Normal file
18
app/Repositories/Shop/DeliveryTypeCalculations.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\DeliveryTypeCalculation;
|
||||
|
||||
class DeliveryTypeCalculations
|
||||
{
|
||||
public static function getByDeliveryType($type_id)
|
||||
{
|
||||
return DeliveryTypeCalculation::byDeliveryTpe($type_id)->get();
|
||||
}
|
||||
|
||||
public static function getPrice($type_id, $weight)
|
||||
{
|
||||
return DeliveryTypeCalculation::byDeliveryType($type_id)->byWeight($weight)->get();
|
||||
}
|
||||
}
|
||||
13
app/Repositories/Shop/DeliveryTypes.php
Normal file
13
app/Repositories/Shop/DeliveryTypes.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Repositories\Shop;
|
||||
|
||||
use App\Models\Shop\DeliveryType;
|
||||
|
||||
class DeliveryTypes
|
||||
{
|
||||
public static function getOptions()
|
||||
{
|
||||
return DeliveryType::pluck('name', 'id');
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Repositories\Shop;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use App\Mail\Acheminement;
|
||||
use App\Mail\ConfirmationCommande;
|
||||
use App\Mail\Preparation;
|
||||
use App\Models\Shop\Order;
|
||||
use App\Repositories\Core\DateStats;
|
||||
@@ -39,31 +40,28 @@ class Orders
|
||||
|
||||
public static function testSend($id)
|
||||
{
|
||||
$order = self::get($id, ['customer', 'address']);
|
||||
dump($order->toArray());
|
||||
exit;
|
||||
self::sendPreparation($order);
|
||||
self::sendPreparation($id);
|
||||
}
|
||||
|
||||
public static function sendOrderConfirmed($order_id)
|
||||
{
|
||||
$order = self::get($order_id, ['customer']);
|
||||
$mail = new Acheminement($order);
|
||||
return Mail::to($order->email)->send($mail);
|
||||
}
|
||||
|
||||
public static function sendShipping($order_id)
|
||||
{
|
||||
$order = self::get($order_id, ['customer']);
|
||||
$mail = new Acheminement($order);
|
||||
return Mail::to($order->email)->send($mail);
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new ConfirmationCommande($order);
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
public static function sendPreparation($order_id)
|
||||
{
|
||||
$order = self::get($order_id, ['customer']);
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new Preparation($order);
|
||||
return Mail::to($order->email)->send($mail);
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
public static function sendShipping($order_id)
|
||||
{
|
||||
$order = self::get($order_id, ['customer', 'address']);
|
||||
$mail = new Acheminement($order);
|
||||
return Mail::to($order->customer->email)->send($mail);
|
||||
}
|
||||
|
||||
public static function count()
|
||||
@@ -99,8 +97,9 @@ class Orders
|
||||
public static function edit($id)
|
||||
{
|
||||
return [
|
||||
'order' => self::get($id, ['customer', 'address', 'detail']),
|
||||
'order' => self::get($id, ['customer', 'address', 'delivery_address', 'detail']),
|
||||
'statuses' => self::statuses(),
|
||||
'delivery_types' => DeliveryTypes::getOptions(),
|
||||
'payment_types' => self::paymentTypes(),
|
||||
'sale_channels' => SaleChannels::getOptions(),
|
||||
];
|
||||
|
||||
@@ -21,14 +21,23 @@
|
||||
<div class="col-6">
|
||||
<h3>{{ $order['customer']['last_name'] }} {{ $order['customer']['first_name'] }}</h3>
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<h6>
|
||||
@if ($order['address'])
|
||||
{{ $order['address']['address'] }}<br/>
|
||||
@isset ($order['address']['address2']) {{ $order['address']['address2'] }}<br/> @endisset
|
||||
{{ $order['address']['zipcode'] }} {{ $order['address']['city'] }}<br/>
|
||||
@endif
|
||||
</h6>
|
||||
<div class="col-6">
|
||||
<x-card title="Adresse de facturation" classBody="mt-3">
|
||||
@if ($order['address'])
|
||||
{{ $order['address']['address'] }}<br/>
|
||||
@isset ($order['address']['address2']) {{ $order['address']['address2'] }}<br/> @endisset
|
||||
{{ $order['address']['zipcode'] }} {{ $order['address']['city'] }}<br/>
|
||||
@endif
|
||||
</x-card>
|
||||
</div>
|
||||
<div class="col-6">
|
||||
<x-card title="Adresse de livraison" classBody="mt-3">
|
||||
@if ($order['delivery_address'])
|
||||
{{ $order['delivery_address']['address'] }}<br/>
|
||||
@isset ($order['delivery_address']['address2']) {{ $order['delivery_address']['address2'] }}<br/> @endisset
|
||||
{{ $order['delivery_address']['zipcode'] }} {{ $order['delivery_address']['city'] }}<br/>
|
||||
@endif
|
||||
</x-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -49,7 +58,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">
|
||||
<div class="col-6">
|
||||
@include('components.form.select', [
|
||||
'label' => 'Canal de vente',
|
||||
'name' => 'sale_channel_id',
|
||||
@@ -58,14 +67,7 @@
|
||||
'class' => 'select2',
|
||||
])
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@include('components.form.input', [
|
||||
'label' => 'Référence colis',
|
||||
'name' => 'delivery_ref',
|
||||
'value' => $order['deivery_ref'],
|
||||
])
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<div class="col-6">
|
||||
@include('components.form.select', [
|
||||
'label' => 'Règlement',
|
||||
'name' => 'payment_type',
|
||||
@@ -75,6 +77,32 @@
|
||||
])
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
<div class="col-4">
|
||||
@include('components.form.select', [
|
||||
'label' => 'Type de livraison',
|
||||
'name' => 'delivery_type_id',
|
||||
'list' => $delivery_types ?? [],
|
||||
'value' => $order['delivery_type_id'],
|
||||
'with_empty' => '',
|
||||
])
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@include('components.form.input', [
|
||||
'label' => 'Référence colis',
|
||||
'name' => 'delivery_ref',
|
||||
'value' => $order['delivery_ref'] ?? null,
|
||||
])
|
||||
</div>
|
||||
<div class="col-4">
|
||||
@include('components.form.input', [
|
||||
'label' => 'Lien suivi',
|
||||
'name' => 'delivery_link',
|
||||
'value' => $order['delivery_link'] ?? null,
|
||||
])
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row mb-3">
|
||||
|
||||
@@ -4,10 +4,19 @@
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
{{ Form::label('name', 'Nom') }}
|
||||
@include('components.form.input', ['name' => 'name', 'value' => (isset($family['name'])) ? $family['name'] : null, 'required' => true])
|
||||
@include('components.form.input', [
|
||||
'name' => 'name',
|
||||
'value' => $family['name'] ?? null,
|
||||
'required' => true,
|
||||
])
|
||||
|
||||
{{ Form::label('description', 'Description') }}
|
||||
@include('components.form.textarea', ['name' => 'description', 'value' => isset($description) ? $description : null, 'class' => 'editor', 'required' => false])
|
||||
@include('components.form.textarea', [
|
||||
'name' => 'description',
|
||||
'value' => $description ?? null,
|
||||
'class' => 'editor',
|
||||
'required' => false,
|
||||
])
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user