<?php
$sub_menu = '400900';
include_once('./_common.php');

$cart_title3 = '주문번호';
$cart_title4 = '배송완료';

auth_check($auth[$sub_menu], "w");

$g5['title'] = "포인트구매 - 주문 내역 수정";
include_once(G5_ADMIN_PATH.'/admin.head.php');

// 완료된 주문에 포인트를 적립한다.
save_order_point("완료");

//------------------------------------------------------------------------------
// 주문서 정보
//------------------------------------------------------------------------------
$sql = " select * from g5_shoppoint_order where od_id = '$od_id' ";
$od = sql_fetch($sql);
if (!(isset($od['od_id']) && $od['od_id'])) {
    alert("해당 주문번호로 주문서가 존재하지 않습니다.");
}

$od['mb_id'] = $od['mb_id'] ? $od['mb_id'] : "비회원";

$od_misu = $od['od_misu'];
$od_status = $od['od_status'];
$od_cart_price = $od['od_cart_price'];
$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'];
$od_settle_case = $od['od_settle_case'];
$od_time = $od['od_time'];
$od_bank_account = $od['od_bank_account'];
$od_deposit_name = $od['od_deposit_name'];

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;
}

$krw_nation_flag_img = "<img src='".G5_DATA_URL."/item/img_nation_flag/svg/kr.svg' class='nation_flag_img2'>";

//------------------------------------------------------------------------------

$pg_anchor = '<ul class="anchor">
<li><a href="#anc_sodr_list">주문상품 목록</a></li>
<li><a href="#anc_sodr_pay">주문결제 내역</a></li>
<li><a href="#anc_sodr_chk">결제상세정보 확인</a></li>
<li><a href="#anc_sodr_paymo">결제상세정보 수정</a></li>
<li><a href="#anc_sodr_memo">상점메모</a></li>
<li><a href="#anc_sodr_orderer">주문하신 분</a></li>
<li><a href="#anc_sodr_taker">받으시는 분</a></li>
</ul>';

$html_receipt_chk = '<input type="checkbox" id="od_receipt_chk" value="'.$od['od_fx_amount'].'" onclick="chk_receipt_price()">
<label for="od_receipt_chk">주문금액(판매금액) 입력</label><br>';

$qstr1 = "od_status=".urlencode($od_status)."&amp;od_settle_case=".urlencode($od_settle_case)."&amp;od_misu=$od_misu&amp;od_cancel_price=$od_cancel_price&amp;od_refund_price=$od_refund_price&amp;od_receipt_point=$od_receipt_point&amp;od_coupon=$od_coupon&amp;fr_date=$fr_date&amp;to_date=$to_date&amp;sel_field=$sel_field&amp;search=$search&amp;save_search=$search";
if($default['de_escrow_use'])
    $qstr1 .= "&amp;od_escrow=$od_escrow";
$qstr = "$qstr1&amp;sort1=$sort1&amp;sort2=$sort2&amp;page=$page";

