|
|
|
@@ -14,6 +14,7 @@ use App\Kintone\Models\SubTable\Receipt\ReceiptDetail; |
|
|
|
use App\Kintone\Models\SubTable\Receipt\TaxDetail; |
|
|
|
use App\Util\DateUtil; |
|
|
|
use App\Util\TaxUtil; |
|
|
|
use Exception; |
|
|
|
use Illuminate\Support\Collection; |
|
|
|
use PDF; |
|
|
|
|
|
|
|
@@ -180,12 +181,7 @@ class ReceiptManager |
|
|
|
|
|
|
|
public function makePdf(): ReceiptReceipt |
|
|
|
{ |
|
|
|
$pdf = PDF::loadView("pdf/receipt", $this->getPdfData()) |
|
|
|
->setPaper("A4") |
|
|
|
// ->setOption('page-width', 210) |
|
|
|
// ->setOption('page-height', 148) |
|
|
|
->setOrientation("Portrait") |
|
|
|
->setOption('encoding', 'utf-8'); |
|
|
|
$pdf = $this->pdf(); |
|
|
|
|
|
|
|
|
|
|
|
$file = new ReceiptReceipt(); |
|
|
|
@@ -195,16 +191,47 @@ class ReceiptManager |
|
|
|
return $file; |
|
|
|
} |
|
|
|
|
|
|
|
private function savePdf() |
|
|
|
{ |
|
|
|
if ($this->receipt === null) { |
|
|
|
throw new Exception("領収証不正"); |
|
|
|
} |
|
|
|
|
|
|
|
$file = $this->makePdf(); |
|
|
|
$access = Receipt::getAccess(); |
|
|
|
|
|
|
|
$data = []; |
|
|
|
$data[] = [ |
|
|
|
'fileKey' => $access->filePut($file), |
|
|
|
'name' => sprintf("領収証_%s.pdf", $this->receipt->receiptNo), |
|
|
|
'contentType' => $file->getMimeType(), |
|
|
|
]; |
|
|
|
|
|
|
|
$this->receipt->set(Receipt::FIELD_RECEIPT_PDF_FILE, $data); |
|
|
|
|
|
|
|
$this->receipt->save(); |
|
|
|
} |
|
|
|
|
|
|
|
public function getPdf() |
|
|
|
{ |
|
|
|
$pdf = PDF::loadView("pdf/receipt", $this->getPdfData()) |
|
|
|
$pdf = $this->pdf(); |
|
|
|
|
|
|
|
if ($this->receipt->receiptPdfFileDownloadDatetime === null) { |
|
|
|
$this->receipt->receiptPdfFileDownloadDatetime = DateUtil::now(); |
|
|
|
$this->savePdf(); |
|
|
|
} |
|
|
|
|
|
|
|
return $pdf->inline(); |
|
|
|
} |
|
|
|
|
|
|
|
private function pdf() |
|
|
|
{ |
|
|
|
return PDF::loadView("pdf/receipt", $this->getPdfData()) |
|
|
|
->setPaper("A4") |
|
|
|
// ->setOption('page-width', 210) |
|
|
|
// ->setOption('page-height', 148) |
|
|
|
->setOrientation("Portrait") |
|
|
|
->setOption('encoding', 'utf-8'); |
|
|
|
|
|
|
|
return $pdf->inline(); |
|
|
|
} |
|
|
|
|
|
|
|
public function getHtml() |
|
|
|
@@ -215,10 +242,9 @@ class ReceiptManager |
|
|
|
private function makeFileName(ReceiptReceipt $file) |
|
|
|
{ |
|
|
|
return sprintf( |
|
|
|
"領収証_%s_%s_%s.%s", |
|
|
|
"領収証_%s_%s.%s", |
|
|
|
$this->receipt->receiptNo, |
|
|
|
$this->receipt->customerName, |
|
|
|
$this->receipt->receiptPurpose, |
|
|
|
$file->getFileExtension(), |
|
|
|
); |
|
|
|
} |
|
|
|
|