diff --git a/api.asp b/api.asp index cea3c21..39fa407 100644 --- a/api.asp +++ b/api.asp @@ -55,6 +55,8 @@ Select Case action GetShopfloorPCs() Case "getRecordedIP" GetRecordedIP() + Case "updateMachinePositions" + UpdateMachinePositions() Case Else SendError "Invalid action: " & action End Select @@ -2412,4 +2414,69 @@ Sub UpdateWinRMStatus() Response.Write "{""success"":true,""message"":""WinRM status updated"",""hostname"":""" & hostname & """,""iswinrm"":" & winrmValue & "}" End Sub +' ============================================================================ +' UPDATE MACHINE POSITIONS - Bulk update mapleft/maptop for machines +' ============================================================================ +Sub UpdateMachinePositions() + On Error Resume Next + + Dim changesJson, changes, i, updateCount, errorCount + changesJson = Request.Form("changes") + + If changesJson = "" Then + SendError "Missing changes parameter" + Exit Sub + End If + + LogToFile "UpdateMachinePositions: Received " & Len(changesJson) & " bytes" + + ' Parse JSON array + changes = ParseJSONArray(changesJson) + + If Not IsArray(changes) Then + SendError "Invalid changes format" + Exit Sub + End If + + updateCount = 0 + errorCount = 0 + + ' Update each machine position + For i = 0 To UBound(changes) + Dim machineId, newLeft, newTop, updateSQL + + machineId = GetJSONValue(changes(i), "id") + newLeft = GetJSONValue(changes(i), "newLeft") + newTop = GetJSONValue(changes(i), "newTop") + + If machineId <> "" And IsNumeric(machineId) And IsNumeric(newLeft) And IsNumeric(newTop) Then + updateSQL = "UPDATE machines SET mapleft = " & CLng(newLeft) & ", maptop = " & CLng(newTop) & _ + " WHERE machineid = " & CLng(machineId) + objConn.Execute updateSQL + + If Err.Number = 0 Then + updateCount = updateCount + 1 + LogToFile " Updated machineid " & machineId & " to (" & newLeft & ", " & newTop & ")" + Else + errorCount = errorCount + 1 + LogToFile " Error updating machineid " & machineId & ": " & Err.Description + Err.Clear + End If + Else + errorCount = errorCount + 1 + LogToFile " Invalid data for change " & i + End If + Next + + LogToFile "UpdateMachinePositions: Updated " & updateCount & ", Errors " & errorCount + + ' Send response + Response.ContentType = "application/json" + If errorCount = 0 Then + Response.Write "{""success"":true,""message"":""Updated " & updateCount & " position(s)"",""updated"":" & updateCount & "}" + Else + Response.Write "{""success"":true,""message"":""Updated " & updateCount & ", " & errorCount & " error(s)"",""updated"":" & updateCount & ",""errors"":" & errorCount & "}" + End If +End Sub + %> diff --git a/machine_map.asp b/machine_map.asp index 2447386..92aae54 100644 --- a/machine_map.asp +++ b/machine_map.asp @@ -128,7 +128,7 @@ Do While Not rsLegend.EOF Case Else: legendColor = "#FFC107" End Select Response.Write("
") - Response.Write("") + Response.Write("") Response.Write("" & Server.HTMLEncode(rsLegend("machinetype")) & "") Response.Write("
") rsLegend.MoveNext @@ -297,6 +297,8 @@ strSQL = "SELECT m.machineid, m.machinenumber, m.alias, m.serialnumber, " &_ "AND m.isactive = 1 " &_ "AND m.mapleft IS NOT NULL " &_ "AND m.maptop IS NOT NULL " &_ + "AND mt.machinetypeid NOT IN (1, 16, 17, 18, 19, 20) " &_ + "AND mt.machinetypeid < 33 " &_ "ORDER BY mt.machinetype, m.machinenumber ASC" Set rs = objConn.Execute(strSQL) @@ -385,12 +387,12 @@ Do While Not rs.EOF // Get color for this machine type var color = machineTypeColors[machineTypeId] || machineTypeColors['default']; - // Create custom marker icon + // Create custom marker icon (12px for less overlap) var icon = L.divIcon({ - html: '
', - iconSize: [20, 20], - iconAnchor: [10, 10], - popupAnchor: [0, -5], + html: '
', + iconSize: [12, 12], + iconAnchor: [6, 6], + popupAnchor: [0, -3], className: 'custom-marker' }); diff --git a/machine_map_editor.asp b/machine_map_editor.asp new file mode 100644 index 0000000..01b234b --- /dev/null +++ b/machine_map_editor.asp @@ -0,0 +1,525 @@ + + + + + + Machine Map Editor - ShopDB + + + + +<% + theme = Request.Cookies("theme") + If theme = "" Then theme = "bg-theme1" +%> + + +
+ + + +
+ +
+
+ + +
+
+

Machine Map Editor

+ +
+
+ + +
+ +
+
+
+ + + +
+ +
+
+
+ + + + + + + + + + + + + + + +<%objConn.Close%>