// 주소 참고항목 필드추가
if(!isset($od['od_addr3'])) {
    sql_query(" ALTER TABLE `g5_shoppoint_order`
                    ADD `od_addr3` varchar(255) NOT NULL DEFAULT '' AFTER `od_addr2`,
                    ADD `od_b_addr3` varchar(255) NOT NULL DEFAULT '' AFTER `od_b_addr2` ", true);
}

// 배송목록에 참고항목 필드추가
if(!sql_query(" select ad_addr3 from g5_shoppoint_order_address limit 1", false)) {
    sql_query(" ALTER TABLE g5_shoppoint_order_address
                    ADD `ad_addr3` varchar(255) NOT NULL DEFAULT '' AFTER `ad_addr2` ", true);
}

// 결제 PG 필드 추가
if(!sql_query(" select od_pg from g5_shoppoint_order limit 1 ", false)) {
    sql_query(" ALTER TABLE `g5_shoppoint_order`
                    ADD `od_pg` varchar(255) NOT NULL DEFAULT '' AFTER `od_mobile`,
                    ADD `od_casseqno` varchar(255) NOT NULL DEFAULT '' AFTER `od_escrow` ", true);

    // 주문 결제 PG kcp로 설정
    sql_query(" update g5_shoppoint_order set od_pg = 'kcp' ");
}

// LG 현금영수증 JS
if($od['od_pg'] == 'lg') {
    if($default['de_card_test']) {
    echo '<script language="JavaScript" src="'.SHOP_TOSSPAYMENTS_CASHRECEIPT_TEST_JS.'"></script>'.PHP_EOL;
    } else {
        echo '<script language="JavaScript" src="'.SHOP_TOSSPAYMENTS_CASHRECEIPT_REAL_JS.'"></script>'.PHP_EOL;
    }
}

// add_javascript('js 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
// add_javascript(G5_POSTCODE_JS, 0);    //다음 주소 js

// 판매자센터
$is_use_partner = (defined('USE_PARTNER') && USE_PARTNER) ? true : false;
?>

<style>
.small-decimal {
    font-size: 0.8em; /* 소수점 이하 숫자를 작게 표시 */
    color: red; /* 눈에 띄는 색상으로 변경 */
}
</style>

<section id="anc_sodr_list">
    <h2 class="h2_frm">주문상품 목록</h2>
    <?php echo $pg_anchor; ?>
    <div class="local_desc02 local_desc">
        <p>
            현재 주문상태 <strong><?php echo $od['od_status'] ?></strong>
            |
            주문일시 <strong><?php echo substr($od['od_time'],0,16); ?> (<?php echo get_yoil($od['od_time']); ?>)</strong>
            |
            주문총액 <strong><?php echo number_format($od['od_cart_price'] + $od['od_send_cost'] + $od['od_send_cost2']); ?></strong>원
        </p>
        <?php if ($default['de_hope_date_use']) { ?><p>희망배송일은 <?php echo $od['od_hope_date']; ?> (<?php echo get_yoil($od['od_hope_date']); ?>) 입니다.</p><?php } ?>
        <?php if($od['od_mobile']) { ?>
        <p>모바일 쇼핑몰의 주문입니다.</p>
        <?php } ?>
    </div>

    <form name="frmorderform" method="post" action="./orderformcartupdate4shoppoint.php" onsubmit="return form_submit(this);">
    <input type="hidden" name="od_id" value="<?php echo $od_id; ?>">
    <input type="hidden" name="mb_id" value="<?php echo $od['mb_id']; ?>">
    <input type="hidden" name="od_email" value="<?php echo $od['od_email']; ?>">
    <input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
    <input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
    <input type="hidden" name="sel_field" value="<?php echo $sel_field; ?>">
    <input type="hidden" name="search" value="<?php echo $search; ?>">
    <input type="hidden" name="page" value="<?php echo $page;?>">
    <input type="hidden" name="pg_cancel" value="0">

    <div class="tbl_head01 tbl_wrap">

        <table>
        <caption>주문 상품 목록</caption>
        <thead>
        <tr>
            <th scope="col" style="background:#28a745;">
                <label for="sit_select_all" class="sound_only">주문 상품 전체</label>
                <input type="checkbox" id="sit_select_all">
            </th>
			<?php if($is_use_partner) { ?>
				<th scope="col" style="background:#28a745;">판매자센터</th>
			<?php } ?>
			<th scope="col" style="background:#28a745;">이미지</th>
            <th scope="col" style="background:#28a745;">주문일시</th>
			<th scope="col" style="background:#28a745;">상품명</th>
   			<th scope="col" style="background:#28a745;">상태</th>
            <th scope="col" style="background:#28a745;">주문포인트</th>
            <th scope="col" style="background:#28a745;">판매가</th>
            <th scope="col" style="background:#28a745;">적용환율(1KRW→<?php echo $target_currency?>)</th>
            <th scope="col" style="background:#28a745;">적용환율(1<?php echo $target_currency?>→KRW)</th>
            <th scope="col" style="background:#28a745;">입금방법</th>
            <th scope="col" style="background:#28a745;">입금계좌</th>
            <th scope="col" style="background:#28a745;">입금자명</th>
        </tr>
        </thead>
        <tbody>
        <?php
		$chk_cnt = 0;
        ?>
        <tr>
            <td class="td_chk">
                <label for="ct_chk_<?php echo $chk_cnt; ?>" class="sound_only"><?php echo get_text($opt['ct_option']); ?></label>
                <input type="checkbox" name="ct_chk[<?php echo $chk_cnt; ?>]" id="ct_chk_<?php echo $chk_cnt; ?>" value="<?php echo $chk_cnt; ?>" class="sct_sel_<?php echo $i; ?>">
                <input type="hidden" name="ct_id[<?php echo $chk_cnt; ?>]" value="<?php echo $od['od_id']; ?>">
            </td>
            <?php if($is_use_partner) { ?>
            <td class="td_mng">
                <nobr>
                    <?php
                        if ($row['pt_id']) {
                            $p_name = '탈퇴';

                            $pmb = get_member($row['pt_id'], 'mb_nick, mb_email, mb_homepage');

                            if ($pmb['mb_nick']) {
                                $p_name = get_text($pmb['mb_nick']);
                                echo '<b>'.apms_sideview($row['pt_id'], $p_name, $pmb['mb_email'], $pmb['mb_homepage']).'</b>';
                            } else {
                                echo '<b>'.$p_name.'</b>';
                            }

                            echo '<br>('.$row['pt_id'].')';

                            $p_id = $row['pt_id'];
                            $pt_name[$p_id] = $p_name;
                        } else {
                            echo '-';
                        }
                    ?>
                </nobr>
            </td>
            <?php } ?>
            <td>
                <?php
                    echo "<style>.nation_flag_img1 {height:15px;width:auto;margin-right:5px;} .nation_flag_img2 {height:15px;width:auto;margin-right:5px;border:1px solid #ccc;}</style>";
                    $image = "<div style='display:flex; justify-content:center; align-items:center; width:40px; height:40px; padding:1px; border:5px dashed #F2CC00; border-radius:50%; background:gold; color:#333333; font-size:0.7em; margin:0 auto 0;'>POINT</div>";
                ?>
                <?php echo $image; ?>
            </td>
            <td><?php echo $od_time; ?></td>
            <td>
                포인트구매
            </td>
            <td><?php echo $od_status; ?></td>
            <td>
                <?php echo number_format($od_cart_price,0); ?> Point
                <?php
                    $sql_getpoint = " select sum(po_point) as sum_po_point
                                from {$g5['point_table']}
                                where mb_id = '{$od['mb_id']}' and po_rel_action = '{$od['od_id']}' and po_rel_table = '@buyshoppoints' ";
                    $row_getpoint = sql_fetch($sql_getpoint);
                    if ($row_getpoint['sum_po_point']) {
                        echo '<br><div style="background:#1ddb16; color:#fff; font-size:0.8em; line-height:13px; padding:2px 1px;">입금충전완료<br>'.number_format($row_getpoint['sum_po_point']).' Point</div>';
                    } else {
                        echo '<br><div style="background:#ff5e00; color:#fff; font-size:0.8em; line-height:13px; padding:2px 1px;">미충전<br>'.number_format($row_getpoint['sum_po_point']).' Point</div>';
                    }
                ?>
            </td>
            <td style="background:yellow;">
                <?php echo $target_nation_flag_img; ?>
                <?php
                    // $od_fx_amount를 소수점 기준으로 분리
                    $formatted_rate = number_format($od_fx_amount, 2);
                    list($integer_part, $decimal_part) = explode('.', $formatted_rate);
                ?>
                <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
                <?php echo $target_currency; ?>
            </td>
            <td>
                <?php echo $target_nation_flag_img; ?>
                <?php
                    // $od_fx_rate를 소수점 기준으로 분리
                    $formatted_rate = number_format($od_fx_rate, 5);
                    list($integer_part, $decimal_part) = explode('.', $formatted_rate);
                ?>
                <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
                <?php echo $target_currency?>
            </td>
            <td>
                <?php echo $krw_nation_flag_img; ?>
                <?php
                    // $od_fx_rate를 소수점 기준으로 분리
                    $formatted_rate = number_format(1/$od_fx_rate, 5);
                    list($integer_part, $decimal_part) = explode('.', $formatted_rate);
                ?>
                <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
                KRW
            </td>
            <td><?php echo $od_settle_case; ?></td>
            <td><?php echo $od_bank_account; ?></td>
            <td><?php echo $od_deposit_name; ?></td>
        </tr>
        <?php
            $chk_cnt++;
        ?>

        </tbody>
        </table>

    </div>

    <div class="btn_list02 btn_list">
        <p>
            <input type="hidden" name="chk_cnt" value="<?php echo $chk_cnt; ?>">
            <strong>주문 및 장바구니 상태 변경</strong>
            <input type="submit" name="ct_status" value="주문" onclick="document.pressed=this.value" class="btn_02 color_01">
            <input type="submit" name="ct_status" value="입금" onclick="document.pressed=this.value" class="btn_02 color_02">
            <input type="submit" name="ct_status" value="준비" onclick="document.pressed=this.value" class="btn_02 color_03">
            <input type="submit" name="ct_status" value="배송" onclick="document.pressed=this.value" class="btn_02 color_04">
            <input type="submit" name="ct_status" value="완료" onclick="document.pressed=this.value" class="btn_02 color_05">
            <input type="submit" name="ct_status" value="취소" onclick="document.pressed=this.value" class="btn_02 color_06">
            <input type="submit" name="ct_status" value="반품" onclick="document.pressed=this.value" class="btn_02 color_06">
            <input type="submit" name="ct_status" value="품절" onclick="document.pressed=this.value" class="btn_02 color_06">
		</p>
    </div>

    <div class="local_desc01 local_desc">
        <p>주문, 입금, 준비, 배송, 완료는 장바구니와 주문서 상태를 모두 변경하지만, 취소, 반품, 품절은 장바구니의 상태만 변경하며, 주문서 상태는 변경하지 않습니다.</p>
        <p>개별적인(이곳에서의) 상태 변경은 모든 작업을 수동으로 처리합니다. 예를 들어 주문에서 입금으로 상태 변경시 입금액(결제금액)을 포함한 모든 정보는 수동 입력으로 처리하셔야 합니다.</p>
    </div>

    </form>

    <?php if ($od['od_mod_history']) { ?>
    <section id="sodr_qty_log">
        <h3>주문 수량변경 및 주문 전체취소 처리 내역</h3>
        <div style="white-space:pre-line;">
            <?php echo conv_content($od['od_mod_history'], 0); ?>
        </div>
    </section>
    <?php } ?>

</section>

<?php if($od['od_test']) { ?>
<div class="od_test_caution">주의) 이 주문은 테스트용으로 실제 결제가 이루어지지 않았으므로 절대 충전하시면 안됩니다.</div>
<?php } ?>
<?php if($od['od_pg'] === 'inicis' && !$od['od_test']) {
    $sql = "select P_TID from g5_shoppoint_inicis_log_table where oid = '$od_id' and P_STATUS = 'cancel' ";
    $tmp_row = sql_fetch($sql);
    if($tmp_row['P_TID']){
?>
<div class="od_test_caution">주의) 이 주문은 결제취소된 내역이 있습니다. 이니시스 관리자 상점에서 반드시 재확인을 해 주세요.</div>
<?php
    }   //end if
}   //end if
?>

<section id="anc_sodr_pay">
    <h2 class="h2_frm">주문결제 내역</h2>
    <?php echo $pg_anchor; ?>

    <?php
    // 주문금액 = 상품구입금액 + 배송비 + 추가배송비
    $amount['order'] = $od['od_cart_price'] + $od['od_send_cost'] + $od['od_send_cost2'];

    // 입금액 = 결제금액 + 포인트
    $amount['receipt'] = $od['od_receipt_price'] + $od['od_receipt_point'];

    // 쿠폰금액
    $amount['coupon'] = $od['od_cart_coupon'] + $od['od_coupon'] + $od['od_send_coupon'];

    // 취소금액
    $amount['cancel'] = $od['od_cancel_price'];

    // 미수금 = 주문금액 - 취소금액 - 입금금액 - 쿠폰금액
    //$amount['미수'] = $amount['order'] - $amount['receipt'] - $amount['coupon'];

    // 결제방법
    $s_receipt_way = ($od['pt_case']) ? $od['pt_case'] : $od['od_settle_case'];

    if($od['od_settle_case'] == '간편결제') {
        switch($od['od_pg']) {
            case 'lg':
                $s_receipt_way = 'PAYNOW';
                break;
            case 'inicis':
                $s_receipt_way = 'KPAY';
                break;
            case 'kcp':
                $s_receipt_way = 'PAYCO';
                break;
            default:
                $s_receipt_way = $row['od_settle_case'];
                break;
        }
    }

    if ($od['od_receipt_point'] > 0)
        $s_receipt_way .= "+포인트";
    ?>

    <div class="tbl_head01 tbl_wrap">
        <strong class="sodr_nonpay">미수금
        <?php echo $target_nation_flag_img; ?>
        <?php
            // $od_fx_amount를 소수점 기준으로 분리
            $formatted_rate = number_format($od['od_misu'] * $od_fx_rate, 2);
            list($integer_part, $decimal_part) = explode('.', $formatted_rate);
        ?>
        <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
        <?php echo $target_currency; ?></strong>

        <table>
        <caption>주문결제 내역</caption>
        <thead>
        <tr>
            <th scope="col" style="background:#28a745;">주문번호</th>
            <th scope="col" style="background:#28a745;">결제방법</th>
            <th scope="col" style="background:#28a745;">주문총액</th>
            <th scope="col" style="background:#28a745;">배송비</th>
            <th scope="col" style="background:#28a745;">포인트결제</th>
            <th scope="col" style="background:#28a745;">총결제액</th>
            <th scope="col" style="background:#28a745;">쿠폰</th>
            <th scope="col" style="background:#28a745;">주문취소</th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <td><?php echo $od['od_id']; ?></td>
            <td><?php echo $s_receipt_way; ?></td>
            <td>
                <?php echo $target_nation_flag_img; ?>
                <?php
                    // $od_fx_amount를 소수점 기준으로 분리
                    $formatted_rate = number_format($od_fx_amount, 2);
                    list($integer_part, $decimal_part) = explode('.', $formatted_rate);
                ?>
                <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
                <?php echo $target_currency; ?>
            </td>
            <td><?php echo display_price($od['od_send_cost'] + $od['od_send_cost2']); ?></td>
            <td><?php echo display_point($od['od_receipt_point']); ?></td>
            <td>
				<?php echo number_format($amount['receipt']); ?>원
				<?php if($od['pt_price']) { //페이팔 등 결제금액 ?>
					<br />(<?php echo $od['pt_price'];?>)
				<?php } ?>
			</td>
            <td><?php echo display_price($amount['coupon']); ?></td>
            <td><?php echo number_format($amount['cancel']); ?>원</td>
        </tr>
        </tbody>
        </table>
    </div>
</section>

<section class="">
    <h2 class="h2_frm">결제상세정보</h2>
    <?php echo $pg_anchor; ?>

    <form name="frmorderreceiptform" action="./orderformreceiptupdate4shoppoint.php" method="post" autocomplete="off">
    <input type="hidden" name="od_id" value="<?php echo $od_id; ?>">
    <input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
    <input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
    <input type="hidden" name="sel_field" value="<?php echo $sel_field; ?>">
    <input type="hidden" name="search" value="<?php echo $search; ?>">
    <input type="hidden" name="page" value="<?php echo $page; ?>">
    <input type="hidden" name="od_name" value="<?php echo $od['od_name']; ?>">
    <input type="hidden" name="od_hp" value="<?php echo $od['od_hp']; ?>">
    <input type="hidden" name="od_tno" value="<?php echo $od['od_tno']; ?>">
    <input type="hidden" name="od_escrow" value="<?php echo $od['od_escrow']; ?>">
    <input type="hidden" name="od_pg" value="<?php echo $od['od_pg']; ?>">

    <div class="compare_wrap">

        <section id="anc_sodr_chk" class="compare_left">
            <h3>결제상세정보 확인</h3>

            <div class="tbl_frm01">
                <table>
                <caption>결제상세정보</caption>
                <colgroup>
                    <col class="grid_3">
                    <col>
                </colgroup>
                <tbody>
				<?php if($od['pt_case']) { ?>
					<tr>
						<th scope="row">결제방법</th>
						<td><?php echo $od['pt_case']; ?></td>
					</tr>
					<tr>
						<th scope="row">결제금액</th>
						<td><?php echo $od['pt_price']; ?></td>
					</tr>
					<tr>
						<th scope="row">결제정보</th>
						<td><?php echo get_text($od['pt_memo']); ?></td>
					</tr>
					<tr>
						<th scope="row">결제일시</th>
						<td>
							<?php echo $od['od_receipt_time']; ?> (<?php echo get_yoil($od['od_receipt_time']); ?>)
						</td>
					</tr>
				<?php } else { ?>
					<?php if ($od['od_settle_case'] == '무통장' || $od['od_settle_case'] == '가상계좌' || $od['od_settle_case'] == '계좌이체') { ?>
					<?php if ($od['od_settle_case'] == '무통장' || $od['od_settle_case'] == '가상계좌') { ?>
					<tr>
						<th scope="row">계좌번호</th>
						<td><?php echo get_text($od['od_bank_account']); ?></td>
					</tr>
					<?php } ?>
					<tr>
						<th scope="row"><?php echo $od['od_settle_case']; ?> 입금액</th>
						<td>
                            <?php echo $target_nation_flag_img; ?>
                            <?php
                                // $od_fx_amount를 소수점 기준으로 분리
                                $formatted_rate = number_format($od['od_receipt_price'] * $od_fx_rate, 2);
                                list($integer_part, $decimal_part) = explode('.', $formatted_rate);
                            ?>
                            <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
                            <?php echo $target_currency; ?>
                        </td>
					</tr>
					<tr>
						<th scope="row">입금자</th>
						<td><?php echo get_text($od['od_deposit_name']); ?></td>
					</tr>
					<tr>
						<th scope="row">입금 확인일시</th>
						<td>
							<?php if ($od['od_receipt_time'] == 0) { ?>입금 확인일시를 체크해 주세요.
							<?php } else { ?><?php echo G5_TIMEZONE; ?> <?php echo $od['od_receipt_time']; ?> (<?php echo get_yoil($od['od_receipt_time']); ?>)
							<?php } ?>
						</td>
					</tr>
					<?php } ?>
				<?php } ?>
				<?php if ($od['od_settle_case'] == '포인트') { ?>
                <tr>
                    <th scope="row">결제 확인일시</th>
                    <td>
                       <?php echo $od['od_receipt_time']; ?> (<?php echo get_yoil($od['od_receipt_time']); ?>)
                    </td>
                </tr>
                <?php } ?>
				<?php if ($od['od_settle_case'] == '휴대폰') { ?>
                <tr>
                    <th scope="row">휴대폰번호</th>
                    <td><?php echo get_text($od['od_bank_account']); ?></td>
                    </tr>
                <tr>
                    <th scope="row"><?php echo $od['od_settle_case']; ?> 결제액</th>
                    <td><?php echo display_price($od['od_receipt_price']); ?></td>
                </tr>
                <tr>
                    <th scope="row">결제 확인일시</th>
                    <td>
                        <?php if ($od['od_receipt_time'] == 0) { ?>결제 확인일시를 체크해 주세요.
                        <?php } else { ?><?php echo $od['od_receipt_time']; ?> (<?php echo get_yoil($od['od_receipt_time']); ?>)
                        <?php } ?>
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] == '신용카드') { ?>
                <tr>
                    <th scope="row" class="sodr_sppay">신용카드 결제금액</th>
                    <td>
                        <?php if ($od['od_receipt_time'] == "0000-00-00 00:00:00") {?>0원
                        <?php } else { ?><?php echo display_price($od['od_receipt_price']); ?>
                        <?php } ?>
                    </td>
                </tr>
                <tr>
                    <th scope="row" class="sodr_sppay">카드 승인일시</th>
                    <td>
                        <?php if ($od['od_receipt_time'] == "0000-00-00 00:00:00") {?>신용카드 결제 일시 정보가 없습니다.
                        <?php } else { ?><?php echo substr($od['od_receipt_time'], 0, 20); ?>
                        <?php } ?>
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] == 'KAKAOPAY') { ?>
                <tr>
                    <th scope="row" class="sodr_sppay">KAKOPAY 결제금액</th>
                    <td>
                        <?php if ($od['od_receipt_time'] == "0000-00-00 00:00:00") {?>0원
                        <?php } else { ?><?php echo display_price($od['od_receipt_price']); ?>
                        <?php } ?>
                    </td>
                </tr>
                <tr>
                    <th scope="row" class="sodr_sppay">KAKAOPAY 승인일시</th>
                    <td>
                        <?php if ($od['od_receipt_time'] == "0000-00-00 00:00:00") {?>신용카드 결제 일시 정보가 없습니다.
                        <?php } else { ?><?php echo substr($od['od_receipt_time'], 0, 20); ?>
                        <?php } ?>
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] == '간편결제' || ($od['od_pg'] == 'inicis' && is_inicis_order_pay($od['od_settle_case']) ) ) { ?>
                <tr>
                    <th scope="row" class="sodr_sppay"><?php echo $s_receipt_way; ?> 결제금액</th>
                    <td>
                        <?php if ($od['od_receipt_time'] == "0000-00-00 00:00:00") {?>0원
                        <?php } else { ?><?php echo display_price($od['od_receipt_price']); ?>
                        <?php } ?>
                    </td>
                </tr>
                <tr>
                    <th scope="row" class="sodr_sppay"><?php echo $s_receipt_way; ?> 승인일시</th>
                    <td>
                        <?php if ($od['od_receipt_time'] == "0000-00-00 00:00:00") { echo $s_receipt_way; ?> 결제 일시 정보가 없습니다.
                        <?php } else { ?><?php echo substr($od['od_receipt_time'], 0, 20); ?>
                        <?php } ?>
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] != '무통장' && $od['od_settle_case'] != '포인트') { ?>
                <tr>
                    <th scope="row">결제대행사 링크</th>
                    <td>
                        <?php
                        if ($od['od_settle_case'] != '무통장' && $od['od_settle_case'] != '포인트') {
                            switch($od['od_pg']) {
                                case 'lg':
                                    $pg_url  = 'http://pgweb.uplus.co.kr';
                                    $pg_test = '토스페이먼츠';
                                    if ($default['de_card_test']) {
                                        $pg_url = 'http://pgweb.uplus.co.kr/tmert';
                                        $pg_test .= ' 테스트 ';
                                    }
                                    break;
                                case 'inicis':
                                    $pg_url  = 'https://iniweb.inicis.com/';
                                    $pg_test = 'KG이니시스';
                                    break;
                                case 'KAKAOPAY':
                                    $pg_url  = 'https://mms.cnspay.co.kr';
                                    $pg_test = 'KAKAOPAY';
                                    break;
								default:
                                    $pg_url  = 'http://admin8.kcp.co.kr';
                                    $pg_test = 'KCP';
                                    if ($default['de_card_test']) {
                                        // 로그인 아이디 / 비번
                                        // 일반 : test1234 / test12345
                                        // 에스크로 : escrow / escrow913
                                        $pg_url = 'http://testadmin8.kcp.co.kr';
                                        $pg_test .= ' 테스트 ';
                                    }

                                }
                            echo "<a href=\"{$pg_url}\" target=\"_blank\">{$pg_test}바로가기</a><br>";
                        }
                        //------------------------------------------------------------------------------
                        ?>
                    </td>
                </tr>
                <?php } ?>

                <?php if($od['od_tax_flag']) { ?>
                <tr>
                    <th scope="row">과세공급가액</th>
                    <td><?php echo display_price($od['od_tax_mny']); ?></td>
                </tr>
                <tr>
                    <th scope="row">과세부가세액</th>
                    <td><?php echo display_price($od['od_vat_mny']); ?></td>
                </tr>
                <tr>
                    <th scope="row">비과세공급가액</th>
                    <td><?php echo display_price($od['od_free_mny']); ?></td>
                </tr>
                <?php } ?>
                <tr>
                    <th scope="row">주문금액할인(쿠폰할인)</th>
                    <td>
                        <?php echo $target_nation_flag_img; ?>
                        <?php
                            // $od_fx_amount를 소수점 기준으로 분리
                            $formatted_rate = number_format($od['od_coupon'], 2);
                            list($integer_part, $decimal_part) = explode('.', $formatted_rate);
                        ?>
                        <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
                        <?php echo $target_currency; ?>
                    </td>
                </tr>
                <tr>
                    <th scope="row">포인트 결제액</th>
                    <td><?php echo number_format($od['od_receipt_point']) . " Point"; ?></td>
                </tr>
                <tr>
                    <th scope="row">결제취소/환불금액</th>
                    <td>
                        <?php echo $target_nation_flag_img; ?>
                        <?php
                            // $od_fx_amount를 소수점 기준으로 분리
                            $formatted_rate = number_format($od['od_refund_price'], 2);
                            list($integer_part, $decimal_part) = explode('.', $formatted_rate);
                        ?>
                        <?php echo $integer_part; ?>.<span class="small-decimal"><?php echo $decimal_part; ?></span>
                        <?php echo $target_currency; ?>
                    </td>
                </tr>
                <?php if ($od['od_invoice']) { ?>
                <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 is_null_time($od['od_invoice_time']) ? "" : $od['od_invoice_time']; ?></td>
                </tr>
                <?php } ?>
                <tr>
                    <th scope="row"><label for="od_send_cost">배송비</label></th>
                    <td>
                        <?php echo $target_nation_flag_img; ?> <input type="text" name="od_send_cost" value="<?php echo sprintf("%.2f", ($od['od_send_cost'] * $od_fx_rate)); ?>" id="od_send_cost" class="frm_input" size="10"> <?php echo $target_currency; ?>
                    </td>
                </tr>
                <?php if($od['od_send_coupon']) { ?>
                <tr>
                    <th scope="row">배송비할인</th>
                    <td><?php echo display_price($od['od_send_coupon']); ?></td>
                </tr>
                <?php } ?>
                <tr>
                    <th scope="row"><label for="od_send_cost2">추가배송비</label></th>
                    <td>
                        <?php echo $target_nation_flag_img; ?> <input type="text" name="od_send_cost2" value="<?php echo sprintf("%.2f", ($od['od_send_cost2'] * $od_fx_rate)); ?>" id="od_send_cost2" class="frm_input" size="10"> <?php echo $target_currency; ?>
                    </td>
                </tr>
                <?php
				if ($od['od_misu'] == 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 G5_SHOP_PATH.'/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 G5_SHOP_PATH.'/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; ?>">현금영수증 확인</a>
                    <?php } else { ?>
                        <a href="javascript:;" onclick="window.open('<?php echo G5_SHOP_URL; ?>/taxsave.php?od_id=<?php echo $od_id; ?>', 'taxsave', 'width=550,height=400,scrollbars=1,menus=0');">현금영수증 발급</a>
                    <?php } ?>
                    </td>
                </tr>
                <?php
                }
                ?>
				<?php
				// 영수증
				$disp_receipt_href = '';
				$disp_receipt = ($od['od_settle_case'] == '신용카드' || $od['od_settle_case'] == '휴대폰' || $od['od_settle_case'] == 'KAKAOPAY') ? true : false;
				if($disp_receipt) {
					if($od['od_settle_case'] == '휴대폰')
					{
						if($od['od_pg'] == 'lg') {
							require_once G5_SHOP_PATH.'/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\');';
						}

						$disp_receipt_href = 'href="javascript:;" onclick="'.$hp_receipt_script.'"';
					}

					if($od['od_settle_case'] == '신용카드')
					{
						if($od['od_pg'] == 'lg') {
							require_once G5_SHOP_PATH.'/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\');';
						}

						$disp_receipt_href = 'href="javascript:;" onclick="'.$card_receipt_script.'"';
					}

					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\');';

						$disp_receipt_href = 'href="javascript:;" onclick="'.$card_receipt_script.'"';
					}
				}
				?>
				<?php if($disp_receipt_href) { ?>
					<tr>
						<th scope="row">영수증</th>
						<td><a <?php echo $disp_receipt_href;?>>영수증 출력</a></td>
					</tr>
				<?php } ?>
                </tbody>
                </table>
            </div>
        </section>

        <section id="anc_sodr_paymo" class="compare_right">
            <h3>결제상세정보 수정</h3>

            <div class="tbl_frm01">
                <table>
                <caption>결제상세정보 수정</caption>
                <colgroup>
                    <col class="grid_3">
                    <col>
                </colgroup>
                <tbody>
                <?php if ($od['od_settle_case'] == '무통장' || $od['od_settle_case'] == '가상계좌' || $od['od_settle_case'] == '계좌이체') { ########## 시작?>
                <?php
                if ($od['od_settle_case'] == '무통장')
                {
                    // 은행계좌를 배열로 만든후
                    $str = explode("\n", $default['de_bank_account']);
                    $bank_account .= '<select name="od_bank_account" id="od_bank_account">'.PHP_EOL;
                    $bank_account .= '<option value="">선택하십시오</option>'.PHP_EOL;
                    // 저장된 계좌가 없으면 통화에 맞는 첫 번째 계좌를 기본 선택
                    $_acct_cur = $od['od_bank_account'];
                    if ($_acct_cur === '' && $target_currency !== '') {
                        foreach ($str as $_al) {
                            $_al = str_replace("\r", "", trim($_al));
                            if (stripos($_al, '[' . $target_currency . ']') !== false) {
                                $_acct_cur = trim(preg_replace('/\[.*?\]\s*/', '', $_al));
                                break;
                            }
                        }
                    }
                    for ($i=0; $i<count($str); $i++) {
                        $str[$i] = str_replace("\r", "", $str[$i]);
                        // $str[$i]의 대괄호와 그 안의 내용을 제거
                        $str_cleaned = trim(preg_replace('/\[.*?\]\s*/', '', $str[$i]));
                        $bank_account .= '<option value="'.$str_cleaned.'" '.get_selected($_acct_cur, $str_cleaned).'>'.$str[$i].'</option>'.PHP_EOL;
                    }
                    $bank_account .= '</select> ';
                }
                else if ($od['od_settle_case'] == '가상계좌')
                    $bank_account = $od['od_bank_account'].'<input type="hidden" name="od_bank_account" value="'.$od['od_bank_account'].'">';
                else if ($od['od_settle_case'] == '계좌이체')
                    $bank_account = $od['od_settle_case'];
                ?>

                <?php if ($od['od_settle_case'] == '무통장' || $od['od_settle_case'] == '가상계좌') { ?>
                <tr>
                    <th scope="row"><label for="od_bank_account">계좌번호</label></th>
                    <td><?php echo $bank_account; ?></td>
                </tr>
                <?php } ?>

                <tr>
                    <th scope="row"><label for="od_receipt_price"><?php echo $od['od_settle_case']; ?> 입금액</label></th>
                    <td>
                        <?php echo $html_receipt_chk; ?>
                        <div id="receipt_price_to_pointer_price" style="color:red; font-weight:bold;"><?php echo number_format($od['od_receipt_price']); ?> Point (※입금액 자동환산)</div>
                        <div><?php echo $target_nation_flag_img; ?> <input type="text" name="od_receipt_price" value="<?php echo sprintf("%.2f", ($od['od_receipt_price'] * $od_fx_rate)); ?>" id="od_receipt_price" class="frm_input"> <?php echo $target_currency; ?></div>
                    </td>
                </tr>

                <script>
                    document.getElementById('od_receipt_price').addEventListener('input', function(e) {
                        var value = e.target.value;

                        // 처음 값이 '0'인 경우 새로운 값으로 덮어쓰기
                        if (value.length > 1 && value[0] === '0' && value[1] !== '.') {
                            value = value.substring(1);
                        }

                        // 숫자와 소수점 이외의 문자를 입력하지 못하도록 필터링
                        var sanitizedValue = value.replace(/[^0-9.]/g, '');

                        // 점(.)이 여러 개 입력되지 않도록 처리
                        var parts = sanitizedValue.split('.');
                        if (parts.length > 2) {
                            sanitizedValue = parts[0] + '.' + parts.slice(1).join('');
                        }

                        if (sanitizedValue !== value) {
                            e.target.value = sanitizedValue;
                        } else {
                            e.target.value = sanitizedValue; // Sanitize the input field value
                        }

                        // 입력된 값을 실시간으로 계산하여 div에 표시
                        var numberValue = parseFloat(sanitizedValue);
                        if (!isNaN(numberValue)) {
                            document.getElementById('receipt_price_to_pointer_price').textContent = number_format(numberValue * <?php echo (1/$od_fx_rate); ?>) + " Point (※입금액 자동환산)";
                        } else {
                            document.getElementById('receipt_price_to_pointer_price').textContent = "0 Point (※입금액 자동환산)";
                        }
                    });
                </script>

                <tr>
                    <th scope="row"><label for="od_deposit_name">입금자명</label></th>
                    <td>
                        <?php if ($config['cf_sms_use'] && $default['de_sms_use4']) { ?>
                        <input type="checkbox" name="od_sms_ipgum_check" id="od_sms_ipgum_check">
                        <label for="od_sms_ipgum_check">SMS 입금 문자전송</label>
                        <br>
                        <?php } ?>
                        <input type="text" name="od_deposit_name" value="<?php echo get_text($od['od_deposit_name']); ?>" id="od_deposit_name" class="frm_input">
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_receipt_time">입금 확인일시</label></th>
                    <td>
                        <input type="checkbox" name="od_bank_chk" id="od_bank_chk" value="<?php echo date("Y-m-d H:i:s", G5_SERVER_TIME); ?>" onclick="if (this.checked == true) this.form.od_receipt_time.value=this.form.od_bank_chk.value; else this.form.od_receipt_time.value = this.form.od_receipt_time.defaultValue;">
                        <label for="od_bank_chk">현재 시간으로 설정</label><br>
                        <input type="text" name="od_receipt_time" value="<?php echo is_null_time($od['od_receipt_time']) ? "" : $od['od_receipt_time']; ?>" id="od_receipt_time" class="frm_input" maxlength="19">
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] == '휴대폰') { ?>
                <tr>
                    <th scope="row">휴대폰번호</th>
                    <td><?php echo get_text($od['od_bank_account']); ?></td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_receipt_price"><?php echo $od['od_settle_case']; ?> 결제액</label></th>
                    <td>
                        <?php echo $html_receipt_chk; ?>
                        <input type="text" name="od_receipt_price" value="<?php echo sprintf("%.2f", ($od['od_receipt_price'] * $od_fx_rate)); ?><?php echo $od['od_receipt_price']; ?>" id="od_receipt_price" class="frm_input"> 원 (KRW전용)
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="op_receipt_time">휴대폰 결제일시</label></th>
                    <td>
                        <input type="checkbox" name="od_hp_chk" id="od_hp_chk" value="<?php echo date("Y-m-d H:i:s", G5_SERVER_TIME); ?>" onclick="if (this.checked == true) this.form.od_receipt_time.value=this.form.od_hp_chk.value; else this.form.od_receipt_time.value = this.form.od_receipt_time.defaultValue;">
                        <label for="od_hp_chk">현재 시간으로 설정</label><br>
                        <input type="text" name="od_receipt_time" value="<?php echo is_null_time($od['od_receipt_time']) ? "" : $od['od_receipt_time']; ?>" id="op_receipt_time" class="frm_input" size="19" maxlength="19">
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] == '신용카드') { ?>
                <tr>
                    <th scope="row" class="sodr_sppay"><label for="od_receipt_price">신용카드 결제금액</label></th>
                    <td>
                        <?php echo $html_receipt_chk; ?>
                        <input type="text" name="od_receipt_price" id="od_receipt_price" value="<?php echo $od['od_receipt_price']; ?>" class="frm_input" size="10"> 원 (KRW전용)
                    </td>
                </tr>
                <tr>
                    <th scope="row" class="sodr_sppay"><label for="od_receipt_time">카드 승인일시</label></th>
                    <td>
                        <input type="checkbox" name="od_card_chk" id="od_card_chk" value="<?php echo date("Y-m-d H:i:s", G5_SERVER_TIME); ?>" onclick="if (this.checked == true) this.form.od_receipt_time.value=this.form.od_card_chk.value; else this.form.od_receipt_time.value = this.form.od_receipt_time.defaultValue;">
                        <label for="od_card_chk">현재 시간으로 설정</label><br>
                        <input type="text" name="od_receipt_time" value="<?php echo is_null_time($od['od_receipt_time']) ? "" : $od['od_receipt_time']; ?>" id="od_receipt_time" class="frm_input" size="19" maxlength="19">
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] == 'KAKAOPAY') { ?>
                <tr>
                    <th scope="row" class="sodr_sppay"><label for="od_receipt_price">KAKAOPAY 결제금액</label></th>
                    <td>
                        <?php echo $html_receipt_chk; ?>
                        <input type="text" name="od_receipt_price" id="od_receipt_price" value="<?php echo $od['od_receipt_price']; ?>" class="frm_input" size="10"> 원 (KRW전용)
                    </td>
                </tr>
                <tr>
                    <th scope="row" class="sodr_sppay"><label for="od_receipt_time">KAKAOPAY 승인일시</label></th>
                    <td>
                        <input type="checkbox" name="od_card_chk" id="od_card_chk" value="<?php echo date("Y-m-d H:i:s", G5_SERVER_TIME); ?>" onclick="if (this.checked == true) this.form.od_receipt_time.value=this.form.od_card_chk.value; else this.form.od_receipt_time.value = this.form.od_receipt_time.defaultValue;">
                        <label for="od_card_chk">현재 시간으로 설정</label><br>
                        <input type="text" name="od_receipt_time" value="<?php echo is_null_time($od['od_receipt_time']) ? "" : $od['od_receipt_time']; ?>" id="od_receipt_time" class="frm_input" size="19" maxlength="19">
                    </td>
                </tr>
                <?php } ?>

                <?php if ($od['od_settle_case'] == '간편결제' || ($od['od_pg'] == 'inicis' && is_inicis_order_pay($od['od_settle_case']) )) { ?>
                <tr>
                    <th scope="row" class="sodr_sppay"><label for="od_receipt_price"><?php echo $s_receipt_way; ?> 결제금액</label></th>
                    <td>
                        <?php echo $html_receipt_chk; ?>
                        <input type="text" name="od_receipt_price" id="od_receipt_price" value="<?php echo $od['od_receipt_price']; ?>" class="frm_input" size="10"> 원 (KRW전용)
                    </td>
                </tr>
                <tr>
                    <th scope="row" class="sodr_sppay"><label for="od_receipt_time"><?php echo $s_receipt_way; ?> 승인일시</label></th>
                    <td>
                        <input type="checkbox" name="od_card_chk" id="od_card_chk" value="<?php echo date("Y-m-d H:i:s", G5_SERVER_TIME); ?>" onclick="if (this.checked == true) this.form.od_receipt_time.value=this.form.od_card_chk.value; else this.form.od_receipt_time.value = this.form.od_receipt_time.defaultValue;">
                        <label for="od_card_chk">현재 시간으로 설정</label><br>
                        <input type="text" name="od_receipt_time" value="<?php echo is_null_time($od['od_receipt_time']) ? "" : $od['od_receipt_time']; ?>" id="od_receipt_time" class="frm_input" size="19" maxlength="19">
                    </td>
                </tr>
                <?php } ?>

                <tr>
                    <th scope="row"><label for="od_receipt_point">포인트 결제액</label></th>
                    <td><input type="text" name="od_receipt_point" value="<?php echo $od['od_receipt_point']; ?>" id="od_receipt_point" class="frm_input" size="10"> Point</td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_refund_price">결제취소/환불금액</label></th>
                    <td>
                        <?php echo $target_nation_flag_img; ?> <input type="text" name="od_refund_price" value="<?php echo sprintf("%.2f", ($od['od_refund_price'] * $od_fx_rate)); ?>" class="frm_input" size="10"> <?php echo $target_currency; ?>
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_invoice">운송장번호</label></th>
                    <td>
                        <?php if ($config['cf_sms_use'] && $default['de_sms_use5']) { ?>
                        <input type="checkbox" name="od_sms_baesong_check" id="od_sms_baesong_check">
                        <label for="od_sms_baesong_check">SMS 배송 문자전송</label>
                        <br>
                        <?php } ?>
                        <input type="text" name="od_invoice" value="<?php echo $od['od_invoice']; ?>" id="od_invoice" class="frm_input">
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_delivery_company">배송회사</label></th>
                    <td>
                        <input type="checkbox" id="od_delivery_chk" value="<?php echo $default['de_delivery_company']; ?>" onclick="chk_delivery_company()">
                        <label for="od_delivery_chk">기본 배송회사로 설정</label><br>
                        <input type="text" name="od_delivery_company" id="od_delivery_company" value="<?php echo $od['od_delivery_company']; ?>" class="frm_input">
                    </td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_invoice_time">배송일시</label></th>
                    <td>
                        <input type="checkbox" id="od_invoice_chk" value="<?php echo date("Y-m-d H:i:s", G5_SERVER_TIME); ?>" onclick="chk_invoice_time()">
                        <label for="od_invoice_chk">현재 시간으로 설정</label><br>
                        <input type="text" name="od_invoice_time" id="od_invoice_time" value="<?php echo is_null_time($od['od_invoice_time']) ? "" : $od['od_invoice_time']; ?>" class="frm_input" maxlength="19">
                    </td>
                </tr>

                <?php if ($config['cf_email_use']) { ?>
					<tr>
						<th scope="row"><label for="od_send_mail">메일발송</label></th>
						<td>
							<?php echo help("주문자님께 입금, 배송내역을 메일로 발송합니다.\n메일발송시 상점메모에 기록됩니다."); ?>
							<input type="checkbox" name="od_send_mail" value="1" id="od_send_mail"> 메일발송
						</td>
					</tr>
					<?php // 판매자센터 메일알림
					if($is_use_partner && count($pt_email)) {
					    $pt_email = array_unique($pt_email);
					    $pt_email = array_values($pt_email);
					?>
						<tr>
							<th scope="row"><label for="pt_send_mail">주문알림</label></th>
							<td>
								<?php echo help("판매자센터에게 결제, 주문내역을 메일로 발송합니다."); ?>
								<?php for($i=0; $i < count($pt_email); $i++) {
									$pt_id = $pt_email[$i];
								?>
									<p><label><input type="checkbox" name="pt_email[]" value="<?php echo $pt_email[$i];?>" id="pt_send_mail<?php $i;?>"> <b><?php echo $pt_name[$pt_id];?></b>(<?php echo $pt_id;?>) 님께 메일발송</label></p>
								<?php } ?>
						        <textarea name="pt_email_memo" id="pt_email_memo" rows="4" placeholder="판매자센터 전달사항" style="height:80px;"></textarea>
							</td>
						</tr>
					<?php } ?>
				<?php } ?>
                </tbody>
                </table>
            </div>
        </section>

    </div>

    <div class="btn_confirm01 btn_confirm">
        <input type="submit" value="결제/배송내역 수정" class="btn_submit btn">
        <?php if($od['od_status'] == '주문' && $od['od_misu'] > 0) { ?>
        <a href="./personalpayform4shoppoint.php?popup=yes&amp;od_id=<?php echo $od_id; ?>" id="personalpay_add" class="btn btn_02">개인결제추가</a>
        <?php } ?>
        <?php if($od['od_misu'] < 0 && ($od['od_receipt_price'] - $od['od_refund_price']) > 0 && ($od['od_settle_case'] == '신용카드' || $od['od_settle_case'] == '계좌이체' || $od['od_settle_case'] == 'KAKAOPAY')) { ?>
        <a href="./orderpartcancel4shoppoint.php?od_id=<?php echo $od_id; ?>" id="orderpartcancel" class="btn btn_02"><?php echo $od['od_settle_case']; ?> 부분취소</a>
        <?php } ?>
        <a href="./orderlist4shoppoint.php?<?php echo $qstr; ?>" class="btn btn_02">목록</a>
    </div>
    </form>
