PI_WORKINGTIME_CUS.jsp 33.6 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 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
<%@page contentType="text/html; charset=UTF-8" language="java" %>
<%@page import="com.csc.library.entry.HelpEntry,com.csc.library.system.*,com.csc.library.utilities.*,java.util.*"%>
<%@page import="com.csc.library.utilities.CscCalendar,com.csc.library.entry.HelpEntry,com.csc.library.system.*"%>
<%@page import="com.csc.library.entry.*,com.csc.library.database.*,com.csc.library.session.*,com.csc.library.formula.FormulaString"  %>
<%@page import="java.text.DecimalFormat"  %>
<% request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="EMV" class="com.csc.library.system.Task" scope="page" />
<jsp:setProperty name="EMV" property="appname" value="empview" />
<%
	EMV.setChannel(request, response);	
		
	CscCalendar cs = new CscCalendar();
	CscCalendar cs1 = new CscCalendar("01-"+cs.getMM()+"-"+cs.getYear());
	CscCalendar cs2 = new CscCalendar(cs.getEndDateOfMonth()+"-"+cs.getMM()+"-"+cs.getYear());
	if (request.getParameter("date_start")!=null && request.getParameter("date_end")!=null) {
		cs1 = new CscCalendar(request.getParameter("date_start"));
		cs2 = new CscCalendar(request.getParameter("date_end"));		
	}
	CheckNull chk = new CheckNull();
	String displayLate = chk.chkNullString((String) request.getParameter("display_late"));
	String displayAbsent = chk.chkNullString((String) request.getParameter("display_absent"));
	String displayLeave = chk.chkNullString((String) request.getParameter("display_leave"));
	String displayOT = chk.chkNullString((String) request.getParameter("display_ot"));
	String emp = chk.chkNullString((String) request.getParameter("display_ot"), EMV.getUProfile().getEmvEmpId());
	
	HelpEntry screen = (HelpEntry) EMV.process("HelpEntry", "PI_WORKINGTIMEHELP"); 	
	String filter = "employeeid = '"+emp+"' "+
		"and (dateid between '"+cs1.getYYYYMMDD()+"' and '"+cs2.getYYYYMMDD()+"')";
	String filter_display = "";
	if (displayLate.equals("on")) {
		filter_display = " (lt>0) ";
	}
	if (displayAbsent.equals("on")) {
		if (!filter_display.equals("")) {
			filter_display += " or (eventgrp='J') ";
		} else filter_display = " (eventgrp='J') ";
	}
	if (displayLeave.equals("on")) {
		if (!filter_display.equals("")) {
			filter_display += " or (m_lv>0 and (tr_type like 'A%')) ";
		} else filter_display = " (m_lv>0 and (tr_type like 'A%')) ";
	}
	if (displayOT.equals("on")) {
		if (!filter_display.equals("")) {
			filter_display += " or (ac_ot>0) ";
		} else filter_display = " (ac_ot>0) ";
	} 
	if (!filter_display.equals("")) {
		filter += " and ("+filter_display+")";
	}
	screen.inq.setFilter(filter);
	screen.inq.refresh();	
	//screen.nextRec();
	
	FormulaString fs = new FormulaString();
	DecimalFormat df = new DecimalFormat("0.00");
	DecimalFormat df2 = new DecimalFormat("00.00");

	//out.print(EMV.getUProfile());
	
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="../Templates/template-emv-main.dwt.jsp" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Employee View</title>
<!-- InstanceEndEditable -->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<!-- InstanceBeginEditable name="head" -->
<!-- Begin CSS Links -->
<link rel="stylesheet" type="text/css" href="../CSS/DDMENU.css" />
<link rel="stylesheet" type="text/css" href="../CSS/EMV_LAYOUT.css" />
<link rel="stylesheet" type="text/css" href="../CSS/EMV_DEFAULT.css" />
<link rel="stylesheet" type="text/css" href="../CSS/EMV_LAYOUT_TWO.css" />
<link rel="stylesheet" type="text/css" href="../CSS/EMV_TEXT.css" />
<link rel="stylesheet" type="text/css" href="CSS/empview_style.css" />
<!-- End CSS Links -->
<!-- Begin Scripts -->
<!-- Begin script for Dropdown Menu -->
<!-- DO NOT EDIT -->
<script language="JavaScript" type="text/javascript" src="../JS/EVENTS.js"></script>
<script language="JavaScript" type="text/javascript" src="../JS/DDMENU.js"></script>
<!--[if lt IE 7]><script language="JavaScript" type="text/javascript" src="../JS/IEHOVER-FIX.js"></script><![endif]-->
<!-- DO NOT EDIT -->
<!-- End script for Dropdown Menu -->
<script language="JavaScript" type="text/javascript" src="../JS/UTILITIES.js"></script>
<script language="JavaScript" type="text/javascript" src="../JS/ACTIVE_OBJECT.js"></script>
<script language="JavaScript" type="text/javascript" src="../JS/SCREEN.js"></script>
<script language="JavaScript" type="text/javascript" src="../JS/DATEINPUT.js"></script>
<script language="JavaScript" type="text/javascript" src="../JS/VIEWCALENDAR.js"></script>
<script language="JavaScript">setLang('<%=screen.getUProfile().get("lang")%>');</script>

