Browse Source

PDFインラインレスポンスにファイル名を追記

SATE_RECEIPT-23 document.pdf
develop
sosuke.iwabuchi 2 years ago
parent
commit
da0a037c27
2 changed files with 22 additions and 3 deletions
  1. +8
    -1
      app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/PDFDownLoadManagerHelloTechno.php
  2. +14
    -2
      app/Logic/ReceiptIssuingOrder/PDFDownLoadManager.php

+ 8
- 1
app/Logic/ReceiptIssuingOrder/Custom/HelloTechno/PDFDownLoadManagerHelloTechno.php View File

@@ -70,11 +70,18 @@ class PDFDownLoadManagerHelloTechno extends PDFDownLoadManager
$pdf = PDF::loadView('pdf/receipt_letters', [ $pdf = PDF::loadView('pdf/receipt_letters', [
'orders' => $data 'orders' => $data
]); ]);


$filename = $list->count() === 1 ? $this->getFileNameLetter() : sprintf(
"領収証はがき一括_%s.pdf",
DateUtil::now()->format('YmdHis')
);
// はがきサイズを指定 // はがきサイズを指定
$ret = $pdf->setOption('page-height', 148) $ret = $pdf->setOption('page-height', 148)
->setOption('page-width', 100) ->setOption('page-width', 100)
->setOption('encoding', 'utf-8') ->setOption('encoding', 'utf-8')
->inline();
->inline()
->header("Content-Disposition", sprintf('inline; filename=%s', $filename));
return $ret; return $ret;
} }




+ 14
- 2
app/Logic/ReceiptIssuingOrder/PDFDownLoadManager.php View File

@@ -33,7 +33,8 @@ class PDFDownLoadManager extends ReceiptIssuingOrderManager
$order = $this->order; $order = $this->order;


$ret = $this->makeA4() $ret = $this->makeA4()
->inline();
->inline()
->header("Content-Disposition", sprintf('inline; filename=%s', $this->getFileNameA4()));
if ($order->status_receipt_download_datetime === null) { if ($order->status_receipt_download_datetime === null) {


$order->status_receipt_download_datetime = DateUtil::now(); $order->status_receipt_download_datetime = DateUtil::now();
@@ -77,7 +78,9 @@ class PDFDownLoadManager extends ReceiptIssuingOrderManager
$ret = $pdf->setOption('page-height', 148) $ret = $pdf->setOption('page-height', 148)
->setOption('page-width', 100) ->setOption('page-width', 100)
->setOption('encoding', 'utf-8') ->setOption('encoding', 'utf-8')
->inline();
->inline()
->header("Content-Disposition", sprintf('inline; filename=%s', $this->getFileNameLetter()));



return $ret; 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, 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'));
}
} }

Loading…
Cancel
Save