<?php
include_once('./_common.php');

$member_mb_id_esc = '';
if ($is_member) {
	$member_mb_id_esc = sql_escape_string($member['mb_id']);
}

echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">";

$od_id = oi_clean_id($od_id);
$uid = oi_clean_uid(isset($_GET['uid']) ? $_GET['uid'] : '');

if( isset($_GET['ini_noti']) && !$uid ){
    goto_url(G5_URL.'/shoppoint/orderinquiry4withdraw.php');
	exit;
}

// 불법접속을 할 수 없도록 세션에 아무값이나 저장하여 hidden 으로 넘겨서 다음 페이지에서 비교함
$token = md5(uniqid(rand(), true));
set_session("ss_token", $token);

if (!$is_member) {
	if (get_session('ss_orderview_uid') != $uid)
        alert("직접 링크로는 포인트 출금신청서 조회가 불가합니다.\\n\\n포인트 출금신청조회 화면을 통하여 조회하시기 바랍니다.", G5_URL.'/shoppoint/');
}

$sql = "select * from g5_shoppoint_order4withdraw where od_id = '$od_id' ";
if($is_member && !$is_admin)
	$sql .= " and mb_id = '{$member_mb_id_esc}' ";
$od = sql_fetch($sql);
if (!$od['od_id'] || (!$is_member && md5($od['od_id'].$od['od_time'].$od['od_ip']) != get_session('ss_orderview_uid'))) {
    alert("조회하실 포인트 출금신청서가 없습니다.", G5_URL.'/shoppoint/');
}

// 결제방법
$settle_case = $od['od_settle_case'];

if (G5_IS_MOBILE) {
    include_once(G5_PATH.'/mobile/shoppoint/orderinquiryview4withdraw.php');
    return;
}

// 테마에 orderinquiryview4withdraw.php 있으면 include
if(defined('G5_THEME_SHOP_PATH')) {
    $theme_inquiryview_file = G5_THEME_SHOP_PATH.'/orderinquiryview4withdraw.php';
    if(is_file($theme_inquiryview_file)) {
        include_once($theme_inquiryview_file);
        return;
        unset($theme_inquiryview_file);
    }
}

$g5['title'] = '포인트 포인트 출금신청상세';
include_once('./_head.php');

// LG 현금영수증 JS
if($od['od_pg'] == 'lg') {
    if($default['de_card_test']) {
    echo '<script language="JavaScript" src="http://pgweb.uplus.co.kr:7085/WEB_SERVER/js/receipt_link.js"></script>'.PHP_EOL;
    } else {
        echo '<script language="JavaScript" src="http://pgweb.uplus.co.kr/WEB_SERVER/js/receipt_link.js"></script>'.PHP_EOL;
    }
}
?>