<!-- dwr -->
<script type='text/javascript' src='/hr/dwr/engine.js'></script>
<script type='text/javascript' src='/hr/dwr/util.js'></script>
<script type="text/javascript" src="/hr/dwr/interface/ReCalTtimecurrent1.js"></script>

<!-- jquery -->
<script type="text/javascript" src="../JS/jquery-1.7.2.min.js"></script>

<script type="text/javascript">
<!--
	function goHelp(helpName,inputName) {
		var helpReturn;
		var fixCon = "";
		if(inputName=="__employeeid" ) {
			fixCon = "status not in ('X','Y','Z')";
			helpReturn="__employeeid:employeeid,MEMPLOYEE@FULLNAME,__emptime0:time0";	
		}
				
		linkHelp_Return(helpName,helpReturn, fixCon);	
	}
//-->
</script>
<!-- End Scripts -->
<!-- Begin Head -->
<script>
<!--
	$(function() {
		/* select swipe in-out */
		$('.btn').click(function(){
			var trname = $(this).attr('id') ;

			$('#tm_source').val(trname);	/* set target name */
			$('.time_popup').attr('style','display:block');	/* show time popup */

		}) ;

		$('.btn_out').click(function(){
			var trname = $(this).attr('id') ;

			$('#tm_source').val(trname);	/* set target name */
			$('.time_popup').attr('style','display:block');	/* show time popup */

		}) ;

		$('#time_pop_close').click(function(){
			$('.time_popup').attr('style','display:none');
		});

		$('.td-doc-var').click(function(){
			var tm_ = $(this).find("td:eq(1) div").html() ;
			var tr_ = $('#tm_source').val();

			var starget = $('#' + tr_);
			starget.html(tm_);	/* set time value to target */
			starget.attr('style','color: #ffffff;text-decoration: none;');

			/* show update icon */
			var row_ = starget.closest('tr');
			row_.attr('timeupdated','true');
			$('#upd_' + row_.attr('runno')).attr('style','display:block');

			/* set updated flag */
			if(starget.attr('id').substring(0,1) == 'i'){
				row_.attr('timeinupdated','true');
			}else{
				row_.attr('timeoutupdated','true');
			}

			/* close popup */
			$('.time_popup').attr('style','display:none'); 


		});

		/* select shift */
		$('.btn_shift').click(function(){
			var trname = $(this).attr('id') ;

			$('#sh_source').val(trname);	/* set target name */
			$('.shift_popup').attr('style','display:block');	/* show shift popup */
		});

		$('#shift_pop_close').click(function(){
			$('.shift_popup').attr('style','display:none');
		});

		$('.td-shift-var').click(function(){
			var sh_desc = $(this).attr('tdesc') ;
			var sh_id = $(this).attr('time0id') ;
			var sh_in1 = $(this).attr('timein1') ;
			var sh_out1 = $(this).attr('timeout1') ;
			var sh_in2 = $(this).attr('timein2') ;
			var sh_out2 = $(this).attr('timeout2') ;

			var tr_ = $('#sh_source').val();
			var target_obj = $('#' + tr_);

			target_obj.html("<font color='#FFFFFF'>" + sh_in1 + "&nbsp;-&nbsp;" + sh_out2 + "</font>");	/* set time value to target */
			target_obj.attr('time0id', sh_id);
			target_obj.attr('sh_tin', sh_in1);
			target_obj.attr('sh_tout', sh_out1);
			target_obj.attr('sh_tin1', sh_in2);
			target_obj.attr('sh_tout1', sh_out2);

			/* show update icon */
			var row_ = target_obj.closest('tr');
			row_.attr('shiftupdated','true');
			$('#upd_' + row_.attr('runno')).attr('style','display:block');

			/* close popup */
			$('.shift_popup').attr('style','display:none'); 
		});

		$('.updateline').click(function(){
			var emp = $('#__employeeid').val();	/* employeeid */
			var trid = $(this).closest('tr');	/* time_current1 row */
			var dateid = trid.attr('dateid');	/* dateid */
			var runno = trid.attr('runno');		/* runno ttime_current1 */
			var sfupdate = trid.attr('shiftupdated');
			var tmupdate = trid.attr('timeupdated');
			var oldtime0 = trid.attr('oldtime0');
			var inupdate = trid.attr('timeinupdated');
			var outupdate = trid.attr('timeoutupdated');

			var search_st = $('#date_start').val();
			var search_en = $('#date_end').val();
			var emptime0 = $('#__emptime0').val();


			var shprop = trid.find('#shifprop_' + runno); /* shift prop object */
			var time0id = shprop.attr('time0id');
			var tmin1 = shprop.attr('sh_tin');
			var tmout1 = shprop.attr('sh_tout');
			var tmin2 = shprop.attr('sh_tin1');
			var tmout2 = shprop.attr('sh_tout1');

			var timeinprop = trid.find('#in_' + runno) ; /* swipe in */
			var d_in = timeinprop.attr('datein');
			var m_in = timeinprop.html();

			var timeoutprop = trid.find('#out_' + runno) ; /* swipe out */
			var d_out = timeoutprop.attr('datein');
			var m_out = timeoutprop.html();

			var shfee = trid.find('#shiftfee_' + runno) ; /* night shift fee*/
			var shfee = shfee.html();

			var trsfee = trid.find('#transfee_' + runno) ; /* transport fee*/
			var trsfee = trsfee.html();
			
			ReCalTtimecurrent1.calculate(emp
										, new Array(time0id, tmin1, tmout1, tmin2, tmout2, oldtime0)
										, new Array(dateid, time0id, d_in, m_in, d_out, m_out, runno)
										, new Array(shfee, trsfee)
										, new Array(search_st, search_en, emptime0, sfupdate, tmupdate, inupdate, outupdate)
										, resultdwr);
		});

		var resultdwr = function(data){
			window.document.cscform.submit();
		}

			
	});
