Modificare il file:
\Buoni-spesa-OLD\buono_edit.asp
<!--#include file="include/dbcommon.asp"--> <!--#include file="include/buono_variables.asp"--> <!--#include file="libs/smarty.asp"--> <% ' check if logged in if SESSION("UserID")="" or not CheckSecurity(SESSION("_" & strTableName & "_OwnerID"),"Edit") then SESSION("MyURL")=request.ServerVariables("SCRIPT_NAME")&"?"&request.ServerVariables("QUERY_STRING") response.Redirect "login.asp?message=expired" response.End end if Set myRequest = CreateObject("Scripting.Dictionary") Set myRequestFiles = CreateObject("Scripting.Dictionary") if ParseMultiPartForm()=true then parse=1 MaxSizeSet=false filename="" status="" message="" readevalues=false errorhappened=false set showKeys = Server.CreateObject("Scripting.Dictionary") inlineedit = false set showValues = Server.CreateObject("Scripting.Dictionary") set showRawValues = Server.CreateObject("Scripting.Dictionary") set showFields = Server.CreateObject("Scripting.Dictionary") set showDetailKeys = Server.CreateObject("Scripting.Dictionary") IsSaved = false HaveData = true if postvalue("editType")="inline" then inlineedit = true templatefile = "buono_inline_edit.htm" else inlineedit = false templatefile = "buono_edit.htm" end if ' connect database dbConnection="" db_connect() DoEvent "BeforeProcessEdit dbConnection" Set rs = server.CreateObject("ADODB.Recordset") Set rsLookup = server.CreateObject("ADODB.Recordset") set keys = CreateObject("Scripting.Dictionary") keys("N_Buono")=postvalue("editid1") ' prepare data for saving if getRequestForm("a")="edited" then sstrWhere=KeyWhere(keys,"") strSQL = "select * from " & AddTableWrappers(strOriginalTableName) & " where " & sstrWhere set evalues = CreateObject("Scripting.Dictionary") set efilename_values = CreateObject("Scripting.Dictionary") set files_delete = CreateObject("Scripting.Dictionary") set files_move = CreateObject("Scripting.Dictionary") ' processing titolo - start value = postvalue("value_titolo") ttype=postvalue("type_titolo") toedit=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 _ toedit=false end if if toedit then evalues("titolo") = value end if end if ' processibng titolo - end ' processing cognome_nome - start value = postvalue("value_cognome_nome") ttype=postvalue("type_cognome_nome") toedit=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 _ toedit=false end if if toedit then evalues("cognome_nome") = value end if end if ' processibng cognome_nome - end ' processing importo - start value = postvalue("value_importo") ttype=postvalue("type_importo") toedit=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 _ toedit=false end if if toedit then evalues("importo") = value end if end if ' processibng importo - end ' processing durata_num - start value = postvalue("value_durata_num") ttype=postvalue("type_durata_num") toedit=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 _ toedit=false end if if toedit then evalues("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") toedit=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 _ toedit=false end if if toedit then evalues("durata_let") = value end if end if ' processibng durata_let - end ' processing titolare - start value = postvalue("value_titolare") ttype=postvalue("type_titolare") toedit=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 _ toedit=false end if if toedit then evalues("titolare") = value end if end if ' processibng titolare - end ' processing scade - start value = postvalue("value_scade") ttype=postvalue("type_scade") toedit=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 _ toedit=false end if if toedit then evalues("scade") = value end if end if ' processibng scade - end ' processing data_emissione - start value = postvalue("value_data_emissione") ttype=postvalue("type_data_emissione") toedit=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 _ toedit=false end if if toedit then evalues("data_emissione") = value end if end if ' processibng data_emissione - end ' processing chiuso - start value = postvalue("value_chiuso") ttype=postvalue("type_chiuso") toedit=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 _ toedit=false end if if toedit then evalues("chiuso") = value end if end if ' processibng chiuso - end for each ekey in efilename_values if evalues.Exists(ekey) then evalues.Remove(ekey) evalues(ekey) = efilename_values.Item(ekey) next ' do event retval=true DoEvent "retval=BeforeEdit(evalues,sstrWhere,rsold,keys,message,inlineedit)" if retval then on error resume next rs.Open strSQL, dbConnection, 1,2 call report_error if IsUpdatable(rs("N_Buono")) then ' update N_Buono field strValue=false if evalues.exists("N_Buono") then _ strValue = evalues.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 ' update titolo field strValue=false if evalues.exists("titolo") then _ strValue = evalues.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 ' update cognome_nome field strValue=false if evalues.exists("cognome_nome") then _ strValue = evalues.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 ' update importo field strValue=false if evalues.exists("importo") then _ strValue = evalues.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 ' update durata_num field strValue=false if evalues.exists("durata_num") then _ strValue = evalues.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 ' update durata_let field strValue=false if evalues.exists("durata_let") then _ strValue = evalues.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 ' update titolare field strValue=false if evalues.exists("titolare") then _ strValue = evalues.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 ' update scade field strValue=false if evalues.exists("scade") then _ strValue = evalues.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 ' update data_emissione field strValue=false if evalues.exists("data_emissione") then _ strValue = evalues.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 ' update chiuso field strValue=false if evalues.exists("chiuso") then _ strValue = evalues.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 rs.Close ' delete & move files on error goto 0 if not errorhappened then Set fso = CreateObject("Scripting.FileSystemObject") for each file in files_delete if fso.FileExists(file) then fso.DeleteFile(file) next for each file in files_move if fso.FileExists(file) then fso.MoveFile file(0),file(1) next Set fso=nothing if inlineedit then status="UPDATED" message="" & "Recordo aggiornato" & "" IsSaved = true else message="<div class=message><<< " & "Recordo aggiornato" & " >>></div>" end if ' after edit event DoEvent "AfterEdit evalues,rsold,keys,inlineedit" end if else readevalues=true end if end if ' get current values and show edit controls strWhereClause=KeyWhere(keys,"") strSQL = gSQLWhereAdd(strWhereClause) strSQLbak = strSQL DoEvent "BeforeQueryEdit strSQL,strWhereClause" if strSQLbak = strSQL then strSQL = gSQLWhereAdd(strWhereClause) end if LogInfo(strSQL) Set rs = nothing Set rs = server.CreateObject("ADODB.Recordset") rs.Open strSQL,dbConnection,1,2 if rs.EOF then response.redirect "buono_list.asp?a=return" response.end end if 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>" includes=includes & "<script language=""JavaScript"" src=""include/ajaxsuggest.js""></script>" end if includes=includes & "<script language=""JavaScript"" src=""include/jsfunctions.js""></script>" includes=includes & "<script language=""JavaScript"">" & _ "var locale_dateformat = " & locale_info("LOCALE_IDATE") & ";" & _ "var locale_datedelimiter = """ & locale_info("LOCALE_SDATE") & """;" & _ "var bLoading=false;" & _ "var TEXT_PLEASE_SELECT='" & addslashes("Prego seleziona") & "';" 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 "key1",my_htmlspecialchars(keys("N_Buono")) showKeys.Add "show_key1",server.urlencode(keys("N_Buono")) smarty.Add "show_key1", my_htmlspecialchars(GetData(rs,"N_Buono", "")) smarty.Add "message",message set readonlyfields = CreateObject("Scripting.Dictionary") 'smarty.Add "value_titolo",dbvalue(rs("titolo")) if readevalues then smarty.Add "value_titolo",evalues("titolo") else smarty.Add "value_titolo",dbvalue(rs("titolo")) end if 'smarty.Add "value_cognome_nome",dbvalue(rs("cognome_nome")) if readevalues then smarty.Add "value_cognome_nome",evalues("cognome_nome") else smarty.Add "value_cognome_nome",dbvalue(rs("cognome_nome")) end if 'smarty.Add "value_importo",dbvalue(rs("importo")) if readevalues then smarty.Add "value_importo",evalues("importo") else smarty.Add "value_importo",dbvalue(rs("importo")) end if 'smarty.Add "value_durata_num",dbvalue(rs("durata_num")) if readevalues then smarty.Add "value_durata_num",evalues("durata_num") else smarty.Add "value_durata_num",dbvalue(rs("durata_num")) end if 'smarty.Add "value_durata_let",dbvalue(rs("durata_let")) if readevalues then smarty.Add "value_durata_let",evalues("durata_let") else smarty.Add "value_durata_let",dbvalue(rs("durata_let")) end if 'smarty.Add "value_titolare",dbvalue(rs("titolare")) if readevalues then smarty.Add "value_titolare",evalues("titolare") else smarty.Add "value_titolare",dbvalue(rs("titolare")) end if 'smarty.Add "value_scade",dbvalue(rs("scade")) if readevalues then smarty.Add "value_scade",evalues("scade") else smarty.Add "value_scade",dbvalue(rs("scade")) end if 'smarty.Add "value_data_emissione",dbvalue(rs("data_emissione")) if readevalues then smarty.Add "value_data_emissione",evalues("data_emissione") else smarty.Add "value_data_emissione",dbvalue(rs("data_emissione")) end if 'smarty.Add "value_chiuso",dbvalue(rs("chiuso")) if readevalues then smarty.Add "value_chiuso",evalues("chiuso") else smarty.Add "value_chiuso",dbvalue(rs("chiuso")) end if 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 where=sstrWhere if getRequestForm("a")="edited" and inlineedit then if rs.EOF then set rs=evalues HaveData = false end if 'Preparation view values ' detail tables 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")="edited" 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 "BeforeShowEdit smarty,templatefile" smarty_display(templatefile) end if sub report_error if Err.number<>0 then if inlineedit then message ="" & "Il record non è stato modificato" & ". " & Err.Description else message = "<div class=message><<< " & "Il record non è stato modificato" & " >>><br><br>" & Err.Description & "</div>" end if readevalues=true errorhappened=true err.clear end if end sub %>
[
Íàçàä
]