<?
//DB연결
$dblink = SetConn($_conf_db["main_db"]);

//회원의 경우 회원아이디로 로그인 전이라면 세션 아이디로
if($_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["ID"]){
	$tp = "1";

	$arrMemInfo = getUserInfo(mysql_real_escape_string($_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["ID"]));

	$arrEmail = explode("@",$arrMemInfo["list"][0][email]);
	$arrPhone = explode("-",$arrMemInfo["list"][0][phone]);
	$arrMobile = explode("-",$arrMemInfo["list"][0][mobile]);
	$arrFax = explode("-",$arrMemInfo["list"][0][fax]);
	$arrZip = explode("-",$arrMemInfo["list"][0][zip]);
	$arrTel = explode("-",$arrMemInfo["list"][0][regnum1]);
}else{
	$tp = "2";
}	
$arrInfo = getOrderInfo($_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["ID"], $tp, mysql_real_escape_string($_REQUEST["order_no"]));

//DB해제
SetDisConn($dblink);

//주문번호 확인 => 주문번호가 있어야만 주문가능
if($arrInfo["total"] > 0){
?>
		<div class="contain">
			<div id="contentArea">
				<div class="real-cont">
					<!--// content -->
					<div class="order-step step3">
						<h2><img src="../images/shop/order_step_tit3.png" alt="주문완료"></h2>
					</div>
					<div class="total-price">[주문번호] <strong><?=$arrInfo["list"][0]["order_no"]?></strong> &nbsp;&nbsp;&nbsp; [주문내역] <strong><?=$arrInfo["list"][0]["order_summary"]?></strong></div>

					<div class="order-info">
						<ol>
							<li>1. 신용카드결제시, 결제가 정상적으로 이루어졌는지 주문조회를 통해 확인하시기 바랍니다.</li>
							<li>2. 주문내용은 <em>[마이페이지 &gt; 주문/배송조회]</em>를 통해 언제나 주문/배송상황을 알아보실 수 있습니다.</li>
							<li>3. 주문서가 접수되었으므로 장바구니는 자동으로 비워집니다.</li>
							<li>4. 신용카드로 결제하신 고객님들께서는 결제대행사 승인전표 서비스 페이지에서 승인전표를 확인해 주시기 바랍니다.</li>
						</ol>
					</div>
        
					<div class="shop-table mgb30">
						<table>
						<colgroup>
							<col width="10%" />
							<col />
							<col width="12%" />
							<col width="8%" />
							<col width="6%" />
							<col width="12%" />
						</colgroup>
						<thead>
						<tr>
							<th colspan="2">상품명</th>
							<th>판매가</th>
							<th>적립금</th>
							<th>수량</th>
							<th>합계/추가금</th>
						</tr>
						</thead>
						<tbody>
							<?
							if($arrInfo["good_total"]>0){
								for($i=0;$i<$arrInfo["good_total"];$i++){
									//추가금액 계산
									$optionPrice = $arrInfo["good_list"][$i][g_opt_1_price] + $arrInfo["good_list"][$i][g_opt_2_price] + $arrInfo["good_list"][$i][g_opt_3_price] + $arrInfo["good_list"][$i][g_opt_4_price] + $arrInfo["good_list"][$i][g_opt_5_price];

									//합계금액 계산
									$totalPrice += ($arrInfo["good_list"][$i][g_price]*$arrInfo["good_list"][$i][g_qty])+($optionPrice * $arrInfo["good_list"][$i][g_qty]);
							?>
							<tr>
								<td><a href="/shop.php?goPage=GoodDetail&g_code=<?=$arrInfo["good_list"][$i][g_code]?>" target="_blank"><img src="/uploaded/shop_good/<?=$arrInfo["good_list"][$i][g_idx]?>/<?=$arrInfo["good_list"][$i][p_image]?>" width="80" height="80" alt="" class="img_border" /></a></td>
								<td class="prd_info">

									<p class="prd_tit"><?=stripslashes($arrInfo["good_list"][$i][g_name])?></p>
									<p class="prd_op"><?=$arrInfo["good_list"][$i][g_opt_1]?"<br />".$arrInfo["good_list"][$i][g_opt_1]:""?><?=$arrInfo["good_list"][$i][g_opt_1_price]?" +".number_format($arrInfo["good_list"][$i][g_opt_1_price]):""?>
									<?=$arrInfo["good_list"][$i][g_opt_2]?"<br />".$arrInfo["good_list"][$i][g_opt_2]:""?><?=$arrInfo["good_list"][$i][g_opt_2_price]?" +".number_format($arrInfo["good_list"][$i][g_opt_2_price]):""?>
									<?=$arrInfo["good_list"][$i][g_opt_3]?"<br />".$arrInfo["good_list"][$i][g_opt_3]:""?><?=$arrInfo["good_list"][$i][g_opt_3_price]?" +".number_format($arrInfo["good_list"][$i][g_opt_3_price]):""?>
									<?=$arrInfo["good_list"][$i][g_opt_4]?"<br />".$arrInfo["good_list"][$i][g_opt_4]:""?><?=$arrInfo["good_list"][$i][g_opt_4_price]?" +".number_format($arrInfo["good_list"][$i][g_opt_4_price]):""?>
									<?=$arrInfo["good_list"][$i][g_opt_5]?"<br />".$arrInfo["good_list"][$i][g_opt_5]:""?><?=$arrInfo["good_list"][$i][g_opt_5_price]?" +".number_format($arrInfo["good_list"][$i][g_opt_5_price]):""?></div>
									
								</td>
								<td><?=number_format($arrInfo["good_list"][$i][g_price]+$optionPrice)?>원</td>
								<td><?=number_format($arrInfo["good_list"][$i][g_point])?></td>
								<td><?=number_format($arrInfo["good_list"][$i][g_qty])?></td>
								<td><p class="prd_price"><?=number_format(($arrInfo["good_list"][$i][g_price]*$arrInfo["good_list"][$i][g_qty])+($optionPrice * $arrInfo["good_list"][$i][g_qty]))?>원</p></td>
							</tr>
							<?	
								}
							}else{
							?>
							<tr height="100">
								<td colspan="12" align="center">구매항목이 없습니다.</td>
							</tr>
							<?}?>
						</tbody>
						</table>
					</div>            

        
       <div class="mgb30">
			<div class="order-info-title">
				<h3><img src="../images/shop/order_tit5.png" alt="배송지 정보"></h3>
			</div>
            <table class="order-info-table">
				<colgroup>
					<col width="120">
					<col width="*">
				</colgroup>
				<tbody>
				<tr>
					<th>이름</th>
					<td><?=$arrInfo["list"][0]["ship_name"]?></td>
				</tr>
				<tr>
					<th>주소</th>
					<td>[<?=$arrInfo["list"][0]["ship_zip"]?>] <?=$arrInfo["list"][0]["ship_address"]?> <?=$arrInfo["list"][0]["ship_address_ext"]?></td>
				</tr>
				<tr>
					<th>전화번호</th>
					<td><?=$arrInfo["list"][0]["ship_phone"]?></td>
				</tr>
				<tr>
					<th>휴대폰번호</th>
					<td><?=$arrInfo["list"][0]["ship_mobile"]?></td>
				</tr>
				<tr>
					<th>남기실 내용</th>
					<td><?=$arrInfo["list"][0]["order_comment"]?></td>
				</tr>
				<tbody>
            </table>
        </div>
        
        
        
        <div class="mgb30">
			<div class="order-info-title">
				<h3><img src="../images/shop/order_tit6.png" alt="결제내역"></h3>
			</div>
			<table class="order-info-table">
				<colgroup>
					<col width="120">
					<col width="*">
				</colgroup>
				<tbody>
					<tr>
						<th>결제방법</th>
						<td>
						<? if ($_POST["charge_type"] == "1") { ?>
							<?=$_SITE["SHOP"]["PAY_TYPE_MOBILE"][$arrInfo["list"][0]["pay_type"]]?>
						<? } else { ?>
							<?=$_SITE["SHOP"]["PAY_TYPE"][$arrInfo["list"][0]["pay_type"]]?>
						<? } ?>
						</td>
					</tr>
					<tr>
						<th>결제금액 산출</th>
						<td>상품구매금액(<?=number_format($arrInfo["list"][0]["total_amount"])?>원) + 배송비(<?=number_format($arrInfo["list"][0]["ship_amount"])?>원) 
					</tr>
					<tr style="display:none">
						<th>쿠폰 사용</th>
						<td><?=number_format($arrInfo["list"][0]["coupon_amount"])?>원</td>
					</tr>
					<tr>
						<th>적립금 사용</th>
						<td><?=number_format($arrInfo["list"][0]["using_point"])?></td>
					</tr>
					<tr>
						<th>총결제금액</th>
						<td class="prd_price"><?=number_format($arrInfo["list"][0]["pay_amount"])?>원</td>
					</tr>
					<?if($arrInfo["list"][0]["pay_type"]=="cash") {?>
					<tr>
						<th>입금계좌</th>
						<td><?=$arrInfo["list"][0]["bank_type"]?></td>
					</tr>
					<tr>
						<th>입금자명</th>
						<td><?=$arrInfo["list"][0]["bank_name"]?></td>
					</tr>
					<tr>
						<th>입금예정일자</th>
						<td><?=$arrInfo["list"][0]["bank_date"]?></td>
					</tr>
					<?} else if($arrInfo["list"][0]["pay_type"]=="gift") {?>
					<tr>
						<th>결제결과</th>
						<td>문화상품권이 정상적으로 결제되었습니다.</td>
					</tr>
					<?} else {?>
					<tr>
					  <th>결제결과</th>
					  <td><?
						//올더게이트
						if($_SITE["SHOP"]["PG"]["COMPANY"]=="agspay") {
							if ($_POST["charge_type"] == "1") {
								include $_SERVER[DOCUMENT_ROOT] . "/module/shop/pg/agspay_mobile_result.php";
							} else { 
								include $_SERVER[DOCUMENT_ROOT] . "/module/shop/pg/agspay_result.php";
							}
						}
						//ksnet
						if($_SITE["SHOP"]["PG"]["COMPANY"]=="kspay") {
							include $_SERVER[DOCUMENT_ROOT] . "/module/shop/pg/kspay_result.php";
						}
						?></td>
					</tr>
					<?}?>
				</tbody>
            </table>
        </div>
        
        <div class="buttons">
			<div class="cen">
				<a href="javascript:print();" class="btn-pack xlarge dark">인쇄하기</a>
				<a href="/shop.php?goPage=OrderList" class="btn-pack xlarge focus">결제확인</a>
			</div>
		</div>
        <!-- <div class="total_btn_c">
        			<a href="javascript:print();"><img src="/images/shop/btn_print.gif" alt="결제내역 인쇄하기" /></a>
        			<span class="btn_set"><a href="/shop.php?goPage=OrderList"><img src="/images/shop/btn_confirm.gif" alt="확인" /></a></span>
        </div> -->
    </div>
<?
}else{
?>
<table width="100%" border="1">
	<tr align="center">
		<td height="100">해당하는 주문내역이 없습니다.</td>
	</tr>
</table>
<?
}
?>