-->
</script>
<!-- End Head -->
<!-- InstanceEndEditable -->
</head>
<body>
<div id="wrapper">
  <div id="header"><!-- InstanceBeginEditable name="header" -->
    <jsp:include page="EMV_HEADER.jsp" flush="true" />
   <!-- InstanceEndEditable -->  </div>
  <div id="topnav"><!-- InstanceBeginEditable name="top_navigation" -->
  <jsp:include page="EMV_TOPMENU.jsp" flush="true" />  
  <!-- InstanceEndEditable -->  </div>
  <div id="container">

    <div id="content"><!-- InstanceBeginEditable name="main_content" -->
    <jsp:include page="EMV_HELPBAR.jsp" flush="true" />
    <!-- Begin Main Content -->
      
		
        <div class="content">
      <form id="cscform" name="cscform" method="post" action="PI_WORKINGTIME_CUS.jsp">
        <input type="hidden" name="__cmd" value="">
        <input type="hidden" name="__screen"  value="PI_WORKINGTIME_CUS"> 
        <input type="hidden" name="__help" value="">
        <input type="hidden" name="__helpReturn" value="">
        <input type="hidden" name="__helpName" value="">
        <input type="hidden" name="__pageCall" >
        <input type="hidden" name="__referPage" value="">
        <input type="hidden" name="__calendar">
        <script language="javascript">getInputFormatDate();</script>
        <input type="hidden" name="__companyid"  value="<%=screen.getUProfile().get("companyid")%>">
        <input type="hidden" name="__fixCon"  > 
        <input type="hidden" name="__language" value="<%=screen.getUProfile().get("lang")%>">
        
		<input type="hidden" id="tr_source" name="tr_source" value="">
		<input type="hidden" id="tm_source" name="tm_source" value="">
		<input type="hidden" id="sh_source" name="sh_source" value="">
        <input type="hidden" id="__emptime0" name="__emptime0" value="<%=screen.getUProfile().get("time0id")%>">
    
       <%
				String stick ="";
				String sql  = "select * from mtime0 where  time0id in (select time0 from memployee where employeeid ='"+screen.getUProfile().get("employeeid")+"')";				
				String dbName = screen.getUProfile().getDbName();
				DataSet ds = new DataSet(sql, dbName, "mtime0" ); 
				ds.initConnection(screen.getUProfile());
				while(ds.next()){
					 stick = ds.getString("sticktm");
			
				}
				//	out.print(stick);
				
				%>
        <input type="hidden" name="__childFilter" >
    
	
        <div id="toolTipLayer" style="position:absolute; visibility: hidden"></div>      
		<script language="javascript">initToolTips();</script>    
          <div class="content-box2">
            <div class="content-header"><h2><script language="javascript">swapLang('Working Time Detail')</script></h2></div>
            	
                <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table-search-condition">
				<tr>
                	<td colspan="2" class="column-input">&nbsp;</td>
                </tr>
				<tr>
					<td class="column-input" align="">&nbsp;&nbsp;<script type="text/javascript" language="JavaScript">swapLang("Employee")</script></td>
					<td class="column-input">
						
						<input id="__employeeid" name="__employeeid" type="text" size="10" value="<%=chk.chkNullString(request.getParameter("__employeeid"),EMV.getUProfile().get("employeeid"))%>" />
						<a href="javascript: goHelp('MEMPLOYEEHELP','__employeeid');"><img src="../IMAGES/BUTTON/MAIN/SEARCH20.gif" width="20" height="20" border="0" align="absmiddle"  /></a>
						<input name="MEMPLOYEE@FULLNAME" type="text" class="text" id="MEMPLOYEE@FULLNAME" size="40" readonly="readonly" value="<%=chk.chkNullString(request.getParameter("MEMPLOYEE@FULLNAME"),EMV.getUProfile().get("tfullname")) %>" /></td>
				</tr>
                <tr>
					<td class="column-input" align="">&nbsp;&nbsp;<strong><script language="javascript">swapLang('Date')</script></strong></td>
               		<td class="column-input">
                    
					<% if (request.getParameter("date_start")==null) { %>									 
                  
			  		<input id="date_start" name="date_start" type="text" value="<%=cs1.getDDMMYYYY()%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(this,date_end)" onKeypress = "chkIntegerOfDate(this.value)" onMouseOver="toolTip('วันเริ่มต้น(DDMMYYYY)')" onMouseOut="toolTip()">&nbsp;
				  	<% } else {%>
				   		<input id="date_start" name="date_start" type="text" value="<%=request.getParameter("date_start")%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(this,date_end)" onKeypress = "chkIntegerOfDate(this.value)" onMouseOver="toolTip('วันเริ่มต้น(DDMMYYYY)')" onMouseOut="toolTip()">&nbsp;
			  	<% }%>
				  		<a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('calendar1','','../IMAGES/EMPVIEW/ICON_CALENDAR.gif',1)">
				  		<img src="../IMAGES/EMPVIEW/ICON_CALENDAR.gif" name="calendar1" width="20" height="20" border="0" align="absmiddle" onClick="viewCal('date_start')" alt="Calendar"></a>&nbsp;&nbsp;&nbsp;-&nbsp;&nbsp;&nbsp; 
					<% if (request.getParameter("date_end")==null) { %>
				  		<input id="date_end" name="date_end" type="text" value="<%=cs2.getDDMMYYYY()%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(date_start,this)" onKeypress = "chkIntegerOfDate(this.value)" onMouseOver="toolTip('วันสิ้นสุด(DDMMYYYY)')" onMouseOut="toolTip()">&nbsp;
				   	<% } else {%>
				   		<input id="date_end" name="date_end" type="text" value="<%=request.getParameter("date_end")%>" size="9" maxlength="10" onKeyup = "formatDate(this)" onBlur = "chkInputDate2(date_start,this)" onKeypress = "chkIntegerOfDate(this.value)" onMouseOver="toolTip('วันสิ้นสุด(DDMMYYYY)')" onMouseOut="toolTip()">&nbsp;
			  	  <% }%>
			  		  <a href="#" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('calendar2','','../IMAGES/EMPVIEW/ICON_CALENDAR.gif',1)">
		  		    <img src="../IMAGES/EMPVIEW/ICON_CALENDAR.gif" name="calendar2" width="20" height="20" border="0" align="absmiddle" onClick="viewCal('date_end')" alt="Calendar"></a>
					&nbsp;&nbsp;&nbsp;
                    <a href="javascript:search();"><img src="../IMAGES/EMPVIEW/BUTTON/SEARCH.gif" width="60" height="23" border="0" align="absmiddle" /></a>
					</td>
				</tr>
               	<tr>
                	<td colspan="2" class="column-input">&nbsp;</td>
                </tr>
                </table>
				  
	
                
				<table width="100%" border="0" cellpadding="0" cellspacing="1" class="table-content-list">
				<tr>
                    <td rowspan="2" width="10%" class="column-header"><script language="javascript">swapLang('Date')</script></td>
                    <td rowspan="2" class="column-header"><script language="javascript">swapLang('Day')</script></td>

					<%if(!stick.equals("9")){%>
                    <td rowspan="2" width="16%" class="column-header"><script language="javascript">swapLang('Working Time')</script></td>
					<%}%>
                    
					<td rowspan="2" width="14%" class="column-header"><script language="javascript">swapLang('SwipeTime')</script></td>
                    <td rowspan="2" width="" class="column-header"><script language="javascript">swapLang('Day Type')</script></td>
                    <td rowspan="2" width="" class="column-header"><script language="javascript">swapLang('Late')</script></td>
                    <td rowspan="2" width="" class="column-header"><script language="javascript">swapLang('Absent')</script></td>
                    <td rowspan="2" width="" class="column-header"><script language="javascript">swapLang('Leave')</script></td>
                    <!-- <td width="" class="column-header"><script language="javascript">swapLang('OT')</script></td> -->
                    <td colspan="4" width="" class="column-header"><script language="javascript">swapLang('OT')</script></td>

                    <td rowspan="2" width="" class="column-header"><script language="javascript">swapLang('Work')</script></td>
					<td rowspan="2" width="" class="column-header"><script language="javascript">swapLang('Shift fee')</script></td>
					<td rowspan="2" width="" class="column-header"><script language="javascript">swapLang('Trans fee')</script></td>
					<td rowspan="2" width="" class="column-header">&nbsp;</td>
                </tr>

          		<tr>
                    <td width="" class="column-header">1</td>
                    <td width="" class="column-header">1.5</td>
                    <td width="" class="column-header">2</td>
                    <td width="" class="column-header">3</td>
                </tr> 
				
           	<%
				HashMap hmHoliday = new HashMap();
				try {
					DbInquiry inqHoliday = new InitialInquiry(screen.getUProfile()).getDbInquiry();
					inqHoliday.setSchemaName(screen.getUProfile().getSchemaName());
					inqHoliday.initMyTable("Mholiday1", "", "");
					inqHoliday.setColumn("*");
								
					DbInquiry inqTime = new InitialInquiry(screen.getUProfile()).getDbInquiry();
					inqTime.setSchemaName(screen.getUProfile().getSchemaName());
					inqTime.initMyTable("Mtime0", "", "");
					inqTime.setColumn("*");
					inqTime.putChild(inqHoliday);					
					
					DbInquiry inqEmp = new InitialInquiry(screen.getUProfile()).getDbInquiry();
					inqEmp.setSchemaName(screen.getUProfile().getSchemaName());
					inqEmp.initMyTable("Memployee", "employeeid='"+EMV.getUProfile().getEmvEmpId()+"'", "");
					//inqEmp.setColumn("*");
					inqEmp.setColumn("employeeid,companyid,fname,lname,efname,elname,emp_prefix,emp_level,time0,bu1,bu2,bu3,bu4,bu5");
					inqEmp.putChild(inqTime);								
					inqEmp.refresh();
					while (inqEmp.next()) {
						DbInquiry childTime =  (DbInquiry) inqEmp.getChild("Mtime0");
						DbInquiry child = (DbInquiry) childTime.getChild("Mholiday1");
						do {
							CscCalendar cHol = new CscCalendar(child.getString("hdate"));
							hmHoliday.put(cHol.getDDMMYYYY(), child.getString("tdesc"));
						} while (child.next());
					}
				} catch (Exception e) {}
				//out.println(hmHoliday);

				String holiday = "";
				CscTime ct_late = new CscTime();
				CscTime ct_absent = new CscTime();
				CscTime ct_leave = new CscTime();
				CscTime ct_ot = new CscTime();
				CscTime ct_ot1 = new CscTime();
				CscTime ct_ot5 = new CscTime();
				CscTime ct_ot2 = new CscTime();
				CscTime ct_ot3 = new CscTime();
				CscTime ct_work = new CscTime();
				CscTime ct_shift = new CscTime();
				CscTime ct_trans = new CscTime();

				while (screen.inq.next()) {	
					DbRecord rec = screen.inq.getCurrentDbRecord();
					CscCalendar cDate = new CscCalendar(rec.getString("dateid"));
					String day = "", cFont  = "";
					if (((String) screen.getUProfile().get("lang")).equalsIgnoreCase("THA")) { //แสดงวันจันทร์ , อังคาร, พุธ เป็นต้น
						day = cDate.getDOWthi(); 
					} else day = cDate.getDOWENG(); 
					if (rec.getString("eventgrp").equals("H")) {
						cFont = "week";
					} else if (rec.getString("eventgrp").equals("I")) {
						cFont = "holiday";
						//holiday += cDate.getDDMMYYYY()+" "+((String) hmHoliday.get(cDate.getDDMMYYYY()))+", ";
						String tmp = ((String) hmHoliday.get(cDate.getDDMMYYYY()));
						if (tmp==null) tmp="";
						holiday += cDate.getDDMMYYYY()+" "+tmp+", ";
					} else if (rec.getString("eventgrp").equals("J")) {
						cFont = "absent";
					}				
			%>
			  
            <tr class="datarow" id="tr_<%=screen.getString("runno")%>" runno="<%=screen.getString("runno")%>" dateid="<%=screen.getString("dateid")%>" shiftupdated="false" timeupdated="false" oldtime0="<%=screen.getString("time0id")%>" timeinupdated="false" timeoutupdated="false">
            	<td class="column-text-center"><font class="<%=cFont%>"><%=cDate.getDDMMYYYY()%></font></td>
                <td class="column-text-center"><font class="<%=cFont%>"><%=day%></font></td>
				
				<!-- only normal shift will show (blank when emp's flexible)-->
				<%if(!stick.equals("9")){%>
             	<td class="column-text-center"><a id="shifprop_<%=screen.getString("runno")%>" time0id="<%=screen.getString("time0id")%>" sh_din='<%=screen.getString("sh_dt_bg")%>' sh_tin='<%=screen.getString("sh_tm_bg")%>' sh_dout='<%=screen.getString("dt_breakin")%>' sh_tout='<%=screen.getString("tm_breakin")%>' sh_din1='<%=screen.getString("dt_breakout")%>' sh_tin1='<%=screen.getString("tm_breakout")%>' sh_dout1='<%=screen.getString("sh_dt_en")%>' sh_tout1='<%=screen.getString("sh_tm_en")%>' class="btn_shift" href='javascript:;' style='text-decoration: none'><%=df2.format(rec.getDouble("sh_tm_bg"))%> - <%=df2.format(rec.getDouble("sh_tm_en"))%></a></td>
                <%}%>
				
				<!-- in - out -->
				<td class="column-text-center"><font class="<%=cFont%>">
				<%
					String time_in = "";
					String time_out = "";
					if(rec.getString("doctype").equals("A")){ /* leave will not show swipetime */
						/* show nothing */
					}else{
						if (rec.getString("forget_in").equals("1")) {
							time_in = "__.__";
							out.print("<a datein='"+ screen.getString("m_dt_bg") +"' id='in_" + screen.getString("runno") + "' class='btn_out' href='javascript:;' style='text-decoration: none'>" + time_in + "</a>");
						} else {
							time_in = df2.format(rec.getDouble("m_tm_bg"));
							out.print("<a datein='"+ screen.getString("m_dt_bg") +"' id='in_" + screen.getString("runno") + "' class='btn' href='javascript:;' style='text-decoration: none'>" + time_in + "</a>");
						}

						out.print("&nbsp;-&nbsp;");

						if (rec.getString("forget_out").equals("1")) {
							time_out = "__.__";
							out.println("<a datein='"+ screen.getString("m_dt_en") +"' id='out_" + screen.getString("runno") + "' class='btn_out' href='javascript:;' style='text-decoration: none'>"+time_out + "</a>");
						} else {
							time_out = df2.format(rec.getDouble("m_tm_en"));
							out.println("<a datein='"+ screen.getString("m_dt_en") +"' id='out_" + screen.getString("runno") + "' class='btn' href='javascript:;' style='text-decoration: none'>"+time_out + "</a>");
						}
					}
				%></font>
                </td>

                <!-- day type -->
				<td class="column-text-center"><font class="<%=cFont%>">
                	<% if (rec.getString("eventgrp").equals("H")) { %>
						<script language="javascript">swapLang('Holiday')</script>
					<%} else if (rec.getString("eventgrp").equals("I")) {%>
						<script language="javascript">swapLang('Special Holiday')</script>
					<% } else { 
						out.println(screen.getString("meventgrp","tdesc"));
					 } %>
                </font></td>
                
				<!-- late -->
				<td class="column-text-center"><font class="<%=cFont%>"><span id="late_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("lt")>0) { 
						ct_late.add(rec.getDouble("lt"));
						out.println(df.format(rec.getDouble("lt")));
					} 
				%> 
               	</span></font></td>

				<!-- absent -->
                <td class="column-text-center"><font class="<%=cFont%>"><span id="absent_<%=screen.getString("runno")%>">
				<% 
					if (rec.getString("eventgrp").equals("J") && rec.getDouble("m_lv")>0) { 
						ct_absent.add(rec.getDouble("m_lv"));
						out.println(df.format(rec.getDouble("m_lv")));
					} 
				%>
				</span></font></td>

                <!-- leave -->
				<td class="column-text-center"><font class="<%=cFont%>"><span id="leave_<%=screen.getString("runno")%>">
				<% 
					if (!rec.getString("eventgrp").equals("J") && rec.getDouble("m_lv")>0) { 
						ct_leave.add(rec.getDouble("m_lv"));
						out.println(df.format(rec.getDouble("m_lv")));
					} 
				%>
				</span></font></td>
              	
				<!-- <td class="column-text-center"><font class="<%=cFont%>"> -->
				<% 
					if (rec.getDouble("ac_ot")>0) { 
						ct_ot.add(rec.getDouble("ac_ot"));
						//out.println(df.format(rec.getDouble("ac_ot")));
					} 
				%> 
                <!-- </font></td> -->
                
				<td class="column-text-center"><font class="<%=cFont%>"><span id="ot1_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("ot1")>0) { 
						ct_ot1.add(rec.getDouble("ot1"));
						out.println(df.format(rec.getDouble("ot1")));
					} 
				%> 
                </span></font></td>
               	
				<td class="column-text-center"><font class="<%=cFont%>"><span id="ot5_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("ot5")>0) { 
						ct_ot5.add(rec.getDouble("ot5"));
						out.println(df.format(rec.getDouble("ot5")));
					} 
				%> 
                </span></font></td>
                
				<td class="column-text-center"><font class="<%=cFont%>"><span id="ot2_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("ot2")>0) { 
						ct_ot2.add(rec.getDouble("ot2"));
						out.println(df.format(rec.getDouble("ot2")));
					} 
				%> 
                </span></font></td>
                
				<td class="column-text-center"><font class="<%=cFont%>"><span id="ot3_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("ot3")>0) { 
						ct_ot3.add(rec.getDouble("ot3"));
						out.println(df.format(rec.getDouble("ot3")));
					} 
				%> 
                </span></font></td>
                <td class="column-text-center"><font class="<%=cFont%>"><span id="work_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("hour_d")>0) { 
						ct_work.add(rec.getDouble("hour_d"));
						out.println(df.format(rec.getDouble("hour_d")));
					} 
				%> 
                </span></font></td>
				<td class="column-text-center"><font class="<%=cFont%>"><span id="shiftfee_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("unused9") > 0) {
						ct_shift.add(rec.getDouble("unused9"));
						out.println(df.format(rec.getDouble("unused9")));
					}else if(rec.getDouble("unused6") > 0){
						ct_shift.add(rec.getDouble("unused6"));
						out.println(df.format(rec.getDouble("unused6")));
					} 
				%> 
                </span></font></td>

				<td class="column-text-center"><font class="<%=cFont%>"><span id="transfee_<%=screen.getString("runno")%>">
				<% 
					if (rec.getDouble("unused10")>0) {
						ct_trans.add(rec.getDouble("unused10"));
						out.println(df.format(rec.getDouble("unused10")));
					}else if(rec.getDouble("unused7") > 0){
						ct_trans.add(rec.getDouble("unused7"));
						out.println(df.format(rec.getDouble("unused7")));
					} 
				%> 
                </span></font></td>

				<td class="column-text-center"><div align="center"><a class="updateline" href="javascript:;"><img id="upd_<%=screen.getString("runno")%>" hint="calculate" title="calculate" src="../IMAGES/BUTTON/MAIN/UPOAD20.gif" width="23" height="23" border="0" align="absmiddle" style="display:none"/></div></td>
          	</tr>                
            <%
				} //while (screen.inq.next()) 
			%>      
            <!-- Display Summary -->
            <tr>
				<%
				int col = 5 ;
				if(stick.equals("9")){
					col--;
					}
				%>
            	<td class="column-text-right" colspan="<%=col%>"><script language="javascript">swapLang('Total')</script>&nbsp;</td>    
            	<td id="sum_late" class="column-text-center"><%=(ct_late.getFloat()==0)?"":df.format(ct_late.getFloat())%></td>    
                <td id="sum_absent" class="column-text-center"><%=(ct_absent.getFloat()==0)?"":df.format(ct_absent.getFloat())%></td>      
                <td id="sum_leave" class="column-text-center"><%=(ct_leave.getFloat()==0)?"":df.format(ct_leave.getFloat())%></td>
                <!-- <td class="column-text-center"><%=(ct_ot.getFloat()==0)?"":df.format(ct_ot.getFloat())%></td> -->    
                <td id="sum_ot1" class="column-text-center"><%=(ct_ot1.getFloat()==0)?"":df.format(ct_ot1.getFloat())%></td>      
                <td id="sum_ot5" class="column-text-center"><%=(ct_ot5.getFloat()==0)?"":df.format(ct_ot5.getFloat())%></td>      
                <td id="sum_ot2" class="column-text-center"><%=(ct_ot2.getFloat()==0)?"":df.format(ct_ot2.getFloat())%></td>      
                <td id="sum_ot3" class="column-text-center"><%=(ct_ot3.getFloat()==0)?"":df.format(ct_ot3.getFloat())%></td>
                <td id="sum_work" class="column-text-center"><%=(ct_work.getFloat()==0)?"":df.format(ct_work.getFloat())%></td>   
				<td id="sum_shift" class="column-text-center"><%=(ct_shift.getFloat()==0)?"":df.format(ct_shift.getFloat())%></td>   
				<td id="sum_trans" class="column-text-center"><%=(ct_trans.getFloat()==0)?"":df.format(ct_trans.getFloat())%></td>   
				<td class="column-text-center">&nbsp;</td>   
            </tr>
			<tr>
            	<td colspan="<%=(col + 11)%>" class="column-text">&nbsp;<%=holiday%></td>
          	</tr> 
            </table>           	
            <div class="content-footer"><img src="../IMAGES/SPACER.gif" width="3" height="3" /></div>
          </div>            
      
      <!-- End Main Content -->
      <!-- InstanceEndEditable -->    </div>
  </div>
