<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c"  uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<script>
//업무사항 초기화
function clearForm(){
	var f = document.frm;
	f.work_sort.value = "new";
	f.client_name.value = "";
	f.work_content.value = "";
	f.work_check_date.value = "";
	f.work_end_date.value = "";
	f.work_status.value = "";
	f.work_manager.value = "";		
}
//전달사항 초기화
function clearForm2(){
	var f = document.frm1;
	f.delivery_sort.value = "sort";
	f.client_name.value = "";
	f.delivery_content.value = "";
	f.delivery_check_date.value = "";
	f.delivery_end_date.value = "";
	f.delivery_status.value = "sort";
	f.delivery_manager.value = "";		
}

//빈칸 체크.
function validateCheck(){
	var sort = document.getElementById("delivery_sort").value;
	if(sort == "sort"){
		alert("구분을 선택해주세요");
		return false;
	}
	
	var name = document.getElementById("client_name").value;
	if(name == ""){
		alert("고객명을 입력해주세요");
		return false;
	}
	
	var content = document.getElementById("delivery_content").value;
	if(content == ""){
		alert("전달 사항을 입력해주세요");
		return false;
	}
	
	var check = document.getElementById("delivery_check_date").value;
	if(check == "" || check == null){
		alert("확인 날짜를 입력해주세요");
		return false;
	}
	
	var end = document.getElementById("delivery_end_date").value;
	if(end == "" || end == null){
		alert("마감 날짜를 입력해주세요");
		return false;
	}
	
	var status = document.getElementById("delivery_status").value;
	if(status == "sort"){
		alert("상태를 입력해주세요");
		return false;
	}
	return true;	
}

//빈칸체크1
function validateCheck1(){
	var sort = document.getElementById("work_sort").value;
	if(sort == "sort"){
		alert("구분을 선택해주세요");
		return false;
	}
	
	var name = document.getElementById("client_name1").value;
	if(name == ""){
		alert("고객명을 입력해주세요");
		return false;
	}
	
	var content = document.getElementById("work_content").value;
	if(content == ""){
		alert("업무 내용을 입력해주세요");
		return false;
	}
	
	var check = document.getElementById("work_check_date").value;
	if(check == "" || check == null){
		alert("확인 날짜를 입력해주세요");
		return false;
	}
	
	var end = document.getElementById("work_end_date").value;
	if(end == "" || end == null){
		alert("마감 날짜를 입력해주세요");
		return false;
	}
	
	var status = document.getElementById("work_status").value;
	if(status == "sort"){
		alert("상태를 입력해주세요");
		return false;
	}
	return true;		
}

//날짜 입력 체크
function validate_date(){	
	var seleteddate = document.getElementById("seleteddate").value;
	if(seleteddate == "" || seleteddate == null){
		alert("날짜를 입력해주세요");
		return false;
	}
}

</script>
<script type="text/javascript" src="IDC/js/myBus.js"></script>
<script type="text/javascript" src="IDC/js/BusinessJSON.js"></script>
<script src="IDC/js/setToken.js"></script>
<script type="text/javascript">
$(function()
{
	$(document).ready(function()
	{
		$(".token").each(function()
		{
			$(this).val($("#token").val());
		});
	});
});

</script>