</section>

<section id="anc_sodr_memo">
    <h2 class="h2_frm">상점메모</h2>
    <?php echo $pg_anchor; ?>
    <div class="local_desc02 local_desc">
        <p>
            현재 열람 중인 주문에 대한 내용을 메모하는곳입니다.<br>
            입금, 배송 내역을 메일로 발송할 경우 함께 기록됩니다.
        </p>
    </div>

    <form name="frmorderform2" action="./orderformupdate4shoppoint.php" method="post">
    <input type="hidden" name="od_id" value="<?php echo $od_id; ?>">
    <input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
    <input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
    <input type="hidden" name="sel_field" value="<?php echo $sel_field; ?>">
    <input type="hidden" name="search" value="<?php echo $search; ?>">
    <input type="hidden" name="page" value="<?php echo $page; ?>">
    <input type="hidden" name="mod_type" value="memo">

    <div class="tbl_wrap">
        <label for="od_shop_memo" class="sound_only">상점메모</label>
        <textarea name="od_shop_memo" id="od_shop_memo" rows="8"><?php echo html_purifier(stripslashes($od['od_shop_memo'])); ?></textarea>
    </div>

    <div class="btn_confirm01 btn_confirm">
        <input type="submit" value="메모 수정" class="btn_submit btn">
    </div>

    </form>
