<%@ 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="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@ taglib prefix="ec" uri="/WEB-INF/tld/ecnet_tld.tld"%>

<!DOCTYPE html>
<html lang="ko">
<head>
	<meta charset="UTF-8">
	<title>문자발송 전송 Agent 상태 관리</title>
	<script type="text/javascript">
	$(document).ready(function(){
		console.log("조회 조건==========="+ "${searchVO.searchUseYn } "  ) ; 
		
	});
	
	// 	
	
	function fn_search(){
		var listForm = document.listForm ;
		listForm.action = "<c:url value='/let/mjo/msgagent/selectMjonMsgAgentStsMultiList.do'/>";
		listForm.submit();

	}	
	
	
	// 일괄 일괄변경
	function setMassEdit() {
		console.log("inputAgentRate listForm.serialize: " + $("#listForm").serialize()) ;

	 	var varRepAgents = document.listForm.repAgents;
    	var varAgentCodes = document.listForm.agentCodes;
    	var varMsgTypes = document.listForm.msgTypes;	    
    	var varUseYns = document.listForm.useYns;    	
    	var varSendRates = document.listForm.sendRates;    	
		console.log(" varRepAgents.length :" + varRepAgents.length  ) ;
		var totSendRateS = 0 ; // 단문 전송비율 총합 
		var totSendRateP = 0 ; // 그림 전송비율 총합		
		var totSendRateL = 0 ; // 장문 전송비율 총합		
		var repAgentYnS = "N" ; // 대표전송사여부 (사용으로 선택된 전송사 중에 있어야 함 )
		var repAgentYnP = "N"; // 대표전송사여부 (사용으로 선택된 전송사 중에 있어야 함 )
		var repAgentYnL = "N" ; // 대표전송사여부 (사용으로 선택된 전송사 중에 있어야 함 )		
		
        for(var i=0; i < agentCodes.length; i++) {
			var mainUseYn = varUseYns[i].value ;				
			var mainSendRate = varSendRates[i].value ;			
			var mainMsgType = varMsgTypes[i].value ;			

			if (mainUseYn=="Y" & mainMsgType=="S")  // 단문 전송비율 합 구하기 
			{
				console.log(" i :" + i ) ;				
				console.log(" mainMsgType :" + mainMsgType ) ;				
				console.log(" varAgentCodes[i].value :" + varAgentCodes[i].value  ) ;				
				console.log(" mainSendRate :" + mainSendRate  ) ;				
				totSendRateS = totSendRateS + Number(mainSendRate) ;  		
				console.log(" totSendRateS :" + totSendRateS  ) ;					
			} else  if (mainUseYn=="Y" & mainMsgType=="P")  // 그림 전송비율 합 구하기 
			{
				console.log(" i :" + i ) ;				
				console.log(" mainMsgType :" + mainMsgType ) ;				
				console.log(" varAgentCodes[i].value :" + varAgentCodes[i].value  ) ;				
				console.log(" mainSendRate :" + mainSendRate  ) ;				
				totSendRateP = totSendRateP + Number(mainSendRate) ;  		
				console.log(" totSendRateP :" + totSendRateP  ) ;					
			} if (mainUseYn=="Y" & mainMsgType=="L")  // 장문 전송비율 합 구하기 
			{
				console.log(" i :" + i ) ;				
				console.log(" mainMsgType :" + mainMsgType ) ;				
				console.log(" varAgentCodes[i].value :" + varAgentCodes[i].value  ) ;				
				console.log(" mainSendRate :" + mainSendRate  ) ;				
				totSendRateL = totSendRateL + Number(mainSendRate) ;  		
				console.log(" totSendRateL :" + totSendRateL  ) ;					
			}

        	
			
			// 대표전송사 선택값 단문/그림/장문 별로 일괄 세팅 
			// (대표전송사 라디오버튼 이름을 다르게 명명해야 동작해야 되서 다른이름으로 명명 후 네이밍 규칙을 따라 순환하면서 hidden 대표전송사 값에 세팅)
	 		var varRepAgent = $('#repAgent_'+varAgentCodes[i].value+'_'+varMsgTypes[i].value).val();		// 사용비율
	 		if ($('#repAgent_'+varAgentCodes[i].value+'_'+varMsgTypes[i].value).is(':checked') )  // 대표전송사 선택 된 대표전송사 코드 수정  
			{
	          	for(var j=0; j < agentCodes.length; j++) {
		          	if (mainMsgType == varMsgTypes[j].value )
		          		{
			              	console.log("i: " + i +  " varRepAgent :" + varRepAgent) ;		            		
			               	console.log(" ===sub varMsgTypes[i] :" + varMsgTypes[i].value) ;
			               	console.log(" ===sub varAgentCodes[i] :" + varAgentCodes[i].value) ;
			               	console.log(" ===sub varMsgTypes[j] :" + varMsgTypes[j].value) ;
			               	console.log(" ===sub varAgentCodes[j] :" + varAgentCodes[j].value) ;
			               	varRepAgents[j].value = varRepAgent ; 
		          		}
	          	}
	          	
	          	if (mainMsgType== "S" && mainUseYn == "Y" )
	          	{
	          		repAgentYnS = "Y" ; 	
	          	} else  if (mainMsgType== "L" && mainUseYn == "Y" )
	          	{
	          		repAgentYnL = "Y" ; 	
	          	} else if (mainMsgType== "P" && mainUseYn == "Y")
	          	{
	          		repAgentYnP = "Y" ; 	
	          	}
	          	
			} 
		}
		
		
		// 대표전송사 유무 체크
		
		
		console.log( $("sssss" + '#searchUseYn').value)  ;
		if ( "${searchVO.searchUseYn}"  != "N" )
       	{
			// 대표전송사 유무 체크 
			
			if(repAgentYnS == "N" ){
				alert("단문의 대표전송사가 선택되지 않았습니다. \n 사용여부 값이 '사용'인 대표전송사(단문)를 선택해 주시기 바랍니다.")
				return;
			}		
			if(repAgentYnL == "N" ){
				alert("장문의 대표전송사가 선택되지 않았습니다. \n 사용여부 값이 '사용'인 대표전송사(장문)를 선택해 주시기 바랍니다.")
				return;
			}		
			if(repAgentYnP == "N" ){
				alert("그림문자의 대표전송사가 선택되지 않았습니다. \n 사용여부 값이 '사용'인 대표전송사(그림문자)를 선택해 주시기 바랍니다.")
				return;
			}		

			
			
			
			// 문자발송율 체크 
				if(totSendRateS > 100 ){
					alert("문자발송율(단문) 총 합이 100%  초과입니다. (총 합: " + totSendRateS + "%)\n 문자발송율(단문)을 100%가 되도록 맞춰주시기 바랍니다.")
					return;
				} else if(totSendRateS < 100 ){
					alert("문자발송율(단문) 총 합이 100% 미만입니다. (총 합: " + totSendRateS + "%)\n 문자발송율(단문)을 100%가 되도록 맞춰주시기 바랍니다.")
					return;
				} 
				
				
				if(totSendRateL > 100 ){
					alert("문자발송율(장문) 총 합이 100%  초과입니다. (총 합: " + totSendRateL + "%)\n 문자발송율(장문)을 100%가 되도록 맞춰주시기 바랍니다.")
					return;
				} else if(totSendRateL < 100 ){
					alert("문자발송율(장문) 총 합이 100% 미만입니다. (총 합: " + totSendRateL + "%)\n 문자발송율(장문)을 100%가 되도록 맞춰주시기 바랍니다.")
					return;
				} 
	   
	
			if(totSendRateP > 100 ){
				alert("문자발송율(그림문자) 총 합이 100%  초과입니다. (총 합: " + totSendRateP + "%)\n 문자발송율(그림문자)을 100%가 되도록 맞춰주시기 바랍니다.")
				return;
			} else if(totSendRateP < 100 ){
				alert("문자발송율(그림문자) 총 합이 100% 미만입니다. (총 합: " + totSendRateP + "%)\n 문자발송율(그림문자)을 100%가 되도록 맞춰주시기 바랍니다.")
				return;
			} 				

    	}
		
		 
		if(!confirm("일괄변경 하시겠습니까?")) {
 
			return;
		}
		console.log("inputAgentRate 2: " + document.listForm.inputAgentRate ) ;
		$.ajax({
	        type: "POST",
	        url: "/letter/photo/updateMultiMjonMsgAgentStsDataAjax.do",
	        data: $("#listForm").serialize(),
	        dataType:'json',
	        async: false,
	        success: function (data) {
	        	console.log(data);
				if (data.isSuccess) { 
					alert("저장 완료했습니다.");
					location.reload();
				} 
				else {
					alert("data.isSuccess Not Msg : " + data.msg);
				}
			},
	        error: function (e) { 
	         	console.log("data===" + JSON.stringify(e) + "=== end ===")
	        	alert("ERROR : " + JSON.stringify(e)); 
	        }
	    });				
	}	
	
	
	function doUpdate(agentCode, type) {
		var form = document.modiForm;
		var updtYn = $('#useYn_'+agentCode+'_'+type).val();					// 사용여부
		var agentRate = $('#agentRate_'+agentCode+'_'+type).val();			// 사용비율
		var repAgent = $('input[name="repAgent_'+type+'"]:checked').val();	// 대표전송사 설정
		var agentPrice = $('#agentPrice_'+agentCode+'_'+type).val();		// 사용비율
		
		form.agentCode.value = agentCode;
		form.sendRate.value = agentRate;
		form.useYn.value = updtYn;
		form.msgType.value = type;
		form.repAgent.value = repAgent;
		form.agentPrice.value = agentPrice;
		
		form.action = "/let/mjo/msgagent/updateMjonMsgAgentStsData.do";

		// 비활성화 상태 적용전에 대표전송사 여부 확인
		if(updtYn == "N"){
			
			if(repAgent == agentCode){
				alert("대표전송사는 미사용으로 변경이 불가능 합니다. \n대표전송사를 변경 후 진행해 주세요")
				return;
			}
			
		}
		
		if (!confirm('수정 후 문자타입별 전송사 배분률이 100%가 되어야 합니다. \n수정하시겠습니까? ')) 
			return;
		
		form.submit();
	}
	
	function doInsert(){
		
		var form = document.modiForm;
		var agentCode = $("#selectAgentCode").val();
		var msgType = $("#selectMsgType").val();
		var agentRate = $("#inputAgentRate").val();

		
		if(agentRate == ""){
			alert("문자발송 비율을 입력해주세요");
			$("#inputAgentRate").focus();
			return false;
		}
		
		if (!confirm('등록하시겠습니까?')){
			return false;
		} 
		
		form.agentCode.value = agentCode;
		form.msgType.value = msgType;
		form.sendRate.value = agentRate;
		
		// 			url : "<c:url value='/let/mjo/msgagent/insertMjonMsgAgentStsDataAjax.do'/>"
		var data = new FormData(form);
		$.ajax({
			url : "<c:url value='/let/mjo/msgagent/insertMjonMsgAgentStsDataAjax.do'/>"
			, type : 'POST'
			, data : data
			, dataType:'json'
			, async: false
			, processData: false
			, contentType: false
			, cache: false
			, success: function (returnData, status) {
				if(returnData.result == "fail") {//차단 발신번호인 경우 등록 불가
					alert(returnData.message);
					return false;
				}else{
					window.location.reload()
				}
			}
			,error : function(request , status, error){
				alert("code:"+request.status+"\n"+"message:"+request.responseText+"\n"+"error:"+error);
			}
		});
	}
	
	function doUpdateConf(confCodeId) {
		var form = document.confForm;
		var confCode = $("#confCode").val();
		
		
		if (!confirm('문자, 알림톡 사용자화면 발송 사용여부가 변경됩니다.\n긴급 시스템작업시에만 사용해주세요.\n수정 하시겠습니까?')){
			return false;
		}
		
		form.confCodeId.value = confCodeId;
		form.confCode.value = confCode;
		
		var data = new FormData(form);
		$.ajax({
			url : "<c:url value='/let/mjo/conf/updateMjonConfAjax.do'/>"
			, type : 'POST'
			, data : data
			, async: false
			, processData: false
			, contentType: false
			, cache: false
			, success: function (returnData, status) {
				console.log("=== data:" + data) ; 
				if(returnData.result == "fail") {
					alert(returnData.message);
					return false;
				}else{
					alert("수정 완료하였습니다.");
				}
			}
			,error: function (e) { alert("저장에 실패하였습니다."); console.log("ERROR : ", e); }
		});
	}
	
	</script>
	
	<style>
		.maxWth {max-width: 1100px !important;}
 
	</style>
