Ajout dans la facture du détail de livraison, pour PointRetrait et ClickAndCollect

This commit is contained in:
2021-04-14 19:11:39 +02:00
parent 276603d372
commit 96173c0058
10 changed files with 510 additions and 0 deletions

View File

@@ -27,6 +27,11 @@
<tag name="hook.event_listener" event="email-html.order-confirmation.delivery-address" type="email" method="displayDeliveryDateWithinEmail" /> <tag name="hook.event_listener" event="email-html.order-confirmation.delivery-address" type="email" method="displayDeliveryDateWithinEmail" />
<tag name="hook.event_listener" event="email-html.order-notification.before-products" type="email" method="displayCompleteInformationWithinEmail" /> <tag name="hook.event_listener" event="email-html.order-notification.before-products" type="email" method="displayCompleteInformationWithinEmail" />
</hook> </hook>
<hook id="cnc.pdf.hookmanager" class="ClickAndCollect\Hook\PdfHook">
<tag name="hook.event_listener" event="invoice.after-delivery-module" type="pdf" method="displayDeliveryDateWithinPdf" />
</hook>
</hooks> </hooks>
<forms> <forms>

View File

@@ -0,0 +1,52 @@
<?php
namespace ClickAndCollect\Hook;
use ClickAndCollect\ClickAndCollect;
use PlanificationLivraison\Model\OrderDeliveryScheduleQuery;
use PlanificationLivraison\PlanificationLivraison;
use PointRetrait\Model\PdrPlacesQuery;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
use Thelia\Exception\TheliaProcessException;
use Thelia\Model\OrderQuery;
class PdfHook extends BaseHook
{
public function displayDeliveryDateWithinPdf(HookRenderEvent $event)
{
$orderId = $event->getArgument('order');
$moduleId = OrderQuery::create()->findOneById($orderId)->getDeliveryModuleId();
if ((null !== $orderId) && $moduleId === ClickAndCollect::getModuleId()) {
$order = OrderDeliveryScheduleQuery::create()->findOneByOrderId($orderId);
if (null !== $order) {
$selectedDay = $order->getDueDeliveryTimeStart(PlanificationLivraison::FORMAT_DATES);
$beginTime = $order->getDueDeliveryTimeStart(PlanificationLivraison::FORMAT_HEURE);
$endTime = $order->getDueDeliveryTimeEnd(PlanificationLivraison::FORMAT_HEURE);
$placeID = $order->getDeliveryPlaceId();
$place = PdrPlacesQuery::create()->findOneById($placeID);
if ((null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime)) {
$event->add(
$this->render(
'delivery-address.html', [
'day' => $selectedDay,
'begin_time' => $beginTime,
'end_time' => $endTime,
'title' => $place->getTitle(),
'address1' => $place->getAddress1(),
'address2' => $place->getAddress2(),
'zipcode' => $place->getZipcode(),
'city' => $place->getCity()
])
);
} else
throw new TheliaProcessException("ClickAndCollect : Impossible de récupérer les données");
}
}
}
}

View File

