%@ LANGUAGE="VBSCRIPT" %>
<% PageStrings = "359, 401, 402, 572, 573, 631, 632, 633, 585"
strThisBackPage = "products" %>
<%
'===============================================
' CactuShop ASP Shopping Cart
' ©1999-2004 Cactusoft Ltd. www.cactusoft.com
'===============================================
' All rights reserved.
' Use of this code is covered by the terms and
' conditions in the license agreement. No
' unauthorized duplication or distribution is
' permitted. Cactusoft's copyright notices must
' remain in the ASP sections of the code.
'===============================================
Dim Uploader, File
Set Uploader = New FileUploader
' This starts the upload process
Uploader.Upload()
'-----------------------------------------------
'COLLECT VALUES FROM FORM
'-----------------------------------------------
strCallMode = Uploader.Form("strCallMode")
If strCallMode = "Delete" And Len(Uploader.Form("strHardDelete")) > 0 Then
strCallMode = "strHardDelete"
ElseIf strCallMode = "Delete" And Len(Uploader.Form("strSoftDelete")) > 0 Then
strCallMode = "strSoftDelete"
End If
PT_ID = Uploader.Form("PT_ID")
Select Case strCallMode
Case "Add", "Modify"
PT_Live = Uploader.Form("PT_Live")
PT_DeleteImage = Uploader.Form("PT_DeleteImage")
PT_DeleteImage_Large = Uploader.Form("PT_DeleteImage_Large")
PT_MotherProdType = Uploader.Form("PT_MotherProdType")
If Not PT_Live = "y" Then PT_Live = "n"
PT_ProductDisplayType = Uploader.Form("PT_ProductDisplayType")
PT_ProdTypeDisplayType = Uploader.Form("PT_ProdTypeDisplayType")
PT_OrderByValue = Uploader.Form("PT_OrderByValue")
If Not IsNumeric(PT_OrderByValue) then PT_OrderByValue = 0
PT_OrderProductsBy = Uploader.Form("PT_OrderProductsBy")
Dim PT_Name(), PT_Desc()
Redim PT_Name(numTotalLanguages)
Redim PT_Desc(numTotalLanguages)
For numCounter = 1 to numTotalLanguages
PT_Name(numCounter) = Uploader.Form("PT_Name" & CStr(numCounter))
PT_Desc(numCounter) = Uploader.Form("PT_Desc" & CStr(numCounter))
next
'-------------------------------------------
'CHECK FILE UPLOAD IS OK FILETYPE
'-------------------------------------------
If Uploader.Files.Exists("PT_Image") Then
strFileUploadName = Uploader.Files("PT_Image").FileName
If Not strFileUploadName = "" Then
aryFileUploadName = Split(strFileUploadName, ".")
strFileType = LCase(aryFileUploadName(Ubound(aryFileUploadName)))
End If
If InStr("," & Application(LICENSENUMBER & "allowedimages") & ",", "," & strFileType & ",") < 1 Then
numErrorNo = numErrorNo + 1
strErrorText = strErrorText + "" + CStr(numErrorNo) + ". " + GetString("ContentText_ErrorChkUploadFileType") & replace(Application(LICENSENUMBER & "allowedimages"),",",", ") & ".
"
End If
End If
If Uploader.Files.Exists("PT_Image_Large") Then
strFileUploadName = Uploader.Files("PT_Image_Large").FileName
If Not strFileUploadName = "" Then
aryFileUploadName = Split(strFileUploadName, ".")
strFileType_Large = LCase(aryFileUploadName(Ubound(aryFileUploadName)))
End If
If InStr("," & Application(LICENSENUMBER & "allowedimages") & ",", "," & strFileType_Large & ",") < 1 Then
numErrorNo = numErrorNo + 1
strErrorText = strErrorText + "" + CStr(numErrorNo) + ". " + GetString("ContentText_ErrorChkUploadFileType") & replace(Application(LICENSENUMBER & "allowedimages"),",",", ") & ".
"
End If
End If
'-----------------------------------------------
'ERROR CHECKING
'-----------------------------------------------
blnAllNamesBlank = true
blnAllDescsBlank = true
For numCounter = 1 to numTotalLanguages
'If it's live on the front, then it can't be blank
If aryLangLiveFront(numCounter) = "y" then
blnAllNamesBlank = blnAllNamesBlank and PT_Name(numCounter) = ""
blnAllDescsBlank = blnAllDescsBlank and PT_Desc(numCounter) = ""
end if
'check them all for length
strErrorText = ErrorcheckLength(strErrorText, numErrorNo, GetString("FormLabel_CategoryName") & " " & cstr(numCounter), PT_Name(numCounter), Application(LICENSENUMBER & "PT_Name_AL"))
strErrorText = ErrorcheckLength(strErrorText, numErrorNo, GetString("FormLabel_CategoryDescription") & " " & cstr(numCounter), PT_Desc(numCounter), Application(LICENSENUMBER & "PT_Desc_AL"))
next
If blnAllNamesBlank then strErrorText = CheckNotBlank(strErrorText, numErrorNo, GetString("FormLabel_CategoryName"), "")
If blnAllDescsBlank then strErrorText = CheckNotBlank(strErrorText, numErrorNo, GetString("FormLabel_CategoryDescription"), "")
If strErrorText = "" Then
If PT_ID = 0 Then
strQuery="INSERT INTO tblCactuShopProdtype ("
For numCounter = 1 to numTotalLanguages
If aryLangLiveBack(numCounter) = "y" then strQuery = strQuery & "PT_Name" & CStr(numCounter) & ", PT_Desc" & CStr(numCounter) & ", "
next
strQuery = strQuery & "PT_ProductDisplayType, PT_ProdTypeDisplayType, PT_MotherProdType, PT_OrderByValue, PT_OrderProductsBy, PT_Live) VALUES ("
For numCounter = 1 to numTotalLanguages
If aryLangLiveBack(numCounter) = "y" then strQuery = strQuery & "'" & sqlsafe(PT_Name(numCounter)) & "', '" & sqlsafe(PT_Desc(numCounter)) & "', "
next
strQuery = strQuery & "'" &_
sqlsafe(PT_ProductDisplayType) & "','" &_
sqlsafe(PT_ProdTypeDisplayType) & "'," &_
PT_MotherProdType & "," &_
PT_OrderByValue & ",'" &_
sqlsafe(PT_OrderProductsBy) & "','" &_
sqlsafe(PT_Live) & "')"
Call ExecuteSQL(strQuery, numCursorType, objRecordSet)
'--------------------------------------------------
'FIND ID OF NEW CATEGORY
'--------------------------------------------------
strQuery = "SELECT PT_ID FROM tblCactuShopProdtype WHERE PT_Name" & CStr(numDefaultLanguage) & "='" & sqlsafe(PT_Name(numDefaultLanguage)) & "' ORDER BY PT_ID DESC"
Call ExecuteSQL(strQuery, numCursorType, objRecordSet)
PT_ID = objRecordSet("PT_ID")
objRecordSet.close
Else
strQuery="UPDATE tblCactuShopProdtype SET "
for numCounter = 1 to numTotalLanguages
If arylangliveback(numCounter) = "y" then strQuery = strQuery & "PT_Name" & CStr(numCounter) & "='" & sqlsafe(PT_Name(numCounter)) & "', PT_Desc" & CStr(numCounter) & "='" & sqlsafe(PT_Desc(numCounter)) & "',"
next
strQuery = strQuery &_
"PT_ProductDisplayType='" & sqlsafe(PT_ProductDisplayType) & "'," &_
"PT_ProdTypeDisplayType='" & sqlsafe(PT_ProdTypeDisplayType) & "'," &_
"PT_MotherProdType=" & PT_MotherProdType & "," &_
"PT_OrderByValue=" & PT_OrderByValue & "," &_
"PT_OrderProductsBy='" & sqlsafe(PT_OrderProductsBy) & "'," &_
"PT_Live='" & sqlsafe(PT_Live) & "' WHERE PT_ID=" & PT_ID
Call ExecuteSQL(strQuery, numCursorType, objRecordSet)
End If
'Do the image management, if needed
'Use Prodtype ID + File Extension for name to avoid overwriting pre-existing images.
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
If PT_DeleteImage = "y" Or Uploader.Files.Exists("PT_Image") Then DeleteFile Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_categories/" & PT_ID), Split(Application(LICENSENUMBER & "allowedimages"), ","), objFileSystem
If PT_DeleteImage_Large = "y" Or Uploader.Files.Exists("PT_Image_Large") Then DeleteFile Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_categories_large/" & PT_ID), Split(Application(LICENSENUMBER & "allowedimages"), ","), objFileSystem
Set objFileSystem = Nothing
If Uploader.Files.Exists("PT_Image") Then
Uploader.Files("PT_Image").FileName = PT_ID & "." & strFileType
Uploader.Files("PT_Image").SaveToDisk Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_categories/")
End If
If Uploader.Files.Exists("PT_Image_Large") Then
Uploader.Files("PT_Image_Large").FileName = PT_ID & "." & strFileType_Large
Uploader.Files("PT_Image_Large").SaveToDisk Server.MapPath(Application(LICENSENUMBER & "uploadsfolder") & "images_categories_large/")
End If
End If
Case Else
'-----------------------------------------------
'DELETES A CATEGORY
'-----------------------------------------------
If PT_ID = 0 then response.redirect("error.asp")
If strErrorText = "" Then
Set objFileSystem = Server.CreateObject("Scripting.FileSystemObject")
Set objRecordSet2 = Server.CreateObject("ADODB.RecordSet")
DeleteCategory PT_ID, (strCallMode = "strHardDelete"), objFileSystem, objRecordSet, objRecordSet2
Set objFileSystem = Nothing
Set objRecordSet2 = Nothing
End If
End Select
If strErrorText = "" Then
'Redirect
Select Case strCallMode
Case "Add", "Modify"
Response.Redirect("_prodtype_back.asp?PT_ID=" & PT_ID)
Case Else
Response.Redirect("_default.asp")
end select
Else
%>
<% =GetString("Config_headtitle") %>
<% End If %>