diff --git a/app/Http/Controllers/Admin/WarehouseController.php b/app/Http/Controllers/Admin/WarehouseController.php
index ce34029..858f44c 100644
--- a/app/Http/Controllers/Admin/WarehouseController.php
+++ b/app/Http/Controllers/Admin/WarehouseController.php
@@ -637,10 +637,11 @@ class WarehouseController extends Controller
$products = Product::with('translations')->orderBy('name')->get(['id', 'name', 'image_url', 'name_dictionary_key']);
// 同租戶帳號(用於指派人員)
- $users = \App\Models\System\User::where('company_id', Auth::user()->company_id)
- ->where('status', 'active')
- ->orderBy('name')
- ->get(['id', 'name']);
+ $userQuery = \App\Models\System\User::where('status', 1)->orderBy('name');
+ if (!Auth::user()->isSystemAdmin()) {
+ $userQuery->where('company_id', Auth::user()->company_id);
+ }
+ $users = $userQuery->get(['id', 'name']);
return view('admin.warehouses.replenishments', compact('orders', 'warehouses', 'machines', 'products', 'users'));
}
@@ -844,6 +845,7 @@ class WarehouseController extends Controller
{
$validated = $request->validate([
'status' => 'required|in:prepared,delivering,completed',
+ 'assigned_to' => 'nullable|exists:users,id',
]);
$newStatus = $validated['status'];
@@ -855,9 +857,14 @@ class WarehouseController extends Controller
], 422);
}
- DB::transaction(function () use ($replenishmentOrder, $newStatus) {
+ DB::transaction(function () use ($replenishmentOrder, $newStatus, $validated) {
$replenishmentOrder->loadMissing('items');
+ // 更新指派人員 (如果有傳遞的話)
+ if (array_key_exists('assigned_to', $validated)) {
+ $replenishmentOrder->assigned_to = $validated['assigned_to'];
+ }
+
// pending → prepared:扣減倉庫庫存
if ($newStatus === ReplenishmentOrder::STATUS_PREPARED) {
foreach ($replenishmentOrder->items as $item) {
@@ -1002,23 +1009,26 @@ class WarehouseController extends Controller
public function assignReplenishment(Request $request, ReplenishmentOrder $replenishmentOrder)
{
$validated = $request->validate([
- 'assigned_to' => 'required|exists:users,id',
+ 'assigned_to' => 'nullable|exists:users,id',
]);
- // 確保指派人員屬於同租戶
- $user = \App\Models\System\User::where('id', $validated['assigned_to'])
- ->where('company_id', Auth::user()->company_id)
- ->first();
+ if ($validated['assigned_to']) {
+ // 確保指派人員屬於同租戶
+ $user = \App\Models\System\User::where('id', $validated['assigned_to'])
+ ->where('company_id', Auth::user()->company_id)
+ ->first();
- if (!$user) {
- return response()->json([
- 'success' => false,
- 'message' => __('Invalid personnel selection')
- ], 422);
+ if (!$user) {
+ return response()->json([
+ 'success' => false,
+ 'message' => __('Invalid personnel selection')
+ ], 422);
+ }
+ $replenishmentOrder->assigned_to = $user->id;
+ } else {
+ $replenishmentOrder->assigned_to = null;
}
- $replenishmentOrder->update(['assigned_to' => $user->id]);
-
session()->flash('success', __('Personnel assigned successfully'));
return response()->json([
diff --git a/lang/en.json b/lang/en.json
index ca62036..6cc5fa0 100644
--- a/lang/en.json
+++ b/lang/en.json
@@ -1470,5 +1470,8 @@
"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
+ "Expected Expiry Date & Time": "Expected Expiry Date & Time",
+ "Assign Personnel (Optional)": "Assign Personnel (Optional)",
+ "Unassigned / No Change": "Unassigned / No Change",
+ "You can assign or change the personnel handling this order": "You can assign or change the personnel handling this order"
+}
diff --git a/lang/ja.json b/lang/ja.json
index d684683..875e0a0 100644
--- a/lang/ja.json
+++ b/lang/ja.json
@@ -299,5 +299,8 @@
"Expired": "期限切れ",
"Cancelled": "キャンセル済み",
"Active": "有効",
- "All Status": "すべてのステータス"
-}
\ No newline at end of file
+ "All Status": "すべてのステータス",
+ "Assign Personnel (Optional)": "担当者指定 (オプション)",
+ "Unassigned / No Change": "未指定 / 変更なし",
+ "You can assign or change the personnel handling this order": "この注文の担当者を割り当て、または変更できます"
+}
diff --git a/lang/zh_TW.json b/lang/zh_TW.json
index cfee4d4..ba698a1 100644
--- a/lang/zh_TW.json
+++ b/lang/zh_TW.json
@@ -132,6 +132,7 @@
"Assign Advertisement": "投放廣告",
"Assign Machines": "分配機台",
"Assign Personnel": "指派人員",
+ "Assign Personnel (Optional)": "指派人員 (選填)",
"Assign replenishment staff": "指派補貨人員",
"Assign warehouse managers": "指派倉庫負責人",
"Assigned Machines": "授權機台",
@@ -1476,6 +1477,7 @@
"Type to search or leave blank for system defaults.": "輸入關鍵字搜尋,或留空以使用系統預設。",
"UI Elements": "UI元素",
"Unassigned": "未指派",
+ "Unassigned / No Change": "未指派 / 不變動",
"Unauthorized login attempt: :account": "越權登入嘗試::account",
"Unauthorized Status": "未授權",
"Unauthorized: Account not authorized for this machine": "授權失敗:此帳號無存取該機台的權限",
@@ -1606,5 +1608,5 @@
"Delete Pass Code": "刪除通行碼",
"Are you sure you want to delete this pass code?": "確定要刪除此通行碼嗎?",
"Yes, Delete": "確認刪除",
- "Delete Code": "刪除代碼"
-}
\ No newline at end of file
+ "You can assign or change the personnel handling this order": "您可以指派或變更處理此訂單的人員"
+}
diff --git a/resources/views/admin/basic-settings/machines/distribution.blade.php b/resources/views/admin/basic-settings/machines/distribution.blade.php
index d6a3cf1..8b9328a 100644
--- a/resources/views/admin/basic-settings/machines/distribution.blade.php
+++ b/resources/views/admin/basic-settings/machines/distribution.blade.php
@@ -48,7 +48,7 @@
.marker-error { background-color: #ef4444; }
-
+
@@ -177,19 +177,119 @@
-
+
{{ __('Machine Distribution Map') }}
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ __('Machine List') }}
+
+
+ {{ $machines->count() }} {{ __('Units') }}
+
+
+
+
+
+
+
+
+
+
@@ -274,6 +374,17 @@
});
function focusMachine(lat, lng, id) {
+ // Close mobile menu if open
+ if (window.innerWidth < 768) {
+ try {
+ // Access Alpine state via data-stack
+ const body = document.querySelector('body');
+ if (body && body._x_dataStack) {
+ body._x_dataStack[0].mobileMenuOpen = false;
+ }
+ } catch (e) { console.log('Alpine sync error:', e); }
+ }
+
map.flyTo([lat, lng], 15, {
duration: 1.5
});
@@ -329,13 +440,21 @@
function updateSearchFilter(query) {
currentSearchQuery = query.toLowerCase().trim();
+
+ // Sync all search inputs
+ document.querySelectorAll('.machine-search-input').forEach(input => {
+ if (input.value.toLowerCase().trim() !== currentSearchQuery) {
+ input.value = query;
+ }
+ });
+
applyFilters();
}
function resetFilter() {
currentModelFilter = null;
currentSearchQuery = '';
- document.getElementById('machine-search').value = '';
+ document.querySelectorAll('.machine-search-input').forEach(input => input.value = '');
applyFilters();
map.setView([23.973875, 120.982024], 8);
}
diff --git a/resources/views/admin/warehouses/partials/modal-replenishment-assign.blade.php b/resources/views/admin/warehouses/partials/modal-replenishment-assign.blade.php
index 5839665..43da69e 100644
--- a/resources/views/admin/warehouses/partials/modal-replenishment-assign.blade.php
+++ b/resources/views/admin/warehouses/partials/modal-replenishment-assign.blade.php
@@ -3,19 +3,23 @@
-
+
{{ __('Assign Personnel') }}
{{ __('Select a team member to handle this replenishment order') }}
-
+
diff --git a/resources/views/admin/warehouses/partials/modal-replenishment-status.blade.php b/resources/views/admin/warehouses/partials/modal-replenishment-status.blade.php
index 8c64601..ac237fb 100644
--- a/resources/views/admin/warehouses/partials/modal-replenishment-status.blade.php
+++ b/resources/views/admin/warehouses/partials/modal-replenishment-status.blade.php
@@ -3,7 +3,7 @@
-
+
+
+
+
+ @foreach($users as $u)
+
+ @endforeach
+
+
+
* {{ __('You can assign or change the personnel handling this order') }}
+
+