Modificare il file:
\Buoni-spesa-OLD\transizioni_add.asp
<!--#include file="include/dbcommon.asp"--> <!--#include file="include/transizioni_variables.asp"--> <!--#include file="libs/smarty.asp"--> <% Set myRequest = CreateObject("Scripting.Dictionary") Set myRequestFiles = CreateObject("Scripting.Dictionary") if ParseMultiPartForm()=true then parse=1 MaxSizeSet=false '// check if logged in if SESSION("UserID")="" or not CheckSecurity(SESSION("_" & strTableName & "_OwnerID"),"Add") then SESSION("MyURL")=request.ServerVariables("SCRIPT_NAME")&"?"&request.ServerVariables("QUERY_STRING") response.Redirect "login.asp?message=expired" response.End end if filename="" status="" message="" readavalues=false errorhappened=false set showKeys = Server.CreateObject("Scripting.Dictionary") inlineedit = false set showValues = Server.CreateObject("Scripting.Dictionary") set showFields = Server.CreateObject("Scripting.Dictionary") set showRawValues = Server.CreateObject("Scripting.Dictionary") set showDetailKeys = Server.CreateObject("Scripting.Dictionary") IsSaved = false HaveData = true if postvalue("editType")="inline" then inlineedit = true templatefile = "transizioni_inline_add.htm" else inlineedit = false templatefile = "transizioni_add.htm" end if '//connect database dbConnection="" db_connect() DoEvent "BeforeProcessAdd dbConnection" Set rs = server.CreateObject("ADODB.Recordset") Set rsLookup = server.CreateObject("ADODB.Recordset") '// insert new record if we have to if getRequestForm("a")="added" then set afilename_values = CreateObject("Scripting.Dictionary") set avalues = CreateObject("Scripting.Dictionary") set files_move = CreateObject("Scripting.Dictionary") dim toadd dim thumb '// processing N_Buono - start value = postvalue("value_N_Buono") ttype=postvalue("type_N_Buono") toadd=true if myRequest.Exists("value_N_Buono") or myRequest.Exists("value_N_Buono[]") or myRequest.Exists("type_N_Buono") then value=prepare_for_db("N_Buono",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("N_Buono")=value end if end if ' processibng N_Buono - end '// processing importo - start value = postvalue("value_importo") ttype=postvalue("type_importo") toadd=true if myRequest.Exists("value_importo") or myRequest.Exists("value_importo[]") or myRequest.Exists("type_importo") then value=prepare_for_db("importo",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("importo")=value end if end if ' processibng importo - end '// processing data_emissione - start value = postvalue("value_data_emissione") ttype=postvalue("type_data_emissione") toadd=true if myRequest.Exists("value_data_emissione") or myRequest.Exists("value_data_emissione[]") or myRequest.Exists("type_data_emissione") then value=prepare_for_db("data_emissione",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("data_emissione")=value end if end if ' processibng data_emissione - end '// add filenames to values for each akey in afilename_values avalues(akey)=afilename_values(akey) next '// before Add event retval = true DoEvent "retval = BeforeAdd(avalues,message,inlineedit)" if retval then on error resume next rs.Open "select * from " & AddTableWrappers(strOriginalTableName) & " where 1=0", dbConnection, 1,2 rs.Addnew call report_error if IsUpdatable(rs("N_Buono")) then ' insert N_Buono field strValue=false if avalues.exists("N_Buono") then _ strValue = avalues.Item("N_Buono") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_N_Buono") if strValue<>"" and IsNumeric(strValue) then rs("N_Buono") = CLng(strValue) else rs("N_Buono") = null end if call report_error end if end if ' insert importo field strValue=false if avalues.exists("importo") then _ strValue = avalues.Item("importo") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_importo") if strValue<>"" then rs("importo") = CSmartDbl(strValue) else rs("importo") = null end if call report_error end if ' insert data_emissione field strValue=false if avalues.exists("data_emissione") then _ strValue = avalues.Item("data_emissione") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_data_emissione") if strValue="" then rs("data_emissione")=null else rs("data_emissione")=strValue end if call report_error end if if not errorhappened then rs.Update call report_error end if on error goto 0 if not errorhappened then if inlineedit then status="ADDED" message="" & "Il Record e stato aggiunto" & "" IsSaved = true else message="<div class=message><<< " & "Il Record e stato aggiunto" & " >>></div>" end if ' get new key values if inlineedit then set keys = CreateObject("Scripting.Dictionary") failed_inline_add = false keys("N_Buono") = rs("N_Buono") end if rs.Close ' after add event DoEvent "AfterAdd avalues,keys,inlineedit" end if else readavalues=true end if end if set defvalues = CreateObject("Scripting.Dictionary") set copykeys = CreateObject("Scripting.Dictionary") copykeys("N_Buono")=postvalue("copyid1") '// copy record if getRequestForm("copyid1")<>"" then sstrWhere=KeyWhere(copykeys,"") strSQL = gSQLWhereAdd(sstrWhere) LogInfo(strSQL) rs.open strSQL,dbConnection, 1, 2 if not rs.EOF then defvalues("N_Buono")=dbvalue(rs("N_Buono")) defvalues("importo")=dbvalue(rs("importo")) defvalues("data_emissione")=dbvalue(rs("data_emissione")) end if '// clear key fields defvalues("N_Buono")="" '//call CopyOnLoad event DoEvent "Call CopyOnLoad(defvalues,sstrWhere)" else end if ' save previously enterd values if readavalues then if avalues.exists("N_Buono") then defvalues("N_Buono")= avalues("N_Buono") end if if avalues.exists("importo") then defvalues("importo")= avalues("importo") end if if avalues.exists("data_emissione") then defvalues("data_emissione")= avalues("data_emissione") end if end if for each key in defvalues smarty.Add "value_" & GoodFieldName(key),defvalues(key) next if not inlineedit then '// include files includes="" '// validation stuff bodyonload="" onsubmit="" includes=includes & "<script language=""JavaScript"" src=""include/validate.js""></script> " includes=includes & "<script language=""JavaScript""> " includes=includes & "var TEXT_FIELDS_REQUIRED='" & addslashes("I seguenti campi sono richiesti") & "'; " includes=includes & "var TEXT_FIELDS_ZIPCODES='" & addslashes("") & "'; " includes=includes & "var TEXT_FIELDS_EMAILS='" & addslashes("I seguenti campi devono essere email valide") & "'; " includes=includes & "var TEXT_FIELDS_NUMBERS='" & addslashes("I seguenti campi devono essere numeri") & "'; " includes=includes & "var TEXT_FIELDS_CURRENCY='" & addslashes("I seguenti campi devono essere valuta") & "'; " includes=includes & "var TEXT_FIELDS_PHONE='" & addslashes("I seguenti campi devono essere numeri telefonici") & "'; " includes=includes & "var TEXT_FIELDS_PASSWORD1='" & addslashes("I campi seguenti devono essere una password corretta") & "'; " includes=includes & "var TEXT_FIELDS_PASSWORD2='" & addslashes("lunga almeno 4 caratteri ") & "'; " includes=includes & "var TEXT_FIELDS_PASSWORD3='" & addslashes("Non puo essere una password") & "'; " includes=includes & "var TEXT_FIELDS_STATE='" & addslashes("I seguenti campi devono essere nome di stato") & "'; " includes=includes & "var TEXT_FIELDS_SSN='" & addslashes("") & "'; " includes=includes & "var TEXT_FIELDS_DATE='" & addslashes("I seguenti campi devono essere date corrette") & "'; " includes=includes & "var TEXT_FIELDS_TIME='" & addslashes("I seguenti campi devono essere nel formato 24 ore per essere validi") & "'; " includes=includes & "var TEXT_FIELDS_CC='" & addslashes("I seguenti campi devono essere un valido numero di Carta di Credito") & "'; " includes=includes & "var TEXT_FIELDS_SSN='" & addslashes("") & "'; " includes=includes & "</script> " validatetype="" if validatetype<>"" then bodyonload=bodyonload & "define('value_N_Buono','" & validatetype & "','N_Buono');" validatetype="IsNumeric" if validatetype<>"" then bodyonload=bodyonload & "define('value_importo','" & validatetype & "','importo');" validatetype="" validatetype=validatetype & "IsRequired" if validatetype<>"" then bodyonload=bodyonload & "define('value_data_emissione','" & validatetype & "','data_emissione');" if bodyonload<>"" then onsubmit="return validate();" bodyonload="onload=""" & bodyonload & """" end if if useAJAX then includes=includes & "<script language=""JavaScript"" src=""include/jquery.js""></script>" & vbcrlf includes=includes & "<script language=""JavaScript"" src=""include/ajaxsuggest.js""></script>" & vbcrlf end if includes=includes & "<script language=""JavaScript"" src=""include/jsfunctions.js""></script> " & vbcrlf includes=includes & "<script language=""JavaScript""> " & vbcrlf includes=includes & "var locale_dateformat = " & locale_info("LOCALE_IDATE") & "; " & vbcrlf includes=includes & "var locale_datedelimiter = """ & locale_info("LOCALE_SDATE") & """; " & vbcrlf includes=includes & "var bLoading=false; " & vbcrlf includes=includes & "var TEXT_PLEASE_SELECT='" & addslashes("Prego seleziona") & "'; " & vbcrlf if useAJAX then includes=includes & "var AUTOCOMPLETE_TABLE='transizioni_autocomplete.asp';" & vbcrlf includes=includes & "var SUGGEST_TABLE='transizioni_searchsuggest.asp';" & vbcrlf includes=includes & "var SUGGEST_LOOKUP_TABLE='transizioni_lookupsuggest.asp';" & vbcrlf end if includes=includes & "</script> " & vbcrlf if useAJAX then includes=includes & "<div id=""search_suggest""></div>" & vbcrlf end if '// include datepicker files includes=includes & "<script language=""JavaScript"" src=""include/calendar.js""></script> " smarty.Add "includes",includes smarty.Add "bodyonload",bodyonload if len(onsubmit)>0 then onsubmit="onSubmit=""" & onsubmit & """" smarty.Add "onsubmit",onsubmit end if smarty.Add "message",message smarty.Add "status",status set readonlyfields = CreateObject("Scripting.Dictionary") '// show readonly fields linkdata="" if useAJAX then record_id = postvalue("recordID") if inlineedit then if postvalue("browser")="ie" then smarty.Add "browserie",true end if smarty.Add "id",record_id linkdata = replace(linkdata,"&","&") linkdata = replace(linkdata,"<","<") linkdata = replace(linkdata,">",">") else linkdata = "<script type=""text/javascript"">" & vbCrLf _ & "$(document).ready(function(){" & vbCrLf _ & linkdata & "});</script>" end if else end if smarty.Add "linkdata",linkdata if getRequestForm("a")="added" and inlineedit then 'Preparation view values ' get current values and show edit controls strWhereClause = KeyWhere(keys,"") strSQL = gSQLWhereAdd(strWhereClause) LogInfo(strSQL) rs.Open strSQL,dbConnection,1,2 if rs.EOF then set rs=avalues HaveData = false end if 'check if correct values added smarty.Add "show_key1", my_htmlspecialchars(rs("N_Buono")) showKeys.Add "show_key1", my_htmlspecialchars(rs("N_Buono")) keylink="" keylink=keylink & "&key1=" & my_htmlspecialchars(server.urlencode(dbvalue(rs("N_Buono")))) Set fso = CreateObject("Scripting.FileSystemObject") '//////////////////////////////////////////// '// N_Buono - value="" if len(rs("N_Buono"))<>"" then strdata = make_db_value("N_Buono",rs("N_Buono"),"","") LookupSQL="SELECT " LookupSQL=LookupSQL & "[N_Buono]" LookupSQL=LookupSQL & " FROM [buono] WHERE [N_Buono] = " & strdata LogInfo(LookupSQL) rsLookup.Open LookupSQL,dbConnection lookupvalue=rs("N_Buono") if not rsLookup.eof then _ lookupvalue=rsLookup(0) value=ProcessLargeText(GetDataInt(lookupvalue,rs,"N_Buono", ""),"field=N%5FBuono" & keylink,"",MODE_LIST) rsLookup.Close else value="" end if showValues.Add "showValue1",value showFields.Add "showField1","N_Buono" showRawValues.Add "showRawValues1","" '//////////////////////////////////////////// '// importo - Number value="" value = ProcessLargeText(GetData(rs,"importo", "Number"),"","",MODE_LIST) showValues.Add "showValue2",value showFields.Add "showField2","importo" showRawValues.Add "showRawValues2","" '//////////////////////////////////////////// '// data_emissione - Short Date value="" value = ProcessLargeText(GetData(rs,"data_emissione", "Short Date"),"","",MODE_LIST) showValues.Add "showValue3",value showFields.Add "showField3","data_emissione" showRawValues.Add "showRawValues3","" end if if getRequestForm("a")="added" and inlineedit then response.write "<textarea id=""data"">" if IsSaved and showValues.Count > 0 then if HaveData then response.write "saved" else response.write "savnd" end if print_inline_array showKeys.Items response.write vblf print_inline_array showValues.Items response.write vblf print_inline_array showFields.Items response.write vblf print_inline_array showRawValues.Items response.write vblf print_inline_array showDetailKeys.Keys response.write vblf print_inline_array showDetailKeys.Items else response.write "error" tmpVal = message tmpVal = replace(tmpVal,"&","&") tmpVal = replace(tmpVal,"<","<") tmpVal = replace(tmpVal,"\","\\") tmpVal = replace(tmpVal,vbcr,"\r") tmpVal = replace(tmpVal,vblf,"\n") response.write tmpVal end if response.write "</textarea>" else DoEvent "BeforeShowAdd smarty,templatefile" smarty_display(templatefile) end if function report_error if Err.number<>0 then if inlineedit then message ="" & "Il record non è stato aggiunto" & ". " & Err.Description else message = "<div class=message><<< " & "Il record non è stato aggiunto" & " >>><br><br>" & Err.Description & "</div>" end if readavalues=true errorhappened=true err.clear end if end function %>
[
Íàçàä
]