[PROMOTE] 晉升捐贈發票列印修正至 demo

1. 捐贈發票排除列印按鈕並補上不可列印提示,後端加守衛防偽造 POST。
This commit is contained in:
sky121113 2026-06-16 11:41:56 +08:00
commit 372f2fc55d
5 changed files with 13 additions and 0 deletions

View File

@ -1155,6 +1155,10 @@ class SalesController extends Controller
if ($invoice->status !== Invoice::STATUS_ISSUED || empty($invoice->invoice_no)) {
return back()->with('error', __('Only issued invoices can be printed'));
}
// 捐贈發票依法無紙本、不可列印(綠界 InvoicePrint 會回查無資料)
if (!empty($invoice->love_code)) {
return back()->with('error', __('Donation invoices cannot be printed'));
}
$machine = $invoice->machine;
if (!$machine || !$ecpay->configForMachine($machine)) {
return back()->with('error', __('This machine has no ECPay invoice settings'));

View File

@ -587,6 +587,7 @@
"Displayed below Logo on the left (defaults to customer name).": "Displayed below Logo on the left (defaults to customer name).",
"Displayed below main title on the left.": "Displayed below main title on the left.",
"Displaying": "Displaying",
"Donation invoices cannot be printed": "Donation invoices cannot be printed",
"Done": "Done",
"Door Closed": "Door Closed",
"Door Opened": "Door Opened",

View File

@ -587,6 +587,7 @@
"Displayed below Logo on the left (defaults to customer name).": "左側のロゴの下に表示されるメインタイトル(未設定の場合はデフォルトで顧客名になります)。",
"Displayed below main title on the left.": "左側のメインタイトルの下に表示されるサブタイトル。",
"Displaying": "表示中",
"Donation invoices cannot be printed": "寄付の領収書は印刷できません",
"Done": "完了",
"Door Closed": "扉が閉まりました",
"Door Opened": "扉が開きました",

View File

@ -587,6 +587,7 @@
"Displayed below Logo on the left (defaults to customer name).": "顯示於左側 Logo 下方的主標題(未設定則預設帶入客戶名稱)。",
"Displayed below main title on the left.": "顯示於左側主標題下方的副標題/英文名稱。",
"Displaying": "目前顯示",
"Donation invoices cannot be printed": "捐贈發票無法列印",
"Done": "已完成",
"Door Closed": "機門已關閉",
"Door Opened": "機門已開啟",

View File

@ -292,6 +292,8 @@
'void' => ['label' => __('Void'), 'color' => 'slate'],
];
$invBadge = $invStatusMap[$invStatus] ?? ['label' => $invStatus, 'color' => 'slate'];
// 捐贈發票依法無紙本、不可列印(綠界 InvoicePrint 會回查無資料)
$invPrintable = empty($order->invoice->love_code);
@endphp
<div class="relative flex flex-col sm:flex-row sm:items-center justify-between gap-6">
<div class="space-y-3">
@ -309,12 +311,16 @@
@if($invStatus === 'issued')
<div class="flex items-center gap-3">
@if($invPrintable)
<form method="POST" action="{{ route('admin.sales.invoices.print', $order->invoice) }}" target="_blank">
@csrf
<button type="submit" class="flex-1 sm:flex-none px-6 py-3 rounded-xl bg-white dark:bg-slate-800 text-slate-600 dark:text-slate-300 font-bold text-xs border border-slate-200 dark:border-slate-700 hover:bg-indigo-500 hover:text-white hover:border-indigo-500 transition-all duration-300 shadow-sm">
{{ __('Print Invoice') }}
</button>
</form>
@else
<span class="text-[11px] font-bold text-slate-400 dark:text-slate-500 px-2">{{ __('Donation invoices cannot be printed') }}</span>
@endif
<form method="POST" action="{{ route('admin.sales.invoices.void', $order->invoice) }}"
onsubmit="return confirm('{{ __('Void this invoice?') }}')">
@csrf