@@ -42,6 +42,8 @@ return array(
'There is no order to deliver' => 'Aucune commande à déposer', 'There is no order to deliver' => 'Aucune commande à déposer',
'There is no schedule for this place' => 'Aucun jour d\'ouverture pour ce point click and Collect', 'There is no schedule for this place' => 'Aucun jour d\'ouverture pour ce point click and Collect',
'Title of config view' => 'Point Click and Collect - Configuration', 'Title of config view' => 'Point Click and Collect - Configuration',
'Withdrawal address' => 'Retrait à l\'adresse suivante : ',
'Withdrawal date' => 'A retirer à partir du : ',
'Working day' => 'Jour d\'ouverture', 'Working day' => 'Jour d\'ouverture',
'Zipcode' => 'Code postal', 'Zipcode' => 'Code postal',
'' => '', '' => '',

View File

@@ -0,0 +1,12 @@
<div class="panel panel-default col-sm-6">
<div>
<p><span>{intl l="Withdrawal date" d="clickandcollect"}<strong>{$day}</strong></span></p>
<p><span><strong>{intl l="Withdrawal address" d="clickandcollect"}</strong><br>
{$title}<br>
{$address1}<br>
{$address2}<br>
{$zipcode} {$city}
</span>
</p>
</div>
</div>

View File

@@ -28,6 +28,10 @@
<tag name="hook.event_listener" event="email-html.order-notification.before-products" type="email" method="displayCompleteInformationWithinEmail" /> <tag name="hook.event_listener" event="email-html.order-notification.before-products" type="email" method="displayCompleteInformationWithinEmail" />
</hook> </hook>
<hook id="pdr.pdf.hookmanager" class="PointRetrait\Hook\PdfHook">
<tag name="hook.event_listener" event="invoice.after-delivery-module" type="pdf" method="displayDeliveryDateWithinPdf" />
</hook>
</hooks> </hooks>
<loops> <loops>

View File

@@ -0,0 +1,52 @@
<?php
namespace PointRetrait\Hook;
use PlanificationLivraison\Model\OrderDeliveryScheduleQuery;
use PlanificationLivraison\PlanificationLivraison;
use PointRetrait\Model\PdrPlacesQuery;
use PointRetrait\PointRetrait;
use Thelia\Core\Event\Hook\HookRenderEvent;
use Thelia\Core\Hook\BaseHook;
use Thelia\Exception\TheliaProcessException;
use Thelia\Model\OrderQuery;
class PdfHook extends BaseHook
{
public function displayDeliveryDateWithinPdf(HookRenderEvent $event)
{
$orderId = $event->getArgument('order');
$moduleId = OrderQuery::create()->findOneById($orderId)->getDeliveryModuleId();
if ((null !== $orderId) && $moduleId === PointRetrait::getModuleId()) {
$order = OrderDeliveryScheduleQuery::create()->findOneByOrderId($orderId);
if (null !== $order) {
$selectedDay = $order->getDueDeliveryTimeStart(PlanificationLivraison::FORMAT_DATES);
$beginTime = $order->getDueDeliveryTimeStart(PlanificationLivraison::FORMAT_HEURE);
$endTime = $order->getDueDeliveryTimeEnd(PlanificationLivraison::FORMAT_HEURE);
$placeID = $order->getDeliveryPlaceId();
$place = PdrPlacesQuery::create()->findOneById($placeID);
if ((null !== $selectedDay) && (null !== $beginTime) && (null !== $endTime)) {
$event->add(
$this->render(
'delivery-address.html', [
'day' => $selectedDay,
'begin_time' => $beginTime,
'end_time' => $endTime,
'title' => $place->getTitle(),
'address1' => $place->getAddress1(),
'address2' => $place->getAddress2(),
'zipcode' => $place->getZipcode(),
'city' => $place->getCity()
])
);
} else
throw new TheliaProcessException("PointRetrait : Impossible de récupérer les données");
}
}
}
}

View File

@@ -47,6 +47,8 @@ return array(
'Withdrawal days' => 'Jours de retrait', 'Withdrawal days' => 'Jours de retrait',
'Withdrawal ending time' => 'Fin du retrait', 'Withdrawal ending time' => 'Fin du retrait',
'Withdrawal price' => 'Coût du retrait', 'Withdrawal price' => 'Coût du retrait',
'Withdrawal address' => 'Retrait à l\'adresse suivante : ',
'Withdrawal date' => 'A retirer le : ',
'Zipcode' => 'Code postal', 'Zipcode' => 'Code postal',
'' => '', '' => '',
); );

View File

@@ -0,0 +1,12 @@
<div class="panel panel-default col-sm-6">
<div>
<p><span>{intl l="Withdrawal date" d="pointretrait"}<strong>{$day} entre {format_date date=$begin_time format="H\hi"} et {format_date date=$end_time format="H\hi"}</strong></span></p>
<p><span><strong>{intl l="Withdrawal address" d="pointretrait"}</strong><br>
{$title}<br>
{$address1}<br>
{$address2}<br>
{$zipcode} {$city}
</span>
</p>
</div>
</div>

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

