Files
shopdb/quickaddapplication.asp
cproudlock 249bfbba8c Standardize ASP filenames: remove underscores
Renamed 45 ASP files to follow lowercase concatenated naming convention:
- Direct handlers: save_machine_direct.asp -> savemachinedirect.asp
- USB files: checkin_usb.asp -> checkinusb.asp
- API files: api_usb.asp -> apiusb.asp
- Map files: network_map.asp -> networkmap.asp
- Printer files: printer_lookup.asp -> printerlookup.asp

Also:
- Updated 84+ internal references across all ASP and JS files
- Deleted 6 test/duplicate files (editmacine.asp, test_*.asp)
- Updated production migration guide with filename changes
- Added rename scripts for Linux (bash) and Windows (PowerShell)
2025-12-10 20:40:05 -05:00

80 lines
2.3 KiB
Plaintext

<%@ Language=VBScript %>
<%
Response.ContentType = "application/json"
%>
<!--#include file="./includes/sql.asp"-->
<%
' Get form inputs
Dim appname, appdescription
appname = Trim(Request.Form("appname"))
appdescription = Trim(Request.Form("appdescription"))
' Basic validation
If Len(appname) = 0 Then
Response.Write("{""success"":false,""error"":""Application name is required""}")
objConn.Close
Response.End
End If
If Len(appname) > 50 Then
Response.Write("{""success"":false,""error"":""Application name too long (max 50 characters)""}")
objConn.Close
Response.End
End If
If Len(appdescription) > 255 Then
Response.Write("{""success"":false,""error"":""Description too long (max 255 characters)""}")
objConn.Close
Response.End
End If
' Escape single quotes
appname = Replace(appname, "'", "''")
appdescription = Replace(appdescription, "'", "''")
' Check if application already exists
Dim checkSQL, rsCheck
checkSQL = "SELECT appid FROM applications WHERE appname = '" & appname & "'"
Set rsCheck = objConn.Execute(checkSQL)
If Not rsCheck.EOF Then
Response.Write("{""success"":false,""error"":""An application with this name already exists""}")
rsCheck.Close
Set rsCheck = Nothing
objConn.Close
Response.End
End If
rsCheck.Close
Set rsCheck = Nothing
' Get default support team ID (use 1 as default)
Dim defaultSupportTeamId
defaultSupportTeamId = 1
' Build INSERT statement with minimal required fields
Dim strSQL
strSQL = "INSERT INTO applications (appname, appdescription, supportteamid, isactive, isinstallable, ishidden, isprinter, islicenced) " & _
"VALUES ('" & appname & "', '" & appdescription & "', " & defaultSupportTeamId & ", 1, 0, 0, 0, 0)"
On Error Resume Next
objConn.Execute strSQL
If Err.Number <> 0 Then
Response.Write("{""success"":false,""error"":""Database error: " & Replace(Err.Description, """", "'") & """}")
objConn.Close
Response.End
End If
' Get the newly inserted ID
Dim newId, rsNewId
Set rsNewId = objConn.Execute("SELECT LAST_INSERT_ID() AS newid")
newId = rsNewId("newid")
rsNewId.Close
Set rsNewId = Nothing
' Return success with new ID
Response.Write("{""success"":true,""appid"":" & newId & ",""appname"":""" & Replace(appname, """", "'") & """}")
objConn.Close
%>