</div>

<!-- shift selector popup -->
<div class="shift_popup">
	<div align="right" style="height:15px">[<a id="shift_pop_close" href="javascript:;" style="text-decoration: none">close</a>]</div>
	<table class="tbl-emp-hint">
<%
	try {
	String emptime0 = (String) EMV.getUProfile().get("time0id");
	String filter_sh = "";
	String sel = "select m0.time0id,m0.tdesc,m0.edesc,m1.timein1,m1.timein2,m1.timeout1,m1.timeout2 from mtime0 m0 left join mtime1 m1 on m0.time0id = m1.time0id where m1.dayweekid = '1' and ";
	String order_sh = " order by m1.timein1" ;
	if(emptime0.startsWith("F")){
		filter_sh = "m0.time0id like '%Flex%' and m0.status = '0'";
	}else if(emptime0.equals("6")){
		filter_sh = "m0.time0id = '6'" ;
	}else{
		filter_sh = "(left(m1.TIME0ID,1) = 'A' or  left(m1.TIME0ID,1) = 'C') and m0.time0id not like '%Flex%' and m0.time0id != '6' and m0.status = '0'";
	}
	//dbName = screen.getUProfile().getDbName();
	DataSet ds_shift = new DataSet(sel + filter_sh + order_sh, screen.getUProfile().getDbName(), "mtime1" ); 
	ds_shift.initConnection(EMV.getUProfile());
	
	while(ds_shift.next()){
		try {
%>
	<tr name="tr_shift" class="td-shift-var" time0id='<%=ds_shift.getString("time0id")%>' tdesc='<%=ds_shift.getString("tdesc")%>' edesc='<%=ds_shift.getString("edesc")%>' timein1='<%=df2.format(Float.parseFloat(ds_shift.getString("timein1")))%>' timeout1='<%=df2.format(Float.parseFloat(ds_shift.getString("timeout1")))%>' timein2='<%=df2.format(Float.parseFloat(ds_shift.getString("timein2")))%>' timeout2='<%=df2.format(Float.parseFloat(ds_shift.getString("timeout2")))%>'>
		<td><div><%=ds_shift.getString("time0id")%></div></td>
		<td>
			<div><%=ds_shift.getString("tdesc")%></div>
		</td>
		<td>
			<div>[<%=df2.format(Double.parseDouble(ds_shift.getString("timein1")))%>&nbsp;-&nbsp;<%=df2.format(Double.parseDouble(ds_shift.getString("timeout2")))%>]</div>
		</td>
	</tr>
<%
		}catch(Exception e1){
			e1.printStackTrace();
		}
	}
	}catch(Exception e){
		System.out.print("--->" + e.getMessage());
	}
