<?php
//로그인확인
if(!$_SESSION[$_SITE["DOMAIN"]]["GUEST"]["NAME"]){//비회원로그인도 하지 않았다면
	include_once $_SERVER[DOCUMENT_ROOT] . "/module/member/auth.php";
}

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

if($_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["ID"]){//회원로그인을 한 상태라면
	$arrInfo = getOrderInfo($_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["ID"], 1, mysql_real_escape_string($_REQUEST["order_no"]));
}else{
	$arrInfo = getOrderInfoGuest($_SESSION[$_SITE["DOMAIN"]]["GUEST"]["NAME"], $_SESSION[$_SITE["DOMAIN"]]["GUEST"]["MOBILE"], mysql_real_escape_string($_REQUEST["order_no"]));
}

//DB해제
SetDisConn($dblink);
?>
<?
//주문번호 확인 
if($arrInfo["total"] > 0){
?>
	
    <div id="content">
		<div class="sub-title">
			<h2>주문/배송조회</h2>
			<div class="path">
				Home <span class="arrow">&gt;</span> 마이페이지 <span class="arrow">&gt;</span> 주문/배송조회
			</div>
		</div>
        <div class="con_area">
			
		<!-- 본문내용 START -->
        <div class="order_wrap">
		<div class="total-price mgb30">[주문번호] <strong><?=$arrInfo["list"][0]["order_no"]?></strong> &nbsp;&nbsp;&nbsp; [주문내역] <strong><?=$arrInfo["list"][0]["order_summary"]?></strong></div>
		<br />
		<div class="shop-table mgb20">
			<table>
				<colgroup>
					<col width="*">
					<col width="110">
					<!-- <col width="80"> -->
					<col width="70">
					<col width="90">
					<col width="110">
				</colgroup>
				<thead>
					<tr>
						<th scope="col">상품명</th>
						<th scope="col">판매가</th>
						<!-- <th scope="col">적립금</th> -->
						<th scope="col">수량</th>
						<th scope="col">합계/추가금</th>
						<th scope="col">배송상태</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 class="prd_info">
							<div class="prod-info">
								<div class="img"><a href="/shop.php?goPage=GoodDetail&idx=<?=$arrInfo["good_list"][$i][g_idx]?>" target="_blank"><img src="/uploaded/shop_good/<?=$arrInfo["good_list"][$i][g_idx]?>/<?=$arrInfo["good_list"][$i][p_image]?>" width="70" height="70" alt="" class="" /></a></div>
								<div class="info">
									<div class="prd_tit"><?=stripslashes($arrInfo["good_list"][$i][g_name])?></div>
									<div 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>
								</div>
							</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 class="prd_price"><?=number_format(($arrInfo["good_list"][$i][g_price]*$arrInfo["good_list"][$i][g_qty])+($optionPrice * $arrInfo["good_list"][$i][g_qty]))?>원</td>
						<td>
							<p class="state"><?=$_SITE["SHOP"]["ORDER_STATE"][$arrInfo["list"][0][order_state]]?></p>
							<? if( $arrInfo["list"][0]["order_state"] == "7" || $arrInfo["list"][0]["order_state"] == "8"  || $arrInfo["list"][0]["order_state"] == "9") {?>
							<!-- <a href="/shop.php?goPage=MyReview&boardid=after&mode=write&g_idx=<?=$arrInfo["good_list"][$i][g_idx]?>">이용후기쓰기</a> -->
							<?}?>
						</td>
					</tr>
					<?	
						}
					}else{
					?>
					<tr height="100">
						<td colspan="12" align="center">구매항목이 없습니다.</td>
					</tr>
					<?}?>	
				</tbody>
			</table>
		</div>            

		<div class="OrderInfoWrap">
			<h3>주문하시는 분 정보</h3>
			<table class="order-info-table">
			<colgroup>
				<col width="20%" />
				<col width="80%" />
			</colgroup>
			<tr>
				<th>이름</th>
				<td><?=$arrInfo["list"][0]["order_name"]?></td>
			</tr>
			<tr>
				<th>주소</th>
				<td>[<?=$arrInfo["list"][0]["order_zip"]?>] <?=$arrInfo["list"][0]["order_address"]?> <?=$arrInfo["list"][0]["order_address_ext"]?></td>
			</tr>
			<tr>
				<th>전화번호</th>
				<td><?=$arrInfo["list"][0]["order_phone"]?></td>
			</tr>
			<tr>
				<th>휴대폰번호</th>
				<td><?=$arrInfo["list"][0]["order_mobile"]?></td>
			</tr>
			<tr>
				<th>E-mail</th>
				<td><?=$arrInfo["list"][0]["order_email"]?></td>
			</tr>
			</table>
		</div>
		<br /><br />
		<div class="OrderInfoWrap">
			<h3>배송지 정보</h3>
			<table class="order-info-table">
			<colgroup>
				<col width="20%" />
				<col width="80%" />
			</colgroup>
			<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>
			</table>
		</div>
		
		
		<br /><br />
		<div class="OrderInfoWrap">
			<h3>결제내역</h3>
			<table class="order-info-table">
			<colgroup>
				<col width="20%" />
				<col width="80%" />
			</colgroup>
			<tr>
				<th>결제방법</th>
				<td><?=$_SITE["SHOP"]["PAY_TYPE"][$arrInfo["list"][0]["pay_type"]]?></td>
			</tr>
			<?if($arrInfo["list"][0]["pay_type"]!="cash"){?>
			<tr>
				<th>결제내역 조회</th>
				<td>
					※당일 결제건에 한해서 영수증 출력이 가능합니다. <br />
					<a href="http://www.allthegate.com/support/card_search.html" target="_blank">http://www.allthegate.com/support/card_search.html</a>
				</td>
			</tr>
			<?}?>
			<tr>
				<th>결제금액 산출</th>
				<td>상품구매금액(<?=number_format($arrInfo["list"][0]["total_amount"])?>원) + 배송비(<?=number_format($arrInfo["list"][0]["ship_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>
			<?endif;?>
			<tr>
				<th>택배회사</th>
				<td><?=$arrInfo["list"][0]["shipping_company"]?></td>
			</tr>
			<tr>
				<th>송장번호</th>
				<td>
					<form name="door_to_door_frm" method="post" onsubmit="doorToDoorSearch()" ENCTYPE="multipart/form-data">
					  <select name="dtd_select" id="dtd_select"  style="display:none">
						<option value="로젠택배" <?=$arrInfo["list"][0]["shipping_company"]=="로젠택배"?"selected":""?>>로젠택배</option>
						<!-- <option value="CJ GLS" <?=$arrInfo["list"][0]["shipping_company"]=="CJ택배"?"selected":""?>>CJ GLS</option> -->
						<option value="KG옐로우캡택배" <?=$arrInfo["list"][0]["shipping_company"]=="KG옐로우캡택배"?"selected":""?>>KG옐로우캡택배</option>
					  </select>
					  <input type="text" style="width:201px;" class="input" name="dtd_number_query" id="dtd_number_query" value="<?=$arrInfo["list"][0]["shipping_no"]?>" readonly>
					  <input type="submit" value="조회">
					  &nbsp;
					  <?if($arrInfo["list"][0]["shipping_company"]=="KG옐로우캡택배"){?>
					  <!-- <a href="http://www.kglogis.co.kr/delivery/waybill.jsp" target="_blank">옐로우캡 배송조회</a> -->
					  <?}?>
					  <!--<span class="btn_pack large"><a href="javascript:doorToDoorSearch()">조회</a></span>-->
					</form>
					<!--<a href="http://www.ilogen.com/iLOGEN.Web.New/TRACE/TraceNoView.aspx?slipno=<?=$arrInfo["list"][0]["shipping_no"]?>&gubun=slipno" target="_blank">-->
					<!--
					<?=$arrInfo["list"][0]["shipping_no"]?>
					</a><br />
					<strong>
						<?if($arrInfo["list"][0]["shipping_company"]=="CJ택배"){?>
						<a href="https://www.doortodoor.co.kr/parcel/pa_004.jsp">
						<?}else{?>
						<a href="https://www.doortodoor.co.kr/parcel/pa_004.jsp">
						<?}?>
						※ 배송조회 바로가기
						</a>
					</strong>
					-->
				</td>
			</tr>
			<!-- <tr>
				<th>송장번호</th>
				<td><a href="http://www.ilogen.com/iLOGEN.Web.New/TRACE/TraceNoView.aspx?slipno=<?=$arrInfo["list"][0]["shipping_no"]?>&gubun=slipno" target="_blank"><?=$arrInfo["list"][0]["shipping_no"]?></a><br /><strong>※ 송장번호를 클릭하시면 배송조회를 하실 수 있습니다.</strong></td>
			</tr> -->
			</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="btn_box">
		            <div class="submit" style="text-align:center">
			<span class="btn_set"><a href="#"><img src="/images/shop/btn_print.gif" border="0" alt="결제내역 인쇄하기" /></a></span>
			<a href="/shop.php?goPage=OrderList"><img src="/images/shop/btn_confirm.gif" border="0" alt="확인" /></a>
			</div>
		</div> -->
	</div>
	</div>
	</div>
	</div>

<?
}else{
?>
<table width="100%" border="1">
	<tr align="center">
		<td height="100">해당하는 주문내역이 없습니다.</td>
	</tr>
</table>
<?
}

//DB해제
SetDisConn($dblink);
?>

<script type="text/javascript">
function cancelRequest(order_no){
	document.cancelFrm.order_no.value = order_no;
	document.cancelFrm.submit();
}
</script>
<form action="/module/shop/order_evn.php" method="post" name="cancelFrm">
<input type="hidden" name="evnMode" value="orderCancel"/>
<input type="hidden" name="order_no" value=""/>
</form>