<!-- 포인트 출금신청상세내역 시작 { -->
<div id="sod_fin">

    <div id="sod_fin_no">포인트 출금신청번호 <strong><?php echo $od_id; ?></strong></div>

    <section id="sod_fin_list">
        <?php
        $st_count1 = $st_count2 = 0;
        $custom_cancel = false;

		$od_misu = $od['od_misu'];
		$od_status = $od['od_status'];
		$od_cart_price = $od['od_cart_price'];
		$od_withdraw_fee = $od['od_withdraw_fee'];
		$od_fx_type = $od['od_fx_type'];
		$target_currency = substr($od_fx_type,3,3);
		$od_fx_rate = $od['od_fx_rate'];
		$od_fx_amount = $od['od_fx_amount'];
		switch ($target_currency) {
			case 'KRW':
				$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/kr.svg' class='nation_flag_img2'>";
				$od_fx_amount_display = number_format($od_fx_amount,0);
				break;
			case 'USD':
				$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/us.svg' class='nation_flag_img1'>";
				$od_fx_amount_display = number_format($od_fx_amount,2);
				break;
			case 'EUR':
				$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/eu.svg' class='nation_flag_img1'>";
				$od_fx_amount_display = number_format($od_fx_amount,2);
				break;
			case 'CNY':
				$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/cn.svg' class='nation_flag_img1'>";
				$od_fx_amount_display = number_format($od_fx_amount,2);
				break;
			case 'JPY':
				$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/jp.svg' class='nation_flag_img2'>";
				$od_fx_amount_display = number_format($od_fx_amount,0);
				break;
			case 'VND':
				$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/vn.svg' class='nation_flag_img1'>";
				$od_fx_amount_display = number_format($od_fx_amount,0);
				break;
			default:
				$target_nation_flag_img = '';
				$od_fx_amount_display = number_format($od_cart_price, 0);
				$target_currency = 'P';
				break;
		}
		// od_fx_type 미저장 bank 출금: 은행 국가코드로 통화/국기 추론
		if ($target_currency === 'P' && strtolower($od['od_withdraw_type']) === 'bank') {
			$_bc = strtoupper(trim($od['od_withdraw_bank_country'] ?? ''));
			$_bc_map = array(
				'KRW'=>array('cur'=>'KRW','svg'=>'kr','cls'=>'nation_flag_img2','dec'=>0),
				'KOREA'=>array('cur'=>'KRW','svg'=>'kr','cls'=>'nation_flag_img2','dec'=>0),
				'KR'=>array('cur'=>'KRW','svg'=>'kr','cls'=>'nation_flag_img2','dec'=>0),
				''=>array('cur'=>'KRW','svg'=>'kr','cls'=>'nation_flag_img2','dec'=>0),
				'USD'=>array('cur'=>'USD','svg'=>'us','cls'=>'nation_flag_img1','dec'=>2),
				'US'=>array('cur'=>'USD','svg'=>'us','cls'=>'nation_flag_img1','dec'=>2),
				'USA'=>array('cur'=>'USD','svg'=>'us','cls'=>'nation_flag_img1','dec'=>2),
				'EUR'=>array('cur'=>'EUR','svg'=>'eu','cls'=>'nation_flag_img1','dec'=>2),
				'EU'=>array('cur'=>'EUR','svg'=>'eu','cls'=>'nation_flag_img1','dec'=>2),
				'CNY'=>array('cur'=>'CNY','svg'=>'cn','cls'=>'nation_flag_img1','dec'=>2),
				'CN'=>array('cur'=>'CNY','svg'=>'cn','cls'=>'nation_flag_img1','dec'=>2),
				'JPY'=>array('cur'=>'JPY','svg'=>'jp','cls'=>'nation_flag_img2','dec'=>0),
				'JP'=>array('cur'=>'JPY','svg'=>'jp','cls'=>'nation_flag_img2','dec'=>0),
				'VND'=>array('cur'=>'VND','svg'=>'vn','cls'=>'nation_flag_img1','dec'=>0),
				'VN'=>array('cur'=>'VND','svg'=>'vn','cls'=>'nation_flag_img1','dec'=>0),
			);
			if (isset($_bc_map[$_bc])) {
				$_inf = $_bc_map[$_bc];
				$target_currency = $_inf['cur'];
				$target_nation_flag_img = "<img src='".\G5_DATA_URL."/item/img_nation_flag/svg/".$_inf['svg'].".svg' class='".$_inf['cls']."'>";
				$od_fx_amount_display = number_format($od_cart_price, 0);
			}
		}
        ?>
        <div class="tbl_head03 tbl_wrap">
            <table style="font-size:1.3rem;">
            <thead>
			<tr class="th_line">
				<th scope="col" id="th_itimg"></th>
				<th scope="col" id="th_itname">상품명</th>
				<th scope="col" id="th_itprice">포인트 출금신청금액</th>
				<th scope="col" id="th_itprice">출금수수료</th>
				<th scope="col" id="th_itpt">출금전환포인트</th>
				<th scope="col" id="th_itst">상태</th>
			</tr>
			</thead>
			<tbody>
			<tr>
				<?php
					$image = "<div style='display:flex; justify-content:center; align-items:center; width:50px; height:50px; padding:1px; border:5px dashed #0f4ba9; border-radius:50%; background:#0063ff; color:#fff; font-size:0.6em; line-height:1;'>POINT<br>Withdraw</div>";
				?>
                <td headers="th_itimg" class="td_imgsmall"><?php echo $image; ?></td>
				<td headers="th_itopt" class="td_dvr" style="white-space: nowrap;">포인트전환출금</td>
				<td headers="th_itprice" class="td_numbig"><?php echo $target_nation_flag_img?><?php echo $od_fx_amount_display;?> <?php echo $target_currency;?></td>
				<td headers="th_itpt" class="td_numbig"><?php echo number_format($od_withdraw_fee);?> Point</td>
				<td headers="th_itpt" class="td_numbig"><?php echo number_format($od_cart_price);?> Point</td>
				<td headers="th_itst" class="td_mngsmall"><?php echo $od_status;?></td>
			</tr>
			</tbody>

            <?php
			$tot_point       += $point;

			$st_count1++;
			if($opt['ct_status'] == '신청')
				$st_count2++;

            // 주문 상품의 상태가 모두 포인트 출금신청이면 고객 취소 가능
            if($st_count1 > 0 && $st_count1 == $st_count2)
                $custom_cancel = true;
            ?>
            </tbody>
            </table>
        </div>

        <div id="sod_sts_wrap">
            <span class="sound_only">상품 상태 설명</span>
            <button type="button" id="sod_sts_explan_open" class="btn_frmline">상태설명보기</button>
            <div id="sod_sts_explan">
                <dl id="sod_fin_legend">
                    <dt>출금신청</dt>
                    <dd>포인트 출금신청이 접수되었습니다.
                    <dt>출금완료</dt>
                    <dd>출금이 완료 되었습니다.
					<!--
                    <dt>준비</dt>
                    <dd>상품 준비 중입니다.
                    <dt>배송</dt>
                    <dd>상품 배송 중입니다.
                    <dt>완료</dt>
                    <dd>상품 배송이 완료 되었습니다.
					-->
                </dl>
                <button type="button" id="sod_sts_explan_close" class="btn_frmline">상태설명닫기</button>
            </div>
        </div>

    </section>

	<div style="display:flex; justify-content:center; align-items:flex-start; width:100%;">
		<div class="sod_left" style="width:65%;">
			<h2>결제/진행상황 정보</h2>
			<?php
			// 총계 = 주문상품금액합계 + 배송비 - 상품할인 - 결제할인 - 배송비할인
			$tot_price = $od['od_cart_price'] + $od['od_send_cost'] + $od['od_send_cost2']
							- $od['od_cart_coupon'] - $od['od_coupon'] - $od['od_send_coupon']
							- $od['od_cancel_price'];

			$receipt_price  = $od['od_receipt_price']
							+ $od['od_receipt_point'];
			$cancel_price   = $od['od_cancel_price'];

			$misu = true;
			$misu_price = $tot_price - $receipt_price - $cancel_price;

			if ($misu_price < 1 && ($od['od_cart_price'] > $od['od_cancel_price'])) {
				$wanbul = " (완불)";
				$misu = false; // 미수금 없음
			}
			else
			{
				$wanbul = display_price($receipt_price);
			}

			// 결제정보처리
			if($od['od_receipt_price'] > 0) {
				$od_receipt_price = display_price($od['od_receipt_price']);
			} else {
				if ($od['od_settle_case'] == '포인트') {
					$od_receipt_price = display_price($od['od_receipt_point']);;
				} else {
					$od_receipt_price = '아직 입금되지 않았거나 입금정보를 입력하지 못하였습니다.';
				}
			}

			$app_no_subj = '';
			$disp_bank = true;
			$disp_receipt = false;
			if($od['od_settle_case'] == '신용카드' || $od['od_settle_case'] == 'KAKAOPAY' || is_inicis_order_pay($od['od_settle_case']) ) {
				$app_no_subj = '승인번호';
				$app_no = $od['od_app_no'];
				$disp_bank = false;
				$disp_receipt = true;
			} else if($od['od_settle_case'] == '간편결제') {
				$app_no_subj = '승인번호';
				$app_no = $od['od_app_no'];
				$disp_bank = false;
				switch($od['od_pg']) {
					case 'lg':
						$easy_pay_name = 'PAYNOW';
						break;
					case 'inicis':
						$easy_pay_name = 'KPAY';
						break;
					case 'kcp':
						$easy_pay_name = 'PAYCO';
						break;
					default:
						break;
				}
			} else if($od['od_settle_case'] == '휴대폰') {
				$app_no_subj = '휴대폰번호';
				$app_no = $od['od_bank_account'];
				$disp_bank = false;
				$disp_receipt = true;
			} else if($od['od_settle_case'] == '가상계좌' || $od['od_settle_case'] == '계좌이체') {
				$app_no_subj = '거래번호';
				$app_no = $od['od_tno'];
			}
			?>

			<section id="sod_fin_pay">
				<h3>포인트 출금신청정보</h3>

				<div class="tbl_head01 tbl_wrap">
					<table>
					<tbody>
					<tr>
						<th scope="row">신청번호</th>
						<td><?php echo $od_id; ?></td>
					</tr>
					<tr>
						<th scope="row">신청일시</th>
						<td><?php echo $od['od_time']; ?></td>
					</tr>
					<tr>
						<th scope="row">입금 받는 방법</th>
						<td style="font-weight:bold;">
						<strong><?php
							switch (strtolower($od['od_withdraw_type'])) {
								case 'bank': echo '은행계좌이체'; break;
								case 'pay': echo '간편결제'; break;
								case 'coin': echo '가상자산'; break;
								default: echo htmlspecialchars($od['od_withdraw_type']); break;
							}
						?></strong>
							<?php
								if (strtolower($od['od_withdraw_type']) === 'bank') {
									switch (substr($od['od_fx_type'],3,3)) {
										case 'KRW':
											$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/kr.svg' class='nation_flag_img2'>";
											$od_fx_amount_display = number_format($od['od_fx_amount'],0);
											break;
										case 'USD':
											$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/us.svg' class='nation_flag_img1'>";
											$od_fx_amount_display = number_format($od['od_fx_amount'],2);
											break;
										case 'EUR':
											$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/eu.svg' class='nation_flag_img1'>";
											$od_fx_amount_display = number_format($od['od_fx_amount'],2);
											break;
										case 'CNY':
											$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/cn.svg' class='nation_flag_img1'>";
											$od_fx_amount_display = number_format($od['od_fx_amount'],2);
											break;
										case 'JPY':
											$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/jp.svg' class='nation_flag_img2'>";
											$od_fx_amount_display = number_format($od['od_fx_amount'],0);
											break;
										case 'VND':
											$target_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/vn.svg' class='nation_flag_img1'>";
											$od_fx_amount_display = number_format($od['od_fx_amount'],0);
											break;
									default:
										$target_nation_flag_img = '';
										$od_fx_amount_display = number_format($od_cart_price, 0);
										break;
									}
										$_bfl = '';
										$_bfmap = array('KRW'=>'kr','KOREA'=>'kr','KR'=>'kr','USD'=>'us','US'=>'us','EUR'=>'eu','EU'=>'eu','CNY'=>'cn','CN'=>'cn','JPY'=>'jp','JP'=>'jp','VND'=>'vn','VN'=>'vn');
										$_bcsz = array('KRW','KOREA','KR','JPY','JP','VND','VN');
										$_bcc = strtoupper(trim($od['od_withdraw_bank_country']));
										if (isset($_bfmap[$_bcc])) { $_bfl = "<img src='".\G5_DATA_URL."/item/img_nation_flag/svg/".$_bfmap[$_bcc].".svg' class='".(in_array($_bcc,$_bcsz)?'nation_flag_img2':'nation_flag_img1')."'>"; }
									echo $_bfl."[".$od['od_withdraw_bank_country']."] ".$od['od_withdraw_bank_name']." ".$od['od_withdraw_bank_account']." ".$od['od_withdraw_bank_account_name'];
								} else if (strtolower($od['od_withdraw_type']) === 'pay') {
									echo $od['od_withdraw_pay']." ".$od['od_withdraw_pay_id'];
								} else if (strtolower($od['od_withdraw_type']) === 'coin') {
									echo $od['od_withdraw_coin']." ".$od['od_withdraw_coin_id'];
								}
							?>

						</td>
					</tr>
					<tr>
						<th scope="row">출금통화</th>
						<td style="font-weight:bold;">
							<?php
								if ($target_currency === "KRW") echo "한국 원화 (KRW)";
								elseif ($target_currency === "USD") echo "미국 달러 (USD)";
								elseif ($target_currency === "EUR") echo "유로 (EUR)";
								elseif ($target_currency === "CNY") echo "중국 위안화 (CNY)";
								elseif ($target_currency === "JPY") echo "일본 엔화 (JPY)";
								elseif ($target_currency === "VND") echo "베트남 동 (VND)";
								else echo "포인트 (P)";
							?>
						</td>
					</tr>
					<!-- <tr>
						<th scope="row">결제금액</th>
						<td>
							<?php
								if ($wanbul == " (완불)") {
									echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
								} else {
									echo $target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
								}
							?>
						</td>
					</tr> -->
					<?php
					// 승인번호, 휴대폰번호, 거래번호
					if($app_no_subj)
					{
					?>
					<tr>
						<th scope="row"><?php echo $app_no_subj; ?></th>
						<td><?php echo $app_no; ?></td>
					</tr>
					<?php
					}

					// 계좌정보
					if($disp_bank)
					{
					?>
					<tr>
						<th scope="row">실수령금액</th>
						<td style="font-weight:bold;">
							<?php
								if ($wanbul == " (완불)") {
									echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
								} else {
									if ($misu_price > 1 && round($od_fx_amount,2) != round(($misu_price * $od_fx_rate),2)) {
										echo $target_nation_flag_img.$od_fx_amount_display.' '.$target_currency;
										switch (substr($od['od_fx_type'],3,3)) {
											case 'KRW':
												echo "<span style='font-size:0.9rem;color:orangered;margin-left:30px;font-weight:normal;'>※미수령금액 ".number_format($misu_price * $od_fx_rate, 0).' '.$target_currency."</span>";
												break;
											case 'USD':
												echo "<span style='font-size:0.9rem;color:orangered;margin-left:30px;font-weight:normal;'>※미수령금액 ".number_format($misu_price * $od_fx_rate, 2).' '.$target_currency."</span>";
												break;
											case 'EUR':
												echo "<span style='font-size:0.9rem;color:orangered;margin-left:30px;font-weight:normal;'>※미수령금액 ".number_format($misu_price * $od_fx_rate, 2).' '.$target_currency."</span>";
												break;
											case 'CNY':
												echo "<span style='font-size:0.9rem;color:orangered;margin-left:30px;font-weight:normal;'>※미수령금액 ".number_format($misu_price * $od_fx_rate, 2).' '.$target_currency."</span>";
												break;
											case 'JPY':
												echo "<span style='font-size:0.9rem;color:orangered;margin-left:30px;font-weight:normal;'>※미수령금액 ".number_format($misu_price * $od_fx_rate, 0).' '.$target_currency."</span>";
												break;
											case 'VND':
												echo "<span style='font-size:0.9rem;color:orangered;margin-left:30px;font-weight:normal;'>※미수령금액 ".number_format($misu_price * $od_fx_rate, 0).' '.$target_currency."</span>";
												break;
										}
									} else {
										echo $target_nation_flag_img.$od_fx_amount_display.' '.$target_currency;
									}
								}
							?>
						</td>
					</tr>
					<tr>
						<th scope="row" style="color:green;">송금자명</th>
						<td style="font-weight:bold;padding-left:33px;letter-spacing:1px;color:green;">
							<?php echo get_text($od['od_deposit_name']); ?><span style='font-size:0.9rem;margin-left:30px;font-weight:normal;color:#111;letter-spacing: 0px;'>※ 송금자명이 기재되는 수령방법인 경우 좌측 영문이름이 표기됩니다.</span>
						</td>
					</tr>
					<?php
					if($od['od_receipt_price'] > 0)
					{
					?>
					<tr>
						<th scope="row">지급일시</th>
						<td><?php echo $od['od_receipt_time']; ?></td>
					</tr>
					<?php
					}
					?>
					<?php
						if ($wanbul != " (완불)") {
					?>
					<tr>
						<th scope="row">처리기한</th>
						<td>
							<?php
								// $od['od_time']을 DateTime 객체로 변환합니다.
								$od_time = new DateTime($od['od_time']);

								// 30분을 더합니다.
								$od_time->add(new DateInterval('PT30M'));

								// 변경된 시간을 출력합니다.
								echo "포인트 출금신청일로부터 1영업일내에 처리됩니다.</span>";
							?>
						</td>
					</tr>
					<?php
						}
					?>

					<?php
					}

					if($disp_receipt) {
					?>
					<tr>
						<th scope="row">영수증</th>
						<td>
							<?php
							if($od['od_settle_case'] == '휴대폰')
							{
								if($od['od_pg'] == 'lg') {
									require_once G5_PATH.'/shoppoint/settle_lg.inc.php';
									$LGD_TID      = $od['od_tno'];
									$LGD_MERTKEY  = $config['cf_lg_mert_key'];
									$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);

									$hp_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
								} else if($od['od_pg'] == 'inicis') {
									$hp_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
								} else {
									$hp_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'mcash_bill&tno='.$od['od_tno'].'&order_no='.$od['od_id'].'&trade_mony='.$od['od_receipt_price'].'\', \'winreceipt\', \'width=500,height=690,scrollbars=yes,resizable=yes\');';
								}
							?>
							<a href="javascript:;" onclick="<?php echo $hp_receipt_script; ?>">영수증 출력</a>
							<?php
							}

							if($od['od_settle_case'] == '신용카드' || is_inicis_order_pay($od['od_settle_case']) )
							{
								if($od['od_pg'] == 'lg') {
									require_once G5_PATH.'/shoppoint/settle_lg.inc.php';
									$LGD_TID      = $od['od_tno'];
									$LGD_MERTKEY  = $config['cf_lg_mert_key'];
									$LGD_HASHDATA = md5($LGD_MID.$LGD_TID.$LGD_MERTKEY);

									$card_receipt_script = 'showReceiptByTID(\''.$LGD_MID.'\', \''.$LGD_TID.'\', \''.$LGD_HASHDATA.'\');';
								} else if($od['od_pg'] == 'inicis') {
									$card_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/mCmReceipt_head.jsp?noTid='.$od['od_tno'].'&noMethod=1\',\'receipt\',\'width=430,height=700\');';
								} else {
									$card_receipt_script = 'window.open(\''.G5_BILL_RECEIPT_URL.'card_bill&tno='.$od['od_tno'].'&order_no='.$od['od_id'].'&trade_mony='.$od['od_receipt_price'].'\', \'winreceipt\', \'width=470,height=815,scrollbars=yes,resizable=yes\');';
								}
							?>
							<a href="javascript:;" onclick="<?php echo $card_receipt_script; ?>">영수증 출력</a>
							<?php
							}

							if($od['od_settle_case'] == 'KAKAOPAY')
							{
								$card_receipt_script = 'window.open(\'https://mms.cnspay.co.kr/trans/retrieveIssueLoader.do?TID='.$od['od_tno'].'&type=0\', \'popupIssue\', \'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=420,height=540\');';
							?>
							<a href="javascript:;" onclick="<?php echo $card_receipt_script; ?>">영수증 출력</a>
							<?php
							}
							?>
						</td>
					</tr>
					<?php
					}

					if ($od['od_receipt_point'] > 0)
					{
					?>
					<tr>
						<th scope="row">포인트사용</th>
						<td><?php echo display_point($od['od_receipt_point']); ?></td>
					</tr>

					<?php
					}

					if ($od['od_refund_price'] != "")
					{
					/*
					?>
					<tr>
						<th scope="row">절사금액</th>
						<td><?php echo $target_nation_flag_img.number_format($od['od_refund_price'] * $od['od_fx_rate'],2)." ".substr($od['od_fx_type'],3,3); ?></td>
					</tr>
					<?php
					*/
					}

					// 현금영수증 발급을 사용하는 경우에만
					if ($default['de_taxsave_use']) {
						// 미수금이 없고 현금일 경우에만 현금영수증을 발급 할 수 있습니다.
						if ($misu_price == 0 && $od['od_receipt_price'] && ($od['od_settle_case'] == '무통장' || $od['od_settle_case'] == '계좌이체' || $od['od_settle_case'] == '가상계좌')) {
					?>
					<tr>
						<th scope="row">현금영수증</th>
						<td>
						<?php
						if ($od['od_cash'])
						{
							if($od['od_pg'] == 'lg') {
								require_once G5_PATH.'/shoppoint/settle_lg.inc.php';

								switch($od['od_settle_case']) {
									case '계좌이체':
										$trade_type = 'BANK';
										break;
									case '가상계좌':
										$trade_type = 'CAS';
										break;
									default:
										$trade_type = 'CR';
										break;
								}
								$cash_receipt_script = 'javascript:showCashReceipts(\''.$LGD_MID.'\',\''.$od['od_id'].'\',\''.$od['od_casseqno'].'\',\''.$trade_type.'\',\''.$CST_PLATFORM.'\');';
							} else if($od['od_pg'] == 'inicis') {
								$cash = unserialize($od['od_cash_info']);
								$cash_receipt_script = 'window.open(\'https://iniweb.inicis.com/DefaultWebApp/mall/cr/cm/Cash_mCmReceipt.jsp?noTid='.$cash['TID'].'&clpaymethod=22\',\'showreceipt\',\'width=380,height=540,scrollbars=no,resizable=no\');';
							} else {
								require_once G5_PATH.'/shoppoint/settle_kcp.inc.php';

								$cash = unserialize($od['od_cash_info']);
								$cash_receipt_script = 'window.open(\''.G5_CASH_RECEIPT_URL.$default['de_kcp_mid'].'&orderid='.$od_id.'&bill_yn=Y&authno='.$cash['receipt_no'].'\', \'taxsave_receipt\', \'width=360,height=647,scrollbars=0,menus=0\');';
							}
						?>
							<a href="javascript:;" onclick="<?php echo $cash_receipt_script; ?>" class="btn_frmline">현금영수증 확인하기</a>
						<?php
						}
						else
						{
						?>
							<a href="javascript:;" onclick="window.open('<?php echo G5_URL.'/shoppoint/'; ?>/taxsave.php?od_id=<?php echo $od_id; ?>', 'taxsave', 'width=550,height=400,scrollbars=1,menus=0');" class="btn_frmline">현금영수증을 발급하시려면 클릭하십시오.</a>
						<?php } ?>
						</td>
					</tr>
					<?php
						}
					}
					?>
					</tbody>
					</table>
				</div>
			</section>
			<section id="sod_fin_orderer">
				<h3>포인트 출금신청하신 분</h3>

				<div class="tbl_head01 tbl_wrap">
					<table>

					<tbody>
					<tr>
						<th scope="row">이 름</th>
						<td><?php echo get_text($od['od_name']); ?></td>
					</tr>
					<tr>
						<th scope="row">메신저</th>
						<td>
							<?php if (trim($od['od_sns_id']) != '') { ?>
								[<?php echo get_text($od['od_sns_name']); ?>] <?php echo get_text($od['od_sns_id']); ?>
							<?php } else { ?>
								없음
							<?php } ?>
						</td>
					</tr>
					<!--
					<tr>
						<th scope="row">전화번호</th>
						<td><?php echo get_text($od['od_tel']); ?></td>
					</tr>
					-->
					<tr>
						<th scope="row">휴대폰</th>
						<td>
							<?php if (trim($od['od_hp']) != '') { ?>
								<?php
									$_hp_nation = strtoupper(trim(get_text($od['od_hp_nation'])));
									$_hp_dial_map = array('KOREA'=>array('svg'=>'kr','cls'=>'nation_flag_img2','dial'=>'+82'),'KR'=>array('svg'=>'kr','cls'=>'nation_flag_img2','dial'=>'+82'),'US'=>array('svg'=>'us','cls'=>'nation_flag_img1','dial'=>'+1'),'USA'=>array('svg'=>'us','cls'=>'nation_flag_img1','dial'=>'+1'),'CN'=>array('svg'=>'cn','cls'=>'nation_flag_img1','dial'=>'+86'),'CHINA'=>array('svg'=>'cn','cls'=>'nation_flag_img1','dial'=>'+86'),'JP'=>array('svg'=>'jp','cls'=>'nation_flag_img2','dial'=>'+81'),'JAPAN'=>array('svg'=>'jp','cls'=>'nation_flag_img2','dial'=>'+81'),'VN'=>array('svg'=>'vn','cls'=>'nation_flag_img1','dial'=>'+84'),'VIETNAM'=>array('svg'=>'vn','cls'=>'nation_flag_img1','dial'=>'+84'));
									if (isset($_hp_dial_map[$_hp_nation])) {
										$_hd = $_hp_dial_map[$_hp_nation];
										echo "<img src='".\G5_DATA_URL."/item/img_nation_flag/svg/".$_hd['svg'].".svg' class='".$_hd['cls']."'> ".$_hd['dial']." ".get_text($od['od_hp']);
									} else {
										echo "[".$_hp_nation."] ".get_text($od['od_hp']);
									}
								?>
							<?php } else { ?>
								없음
							<?php } ?>
						</td>
					</tr>
					<!--
					<tr>
						<th scope="row">주 소</th>
						<td><?php echo get_text(sprintf("(%s%s)", $od['od_zip1'], $od['od_zip2']).' '.print_address($od['od_addr1'], $od['od_addr2'], $od['od_addr3'], $od['od_addr_jibeon'])); ?></td>
					</tr>
					-->
					<tr>
						<th scope="row">E-mail</th>
						<td><?php echo get_text($od['od_email']); ?></td>
					</tr>
					</tbody>
					</table>
				</div>
			</section>

			<section id="sod_fin_receiver" style="display:none;">
				<h3>받으시는 분</h3>

				<div class="tbl_head01 tbl_wrap">
					<table>

					<tbody>
					<tr>
						<th scope="row">이 름</th>
						<td><?php echo get_text($od['od_b_name']); ?></td>
					</tr>
					<tr>
						<th scope="row">전화번호</th>
						<td><?php echo get_text($od['od_b_tel']); ?></td>
					</tr>
					<tr>
						<th scope="row">휴대폰</th>
						<td><?php echo "[".get_text($od['od_hp_nation'])."] ".get_text($od['od_b_hp']); ?></td>
					</tr>
					<tr>
						<th scope="row">주 소</th>
						<td><?php echo get_text(sprintf("(%s%s)", $od['od_b_zip1'], $od['od_b_zip2']).' '.print_address($od['od_b_addr1'], $od['od_b_addr2'], $od['od_b_addr3'], $od['od_b_addr_jibeon'])); ?></td>
					</tr>
					<?php
					// 희망배송일을 사용한다면
					if ($default['de_hope_date_use'])
					{
					?>
					<tr>
						<th scope="row">희망배송일</th>
						<td><?php echo substr($od['od_hope_date'],0,10).' ('.get_yoil($od['od_hope_date']).')' ;?></td>
					</tr>
					<?php }
					if ($od['od_memo'])
					{
					?>
					<tr>
						<th scope="row">전하실 말씀</th>
						<td><?php echo conv_content($od['od_memo'], 0); ?></td>
					</tr>
					<?php } ?>
					</tbody>
					</table>
				</div>
			</section>

			<section id="sod_fin_dvr" style="display:none;">
				<h3>배송정보</h3>

				<div class="tbl_head01 tbl_wrap">
					<table>

					<tbody>
					<?php
					if ($od['od_invoice'] && $od['od_delivery_company'])
					{
					?>
					<tr>
						<th scope="row">배송회사</th>
						<td><?php echo $od['od_delivery_company']; ?> <?php echo get_delivery_inquiry($od['od_delivery_company'], $od['od_invoice'], 'dvr_link'); ?></td>
					</tr>
					<tr>
						<th scope="row">운송장번호</th>
						<td><?php echo $od['od_invoice']; ?></td>
					</tr>
					<tr>
						<th scope="row">배송일시</th>
						<td><?php echo $od['od_invoice_time']; ?></td>
					</tr>
					<?php
					}
					else
					{
					?>
					<tr>
						<td class="empty_table">아직 배송하지 않았거나 배송정보를 입력하지 못하였습니다.</td>
					</tr>
					<?php
					}
					?>
					</tbody>
					</table>
				</div>
			</section>
		</div>

		<div class="sod_right" style="width:35%;">
			<ul id="sod_bsk_tot">
				<li class="sod_bsk_dvr" style="display:none;">
					<span>주문총액</span>
					<strong><?php echo number_format($od['od_cart_price']); ?> 원</strong>
				</li>
				<?php if($od['od_cart_coupon'] > 0) { ?>
				<li class="sod_bsk_dvr">
					<span>개별상품 쿠폰할인</span>
					<strong><?php echo number_format($od['od_cart_coupon']); ?> 원</strong>

				</li>
				<?php } ?>
				<?php if($od['od_coupon'] > 0) { ?>
				<li class="sod_bsk_dvr">
					<span>주문금액 쿠폰할인</span>
					<strong><?php echo number_format($od['od_coupon']); ?> 원</strong>

				</li>
				<?php } ?>
				<?php if ($od['od_send_cost'] > 0) { ?>
				<li class="sod_bsk_dvr">
					<span>배송비</span>
					<strong><?php echo number_format($od['od_send_cost']); ?> 원</strong>

				</li>
				<?php } ?>
				<?php if($od['od_send_coupon'] > 0) { ?>
				<li class="sod_bsk_dvr">
					<span>배송비 쿠폰할인</span>
					<strong><?php echo number_format($od['od_send_coupon']); ?> 원</strong>

				</li>
				<?php } ?>
				<?php if ($od['od_send_cost2'] > 0) { ?>
				<li class="sod_bsk_dvr">
					<span>추가배송비</span>
					<strong><?php echo number_format($od['od_send_cost2']); ?> 원</strong>
				</li>
				<?php } ?>
				<?php if ($od['od_cancel_price'] > 0) { ?>
				<li class="sod_bsk_dvr">
					<span>취소금액</span>
					<strong><?php echo number_format($od['od_cancel_price']); ?> 원</strong>

				</li>
				<?php } ?>
				<li class="sod_bsk_cnt">
					<span>총계</span>
					<strong><?php echo $target_nation_flag_img; ?><?php echo $od_fx_amount_display; ?> <?php echo $target_currency; ?></strong>
				</li>
				<li class="sod_bsk_point" style="display:none;">
					<span>적립포인트</span>
					<strong><?php echo number_format($tot_point); ?> Point</strong>
				</li>
			</ul>

			<section id="sod_fin_tot">
				<h2>출금합계</h2>

				<ul>
					<!-- <li>
						총구매액
						<strong><?php echo $target_nation_flag_img; ?><?php echo $od_fx_amount_display; ?> <?php echo $target_currency; ?></strong>
					</li> -->

					<?php
						if ($misu_price > 0 && $receipt_price == 0) {
							echo '<li style="height:40px; line-height:40px; padding:0px 15px;">';
							echo '<span>미수령액</span>'.PHP_EOL;
							switch (substr($od['od_fx_type'],3,3)) {
								case 'KRW':
									echo '<strong style="font-size:15px;">'.$target_nation_flag_img.number_format($misu_price * $od_fx_rate, 0).' '.$target_currency.'</strong>';
									break;
								case 'USD':
									echo '<strong style="font-size:15px;">'.$target_nation_flag_img.number_format($misu_price * $od_fx_rate, 2).' '.$target_currency.'</strong>';
									break;
								case 'EUR':
									echo '<strong style="font-size:15px;">'.$target_nation_flag_img.number_format($misu_price * $od_fx_rate, 2).' '.$target_currency.'</strong>';
									break;
								case 'CNY':
									echo '<strong style="font-size:15px;">'.$target_nation_flag_img.number_format($misu_price * $od_fx_rate, 2).' '.$target_currency.'</strong>';
									break;
								case 'JPY':
									echo '<strong style="font-size:15px;">'.$target_nation_flag_img.number_format($misu_price * $od_fx_rate, 0).' '.$target_currency.'</strong>';
									break;
								case 'VND':
									echo '<strong style="font-size:15px;">'.$target_nation_flag_img.number_format($misu_price * $od_fx_rate, 0).' '.$target_currency.'</strong>';
									break;
							}
							echo '</li>';
						}
					?>

					<?php
					if ($receipt_price > 0) {
					?>
						<li id="alrdy" style="height:40px; line-height:40px; padding:0px 15px;">
							실수령금액
							<strong style="font-size:15px;">
							<?php
								if ($wanbul == " (완불)") {
									switch (substr($od['od_fx_type'],3,3)) {
										case 'KRW':
											echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 0).' '.$target_currency;
											break;
										case 'USD':
											echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
											break;
										case 'EUR':
											echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
											break;
										case 'CNY':
											echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
											break;
										case 'JPY':
											echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 0).' '.$target_currency;
											break;
										case 'VND':
											echo trim($wanbul).' '.$target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 0).' '.$target_currency;
											break;
									}
								} else {
									switch (substr($od['od_fx_type'],3,3)) {
										case 'KRW':
											echo $target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 0).' '.$target_currency;
											break;
										case 'USD':
											echo $target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
											break;
										case 'EUR':
											echo $target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
											break;
										case 'CNY':
											echo $target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 2).' '.$target_currency;
											break;
										case 'JPY':
											echo $target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 0).' '.$target_currency;
											break;
										case 'VND':
											echo $target_nation_flag_img.number_format($receipt_price * $od_fx_rate, 0).' '.$target_currency;
											break;
									}
								}
							?>
							</strong>
							<?php if( $od['od_receipt_point'] ){    //포인트로 결제한 내용이 있으면 ?>
							<div class="right">
								<p><span class="title"><i class="fa fa-angle-right" aria-hidden="true"></i> 포인트 결제</span><?php echo number_format($od['od_receipt_point']); ?> 점</p>
								<p><span class="title"><i class="fa fa-angle-right" aria-hidden="true"></i> 실결제</span><?php echo number_format($od['od_receipt_price']); ?> 원</p>
							</div>
							<?php } ?>
						</li>
					<?php
					}
					?>

					<?php
						if ($misu_price > 0 && $receipt_price > 0) {
							// echo '<li style="color:orangered;">';
							// echo '미송금액'.PHP_EOL;
							// echo '<strong>'.$target_nation_flag_img.number_format($misu_price * $od_fx_rate, 2).' '.$target_currency.'</strong>';
							// echo '</li>';
						}
					?>

				</ul>
			</section>

			<?php
			/* 컴뷰어스를 위해 코멘트 처리함 JSLEE 2024-02-19
			?>

			<section id="sod_fin_cancel">
				<h2>주문취소</h2>
				<?php
				// 취소한 내역이 없다면
				if ($cancel_price == 0) {
					if ($custom_cancel) {
				?>

				<button type="button" onclick="document.getElementById('sod_fin_cancelfrm').style.display='block';">주문 취소하기</button>

				<div id="sod_fin_cancelfrm">
					<form method="post" action="./orderinquirycancel.php" onsubmit="return fcancel_check(this);">
					<input type="hidden" name="od_id"  value="<?php echo $od['od_id']; ?>">
					<input type="hidden" name="token"  value="<?php echo $token; ?>">

					<label for="cancel_memo" class="sound_only">취소사유</label>
					<input type="text" name="cancel_memo" id="cancel_memo" required class="frm_input required" size="40" maxlength="100" placeholder="취소사유">
					<input type="submit" value="확인" class="btn_frmline">

					</form>
				</div>

				<?php
					}
				} else {
				?>
				<p>주문 취소, 반품, 품절된 내역이 있습니다.</p>
				<?php } ?>
			</section>

			<?php
			*/
			?>
		</div>
	</div>




    <?php if ($od['od_settle_case'] == '가상계좌' && $od['od_misu'] > 0 && $default['de_card_test'] && $is_admin && $od['od_pg'] == 'kcp') {
    preg_match("/\s{1}([^\s]+)\s?/", $od['od_bank_account'], $matchs);
    $deposit_no = trim($matchs[1]);
    ?>
    <p>관리자가 가상계좌 테스트를 한 경우에만 보입니다.</p>
    <div class="tbl_frm01 tbl_wrap">
        <form method="post" action="http://devadmin.kcp.co.kr/Modules/Noti/TEST_Vcnt_Noti_Proc.jsp" target="_blank">
        <table>
        <caption>모의입금처리</caption>
        <colgroup>
            <col class="grid_3">
            <col>
        </colgroup>
        <tbody>
        <tr>
            <th scope="col"><label for="e_trade_no">KCP 거래번호</label></th>
            <td><input type="text" name="e_trade_no" value="<?php echo $od['od_tno']; ?>"></td>
        </tr>
        <tr>
            <th scope="col"><label for="deposit_no">입금계좌</label></th>
            <td ><input type="text" name="deposit_no" value="<?php echo $deposit_no; ?>"></td>
        </tr>
        <tr>
            <th scope="col"><label for="req_name">입금자명</label></th>
            <td><input type="text" name="req_name" value="<?php echo $od['od_deposit_name']; ?>"></td>
        </tr>
        <tr>
            <th scope="col"><label for="noti_url">입금통보 URL</label></th>
            <td><input type="text" name="noti_url" value="<?php echo G5_URL.'/shoppoint/'; ?>/settle_kcp_common.php"></td>
        </tr>
        </tbody>
        </table>
        <div id="sod_fin_test" class="btn_confirm">
            <input type="submit" value="입금통보 테스트" class="btn_submit">
        </div>
        </form>
    </div>
    <?php } ?>

