<!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 agentDetail(siteIdx) {
			var popup = window.open('/agent/detail/' + siteIdx, 'detail', '');
		}

		function goPage(pageNo) {
			var form = document.searchVO;
			form.page.value = pageNo;
			form.action = "/stat/agentReport";
			form.submit();
		}

		function goSearch(pageNo) {
			var form = document.searchVO;
			form.page.value = 1;
			form.action = "/stat/agentReport";
			form.submit();
		}

		function siteUseUpdate(siteId, useYn) {
			if (confirm("상태를 변경하시겠습니까?")) {
				$.ajax({
					type: "post",
					url: "/agent/siteUpdate",
					data: {
						siteId: siteId,
						siteUseYn: useYn
					},
					async: true,
					dataType: "json",
					success: function (data) {
						if (data.RES == "SUCCESS") {
							alert("변경완료");
							//	location.href = location.href; 
							//$('#ciCreditAmt').val();
							location.reload();
						} else {
							alert(data.MSG);
						}
					}
				});
			}
		}

		function siteAdd() {
			if (confirm("생성하시겠습니까?")) {
				$.ajax({
					type: "post",
					url: "/agent/addProc",
					data: {
						siteId: $('#siteId').val(),
						siteName: $('#siteName').val(),
						sitePass: $('#sitePass').val(),
						siteCreditRate: $('#siteCreditRate').val(),
						memo: $('#memo').val()
					},
					async: false,
					dataType: "json",
					success: function (data) {
						if (data.RES == "SUCCESS") {

						} else {

						}
					}
				});
			}
		}

	</script>
</th:block>

<th:block layout:fragment="content">
	<!-- container-fluid -->
	<div class="container-fluid">
		<div class="page-name">
			<h1>에이전시 목록</h1>
		</div>

		<ul class="tabletab">
			<li><a class="active">전체(<em class="num" th:text="${searchVO.tatal_list_count}">0</em>)</a></li>
		</ul>
		<div class="tableserachwrap">
			<div>
				<form class="searchWrap-form" name="searchVO">
					<input type="hidden" id="page" name="page" th:value="${searchVO.page}" />
					<ul class="tableserach">
						<li>
							<div class="input-group">
								<div>
									<label class="input-group-text">기간</label>
								</div>
								<input type="date" name="startDate" th:value="${searchVO.startDate}" />
								<input type="date" name="endDate" th:value="${searchVO.endDate}" />
							</div>
						</li>
						<li>
							<div class="input-group">
								<div>
									<label class="input-group-text">에이전시 아이디</label>
								</div>
								<input type="text" name="searchSiteId" class="br0 mr10" value="검색어" th:value="${searchVO.searchSiteId}" />
							</div>
						</li>
						<li>
							<a class="btn" href="javascript:goSearch()">검색</a>
						</li>
					</ul>
				</form>
			</div>
		</div>
		<div class="table">
			<div class="body">
				<div class="table-responsive">
					<table class="center">
						<thead>
							<tr>
								<th>아이디(에이전시 명)</th>
								<th colspan="2">총 베팅금 / 총 당첨금 / 총 윈루즈</th>
								<th colspan="2">핀트리 베팅금 / 핀트리 당첨금 / 핀트리 윈루즈</th>
								<th colspan="2">프라임 베팅금 / 프라임 당첨금 / 프라임 윈루즈</th>
							</tr>
						</thead>
						<tbody>
							<th:block th:each="site,siteSeq : ${siteList}">
								<tr>
									<td rowspan="3">
										<a th:text="${site.siteId}">아이디</a>
										(<a th:text="${site.siteName}">에이전시</a>)
										(<a th:text="${site.creditBalance}">에이전시</a>)
									</td>
									<td class="ps"><em>전체</em></td>
									<td class="ps">
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('debit'), 0, 'COMMA')}">총 베팅금</span> |
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('credit'), 0, 'COMMA')}">총 당첨금</span> |
										<span class="mr-5 bold" th:text="${#numbers.formatInteger(site.get('winLose'), 0, 'COMMA')}">총 윈루즈</span>
									</td>
									<td class="ps"><em>정품</em></td>
									<td class="ps">
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('onixDebit'), 0, 'COMMA')}">핀트리 베팅금</span> |
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('onixCredit'), 0, 'COMMA')}">핀트리 당첨금</span> |
										<span class="mr-5 bold" th:text="${#numbers.formatInteger(site.get('onixWinLose'), 0, 'COMMA')}">핀트리 윈루즈</span>
									</td>
									<td class="ps"><em>정품</em></td>
									<td class="ps">
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('primeDebit'), 0, 'COMMA')}">프라임 베팅금</span> |
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('primeCredit'), 0, 'COMMA')}">프라임 당첨금</span> |
										<span class="mr-5 bold" th:text="${#numbers.formatInteger(site.get('primeWinLose'), 0, 'COMMA')}">프라임 윈루즈</span>
									</td>
								</tr>
								<tr>
									<td class="ps"><em>EVO</em></td>
									<td class="ps">	
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('evoDebit'), 0, 'COMMA')}">EVO 베팅금</span> |
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('evoCredit'), 0, 'COMMA')}">EVO 당첨금</span> |
										<span class="mr-5 bold" th:text="${#numbers.formatInteger(site.get('evoWinLose'), 0, 'COMMA')}">EVO 윈루즈</span>
									</td>
									<td class="ps"><em>HYB</em></td>
									<td class="ps">
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('onixDebitP'), 0, 'COMMA')}">핀트리(파싱) 베팅금</span> |
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('onixCreditP'), 0, 'COMMA')}">핀트리(파싱) 당첨금</span> |
										<span class="mr-5 bold" th:text="${#numbers.formatInteger(site.get('onixWinLoseP'), 0, 'COMMA')}">핀트리(파싱) 윈루즈</span>
									</td>
									<td class="ps"><em>HYB</em></td>
									<td class="ps">
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('primeDebitP'), 0, 'COMMA')}">프라임(파싱) 베팅금</span> |
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('primeCreditP'), 0, 'COMMA')}">프라임(파싱) 당첨금</span> |
										<span class="mr-5 bold" th:text="${#numbers.formatInteger(site.get('primeWinLoseP'), 0, 'COMMA')}">프라임(파싱) 윈루즈</span>
									</td>
								</tr>
								<tr>
									<td class="ps"><em>PRA</em></td>
									<td class="ps">	
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('prasDebit'), 0, 'COMMA')}">PRA 베팅금</span> |
										<span class="mr-5" th:text="${#numbers.formatInteger(site.get('prasCredit'), 0, 'COMMA')}">PRA 당첨금</span> |
										<span class="mr-5 bold" th:text="${#numbers.formatInteger(site.get('prasWinLose'), 0, 'COMMA')}">PRA 윈루즈</span>
									</td>
									<td colspan="4" class="ps2">
								</tr>
								<tr><td colspan="7" class="ps2"></tr>
							</th:block>
						</tbody>
					</table>
					<th:block th:utext="${pageInfo}"></th:block>
				</div>
			</div>
		</div>
	</div>
	<!-- container-fluid -->
</th:block>