<!-- 여기가 본 페이지이다 -->
<div class="row">
	<input type="hidden" id="token">
	<div class="col-lg-12">
		<div class="panel panel-default">
			<div class="panel-heading">
				<h5><i class="fa fa-desktop fa-fw"></i>업무 일지</h5>
			</div>
			<div class="panel-body">
				<div class="row">
					<div class="col-lg-12">
						<p class="text-center">
							${memberDTO.name } 로그인
						</p>
					</div>
				</div>
				<!-- row -->
	   			<div class="table-responsive">
					<table id="daily_log" class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
								<td colspan="11">업무일지 : ${memberDTO.location}  ${memberDTO.name }</td>
								<td colspan="3">									
									<form action="" method="post" onsubmit="return validate_date();">
									
										<input type="date" name="date" id="seleteddate" value="${memberDTO.curDate}" />
										<input type="submit" value="보기" class="btn-sm btn-info"/>
									</form>																		
								</td>
							</tr>
						</thead>
						<tbody>
							<tr>
								<td></td>
								<td colspan="3">도쿄센터</td>
								<td></td>
								<td colspan="4">치바센터</td>
								<td rowspan="2">진행사항</td>
								<td rowspan="2">건수</td>
								<td rowspan="2">주간</td>
								<td rowspan="2">중간</td>
								<td rowspan="2">야간</td>								
							</tr>						
							<tr>
								<td>주간</td>
								<td>08:00 ~ 16:00</td>								
								<td width="50"><c:if test="${memberDTO.location eq '도쿄' && memberDTO.part eq '0'}"><i class="fa fa-check"></i></c:if></td>
								<td width="50"></td>
								<td>주간</td>
								<td>08:00 ~ 20:00</td>
								<td width="50"><c:if test="${memberDTO.location eq '치바' && memberDTO.part eq '0'}"><i class="fa fa-check"></i></c:if></td>
								<td>08:00 ~ 20:00</td>
								<td width="50"></td>																
							</tr>
							<tr>
								<td>중간</td>
								<td>16:00 ~ 24:00</td>
								<td><c:if test="${memberDTO.location eq '도쿄' && memberDTO.part eq '1'}"><i class="fa fa-check"></i></c:if></td>
								<td></td>
								<td>중간</td>
								<td>14:00 ~ 24:00</td>
								<td><c:if test="${memberDTO.location eq '치바' && memberDTO.part eq '1'}"><i class="fa fa-check"></i></c:if></td>
								<td>12:00 ~ 24:00</td>
								<td></td>
								<td>진행중</td>
								<td>${memberDTO.count_ongoing}</td>
								<td rowspan="2"><c:if test="${memberDTO.part eq '0'}"><i class="fa fa-check"></i></c:if></td>
								<td rowspan="2"><c:if test="${memberDTO.part eq '1'}"><i class="fa fa-check"></i></c:if></td>
								<td rowspan="2"><c:if test="${memberDTO.part eq '2'}"><i class="fa fa-check"></i></c:if></td>
							</tr>
							<tr>
								<td>야간</td>
								<td>24:00 ~ 08:00</td>
								<td><c:if test="${memberDTO.location eq '도쿄' && memberDTO.part eq '2'}"><i class="fa fa-check"></i></c:if></td>
								<td></td>
								<td>야간</td>
								<td>20:00 ~ 08:00</td>
								<td><c:if test="${memberDTO.location eq '치바' && memberDTO.part eq '2'}"><i class="fa fa-check"></i></c:if></td>
								<td>20:00 ~ 08:00</td>
								<td></td>
								<td>완료</td>
								<td>${memberDTO.count_end}</td>						
							</tr>			
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>
				<!-- table-responsive -->
				<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
								<td rowspan="2">고객명</td>
								<td colspan="2">일반</td>
								<td colspan="2">방어</td>
								<td colspan="2">전용</td>
								<td colspan="2">대체</td>
								<td colspan="3">합계</td>
								<td colspan="3">테스트</td>
							</tr>
							<tr>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>합계</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>합계</td>
							</tr>
						</thead>
						<tbody>
							<c:forEach begin="1" end="${IdcHaveListSize-1}" var="temp" varStatus="i">
								<tr>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].client_name }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].normal_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].normal_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].defence_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].defence_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].solo_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].solo_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].sub_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].sub_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].total_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].total_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].total_total }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].test_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-i.count-1].test_c }</td>
									<td><strong>${IdcHaveList[IdcHaveListSize-i.count-1].test_total }</td>
								</tr>
							</c:forEach>
							<tr>
									<td>${IdcHaveList[IdcHaveListSize-1].client_name }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].normal_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].normal_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].defence_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].defence_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].solo_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].solo_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].sub_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].sub_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].total_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].total_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].total_total }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].test_t }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].test_c }</td>
									<td>${IdcHaveList[IdcHaveListSize-1].test_total }</td>
							</tr>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>	
				<!-- table-responsive -->
				<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">						
						<tbody>
							<tr>
								<td rowspan="${fn:length(change_list) + 2}">변동사항</td>
								<td rowspan="2">고객명</td>
								<td colspan="2">신규</td>
								<td colspan="2">해지</td>
								<td colspan="2">신규취소</td>
								<td colspan="2">해지취소</td>
								<td colspan="2">TEST</td>
								<td colspan="2">TEST종료</td>
								<td colspan="2">소계</td>
							</tr>
							<tr>			
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
								<td>도쿄</td>
								<td>치바</td>
							</tr>
							<c:forEach items="${change_list}" var="dto">
								<tr>						
									<td>${dto.client_name}</td>
									<td>${dto.new_t}</td>
									<td>${dto.new_c}</td>
									<td>${dto.del_t}</td>
									<td>${dto.del_c}</td>
									<td>${dto.newCancel_t}</td>
									<td>${dto.newCancel_c}</td>
									<td>${dto.delCancel_t}</td>
									<td>${dto.delCancel_c}</td>
									<td>${dto.test_t}</td>
									<td>${dto.test_c}</td>
									<td>${dto.endTest_t}</td>
									<td>${dto.endTest_c}</td>
									<td>${dto.total_tokyo}</td>
									<td>${dto.total_chiba}</td>
								</tr>			
							</c:forEach>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>
				<!-- table-responsive -->
				
				<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">
						<thead>
						</thead>
						<tbody>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>
				<!-- table-responsive -->
				<div class="row">
					<div class="col-lg-12">
						<p class="text-left">
							<h4>전달사항</h4>
						</p>
					</div>
					<!-- col-lg-12 -->
				</div>
				<!-- row -->
				<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
								<td>
									<select class="btn btn-default myFilter" id="filter1" filter=${filter[0] }>
										<option value="">구분</option>
										<option value="all">전체</option>
										<option value="each">개별</option>
									</select>
								</td>
								<td>
									<select class="btn btn-default myFilter" id="filter2" filter=${filter[1] }>
										<option value="">고객명</option>
									</select>
								</td>
								<td width="300"><span>전달사항</span></td>
								<td>
									<span>확인날짜</span>
									<input type="date" class=" myFilter" id="filter3" filter=${filter[2] }>
								</td>
								<td>
									<span>마감일</span>
									<input type="date" class=" myFilter" id="filter4" filter=${filter[3] }>
								</td>
								<td>
									<select class="btn btn-default myFilter" id="filter5" filter=${filter[4] }>
										<option value="">상태(연장/진행중)</option>
										<option value="end">완료</option>
										<option value="delay">연장</option>
										<option value="ongoing">진행중</option>
									</select>
								</td>
								<td>
									<select class="btn btn-default myFilter" id="filter6" filter=${filter[5] }>
										<option value="">담당자</option>
									</select>
								</td>
								<td>
									<span>수정</span>
								</td>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${delivery_list}" var="dto">
								<tr>
									<td>${dto.delivery_temp}</td>
									<td>${dto.client_name}</td>
									<td>${dto.delivery_content}</td>
									<td>${dto.delivery_check_date}</td>
									<td>${dto.delivery_end_date}</td>
									<td>
										<select class="listFilter" filter="${dto.delivery_temp1}">
											<option value="end">완료</option>
											<option value="delay">연장</option>
											<option value="ongoing">진행중</option>
										</select>
									</td>
									<td>${dto.delivery_manager}</td>
									<td><button class="btn btn-info modifyBtn" url="businessModify" value="${dto.num }">수정</button></td>
								</tr>			
							</c:forEach>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>
				<!-- table-responsive -->
				<div class="row">
					<div class="col-lg-12">
						<p class="text-left">
							<h4>금일 완료된 업무</h4>
						</p>
					</div>
					<!-- col-lg-12 -->
				</div>
				<!-- row -->
				<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
								<td>구분</td>
								<td>고객명</td>
								<td width="300">전달사항</td>
								<td>확인날짜</td>
								<td>마감일</td>
								<td>상태</td>
								<td>담당자</td>
								<td>수정</td>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${endWork_list}" var="dto">
								<tr>
									<td>
										<select class="btn btn-default today_end_filter" filter="${dto.work_sort}">
											<option value="sort">구분</option>
											<option value="new">신규</option>
											<option value="cancel">해지</option>
											<option value="test">테스트</option>
											<option value="substitution">대체</option>
											<option value="lineChange">회선변경</option>
											<option value="block">차단</option>
											<option value="defence">방어</option>
											<option value="disorder">장애</option>
											<option value="accounting">과금</option>
											<option value="request">요청</option>
											<option value="addService">부가 서비스</option>						
										</select>
									</td>
									<td><input type="text"  value="${dto.client_name}"></td>
									<td><input type="text" value="${dto.work_content}"></td>
									<td><input type="date" value="${dto.work_check_date}"></td>
									<td><input type="date" value="${dto.work_end_date}"></td>
									<td>
										<select class="btn btn-default today_end_filter" filter="${dto.work_status}">
											<option value="end">완료</option>
											<option value="delay">연장</option>
											<option value="ongoing">진행중</option>
										</select>
									</td>
									<td><input type="text" value="${dto.work_manager}"></td>
									
									<td>
										<button class="btn btn-info modifyBtn" url="businessGEModify" value="${dto.num }">수정</button>
									</td>
								</tr>			
							</c:forEach>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>
				<!-- table-responsive -->
				<div class="row">
					<div class="col-lg-12">
						<p class="text-left">
							<h4>금일 진행중인 업무</h4>
						</p>
					</div>
					<!-- col-lg-12 -->
				</div>
				<!-- row -->
				<div class="table-responsive">
					<table class="table table-bordered table-hover table-striped">
						<thead>
							<tr>
								<td>구분</td>
								<td>고객명</td>
								<td width="300">전달사항</td>
								<td>확인날짜</td>
								<td>마감일</td>
								<td>상태</td>
								<td>담당자</td>
								<td>수정</td>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${ongoingWork_list}" var="dto">
								<tr>
									<td>
										<select class="btn btn-default today_end_filter" filter="${dto.work_sort}">
											<option value="sort">구분</option>
											<option value="new">신규</option>
											<option value="cancel">해지</option>
											<option value="test">테스트</option>
											<option value="substitution">대체</option>
											<option value="lineChange">회선변경</option>
											<option value="block">차단</option>
											<option value="defence">방어</option>
											<option value="disorder">장애</option>
											<option value="accounting">과금</option>
											<option value="request">요청</option>
											<option value="addService">부가 서비스</option>						
										</select>
									</td>
									<td><input type="text"  value="${dto.client_name}"></td>
									<td><input type="text" value="${dto.work_content}"></td>
									<td><input type="date" value="${dto.work_check_date}"></td>
									<td><input type="date" value="${dto.work_end_date}"></td>
									<td>
										<select class="btn btn-default today_going_filter" filter="${dto.work_status}">
											<option value="end">완료</option>
											<option value="delay">연장</option>
											<option value="ongoing">진행중</option>
										</select>
									</td>
									<td><input id="mName" type="text" value="${dto.work_manager}"></td>
									<td>
										<button class="btn btn-info modifyBtn" url=businessGEModify value="${dto.num }">수정</button>
									</td>
								</tr>			
							</c:forEach>
						</tbody>
						<tfoot>
						</tfoot>
					</table>
				</div>
				<!-- table-responsive -->
				
				<!--  전달 사항 작성 -->
				<div class="row">
					<div class="col-lg-12">
						<p class="text-left">
							<h4>전달 사항 작성</h4>
						</p>
					</div>
					<!-- col-lg-12 -->
				</div>
				<!-- row -->
				<div class="table-responsive">
					<form name="frm1" action="businessDeliveryWrite.bus" method="post" onsubmit="return validateCheck();">
						<input type="hidden" class="token" name="token">
						<table class="table table-bordered table-hover table-striped">
							<thead>
								<tr>
									<td>구분</td>
									<td>고객명</td>
									<td width="300">전달사항</td>
									<td>확인날짜</td>
									<td>마감일</td>
									<td>상태</td>
									<td>담당자</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>
										<select name="delivery_sort" id="delivery_sort">
											<option value="sort">구분</option>											
											<option value="all">전체</option>
											<option value="each">개별</option>											
										</select>
									</td>				
									<td>
										<input type="text" name="client_name" id="client_name"/>
									</td>
									<td>
										<input type="text" name="delivery_content" id="delivery_content"/>
									</td>
									<td>
										<input type="date" name="delivery_check_date" id="delivery_check_date"/>
									</td>
									<td>
										<input type="date" name="delivery_end_date" id="delivery_end_date"/>
									</td>
									<td>
										<select name="delivery_status" id="delivery_status">
											<option value="ongoing">진행중</option>
											<option value="delay">연기</option>
											<option value="end">마감</option>											
										</select>
									</td>
									<td>
										<input type="text" name="delivery_manager" id="delivery_manager" value="${member.name }"/>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="7">				
										<input class="btn btn-outline btn-primary" type="submit" name="save" value="저장">	
										<input class="btn btn-outline btn-danger" type="button" name="clear" value="삭제" onclick="clearForm2()">
									</td>
								</tr>
							</tfoot>
						</table>
					</form>
				</div>
				<!-- table-responsive -->
				
				<!-- 전달사항 작성 -->
				<!-- table-responsive -->
				
				<div class="row">
					<div class="col-lg-12">
						<p class="text-left">
							<h4>업무내용 작성</h4>
						</p>
					</div>
					<!-- col-lg-12 -->
				</div>
				<!-- row -->
				<div class="table-responsive">
					<form name="frm" action="businessWrite.bus" method="post" onsubmit="return validateCheck1();">
						<input type="hidden" class="token" name="token">
						<table class="table table-bordered table-hover table-striped">
							<thead>
								<tr>
									<td>구분</td>
									<td>고객명</td>
									<td width="300">업무 내용</td>
									<td>확인날짜</td>
									<td>마감일</td>
									<td>상태</td>
									<td>담당자</td>
								</tr>
							</thead>
							<tbody>
								<tr>
									<td>
										<select name="work_sort" id="work_sort">
											<option value="sort">구분</option>
											<option value="new">신규</option>
											<option value="cancel">해지</option>
											<option value="test">테스트</option>
											<option value="substitution">대체</option>
											<option value="lineChange">회선변경</option>
											<option value="block">차단</option>
											<option value="defence">방어</option>
											<option value="disorder">장애</option>
											<option value="accounting">과금</option>
											<option value="request">요청</option>
											<option value="addService">부가 서비스</option>											
										</select>
									</td>				
									<td>
										<input type="text" name="client_name" id="client_name1"/>
									</td>
									<td>
										<input type="text" name="work_content" id="work_content"/>
									</td>
									<td>
										<input type="date" name="work_check_date" id="work_check_date"/>
									</td>
									<td>
										<input type="date" name="work_end_date" id="work_end_date"/>
									</td>
									<td>										
										<select name="work_status" id="work_status">
											<option value="ongoing">진행중</option>
											<option value="delay">연기</option>
										</select>
									</td>
									<td>
										<input type="text" name="work_manager" id="work_manager" value="${member.name }"/>
									</td>
								</tr>
							</tbody>
							<tfoot>
								<tr>
									<td colspan="7">				
										<input class="btn btn-outline btn-primary" type="submit" name="save" value="저장">	
										<input class="btn btn-outline btn-danger" type="button" name="clear" value="삭제" onclick="clearForm()">
									</td>
								</tr>
							</tfoot>
						</table>
					</form>
				</div>
				<!-- table-responsive -->
			</div>
			<!-- panel-body -->
		</div>
		<!-- panel panel-default -->
	</div>
	<!-- col-lg-12 -->
</div>
<!-- row -->
<!-- /#page-wrapper -->
