<?php
if (!defined('_GNUBOARD_')) {
    exit;
} // 개별 페이지 접근 불가
// add_stylesheet('css 구문', 출력순서); 숫자가 작을 수록 먼저 출력됨
add_stylesheet('<link rel="stylesheet" href="' . G5_THEME_CSS_URL . '/skin/mobile/asktheme.member.css">', 0);
include G5_THEME_PATH . "/head.php";
?>

<div class='page-wrap point-page'>
    <div class='page-title'>
        <h1><?php echo $g5['title'] ?></h1>
    </div>

    <div class='responsetable'>
        <div class='caption'>포인트 사용내역 목록</div>
        <div class='tb-header'>
            <div class='tb-row'>
                <div class='tb-cell'>일시</div>
                <div class='tb-cell'>내용</div>
                <div class='tb-cell'>만료일</div>
                <div class='tb-cell'>지급포인트</div>
                <div class='tb-cell'>사용포인트</div>
            </div>
        </div>
        <div class='tb-body'>
            <?php
            $sum_point1 = $sum_point2 = $sum_point3 = 0;

            $sql = " select * {$sql_common} {$sql_order} limit {$from_record}, {$rows} ";
            $result = sql_query($sql);
            for ($i = 0; $row = sql_fetch_array($result); $i++) {
                $point1 = $point2 = 0;
                if ($row['po_point'] > 0) {
                    $point1 = '+' . number_format($row['po_point']);
                    $sum_point1 += $row['po_point'];
                } else {
                    $point2 = number_format($row['po_point']);
                    $sum_point2 += $row['po_point'];
                }

                $po_content = $row['po_content'];

                $expr = '';
                if ($row['po_expired'] == 1) {
                    $expr = ' txt_expired';
                }
                ?>
                <div class='tb-row'>
                    <div class='tb-cell'><?php echo $row['po_datetime']; ?></div>
                    <div class='tb-cell'><?php echo $po_content; ?></div>
                    <div class='tb-cell'>
                        <?php echo $expr; ?>
                        <?php if ($row['po_expired'] == 1) { ?>
                            만료<?php echo substr(str_replace('-', '', $row['po_expire_date']), 2); ?>
                            <?php
                        } else {
                            echo $row['po_expire_date'] == '9999-12-31' ? '&nbsp;' : $row['po_expire_date'];
                        }
                        ?>
                    </div>
                    <div class='tb-cell'><?php echo $point1; ?></div>
                    <div class='tb-cell'><?php echo $point2; ?></div>
                </div>
                <?php
            }

            if ($i == 0) {
                echo "<div class='tb-row'><div class='tb-cell'>자료가 없습니다.</div></div>";
            } else {
                if ($sum_point1 > 0) {
                    $sum_point1 = "+" . number_format($sum_point1);
                }
                $sum_point2 = number_format($sum_point2);
            }
            ?>
        </div>

        <div class='tb-row'>
            <div class='tb-cell'>소계</div>
            <div class='tb-cell'></div>
            <div class='tb-cell'></div>
            <div class='tb-cell'><?php echo $sum_point1; ?></div>
            <div class='tb-cell'><?php echo $sum_point2; ?></div>
        </div>

        <div class='tb-row'>
            <div class='tb-cell'>보유포인트</div>
            <div class='tb-cell'></div>
            <div class='tb-cell'></div>
            <div class='tb-cell'></div>
            <div class='tb-cell'><?php echo number_format($member['mb_point']); ?></div>
        </div>

    </div>
    <div class='paging-wrap'>
        <?php echo get_paging(G5_IS_MOBILE ? $config['cf_mobile_pages'] : $config['cf_write_pages'], $page, $total_page, $_SERVER['SCRIPT_NAME'] . '?' . $qstr . '&amp;page='); ?>
    </div>

</div>
<?php
include G5_THEME_PATH . "/tail.php";
