Failed Conditions
Pull Request — experimental/sf (#3336)
by
unknown
471:18 queued 461:42
created

OrderPdfService::getPdfFileName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
ccs 7
cts 7
cp 1
crap 3
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\Order;
20
use Eccube\Entity\OrderItem;
21
use Eccube\Repository\BaseInfoRepository;
22
use Eccube\Repository\OrderRepository;
23
use Eccube\Repository\OrderPdfRepository;
24
use setasign\Fpdi\TcpdfFpdi;
25
26
/**
27
 * Class OrderPdfService.
28
 * Do export pdf function.
29
 */
30
class OrderPdfService extends TcpdfFpdi
31
{
32
    /** @var OrderRepository */
33
    protected $orderRepository;
34
35
    /** @var OrderPdfRepository */
36
    protected $orderPdfRepository;
37
38
    /** @var TaxRuleService */
39
    protected $taxRuleService;
40
    /**
41
     * @var Application
42
     */
43
    private $eccubeConfig;
44
45
    // ====================================
46
    // 定数宣言
47
    // ====================================
48
49
    /** 通貨単位 */
50
    const MONETARY_UNIT = '円';
51
52
    /** ダウンロードするPDFファイルのデフォルト名 */
53
    const DEFAULT_PDF_FILE_NAME = 'nouhinsyo.pdf';
54
55
    /** FONT ゴシック */
56
    const FONT_GOTHIC = 'kozgopromedium';
57
    /** FONT 明朝 */
58
    const FONT_SJIS = 'kozminproregular';
59
60
    // ====================================
61
    // 変数宣言
62
    // ====================================
63
64
    /** @var BaseInfo */
65
    public $baseInfoRepository;
66
67
    /** 購入詳細情報 ラベル配列
68
     * @var array
69
     */
70
    private $labelCell = [];
71
72
    /*** 購入詳細情報 幅サイズ配列
73
     * @var array
74
     */
75
    private $widthCell = [];
76
77
    /** 最後に処理した注文番号 @var string */
78
    private $lastOrderId = null;
79
80
    // --------------------------------------
81
    // Font情報のバックアップデータ
82
    /** @var string フォント名 */
83
    private $bakFontFamily;
84
    /** @var string フォントスタイル */
85
    private $bakFontStyle;
86
    /** @var string フォントサイズ */
87
    private $bakFontSize;
88
    // --------------------------------------
89
90
    // lfTextのoffset
91
    private $baseOffsetX = 0;
92
    private $baseOffsetY = -4;
93
94
    /** ダウンロードファイル名 @var string */
95
    private $downloadFileName = null;
96
97
    /** 発行日 @var string */
98
    private $issueDate = '';
99
100
    /**
101
     * OrderPdfService constructor.
102
     *
103
     * @param EccubeConfig $eccubeConfig
0 ignored issues
show
introduced by
Expected 7 spaces after parameter type; 1 found
Loading history...
104
     * @param OrderRepository $orderRepository
0 ignored issues
show
introduced by
Expected 4 spaces after parameter type; 1 found
Loading history...
105
     * @param TaxRuleService $taxRuleService
0 ignored issues
show
introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
106
     * @param BaseInfoRepository $baseInfoRepository
107
     */
108 29
    public function __construct(EccubeConfig $eccubeConfig, OrderRepository $orderRepository, TaxRuleService $taxRuleService, BaseInfoRepository $baseInfoRepository)
109
    {
110 29
        $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...
111 29
        $this->baseInfoRepository = $baseInfoRepository->get();
112 29
        $this->orderRepository = $orderRepository;
113 29
        $this->taxRuleService = $taxRuleService;
114 29
        parent::__construct();
115
116
        // 購入詳細情報の設定を行う
117
        // 動的に入れ替えることはない
118 29
        $this->labelCell[] = '商品名 / 商品コード / [ 規格 ]';
119 29
        $this->labelCell[] = '数量';
120 29
        $this->labelCell[] = '単価';
121 29
        $this->labelCell[] = '金額(税込)';
122 29
        $this->widthCell = [110.3, 12, 21.7, 24.5];
123
124
        // Fontの設定しておかないと文字化けを起こす
125 29
        $this->SetFont(self::FONT_SJIS);
126
127
        // PDFの余白(上左右)を設定
128 29
        $this->SetMargins(15, 20);
129
130
        // ヘッダーの出力を無効化
131 29
        $this->setPrintHeader(false);
132
133
        // フッターの出力を無効化
134 29
        $this->setPrintFooter(true);
135 29
        $this->setFooterMargin();
136 29
        $this->setFooterFont([self::FONT_SJIS, '', 8]);
137
    }
138
139
    /**
140
     * 注文情報からPDFファイルを作成する.
141
     *
142
     * @param array $formData
143
     *                        [KEY]
144
     *                        ids: 注文番号
145
     *                        issue_date: 発行日
146
     *                        title: タイトル
147
     *                        message1: メッセージ1行目
148
     *                        message2: メッセージ2行目
149
     *                        message3: メッセージ3行目
150
     *                        note1: 備考1行目
151
     *                        note2: 備考2行目
152
     *                        note3: 備考3行目
153
     *
154
     * @return bool
155
     */
156 3
    public function makePdf(array $formData)
157
    {
158
        // 発行日の設定
159 3
        $this->issueDate = '作成日: '.$formData['issue_date']->format('Y年m月d日');
160
        // ダウンロードファイル名の初期化
161 3
        $this->downloadFileName = null;
162
163
        // データが空であれば終了
164 3
        if (!$formData['ids']) {
165
            return false;
166
        }
167
168
        // 注文番号をStringからarrayに変換
169 3
        $ids = explode(',', $formData['ids']);
170
171
        // 空文字列の場合のデフォルトメッセージを設定する
172 3
        $this->setDefaultData($formData);
173
174
        // テンプレートファイルを読み込む
175 3
        $userPath = $this->eccubeConfig['eccube_theme_src_dir'].'/admin/Order/PdfTemplate/nouhinsyo1.pdf';
176 3
        $this->setSourceFile($userPath);
177
178 3
        foreach ($ids as $id) {
179 3
            $this->lastOrderId = $id;
180
181
            // 注文番号から受注情報を取得する
182
            /** @var Order $order */
183 3
            $order = $this->orderRepository->find($id);
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $order is correct as $this->orderRepository->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...
184 3
            if (!$order) {
185
                // 注文情報の取得ができなかった場合
186
                continue;
187
            }
188
189
            // PDFにページを追加する
190 3
            $this->addPdfPage();
191
192
            // タイトルを描画する
193 3
            $this->renderTitle($formData['title']);
194
195
            // 店舗情報を描画する
196 3
            $this->renderShopData();
197
198
            // 注文情報を描画する
199 3
            $this->renderOrderData($order);
200
201
            // メッセージを描画する
202 3
            $this->renderMessageData($formData);
203
204
            // 受注詳細情報を描画する
205 3
            $this->renderOrderDetailData($order);
206
207
            // 備考を描画する
208 3
            $this->renderEtcData($formData);
209
        }
210
211 3
        return true;
212
    }
213
214
    /**
215
     * PDFファイルを出力する.
216
     *
217
     * @return string|mixed
218
     */
219 3
    public function outputPdf()
220
    {
221 3
        return $this->Output($this->getPdfFileName(), 'S');
222
    }
223
224
    /**
225
     * PDFファイル名を取得する
226
     * PDFが1枚の時は注文番号をファイル名につける.
227
     *
228
     * @return string ファイル名
229
     */
230 3
    public function getPdfFileName()
231
    {
232 3
        if (!is_null($this->downloadFileName)) {
233 3
            return $this->downloadFileName;
234
        }
235 3
        $this->downloadFileName = self::DEFAULT_PDF_FILE_NAME;
236 3
        if ($this->PageNo() == 1) {
237 3
            $this->downloadFileName = 'nouhinsyo-No'.$this->lastOrderId.'.pdf';
238
        }
239
240 3
        return $this->downloadFileName;
241
    }
242
243
    /**
244
     * フッターに発行日を出力する.
245
     */
246 3
    public function Footer()
0 ignored issues
show
Coding Style introduced by
Method name "OrderPdfService::Footer" is not in camel caps format
Loading history...
247
    {
248 3
        $this->Cell(0, 0, $this->issueDate, 0, 0, 'R');
249
    }
250
251
    /**
252
     * 作成するPDFのテンプレートファイルを指定する.
253
     */
254 3
    protected function addPdfPage()
255
    {
256
        // ページを追加
257 3
        $this->AddPage();
258
259
        // テンプレートに使うテンプレートファイルのページ番号を取得
260 3
        $tplIdx = $this->importPage(1);
261
262
        // テンプレートに使うテンプレートファイルのページ番号を指定
263 3
        $this->useTemplate($tplIdx, null, null, null, null, true);
264
    }
265
266
    /**
267
     * PDFに店舗情報を設定する
268
     * ショップ名、ロゴ画像以外はdtb_helpに登録されたデータを使用する.
269
     */
270 3
    protected function renderShopData()
271
    {
272
        // 基準座標を設定する
273 3
        $this->setBasePosition();
274
275
        // ショップ名
276 3
        $this->lfText(125, 60, $this->baseInfoRepository->getShopName(), 8, 'B');
277
278
        // 都道府県+所在地
279 3
        $text = $this->baseInfoRepository->getAddr01();
280 3
        $this->lfText(125, 65, $text, 8);
281 3
        $this->lfText(125, 69, $this->baseInfoRepository->getAddr02(), 8);
282
283
        // 電話番号
284 3
        $text = 'TEL: '.$this->baseInfoRepository->getPhoneNumber();
285 3
        $this->lfText(125, 72, $text, 8);  //TEL・FAX
286
287
        // メールアドレス
288 3
        if (strlen($this->baseInfoRepository->getEmail01()) > 0) {
289 3
            $text = 'Email: '.$this->baseInfoRepository->getEmail01();
290 3
            $this->lfText(125, 75, $text, 8);      // Email
291
        }
292
293
        // ロゴ画像(app配下のロゴ画像を優先して読み込む)
294 3
        $logoFile = $this->eccubeConfig['eccube_theme_src_dir'].'/admin/Order/PdfTemplate/logo.png';
295 3
        $this->Image($logoFile, 124, 46, 40);
296
    }
297
298
    /**
299
     * メッセージを設定する.
300
     *
301
     * @param array $formData
302
     */
303 3
    protected function renderMessageData(array $formData)
304
    {
305 3
        $this->lfText(27, 70, $formData['message1'], 8);  //メッセージ1
306 3
        $this->lfText(27, 74, $formData['message2'], 8);  //メッセージ2
307 3
        $this->lfText(27, 78, $formData['message3'], 8);  //メッセージ3
308
    }
309
310
    /**
311
     * PDFに備考を設定数.
312
     *
313
     * @param array $formData
314
     */
315 3
    protected function renderEtcData(array $formData)
316
    {
317
        // フォント情報のバックアップ
318 3
        $this->backupFont();
319
320 3
        $this->Cell(0, 10, '', 0, 1, 'C', 0, '');
321
322 3
        $this->SetFont(self::FONT_GOTHIC, 'B', 9);
323 3
        $this->MultiCell(0, 6, '< 備考 >', 'T', 2, 'L', 0, '');
324
325 3
        $this->SetFont(self::FONT_SJIS, '', 8);
326
327 3
        $this->Ln();
328
        // rtrimを行う
329 3
        $text = preg_replace('/\s+$/us', '', $formData['note1']."\n".$formData['note2']."\n".$formData['note3']);
330 3
        $this->MultiCell(0, 4, $text, '', 2, 'L', 0, '');
331
332
        // フォント情報の復元
333 3
        $this->restoreFont();
334
    }
335
336
    /**
337
     * タイトルをPDFに描画する.
338
     *
339
     * @param string $title
340
     */
341 3
    protected function renderTitle($title)
342
    {
343
        // 基準座標を設定する
344 3
        $this->setBasePosition();
345
346
        // フォント情報のバックアップ
347 3
        $this->backupFont();
348
349
        //文書タイトル(納品書・請求書)
350 3
        $this->SetFont(self::FONT_GOTHIC, '', 15);
351 3
        $this->Cell(0, 10, $title, 0, 2, 'C', 0, '');
352 3
        $this->Cell(0, 66, '', 0, 2, 'R', 0, '');
353 3
        $this->Cell(5, 0, '', 0, 0, 'R', 0, '');
354
355
        // フォント情報の復元
356 3
        $this->restoreFont();
357
    }
358
359
    /**
360
     * 購入者情報を設定する.
361
     *
362
     * @param Order $Order
363
     */
364 3
    protected function renderOrderData(Order $Order)
365
    {
366
        // 基準座標を設定する
367 3
        $this->setBasePosition();
368
369
        // フォント情報のバックアップ
370 3
        $this->backupFont();
371
372
        // =========================================
373
        // 購入者情報部
374
        // =========================================
375
376
        // 購入者都道府県+住所1
377 3
        $text = $Order->getPref().$Order->getAddr01();
378 3
        $this->lfText(27, 47, $text, 10);
379 3
        $this->lfText(27, 51, $Order->getAddr02(), 10); //購入者住所2
380
381
        // 購入者氏名
382 3
        $text = $Order->getName01().' '.$Order->getName02().' 様';
383 3
        $this->lfText(27, 59, $text, 11);
384
385
        // =========================================
386
        // お買い上げ明細部
387
        // =========================================
388 3
        $this->SetFont(self::FONT_SJIS, '', 10);
389
390
        //ご注文日
391 3
        $orderDate = $Order->getCreateDate()->format('Y/m/d H:i');
392 3
        if ($Order->getOrderDate()) {
393
            $orderDate = $Order->getOrderDate()->format('Y/m/d H:i');
394
        }
395
396 3
        $this->lfText(25, 125, $orderDate, 10);
397
        //注文番号
398 3
        $this->lfText(25, 135, $Order->getId(), 10);
399
400
        // 総合計金額
401 3
        $this->SetFont(self::FONT_SJIS, 'B', 15);
402 3
        $paymentTotalText = number_format($Order->getPaymentTotal()).' '.self::MONETARY_UNIT;
403
404 3
        $this->setBasePosition(120, 95.5);
405 3
        $this->Cell(5, 7, '', 0, 0, '', 0, '');
406 3
        $this->Cell(67, 8, $paymentTotalText, 0, 2, 'R', 0, '');
407 3
        $this->Cell(0, 45, '', 0, 2, '', 0, '');
408
409
        // フォント情報の復元
410 3
        $this->restoreFont();
411
    }
412
413
    /**
414
     * 購入商品詳細情報を設定する.
415
     *
416
     * @param Order $Order
417
     */
418 3
    protected function renderOrderDetailData(Order $Order)
419
    {
420 3
        $arrOrder = [];
421
        // テーブルの微調整を行うための購入商品詳細情報をarrayに変換する
422
423
        // =========================================
424
        // 受注詳細情報
425
        // =========================================
426 3
        $i = 0;
427
        /* @var OrderItem $OrderItem */
428 3
        foreach ($Order->getOrderItems() as $OrderItem) {
429
            // class categoryの生成
430 3
            $classCategory = '';
431
            /** @var OrderItem $OrderItem */
432 3
            if ($OrderItem->getClassCategoryName1()) {
433 3
                $classCategory .= ' [ '.$OrderItem->getClassCategoryName1();
434 3
                if ($OrderItem->getClassCategoryName2() == '') {
435 2
                    $classCategory .= ' ]';
436
                } else {
437 1
                    $classCategory .= ' * '.$OrderItem->getClassCategoryName2().' ]';
438
                }
439
            }
440
            // 税
441 3
            $tax = $this->taxRuleService->calcTax($OrderItem->getPrice(), $OrderItem->getTaxRate(), \Eccube\Entity\Master\RoundingType::ROUND);
442 3
            $OrderItem->setPriceIncTax($OrderItem->getPrice() + $tax);
443
444
            // product
445 3
            $arrOrder[$i][0] = sprintf('%s / %s / %s', $OrderItem->getProductName(), $OrderItem->getProductCode(), $classCategory);
446
            // 購入数量
447 3
            $arrOrder[$i][1] = number_format($OrderItem->getQuantity());
448
            // 税込金額(単価)
449 3
            $arrOrder[$i][2] = number_format($OrderItem->getPriceIncTax()).self::MONETARY_UNIT;
450
            // 小計(商品毎)
451 3
            $arrOrder[$i][3] = number_format($OrderItem->getTotalPrice()).self::MONETARY_UNIT;
452
453 3
            ++$i;
454
        }
455
456
        // =========================================
457
        // 小計
458
        // =========================================
459 3
        $arrOrder[$i][0] = '';
460 3
        $arrOrder[$i][1] = '';
461 3
        $arrOrder[$i][2] = '';
462 3
        $arrOrder[$i][3] = '';
463
464 3
        ++$i;
465 3
        $arrOrder[$i][0] = '';
466 3
        $arrOrder[$i][1] = '';
467 3
        $arrOrder[$i][2] = '商品合計';
468 3
        $arrOrder[$i][3] = number_format($Order->getSubtotal()).self::MONETARY_UNIT;
469
470 3
        ++$i;
471 3
        $arrOrder[$i][0] = '';
472 3
        $arrOrder[$i][1] = '';
473 3
        $arrOrder[$i][2] = '送料';
474 3
        $arrOrder[$i][3] = number_format($Order->getDeliveryFeeTotal()).self::MONETARY_UNIT;
475
476 3
        ++$i;
477 3
        $arrOrder[$i][0] = '';
478 3
        $arrOrder[$i][1] = '';
479 3
        $arrOrder[$i][2] = '手数料';
480 3
        $arrOrder[$i][3] = number_format($Order->getCharge()).self::MONETARY_UNIT;
481
482 3
        ++$i;
483 3
        $arrOrder[$i][0] = '';
484 3
        $arrOrder[$i][1] = '';
485 3
        $arrOrder[$i][2] = '値引き';
486 3
        $arrOrder[$i][3] = '- '.number_format($Order->getDiscount()).self::MONETARY_UNIT;
487
488 3
        ++$i;
489 3
        $arrOrder[$i][0] = '';
490 3
        $arrOrder[$i][1] = '';
491 3
        $arrOrder[$i][2] = '請求金額';
492 3
        $arrOrder[$i][3] = number_format($Order->getPaymentTotal()).self::MONETARY_UNIT;
493
494
        // PDFに設定する
495 3
        $this->setFancyTable($this->labelCell, $arrOrder, $this->widthCell);
496
    }
497
498
    /**
499
     * PDFへのテキスト書き込み
500
     *
501
     * @param int    $x     X座標
502
     * @param int    $y     Y座標
503
     * @param string $text  テキスト
504
     * @param int    $size  フォントサイズ
505
     * @param string $style フォントスタイル
506
     */
507 3
    protected function lfText($x, $y, $text, $size = 0, $style = '')
508
    {
509
        // 退避
510 3
        $bakFontStyle = $this->FontStyle;
511 3
        $bakFontSize = $this->FontSizePt;
512
513 3
        $this->SetFont('', $style, $size);
514 3
        $this->Text($x + $this->baseOffsetX, $y + $this->baseOffsetY, $text);
515
516
        // 復元
517 3
        $this->SetFont('', $bakFontStyle, $bakFontSize);
518
    }
519
520
    /**
521
     * Colored table.
522
     *
523
     * TODO: 後の列の高さが大きい場合、表示が乱れる。
524
     *
525
     * @param array $header 出力するラベル名一覧
526
     * @param array $data   出力するデータ
527
     * @param array $w      出力するセル幅一覧
528
     */
529 3
    protected function setFancyTable($header, $data, $w)
530
    {
531
        // フォント情報のバックアップ
532 3
        $this->backupFont();
533
534
        // 開始座標の設定
535 3
        $this->setBasePosition(0, 149);
536
537
        // Colors, line width and bold font
538 3
        $this->SetFillColor(216, 216, 216);
539 3
        $this->SetTextColor(0);
540 3
        $this->SetDrawColor(0, 0, 0);
541 3
        $this->SetLineWidth(.3);
542 3
        $this->SetFont(self::FONT_SJIS, 'B', 8);
543 3
        $this->SetFont('', 'B');
544
545
        // Header
546 3
        $this->Cell(5, 7, '', 0, 0, '', 0, '');
547 3
        $count = count($header);
548 3
        for ($i = 0; $i < $count; ++$i) {
549 3
            $this->Cell($w[$i], 7, $header[$i], 1, 0, 'C', 1);
550
        }
551 3
        $this->Ln();
552
553
        // Color and font restoration
554 3
        $this->SetFillColor(235, 235, 235);
555 3
        $this->SetTextColor(0);
556 3
        $this->SetFont('');
557
        // Data
558 3
        $fill = 0;
559 3
        $h = 4;
560 3
        foreach ($data as $row) {
561
            // 行のの処理
562 3
            $i = 0;
563 3
            $h = 4;
564 3
            $this->Cell(5, $h, '', 0, 0, '', 0, '');
565
566
            // Cellの高さを保持
567 3
            $cellHeight = 0;
568 3
            foreach ($row as $col) {
569
                // 列の処理
570
                // TODO: 汎用的ではない処理。この指定は呼び出し元で行うようにしたい。
571
                // テキストの整列を指定する
572 3
                $align = ($i == 0) ? 'L' : 'R';
573
574
                // セル高さが最大値を保持する
575 3
                if ($h >= $cellHeight) {
576 3
                    $cellHeight = $h;
577
                }
578
579
                // 最終列の場合は次の行へ移動
580
                // (0: 右へ移動(既定)/1: 次の行へ移動/2: 下へ移動)
581 3
                $ln = ($i == (count($row) - 1)) ? 1 : 0;
582
583 3
                $this->MultiCell(
584 3
                    $w[$i],             // セル幅
585 3
                    $cellHeight,        // セルの最小の高さ
586 3
                    $col,               // 文字列
587 3
                    1,                  // 境界線の描画方法を指定
588 3
                    $align,             // テキストの整列
589 3
                    $fill,              // 背景の塗つぶし指定
590 3
                    $ln                 // 出力後のカーソルの移動方法
591
                );
592 3
                $h = $this->getLastH();
593
594 3
                ++$i;
595
            }
596 3
            $fill = !$fill;
597
        }
598 3
        $this->Cell(5, $h, '', 0, 0, '', 0, '');
599 3
        $this->Cell(array_sum($w), 0, '', 'T');
600 3
        $this->SetFillColor(255);
601
602
        // フォント情報の復元
603 3
        $this->restoreFont();
604
    }
605
606
    /**
607
     * 基準座標を設定する.
608
     *
609
     * @param int $x
610
     * @param int $y
611
     */
612 3
    protected function setBasePosition($x = null, $y = null)
613
    {
614
        // 現在のマージンを取得する
615 3
        $result = $this->getMargins();
616
617
        // 基準座標を指定する
618 3
        $actualX = is_null($x) ? $result['left'] : $x;
619 3
        $this->SetX($actualX);
620 3
        $actualY = is_null($y) ? $result['top'] : $y;
621 3
        $this->SetY($actualY);
622
    }
623
624
    /**
625
     * データが設定されていない場合にデフォルト値を設定する.
626
     *
627
     * @param array $formData
628
     */
629 3
    protected function setDefaultData(array &$formData)
630
    {
631
        $defaultList = [
632 3
            'title' => trans('admin.order.export.pdf.title.default'),
633 3
            'message1' => trans('admin.order.export.pdf.message1.default'),
634 3
            'message2' => trans('admin.order.export.pdf.message2.default'),
635 3
            'message3' => trans('admin.order.export.pdf.message3.default'),
636
        ];
637
638 3
        foreach ($defaultList as $key => $value) {
639 3
            if (is_null($formData[$key])) {
640 3
                $formData[$key] = $value;
641
            }
642
        }
643
    }
644
645
    /**
646
     * Font情報のバックアップ.
647
     */
648 3
    protected function backupFont()
649
    {
650
        // フォント情報のバックアップ
651 3
        $this->bakFontFamily = $this->FontFamily;
652 3
        $this->bakFontStyle = $this->FontStyle;
653 3
        $this->bakFontSize = $this->FontSizePt;
654
    }
655
656
    /**
657
     * Font情報の復元.
658
     */
659 3
    protected function restoreFont()
660
    {
661 3
        $this->SetFont($this->bakFontFamily, $this->bakFontStyle, $this->bakFontSize);
662
    }
663
}
664