|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Application\View\Helper; |
|
6
|
|
|
|
|
7
|
|
|
use Application\DBAL\Types\ProductTypeType; |
|
8
|
|
|
use Application\Model\Order; |
|
9
|
|
|
use Application\Model\OrderLine; |
|
10
|
|
|
use Application\Utility; |
|
11
|
|
|
use Laminas\View\Helper\AbstractHelper; |
|
12
|
|
|
|
|
13
|
|
|
class OrderLines extends AbstractHelper |
|
14
|
|
|
{ |
|
15
|
|
|
/** |
|
16
|
|
|
* This is used for custom admin and customer emails, so links must be frontend, not backend |
|
17
|
|
|
*/ |
|
18
|
7 |
|
public function __invoke(Order $order): string |
|
19
|
|
|
{ |
|
20
|
7 |
|
$result = '<ul>'; |
|
21
|
|
|
|
|
22
|
|
|
/** @var OrderLine $line */ |
|
23
|
7 |
|
foreach ($order->getOrderLines() as $line) { |
|
24
|
7 |
|
$label = $this->view->escapeHtml($line->getName()); |
|
25
|
7 |
|
$price = ' <strong>' . Utility::getFormattedBalance($line) . '</strong>'; |
|
26
|
|
|
|
|
27
|
7 |
|
$type = ''; |
|
28
|
7 |
|
switch ($line->getType()) { |
|
29
|
|
|
case ProductTypeType::BOTH: |
|
30
|
6 |
|
$type = ', papier et numérique'; |
|
31
|
|
|
|
|
32
|
6 |
|
break; |
|
33
|
|
|
case ProductTypeType::DIGITAL: |
|
34
|
6 |
|
$type = ', numérique'; |
|
35
|
|
|
|
|
36
|
6 |
|
break; |
|
37
|
|
|
case ProductTypeType::PAPER: |
|
38
|
6 |
|
$type = ', papier'; |
|
39
|
|
|
|
|
40
|
6 |
|
break; |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
7 |
|
if ($line->getProduct()) { |
|
44
|
6 |
|
$url = $this->view->serverUrl . '/larevuedurable/article/' . $line->getProduct()->getId(); |
|
45
|
6 |
|
$label = '<a href="' . $url . '">' . $label . ', ' . $line->getProduct()->getCode() . '</a>'; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
7 |
|
if ($line->getSubscription()) { |
|
49
|
6 |
|
$url = $this->view->serverUrl . '/larevuedurable/abonnements'; |
|
50
|
6 |
|
$label = '<a href="' . $url . '">' . $label . '</a>'; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
7 |
|
$extra = ''; |
|
54
|
7 |
|
if ($line->getAdditionalEmails()) { |
|
55
|
6 |
|
$extra .= '<ul>'; |
|
56
|
6 |
|
foreach ($line->getAdditionalEmails() as $email) { |
|
57
|
6 |
|
$extra .= '<li>' . $this->view->escapeHtml($email) . '</li>'; |
|
58
|
|
|
} |
|
59
|
6 |
|
$extra .= '</ul>'; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
7 |
|
$result .= '<li>' . $label . $type . $price . $extra . '</li>'; |
|
63
|
|
|
} |
|
64
|
7 |
|
$result .= '</ul>'; |
|
65
|
|
|
|
|
66
|
7 |
|
return $result; |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|