diff --git a/app/Http/Controllers/Admin/SalesController.php b/app/Http/Controllers/Admin/SalesController.php index fd5b87a..9e10917 100644 --- a/app/Http/Controllers/Admin/SalesController.php +++ b/app/Http/Controllers/Admin/SalesController.php @@ -30,7 +30,7 @@ class SalesController extends Controller // 取貨碼設定 public function pickupCodes(Request $request) { - $query = PickupCode::with(['machine', 'creator'])->latest(); + $query = PickupCode::with(['machine.slots.product', 'creator'])->latest(); if ($request->search) { $query->where(function($q) use ($request) { @@ -70,7 +70,8 @@ class SalesController extends Controller 'expires_hours' => 'nullable|integer|min:1|max:720', // 最長一個月 ]); - $expiresAt = now()->addHours($request->expires_hours ?? 24); + $machine = Machine::findOrFail($validated['machine_id']); + $expiresAt = now()->addHours((int) ($request->expires_hours ?? 24)); $pickupCode = PickupCode::create([ 'machine_id' => $validated['machine_id'], @@ -78,6 +79,7 @@ class SalesController extends Controller 'code' => PickupCode::generateUniqueCode($validated['machine_id']), 'expires_at' => $expiresAt, 'status' => 'active', + 'company_id' => $machine->company_id, 'created_by' => Auth::id(), ]); @@ -166,7 +168,8 @@ class SalesController extends Controller 'custom_code' => 'nullable|string|min:4|max:12', ]); - $expiresAt = $request->expires_days ? now()->addDays($request->expires_days) : null; + $machine = Machine::findOrFail($validated['machine_id']); + $expiresAt = $request->expires_days ? now()->addDays((int) $request->expires_days) : null; $passCode = PassCode::create([ 'machine_id' => $validated['machine_id'], @@ -174,6 +177,7 @@ class SalesController extends Controller 'code' => $validated['custom_code'] ?? PassCode::generateUniqueCode($validated['machine_id']), 'expires_at' => $expiresAt, 'status' => 'active', + 'company_id' => $machine->company_id, 'created_by' => Auth::id(), ]); diff --git a/app/Models/Transaction/PassCode.php b/app/Models/Transaction/PassCode.php index 142f3e4..76155bb 100644 --- a/app/Models/Transaction/PassCode.php +++ b/app/Models/Transaction/PassCode.php @@ -3,7 +3,7 @@ namespace App\Models\Transaction; use App\Models\Machine\Machine; -use App\Models\User; +use App\Models\System\User; use App\Traits\TenantScoped; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; diff --git a/app/Models/Transaction/PickupCode.php b/app/Models/Transaction/PickupCode.php index 960174f..c72bc88 100644 --- a/app/Models/Transaction/PickupCode.php +++ b/app/Models/Transaction/PickupCode.php @@ -3,7 +3,7 @@ namespace App\Models\Transaction; use App\Models\Machine\Machine; -use App\Models\User; +use App\Models\System\User; use App\Traits\TenantScoped; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; diff --git a/database/migrations/2026_04_28_171312_make_company_id_nullable_in_codes_tables.php b/database/migrations/2026_04_28_171312_make_company_id_nullable_in_codes_tables.php new file mode 100644 index 0000000..17c25ce --- /dev/null +++ b/database/migrations/2026_04_28_171312_make_company_id_nullable_in_codes_tables.php @@ -0,0 +1,36 @@ +foreignId('company_id')->nullable()->change(); + }); + + Schema::table('pass_codes', function (Blueprint $table) { + $table->foreignId('company_id')->nullable()->change(); + }); + } + + /** + * Reverse the migrations. + */ + public function down(): void + { + Schema::table('pickup_codes', function (Blueprint $table) { + $table->foreignId('company_id')->nullable(false)->change(); + }); + + Schema::table('pass_codes', function (Blueprint $table) { + $table->foreignId('company_id')->nullable(false)->change(); + }); + } +}; diff --git a/lang/en.json b/lang/en.json index c61ea7c..ca62036 100644 --- a/lang/en.json +++ b/lang/en.json @@ -1435,5 +1435,40 @@ "Manage your company's sub-accounts and role permissions": "Manage your company's sub-accounts and role permissions", "Tenant": "Tenant", "Permission Tags": "Permission Tags", - "All Permissions": "All Permissions" + "All Permissions": "All Permissions", + "Pickup Codes": "Pickup Codes", + "Generate and manage one-time pickup codes for customers": "Generate and manage one-time pickup codes for customers", + "Generate New Code": "Generate New Code", + "Search by code, machine name or serial...": "Search by code, machine name or serial...", + "Machine / Slot": "Machine / Slot", + "Are you sure you want to cancel this code?": "Are you sure you want to cancel this code?", + "Cancel Code": "Cancel Code", + "No pickup codes found": "No pickup codes found", + "Generate Pickup Code": "Generate Pickup Code", + "Select Slot": "Select Slot", + "Validity Period (Hours)": "Validity Period (Hours)", + "Hrs": "Hrs", + "Max 720 hours (30 days)": "Max 720 hours (30 days)", + "No Actions": "No Actions", + "Pass Codes": "Pass Codes", + "Manage multi-use authorization codes for testing and maintenance": "Manage multi-use authorization codes for testing and maintenance", + "Create Pass Code": "Create Pass Code", + "Search by code, name or machine...": "Search by code, name or machine...", + "Name / Machine": "Name / Machine", + "Are you sure you want to delete this pass code?": "Are you sure you want to delete this pass code?", + "Delete Code": "Delete Code", + "No pass codes found": "No pass codes found", + "Target Machine": "Target Machine", + "Description / Name": "Description / Name", + "e.g. Test Code for Maintenance": "e.g. Test Code for Maintenance", + "Pass Code (8 Digits)": "Pass Code (8 Digits)", + "Regenerate": "Regenerate", + "Validity Period (Days)": "Validity Period (Days)", + "Days": "Days", + "Leave empty for permanent code": "Leave empty for permanent code", + "Permanent": "Permanent", + "All Status": "All Status", + "Add Pickup Code": "Add Pickup Code", + "Add Pass Code": "Add Pass Code", + "Expected Expiry Date & Time": "Expected Expiry Date & Time" } \ No newline at end of file diff --git a/lang/ja.json b/lang/ja.json index 877f450..d684683 100644 --- a/lang/ja.json +++ b/lang/ja.json @@ -260,5 +260,44 @@ "Stock Level > 50%": "在庫 50% 以上", "Manage your company's sub-accounts and role permissions": "会社のサブアカウントとロール権限の管理", "Role Management": "ロール管理", - "Account List": "アカウント一覧" + "Account List": "アカウント一覧", + "Pickup Codes": "受取コード", + "Generate and manage one-time pickup codes for customers": "お客様向けの1回限り受取コードを生成・管理します", + "Generate New Code": "新しいコードを生成", + "Search by code, machine name or serial...": "コード、機台名、またはシリアルで検索...", + "Code": "コード", + "Machine / Slot": "機台 / 貨道", + "Are you sure you want to cancel this code?": "このコードをキャンセルしてもよろしいですか?", + "Cancel Code": "コードをキャンセル", + "No pickup codes found": "受取コードが見つかりません", + "Generate Pickup Code": "受取コードを生成", + "Select Slot": "貨道を選択", + "Validity Period (Hours)": "有効期限 (時間)", + "Hrs": "時間", + "Max 720 hours (30 days)": "最大 720 時間 (30 日間)", + "Generate": "生成", + "No Actions": "操作なし", + "Pass Codes": "通行コード", + "Manage multi-use authorization codes for testing and maintenance": "テストおよびメンテナンス用のマルチユース認証コードを管理します", + "Create Pass Code": "通行コードを作成", + "Search by code, name or machine...": "コード、名称、または機台で検索...", + "Pass Code": "通行コード", + "Name / Machine": "名称 / 機台", + "Are you sure you want to delete this pass code?": "この通行コードを削除してもよろしいですか?", + "Delete Code": "コードを削除", + "No pass codes found": "通行コードが見つかりません", + "Target Machine": "対象機台", + "Description / Name": "説明 / 名称", + "e.g. Test Code for Maintenance": "例:メンテナンス用テストコード", + "Pass Code (8 Digits)": "通行コード (8桁)", + "Regenerate": "再生成", + "Validity Period (Days)": "有効期限 (日)", + "Days": "日", + "Leave empty for permanent code": "無期限にする場合は空欄にしてください", + "Permanent": "無期限", + "Used": "使用済み", + "Expired": "期限切れ", + "Cancelled": "キャンセル済み", + "Active": "有効", + "All Status": "すべてのステータス" } \ No newline at end of file diff --git a/lang/zh_TW.json b/lang/zh_TW.json index e762c69..347930b 100644 --- a/lang/zh_TW.json +++ b/lang/zh_TW.json @@ -20,9 +20,8 @@ "Account:": "帳號:", "accounts": "帳號管理", "Accounts / Machines": "帳號 / 機台", - "Action": "操作", "Actions": "操作", - "Active": "使用中", + "Active": "有效", "Active Slots": "使用中貨道", "Active Status": "啟用狀態", "Ad Settings": "廣告設置", @@ -78,6 +77,7 @@ "All Stable": "狀態穩定", "All Status": "所有狀態", "All Statuses": "所有狀態", + "All Statuses (Codes)": "所有狀態", "All Times System Timezone": "所有時間為系統時區", "All Types": "所有類型", "All Warehouses": "所有倉庫", @@ -107,7 +107,9 @@ "Are you sure you want to change the status of this product? Disabled products will not be visible on the machine.": "確定要變更此商品的狀態嗎?停用的商品將不會在機台上顯示。", "Are you sure you want to change the status? After disabling, this account will no longer be able to log in to the system.": "您確定要變更狀態嗎?停用之後,該帳號將會立即被登出且無法再登入系統。", "Are you sure you want to change the status? This may affect associated accounts.": "您確定要變更狀態嗎?這可能會影響相關帳號的權限效力。", + "Are you sure you want to cancel this code?": "確定要取消此代碼嗎?", "Are you sure you want to confirm this stock-in order? This action will update your inventory levels.": "您確定要確認此進貨單嗎?此操作將會更新您的庫存數量。", + "Are you sure you want to delete this pass code?": "確定要刪除此通行碼嗎?", "Are you sure you want to confirm this transfer? This will deduct stock from source and add to target.": "您確定要確認此調撥單嗎?此操作將會扣除來源庫存並增加目標庫存。", "Are you sure you want to deactivate this account? After deactivating, this account will no longer be able to log in to the system.": "確定要停用此帳號嗎?停用後將無法登入系統。", "Are you sure you want to delete this account?": "您確定要刪除此帳號嗎?", @@ -175,6 +177,7 @@ "by": "由", "Calculate Replenishment": "計算補貨量", "Cancel": "取消", + "Cancel Code": "取消代碼", "Cancel Order": "取消訂單", "Cancel Purchase": "取消購買", "Cancelled": "已取消", @@ -222,6 +225,7 @@ "Click to Open Dashboard": "點擊開啟儀表板", "Click to upload": "點擊上傳", "Close Panel": "關閉面板", + "Code": "代碼", "Coin/Banknote Machine": "硬幣機/紙鈔機", "Coin/Bill Acceptor": "硬幣機/紙鈔機", "Command Center": "指令中心", @@ -341,6 +345,7 @@ "Date": "日期", "Date Range": "日期區間", "Day Before": "前日", + "Days": "天", "Default Donate": "預設捐贈", "Default Not Donate": "預設不捐贈", "Define and manage security roles and permissions.": "定義並管理系統安全角色與權限。", @@ -349,6 +354,7 @@ "Delete Account": "刪除帳號", "Delete Advertisement": "刪除廣告", "Delete Advertisement Confirmation": "刪除廣告確認", + "Delete Code": "刪除代碼", "Delete Customer": "刪除客戶", "Delete Permanently": "確認永久刪除資料", "Delete Product": "刪除商品", @@ -361,6 +367,7 @@ "Delivery door opened": "送貨門開啟", "Deposit Bonus": "儲值回饋", "Describe the repair or maintenance status...": "請描述維修或保養狀況...", + "Description / Name": "描述 / 名稱", "Deselect All": "取消全選", "Detail": "詳細", "Details": "明細", @@ -397,6 +404,7 @@ "e.g. johndoe": "例如:xiaoming", "e.g. Main Warehouse": "如:總倉A", "e.g. Taiwan Star": "例如:台灣之星", + "e.g. Test Code for Maintenance": "例如:維修測試代碼", "e.g. TWSTAR": "例如:TWSTAR", "e.g., Beverage": "例如:飲料", "e.g., Company Standard Pay": "例如:公司標準支付", @@ -521,6 +529,10 @@ "Functional Settings": "功能設定", "Games": "互動遊戲", "General permissions not linked to a specific menu.": "未連結到特定選單的一般權限。", + "Generate": "產生", + "Generate and manage one-time pickup codes for customers": "產生並管理客戶的一次性取貨碼", + "Generate New Code": "產生新代碼", + "Generate Pickup Code": "產生取貨碼", "Gift Definitions": "禮品設定", "Global roles accessible by all administrators.": "適用於所有管理者的全域角色。", "Go Back": "返回", @@ -546,6 +558,7 @@ "Hopper heating timeout": "料斗箱加熱逾時", "Hopper overheated": "料斗箱過熱", "hours ago": "小時前", + "Hrs": "小時", "Identity & Codes": "識別與代碼", "Image": "圖片", "image": "圖片", @@ -588,6 +601,7 @@ "Last Updated": "最後更新日期", "Latitude": "緯度", "Lease": "租賃", + "Leave empty for permanent code": "留空表示永久有效", "Level": "層級", "LEVEL TYPE": "層級類型", "line": "Line 管理", @@ -694,11 +708,9 @@ "Manage": "管理", "Manage Account Access": "管理帳號存取", "Manage ad materials and machine playback settings": "管理廣告素材與機台播放設定", + "Manage multi-use authorization codes for testing and maintenance": "管理用於測試與維修的多用途授權碼", "Manage administrative and tenant accounts": "管理系統管理者與客戶帳號", "Manage all tenant accounts and validity": "管理所有客戶帳號及其效期", - "Manage Expiry": "進入效期管理", - "Manage inventory and monitor expiry dates across all machines": "管理各機台庫存架位與效期監控", - "Manage machine access permissions": "管理機台存取權限", "Manage stock levels, stock-in orders, and movement history": "追蹤庫存水位、進貨單與異動紀錄", "Manage stock transfers between warehouses and machine returns": "建立倉庫間調撥或機台退庫單", "Manage warehouse stock levels, stock-in orders, adjustments, and movement history": "管理倉庫庫存水位、入庫單、盤點調整與異動紀錄", @@ -721,6 +733,7 @@ "Max Capacity": "最大容量", "Max Capacity:": "最大容量:", "Max Stock": "庫存上限", + "Max 720 hours (30 days)": "最大 720 小時 (30 天)", "Member": "會員價", "Member & External": "會員與外部系統", "Member List": "會員列表", @@ -987,6 +1000,7 @@ "PI_MERCHANT_ID": "Pi 拍錢包 商店代號", "Picked up": "領取", "Picked up Time": "領取時間", + "Machine / Slot": "機台 / 貨道", "Pickup Code": "取貨碼", "Pickup Codes": "取貨碼", "Pickup door closed": "取貨門已關閉", @@ -1479,6 +1493,9 @@ "vending": "販賣頁", "Vending Page": "販賣頁", "Venue Management": "場地管理", + "Used": "已使用", + "Validity Period (Days)": "有效期限 (天)", + "Validity Period (Hours)": "有效期限 (小時)", "Video": "影片", "video": "影片", "View all warehouses": "查看所有倉庫", @@ -1546,5 +1563,28 @@ "Manage your company's sub-accounts and role permissions": "管理您公司的子帳號與角色權限", "Tenant": "客戶", "Permission Tags": "權限標籤", - "All Permissions": "全部權限" + "All Permissions": "全部權限", + "All Status": "所有狀態", + "Select Slot": "選擇貨道", + "Validity Period (Hours)": "有效期限 (小時)", + "Hrs": "小時", + "No Actions": "無操作", + "Target Machine": "目標機台", + "Description / Name": "描述 / 名稱", + "Pass Code (8 Digits)": "通行碼 (8 位數)", + "Regenerate": "重新產生", + "Validity Period (Days)": "有效期限 (天)", + "Leave empty for permanent code": "留空表示永久有效", + "Permanent": "永久有效", + "Add Pickup Code": "新增取貨碼", + "Add Pass Code": "新增通行碼", + "QR": "QR Code", + "Scan QR Code": "掃描 QR Code", + "View QR Code": "查看 QR Code", + "Expected Expiry": "預計過期時間", + "Max :max hours": "最多 :max 小時", + "Expected Expiry Date & Time": "預計過期日期與時間", + "Validity Period": "有效期限", + "Max 24 Hours": "最多 24 小時", + "Please select a machine": "請選擇機台" } \ No newline at end of file diff --git a/resources/views/admin/basic-settings/machines/index.blade.php b/resources/views/admin/basic-settings/machines/index.blade.php index 7df50d1..58f73a1 100644 --- a/resources/views/admin/basic-settings/machines/index.blade.php +++ b/resources/views/admin/basic-settings/machines/index.blade.php @@ -1114,9 +1114,7 @@
- {{ __('Maintenance QR Code') }} +

diff --git a/resources/views/admin/sales/pass-codes/index.blade.php b/resources/views/admin/sales/pass-codes/index.blade.php index 615ac6a..14e9044 100644 --- a/resources/views/admin/sales/pass-codes/index.blade.php +++ b/resources/views/admin/sales/pass-codes/index.blade.php @@ -38,11 +38,11 @@ :title="__('Pass Codes')" :subtitle="__('Manage multi-use authorization codes for testing and maintenance')" > - @@ -52,11 +52,30 @@

- +
+ +
+ + + + +
+ +
+ + +
+
{{-- Table (Desktop) --}}