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

if (!$member[mb_id]) 
    alert_close("회원만 조회하실 수 있습니다.");

$g4[title] = "<span class='nickname'>".$member[mb_nick] . "</span>님의 $zm_config[pointname] 내역";
include_once("$g4[path]/head.sub.php");

$list = array();

$sql_common = " from $g4[point_table] where mb_id = '".mysql_real_escape_string($member[mb_id])."' ";
$sql_order = " order by po_id desc ";

$sql = " select count(*) as cnt $sql_common ";
$row = sql_fetch($sql);
$total_count = $row[cnt];

$rows = $config[cf_page_rows];
$total_page  = ceil($total_count / $rows);  // 전체 페이지 계산
if (!$page) { $page = 1; } // 페이지가 없으면 첫 페이지 (1 페이지)
$from_record = ($page - 1) * $rows; // 시작 열을 구함
?>
<style type="text/css">
div.title	{ font:normal 14px '맑은 고딕'; padding:5px; }
div.title span.point	{ font:normal 14px Dotum; color:#FF4040; }
span.nickname	{ color:#30C0FF; font-weight:bold; }

.tbl_box	{ border:1px solid #C3C3C3; border-top:2px solid #626262; }
.tbl_box th	{ border-bottom:1px solid #C3C3C3; background:#F7F7F7; }
.tbl_box td	{ border-bottom:1px solid #C3C3C3; border-right:1px solid #C3C3C3; padding:2px; font:normal 11px Dotum; color:#5D5D5D; }
.tbl_box td:last-child	{ border-right:0; }
.tbl_box tr:last-child td	{ border-top:2px solid #C3C3C3; border-bottom:0; }
</style>

<div class="title"><?=$g4[title]?> (보유 <?=$zm_config[pointname]?> : <span class="point"><?=number_format($member[mb_point])?></span> 점)</div>
<table width=98% cellpadding=0 cellspacing=0 border=0 class="tbl_box" align="center">
<colgroup width="20%">
<colgroup width="40%">
<colgroup width="20%">
<colgroup width="20%">
<tr height="25">
	<th>일시</td>
    <th>내용</td>
    <th>지급<?=$zm_config[pointname]?></td>
    <th>사용<?=$zm_config[pointname]?></td>
</tr>
<?
$sum_point1 = $sum_point2 = 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];
    }
    
	if($i%2) $bg_color = "#FBFBFB"; else $bg_color = "#F3F3F3";
    echo <<<HEREDOC
    <tr height=25 bgcolor="$bg_color" align="center"> 
        <td height="24">$row[po_datetime]</td>
        <td align="left" title='$row[po_content]'><nobr style='display:block; overflow:hidden; width:250px;'>&nbsp;$row[po_content]</a></td>
        <td align=right>{$point1}&nbsp;</td>
        <td align=right>{$point2}&nbsp;</td>
    </tr>
HEREDOC;
}

if ($i == 0)
    echo "<tr><td colspan=5 align=center height=100>자료가 없습니다.</td></tr>";
else {
    if ($sum_point1 > 0)
        $sum_point1 = "+ " . number_format($sum_point1);
    $sum_point2 = number_format($sum_point2);
    echo <<<HEREDOC
    <tr height=25 align="center"> 
        <td height="24" colspan=2 align=center><b>소계</b></td>
        <td align=right>{$sum_point1}&nbsp;</td>
        <td align=right>{$sum_point2}&nbsp;</td>
    </tr>
HEREDOC;
} ?>
<tr>
</table>
<div style="text-align:center;"><?=get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=");?></div>
<div style="text-align:center;"><a href="javascript:window.close();"><img src="<?=$g4[bbs_img_path]?>/close.gif" width="66" height="20" border="0"></a></div>
<br>


<?/*?>
<table width='100%' cellpadding=0 cellspacing=0>
	<tr><td bgcolor=#B8B7B7><img src='<?=$g4[bbs_img_path]?>/title_point.gif'></td></tr>
</table>
<br>

<table width='99%' align=center cellpadding=3 cellspacing=0 border=1 bordercolordark=#F0F0F0>
<colgroup width=130></colgroup>
<colgroup width=''></colgroup>
<colgroup width=70></colgroup>
<colgroup width=70></colgroup>
<tr height=25 bgcolor=#F9F9F9 align=center>
	<td>일시</td>
	<td>내용</td>
	<td>지급<?=$zm_config[pointname]?></td>
	<td>사용<?=$zm_config[pointname]?></td>
</tr>

<?
$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 = "";
    if ($row[po_point] >= 0) {
        $point1 = "+" . number_format($row[po_point]);
    } else {
        $point2 = number_format($row[po_point]);
    }

    echo "
    <tr height=25>
        <td align=center>$row[po_datetime]</td>
        <td title='$row[po_content]'><nobr style='display:block; overflow:hidden; width:200px;'>&nbsp;$row[po_content]</a></td>
        <td align=right>$point1&nbsp;</td>
        <td align=right>$point2&nbsp;</td>
    </tr>
    ";
}

if ($i == 0)
    echo "<tr><td colspan=4 align=center height=100>자료가 없습니다.</td></tr>";
?>
</table>

<table width='100%' cellpadding=3 cellspacing=0>
<tr><td height=45 align=center><?=get_paging($config[cf_write_pages], $page, $total_page, "$_SERVER[PHP_SELF]?$qstr&page=");?></td></tr>
</table>

<table width='99%' align=center cellpadding=1 cellspacing=0 bgcolor=#CCCCCC>
	<tr>
		<td>
			<table width='100%' cellpadding=0 cellspacing=0 bgcolor=#F9F9F9>
				<tr>
					<td height=50>&nbsp;&nbsp;&nbsp;<B>내 <?=$zm_config[pointname]?> </B></td>
					<td><img src='<?=$g4[bbs_img_path]?>/icon_02.gif'> 보유 <?=$zm_config[pointname]?> : <B><?=number_format($member[mb_point])?></B></td>
				</tr>
			</table>
		</td>
	</tr>
</table>

<table width='100%' cellpadding=3 cellspacing=0>
	<tr><td colspan=2 height=45 align=center><a href='javascript:window.close();'><img src='<?=$g4[bbs_img_path]?>/btn_close.gif' border=0></a></td></tr>
</table>
<?*/?>

<?
include_once("$g4[path]/tail.sub.php");
?>