</head>
<body>
	<form id="modiForm" name="modiForm" method="post">
		<input type="hidden" id="agentCode" name="agentCode" value=""/>	<!-- 전송사 코드 -->
		<input type="hidden" id="msgType" name="msgType" value=""/>		<!-- 메세지 타입(단문, 장문, 그림) -->
		<input type="hidden" id="sendRate" name="sendRate" value=""/>	<!-- 전송비율 -->
		<input type="hidden" id="useYn" name="useYn" value=""/>			<!-- 사용여부 -->
		<input type="hidden" id="repAgent" name="repAgent" value=""/>	<!-- 대표전송사 -->
		<input type="hidden" id="agentPrice" name="agentPrice" value=""/>	<!-- 전송사 단가 -->
	</form>
	<form name="confForm" id="confForm" method="post">
		<input type="hidden" name="confCodeId" value="" />
		<input type="hidden" name="confCode" value="" />
	</form>

	<form id="listForm" name="listForm" method="post">		
	<div class="contWrap">
		<div class="pageTitle">
			<div class="pageIcon"><img src="/pb/img/pageTitIcon4.png" alt=""></div>
			<h2 class="titType1 c_222222 fwBold">문자발송 전송 Agent 상태 관리</h2>
			<p class="tType6 c_999999">문자발송 전송 Agent 상태 관리 페이지 입니다.</p>
		</div>
		<div class="pageCont">
			<div class="listTop maxWth">
				<span class="tType4 color_blue fwBold">
					<p>문자 발송율은 총 합이 100%가 되도록 맞춰주시기 바랍니다.</p>
				</span>
			</div>
			<div class="tableWrap maxWth">
				<table class="tbType2">
					<colgroup>
						<col width="30%">
						<col width="*">
					</colgroup>
					<tbody>
						<tr>
							<th>

									<select id="selectAgentCode" name="selectAgentCode">
										<c:forEach var="result" items="${frwrdAgent}" varStatus="status">
											<option value="${result.code}"><c:out value='${result.codeNm}'/></option>
										</c:forEach>
									</select>

							</th>
							<td>
								문자종류&nbsp;:&nbsp; 
								<select id="selectMsgType" name="selectMsgType">
									<option value="S">단문</option>
									<option value="L">장문</option>
									<option value="P">그림</option>
								</select>
								<input type="number" id="inputAgentRate" name="inputAgentRate" value="" style="width:20px;"/>
								&nbsp;% &nbsp;&nbsp;
								<input type="button" class="btnType1" value="추가" onclick="javascript:doInsert(); return false;">
							</td>
						</tr>
					</tbody>
				</table>
			</div>
			
			<br><br />
			<div class="listTop maxWth">
				<span class="tType4 c_e40000 fwBold">
					<p>문자, 알림톡 발송 사용여부 - 문자, 알림톡 사용자화면 발송 사용여부(주의)</p>
				</span>
			</div>
			<div class="tableWrap maxWth">
				<table class="tbType2">
					<colgroup>
						<col width="30%">
						<col width="*">
					</colgroup>
					<tbody>
						<tr>
							<th>
								문자, 알림톡 발송 사용여부
							</th>
							<td>
								<ec:select codeId="CONF01" name="confCode" id="confCode" css="class='select'" selectedValue="${confVO.confCode}" />
								<input type="button" class="btnType1" value="수정" onclick="javascript:doUpdateConf('CONF01'); return false;">
							</td>
						</tr>
					</tbody>
				</table>
			</div>
			<br>
			<!--  
			<div class="listSerch">
				<select id="searchYear" name="searchYear" onchange="linkPage();"></select>
			</div>			
			
			-->
			<br /><br />
			<div class="listTop maxWth">
					<p class="tType5" style="margin-bottom: 0px;">단문</p>

					<select id="searchUseYn" name="searchUseYn" onchange="fn_search();" style="float: right;">
							<option value="-" <c:if test="${searchVO.searchUseYn == ''}">selected</c:if> >전체</option>				
							<option value="Y" <c:if test="${searchVO.searchUseYn == 'Y'}">selected</c:if> >사용</option>
							<option value="N" <c:if test="${searchVO.searchUseYn == 'N'}">selected</c:if> >미사용</option>
					</select>
			</div>			
			<div class="tableWrap maxWth">
				<table class="tbType2">
					<colgroup>
						<col width="30%">
						<col width="15%">
						<col width="*">
					</colgroup>
					<tbody>
						<c:forEach var="result" items="${agentList}" varStatus="status">

						
						<c:if test="${result.msgType eq 'S'}">
							<tr>
								<th>
									<input type="hidden" id="agentCodes" name="agentCodes" value="${result.agentCode}"/>		<!-- 메세지 타입(단문, 장문, 그림) -->								
									<input type="hidden" id="msgTypes" name="msgTypes" value="${result.msgType}"/>		<!-- 메세지 타입(단문, 장문, 그림) -->									
									<input type="hidden" id="repAgents" name="repAgents" value="${result.repAgent}"/>											
								
									<c:forEach var="frwrdAgent" items="${frwrdAgent}" varStatus="status">
										<c:if test="${result.agentCode eq frwrdAgent.code }">
											<span style="flat:left;line-height:42.5px;">
												<c:out value='${frwrdAgent.codeNm}'/>
											</span>
										</c:if>
									</c:forEach>
									<span style="float:right;">
											단가 : <input type="text" style="width:50px;min-width:auto;padding:0 10px;" id="agentPrices" name="agentPrices" value='${result.agentPrice}' /> 원
									</span>
								</th>
								<td>
									<c:choose>
										<c:when test="${result.agentCode == '01'}">
											<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="01" <c:if test="${result.repAgent eq '01'}">checked="checked"</c:if>/>
											<label for="">대표전송사</label>
										</c:when>
										<c:when test="${result.agentCode == '02'}">
											<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="02" <c:if test="${result.repAgent eq '02'}">checked="checked"</c:if>/>
											<label for="">대표전송사</label>
										</c:when>
										<c:when test="${result.agentCode == '03'}">
											<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="03" <c:if test="${result.repAgent eq '03'}">checked="checked"</c:if>/>
											<label for="">대표전송사</label>
										</c:when>
										<c:when test="${result.agentCode == '04'}">
											<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="04" <c:if test="${result.repAgent eq '04'}">checked="checked"</c:if>/>
											<label for="">대표전송사</label>
										</c:when>
										<c:when test="${result.agentCode == '05'}">
											<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="05" <c:if test="${result.repAgent eq '05'}">checked="checked"</c:if>/>
											<label for="">대표전송사</label>
										</c:when>
										<c:when test="${result.agentCode == '07'}">
											<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="07" <c:if test="${result.repAgent eq '07'}">checked="checked"</c:if>/>
											<label for="">대표전송사</label>
										</c:when>
									</c:choose>
								</td>
								<td>
									<select id="useYns" name="useYns">
										<option value="Y" <c:if test="${result.useYn == 'Y'}">selected</c:if> >사용</option>
										<option value="N" <c:if test="${result.useYn == 'N'}">selected</c:if> >미사용</option>
									</select>
									<input type="text"  id="sendRates" name="sendRates" value="${result.sendRate}" style="width:20px;" />&nbsp;% &nbsp;&nbsp;
								</td>
							</tr>
						</c:if>
						</c:forEach>
					</tbody>
				</table>
			</div>
			
			<br /><br />
			<div class="listTop maxWth" style="margin-bottom: 10px;">
				<p class="tType5">장문</p>
			</div>
			<div class="tableWrap maxWth">
				<table class="tbType2">
					<colgroup>
						<col width="30%">
						<col width="15%">
						<col width="*">
					</colgroup>
					<tbody>
						<c:forEach var="result" items="${agentList}" varStatus="status">
							<c:if test="${result.msgType eq 'L'}">
								<tr>
									<th>
										<input type="hidden" id="agentCodes" name="agentCodes" value="${result.agentCode}"/>		<!-- 메세지 타입(단문, 장문, 그림) -->								
										<input type="hidden" id="msgTypes" name="msgTypes" value="${result.msgType}"/>		<!-- 메세지 타입(단문, 장문, 그림) -->									
										<input type="hidden" id="repAgents" name="repAgents" value="${result.repAgent}"/>		
																		
										<c:forEach var="frwrdAgent" items="${frwrdAgent}" varStatus="status">
											<c:if test="${result.agentCode eq frwrdAgent.code }">
												<span style="flat:left;line-height:42.5px;"><c:out value='${frwrdAgent.codeNm}'/></span>
											</c:if>
										</c:forEach>
										<span style="float:right;">
											단가 : <input type="text" style="width:50px;min-width:auto;padding:0 10px;" id="agentPrices" name="agentPrices" value='${result.agentPrice}' /> 원
										</span>
									</th>
									<td>
										<c:choose>
											<c:when test="${result.agentCode == '01'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="01" <c:if test="${result.repAgent eq '01'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '02'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="02" <c:if test="${result.repAgent eq '02'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '03'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="03" <c:if test="${result.repAgent eq '03'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '04'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="04" <c:if test="${result.repAgent eq '04'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '05'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="05" <c:if test="${result.repAgent eq '05'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '07'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="07" <c:if test="${result.repAgent eq '07'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
										</c:choose>
									</td>
									<td>
									<select id="useYns" name="useYns">
										<option value="Y" <c:if test="${result.useYn == 'Y'}">selected</c:if> >사용</option>
										<option value="N" <c:if test="${result.useYn == 'N'}">selected</c:if> >미사용</option>
									</select>
									<input type="text"  id="sendRates" name="sendRates" value="${result.sendRate}" style="width:20px;" />&nbsp;% &nbsp;&nbsp;									
									</td>
								</tr>
							</c:if>
						</c:forEach>
					</tbody>
				</table>
			</div>
			
			<br /><br />
			<div class="listTop maxWth" style="margin-bottom: 10px;">
				<p class="tType5">그림</p>
			</div>
			<div class="tableWrap maxWth">
				<table class="tbType2">
					<colgroup>
						<col width="30%">
						<col width="15%">						
						<col width="*">
					</colgroup>
					<tbody>
						<c:forEach var="result" items="${agentList}" varStatus="status">
							<c:if test="${result.msgType eq 'P'}">
								<tr>
									<th>
										<input type="hidden" id="agentCodes" name="agentCodes" value="${result.agentCode}"/>		<!-- 메세지 타입(단문, 장문, 그림) -->								
										<input type="hidden" id="msgTypes" name="msgTypes" value="${result.msgType}"/>		<!-- 메세지 타입(단문, 장문, 그림) -->									
										<input type="hidden" id="repAgents" name="repAgents" value="${result.repAgent}"/>
									
										<c:forEach var="frwrdAgent" items="${frwrdAgent}" varStatus="status">
											<c:if test="${result.agentCode eq frwrdAgent.code }">
												<span style="flat:left;line-height:42.5px;"><c:out value='${frwrdAgent.codeNm}'/></span>
											</c:if>
										</c:forEach>
										<span style="float:right;">
											단가 : <input type="text" style="width:50px;min-width:auto;padding:0 10px;" id="agentPrices" name="agentPrices" value='${result.agentPrice}' /> 원
										</span>
									</th>
									<td>
										<c:choose>
											<c:when test="${result.agentCode == '01'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="01" <c:if test="${result.repAgent eq '01'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '02'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="02" <c:if test="${result.repAgent eq '02'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '03'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="03" <c:if test="${result.repAgent eq '03'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '04'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="04" <c:if test="${result.repAgent eq '04'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '05'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="05" <c:if test="${result.repAgent eq '05'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
											<c:when test="${result.agentCode == '07'}">
												<input type="radio" name="repAgent_<c:out value='${result.msgType}'/>" id="repAgent_<c:out value='${result.agentCode}'/>_<c:out value='${result.msgType}'/>" value="07" <c:if test="${result.repAgent eq '07'}">checked="checked"</c:if>/>
												<label for="">대표전송사</label>
											</c:when>
										</c:choose>
									</td>
									<td>
									<select id="useYns" name="useYns">
										<option value="Y" <c:if test="${result.useYn == 'Y'}">selected</c:if> >사용</option>
										<option value="N" <c:if test="${result.useYn == 'N'}">selected</c:if> >미사용</option>
									</select>
									<input type="text"  id="sendRates" name="sendRates" value="${result.sendRate}" style="width:20px;" />&nbsp;% &nbsp;&nbsp;
									</td>
								</tr>
							</c:if>
						</c:forEach>
					</tbody>
				</table>
			</div>
			<div class="btnWrap maxWth right">
				<input type="button" class="btnType1 large btnType fill primary" value="수정" onclick="javascript:setMassEdit(); return false;">
			</div>			
		</div>
	</div>
</form>			
</body>
</html>