<%@ page contentType="text/html; charset=UTF-8"%><%@ include file="/WEB-INF/jspf/include/taglibs.jsp"%>
<html lang="ru">
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<title>Пополнение счета | BGBilling</title>

		<link href="css/style-pub.css" rel="stylesheet" type="text/css" />
		<link href="css/payment.css" rel="stylesheet" type="text/css" />
		<!-- специальный пустой css файл для пользовательский стилей, не перетирается при обновлениях -->
		<link href="css/payment_custom.css" rel="stylesheet" type="text/css"/>
	</head>

<body>
<div class="pageHeader"><div class="content"><div class="logo"></div><div class="logoText">Пополнение счета</div></div></div>

<div class="bodyContent">
	<div class="areaContainer"> 
	<div class="areaSelect" style="width: 15rem; min-width: 15rem;">
		<form method="post" action="pubexecuter" name="buttons">
		<input type="hidden" name="module" value="contract.function">
		<input type="hidden" name="action" value="DoTransaction">
		<input type="hidden" name="button" value="">
		<div class="vButtons">
			<c:set var="buttonSelect"><c:if test="${buttonSelectKey eq 'payment'}">buttonSelect</c:if></c:set>
			<div class="button ${buttonSelect}" onclick="document.forms['buttons'].button.value='payment'; document.forms['buttons'].submit();">пополнить счет</div>
		</div>
		<div class="labelText labelFont labelTextMarginTop">Найти договор:</div>
		<div class="vButtons">
			<c:forEach var="searchModule" items="${searchModules}">
			<c:set var="buttonSelect"><c:if test="${buttonSelectKey eq searchModule.key}">buttonSelect</c:if></c:set>
			<div class="button ${buttonSelect}" onclick="document.forms['buttons'].button.value='${searchModule.key}'; document.forms['buttons'].submit();">${searchModule.value}</div>
			</c:forEach>
			<c:if test="${empty searchModules}"><div style="border: 0px; text-align: center; font-style: italic;">поисковые модули не настроены</div></c:if>
		</div>
		</form>
	</div>
	<div class="areaBody">
	<c:choose>
		<c:when test="${buttonSelectKey ne 'payment'}">
			<form method="post" action="pubexecuter" name="search">
			<input type="hidden" name="module" value="contract.function">
			<input type="hidden" name="action" value="DoTransaction">
			<input type="hidden" name="button" value="${buttonSelectKey}">
			<input type="hidden" name="contract" value="">
			
			<div class="labelText labelFont">Поиск договора ${contractSearchTitle}</div>
			<c:if test="${useHintSearch}"><c:set var="searchOninput">oninput="return doHintSearch( this.value );"</c:set></c:if>
			<div class="inputMarginTop" style="position: relative;"><input type="text" name="searchText" class="textField textFont" style="" value="${searchText}" placeholder="${searchTextPlaceHolder}" autocomplete="off" ${searchOninput}>
				<div id="popupHintSearch" style="display: none; position: absolute; top: 3rem; width: calc(100% - 2rem); z-index: 100; border: 1px solid red; background-color: white; border-radius: 10px; padding: 1rem; font-size: 1.5rem;">fajsdfhkasdh</div>
			</div>
			<div class="labelComment">${searchTextComment}</div>
			<div style="margin: 30px 0px; text-align: right;"><input type="submit" value="ИСКАТЬ" class="button" style="padding: 10px 20px;" /></div>
			<c:if test="${searchResult != null}">
				<div class="labelText labelFont labelTextMarginTop" style="margin-bottom: 20px;">Результаты поиска</div>
				<c:choose>
					<c:when test="${not empty searchResult}">
						<c:forEach var="item" items="${searchResult}">
						<div class="flexRow" style="margin-top: 30px;">
							<div>
								<div class="labelFont" style="">${item.contractTitle}</div>
								<c:if test="${not empty item.verifyTitle}"><div style="margin: 10px 20px; font-style: italic;">${item.verifyTitle}: ${item.verifyValue}</div></c:if>
							</div>
							<div><button class="selectContract" onclick="document.forms['search'].button.value='payment'; document.forms['search'].contract.value='${item.contractTitle}'; document.forms['buttons'].submit();">ВЫБРАТЬ</button></div>
						</div>
						</c:forEach>
					</c:when>
					<c:otherwise>
						<div style="text-align: center; font-style: italic;">Договора не найдены</div>
					</c:otherwise>
				</c:choose>
			</c:if>
			</form>
		</c:when>
		<c:otherwise>
		<form>
		<div class="labelText">Номер договора:</div>
		<div class="inputMarginTop"><input type="text" name="contractTitle" class="textField textFont"></div>
		<div class="labelText labelTextMarginTop">Сумма:</div>
		<div class="inputMarginTop"><input type="text" name="sum" class="textField textFont textDecimal" placeholder="0.00"></div>
		<div class="labelText labelTextMarginTop">E-mail (для чека):</div>
		<div class="inputMarginTop"><input type="text" name="email" class="textField textFont textDecimal" placeholder="email@mail.ru"></div>
		<c:forEach var="item" items="${paymentModules}">
		<c:if test="${not empty item.paymentMethods}">
		<div class="labelText labelFont lineBottom2 labelTextMarginTop">${item.moduleTitle}</div>
		<div class="labelText labelTextMarginTop">Способ оплаты:</div>
		<div class="hButtons">
			<c:forEach var="method" items="${item.paymentMethods}">
			<c:choose>
			<c:when test="${method eq 'QR'}"><div>QR код</div></c:when>
			<c:when test="${method eq 'SBP'}"><div>СБП</div></c:when>
			<c:when test="${method eq 'CARD'}"><div>Банковская карта</div></c:when>
			</c:choose>
			</c:forEach>
		</div>
		</c:if>
		</c:forEach>
		</form>
		</c:otherwise>
	</c:choose>
	</div>
	</div>
</div>

<div class="pageFooter"></div>
</body>
</html>