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

Jsp/Servlet

开发平台:

Java

  1. <%@ page contentType="text/html;charset=gb2312"%>
  2. <%@ page import = "java.net.URLEncoder"%>
  3. <%@ page import = "java.util.Calendar"%>
  4. <%@ page import = "java.util.Date"%>
  5. <%@ page import = "com.redmoon.oa.db.Conn"%>
  6. <%@ page import = "com.redmoon.oa.db.PageQuery"%>
  7. <%@ include file="../inc/inc.jsp"%>
  8. <%@ page import="java.text.*"%>
  9. <jsp:useBean id="fchar" scope="page" class="cn.js.fan.util.StrUtil"/>
  10. <jsp:useBean id="privilege" scope="page" class="com.redmoon.oa.pvg.Privilege"/>
  11. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  12. <html>
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  15. <title>请假申请</title>
  16. <link href="../common.css" rel="stylesheet" type="text/css">
  17. <%@ include file="../inc/nocache.jsp"%>
  18. <script language="JavaScript" type="text/JavaScript">
  19. <!--
  20. function MM_preloadImages() { //v3.0
  21.   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
  22.     var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
  23.     if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
  24. }
  25. //-->
  26. </script>
  27. <script language=javascript>
  28. <!--
  29. function openWin(url,width,height)
  30. {
  31. 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);
  32. }
  33. //-->
  34. </script>
  35. </head>
  36. <body background="" leftmargin="0" topmargin="3" marginwidth="0" marginheight="0">
  37. <jsp:useBean id="calsheet" scope="page" class="com.redmoon.oa.CalendarSheet"/>
  38. <%
  39. String showtype = fchar.getNullStr(request.getParameter("showtype"));
  40. String stype = "";
  41. if (!showtype.equals(""))
  42. {
  43. if (showtype.equals("evection"))
  44. stype = "出差 ";
  45. else
  46. stype = "其他原因 "; 
  47. }
  48. int showmonth = 1, showyear = 2003;
  49. Calendar cal = Calendar.getInstance();
  50. int curday = cal.get(cal.DAY_OF_MONTH);
  51. int curmonth = cal.get(cal.MONTH);
  52. int curyear = cal.get(cal.YEAR);
  53. String strshowyear = request.getParameter("showyear");
  54. String strshowmonth = request.getParameter("showmonth");
  55. if (strshowyear!=null)
  56. showyear = Integer.parseInt(strshowyear);
  57. else
  58. showyear = curyear;
  59. if (strshowmonth!=null)
  60. {
  61. showmonth = Integer.parseInt(strshowmonth);
  62. }
  63. else
  64. showmonth = curmonth+1;
  65. if (showmonth==-1)
  66. strshowmonth = "全年";
  67. else
  68. strshowmonth = showmonth+"月";
  69. String myname = fchar.UnicodeToGB(request.getParameter("name"));
  70. if (myname==null) {
  71. out.print(fchar.makeErrMsg("缺少用户名!"));
  72. return;
  73. }
  74. %>
  75. <table width="494" border="0" align="center" cellpadding="0" cellspacing="0">
  76.   <tr>
  77.     <td height="23" valign="bottom" background="../images/tab-b2-top.gif">     <span class="right-title"><%=myname%> <%=strshowmonth%><%=stype%>&nbsp;请 
  78.       假 申 请&nbsp;</span></td>
  79.   </tr>
  80.   <tr>
  81.     <td valign="top" background="../images/tab-b-back.gif">
  82. <%
  83. String priv="admin";
  84. if (!privilege.isUserPrivValid(request,priv))
  85. {
  86. out.println(cn.js.fan.web.SkinUtil.makeErrMsg(request, cn.js.fan.web.SkinUtil.LoadString(request, "pvg_invalid")));
  87. return;
  88. }
  89. %> <table width="90%" border="0" align="center">
  90.         <tr>
  91.           <td align="center">
  92.   
  93.   <% if (showmonth==-1)
  94.    out.print("<font color=red>全年</font>");
  95.  else { %>
  96.   <a href="leave_m.jsp?name=<%=URLEncoder.encode(myname,"GBK")%>&showtype=<%=showtype%>&showmonth=-1">全年</a>
  97.   <% } %>
  98. <%
  99. for (int i=1; i<=12; i++) {
  100. if (showmonth==i)
  101. out.print("<a href='leave_m.jsp?name="+URLEncoder.encode(myname,"GBK")+"&showtype="+showtype+"&showmonth="+i+"'><font color=red>"+i+"月</font></a>&nbsp;");
  102. else
  103. out.print("<a href='leave_m.jsp?name="+URLEncoder.encode(myname,"GBK")+"&showtype="+showtype+"&showmonth="+i+"'>"+i+"月</a>&nbsp;");
  104. }
  105. %>    
  106.   </td>
  107.         </tr>
  108.         <tr> 
  109.           <td align="center"><a href="leave_m.jsp?name=<%=URLEncoder.encode(myname,"GBK")%>&showmonth=<%=showmonth%>">全部类型</a> 
  110.             <a href="leave_m.jsp?name=<%=URLEncoder.encode(myname,"GBK")%>&showmonth=<%=showmonth%>&showtype=evection">出差</a> 
  111.             <a href="leave_m.jsp?name=<%=URLEncoder.encode(myname,"GBK")%>&showmonth=<%=showmonth%>&showtype=other">其他</a>
  112. </td>
  113.         </tr>
  114.       </table>
  115.       <%
  116.    PageQuery pagebean = new PageQuery("ttoa");
  117. String sql;
  118. if (!showtype.equals(""))
  119. {
  120. if (showmonth==-1) //当年所有的showtype类型记录
  121. sql = "select * from leave where DATEDIFF(year,mydate,getDate())=0 and name="+fchar.sqlstr(myname)+" and type="+fchar.sqlstr(showtype);
  122. else //当年showmonth的记录
  123. sql = "select * from leave where DATEDIFF(year,mydate,getDate())=0 and DATEPART(month,mydate)="+showmonth+" and name="+fchar.sqlstr(myname)+" and type="+fchar.sqlstr(showtype);
  124. }
  125. else //显示所有的请假事项
  126. {
  127. if (showmonth == -1) //当年所有类型记录
  128. sql = "select * from leave where DATEDIFF(year,mydate,getDate())=0 and name="+fchar.sqlstr(myname);
  129. else //当年showmonth的记录
  130. sql = "select * from leave where DATEDIFF(year,mydate,getDate())=0 and DATEPART(month,mydate)="+showmonth+" and name="+fchar.sqlstr(myname);
  131. }
  132. int pagesize = 40; //设为40以使不分页显示,便于统计
  133. pagebean.setPageSize(pagesize);
  134. String Query = fchar.getNullString(request.getParameter("Query"));
  135. if (!Query.equals(""))
  136. sql = Query;
  137. ResultSet rs=pagebean.myQuery(sql,request) ; 
  138. pagebean.PageLegend(response);
  139. int curpage,totalpages;
  140. curpage = pagebean.getCurrentPages();
  141. totalpages = pagebean.getTotalPages();
  142. if (totalpages==0)
  143. {
  144. curpage = 1;
  145. totalpages = 1;
  146. }
  147. int i = 0;
  148. String id="",checkman="",mydate="",xjdate="",reason="",begindate="",days="",type="";
  149. //用于计算请假次数,销假次数,按时销假次数,超时销假天数,总请假天数,总实际请假天数,总超假天数
  150. int qjcount=0,xjcount=0,asxjcount=0;
  151. float csxjdays=0,allqjdays=0,allrealqjdays=0,allcjdays=0;
  152. float fdays = 0;//本次请假的天数
  153. Date dqjdate,dxjdate;
  154. boolean isxj = false;
  155. try
  156. {
  157.   if (rs!=null )
  158.   {
  159.     if (pagebean.getTotalPages()>0)
  160. {
  161. %>
  162.       <br> <table width="95%" border="0" align="center" cellpadding="0" cellspacing="0">
  163.         <tr> 
  164.           <td width="47"><img src="../images/title1-l.gif" width="47" height="25"></td>
  165.           <td valign="top" background="../images/title1-back.gif"><div align="center" class="title1">共有请假记录 
  166.               <b><%=pagebean.getTotal() %></b> 条 <!--每页显示 <b><%=pagebean.getPageSize() %></b> 
  167.               条 页次 <b><%=curpage %>/<%=totalpages %></b>--></div></td>
  168.           <td width="47"><img src="../images/title1-r.gif" width="47" height="25"></td>
  169.         </tr>
  170.       </table>
  171.       <%
  172. do
  173. {
  174. i++;
  175. id = rs.getString("id");
  176. checkman = rs.getString("checkman");
  177. mydate = rs.getString("mydate").substring(0,10);
  178. begindate = rs.getString("begindate").substring(0,10);
  179. dqjdate = rs.getDate("begindate");
  180. days = rs.getString("days");
  181. fdays = rs.getFloat("days");
  182. allqjdays += fdays;
  183. reason = rs.getString("reason");
  184. isxj = rs.getBoolean("isxj"); //是不否已销假
  185. type = rs.getString("type");
  186. xjdate = fchar.getNullStr(rs.getString("xjdate"));
  187. if (!xjdate.equals(""))
  188. xjdate = xjdate.substring(0,19);
  189. qjcount++;
  190. if (isxj)
  191. {
  192. xjcount++;
  193. SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  194. dxjdate = format.parse(xjdate);
  195. long timeqj = dqjdate.getTime(); //假期开始时间
  196. long timeyxj = timeqj+(int)(fdays*24*60*60*1000);//应销假的时间
  197. long timexj = dxjdate.getTime(); //实际销假的时间
  198. //计算是否超出天数,如果超出半天时间,则认为是超假
  199. int m = (int)(timexj-timeyxj)/1000/60;//销假时的假期总分钟数
  200. int d = (int)(timexj-timeqj)/1000/60/60/24;//实际请假的天数
  201. if (m<12*60) //如果销假时间不超出半天,则认为是按时销假
  202. asxjcount++; //按时销假次数
  203. else {
  204. csxjdays += m/60/24;//超时销假天数
  205. allcjdays += csxjdays;//总超假天数
  206. }
  207. allrealqjdays += d;//实际总请假天数
  208. }
  209. %>
  210.       <table width="100%" border="0" height="5">
  211.         <tr> 
  212.           <td></td>
  213.         </tr>
  214.       </table>
  215.       <table width="416" border="0" align="center" cellpadding="2" cellspacing="0" class="stable">
  216.         <tr bgcolor="#C4DAFF" class="stable"> 
  217.           <td class="stable" width="18%">准 假 人:</td>
  218.           <td width="19%" class="stable" ><%=checkman%> </td>
  219.           <td width="17%" class="stable" >申请日期:</td>
  220.           <td width="46%" class="stable" ><%=mydate%></td>
  221.         </tr>
  222.         <tr bgcolor="#FFFFFF" class="stable">
  223.           <td class="stable" bgcolor="#EEEEEE">状&nbsp;&nbsp;&nbsp; 态:</td>
  224.           <td colspan="3" class="stable">
  225.   <%
  226.   if (isxj)
  227.   {
  228.    out.print("已销假   销假时间 "+xjdate);
  229.   }
  230.   else
  231.   {
  232.    out.print("未销假&nbsp;&nbsp;&nbsp;");
  233. out.print("<a href='leave_xj.jsp?id="+id+"'>现在销假</a>");
  234.   }
  235.   %>
  236.   </td>
  237.         </tr>
  238.         <tr bgcolor="#FFFFFF" class="stable"> 
  239.           <td class="stable" bgcolor="#EEEEEE">开始时间:</td>
  240.           <td colspan="3" class="stable"><%=begindate%></td>
  241.         </tr>
  242.         <tr bgcolor="#FFFFFF" class="stable"> 
  243.           <td class="stable" valign="top" bgcolor="#EEEEEE">天&nbsp;&nbsp;&nbsp;&nbsp;数:</td>
  244.           <td colspan="3" class="stable"><%=days%></td>
  245.         </tr>
  246.         <tr bgcolor="#FFFFFF" class="stable"> 
  247.           <td class="stable" valign="top" bgcolor="#EEEEEE">类 &nbsp;&nbsp;&nbsp;型:</td>
  248.           <td colspan="3" class="stable"> <%
  249.   if (type.equals("evection"))
  250.    type = "出差";
  251.   else
  252.    type = "其他";
  253.   %><%=type%></td>
  254.         </tr>
  255.         <tr bgcolor="#FFFFFF" class="stable"> 
  256.           <td class="stable" valign="top" bgcolor="#EEEEEE">事&nbsp;&nbsp; &nbsp;由:</td>
  257.           <td colspan="3" class="stable"><%=reason%> </td>
  258.         </tr>
  259.       </table>
  260.       <table width="100%" border="0" height="5">
  261.         <tr> 
  262.           <td></td>
  263.         </tr>
  264.       </table>
  265.       <%
  266. }
  267. while(i<pagesize && rs.next());
  268. }
  269. else
  270. out.println(fchar.p_center("暂无请假记录!"));
  271.   }
  272.   else
  273. out.println(fchar.p_center("暂无请假记录!"));
  274.   
  275. }
  276. catch(SQLException e)
  277. {
  278.   out.print("出错: ");
  279.   out.print(e);
  280.   out.print(e.getMessage());
  281. }
  282. if (rs!=null)
  283. {
  284. rs.close();
  285. rs = null;
  286. }
  287. pagebean.clear();
  288. %>
  289.       <table width="100%" border="0" cellspacing="1" cellpadding="3" align="center" class="9black">
  290.         <tr> 
  291.           <td height="23"> <div align="right"> 
  292.               <%
  293.   String querystr = "&showmonth="+showmonth+"&showtype="+showtype;
  294.   %>
  295.               <%if(!pagebean.getFirstPage().equals("none")) {%>
  296.               <a href="leave_m.jsp?<%=pagebean.getFirstPage()+querystr%>"><img src="images/first.gif" width="41" height="12" border="0"></a> 
  297.               <% }
  298.     if(!pagebean.getPrevPage().equals("none")){
  299.      %>
  300.               &nbsp;<a href="leave_m.jsp?<%=pagebean.getPrevPage()+querystr%>"><img src="images/forward.gif" width="47" height="12" border="0"></a> 
  301.               <% } 
  302.     
  303.   if(!pagebean.getNextPage().equals("none")){%>
  304.               &nbsp;<a href="leave_m.jsp?<%=pagebean.getNextPage()+querystr%>"><img src="images/next.gif" width="47" height="12" border="0"></a> 
  305.               <% }
  306.                   if(!pagebean.getLastPage().equals("none")){   %>
  307.               &nbsp;<a href="leave_m.jsp?<%=pagebean.getLastPage()+querystr%>"><img src="images/last.gif" width="41" height="12" border="0"></a> 
  308.               <% }%>
  309.               &nbsp;</div></td>
  310.         </tr>
  311.       </table>
  312.       <table width="98%" border="0" align="center">
  313.         <tr>
  314.           <td align="center"> 
  315.   <%
  316.     if (showmonth==-1)
  317.    out.print("全年:");
  318.  else
  319.   out.print(showmonth+"月:");
  320.   %>
  321.   &nbsp;请假次数<%=qjcount%>,销假次数<%=xjcount%>,按时销假次数<%=asxjcount%>, 超时销假天数<%=csxjdays%><br>
  322.             总请假天数<%=allqjdays%>,总实际请假天数<%=allrealqjdays%>,总超假天数<%=allcjdays%>
  323.   </td>
  324.         </tr>
  325.       </table>
  326.     </td>
  327.   </tr>
  328.   <tr>
  329.     <td height="9"><img src="../images/tab-b-bot.gif" width="494" height="9"></td>
  330.   </tr>
  331. </table>
  332. </body>
  333. </html>