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

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

//회원의 경우 회원아이디로 로그인 전이라면 세션 아이디로
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]);

	$arrEtc1 = explode("-",$arrMemInfo["list"][0][etc_1]);
	$arrEtc3 = explode("|||",$arrMemInfo["list"][0][etc_3]);
	$arrEtc4 = explode("|||",$arrMemInfo["list"][0][etc_4]);
	$arrEtc5 = explode("|||",$arrMemInfo["list"][0][etc_5]);
	$arr5Mobile = explode("-",$arrEtc5[1]);
	$arr5Email = explode("@",$arrEtc5[2]);

}else{
	$tp = "2";
}	

$arrInfo = getOrderInfo($_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["ID"], $tp, mysql_real_escape_string($_REQUEST["order_no"]));


//재고체크
checkPreOderStock($arrList);
?>
<div class="contain">
	<div class="real-cont">
		<div id="con_area">
		<!--// content -->
			<!-- //주문결제 -->
		<div class="order-step step2">
			<h2><img src="../images/shop/order_step_tit2.png" alt="주문서작성/결제"></h2>
		</div>
            
            <div class="shop-table mgb20">
				<table>
					<colgroup>
						<col width="100">
						<col width="*">
						<col width="80">
					</colgroup>
					<thead>
						<tr>
							<th scope="col" colspan="2">상품명</th>
							<th scope="col">합계/추가금</th>
						</tr>
					</thead>
					<tbody>
					<?
					if($arrInfo["good_total"]>0){
					for($i=0;$i<$arrInfo["good_total"];$i++){
						$GoodsInfo = getGoodInfo($arrInfo["good_list"][$i][g_idx]);
						//추가금액 계산
						$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_rel_1_price] + $arrInfo["good_list"][$i][g_opt_rel_2_price];

						//합계금액 계산
						$totalPrice += ($arrInfo["good_list"][$i][g_price]*$arrInfo["good_list"][$i][g_qty])+($optionPrice * $arrInfo["good_list"][$i][g_qty]);
					?>
					<tr>
						<td class="space-left">
							<img src="/uploaded/shop_good/<?=$arrInfo["good_list"][0][g_idx]?>/<?=$arrInfo["good_list"][0][p_image]?>" width="70" height="70" border="0" />
						</td>
						
						<td class="space-left">
							<?=stripslashes($arrInfo["good_list"][$i][g_name])?>
							<?=$arrInfo["good_list"][$i][g_opt_rel_1]?" ".$arrInfo["good_list"][$i][g_opt_rel_1]:""?><?=$arrInfo["good_list"][$i][g_opt_rel_1_price]?" +".number_format($arrInfo["good_list"][$i][g_opt_rel_1_price]):""?>
							<?=$arrInfo["good_list"][$i][g_opt_rel_2]?"/ ".$arrInfo["good_list"][$i][g_opt_rel_2]:""?><?=$arrInfo["good_list"][$i][g_opt_rel_2_price]?" +".number_format($arrInfo["good_list"][$i][g_opt_rel_2_price]):""?>
							<?=$arrInfo["good_list"][$i][g_opt_1]?"/ ".$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]?"/ ".$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]?"/ ".$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]?"/ ".$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]?"/ ".$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]):""?>
						</td>
						<td><?=number_format($arrInfo["good_list"][$i][g_price]+$optionPrice)?>원</td>
					</tr>
					<?
					}
					}
					else{
					?>
					<tr height="100">
					  <td colspan="9" align="center">구매항목이 없습니다.</td>
					</tr>
					<?}?>					
					</tbody>
				</table>
			</div>
					
			<div class="order-info-table mgb20">
				<table style="width:100%">
                <colgroup>
                    <col width="120px" />
					<col width="*" />
                </colgroup>
					<tbody>
					<tr>
						<th>결제 방식</th>
						<td><?=$_SITE["SHOP"]["PAY_TYPE"][$arrInfo["list"][0]["pay_type"]]?>
						</td>
					  </tr>
					  <tr>
						<th>결제금액 산출</th>
						<td>상품구매금액(<?=number_format($arrInfo["list"][0]["total_amount"])?>원)</td>
					</tr>
					<? if($_SESSION[$_SITE["DOMAIN"]]["MEMBER"]["ID"]){ ?>
					<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>
					</table>
					
				</div>
				
				
<?
if ( preg_match('/iPhone|ipod|ios|Mobile|UP.Browser|Android|BlackBerry|Windows CE|Nokia|webOS|Opera Mini|lg|mot|samsung|SAMSUNG|SonyEricsson|Opera mobi|Windows Phone|IEMobile|POLARIS/',$_SERVER['HTTP_USER_AGENT']) ) { 
	//모바일일경우
?>
<!-- <form name="frmOrderForm" method="post" accept-charset="euc-kr"> -->
<form method="post" action="<?=$strAegis?>/payment/mobilev2/intro.jsp" name="frmOrderForm" accept-charset="euc-kr">
<input type="hidden" name="order_no" value="<?=$order_no?>">
<?
	$os_type = "M";
	include $_SERVER[DOCUMENT_ROOT] . "/module/shop/pg/agspay_mobile.php";
}else{
	//웹일경우
?>
<form name="frmOrderForm" method="post">
<input type="hidden" name="order_no" value="<?=$order_no?>">
<?
	$os_type = "W";
	include $_SERVER[DOCUMENT_ROOT] . "/module/shop/pg/agspay.php";
}
//echo "OS_type : ".$os_type."</br>";
//echo "os_type2 : ".$_SERVER['HTTP_USER_AGENT']."</br>";
?>				
				<div class="buttons">
					<div class="cen">
						<a href="javascript:PayPop('<?=$os_type?>','agspay');" class="btn-pack xlarge focus">결제하기</a>
						<a href="javascript:history.back(-2);" class="btn-pack xlarge dark">취소하기</a>
					</div>
				</div>
				<!-- //주문결제 -->
			</div>
		</div>
</form>
</div>