</div>
<!-- } 주문상세내역 끝 -->

<?php
$setup_href = '';
if(function_exists('apms_rows') && function_exists('apms_unpack') && function_exists('apms_skin_thema')) {
	$skin_row = apms_rows('order_'.MOBILE_.'skin, order_'.MOBILE_.'set');
	$skin_name = isset($skin_row['order_'.MOBILE_.'skin']) ? $skin_row['order_'.MOBILE_.'skin'] : '';
	$order_skin_path = G5_SKIN_PATH.'/apms/order/'.$skin_name;
	$order_skin_url = G5_SKIN_URL.'/apms/order/'.$skin_name;
	list($order_skin_path, $order_skin_url) = apms_skin_thema('shop/order', $order_skin_path, $order_skin_url);
	if(is_file($order_skin_path.'/setup.skin.php') && (isset($is_demo) && $is_demo || isset($is_designer) && $is_designer)) {
		$setup_href = './skin.setup.php?skin=order&amp;name='.urlencode($skin_name).'&amp;ts='.urlencode(THEMA);
	}
}
?>

<style>
.oi-fixed-actionbar {
	display: flex;
	justify-content: center;
	align-items: center;
	gap: 6px;
	max-width: 1170px;
	margin: 12px auto 0;
	padding: 0 8px;
}
.oi-fixed-actionbar .btn {
	height: 38px;
	min-width: 104px;
	padding: 0 12px;
	line-height: 36px;
	font-size: 13px;
	font-weight: 700;
	border-radius: 0;
}
@media (max-width: 991px) {
	.oi-fixed-actionbar {
		justify-content: center;
		flex-wrap: wrap;
	}
	.oi-fixed-actionbar .btn {
		min-width: 92px;
		height: 34px;
		line-height: 32px;
		font-size: 12px;
	}
}
</style>

