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')); + } }