</section>

<section>
    <h2 class="h2_frm">주문자/배송지 정보</h2>
    <?php echo $pg_anchor; ?>

    <form name="frmorderform3" action="./orderformupdate4shoppoint.php" method="post">
    <input type="hidden" name="od_id" value="<?php echo $od_id; ?>">
    <input type="hidden" name="sort1" value="<?php echo $sort1; ?>">
    <input type="hidden" name="sort2" value="<?php echo $sort2; ?>">
    <input type="hidden" name="sel_field" value="<?php echo $sel_field; ?>">
    <input type="hidden" name="search" value="<?php echo $search; ?>">
    <input type="hidden" name="page" value="<?php echo $page; ?>">
    <input type="hidden" name="mod_type" value="info">

    <div class="compare_wrap">

        <section id="anc_sodr_orderer" class="compare_left">
            <h3>주문하신 분</h3>

            <div class="tbl_frm01">
                <table>
                <caption>주문자/배송지 정보</caption>
                <colgroup>
                    <col class="grid_4">
                    <col>
                </colgroup>
                <tbody>
                <tr>
                    <th scope="row"><label for="od_name"><span class="sound_only">주문하신 분 </span>이름</label></th>
                    <td><input type="text" name="od_name" value="<?php echo get_text($od['od_name']); ?>" id="od_name" required class="frm_input required"></td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_tel"><span class="sound_only">주문하신 분 </span>전화번호</label></th>
                    <td><input type="text" name="od_tel" value="<?php echo get_text($od['od_tel']); ?>" id="od_tel" class="frm_input"></td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_hp"><span class="sound_only">주문하신 분 </span>휴대폰</label></th>
                    <td>[<?php echo get_text($od['od_hp_nation']); ?>] <input type="text" name="od_hp" value="<?php echo get_text($od['od_hp']); ?>" id="od_hp" class="frm_input"></td>
                </tr>
                <tr>
                    <th scope="row"><span class="sound_only">주문하시는 분 </span>주소</th>
                    <td>
                        <label for="od_zip" class="sound_only">우편번호</label>
                        <input type="text" name="od_zip" value="<?php echo get_text($od['od_zip1']).get_text($od['od_zip2']); ?>" id="od_zip" class="frm_input" size="5">
                        <!-- <button type="button" class="btn_frmline" onclick="win_zip('frmorderform3', 'od_zip', 'od_addr1', 'od_addr2', 'od_addr3', 'od_addr_jibeon');">주소 검색</button><br> -->
                        <label for="od_zip">우편번호</label><br>
                        <span id="od_win_zip" style="display:block"></span>
                        <input type="text" name="od_addr1" value="<?php echo get_text($od['od_addr1']); ?>" id="od_addr1" class="frm_input" size="35">
                        <label for="od_addr1">기본주소</label><br>
                        <input type="text" name="od_addr2" value="<?php echo get_text($od['od_addr2']); ?>" id="od_addr2" class="frm_input" size="35">
                        <label for="od_addr2">상세주소</label>
                        <br>
                        <input type="text" name="od_addr3" value="<?php echo get_text($od['od_addr3']); ?>" id="od_addr3" class="frm_input" size="35">
                        <label for="od_addr3">참고항목</label>
                        <input type="hidden" name="od_addr_jibeon" value="<?php echo get_text($od['od_addr_jibeon']); ?>"><br>
					</td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_email"><span class="sound_only">주문하신 분 </span>E-mail</label></th>
                    <td><input type="text" name="od_email" value="<?php echo $od['od_email']; ?>" id="od_email" required class="frm_input required" size="30"></td>
                </tr>
                <tr>
                    <th scope="row"><span class="sound_only">주문하신 분 </span>IP Address</th>
                    <td><?php echo $od['od_ip']; ?></td>
                </tr>
                </tbody>
                </table>
            </div>
        </section>

        <section id="anc_sodr_taker" class="compare_right">
            <h3>받으시는 분</h3>

            <div class="tbl_frm01">
                <table>
                <caption>받으시는 분 정보</caption>
                <colgroup>
                    <col class="grid_4">
                    <col>
                </colgroup>
                <tbody>
                <tr>
                    <th scope="row"><label for="od_b_name"><span class="sound_only">받으시는 분 </span>이름</label></th>
                    <td><input type="text" name="od_b_name" value="<?php echo get_text($od['od_b_name']); ?>" id="od_b_name" required class="frm_input required"></td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_b_tel"><span class="sound_only">받으시는 분 </span>전화번호</label></th>
                    <td><input type="text" name="od_b_tel" value="<?php echo get_text($od['od_b_tel']); ?>" id="od_b_tel" class="frm_input"></td>
                </tr>
                <tr>
                    <th scope="row"><label for="od_b_hp"><span class="sound_only">받으시는 분 </span>휴대폰</label></th>
                    <td>[<?php echo get_text($od['od_hp_nation']); ?>] <input type="text" name="od_b_hp" value="<?php echo get_text($od['od_b_hp']); ?>" id="od_b_hp" class="frm_input"></td>
                </tr>
                <tr>
                    <th scope="row"><span class="sound_only">받으시는 분 </span>주소</th>
                    <td>
                        <label for="od_b_zip" class="sound_only">우편번호</label>
                        <input type="text" name="od_b_zip" value="<?php echo get_text($od['od_b_zip1']).get_text($od['od_b_zip2']); ?>" id="od_b_zip" class="frm_input" size="5">
                        <!-- <button type="button" class="btn_frmline" onclick="win_zip('frmorderform3', 'od_b_zip', 'od_b_addr1', 'od_b_addr2', 'od_b_addr3', 'od_b_addr_jibeon');">주소 검색</button><br> -->
                        <label for="od_b_zip">우편번호</label><br>
                        <input type="text" name="od_b_addr1" value="<?php echo get_text($od['od_b_addr1']); ?>" id="od_b_addr1" class="frm_input" size="35">
                        <label for="od_b_addr1">기본주소</label><br>
                        <input type="text" name="od_b_addr2" value="<?php echo get_text($od['od_b_addr2']); ?>" id="od_b_addr2" class="frm_input" size="35">
                        <label for="od_b_addr2">상세주소</label><br>
                        <input type="text" name="od_b_addr3" value="<?php echo get_text($od['od_b_addr3']); ?>" id="od_b_addr3" class="frm_input" size="35">
                        <label for="od_b_addr3">참고항목</label>
                        <input type="hidden" name="od_b_addr_jibeon" value="<?php echo get_text($od['od_b_addr_jibeon']); ?>"><br>
                    </td>
                </tr>

                <?php if ($default['de_hope_date_use']) { ?>
                <tr>
                    <th scope="row"><label for="od_hope_date">희망배송일</label></th>
                    <td>
                        <input type="text" name="od_hope_date" value="<?php echo $od['od_hope_date']; ?>" id="od_hopedate" required class="frm_input required" maxlength="10" minlength="10"> (<?php echo get_yoil($od['od_hope_date']); ?>)
                    </td>
                </tr>
                <?php } ?>

                <tr>
                    <th scope="row">전달 메시지</th>
                    <td><?php if ($od['od_memo']) echo get_text($od['od_memo'], 1);else echo "없음";?></td>
                </tr>
                </tbody>
                </table>
            </div>
        </section>

    </div>

    <div class="btn_confirm01 btn_confirm">
        <input type="submit" value="주문자/배송지 정보 수정" class="btn_submit btn ">
        <a href="./orderlist4shoppoint.php?<?php echo $qstr; ?>" class="btn">목록</a>
    </div>

    </form>