View File

@@ -0,0 +1,369 @@
{*************************************************************************************/
/* This file is part of the Thelia package. */
/* */
/* Copyright (c) OpenStudio */
/* email : dev@thelia.net */
/* web : http://www.thelia.net */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************}
{* Set the default translation domain, that will be used by {intl} when the 'd' parameter is not set *}
{default_translation_domain domain='pdf.default'}
{literal}
<style>
h1, h2, h3, h4 {
color:#f6993c;
margin: .5em 0;
}
h1 {
font-size: 48px;
}
h2 {
font-size: 16px;
}
h3 {
font-size: 14px;
}
h4 {
color:#58585a;
font-size: 12px;
}
p, td {
color:#58585a;
font-size: 9px;
}
p {
margin: .5em 0;
}
span {
font-size: 9px;
}
table {
border-collapse: collapse;
width: 100%;
}
tr {
width: 100%;
}
td {
vertical-align: top;
}
.table-info h3 {
font-size: 18px;
color: #58585a;
margin-top: 0;
margin-bottom: 15px;
}
.table-info h3 span {
font-size: 18px;
color: #f6993c;
}
.table-1 td {
background: #f1f3f4;
border:solid 1px #bcbdc0;
}
.table-2 td {
border:solid 1px #bcbdc0;
}
.table-3-1, .table-3-2 {
border: solid 1px #bcbdc0;
}
.table-3-1 p {
font-size: 10px;
}
.table-3-2 p {
font-size: 9px;
color: #747475;
}
.table-3-module h3 {
margin-top: 1.5em;
}
.table-3-module span {
font-size: 11px;
}
.align-left {
text-align: left;
}
.align-center {
text-align: center;
}
.align-right{
text-align: right;
}
.clear {
padding: 0.5%;
border-bottom:solid 1px #dddddd;
}
.clear-none {
padding: 0.5%;
}
{hook name="invoice.css"}
</style>
{/literal}
<page backtop="10mm" backleft="10mm" backright="10mm" backbottom="10mm">
<page_header>
{hook name="invoice.header" order=$order_id}
</page_header>
<page_footer>
{hook name="invoice.footer-top" order=$order_id}
<table>
<col style="width: 80%; padding: 1mm; border: none; text-align: left;" />
<col style="width: 20%; padding: 1mm; border: none; text-align: right;" />
<tbody>
<tr>
<td>
{hook name="invoice.imprint" order=$order_id}
{elsehook rel="invoice.imprint"}
<!-- Imprint -->
{config key="store_name"}
{$addresses="{config key="store_address1"} {config key="store_address2"} {config key="store_address3"}"}
{$city="{config key="store_zipcode"} {config key="store_city"}"}
{if $addresses != " "}- {$addresses}{/if}
{if $city != " " }- {$city}{/if}
{if {config key="store_country"} }
{loop type="country" visible="*" name="address.country.title" id={config key="store_country"}} - {$TITLE}{/loop}
{/if}
{if {config key="store_business_id"} }
- {config key="store_business_id"}
{/if}
<br>
{if {config key="store_phone"} }
{intl l="Phone: "}{config key="store_phone"}
{/if}
{if {config key="store_email"} }
{intl l="Email: "}{config key="store_email"}
{/if}
{/elsehook}
</td>
<td>{intl l="page"} [[page_cu]]/[[page_nb]]</td>
</tr>
</tbody>
</table>
{hook name="invoice.footer-bottom" order=$order_id}
</page_footer>
{$taxes = []}
{loop name="order.invoice" type="order" id=$order_id customer="*"}
<table class="table-info">
<col style="width: 100%; padding: 0mm;" />
<tr>
<td>
<h1>{intl l="INVOICE"}<img src="{image file='assets/img/logo.png'}" style="height:80px; margin-left:100px;"></h1>
</td>
</tr>
<tr>
<td><h3>{intl l="Invoice date"} : <span>{format_date date=$INVOICE_DATE output="date"}</span></h3></td>
</tr>
<tr>
<td><h3>{intl l="Invoice REF"} : <span>{$REF}</span></h3></td>
</tr>
<tr>
<td><h3>{intl l="Customer Number"} : <span>{loop type="customer" name="customer.invoice" id=$CUSTOMER current="0"}{$REF}{/loop}</span></h3></td>
</tr>
{hookblock name="invoice.information" order=$order_id fields="title,value"}
{forhook rel="invoice.information"}
<tr>
<td><h3>{$title} : <span>{$value}</span></h3></td>
</tr>
{/forhook}
{/hookblock}
</table>
{hook name="invoice.after-information" order=$order_id}
<table class="table-address">
<col style="width: 50%; padding: 3mm;" />
<col style="padding: 3mm;" />
<tr>
<td style="border-left: solid 1mm #f6993c;" >
<h3>{intl l="Delivery address"}</h3>
{ifhook rel="invoice.delivery-address"}
{* delivery module can customize the delivery address *}
{hook name="invoice.delivery-address" module={$DELIVERY_MODULE} order=$order_id}
{/ifhook}
{elsehook rel="invoice.delivery-address"}
{format_address order_address=$DELIVERY_ADDRESS locale=$locale}
{/elsehook}
</td>
<td style="border-left: solid 1mm #f6993c;">
<h3>{intl l="Invoice address"}</h3>
{format_address order_address=$INVOICE_ADDRESS locale=$locale}
</td>
</tr>
</table>
{hook name="invoice.after-addresses" order=$order_id}
<table cellspacing="0" cellpadding="0" style="padding-top: 5mm;">
<col style="width: 40%; padding: 1mm;" />
<col style="width: 12%; padding: 1mm;" />
<col style="width: 12%; padding: 1mm;" />
<col style="width: 12%; padding: 1mm;" />
<col style="width: 12%; padding: 1mm;" />
<col style="width: 12%; padding: 1mm;" />
<tr class="table-1">
<td><h4>{intl l="Product"}</h4></td>
<td><h4 class="align-center">{intl l="Unit. price"}</h4></td>
<td><h4 class="align-center">{intl l="Tax"}</h4></td>
<td><h4 class="align-center">{intl l="Unit taxed price"}</h4></td>
<td><h4 class="align-center">{intl l="Quantity"}</h4></td>
<td style="background:#f6993c"><h4 style="color:white;" class="align-center">{intl l="Taxed total"}</h4></td>
</tr>
{loop type="order_product" name="order-products" order=$ID}
{if $WAS_IN_PROMO == 1}
{assign "realPrice" $PROMO_PRICE}
{assign "realTax" $PROMO_PRICE_TAX}
{assign "realTaxedPrice" $TAXED_PROMO_PRICE}
{assign "realTotalPrice" $TOTAL_TAXED_PROMO_PRICE}
{else}
{assign "realPrice" $PRICE}
{assign "realTax" $PRICE_TAX}
{assign "realTaxedPrice" $TAXED_PRICE}
{assign "realTotalPrice" $TOTAL_TAXED_PRICE}
{/if}
{$taxes[{$TAX_RULE_TITLE}][] = floatval($realTax) * $QUANTITY}
<tr class="table-2">
<td>
<p>{$TITLE}</p>
<p>
{intl l="Product ref : "}{$REF}<br>
{intl l="Combination ref : "}{$PRODUCT_SALE_ELEMENTS_REF}
</p>
{ifloop rel="combinations"}
{loop type="order_product_attribute_combination" name="combinations" order_product=$ID}
{$ATTRIBUTE_TITLE} - {$ATTRIBUTE_AVAILABILITY_TITLE}<br>
{/loop}
{/ifloop}
{hook name="invoice.product-list" order_product=$ID order=$order_id}
</td>
<td><p class="align-right">{format_money number=$realPrice currency_id=$CURRENCY}</p></td>
<td><p class="align-right">{format_money number=$realTax currency_id=$CURRENCY}</p></td>
<td><p class="align-right">{format_money number=$realTaxedPrice currency_id=$CURRENCY}</p></td>
<td><p class="align-center">{$QUANTITY}</p></td>
<td><p class="align-right">{format_money number=$realTotalPrice currency_id=$CURRENCY}</p></td>
</tr>
{hook name="invoice.order-product" order={$order_id} order_product={$ID}}
{/loop}
</table>
{hook name="invoice.after-products" order=$order_id}
<table cellspacing="0" cellpadding="0" style="padding-top: 5mm;">
<col style="width: 60%; padding: 1mm;" />
<col style="width: 40%; padding: 1mm;" />
<tr>
<td class="table-3-module">
<h3>{intl l="Payment module"}</h3>
<p>
<span>{loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}</span>
</p>
{hook name="invoice.after-payment-module" order=$order_id module_id=$PAYMENT_MODULE}
<h3>{intl l="Delivery module"}</h3>
<p>
<span>{loop name="delivery-module" type="module" id=$DELIVERY_MODULE}{$TITLE}{/loop}</span>
</p>
{hook name="invoice.after-delivery-module" order=$order_id module_id=$DELIVERY_MODULE}
</td>
<td>
<table class="table-3">
<col style="width: 50%; padding: 1mm;">
<col style="width: 50%; padding: 1mm;">
<tr>
<td class="table-3-1"><p>{intl l="Total without tax"}</p></td>
<td class="table-3-1 align-right"><p>{format_money number={$TOTAL_ITEMS_AMOUNT} currency_id=$CURRENCY}</p></td>
</tr>
{capture name="tax"}{strip}
{foreach $taxes as $name=>$prices}
{assign var="_price_taxe_" value="0"}
{foreach $prices as $price}
{$_price_taxe_= $_price_taxe_ + $price}
{/foreach}
{if $_price_taxe_ != 0}
<tr>
<td class="table-3-2"><p>{$name}</p></td>
<td class="table-3-2 align-right"><p>{format_money number=$_price_taxe_ currency_id=$CURRENCY}</p></td>
</tr>
{/if}
{/foreach}
{/strip}{/capture}
{if $smarty.capture.tax ne ""}
{$smarty.capture.tax nofilter}
{/if}
<tr>
<td class="table-3-1"><p>{intl l="Total with tax"}</p></td>
<td class="table-3-1 align-right"><p>{format_money number={$TOTAL_TAXED_ITEMS_AMOUNT} currency_id=$CURRENCY}</p></td>
</tr>
{if $DISCOUNT > 0}
<tr>
<td class="table-3-1">
<p>
{intl l="Discount with tax"}
<br>{intl l="Tax: %tax" tax={format_money number=$DISCOUNT_TAX currency_id=$CURRENCY}}
</p>
</td>
<td class="table-3-1 align-right"><p>-{format_money number=$DISCOUNT currency_id=$CURRENCY}</p></td>
</tr>
{/if}
<tr>
<td class="table-3-1">
<p>
{intl l="Postage"}
{if $POSTAGE_TAX != 0}
<br>{intl l="Tax %name: %tax" name=$POSTAGE_TAX_RULE_TITLE tax={format_money number=$POSTAGE_TAX currency_id=$CURRENCY}}
{/if}
</p>
</td>
<td class="table-3-1 align-right"><p>{format_money number=$POSTAGE currency_id=$CURRENCY}</p></td>
</tr>
<tr>
<td class="table-3-1" style="background:#f6993c;"><h3 style="color:white;">{intl l="Total"}</h3></td>
<td class="table-3-1 align-right" style="background:#f6993c;"><h3 style="color:white;">{format_money number=$TOTAL_TAXED_AMOUNT currency_id=$CURRENCY}</h3></td>
</tr>
</table>
</td>
</tr>
</table>
{hook name="invoice.after-summary" order=$order_id}
{/loop}
</page>