Modificare il file:
\Buoni-spesa-OLD\buono_add.asp
<!--#include file="include/dbcommon.asp"--> <!--#include file="include/buono_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 = "buono_inline_add.htm" else inlineedit = false templatefile = "buono_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 titolo - start value = postvalue("value_titolo") ttype=postvalue("type_titolo") toadd=true if myRequest.Exists("value_titolo") or myRequest.Exists("value_titolo[]") or myRequest.Exists("type_titolo") then value=prepare_for_db("titolo",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("titolo")=value end if end if ' processibng titolo - end '// processing cognome_nome - start value = postvalue("value_cognome_nome") ttype=postvalue("type_cognome_nome") toadd=true if myRequest.Exists("value_cognome_nome") or myRequest.Exists("value_cognome_nome[]") or myRequest.Exists("type_cognome_nome") then value=prepare_for_db("cognome_nome",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("cognome_nome")=value end if end if ' processibng cognome_nome - 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 durata_num - start value = postvalue("value_durata_num") ttype=postvalue("type_durata_num") toadd=true if myRequest.Exists("value_durata_num") or myRequest.Exists("value_durata_num[]") or myRequest.Exists("type_durata_num") then value=prepare_for_db("durata_num",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("durata_num")=value end if end if ' processibng durata_num - end '// processing durata_let - start value = postvalue("value_durata_let") ttype=postvalue("type_durata_let") toadd=true if myRequest.Exists("value_durata_let") or myRequest.Exists("value_durata_let[]") or myRequest.Exists("type_durata_let") then value=prepare_for_db("durata_let",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("durata_let")=value end if end if ' processibng durata_let - end '// processing titolare - start value = postvalue("value_titolare") ttype=postvalue("type_titolare") toadd=true if myRequest.Exists("value_titolare") or myRequest.Exists("value_titolare[]") or myRequest.Exists("type_titolare") then value=prepare_for_db("titolare",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("titolare")=value end if end if ' processibng titolare - end '// processing scade - start value = postvalue("value_scade") ttype=postvalue("type_scade") toadd=true if myRequest.Exists("value_scade") or myRequest.Exists("value_scade[]") or myRequest.Exists("type_scade") then value=prepare_for_db("scade",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("scade")=value end if end if ' processibng scade - 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 '// processing chiuso - start value = postvalue("value_chiuso") ttype=postvalue("type_chiuso") toadd=true if myRequest.Exists("value_chiuso") or myRequest.Exists("value_chiuso[]") or myRequest.Exists("type_chiuso") then value=prepare_for_db("chiuso",value,ttype,"") if vartype(value)=11 then if value=false then toadd=false end if if toadd then avalues("chiuso")=value end if end if ' processibng chiuso - 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 titolo field strValue=false if avalues.exists("titolo") then _ strValue = avalues.Item("titolo") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_titolo") rs("titolo") = strValue call report_error end if ' insert cognome_nome field strValue=false if avalues.exists("cognome_nome") then _ strValue = avalues.Item("cognome_nome") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_cognome_nome") rs("cognome_nome") = strValue call report_error 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<>"" and IsNumeric(strValue) then rs("importo") = CLng(strValue) else rs("importo") = null end if call report_error end if ' insert durata_num field strValue=false if avalues.exists("durata_num") then _ strValue = avalues.Item("durata_num") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_durata_num") if strValue<>"" and IsNumeric(strValue) then rs("durata_num") = CLng(strValue) else rs("durata_num") = null end if call report_error end if ' insert durata_let field strValue=false if avalues.exists("durata_let") then _ strValue = avalues.Item("durata_let") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_durata_let") rs("durata_let") = strValue call report_error end if ' insert titolare field strValue=false if avalues.exists("titolare") then _ strValue = avalues.Item("titolare") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_titolare") rs("titolare") = strValue call report_error end if ' insert scade field strValue=false if avalues.exists("scade") then _ strValue = avalues.Item("scade") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_scade") if strValue="" then rs("scade")=null else rs("scade")=strValue 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 ' insert chiuso field strValue=false if avalues.exists("chiuso") then _ strValue = avalues.Item("chiuso") if not errorhappened and not (vartype(strValue)=11 and strValue=False) then if isnull(strValue) then strValue="" ctype = GetRequestForm("type_chiuso") if strValue<>"" and IsNumeric(strValue) then rs("chiuso") = CLng(strValue) else rs("chiuso") = null 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("titolo")=dbvalue(rs("titolo")) defvalues("cognome_nome")=dbvalue(rs("cognome_nome")) defvalues("importo")=dbvalue(rs("importo")) defvalues("durata_num")=dbvalue(rs("durata_num")) defvalues("durata_let")=dbvalue(rs("durata_let")) defvalues("titolare")=dbvalue(rs("titolare")) defvalues("scade")=dbvalue(rs("scade")) defvalues("data_emissione")=dbvalue(rs("data_emissione")) defvalues("chiuso")=dbvalue(rs("chiuso")) 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("titolo") then defvalues("titolo")= avalues("titolo") end if if avalues.exists("cognome_nome") then defvalues("cognome_nome")= avalues("cognome_nome") end if if avalues.exists("importo") then defvalues("importo")= avalues("importo") end if if avalues.exists("durata_num") then defvalues("durata_num")= avalues("durata_num") end if if avalues.exists("durata_let") then defvalues("durata_let")= avalues("durata_let") end if if avalues.exists("titolare") then defvalues("titolare")= avalues("titolare") end if if avalues.exists("scade") then defvalues("scade")= avalues("scade") end if if avalues.exists("data_emissione") then defvalues("data_emissione")= avalues("data_emissione") end if if avalues.exists("chiuso") then defvalues("chiuso")= avalues("chiuso") 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="IsNumeric" if validatetype<>"" then bodyonload=bodyonload & "define('value_importo','" & validatetype & "','importo');" validatetype="IsNumeric" if validatetype<>"" then bodyonload=bodyonload & "define('value_durata_num','" & validatetype & "','durata_num');" validatetype="" validatetype=validatetype & "IsRequired" if validatetype<>"" then bodyonload=bodyonload & "define('value_data_emissione','" & validatetype & "','data_emissione');" validatetype="" validatetype=validatetype & "IsRequired" if validatetype<>"" then bodyonload=bodyonload & "define('value_chiuso','" & validatetype & "','chiuso');" 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='buono_autocomplete.asp';" & vbcrlf includes=includes & "var SUGGEST_TABLE='buono_searchsuggest.asp';" & vbcrlf includes=includes & "var SUGGEST_LOOKUP_TABLE='buono_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="" value = ProcessLargeText(GetData(rs,"N_Buono", ""),"","",MODE_LIST) showValues.Add "showValue1",value showFields.Add "showField1","N_Buono" showRawValues.Add "showRawValues1","" '//////////////////////////////////////////// '// titolo - value="" if len(rs("titolo"))<>"" then strdata = make_db_value("titolo",rs("titolo"),"","") LookupSQL="SELECT " LookupSQL=LookupSQL & "[titolo]" LookupSQL=LookupSQL & " FROM [titolo] WHERE [titolo] = " & strdata LogInfo(LookupSQL) rsLookup.Open LookupSQL,dbConnection lookupvalue=rs("titolo") if not rsLookup.eof then _ lookupvalue=rsLookup(0) value=ProcessLargeText(GetDataInt(lookupvalue,rs,"titolo", ""),"field=titolo" & keylink,"",MODE_LIST) rsLookup.Close else value="" end if showValues.Add "showValue2",value showFields.Add "showField2","titolo" showRawValues.Add "showRawValues2","" '//////////////////////////////////////////// '// cognome_nome - value="" value = ProcessLargeText(GetData(rs,"cognome_nome", ""),"","",MODE_LIST) showValues.Add "showValue3",value showFields.Add "showField3","cognome_nome" showRawValues.Add "showRawValues3","" '//////////////////////////////////////////// '// importo - Number value="" value = ProcessLargeText(GetData(rs,"importo", "Number"),"","",MODE_LIST) showValues.Add "showValue4",value showFields.Add "showField4","importo" showRawValues.Add "showRawValues4","" '//////////////////////////////////////////// '// durata_num - value="" value = ProcessLargeText(GetData(rs,"durata_num", ""),"","",MODE_LIST) showValues.Add "showValue5",value showFields.Add "showField5","durata_num" showRawValues.Add "showRawValues5","" '//////////////////////////////////////////// '// durata_let - value="" value = ProcessLargeText(GetData(rs,"durata_let", ""),"","",MODE_LIST) showValues.Add "showValue6",value showFields.Add "showField6","durata_let" showRawValues.Add "showRawValues6","" '//////////////////////////////////////////// '// titolare - value="" if len(rs("titolare"))<>"" then strdata = make_db_value("titolare",rs("titolare"),"","") LookupSQL="SELECT " LookupSQL=LookupSQL & "[titolare]" LookupSQL=LookupSQL & " FROM [titolare] WHERE [titolare] = " & strdata LogInfo(LookupSQL) rsLookup.Open LookupSQL,dbConnection lookupvalue=rs("titolare") if not rsLookup.eof then _ lookupvalue=rsLookup(0) value=ProcessLargeText(GetDataInt(lookupvalue,rs,"titolare", ""),"field=titolare" & keylink,"",MODE_LIST) rsLookup.Close else value="" end if showValues.Add "showValue7",value showFields.Add "showField7","titolare" showRawValues.Add "showRawValues7","" '//////////////////////////////////////////// '// scade - Short Date value="" value = ProcessLargeText(GetData(rs,"scade", "Short Date"),"","",MODE_LIST) showValues.Add "showValue8",value showFields.Add "showField8","scade" showRawValues.Add "showRawValues8","" '//////////////////////////////////////////// '// data_emissione - Short Date value="" value = ProcessLargeText(GetData(rs,"data_emissione", "Short Date"),"","",MODE_LIST) showValues.Add "showValue9",value showFields.Add "showField9","data_emissione" showRawValues.Add "showRawValues9","" '//////////////////////////////////////////// '// chiuso - Checkbox value="" value = GetData(rs,"chiuso", "Checkbox") showValues.Add "showValue10",value showFields.Add "showField10","chiuso" showRawValues.Add "showRawValues10","" 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 %>
[
Íàçàä
]