EMV_BIRTHDAY.jsp 7.9 KB
Newer Older
Thitichaipun Wutthisak committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*"%>
<%@ page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*"  %>
<%@ page import="java.util.*"%>
<%@ include file="../CHECKPROFILE.jsp" %>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="EMV_BD" class="com.csc.library.system.Task" scope="page" />
<jsp:setProperty name="EMV_BD" property="appname" value="empview" />
<%
	String langs="en";
	EMV_BD.setChannel(request, response);
	response.setDateHeader("Expires", -1);
	response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	response.addHeader("Cache-Control", "post-check=0, pre-check=0");
	response.setHeader("Pragma", "no-cache");

	HelpEntry screen_bd = (HelpEntry)EMV_BD.process("HelpEntry", "EMP_NEWEMP");

	if (screen_bd==null){
		return;
	}

	CscCalendar cal = new CscCalendar();
	CscCalendar ca = null;

	String now_month=cal.getMM();
	String now_date=cal.getDD();

	String filter_ = "status not in ('D','W','R','U','X','Y','Z') AND (SUBSTRING(BIRTHDAY,6,2) = '"+now_month +"') and employeeid in(select employeeid from hadjposition where adj_type='10')";
	screen_bd.getInquiry().setFilter(filter_);
	//screen_bd.getInquiry().setFilter("employeeid <= 150202");
	screen_bd.getInquiry().setOrderBy("SUBSTRING(BIRTHDAY,9,2), EMPLOYEEID");
	screen_bd.getInquiry().refresh();
	langs=screen_bd.getUProfile().get("lang");
	CheckNull chk = new CheckNull();
