Completed
Pull Request — experimental/sf (#3468)
by Ryo
427:01 queued 414:55
created

OrderPdfService::renderOrderDetailData()   B

Complexity

Conditions 4
Paths 4

Size

Total Lines 78

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 45
CRAP Score 4.0001

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 0
loc 78
rs 8.48
c 0
b 0
f 0
ccs 45
cts 46
cp 0.9783
crap 4.0001

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) LOCKON CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.lockon.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Service;
15
16
use Eccube\Application;
17
use Eccube\Common\EccubeConfig;
18
use Eccube\Entity\BaseInfo;
19
use Eccube\Entity\OrderItem;
20
use Eccube\Entity\Shipping;
21
use Eccube\Repository\BaseInfoRepository;
22
use Eccube\Repository\OrderPdfRepository;
23
use Eccube\Repository\OrderRepository;
24
use Eccube\Repository\ShippingRepository;
25
use Eccube\Twig\Extension\EccubeExtension;
26
use setasign\Fpdi\TcpdfFpdi;
27
28
/**
29
 * Class OrderPdfService.
30
 * Do export pdf function.
31
 */
32
class OrderPdfService extends TcpdfFpdi
33
{
34
    /** @var OrderRepository */
35
    protected $orderRepository;
36
37
    /** @var ShippingRepository */
38
    protected $shippingRepository;
39
40
    /** @var OrderPdfRepository */
41
    protected $orderPdfRepository;
42
43
    /** @var TaxRuleService */
44
    protected $taxRuleService;
45
46
    /**
47
     * @var Application
48
     */
49
    private $eccubeConfig;
50
51
    /**
52
     * @var EccubeExtension
53
     */
54
    private $eccubeExtension;
55
56
    // ====================================
57
    // 定数宣言
58
    // ====================================
59
60
    /** ダウンロードするPDFファイルのデフォルト名 */
61
    const DEFAULT_PDF_FILE_NAME = 'nouhinsyo.pdf';
62
63
    /** FONT ゴシック */
64
    const FONT_GOTHIC = 'kozgopromedium';
65
    /** FONT 明朝 */
66
    const FONT_SJIS = 'kozminproregular';
67
68
    // ====================================
69
    // 変数宣言
70
    // ====================================
71
72
    /** @var BaseInfo */
73
    public $baseInfoRepository;
74
75
    /** 購入詳細情報 ラベル配列
76
     * @var array
77
     */
78
    private $labelCell = [];
79
80
    /*** 購入詳細情報 幅サイズ配列
81
     * @var array
82
     */
83
    private $widthCell = [];
84
85
    /** 最後に処理した注文番号 @var string */
86
    private $lastOrderId = null;
87
88
    // --------------------------------------
89
    // Font情報のバックアップデータ
90
    /** @var string フォント名 */
91
    private $bakFontFamily;
92
    /** @var string フォントスタイル */
93
    private $bakFontStyle;
94
    /** @var string フォントサイズ */
95
    private $bakFontSize;
96
    // --------------------------------------
97
98
    // lfTextのoffset
99
    private $baseOffsetX = 0;
100
    private $baseOffsetY = -4;
101
102
    /** ダウンロードファイル名 @var string */
103
    private $downloadFileName = null;
104
105
    /** 発行日 @var string */
106
    private $issueDate = '';
107
108
    /**
109
     * OrderPdfService constructor.
110
     *
111
     * @param EccubeConfig $eccubeConfig
112
     * @param OrderRepository $orderRepository
113
     * @param ShippingRepository $shippingRepository
114
     * @param TaxRuleService $taxRuleService
115
     * @param BaseInfoRepository $baseInfoRepository
116
     */
117 28
    public function __construct(EccubeConfig $eccubeConfig, OrderRepository $orderRepository, ShippingRepository $shippingRepository, TaxRuleService $taxRuleService, BaseInfoRepository $baseInfoRepository, EccubeExtension $eccubeExtension)
118
    {
119 28
        $this->eccubeConfig = $eccubeConfig;
0 ignored issues
show
Documentation Bug introduced by
It seems like $eccubeConfig of type object<Eccube\Common\EccubeConfig> is incompatible with the declared type object<Eccube\Application> of property $eccubeConfig.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
120 28
        $this->baseInfoRepository = $baseInfoRepository->get();
121 28
        $this->orderRepository = $orderRepository;
122 28
        $this->shippingRepository = $shippingRepository;
123 28
        $this->taxRuleService = $taxRuleService;
124 28
        $this->eccubeExtension = $eccubeExtension;
125 28
        parent::__construct();
126
127
        // 購入詳細情報の設定を行う
128
        // 動的に入れ替えることはない
129 28
        $this->labelCell[] = '商品名 / 商品コード / [ 規格 ]';
130 28
        $this->labelCell[] = '数量';
131 28
        $this->labelCell[] = '単価';
132 28
        $this->labelCell[] = '金額(税込)';
133 28
        $this->widthCell = [110.3, 12, 21.7, 24.5];
134
135
        // Fontの設定しておかないと文字化けを起こす
136 28
        $this->SetFont(self::FONT_SJIS);
137
138
        // PDFの余白(上左右)を設定
139 28
        $this->SetMargins(15, 20);
140
141
        // ヘッダーの出力を無効化
142 28
        $this->setPrintHeader(false);
143
144
        // フッターの出力を無効化
145 28
        $this->setPrintFooter(true);
146 28
        $this->setFooterMargin();
147 28
        $this->setFooterFont([self::FONT_SJIS, '', 8]);
148
    }
149
150
    /**
151
     * 注文情報からPDFファイルを作成する.
152
     *
153
     * @param array $formData
154
     *                        [KEY]
155
     *                        ids: 注文番号
156
     *                        issue_date: 発行日
157
     *                        title: タイトル
158
     *                        message1: メッセージ1行目
159
     *                        message2: メッセージ2行目
160
     *                        message3: メッセージ3行目
161
     *                        note1: 備考1行目
162
     *                        note2: 備考2行目
163
     *                        note3: 備考3行目
164
     *
165
     * @return bool
166
     */
167 3
    public function makePdf(array $formData)
168
    {
169
        // 発行日の設定
170 3
        $this->issueDate = '作成日: '.$formData['issue_date']->format('Y年m月d日');
171
        // ダウンロードファイル名の初期化
172 3
        $this->downloadFileName = null;
173
174
        // データが空であれば終了
175 3
        if (!$formData['ids']) {
176
            return false;
177
        }
178
179
        // 出荷番号をStringからarrayに変換
180 3
        $ids = explode(',', $formData['ids']);
181
182
        // 空文字列の場合のデフォルトメッセージを設定する
183 3
        $this->setDefaultData($formData);
184
185
        // テンプレートファイルを読み込む
186 3
        $userPath = $this->eccubeConfig->get('eccube_html_admin_dir').'/assets/pdf/nouhinsyo1.pdf';
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Eccube\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
187 3
        $this->setSourceFile($userPath);
188
189 3
        foreach ($ids as $id) {
190 3
            $this->lastOrderId = $id;
191
192
            // 出荷番号から出荷情報を取得する
193
            /** @var Shipping $Shipping */
194 3
            $Shipping = $this->shippingRepository->find($id);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $Shipping is correct as $this->shippingRepository->find($id) (which targets Doctrine\ORM\EntityRepository::find()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
195 3
            if (!$Shipping) {
196
                // 出荷情報の取得ができなかった場合
197
                continue;
198
            }
199
200
            // PDFにページを追加する
201 3
            $this->addPdfPage();
202
203
            // タイトルを描画する
204 3
            $this->renderTitle($formData['title']);
205
206
            // 店舗情報を描画する
207 3
            $this->renderShopData();
208
209
            // 注文情報を描画する
210 3
            $this->renderOrderData($Shipping);
211
212
            // メッセージを描画する
213 3
            $this->renderMessageData($formData);
214
215
            // 出荷詳細情報を描画する
216 3
            $this->renderOrderDetailData($Shipping);
217
218
            // 備考を描画する
219 3
            $this->renderEtcData($formData);
220
        }
221
222 3
        return true;
223
    }
224
225
    /**
226
     * PDFファイルを出力する.
227
     *
228
     * @return string|mixed
229
     */
230 3
    public function outputPdf()
231
    {
232 3
        return $this->Output($this->getPdfFileName(), 'S');
233
    }
234
235
    /**
236
     * PDFファイル名を取得する
237
     * PDFが1枚の時は注文番号をファイル名につける.
238
     *
239
     * @return string ファイル名
240
     */
241 3
    public function getPdfFileName()
242
    {
243 3
        if (!is_null($this->downloadFileName)) {
244 3
            return $this->downloadFileName;
245
        }
246 3
        $this->downloadFileName = self::DEFAULT_PDF_FILE_NAME;
247 3
        if ($this->PageNo() == 1) {
248 3
            $this->downloadFileName = 'nouhinsyo-No'.$this->lastOrderId.'.pdf';
249
        }
250
251 3
        return $this->downloadFileName;
252
    }
253
254
    /**
255
     * フッターに発行日を出力する.
256
     */
257 3
    public function Footer()
258
    {
259 3
        $this->Cell(0, 0, $this->issueDate, 0, 0, 'R');
260
    }
261
262
    /**
263
     * 作成するPDFのテンプレートファイルを指定する.
264
     */
265 3
    protected function addPdfPage()
266
    {
267
        // ページを追加
268 3
        $this->AddPage();
269
270
        // テンプレートに使うテンプレートファイルのページ番号を取得
271 3
        $tplIdx = $this->importPage(1);
272
273
        // テンプレートに使うテンプレートファイルのページ番号を指定
274 3
        $this->useTemplate($tplIdx, null, null, null, null, true);
275
    }
276
277
    /**
278
     * PDFに店舗情報を設定する
279
     * ショップ名、ロゴ画像以外はdtb_helpに登録されたデータを使用する.
280
     */
281 3
    protected function renderShopData()
282
    {
283
        // 基準座標を設定する
284 3
        $this->setBasePosition();
285
286
        // ショップ名
287 3
        $this->lfText(125, 60, $this->baseInfoRepository->getShopName(), 8, 'B');
288
289
        // 都道府県+所在地
290 3
        $text = $this->baseInfoRepository->getAddr01();
291 3
        $this->lfText(125, 65, $text, 8);
292 3
        $this->lfText(125, 69, $this->baseInfoRepository->getAddr02(), 8);
293
294
        // 電話番号
295 3
        $text = 'TEL: '.$this->baseInfoRepository->getPhoneNumber();
296 3
        $this->lfText(125, 72, $text, 8); //TEL・FAX
297
298
        // メールアドレス
299 3
        if (strlen($this->baseInfoRepository->getEmail01()) > 0) {
300 3
            $text = 'Email: '.$this->baseInfoRepository->getEmail01();
301 3
            $this->lfText(125, 75, $text, 8); // Email
302
        }
303
304
        // ロゴ画像(app配下のロゴ画像を優先して読み込む)
305 3
        $logoFile = $this->eccubeConfig->get('eccube_html_admin_dir').'/assets/pdf/logo.png';
0 ignored issues
show
Bug introduced by
The method get() does not seem to exist on object<Eccube\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
306 3
        $this->Image($logoFile, 124, 46, 40);
307
    }
308
309
    /**
310
     * メッセージを設定する.
311
     *
312
     * @param array $formData
313
     */
314 3
    protected function renderMessageData(array $formData)
315
    {
316 3
        $this->lfText(27, 70, $formData['message1'], 8); //メッセージ1
317 3
        $this->lfText(27, 74, $formData['message2'], 8); //メッセージ2
318 3
        $this->lfText(27, 78, $formData['message3'], 8); //メッセージ3
319
    }
320
321
    /**
322
     * PDFに備考を設定数.
323
     *
324
     * @param array $formData
325
     */
326 3
    protected function renderEtcData(array $formData)
327
    {
328
        // フォント情報のバックアップ
329 3
        $this->backupFont();
330
331 3
        $this->Cell(0, 10, '', 0, 1, 'C', 0, '');
332
333 3
        $this->SetFont(self::FONT_GOTHIC, 'B', 9);
334 3
        $this->MultiCell(0, 6, '< 備考 >', 'T', 2, 'L', 0, '');
335
336 3
        $this->SetFont(self::FONT_SJIS, '', 8);
337
338 3
        $this->Ln();
339
        // rtrimを行う
340 3
        $text = preg_replace('/\s+$/us', '', $formData['note1']."\n".$formData['note2']."\n".$formData['note3']);
341 3
        $this->MultiCell(0, 4, $text, '', 2, 'L', 0, '');
342
343
        // フォント情報の復元
344 3
        $this->restoreFont();
345
    }
346
347
    /**
348
     * タイトルをPDFに描画する.
349
     *
350
     * @param string $title
351
     */
352 3
    protected function renderTitle($title)
353
    {
354
        // 基準座標を設定する
355 3
        $this->setBasePosition();
356
357
        // フォント情報のバックアップ
358 3
        $this->backupFont();
359
360
        //文書タイトル(納品書・請求書)
361 3
        $this->SetFont(self::FONT_GOTHIC, '', 15);
362 3
        $this->Cell(0, 10, $title, 0, 2, 'C', 0, '');
363 3
        $this->Cell(0, 66, '', 0, 2, 'R', 0, '');
364 3
        $this->Cell(5, 0, '', 0, 0, 'R', 0, '');
365
366
        // フォント情報の復元
367 3
        $this->restoreFont();
368
    }
369
370
    /**
371
     * 購入者情報を設定する.
372
     *
373
     * @param Shipping $Shipping
374
     */
375 3
    protected function renderOrderData(Shipping $Shipping)
376
    {
377
        // 基準座標を設定する
378 3
        $this->setBasePosition();
379
380
        // フォント情報のバックアップ
381 3
        $this->backupFont();
382
383
        // =========================================
384
        // 購入者情報部
385
        // =========================================
386
387 3
        $Order = $Shipping->getOrder();
388
389
        // 購入者都道府県+住所1
390 3
        $text = $Order->getPref().$Order->getAddr01();
391 3
        $this->lfText(27, 47, $text, 10);
392 3
        $this->lfText(27, 51, $Order->getAddr02(), 10); //購入者住所2
393
394
        // 購入者氏名
395 3
        $text = $Order->getName01().' '.$Order->getName02().' 様';
396 3
        $this->lfText(27, 59, $text, 11);
397
398
        // =========================================
399
        // お買い上げ明細部
400
        // =========================================
401 3
        $this->SetFont(self::FONT_SJIS, '', 10);
402
403
        //ご注文日
404 3
        $orderDate = $Order->getCreateDate()->format('Y/m/d H:i');
405 3
        if ($Order->getOrderDate()) {
406
            $orderDate = $Order->getOrderDate()->format('Y/m/d H:i');
407
        }
408
409 3
        $this->lfText(25, 125, $orderDate, 10);
410
        //注文番号
411 3
        $this->lfText(25, 135, $Order->getId(), 10);
412
413
        // 総合計金額
414 3
        $this->SetFont(self::FONT_SJIS, 'B', 15);
415 3
        $paymentTotalText = $this->eccubeExtension->getPriceFilter($Order->getPaymentTotal());
416
417 3
        $this->setBasePosition(120, 95.5);
418 3
        $this->Cell(5, 7, '', 0, 0, '', 0, '');
419 3
        $this->Cell(67, 8, $paymentTotalText, 0, 2, 'R', 0, '');
420 3
        $this->Cell(0, 45, '', 0, 2, '', 0, '');
421
422
        // フォント情報の復元
423 3
        $this->restoreFont();
424
    }
425
426
    /**
427
     * 購入商品詳細情報を設定する.
428
     *
429
     * @param Shipping $Shipping
430
     */
431 3
    protected function renderOrderDetailData(Shipping $Shipping)
432
    {
433 3
        $arrOrder = [];
434
        // テーブルの微調整を行うための購入商品詳細情報をarrayに変換する
435
436
        // =========================================
437
        // 受注詳細情報
438
        // =========================================
439 3
        $i = 0;
440
        /* @var OrderItem $OrderItem */
441 3
        foreach ($Shipping->getOrderItems() as $OrderItem) {
442
            // class categoryの生成
443 3
            $classCategory = '';
444
            /** @var OrderItem $OrderItem */
445 3
            if ($OrderItem->getClassCategoryName1()) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $OrderItem->getClassCategoryName1() of type string|null is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.

In PHP, under loose comparison (like ==, or !=, or switch conditions), values of different types might be equal.

For string values, the empty string '' is a special case, in particular the following results might be unexpected:

''   == false // true
''   == null  // true
'ab' == false // false
'ab' == null  // false

// It is often better to use strict comparison
'' === false // false
'' === null  // false
Loading history...
446 3
                $classCategory .= ' [ '.$OrderItem->getClassCategoryName1();
447 3
                if ($OrderItem->getClassCategoryName2() == '') {
448
                    $classCategory .= ' ]';
449
                } else {
450 3
                    $classCategory .= ' * '.$OrderItem->getClassCategoryName2().' ]';
451
                }
452
            }
453
454
            // product
455 3
            $arrOrder[$i][0] = sprintf('%s / %s / %s', $OrderItem->getProductName(), $OrderItem->getProductCode(), $classCategory);
456
            // 購入数量
457 3
            $arrOrder[$i][1] = number_format($OrderItem->getQuantity());
458
            // 税込金額(単価)
459 3
            $arrOrder[$i][2] = $this->eccubeExtension->getPriceFilter($OrderItem->getPrice());
460
            // 小計(商品毎)
461 3
            $arrOrder[$i][3] = $this->eccubeExtension->getPriceFilter($OrderItem->getTotalPrice());
462
463 3
            ++$i;
464
        }
465
466 3
        $Order = $Shipping->getOrder();
467
468
        // =========================================
469
        // 小計
470
        // =========================================
471 3
        $arrOrder[$i][0] = '';
472 3
        $arrOrder[$i][1] = '';
473 3
        $arrOrder[$i][2] = '';
474 3
        $arrOrder[$i][3] = '';
475
476 3
        ++$i;
477 3
        $arrOrder[$i][0] = '';
478 3
        $arrOrder[$i][1] = '';
479 3
        $arrOrder[$i][2] = '商品合計';
480 3
        $arrOrder[$i][3] = $this->eccubeExtension->getPriceFilter($Order->getSubtotal());
481
482 3
        ++$i;
483 3
        $arrOrder[$i][0] = '';
484 3
        $arrOrder[$i][1] = '';
485 3
        $arrOrder[$i][2] = '送料';
486 3
        $arrOrder[$i][3] = $this->eccubeExtension->getPriceFilter($Order->getDeliveryFeeTotal());
487
488 3
        ++$i;
489 3
        $arrOrder[$i][0] = '';
490 3
        $arrOrder[$i][1] = '';
491 3
        $arrOrder[$i][2] = '手数料';
492 3
        $arrOrder[$i][3] = $this->eccubeExtension->getPriceFilter($Order->getCharge());
493
494 3
        ++$i;
495 3
        $arrOrder[$i][0] = '';
496 3
        $arrOrder[$i][1] = '';
497 3
        $arrOrder[$i][2] = '値引き';
498 3
        $arrOrder[$i][3] = '- '.$this->eccubeExtension->getPriceFilter($Order->getDiscount());
499
500 3
        ++$i;
501 3
        $arrOrder[$i][0] = '';
502 3
        $arrOrder[$i][1] = '';
503 3
        $arrOrder[$i][2] = '請求金額';
504 3
        $arrOrder[$i][3] = $this->eccubeExtension->getPriceFilter($Order->getPaymentTotal());
505
506
        // PDFに設定する
507 3
        $this->setFancyTable($this->labelCell, $arrOrder, $this->widthCell);
508
    }
509
510
    /**
511
     * PDFへのテキスト書き込み
512
     *
513
     * @param int    $x     X座標
514
     * @param int    $y     Y座標
515
     * @param string $text  テキスト
516
     * @param int    $size  フォントサイズ
517
     * @param string $style フォントスタイル
518
     */
519 3
    protected function lfText($x, $y, $text, $size = 0, $style = '')
520
    {
521
        // 退避
522 3
        $bakFontStyle = $this->FontStyle;
523 3
        $bakFontSize = $this->FontSizePt;
524
525 3
        $this->SetFont('', $style, $size);
526 3
        $this->Text($x + $this->baseOffsetX, $y + $this->baseOffsetY, $text);
527
528
        // 復元
529 3
        $this->SetFont('', $bakFontStyle, $bakFontSize);
530
    }
531
532
    /**
533
     * Colored table.
534
     *
535
     * TODO: 後の列の高さが大きい場合、表示が乱れる。
536
     *
537
     * @param array $header 出力するラベル名一覧
538
     * @param array $data   出力するデータ
539
     * @param array $w      出力するセル幅一覧
540
     */
541 3
    protected function setFancyTable($header, $data, $w)
542
    {
543
        // フォント情報のバックアップ
544 3
        $this->backupFont();
545
546
        // 開始座標の設定
547 3
        $this->setBasePosition(0, 149);
548
549
        // Colors, line width and bold font
550 3
        $this->SetFillColor(216, 216, 216);
551 3
        $this->SetTextColor(0);
552 3
        $this->SetDrawColor(0, 0, 0);
553 3
        $this->SetLineWidth(.3);
554 3
        $this->SetFont(self::FONT_SJIS, 'B', 8);
555 3
        $this->SetFont('', 'B');
556
557
        // Header
558 3
        $this->Cell(5, 7, '', 0, 0, '', 0, '');
559 3
        $count = count($header);
560 3
        for ($i = 0; $i < $count; ++$i) {
561 3
            $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
562
        }
563 3
        $this->Ln();
564
565
        // Color and font restoration
566 3
        $this->SetFillColor(235, 235, 235);
567 3
        $this->SetTextColor(0);
568 3
        $this->SetFont('');
569
        // Data
570 3
        $fill = 0;
571 3
        $h = 4;
572 3
        foreach ($data as $row) {
573
            // 行のの処理
574 3
            $i = 0;
575 3
            $h = 4;
576 3
            $this->Cell(5, $h, '', 0, 0, '', 0, '');
577
578
            // Cellの高さを保持
579 3
            $cellHeight = 0;
580 3
            foreach ($row as $col) {
581
                // 列の処理
582
                // TODO: 汎用的ではない処理。この指定は呼び出し元で行うようにしたい。
583
                // テキストの整列を指定する
584 3
                $align = ($i == 0) ? 'L' : 'R';
585
586
                // セル高さが最大値を保持する
587 3
                if ($h >= $cellHeight) {
588 3
                    $cellHeight = $h;
589
                }
590
591
                // 最終列の場合は次の行へ移動
592
                // (0: 右へ移動(既定)/1: 次の行へ移動/2: 下へ移動)
593 3
                $ln = ($i == (count($row) - 1)) ? 1 : 0;
594
595 3
                $this->MultiCell(
596 3
                    $w[$i], // セル幅
597 3
                    $cellHeight, // セルの最小の高さ
598 3
                    $col, // 文字列
599 3
                    1, // 境界線の描画方法を指定
600 3
                    $align, // テキストの整列
601 3
                    $fill, // 背景の塗つぶし指定
602 3
                    $ln                 // 出力後のカーソルの移動方法
603
                );
604 3
                $h = $this->getLastH();
605
606 3
                ++$i;
607
            }
608 3
            $fill = !$fill;
609
        }
610 3
        $this->Cell(5, $h, '', 0, 0, '', 0, '');
611 3
        $this->Cell(array_sum($w), 0, '', 'T');
612 3
        $this->SetFillColor(255);
613
614
        // フォント情報の復元
615 3
        $this->restoreFont();
616
    }
617
618
    /**
619
     * 基準座標を設定する.
620
     *
621
     * @param int $x
622
     * @param int $y
623
     */
624 3
    protected function setBasePosition($x = null, $y = null)
625
    {
626
        // 現在のマージンを取得する
627 3
        $result = $this->getMargins();
628
629
        // 基準座標を指定する
630 3
        $actualX = is_null($x) ? $result['left'] : $x;
631 3
        $this->SetX($actualX);
632 3
        $actualY = is_null($y) ? $result['top'] : $y;
633 3
        $this->SetY($actualY);
634
    }
635
636
    /**
637
     * データが設定されていない場合にデフォルト値を設定する.
638
     *
639
     * @param array $formData
640
     */
641 3
    protected function setDefaultData(array &$formData)
642
    {
643
        $defaultList = [
644 3
            'title' => trans('admin.order.export.pdf.title.default'),
645 3
            'message1' => trans('admin.order.export.pdf.message1.default'),
646 3
            'message2' => trans('admin.order.export.pdf.message2.default'),
647 3
            'message3' => trans('admin.order.export.pdf.message3.default'),
648
        ];
649
650 3
        foreach ($defaultList as $key => $value) {
651 3
            if (is_null($formData[$key])) {
652 3
                $formData[$key] = $value;
653
            }
654
        }
655
    }
656
657
    /**
658
     * Font情報のバックアップ.
659
     */
660 3
    protected function backupFont()
661
    {
662
        // フォント情報のバックアップ
663 3
        $this->bakFontFamily = $this->FontFamily;
664 3
        $this->bakFontStyle = $this->FontStyle;
665 3
        $this->bakFontSize = $this->FontSizePt;
666
    }
667
668
    /**
669
     * Font情報の復元.
670
     */
671 3
    protected function restoreFont()
672
    {
673 3
        $this->SetFont($this->bakFontFamily, $this->bakFontStyle, $this->bakFontSize);
674
    }
675
}
676