mywork.jsp
上传用户:jhtang88
上传日期:2014-01-27
资源大小:28528k
文件大小:8k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=utf-8"%>
  2. <%@ page import = "java.util.*"%>
  3. <%@ page import = "com.redmoon.oa.person.*"%>
  4. <%@ page import = "com.redmoon.oa.worklog.*"%>
  5. <%@ page import = "cn.js.fan.util.*"%>
  6. <%@ page import = "cn.js.fan.web.*"%>
  7. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  8. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  9. <html>
  10. <head>
  11. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  12. <title>考勤</title>
  13. <link href="../common.css" rel="stylesheet" type="text/css">
  14. <%@ include file="../inc/nocache.jsp"%>
  15. <script language="JavaScript" type="text/JavaScript">
  16. <!--
  17. function MM_preloadImages() { //v3.0
  18.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  19.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  20.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  21. }
  22. //-->
  23. </script>
  24. <script language=javascript>
  25. <!--
  26. function openWin(url,width,height)
  27. {
  28.   var newwin=window.open(url,"_blank","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,top=50,left=120,width="+width+",height="+height);
  29. }
  30. //-->
  31. </script>
  32. </head>
  33. <body background="" leftmargin="0" topmargin="5" marginwidth="0" marginheight="0">
  34. <%
  35. String priv="read";
  36. if (!privilege.isUserLogin(request))
  37. {
  38. out.println(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  39. return;
  40. }
  41. %>
  42. <%!
  43.   int daysInMonth[] = {
  44.       31, 28, 31, 30, 31, 30, 31, 31,
  45.       30, 31, 30, 31};
  46.   public int getDays(int month, int year) {
  47.     //测试选择的年份是否是润年?
  48.     if (1 == month)
  49.       return ( (0 == year % 4) && (0 != (year % 100))) ||
  50.           (0 == year % 400) ? 29 : 28;
  51.         else
  52.       return daysInMonth[month];
  53.   }
  54. %>
  55. <%
  56. String userName = ParamUtil.get(request, "userName");
  57. if (userName.equals("")) {
  58. out.print(StrUtil.Alert_Back("用户名不能为空!"));
  59. return;
  60. }
  61. if (!privilege.canAdminUser(request, userName)) {
  62. out.print(StrUtil.Alert_Back(SkinUtil.LoadString(request, "pvg_invalid")));
  63. return;
  64. }
  65. UserDb ud = new UserDb();
  66. ud = ud.getUserDb(userName);
  67. // 翻月
  68. int showyear,showmonth;
  69. Calendar cal = Calendar.getInstance();
  70. int curday = cal.get(cal.DAY_OF_MONTH);
  71. int curhour = cal.get(cal.HOUR_OF_DAY);
  72. int curminute = cal.get(cal.MINUTE);
  73. int curmonth = cal.get(cal.MONTH);
  74. int curyear = cal.get(cal.YEAR);
  75. String strshowyear = request.getParameter("showyear");
  76. String strshowmonth = request.getParameter("showmonth");
  77. if (strshowyear!=null)
  78. showyear = Integer.parseInt(strshowyear);
  79. else
  80. showyear = cal.get(cal.YEAR);
  81. if (strshowmonth!=null)
  82. showmonth = Integer.parseInt(strshowmonth);
  83. else
  84. showmonth = cal.get(cal.MONTH) + 1;
  85. %>
  86. <table width="98%" border="0" align="center" cellpadding="0" cellspacing="0" class="tableframe">
  87.   <tr>
  88.     <td width="100%" height="23" class="right-title">&nbsp;<%=ud.getRealName()%>&nbsp;&nbsp;<%=showmonth%> 月 工 作 记 事 表 </td>
  89.   </tr>
  90.   <tr>
  91.     <td valign="top" background="images/tab-b-back.gif">
  92. <table width="98%" border="0" align="center">
  93.         <tr> 
  94.           <td align="center">&nbsp;</td>
  95.         </tr>
  96.         <tr> 
  97.           <td align="center"> 
  98. <select name="showyear" onChange="var y = this.options[this.selectedIndex].value; window.location.href='?showyear=' + y + '&userName=<%=StrUtil.UrlEncode(userName)%>';">
  99.   <%for (int y=curyear-60; y<=curyear; y++) {%>
  100.   <option value="<%=y%>"><%=y%></option>
  101.   <%}%>
  102.   </select>
  103.   <script>
  104.   showyear.value = "<%=showyear%>";
  105.   </script>   <%
  106. for (int i=1; i<=12; i++) {
  107. if (showmonth==i)
  108. out.print("<a href='mywork.jsp?userName=" + StrUtil.UrlEncode(userName) + "&showyear="+showyear+"&showmonth="+i+"'><font color=red>"+i+"月</font></a>&nbsp;");
  109. else
  110. out.print("<a href='mywork.jsp?userName=" + StrUtil.UrlEncode(userName) + "&showyear="+showyear+"&showmonth="+i+"'>"+i+"月</a>&nbsp;");
  111. }
  112. %> </td>
  113.         </tr>
  114.       </table>
  115. <%
  116. String sql = "select id from work_log where MONTH(myDate)="+showmonth+" and YEAR(myDate)="+showyear+" and userName="+StrUtil.sqlstr(userName)+" order by myDate asc";
  117. int i = 1;
  118. String content="",mydate="",strweekday="";
  119. int id = -1;
  120. int weekday=0;
  121. Date dt = null;
  122. int monthday = -1;
  123. int monthdaycount = getDays(showmonth-1,showyear);//当前显示月份的天数
  124. String[] wday = {"","日","一","二","三","四","五","六"};
  125. boolean rsnotend = true;
  126. boolean coloralt = true;//背景颜色交替
  127. String backcolor = "#ffffff";
  128. Calendar cld = Calendar.getInstance();
  129. WorkLogDb wld = new WorkLogDb();
  130. Iterator ir = wld.list(sql).iterator();
  131. %>
  132.       <br>
  133.       <table width="98%" border="0" align="center" cellpadding="2" cellspacing="0" class="stable">
  134.         <tr align="center" bgcolor="#C4DAFF"> 
  135.           <td width="8%" class="stable"> <div align="center">星期</div></td>
  136.           <td width="13%" class="stable">日期</td>
  137.           <td class="stable">内 容</td>
  138.           <td width="29%" class="stable">记录时间</td>
  139.         </tr>
  140.       </table>
  141.       <%
  142. if (ir.hasNext()) {
  143. wld = (WorkLogDb)ir.next();
  144. mydate = DateUtil.format(wld.getMyDate(), "yyyy-MM-dd HH:mm:ss");
  145. cld.setTime(wld.getMyDate());
  146. monthday = cld.get(cld.DAY_OF_MONTH);
  147. }
  148. while (i<=monthdaycount) {
  149. if (monthday==i) {
  150. coloralt = !coloralt;
  151. if (coloralt)
  152. backcolor = "#eeeeee";
  153. else
  154. backcolor = "#ECFFDF";
  155. String oldbackcolor = backcolor;
  156. backcolor = oldbackcolor;
  157. if (wld.isLoaded()) {
  158. id = wld.getId();
  159. content = wld.getContent();
  160. mydate = DateUtil.format(wld.getMyDate(), "yyyy-MM-dd HH:mm:ss");
  161. cld.setTime(wld.getMyDate());
  162. weekday = cld.get(cld.DAY_OF_WEEK);
  163. strweekday = wday[weekday];
  164. }
  165. %>
  166. <table width="98%" border="0" align="center" cellpadding="2" cellspacing="0" class="stable">
  167.         <tr align="center" bgcolor="<%=backcolor%>"> 
  168.           <td width="8%" bgcolor="<%=backcolor%>" class="stable"><%=strweekday%> </td>
  169.           <td width="13%" bgcolor="<%=backcolor%>" class="stable"><%=i%></td>
  170.           <td align="left" bgcolor="<%=backcolor%>" class="stable"><a title="查看" href="../mywork_show.jsp?id=<%=id%>&userName=<%=StrUtil.UrlEncode(userName)%>"><%=StrUtil.toHtml(content)%></a></td>
  171.           <td width="29%" bgcolor="<%=backcolor%>" class="stable">
  172.   <%if (curyear==showyear && curmonth+1==showmonth && curday==i) { %>
  173.   <a title="修改" href="../mywork_edit.jsp?id=<%=id%>&userName=<%=StrUtil.UrlEncode(userName)%>"><%=mydate%></a>
  174.   <%} else {%>
  175.   <%=mydate%>
  176.   <% } %>
  177.   </td>
  178.         </tr>
  179.         </table>
  180. <%
  181. if (ir.hasNext()) {
  182. wld = (WorkLogDb)ir.next();
  183. cld.setTime(wld.getMyDate());
  184. monthday = cld.get(cld.DAY_OF_MONTH);
  185. }
  186. else
  187. break;
  188. }
  189. else {
  190. cld.set(showyear,showmonth-1,i);
  191. weekday = cld.get(cld.DAY_OF_WEEK);
  192. strweekday = wday[weekday];
  193. if (weekday==1 || weekday==7) {
  194. strweekday = "<font color=red>"+strweekday+"</font>";
  195. }
  196. %>
  197.   <table width="98%" border="0" align="center" cellpadding="2" cellspacing="0" class="stable">
  198.         <tr align="center"> 
  199.           <td width="8%" class="stable"><%=strweekday%></td>
  200.           <td width="13%" class="stable"><%=i%></td>
  201.           <td class="stable">&nbsp;</td>
  202.           <td width="29%" class="stable">&nbsp;</td>
  203.         </tr>
  204.       </table>
  205. <%
  206. }
  207. i++;
  208. }
  209. %>
  210. <br></td>
  211.   </tr>
  212.   <tr>
  213.     <td height="9">&nbsp;</td>
  214.   </tr>
  215. </table>
  216. </body>
  217. </html>