<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ page import="itn.com.cmm.LoginVO" %>
<!DOCTYPE html>
<html lang="ko">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>거래명세서</title>

    <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="/publish/css/reset.css">
    <link rel="stylesheet" href="/publish/css/common.css">
    <link rel="stylesheet" href="/publish/css/estimate.css">
    <link rel="stylesheet" href="/publish/css/font.css">
    <link rel="stylesheet" href="/publish/css/button.css">
    
</head>
<script type="text/javascript">

function f_print(){
	document.getElementById('est_btn_wrap').style.display = 'none';
	
    var initBody = document.body.innerHTML;
    window.onbeforeprint = function(){
        // print_area는 인쇄하고자 하는 영역의 ID를 말합니다.( 필수 )
//         document.body.innerHTML = document.getElementById("print_area").innerHTML;
    }
    window.onafterprint = function(){
        document.body.innerHTML = initBody;
    }
    window.print();
    document.getElementById('est_btn_wrap').style.display = '';
}

</script>
<style type="text/css">
.est_body h2 span {font-size:18px;font-weight:300;}
.blank {margin:0 12px;}
.blank2 {margin:0 11px;}
.blank3 {margin:0 27px 0 28px;}
.est_table th.text {text-align:center;vertical-align:middle;}
.est_table2_wrap {overflow:hidden;}
.est_table2 {border:0 none;}
.est_table2 tbody td:first-child {border-left:0 none;}
.est_table2 tbody tr:last-child th, .est_table2 tbody tr:last-child td {border-bottom:0 none;}
</style>
<body>
    <!-- 견적서 -->
    <div class="estimate_wrap">
        <div class="estimate">
            <div class="est_head clearfix">
                <img src="/publish/images/CI.png" alt="문자온 CI">
                <div class="clearfix">
                    <p>(12248) 경기도 남양주시 다산순환로 20, A동 735호(다산동, 현대프리미어캠퍼스)</p>
                    <p>TEL  1551-8011</p>
                </div>
            </div>
            <div class="est_body">
                <h2>거래명세서<span>(공급받는자 보관용)</span></h2>
                <div class="cont1">
                    <div>
                        <p>공급받는자</p>
                        <table class="est_table">
                            <caption>공급받는자 정보</caption>
                            <colgroup>
                                <col style="width: 50px;">
                                <col style="width: auto;">
                            </colgroup>
                            <tbody>
                                <tr>
                                    <th>수<span class="blank"></span>신</th>
                                    <td>${mberNm}</td>
                                </tr>
                                <tr>
                                    <th>참<span class="blank"></span>조</th>
                                    <td>${managerNm} (${moblphonNo})</td>
                                </tr>
                                <tr>
                                    <th>거래일자</th>
                                    <td>${startDate}~${endDate}</td>
                                </tr>
                                <tr>
                                    <th rowspan="2" colspan="2" class="text">아래와 같이 계산합니다.</th>
                                </tr>
                                <tr></tr>
                            </tbody>
                        </table>
                    </div>
                    <div>
                        <p>공급자</p>
                        <img src="/publish/images/content/stamp.png" alt="도장" class="stamp mCS_img_loaded">
                        <table class="est_table">
                            <caption>공급자 정보</caption>
                            <colgroup>
                                <col style="width: 82px;">
                                <col style="width: auto;">
                            </colgroup>
                            <tbody>
                                <tr>
                                    <th>회<span class="blank2"></span>사<span class="blank2"></span>명</th>
                                    <td>주식회사 아이티앤</td>
                                </tr>
                                <tr>
                                    <th>사업자등록번호</th>
                                    <td>653-87-00858</td>
                                </tr>
                                <tr>
                                    <th>대<span class="blank2"></span>표<span class="blank2"></span>자</th>
                                    <td>유인식</td>
                                </tr>
                                <tr>
                                    <th>전<span class="blank3"></span>화</th>
                                    <td>1551-8011</td>
                                </tr>
                                <tr>
                                    <th>이<span class="blank2"></span>메<span class="blank2"></span>일</th>
                                    <td>help@iten.co.kr</td>
                                </tr>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="cont2 clearfix">
                    <p>총 사용금액</p>
                    <c:choose>
	                	<c:when test="${searchVO.addVatType eq 'N'}">
	                		<p><span>${totalSumPrice}</span> 원(VAT 별도)</p>
	                	</c:when>
	                	<c:otherwise>
	                		<p><span>${addTaxSumPrice}</span> 원(VAT 포함)</p>
	                	</c:otherwise>
	                </c:choose>
                </div>
                <div class="cont3">
                    <p>(단위 : 원,  건)</p>
                    <div class="est_table2_wrap">
                        <table class="est_table2">
                            <caption>품목, 발송건수, 공급가액, 금액 정보를 제공하는 표</caption>
                            <colgroup>
                                <col style="width:20%;">
                                <col style="width:20%;">
                                <col style="width:20%;">
                                <col style="width:auto;">
                            </colgroup>
                            <thead>
                                <tr>
                                    <th scope="col">품목</th>
                                    <th scope="col">발송건수</th>
                                    <th scope="col">공급가액</th>
                                    <th scope="col">금액</th>
                                </tr>
                            </thead>
                            <tbody>
								<c:if test="${pageType != 'fax'}">
									<c:forEach var="result" items="${resultList}" varStatus="status">
		                            	<tr>
		                            		<td>${result.msgTypeName}</td>
		                            		<td>
		                            			<c:choose>
		                            				<c:when test="${result.msgTypeName eq '단문(SMS)'}">
		                            					<fmt:formatNumber type="number" maxFractionDigits="3" value="${result.shtSendCount}" var="shtSendCount" />
														<c:out value="${shtSendCount}"/>
		                            				</c:when>
		                            				<c:when test="${result.msgTypeName eq '장문(LMS)'}">
		                            					<fmt:formatNumber type="number" maxFractionDigits="3" value="${result.longSendCount}" var="longSendCount" />
														<c:out value="${longSendCount}"/>
		                            				</c:when>
		                            				<c:when test="${result.msgTypeName eq '그림(MMS)'}">
		                            					<fmt:formatNumber type="number" maxFractionDigits="3" value="${result.pictSendCount}" var="pictSendCount" />
														<c:out value="${pictSendCount}"/>
		                            				</c:when>
		                            				<c:when test="${result.msgTypeName eq '알림톡'}">
		                            					<fmt:formatNumber type="number" maxFractionDigits="3" value="${result.atSendCount}" var="atSendCount" />
														<c:out value="${atSendCount}"/>
		                            				</c:when>
		                            				<c:otherwise>
		                            					<fmt:formatNumber type="number" maxFractionDigits="3" value="${result.ftSendCount}" var="ftSendCount" />
														<c:out value="${ftSendCount}"/>
		                            				</c:otherwise>
		                            			</c:choose>
			                            		<%-- <fmt:formatNumber type="number" maxFractionDigits="3" value="${result.sendCount}" var="sendCount" />
												<c:out value="${sendCount}"/>	 --%>	                            		
		                            		</td>
		                            		<td>
			                            		<fmt:formatNumber type="number" maxFractionDigits="3" value="${result.supplyPrice}" var="supplyPrice" />
												<c:out value="${supplyPrice}"/>
	                            			</td>
		                            		<td>
		                            			<fmt:formatNumber type="number" maxFractionDigits="3" value="${result.totalPrice}" var="totalPrice" />
												<c:out value="${totalPrice}"/>
	                            			</td>
		                            	</tr>
									</c:forEach>
                            	</c:if>			
                            	
                            	<c:if test="${empty pageType || pageType == 'fax'}">
									<c:forEach var="resultFax" items="${payUserSumFaxList}" varStatus="status">	
										<c:if test="${resultFax.ftSendCount > 0}">
											<tr>
			                            		<td>${resultFax.msgTypeName}</td>
			                            		<td>
	                            					<fmt:formatNumber type="number" maxFractionDigits="3" value="${resultFax.ftSendCount}" var="ftSendCount" />
													<c:out value="${ftSendCount}"/>
			                            		</td>
			                            		<td>
				                            		<fmt:formatNumber type="number" maxFractionDigits="3" value="${resultFax.supplyPrice}" var="supplyPrice" />
													<c:out value="${supplyPrice}"/>
		                            			</td>
			                            		<td>
			                            			<fmt:formatNumber type="number" maxFractionDigits="3" value="${resultFax.totalPrice}" var="totalPrice" />
													<c:out value="${totalPrice}"/>
		                            			</td>
			                            	</tr>
		                            	</c:if>
									</c:forEach>
								</c:if>
								<c:if test="${empty resultList && empty payUserSumFaxList}">
									<tr>
										<td colspan="5">
											거래내역이 없습니다.
										</td>
									</tr>
								</c:if>
                            </tbody>
                        </table>
                    </div>
                </div>
                <div class="cont4">
                    <table class="est_table">
                        <caption>공급가액, 총 결제금액에 대한 표</caption>
                        <colgroup>
                            <col style="width: 100px;">
                            <col style="width: auto;">
                        </colgroup>
                        <tbody>
                            <tr>
                                <th>공급가액</th>
                                <td><span>${supplySumPrice}</span></td>
                            </tr>
                            <c:choose>
                               	<c:when test="${searchVO.addVatType eq 'N'}">
                               		<tr class="total_price">
	                                	<th>총 사용금액</th>
	                                	<td><span>${totalSumPrice}</span></td>
	                                </tr>
                               	</c:when>
                               	<c:otherwise>
                               		<tr>
	                                	<th>세액(부가세)</th>
	                                	<td>${addTax}</td>
	                                </tr>
	                                <tr class="total_price">
	                                	<th>총 사용금액</th>
	                                	<td><span>${addTaxSumPrice}</span></td>
	                                </tr>
                               	</c:otherwise>
                            </c:choose>
                        </tbody>
                    </table>
                </div>
                <div class="cont5">
                    <p><span>${year} 년&nbsp;&nbsp;<span>${month}</span> 월&nbsp;&nbsp;<span>${day}</span> 일</p>
                </div>
            </div>
            <div class="est_btn_wrap" id="est_btn_wrap">
                    <button type="button" class="btnType" onclick="javascript:f_print(); return false;"><i class="print_img"></i>인쇄하기</button>                  
            </div>
        </div>
    </div><!--// 견적서 -->
</body></html>
