<%@ page contentType="text/html; charset=UTF-8"%><%@ include file="/WEB-INF/jspf/include/taglibs.jsp"%>

    <div class="tab tile ${requestScope.paymentName} balance" style="text-align: center; padding: 10px 20px; background-color: #fff; margin-top: 0;">
    <div class="titleFont3" style="margin-bottom: 20px; margin-top: 10px;">${requestScope.paymentPayText}</div>
    <c:if test="${empty requestScope.paymentFormHidden}">
	<form action="" method="GET" id="paymentForm">
		<input type="hidden" name="action" value="${action}">
		<input type="hidden" name="module" value="${module}">
		<input type="hidden" name="mid" value="${moduleId}">
		<input type="hidden" name="contractId" value="${contract.id}">
		<input type="hidden" name="operation" value="pay" />
		<input type="hidden" name="sbp" value="false" />
	</c:if>
		<c:if test="${not empty dataMap['customerAddressEnable'] and dataMap['customerAddressEnable']}">
			<c:if test="${not empty dataMap['customerAddressRequired'] and dataMap['customerAddressRequired']}"><c:set var="customerAddressRequiredFunction">checkCustomerAddress( form.customerAddress.value, '${dataMap['customerAddressTitle']}' ) &&</c:set></c:if>
			<div class="textField" style="margin-bottom: 5px;"><input type="text" name="customerAddress" value="${dataMap['customerAddress']}" placeholder="${dataMap['customerAddressTitle']}" style="text-align: center; font-size: 1.5rem;"/></div>
		</c:if>
		<%-- телефон, который доп. к оплате (не фискализация), если в модуле none->block, то проверяется обязательность --%>
		<c:set var="paymentPhone" scope="request"><div class="textField" id="paymentPhoneField" style="margin-bottom: 5px; display: none;"><input type="text" name="payment.phone" placeholder="Телефон в формате +79XXXXXXXXX" style="text-align: center; font-size: 1.5rem;" onkeyup="onKeyUpPaymentPhone(this);" value="${paymentPhone}"/></div></c:set>
		<c:if test="${empty requestScope.paymentPaySum}"><c:set var="sumText">Сумма (от <fmt:formatNumber groupingUsed="true" maxFractionDigits="2" minFractionDigits="2" value="${sumMin}" /> до <fmt:formatNumber groupingUsed="true" maxFractionDigits="2" minFractionDigits="2" value="${sumMax}" />)</c:set><c:set var="paymentPaySum" scope="request"><div class="textField"><input type="text" name="sum" placeholder="${sumText}" style="text-align: center; font-size: 1.5rem;" onkeyup="onKeyUpPaymentSum(this);"/></div></c:set></c:if>
		<c:if test="${empty requestScope.paymentPayButton}">
			<c:set var="paymentPayButton" scope="request">
				<c:choose>
					<c:when test="${not empty paymentMethods}">
					<div style="display: flex; flex-direction: row; align-items: center; justify-content: center;">
						<c:forEach var="paymentMethod" items="${paymentMethods}">
							<c:choose>
								<c:when test="${paymentMethod eq 'SBP'}"><div class="paymentMethod" onclick="let form = document.getElementById('paymentForm'); form.sbp.value = 'true'; if ( ${customerAddressRequiredFunction} checkPaymentSum( { sum: form.sum.value, sumMin: ${sumMin}, sumMax: ${sumMax}, currency: '${currencyTitleMedium}', phoneNeed: false } ) ) { if ( doPay( form ) ) form.submit(); } return false;"><img src="${pageContext.request.contextPath}/img/default/payment_sbp.png" title="СБП - система быстрых платежей"  style="height: 3rem;"></div></c:when>
								<c:when test="${paymentMethod eq 'CARD'}"><div class="paymentMethod" onclick="let form = document.getElementById('paymentForm'); let hasPaymentPhoneField=document.getElementById('paymentPhoneField').style.display != 'none'; form.sbp.value = 'false'; if ( ${customerAddressRequiredFunction} checkPaymentSum( { sum: form.sum.value, sumMin: ${sumMin}, sumMax: ${sumMax}, currency: '${currencyTitleMedium}', phoneNeed: hasPaymentPhoneField, phone: form['payment.phone'] ? form['payment.phone'].value : '+70000000000' } ) ) { if ( doPay( form ) ) form.submit(); } return false;"><img src="${pageContext.request.contextPath}/img/default/payment_mir.png" title="Оплата банковской картой" style="height: 3rem;"></div></c:when>
							</c:choose>
						</c:forEach>
					</div>
					</c:when>
					<c:otherwise><div class="formButtons"><button type="submit" onclick="if ( ${customerAddressRequiredFunction} checkPaymentSum( { sum: this.form.sum.value, sumMin: ${sumMin}, sumMax: ${sumMax}, currency: '${currencyTitleMedium}', phoneNeed: false } ) ) { return doPay( this.form ) } return false;" class="btn btn-primary" style="margin-left: 5px;">Оплатить</button></div></c:otherwise>
				</c:choose>
			</c:set>
		</c:if>
		<div>${requestScope.paymentPaySumBefore}${requestScope.paymentPhone}${requestScope.paymentPaySum}${requestScope.paymentPaySumAfter}</div>${requestScope.paymentPayButton}${requestScope.paymentPayNoteMessage}
    <c:if test="${empty requestScope.paymentFormHidden}"></form></c:if>
	</div>
