<!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>
	function keyUpdate(){
		
		if(confirm("키를 재발급합니다. 기존키는 사용할수 없습니다")){

			 $.ajax({
		 			type : "post",
		 			url : "/mypage/siteUpdate",
		 			data : {
		 				siteKey:"new"
		 			},
		 			async : true,
		 			dataType : "json",
		 			success : function(data) {
		 				if(data.RES=="SUCCESS"){
		 					alert("변경완료");		
		 				//	location.href = location.href; 
		 					//$('#ciCreditAmt').val();
		 					$('#sitekey').val(data.DATA);
		 				}else{
		 					alert(data.MSG);
		 				
		 				}
		 			}
		 		});
		}
	}
	
	function ipUpdate(){
		
		if(confirm("허용 IP를 번경합니다 추가시 , 로 구분해주세요")){

			 $.ajax({
		 			type : "post",
		 			url : "/mypage/siteUpdate",
		 			data : {
		 				siteIp:$('#siteIp').val()
		 			},
		 			async : true,
		 			dataType : "json",
		 			success : function(data) {
		 				if(data.RES=="SUCCESS"){
		 					alert("변경완료");		
		 				//	location.href = location.href; 
		 					//$('#ciCreditAmt').val();
		 					$('#sitekey').val(data.DATA);
		 				}else{
		 					alert(data.MSG);
		 				
		 				}
		 			}
		 		});
		}
	}
	
	function cbUpdate(){
		
		if(confirm("기존를 CBURL을 번경합니다")){

			 $.ajax({
		 			type : "post",
		 			url : "/mypage/siteUpdate",
		 			data : {
		 				siteCbUrl:$('#siteCbUrl').val()
		 			},
		 			async : true,
		 			dataType : "json",
		 			success : function(data) {
		 				if(data.RES=="SUCCESS"){
		 					alert("변경완료");		
		 				//	location.href = location.href; 
		 					//$('#ciCreditAmt').val();
		 					$('#sitekey').val(data.DATA);
		 				}else{
		 					alert(data.MSG);
		 				
		 				}
		 			}
		 		});
		}
	}
	
function bankUpdate(){
		
		if(confirm("기존를 계좌번호를  번경합니다")){

			 $.ajax({
		 			type : "post",
		 			url : "/mypage/siteUpdate",
		 			data : {
		 				siteBankInfo:$('#siteBankInfo').val()
		 			},
		 			async : true,
		 			dataType : "json",
		 			success : function(data) {
		 				if(data.RES=="SUCCESS"){
		 					alert("변경완료");		
		 				//	location.href = location.href; 
		 					//$('#ciCreditAmt').val();
		 					$('#sitekey').val(data.DATA);
		 				}else{
		 					alert(data.MSG);
		 				
		 				}
		 			}
		 		});
		}
	}
	
	function passUpdate(){
		
		if($('#nowPass').val()=="" ||$('#newPass').val()=="" ||$('#newPass2').val()=="" ){
			alert("비밀번호를 입력하세요.");return;
		}
		
		if($('#newPass').val() != $('#newPass2').val()  ){
			alert("비밀번호를 확인해주세요.");return;
			
			
		}
		
		
		 $.ajax({
	 			type : "post",
	 			url : "/mypage/pwdUpdate",
	 			data : {
	 				nowPass:$('#nowPass').val(),
	 				newPass:$('#newPass').val(),
	 				newPass2:$('#newPass2').val()
	 			},
	 			async : true,
	 			dataType : "json",
	 			success : function(data) {
	 				if(data.RES=="SUCCESS"){
	 					alert("변경완료");		
	 				
	 				//	location.href = location.href; 
	 					//$('#ciCreditAmt').val();
	 				
	 				}else{
	 					alert(data.MSG);
	 				
	 				}
	 			}
	 		});
		
		
		
	}

