home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Special / chip-cd_2001_spec_05.zip / spec_05 / apps / crystal / disk24 / Xasp23 < prev    next >
Text File  |  1999-08-23  |  7KB  |  231 lines

  1. <% if Session("username") = "" then
  2.         Response.Redirect("logon.asp")
  3.     end if
  4. %>
  5. <%
  6. ' Make sure the browser does not cache this file
  7. response.expires = 0
  8.  
  9. ' Get the requested report name
  10. rpttoview = request.querystring("rpt")
  11.  
  12. ' Set a default, to show a group tree
  13. ' this can be modified for indivual reports 
  14. showgrouptree = "1"
  15.  
  16. ' the viewer type is detected and stored in this variable
  17. viewer = Session("init")
  18.  
  19. 'Save the reportn name that is being processed
  20. Session("report") = rpttoview
  21.  
  22. 'build full path for report
  23. fullpathtorpt = MID(request.ServerVariables("PATH_TRANSLATED"), 1, (LEN(request.ServerVariables("PATH_TRANSLATED"))-32)) & "\reports\xtreme\" & rpttoview & ".rpt"
  24.  
  25. ' Need to set the location of the data, this is done to illustrate
  26. ' the capability of the automation server. 
  27. ' Build the path to the xtreme.mdb
  28. pathtomdb = MID(request.ServerVariables("PATH_TRANSLATED"), 1, (LEN(request.ServerVariables("PATH_TRANSLATED"))-32)) & "\xtreme.mdb"
  29.  
  30. ' Only create the Crystal Application Object on first time through
  31.  
  32. If Not IsObject ( Session ("oApp")) Then
  33. Set Session ("oApp") = Server.CreateObject("Crystal.CRPE.Application")
  34. End If
  35.  
  36. ' Turn off all Error Message dialogs
  37. Set oGlobalOptions = Session ("oApp").Options
  38. oGlobalOptions.MorePrintEngineErrorMessages = 0
  39.  
  40.  
  41. ' Open the report
  42.  
  43. Set Session("oRpt") = Session("oApp").OpenReport(fullpathtorpt)
  44.  
  45. ' Turn off sepecific report error messages
  46. Set oRptOptions = Session("oRpt").Options
  47. oRptOptions.MorePrintEngineErrorMessages = 0
  48.  
  49. ' now set the table location
  50. Set oDB = session("oRpt").Database
  51. For Each oDBTable In oDB.Tables
  52.     oDBTable.Location = pathtomdb
  53. Next
  54.  
  55.  
  56.  
  57. ' Based on the selected report, modify various report parameters
  58.  
  59. Select Case rpttoview
  60.  
  61. Case "customer"
  62.     ' this report is dynamically personalized based on the current user,
  63.     ' by changing a parameter field
  64.         Set paramFlds = Session("oRpt").ParameterFields
  65.         Set paramFld = paramFlds(1)
  66.         paramFld.SetCurrentValue session("username"), 12
  67.         ' now set the table location on the subreport
  68.         Set oSubReport = session("oRpt").OpenSubReport("orders.rpt")
  69.         
  70.         ' Turn off sepecific report error messages
  71.         Set oRptOptions = Session("oRpt").Options
  72.         oRptOptions.MorePrintEngineErrorMessages = 0
  73.         Set oDB = oSubReport.Database
  74.         For Each oDBTable In oDB.Tables
  75.             oDBTable.Location = pathtomdb
  76.         Next
  77.  
  78. Case "empsales"
  79.     ' this report is dynamically personalized based on the current user,
  80.     ' by changing a parameter field
  81.         Set paramFlds = Session("oRpt").ParameterFields
  82.         Set paramFld = paramFlds(1)
  83.         paramFld.SetCurrentValue session("username"), 12
  84.  
  85. Case "statemnt"
  86.     ' this report is dynamically personalized based on the current user,
  87.     ' by changing a parameter field
  88.         Set paramFlds = Session("oRpt").ParameterFields
  89.         Set paramFld = paramFlds(1)
  90.         paramFld.SetCurrentValue session("username"), 12
  91.  
  92. Case "maillabl"
  93.     ' Turn off grouptree for this report
  94.     showgrouptree = "0"
  95.  
  96. Case "balance"
  97.     ' Turn off grouptree for this report
  98.     showgrouptree = "0"
  99.  
  100. Case "finstate"
  101.     ' Turn off grouptree for this report
  102.     showgrouptree = "0"
  103.     ' now set the table location on the subreport
  104.     Set oSubReport = session("oRpt").OpenSubReport("income.rpt")
  105.     ' Turn off sepecific report error messages
  106.     Set oRptOptions = Session("oRpt").Options
  107.     oRptOptions.MorePrintEngineErrorMessages = 0
  108.     Set oDB = oSubReport.Database
  109.     For Each oDBTable In oDB.Tables
  110.         oDBTable.Location = pathtomdb
  111.     Next
  112.  
  113.     ' now set the table location on the subreport
  114.     Set oSubReport = session("oRpt").OpenSubReport("fr2.rpt")
  115.         
  116.     ' Turn off sepecific report error messages
  117.     Set oRptOptions = Session("oRpt").Options
  118.     oRptOptions.MorePrintEngineErrorMessages = 0
  119.     Set oDB = oSubReport.Database
  120.     For Each oDBTable In oDB.Tables
  121.         oDBTable.Location = pathtomdb
  122.     Next
  123.  
  124. Case "income"
  125.     ' Turn off grouptree for this report
  126.     showgrouptree = "0"
  127.  
  128.  
  129. End Select
  130.  
  131.  
  132. ' This method forces all records to be read
  133. Session("oRpt").ReadRecords
  134.  
  135. ' The PageEngine object can derive all (drill down)views of the report
  136. Set Session("oPageEngine") = Session("oRpt").PageEngine
  137.  
  138. ' Now decide what viewer to create
  139.  
  140. Select Case viewer
  141.  
  142.     Case "java"
  143. %>
  144. <html><body
  145. <%
  146. if(Session("page")="fr_sales" ) then
  147. response.write(" bgcolor=#003366")
  148. elseif(Session("page")="fr_company") then
  149. response.write(" bgcolor=#330066")
  150. elseif(Session("page")="fr_eis") then
  151. response.write(" bgcolor=#186666")
  152. elseif(Session("page")="fr_warehouse") then
  153. response.write(" bgcolor=#990000")
  154. end if
  155.  
  156.  
  157. %>
  158.  
  159. >
  160.  
  161.  
  162.  
  163.  
  164. <SCRIPT LANGUAGE="JavaScript"><!--
  165.      var _ns3 = false;
  166.      var _ns4 = false;
  167.      //--></SCRIPT>
  168.      <COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
  169.      var _info = navigator.userAgent;
  170.      var _ns3 = (navigator.appName.indexOf("Netscape") >= 0 && _info.indexOf("Win16") < 0 && _info.indexOf("Mozilla/3") >= 0);
  171.      var _ns4 = (navigator.appName.indexOf("Netscape") >= 0 && _info.indexOf("Win16") < 0 && _info.indexOf("Mozilla/4") >= 0 );
  172.      //--></SCRIPT></COMMENT>
  173.          <SCRIPT LANGUAGE="JavaScript"><!--
  174.              if(_ns3==true)
  175.  document.writeln( '<applet code=com.seagatesoftware.img.ReportViewer.ReportViewer          codebase="/viewer/JavaViewer"          id=ReportViewer width=100% height=95%  archive="/viewer/JavaViewer/ReportViewer.zip">' );
  176.              else if (_ns4 == true)
  177.  document.writeln( '<applet code=com.seagatesoftware.img.ReportViewer.ReportViewer          codebase="/viewer/JavaViewer"          id=ReportViewer width=100% height=95%  archive="/viewer/JavaViewer/ReportViewer.jar">' );
  178.              else
  179.  document.writeln( '<applet code=com.seagatesoftware.img.ReportViewer.ReportViewer          codebase="/viewer/JavaViewer"          id=ReportViewer width=100% height=95%  >' );
  180.          //--></SCRIPT>
  181.  
  182.          <param name=ReportName value="rptserver.asp">
  183.         <param name=HasGroupTree value=true>
  184.         <param name=ShowGroupTree value=<% response.write showgrouptree %>>
  185.         <param name=HasRefreshButton value=true>
  186.         <param name=HasPrintButton value=true>
  187.          <param name=cabbase value="/viewer/JavaViewer/ReportViewer.cab">
  188.         </applet>
  189. </body>
  190. </html>
  191. <%
  192.     Case "actx"
  193. %>
  194. <html><body
  195. <%
  196. if(Session("page")="fr_sales" ) then
  197. response.write(" bgcolor=#003366")
  198. elseif(Session("page")="fr_company") then
  199. response.write(" bgcolor=#330066")
  200. elseif(Session("page")="fr_eis") then
  201. response.write(" bgcolor=#186666")
  202. elseif(Session("page")="fr_warehouse") then
  203. response.write(" bgcolor=#990000")
  204. end if
  205.  
  206.  
  207. %>
  208.  
  209. >
  210. <OBJECT ALIGN = LEFT ID="CRViewer"  WIDTH=100% HEIGHT=95%
  211.  CLASSID="CLSID:C4847596-972C-11D0-9567-00A0C9273C2A"
  212.  CODEBASE="/viewer/activeXViewer/CRViewer.dll#Version=1,2,0,30">
  213.  <PARAM NAME="Report Name" VALUE="rptserver.asp">
  214.     <PARAM NAME="Show Group Tree" VALUE= <% response.write showgrouptree %>>
  215.     <PARAM NAME="Show Toolbar" VALUE= 1>
  216. </OBJECT>
  217.  
  218. <%
  219.     Case "html_frame"
  220.         response.redirect "htmstart.asp"
  221.  
  222.     Case "html_page"
  223.  
  224.     response.redirect "rptserver.asp"
  225.  
  226.  
  227.  
  228.     end select
  229.  
  230. %>
  231.