From da0a037c273e5e7c2123ad7c747253e30274b5c4 Mon Sep 17 00:00:00 2001 From: "sosuke.iwabuchi" Date: Thu, 27 Jul 2023 11:44:05 +0900 Subject: [PATCH] =?UTF-8?q?PDF=E3=82=A4=E3=83=B3=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=B3=E3=83=AC=E3=82=B9=E3=83=9D=E3=83=B3=E3=82=B9=E3=81=AB?= =?UTF-8?q?=E3=83=95=E3=82=A1=E3=82=A4=E3=83=AB=E5=90=8D=E3=82=92=E8=BF=BD?= =?UTF-8?q?=E8=A8=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SATE_RECEIPT-23 document.pdf --- .../PDFDownLoadManagerHelloTechno.php | 9 ++++++++- .../ReceiptIssuingOrder/PDFDownLoadManager.php | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/PDFDownLoadManagerHelloTechno.php b/app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/PDFDownLoadManagerHelloTechno.php index 19fad8c..6aefdd1 100644 --- a/app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/PDFDownLoadManagerHelloTechno.php +++ b/app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/PDFDownLoadManagerHelloTechno.php @@ -70,11 +70,18 @@ class PDFDownLoadManagerHelloTechno extends PDFDownLoadManager $pdf = PDF::loadView('pdf/receipt_letters', [ 'orders' => $data ]); + + + $filename = $list->count() === 1 ? $this->getFileNameLetter() : sprintf( + "領収証はがき一括_%s.pdf", + DateUtil::now()->format('YmdHis') + ); // はがきサイズを指定 $ret = $pdf->setOption('page-height', 148) ->setOption('page-width', 100) ->setOption('encoding', 'utf-8') - ->inline(); + ->inline() + ->header("Content-Disposition", sprintf('inline; filename=%s', $filename)); return $ret; } diff --git a/app/Logic/ReceiptIssuingOrder/PDFDownLoadManager.php b/app/Logic/ReceiptIssuingOrder/PDFDownLoadManager.php index 21db602..5fa88f2 100644 --- a/app/Logic/ReceiptIssuingOrder/PDFDownLoadManager.php +++ b/app/Logic/ReceiptIssuingOrder/PDFDownLoadManager.php @@ -33,7 +33,8 @@ class PDFDownLoadManager extends ReceiptIssuingOrderManager $order = $this->order; $ret = $this->makeA4() - ->inline(); + ->inline() + ->header("Content-Disposition", sprintf('inline; filename=%s', $this->getFileNameA4())); if ($order->status_receipt_download_datetime === null) { $order->status_receipt_download_datetime = DateUtil::now(); @@ -77,7 +78,9 @@ class PDFDownLoadManager extends ReceiptIssuingOrderManager $ret = $pdf->setOption('page-height', 148) ->setOption('page-width', 100) ->setOption('encoding', 'utf-8') - ->inline(); + ->inline() + ->header("Content-Disposition", sprintf('inline; filename=%s', $this->getFileNameLetter())); + return $ret; } @@ -98,4 +101,13 @@ class PDFDownLoadManager extends ReceiptIssuingOrderManager ReceiptIssuingOrderTax::COL_NAME_TAX_AMOUNT => number_format(data_get($tax, ReceiptIssuingOrderTax::COL_NAME_TAX_AMOUNT, 0)) ?? 0, ]; } + + protected function getFileNameA4(): string + { + return sprintf("領収証_%s_%s.pdf", $this->order->receipt_no, DateUtil::now()->format('YmdHis')); + } + protected function getFileNameLetter(): string + { + return sprintf("領収証はがき_%s_%s.pdf", $this->order->receipt_no, DateUtil::now()->format('YmdHis')); + } }