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

Jsp/Servlet

开发平台:

Java

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