</section>

<script>
$(function() {
    // 전체 옵션선택
    $("#sit_select_all").click(function() {
        if($(this).is(":checked")) {
            $("input[name='it_sel[]']").attr("checked", true);
            $("input[name^=ct_chk]").attr("checked", true);
        } else {
            $("input[name='it_sel[]']").attr("checked", false);
            $("input[name^=ct_chk]").attr("checked", false);
        }
    });

    // 상품의 옵션선택
    $("input[name='it_sel[]']").click(function() {
        var cls = $(this).attr("id").replace("sit_", "sct_");
        var $chk = $("input[name^=ct_chk]."+cls);
        if($(this).is(":checked"))
            $chk.attr("checked", true);
        else
            $chk.attr("checked", false);
    });

    // 개인결제추가
    $("#personalpay_add").on("click", function() {
        var href = this.href;
        window.open(href, "personalpaywin", "left=100, top=100, width=700, height=560, scrollbars=yes");
        return false;
    });

    // 부분취소창
    $("#orderpartcancel").on("click", function() {
        var href = this.href;
        window.open(href, "partcancelwin", "left=100, top=100, width=600, height=350, scrollbars=yes");
        return false;
    });
});

function form_submit(f)
{
    var check = false;
    var status = document.pressed;

    for (i=0; i<f.chk_cnt.value; i++) {
        if (document.getElementById('ct_chk_'+i).checked == true)
            check = true;
    }

    if (check == false) {
        alert("처리할 자료를 하나 이상 선택해 주십시오.");
        return false;
    }

    var msg = "";

    <?php if($od['od_settle_case'] == '신용카드' || $od['od_settle_case'] == 'KAKAOPAY' || $od['od_settle_case'] == '간편결제' || ($od['od_pg'] == 'inicis' && is_inicis_order_pay($od['od_settle_case']) )) { ?>
    if(status == "취소" || status == "반품" || status == "품절") {
        var $ct_chk = $("input[name^=ct_chk]");
        var chk_cnt = $ct_chk.size();
        var chked_cnt = $ct_chk.filter(":checked").size();
        <?php if($od['od_pg'] == 'KAKAOPAY') { ?>
        var cancel_pg = "카카오페이";
        <?php } else { ?>
        var cancel_pg = "PG사의 <?php echo $od['od_settle_case']; ?>";
        <?php } ?>

        if(chk_cnt == chked_cnt) {
            if(confirm(cancel_pg+" 결제를 함께 취소하시겠습니까?\n\n한번 취소한 결제는 다시 복구할 수 없습니다.")) {
                f.pg_cancel.value = 1;
                msg = cancel_pg+" 결제 취소와 함께 ";
            } else {
                f.pg_cancel.value = 0;
                msg = "";
            }
        }
    }
    <?php } ?>

    if (confirm(msg+"\'" + status + "\' 상태를 선택하셨습니다.\n\n선택하신대로 처리하시겠습니까?")) {
        return true;
    } else {
        return false;
    }
}

function del_confirm()
{
    if(confirm("주문서를 삭제하시겠습니까?")) {
        return true;
    } else {
        return false;
    }
}

// 기본 배송회사로 설정
function chk_delivery_company()
{
    var chk = document.getElementById("od_delivery_chk");
    var company = document.getElementById("od_delivery_company");
    company.value = chk.checked ? chk.value : company.defaultValue;
}

// 현재 시간으로 배송일시 설정
function chk_invoice_time()
{
    var chk = document.getElementById("od_invoice_chk");
    var time = document.getElementById("od_invoice_time");
    time.value = chk.checked ? chk.value : time.defaultValue;
}

// 결제금액 수동 설정
function chk_receipt_price()
{
    var chk = document.getElementById("od_receipt_chk");
    var price = document.getElementById("od_receipt_price");
    price.value = chk.checked ? parseFloat(chk.value) : price.defaultValue;
}
</script>

<?php
include_once(G5_ADMIN_PATH.'/admin.tail.php');
?>