% if SESSION("UserID")="" then SESSION("MyURL")=request.ServerVariables("SCRIPT_NAME")&"?"&request.ServerVariables("QUERY_STRING") response.Redirect "login.asp?message=expired" response.End end if if not CheckSecurity(SESSION("_" & strTableName & "_OwnerID"),"Export") then response.Write "
" & "Non hai il permesso per accedere a questa tabella" & "" & "Torna alla pagina di login" & "
" response.End end if dbConnection="" db_connect() DoEvent "BeforeProcessExport dbConnection" options ="1" if request("a")<>"" then sWhere = "1=0" options ="" 'process selection set selected_recs = CreateObject("Scripting.Dictionary") if request("mdelete[]").Count>0 then for ind=1 to request("mdelete[]").Count set keys = CreateObject("Scripting.Dictionary") AddDict keys,"N_Buono",request("mdelete1[]").Item(request("mdelete[]").Item(ind)) AddDict selected_recs, ind, keys next elseif request("selection[]").Count>0 then for ind=1 to request("selection[]").Count set keys = CreateObject("Scripting.Dictionary") arr = split(request("selection[]").Item(ind) ,"&") if UBound(arr)-LBound(arr) = 1 - 1 then AddDict keys,"N_Buono", HTMLDecode(arr(0)) AddDict selected_recs, ind, keys end if next end if sr = selected_recs.Items for ind=1 to selected_recs.Count set keys = sr(ind-1) sWhere=sWhere & " or " sWhere=sWhere & KeyWhere(keys,"") next strSQL = gSQLWhereAdd(sWhere) strWhereClause=sWhere SESSION(strTableName & "_SelectedSQL") = strSQL SESSION(strTableName & "_SelectedWhere") = sWhere end if smarty.Add "options",options if SESSION(strTableName & "_SelectedSQL")<>"" and request.QueryString("records")="" then strSQL = SESSION(strTableName & "_SelectedSQL") strWhereClause=SESSION(strTableName & "_SelectedWhere") else strWhereClause=SESSION(strTableName & "_where") strSQL=gSQLWhereAdd(strWhereClause) end if mypage=1 if REQUEST("type")<>"" then Set rs = server.CreateObject("ADODB.Recordset") Set rss = server.CreateObject("ADODB.Recordset") strOrderBy=SESSION(strTableName & "_order") if strOrderBy="" then _ strOrderBy=gstrOrderBy strSQL= strSQL & " " & trim(strOrderBy) strSQLbak = strSQL DoEvent "BeforeQueryExport strSQL,strWhereClause,strOrderBy" ' Rebuild SQL if needed if strSQLbak <> strSQL then ' changed strSQL - old style numrows=GetRowCount(strSQL) else strSQL = gSQLWhereAdd(strWhereClause) strSQL= strSQL & " " & trim(strOrderBy) numrows=gSQLRowCount(strWhereClause) end if LogInfo(strSQL) '// pagination nPageSize=0 if REQUEST("records")="page" and numrows>0 then mypage=SESSION(strTableName & "_pagenumber") nPageSize=SESSION(strTableName & "_pagesize") if numrows<=(mypage-1)*nPageSize then mypage=int(numrows/nPageSize) end if if nPageSize="" then nPageSize=gPageSize if mypage="" then mypage=1 strSQL = AddTop(strSQL, mypage*nPageSize) end if rs.Open strSQL, dbConnection,1,2 if not rs.EOF then rs.Move(nPageSize*(mypage-1)) Server.ScriptTimeOut=300 if REQUEST("type")="excel" then call ExportToExcel elseif REQUEST("type")="word" then call ExportToWord elseif REQUEST("type")="xml" then call ExportToXML elseif REQUEST("type")="csv" then call ExportToCSV elseif REQUEST("type")="pdf" then call ExportToPDF end if rs.Close response.End end if 'Response.AddHeader("Expires: Thu, 01 Jan 1970 00:00:01 GMT") smarty_display("transizioni_export.htm") sub ExportToExcel() Response.ContentType = "application/vnd.ms-excel" Response.AddHeader "Content-Disposition", "attachment;Filename=transizioni.xls" response.Write "" response.Write "" response.Write "" response.Write "" response.Write "