<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout"
      layout:decorate="~{admin/layout/layout}" th:with="title='',active='home'">
<th:block layout:fragment="html_head">
	<script>
		$(document).ready(function () {
			for(i=0.0; i<100.0; i = Math.round((i + 0.1) * 10) / 10) {
				$("#siteCreditRate").append('<option value="'+i+'">'+i+'%</option>');
			}
		})
		
		function siteAdd(){
			
			if($('#sitePass').val()==""){alert("에이전시명을 입력하세요.");return false;}
			if($('#siteId').val()==""){alert("아이디를 입력하세요.");return false;}
			if($('#sitePass').val()=="" || $('#sitePass').val() != $('#sitePasstmp').val() ){alert("비밀번호를 입력하세요.");return false;}
			
			
			if(confirm("생성하시겠습니까?")){	
				
				
				
	        	 $.ajax({
	     			type : "post",
	     			url : "/agent/addProc",
	     			data : {
	     				siteId:$('#siteId').val(),
	     				siteName:$('#siteName').val(),
	     				sitePass:$('#sitePass').val(),
	     				siteMobile:$('#siteMobile').val(),
	     				siteType:$('#siteType').val(),	   
	     				siteLevel:$('#siteLevel').val(),	     	
	     				siteGubun:$('#siteGubun').val(),	     	
	     				siteMaxCredit:$('#siteMaxCredit').val(),
	     				siteCreditRate:$('#siteCreditRate').val(),
	     				memo:$('#memo').val()
	     				
	     			},
	     			async : false,
	     			dataType : "json",
	     			success : function(data) {
	     				if(data.RES=="SUCCESS"){
	     					
	     					alert("등록완료");
	     					location.href = "/agent";
	     				}else{
	     					
	     				}
	     				
	     			}
	     		});
			
			}
		}
	
	</script>

</th:block>

<th:block layout:fragment="content">

            
<div class="container-fluid">
              <div class="page-name">
                  <h1>에이전시 생성</h1>
              </div>

              <div class="table">
                <div class="body">                  
                  <div class="table-responsive">
                  	<div class="head"><h6>에이전시 정보</h6></div>
                    <table>
                      <colgroup>
                        <col width="30%">
                        <col width="70%">
                      </colgroup>
                      <tbody>
                        <tr>
                          <th>에이전트명</th>
                          <td>
                            <div><input type="text" id="siteName" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>아이디</th>
                          <td>
                            <div><input type="text" id="siteId" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>비밀번호</th>
                          <td>
                            <div><input type="password" id="sitePass" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>비밀번호 확인</th>
                          <td>
                            <div><input type="password" id="sitePasstmp" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>단계</th>
                          <td>
                            <div>
                            	<select class="select" id="siteLevel">
                            		<option th:value="${loginSite.siteLevel+1}" th:text="${loginSite.siteLevel+1}">에이전시</option>
                            	</select>
							</div>
                          </td>                          
                        </tr>
                        <tr>
                          <th>분류</th>
                          <td>
                            <div>
                            	<select class="select" id="siteGubun">
                            		<option value="NA" >Normal Agency</option>
                            		<option value="IA" >Insure Agency</option>
                            	</select>
							</div>
                          </td>                          
                        </tr>
                        <tr>
                          <th>타입</th>
                          <td>
                            <div>
                            	<select class="select" id="siteType">
                            		<option value="Ota" >Operator Agency</option>
                            		<option value="Ppa" >Paper Agency</option>
                            	</select>
							</div>
                          </td>                          
                        </tr>
                        <tr>
                          <th>연락처</th>
                          <td>
                            <div><input type="text" id="siteMobile" class="input" ></div>
                          </td>
                        </tr>
                      </tbody>
                    </table>
                  </div>
                </div>  
              </div>      
              <div class="table">
                <div class="body">                  
                  <div class="table-responsive">    
                    <div class="head"><h6>에이전시 잔고</h6></div>
                    <table>
                      <colgroup>
                        <col width="30%">
                        <col width="70%">
                      </colgroup>
                      <tbody>                        
                        <tr style="display:none">
                          <th>에이전트 한도</th>
                          <td>
                            <div><input type="text" id="siteMaxCredit" class="input" value=0></div>
                          </td>
                        </tr>
                        <tr>
                          <th>수수료율(%)</th>
                          <td>
                            <div>
                            	<select class="select" id="siteCreditRate" >
                            		
                            	</select>
							</div>
                          </td>                          
                        </tr>                        
                      </tbody>
                    </table>                 
                  </div>
                </div>
              </div>
              <div class="btnwrap">
                <a class="btn" href="javascript:siteAdd()"><i class="fas fa-plus fa-sm"></i> 등록하기</a>
              </div>                  
            </div><!-- container-fluid -->
            
            
            
            
            
            <!--div class="container-fluid">
              <div class="page-name">
                  <h1>에이전시 생성</h1>
              </div>

              <div class="table">
                <div class="body">                  
                  <div class="table-responsive">
                  	<h4 class="h4">에이전시 정보</h4>
                    <table>
                      <colgroup>
                        <col width="30%">
                        <col width="70%">
                      </colgroup>
                      <tbody>
                        <tr>
                          <th>에이전시명</th>
                          <td>
                            <div><input type="text" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>아이디</th>
                          <td>
                            <div><input type="text" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>비밀번호</th>
                          <td>
                            <div><input type="text" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>비밀번호 확인</th>
                          <td>
                            <div><input type="text" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>등급</th>
                          <td>
                            <div>
                            	<select class="select">
                            		<option>에이전시</option>
                            	</select>
							</div>
                          </td>                          
                        </tr>
                        <tr>
                          <th>연락처</th>
                          <td>
                            <div><input type="text" class="input" ></div>
                          </td>
                        </tr>
                      </tbody>
                    </table>  
                    <h4 class="h4">에이전시 잔고</h4>
                    <table>
                      <colgroup>
                        <col width="30%">
                        <col width="70%">
                      </colgroup>
                      <tbody>                        
                        <tr>
                          <th>에이전시 한도</th>
                          <td>
                            <div><input type="text" class="input" ></div>
                          </td>
                        </tr>
                        <tr>
                          <th>수수료율(%)</th>
                          <td>
                            <div>
                            	<select class="select">
                            		<option>에이전시</option>
                            	</select>
							</div>
                          </td>                          
                        </tr>                        
                      </tbody>
                    </table>                 
                  </div>
                </div>
              </div>
              <div class="btnwrap">
                <a class="btn"><i class="fas fa-plus fa-sm"></i> 등록하기</a>
              </div>                  
            </div><!- container-fluid -->
            
            
            
            
</th:block>