</script>

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

            <div class="container-fluid">
              <div class="page-name">
                  <h1>설정 및 정보</h1>
              </div>

              <div class="table">
                <div class="head"><h6>기본 정보</h6></div>
                <div class="body">
                  <div class="table-responsive">
                    <table>
                      <colgroup>
                        <col width="30%">
                        <col width="70%">
                      </colgroup>
                      <tbody>
                            <tr>
                                <th>번호</th>
                                <td th:text="${mypageInfo.siteIdx}">1907</td>
                            </tr>
                            <tr>
                                <th>분류</th>
                                <td th:text="${mypageInfo.siteType}">총판</td>
                            </tr>
                            <tr>
                                <th>타입</th>
                                <td>병행</td>
                            </tr>
                            <tr>
                                <th>소속 에이전시</th>
                                <td class="selectFlex">
                                  <div class="tgBox">
                                    <a class="selectBox" th:text="${mypageInfo.upperSiteId}">토브로<em>@tobro</em></a>
                                    <div class="tgBoxcon">
                                      <ul>
                                        <li>에이전시</li>
                                        <li><a>수정</a></li>
                                        <li><a href="exchange.html">지급 내역</a></li>
                                        <li><a href="charge.html">충전 내역</a></li>
                                        <li><a href="agentqna.html">문의 내역</a></li>
                                      </ul>
                                      <ul>
                                        <li>유저</li>
                                        <li><a href="user.html">유저 목록</a></li>
                                        <li><a href="payments.html">지급 내역</a></li>
                                      </ul>
                                    </div>
                                  </div>
                                  <span class="selectRight">→</span>
                                  <div class="tgBox">
                                    <a class="selectBox bl" th:text="${mypageInfo.siteId}">no.1<em>@no.1</em></a>
                                    <div class="tgBoxcon">
                                      <ul>
                                        <li>에이전시</li>
                                        <li><a>수정</a></li>
                                        <li><a href="exchange.html">지급 내역</a></li>
                                        <li><a href="charge.html">충전 내역</a></li>
                                        <li><a href="agentqna.html">문의 내역</a></li>
                                      </ul>
                                      <ul>
                                        <li>유저</li>
                                        <li><a href="user.html">유저 목록</a></li>
                                        <li><a href="payments.html">지급 내역</a></li>
                                      </ul>
                                    </div>
                                  </div>
                                </td>
                            </tr>
                            <tr>
                                <th>아이디</th>
                                <td th:text="${mypageInfo.siteId}">no.1</td>
                            </tr>
                            <tr>
                                <th>닉네임</th>
                                <td th:text="${mypageInfo.siteName}">no.1</td>
                            </tr>
                            <tr>
                                <th>비밀번호</th>
                                <td><a class="btn modalBtn">비밀번호 변경</a></td>
                            </tr>
                            <tr>
                                <th>API KEY</th>
                                <td>
                                  <div><input type="text" id="sitekey" class="input" th:value="${mypageInfo.siteKey}" value="PJd0DgzomNIcoJmvC38TIz0T1AmpPQjz6Oyeyd4E" readonly=""><a class="inputbtn" href='javascript:keyUpdate()'>재발급</a></div>
                                  <span class="text">API KEY는 개발에 필요한 정보입니다. 개발자에게 전달해주세요.</span>
                                </td>
                            </tr>
                            <tr>
                                <th>API 호출 허용 IP 설정</th>
                                <td>
                                  <div><input type="text" id="siteIp" class="input" th:value="${mypageInfo.siteIp}" disabled/ ><!--<a class="inputbtn" href='javascript:ipUpdate()'>변경</a>--></div>
                                  <span class="text">IP주소는 운영자가 직접 변경/추가 할 수 없습니다.</span>
                                </td>
                            </tr>
                            <tr>
                                <th>Callback URL</th>
                                <td>
                                  <div><input type="text" id="siteCbUrl" class="input"  th:value="${mypageInfo.siteCbUrl}"  ><a class="inputbtn"  href='javascript:cbUpdate()'>변경</a></div>
                                  <span class="text">정확한 주소값을 전부 입력해주세요. (http 혹 https 사용인지 정확하게 입력)</span>
                                </td>
                            </tr>
                            <tr>
                                <th>계좌 번호</th>
                                <td>
                                  <div><input type="text" id="siteBankInfo" class="input" th:value="${mypageInfo.siteBankInfo}" ><a class="inputbtn" href='javascript:bankUpdate()'>변경</a></div>
                                </td>
                            </tr>
                            <tr>
                                <th>현재 보유 금액</th>
                                <td th:text="|${#numbers.formatInteger(mypageInfo.credit,0, 'COMMA')}  c|">0 c</td>
                            </tr>
                            <tr>
                                <th>하부 에이전시 현재 총 보유 금액</th>
                                <td th:text="|${#numbers.formatInteger(underSiteCredit,0, 'COMMA')}  c|">0 c</td>
                            </tr>                            
                            <tr>
                                <th>요율</th>
                                <td th:text="|${mypageInfo.siteCreditRate} %|">0 %</td>
                            </tr>
                            <tr>
                                <th>총 지급받은 금액</th>
                                <td th:text="|${#numbers.formatInteger(mypageInfo.aiCredit,0, 'COMMA')}  c|">0 C</td>
                            </tr>
                            <tr>
                                <th>총 충전받은 금액</th>
                                <td th:text="|${#numbers.formatInteger(mypageInfo.ciCredit,0, 'COMMA')}  c|">0 C</td>
                            </tr>
                            <tr>
                                <th>총 지급해준 금액</th>
                                <td th:text="|${#numbers.formatInteger(mypageInfo.aoCredit,0, 'COMMA')}  c|">0 C</td>
                            </tr>
                            <tr>
                                <th>총 충전해준 금액</th>
                                <td th:text="|${#numbers.formatInteger(mypageInfo.coCredit,0, 'COMMA')}  c|">0 C</td>
                            </tr>
                            <tr>
                                <th>하부 에이전시 수</th>
                                <td th:text="|${#numbers.formatInteger(mypageInfo.downSiteCnt,0, 'COMMA')}  명|"></tr>
                            <tr>
                                <th>하부 유저 수</th>
                                <td th:text="|${#numbers.formatInteger(mypageInfo.downMemCnt,0, 'COMMA')}  명|">3,148 명</td>
                            </tr>
                            <tr>
                                <th>가입 시각</th>
                                <td  th:text="${mypageInfo.regDate}">22-01-29 02:01</td>
                            </tr>
                        </tbody>
                    </table>
                  </div>
                </div>
              </div>

              <div class="modal-content">
                <div class="modal-header"><h5>비밀번호 변경</h5><a>×</a></div>
                <div class="modal-body">
                  <ul>
                    <li>현재 비밀번호</li>
                    <li><input type="password" id="nowPass"></li>
                  </ul>
                  <ul>
                    <li>새 비밀번호</li>
                    <li><input type="password"  id="newPass"><span class="rdc">특수문자, 숫자, 영문을 모두 포함한 8자리 이상으로 설정해주시기 바랍니다.</span></li>
                  </ul>
                  <ul>
                    <li>새 비밀번호 재입력</li>
                    <li><input type="password" id="newPass2"></li>
                  </ul>
                </div>
                <div class="modal-footer">
                  <a href='javascript:$(".modal-content").hide()')>취소</a>
                  <a href='javascript:passUpdate()'>변경</a>
                </div>
              </div>

            </div><!-- container-fluid -->

</th:block>