%>
<!DOCTYPE HTML>
<html ng-app="myHR">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	</head>
	<body>
		<jsp:include page="EMV_HEADMENU.jsp" flush="true" />

		<script type="text/javascript">

			$(document).ready(function(){
				setLang("<%=screen_bd.getUProfile().get("lang")%>");
				var swap = new swaplang();
				var titlename = swap.swap2String("SW004901");
				setPageTitle(titlename);

				var nows_month = new Date();
				//var month = new Array();
				var strhead="",strtoday="",strlist="";
				var mylang="<%=screen_bd.getUProfile().get("lang")%>";

				setCalendarLang(mylang);
				if (mylang=="eng"){
					strhead="Birthday in "+getMonthFullName(nows_month.getMonth()+1);
					strtoday="Birthday today";
					strlist="List of Birthday";
				}else if (mylang=="tha"){
					strhead="วันคล้ายวันเกิดประจำเดือน "+getMonthFullName(nows_month.getMonth()+1);
					strtoday="ผู้ที่มีวันคล้ายวันเกิดวันนี้";
					strlist="รายชื่อวันคล้ายวันเกิดเดือนนี้";
				}

				$("#cur-month").html(strhead);
				$("#strtodate").html(strtoday);
				$("#strlist").html(strlist);

				nows_month=nows_month.getMonth();

				$('[data-countdown]').each(function() {
					var finalDate=$(this).data('countdown');
					var now = new Date();


					if ($("#lang").val()=="tha"){
						str="วัน";
					}
					else{
						str="days";
					}

					now=now.getDate();

					finalDate=parseInt(finalDate);
					now=parseInt(now);

					finalDate=finalDate-now;
					var finalMonth=$(this).data('month');

					if ((finalDate==0) && ((nows_month+1)==finalMonth)){
						if (mylang=="eng"){
							str="Happy birthday";
						}else if(mylang=="tha"){
							str="สุขสันต์วันเกิด";
						}

					}
					else if ((finalDate<0) || ((nows_month+1)!=finalMonth)){
						$(this).parent().parent().parent().removeClass("services-wrap");
						$(this).parent().parent().parent().addClass("services-wrap-disabled");
						str="";
					}
					else{
						if (mylang=="eng"){
							str="Countdown : "+finalDate+" "+str;
						}else if (mylang=="tha"){
							str="นับถอยหลัง  : "+finalDate+" "+str;
						}
					}


					$(this).html(str);
				});
			});

			function setSrcimagefile(srcid,urlimg){
				document.getElementById(srcid).src=urlimg;
			}


		</script>

		<section id="Birthday" class="service-with-media">
			<div class="container">
				<div class="center fadeInDown">
					<h2 id="cur-month"></h2>
				</div>
				<div class="row" id="today">
					<h3 id="strtodate">Birthday today</h3>
				</div>
				<div class="row">
					<h3 id="strlist">List of Birthday</h3>
				<%
					int k=0;
					if(screen_bd.getInquiry().recCount()>0) {
						String pathfile = "../UPLOAD/PERSONAL/PICTURE/";
						String bd_countdown,bd,bmonth;

						screen_bd.referLangOn();
						while(screen_bd.nextRec()){
							k++;
							ca = new CscCalendar(screen_bd.getString("birthday"));

							if (langs.equals("tha")){
								bd=ca.getThaiLongMonth();
							}
							else{
								bd=ca.getEngLongMonth();
							}


							bd_countdown=ca.getDD();
							bmonth=ca.getMM();
							bd=bd_countdown+" "+bd;


							if ((bd_countdown.equals(now_date)) && (bmonth.equals(now_month))){
				%>
							<script type="text/javascript">
								var genbox="<%=generateBox(screen_bd,bd,bd_countdown,bmonth)%>";
								$("#today").append(genbox);

								setTimeout(function(){
									setSrcimagefile('empbd<%=screen_bd.getString("employeeid")%>','<%=screen_bd.getInquiry().getCurrentDbRecord().getViewUrl("picture")%>');
								},<%=k*250%>)
							</script>

				<%			}
							else{
				%>

							<div class="col-md-4">
								<div class="media services-wrap wow fadeInDown">
									<div class="img-resize">
										<div class="pull-left">
											<img class="img-responsive" id="empbd<%=screen_bd.getString("employeeid")%>">
										</div>
									</div>
									<div class="media-body">
										<h3 class="media-heading"><%=screen_bd.getString("fullname_nopre") %></h3>
										<p class="detail"><%=screen_bd.getLabel("positionname") %> : <%=screen_bd.getString("positionname") %></p>
										<p class="detail"><span swlang code='SW002031'>Department</span> : <%=screen_bd.getString("mbu2", "edesc") %></p>
										<p class="detail"><span swlang code='SW012299'>Date of birth</span> : <%=bd %> </p>
										<p class="detail"><span data-countdown=<%=bd_countdown %> data-month="<%=bmonth%>"></span></p>
									</div>
								</div>
							</div>
							<script type="text/javascript">
								setTimeout(function(){
									setSrcimagefile('empbd<%=screen_bd.getString("employeeid")%>','<%=screen_bd.getInquiry().getCurrentDbRecord().getViewUrl("picture")%>');
								},<%=k*250%>)
							</script>

				<%
							}
						}
					}
				%>
				</div>
			</div>

			<a href="#top" id="top-button">
				<i class="fa fa-angle-up"></i>
				<div class="top-word">Back to top</div>
			</a>
		</section>

		<jsp:include page="FOOTER.jsp" flush="true" />
		<input type="hidden" name="__language" id="lang" value ="<%=langs%>">
	</body>
</html>

<%!
	public String generateBox(HelpEntry screen_bd,String bd,String bd_countdown,String bmonth){
		StringBuilder gen_code = new StringBuilder();

		gen_code.append("<div class='col-md-4'>");
		gen_code.append("<div class='media services-wrap wow fadeInDown'>");
		gen_code.append("<div class='img-resize'>");
		gen_code.append("<div class='pull-left'>");
		gen_code.append("<img class='img-responsive'").append(" id='empbd").append(screen_bd.getString("employeeid")).append("'>");
		gen_code.append("</div></div>");
		gen_code.append("<div class='media-body'>");
		gen_code.append("<h3 class='media-heading'>").append(screen_bd.getString("fullname_nopre")).append("</h3>");
		gen_code.append("<p class='detail'>"+screen_bd.getLabel("positionname")+" : ").append(screen_bd.getString("positionname")).append("</p>");
		gen_code.append("<p class='detail'><span swlang code='SW002031'>Department</span> :").append(screen_bd.getString("mbu2", "edesc")).append("</p>");
		gen_code.append("<p class='detail'><span swlang code='SW012299'>Date of birth</span> : ").append(bd).append("</p>");
		gen_code.append("<p class='detail'><span data-countdown=").append(bd_countdown).append(" data-month=").append(bmonth).append("></span></p>");

		return gen_code.toString();
	}
%>