<?php
$sub_menu = '400910'; // 포인트 구매 관리자페이지용
include_once('./_common.php');

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

$od_id = $_POST['od_id'];

$sql = " select * from g5_shoppoint_order4withdraw where od_id = '$od_id' ";
$od = sql_fetch($sql);

if(!$od['od_id'])
    die('<div>포인트 출금신청정보가 존재하지 않습니다.</div>');

$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'];

// 포인트 출금신청정보
$od_withdraw_type = $od['od_withdraw_type'];
$od_withdraw_bank_country = $od['od_withdraw_bank_country'];
$od_withdraw_bank_name = $od['od_withdraw_bank_name'];
$od_withdraw_bank_account = $od['od_withdraw_bank_account'];
$od_withdraw_bank_account_name = $od['od_withdraw_bank_account_name'];
$od_withdraw_pay = $od['od_withdraw_pay'];
$od_withdraw_pay_id = $od['od_withdraw_pay_id'];
$od_withdraw_coin = $od['od_withdraw_coin'];
$od_withdraw_coin_id = $od['od_withdraw_coin_id'];
$od_withdraw_fee = $od['od_withdraw_fee'];

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'>";

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

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

<section id="cart_list">
    <h2 class="h2_frm">포인트 출금신청 목록</h2>

    <div class="tbl_head01 tbl_wrap">
        <table>
        <caption>포인트 출금신청 목록</caption>
        <thead>
        <tr>
			<th scope="col">이미지</th>
            <th scope="col">포인트 출금신청일시</th>
			<th scope="col">상품명</th>
            <th scope="col">상태</th>
            <th scope="col">출금신청 포인트합계</th>
            <th scope="col">출금신청후 실지급액</th>
            <th scope="col">적용환율(1KRW→<?php echo $target_currency?>)</th>
            <th scope="col">적용환율(1<?php echo $target_currency?>→KRW)</th>
            <th scope="col">수령방법</th>
            <th scope="col">수령계좌</th>
        </tr>
        </thead>
        <tbody>
             <tr>
				<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: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>";
                    ?>
                    <?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+$od_withdraw_fee,0); ?> Point</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_withdraw_type; ?></td>
                <?php if(strtolower($od_withdraw_type) == "bank") { ?>
                    <td><?php echo "[".$od_withdraw_bank_country."] ".$od_withdraw_bank_name." ".$od_withdraw_bank_account." ".$od_withdraw_bank_account_name; ?></td>
                <?php } else if(strtolower($od_withdraw_type) == "pay") { ?>
                    <td><?php echo "[".$od_withdraw_pay."] ".$od_withdraw_pay_id; ?></td>
                <?php } else if(strtolower($od_withdraw_type) == "coin") { ?>
                    <td><?php echo "[".$od_withdraw_coin."] ".$od_withdraw_coin_id; ?></td>
                <?php } ?>





            </tr>

        </tbody>
        </table>
    </div>
</section>