⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rewardreports.jsp

📁 一个jive论坛管理的源码 学习Jive源程序
💻 JSP
字号:
<%@ page contentType="text/html;charset=GB2312" %>
<%
/**
 *	$RCSfile: rewardReports.jsp,v $
 *	$Revision: 1.1.1.1 $
 *	$Date: 2002/09/09 13:50:17 $
 */
%>

<%@ page import="java.util.*,
				 java.text.*,
                 java.sql.*,
				 com.jivesoftware.util.*,
                 com.jivesoftware.forum.*,
				 com.jivesoftware.forum.database.*,
				 com.jivesoftware.forum.util.*"
    errorPage="error.jsp"
%>

<%@ include file="global.jsp" %>

<%!
    private static final int THIS_MONTH = 1;
    private static final int SOME_MONTH = 2;
    private static final int SOME_YEAR = 3;
	private static final int START_YEAR=2000;
	private static final int END_YEAR=Calendar.getInstance().get(Calendar.YEAR) ;
    private static final String POINT_EARNERS_SQL =
        "SELECT userID, SUM(rewardPoints) AS points FROM jiveReward " +
        "WHERE creationDate > ? AND creationDate < ? " +
        "GROUP BY userID ORDER BY points desc";
    private static final SimpleDateFormat monthYearDateFormatter
        = new SimpleDateFormat("MMMM, yyyy");
%>

<%	// get parameters
	int reportType = ParamUtils.getIntParameter(request,"reportType",-1);
    boolean generate = ParamUtils.getBooleanParameter(request,"generate");
    int month = ParamUtils.getIntParameter(request,"month",1);
    int year1 = ParamUtils.getIntParameter(request,"year1",START_YEAR);
    int year2 = ParamUtils.getIntParameter(request,"year2",START_YEAR);

    UserManager userManager = forumFactory.getUserManager();
%>

<%@ include file="header.jsp" %>

<p>

<%  // Title of this page and breadcrumbs
    String title = "点数报告";
    String[][] breadcrumbs = {
        {"主页面", "main.jsp"},
        {title, "rewardReports.jsp"}
    };
%>
<%@ include file="title.jsp" %>

<font size="-1">
使用下面的表单产生点数报告。
</font>

<p>

<form action="rewardReports.jsp">
<input type="hidden" name="generate" value="true">

<font size="-1">选择报告方式:</font>
<ul>
    <input type="radio" name="reportType" value="<%= THIS_MONTH %>" checked>
    <font size="-1">当月最多点数者</font>
    <p>

    <input type="radio" name="reportType" value="<%= SOME_MONTH %>">
    <font size="-1"></font>
    <select size="1" name="year1">
<% for (int y=START_YEAR;y<=END_YEAR;y++) {
%>
	<option value="<%=String.valueOf(y)%>"><%=String.valueOf(y)%>
<%
	}
%>
    </select>年
	<select size="1" name="month">
    <option value="0">一
    <option value="1">二
    <option value="2">三
    <option value="3">四
    <option value="4">五
    <option value="5">六
    <option value="6">七
    <option value="7">八
    <option value="8">九
    <option value="9">十
    <option value="10">十一
    <option value="11">十二
    </select>月点数最多者
    <p>

    <input type="radio" name="reportType" value="<%= SOME_YEAR %>">
    <font size="-1"></font>
    <select size="1" name="year2">
<% for (int y=START_YEAR;y<=END_YEAR;y++) {
%>
	<option value="<%=String.valueOf(y)%>"><%=String.valueOf(y)%>
<%
	}
%>
    </select>年点数最多者
</ul>
<input type="submit" value="产生报告">
</form>

<%  if (generate) { %>
<hr>

<center>

<%      if (reportType != THIS_MONTH
            && reportType != SOME_MONTH
            && reportType != SOME_YEAR)
        {
%>      <font size="-1"><i>请选择一种报告方式</i></font>
<%      } else {
            Calendar cal = Calendar.getInstance();
            // "bottom" out the calendar by resetting it to the beginning day
            // in this month:
            cal.set(Calendar.DAY_OF_MONTH, 1);
            cal.set(Calendar.HOUR_OF_DAY, 0);
            cal.set(Calendar.MINUTE, 0);
            cal.set(Calendar.SECOND, 0);
            cal.set(Calendar.MILLISECOND, 0);
%>

<%      if (reportType == THIS_MONTH) {
%>

    <font size="+1">
    <%= monthYearDateFormatter.format(cal.getTime()) %>年 点数最高者
    </font>

<%      } else if (reportType == SOME_MONTH) {
            cal.set(Calendar.MONTH, month);
            cal.set(Calendar.YEAR, year1);
%>

    <font size="+1">
    <%= monthYearDateFormatter.format(cal.getTime()) %>年	点数最高者
    </font>

<%      } else if (reportType == SOME_YEAR) {
            cal.set(Calendar.DAY_OF_YEAR, 1);
            cal.set(Calendar.YEAR, year2);
%>

    <font size="+1">
    <%= year2 %>  年点数最高者
    </font>

<%      } else {} %>

<p>

<table cellpadding="3" cellspacing="0" border="1" width="80%">
<tr>
    <td align="center" width="10%">&nbsp;</td>
    <td align="center" width="45%"><font size="-1"><b>用户</b></font></td>
    <td align="center" width="45%"><font size="-1"><b>点数</b></font></td>
</tr>

<%
    Connection con = null;
    PreparedStatement pstmt = null;
    try {
        con = ConnectionManager.getConnection();
        pstmt = con.prepareStatement(POINT_EARNERS_SQL);
        if (reportType == THIS_MONTH) {
            pstmt.setString(1, StringUtils.dateToMillis(cal.getTime()));
            cal.roll(Calendar.MONTH,1);
            pstmt.setString(2, StringUtils.dateToMillis(cal.getTime()));
        }
        else if (reportType == SOME_MONTH) {
            pstmt.setString(1, StringUtils.dateToMillis(cal.getTime()));
            cal.roll(Calendar.MONTH,1);
            pstmt.setString(2, StringUtils.dateToMillis(cal.getTime()));
        }
        else if (reportType == SOME_YEAR) {
            pstmt.setString(1, StringUtils.dateToMillis(cal.getTime()));
            cal.roll(Calendar.YEAR,1);
            pstmt.setString(2, StringUtils.dateToMillis(cal.getTime()));
        }
        ResultSet rs = pstmt.executeQuery();
        int count = 0;
        boolean noData = true;
        while (rs.next() && (count++ < 10)) {
            noData = false;
            long userID = rs.getLong(1);
            int points = rs.getInt(2);
%>
<tr>
    <td align="right"><font size="-1"><%= count %></font></td>
    <td align="center"><font size="-1"><%= userManager.getUser(userID).getUsername() %></font></td>
    <td align="center"><font size="-1"><%= points %></font></td>
</tr>
<%      }
        if (noData) {
%>
<tr>
    <td colspan="3" align="center"><font size="-1"><i>此时段没有数据。</i></font></td>
</tr>
<%
        }
    }
    catch (SQLException sqle) {
        sqle.printStackTrace();
    }
    finally {
        try {  pstmt.close();   }
        catch (Exception e) { e.printStackTrace(); }
        try {  con.close();   }
        catch (Exception e) { e.printStackTrace(); }
    }
%>
</table>

<%      }
    }
%>

</center>

<%@ include file="footer.jsp" %>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -