Completed
Pull Request — experimental/sf (#3426)
by k-yamamura
122:47 queued 115:15
created

OrderPdfService::renderEtcData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1

Importance

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