Projekt

Allgemein

Profil

GX-Bug #68784 » KlarnaHubPdfOrderExtender.inc.php

Fix proposal - Moritz Bunjes, 22.07.2021 16:22

 
1
<?php
2
/* --------------------------------------------------------------
3
   KlarnaHubPdfOrderExtender.inc.php 2017-11-09
4
   Gambio GmbH
5
   http://www.gambio.de
6
   Copyright (c) 2017 Gambio GmbH
7
   Released under the GNU General Public License (Version 2)
8
   [http://www.gnu.org/licenses/gpl-2.0.html]
9
   --------------------------------------------------------------
10
*/
11

    
12
class KlarnaHubPdfOrderExtender extends KlarnaHubPdfOrderExtender_parent
13
{
14
    public function extendOrderInfo($orderInfo)
15
    {
16
        $orderInfo = parent::extendOrderInfo($orderInfo);
17
        if($_GET['type'] === 'invoice')
18
        {
19
            $orderService = StaticGXCoreLoader::getService('OrderRead');
20
            $order = $orderService->getOrderById(new IdType((int)$_GET['oID']));
21
            $paymentType = $order->getPaymentType();
22
            $paymentModule = $paymentType->getModule();
23
    
24
            if(in_array($paymentModule, ['KlarnaPaylaterHub', 'KlarnaPaynowHub', 'KlarnaSliceitHub', 'KlarnaBanktransferHub'], true))
25
            {
26
                $languageId = $this->v_data_array['order']->info['languages_id'];
27
                $language = MainFactory::create('LanguageTextManager', 'gambio_hub_klarna_hub', $languageId);
28
                $orderInfo['KlarnaHub'] = [
29
                    0 => 'Klarna',
30
                    1 => $language->get_text('InvoiceNote'),
31
                ];
32
        
33
            }
34
        }
35
        return $orderInfo;
36
    }
37
    
38
    public function extendPdfFooter($footer)
39
    {
40
        $footer = parent::extendPdfFooter($footer);
41
    
42
        if($_GET['type'] === 'invoice')
43
        {
44
            $orderService  = StaticGXCoreLoader::getService('OrderRead');
45
            $order         = $orderService->getOrderById(new IdType((int)$_GET['oID']));
46
            $paymentType   = $order->getPaymentType();
47
            $paymentModule = $paymentType->getModule();
48
    
49
            if (in_array($paymentModule, ['KlarnaPaylaterHub', 'KlarnaPaynowHub', 'KlarnaSliceitHub', 'KlarnaBanktransferHub'], true)) {
50
                $footerColumnsToRemove = explode(', ',gm_get_conf('PDF_FOOTER_REPLACE_ARRAY') ?? gm_get_conf('PDF_FOOTER_REPLACE_COLUMN'));
51
    
52
                foreach ($footerColumnsToRemove as $column) {
53
                    if(is_numeric($column) && isset($footer[(int)$column])) {
54
                        unset($footer[$column]);
55
                    }
56
                }
57
    
58
                $footer = array_values($footer);
59
            }
60
        }
61
        
62
        return $footer;
63
    }
64

    
65
}
    (1-1/1)