<p class="print-hide text-center oi-fixed-actionbar">
	<a class="btn btn-color btn-sm" href="<?php echo $at_href['withdrawalinquiry']; ?>"><i class="fa fa-bars"></i> 목록으로</a>
	<button type="button" onclick="apms_print();" class="btn btn-black btn-sm"><i class="fa fa-print"></i> 프린트</button>
	<?php if($setup_href) { ?>
		<a class="btn btn-color btn-sm win_memo" href="<?php echo $setup_href; ?>">
			<i class="fa fa-cogs"></i> 스킨설정
		</a>
	<?php } ?>
</p>

<script>
$(function() {
    $("#sod_sts_explan_open").on("click", function() {
        var $explan = $("#sod_sts_explan");
        if($explan.is(":animated"))
            return false;

        if($explan.is(":visible")) {
            $explan.slideUp(200);
            $("#sod_sts_explan_open").text("상태설명보기");
        } else {
            $explan.slideDown(200);
            $("#sod_sts_explan_open").text("상태설명닫기");
        }
    });

    $("#sod_sts_explan_close").on("click", function() {
        var $explan = $("#sod_sts_explan");
        if($explan.is(":animated"))
            return false;

        $explan.slideUp(200);
        $("#sod_sts_explan_open").text("상태설명보기");
    });
});

function fcancel_check(f)
{
    if(!confirm("주문을 정말 취소하시겠습니까?"))
        return false;

    var memo = f.cancel_memo.value;
    if(memo == "") {
        alert("취소사유를 입력해 주십시오.");
        return false;
    }

    return true;
}
</script>

<?php
include_once('./_tail.php');
?>