%>
	</table>
</div>


<!-- swipetime popup -->
<div class="time_popup">
	<div align="right" style="height:15px">[<a id="time_pop_close" href="javascript:;" style="text-decoration: none">close</a>]</div>
	<table class="tbl-emp-hint">
<%
	try {
		CscCalendar stpd = new CscCalendar(cs1.getYYYYMMDD());
		CscCalendar enpd = new CscCalendar(cs2.getYYYYMMDD());

		stpd.decDate(2);
		enpd.incDate(2);

		String sel_tm = "select swipedate,swipetime,swipetype from ttimetemp where employeeid = '" + (String) EMV.getUProfile().get("employeeid") + "'";
		String filter_tm = " and swipedate between '" + stpd.getYYYYMMDD() + "' and '" + enpd.getYYYYMMDD() + "'";
		String order_tm = " order by swipedate,swipetime" ;
		
		DataSet ds_time = new DataSet(sel_tm + filter_tm + order_tm, screen.getUProfile().getDbName(), "ttimetemp" ); 
		ds_time.initConnection(EMV.getUProfile());
		
		while(ds_time.next()){
			try {
%>
		<tr name="tr_time" class="td-doc-var">
			<td><div name="swdate"><%=ds_time.getString("swipedate")%></div></td>
			<td><div name="swtime"><%=df2.format(Float.parseFloat(ds_time.getString("swipetime")))%></div></td>
			<td><div name="swtype"><%=ds_time.getString("swipetype").equals("0")?"IN":(ds_time.getString("swipetype").equals("1"))?"OUT":"None"%></div></td>
		</tr>
<%
			}catch(Exception e1){
				e1.printStackTrace();
			}
		}
	
	}catch(Exception e){
		System.out.print("--->" + e.getMessage());
	}
%>
	</table>
</div>

  <div id="footer"><!-- InstanceBeginEditable name="footer" -->
  <jsp:include page="EMV_FOOTER.jsp" flush="true" />
  <!-- InstanceEndEditable -->  
  </div>
</body>
<!-- InstanceEnd -->
</html>