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

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

$g4[title] = $member[mb_nick] . "님의 $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">
td { font-size:11px; }
</style>

<div style="padding:5px;">
	<img src="<?=$g4[bbs_img_path]?>/icon_01.gif" width="5" height="5" align="absmiddle">
	<font color="#666666"><b><?=$g4[title]?></b></font>
</div>
<table width="98%" border="0" cellspacing="0" cellpadding="0" align="center">
<tr><td height="2" bgcolor="#808080"></td></tr>
<tr> 
	<td bgcolor="#FFFFFF">
    <table width=100% cellpadding=1 cellspacing=1 border=0>
	<tr bgcolor=#E1E1E1 align=center> 
		<td width="130" height="24"><b>일시</b></td>
        <td width=""><b>내용</b></td>
        <td width="70"><b>지급<?=$zm_config[pointname]?></b></td>
        <td width="70"><b>사용<?=$zm_config[pointname]?></b></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 bgcolor="#E1E1E1" align="center"> 
                        <td height="24" colspan=2 align=center>소계</td>
                        <td align=right>{$sum_point1}&nbsp;</td>
                        <td align=right>{$sum_point2}&nbsp;</td>
                    </tr>
HEREDOC;
                }
                ?>
	</table>
	</td>
</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:right;">보유 <?=$zm_config[pointname]?> : <B><?=number_format($member[mb_point])?> 점</B></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");
?>