fixes on mail templates, change order edit layout, add DeliveryTypes, DeliveryTypeCalculations & DeliveryPackages

This commit is contained in:
Ludovic CANDELLIER
2023-05-24 23:30:29 +02:00
parent c677dbd5fa
commit 9f9b7173d7
13 changed files with 220 additions and 43 deletions

View File

@@ -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();

View 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();
}
}

View 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');
}
}

View File

@@ -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(),
];