ソースを参照

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

SATE_RECEIPT-23 document.pdf
develop
sosuke.iwabuchi 2年前
コミット
da0a037c27
2個のファイルの変更22行の追加3行の削除
  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 ファイルの表示

@@ -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;
}



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

読み込み中…
キャンセル
保存