<? 
// ###################################################################################
//
//   view.php
//
//   Copyright (c) 2000-2005 InterBank(ANGELPAY) Co. LTD.
//   All rights reserved.
//  ------------------------------------------------------------------------------
//   최종 수정일 : 2002.08.29
//
// ###################################################################################
//
//   쇼핑몰의 ANGELPAY_DIRECT 데이타베이스 테이블을 웹브라우져에서 볼 수 있게 하는 
//   Module이다.
//
// ###################################################################################
?>

<html>
<head>
<title>Angelpay Direct Database</title>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
</head>
<style type="text/css">
<!--
A:link, A:active, A:visited 
	{  font-size: 9pt;  color:  #CC3399;font-weight: bold ;  text-decoration: none; }
A:hover 
	{  font-size: 9pt;  color: #FEA802;  text-decoration:underline; }
TD 
	{  font-family: 굴림;  font-size: 9pt;  color: black; }
TH 
	{  font-family: 굴림;  font-size: 9pt;  color: black; }
body 
	{  font-family: 굴림;  font-size: 9pt;  color: black; }
//--!>
</style>
<body>

<?
include "./config.php";
include "./log.php";
include "./mysql_function.php";

$nConn = FncOpenDatabase();

echo "
      <table border=0 cellspacing=0 cellpadding=0>
        <tr>
          <td>
	";


$nCountPerPage = 20;
$nCountPerJump = 10;	/*  점프할수 있는 페이지 수 */
if (($nJump+0) == 0 ) $nJump = 1;

/* TOTAL 레코드수 */
$svSQL = "SELECT COUNT('ORDER_DATE') FROM $TABLE_ANGELPAY";

$resultcount = @mysql_query( $svSQL,$nConn);
$nTotalRec = @mysql_result($resultcount,0);
$nModRec = $nTotalRec % $nCountPerPage; 
$nTotalPage = $nTotalRec / $nCountPerPage;
settype( $nTotalPage, "integer" );

if ($nModRec != 0) $nTotalPage++;	/* 나머지가 있으면 총페이지수 + 1 */

if (($nRecno+0) != 0)
{	
	if ( $nTotalRec < ($nRecno+0)) $nRecno = $nTotalRec;
	$nRecno = ($nRecno - 1) / $nCountPerPage;
	settype( $nRecno, "integer" );
	$nRecno *= $nCountPerPage;
} 
else $nRecno = 0;

$nCurrentPage = $nRecno / $nCountPerPage + 1;
settype( $nCurrentPage, "integer" );

/* 최대 점프 페이지 수 */
$nModPage = $nTotalPage % $nCountPerJump;
$nMaxJump = $nTotalPage / $nCountPerJump;
settype( $nMaxJump, "integer" );
if ($nModPage != 0) $nMaxJump++;
	
echo "<table border=0 cellspacing=0 cellpadding=0 align=ecnter>";
echo "<tr>";
echo "<td align=left>";
echo "<br><b>전체 페이지: $nTotalPage, 현재 페이지: $nCurrentPage</b><br><br>";
echo "</td>";
echo "</tr>";
echo "</table>";

$svSQL = "SELECT * FROM $TABLE_ANGELPAY order by ORDER_DATE DESC,SEQUENCE_NO DESC,ORDER_TIME ASC limit $nRecno,$nCountPerPage";
$result = mysql_query($svSQL,$nConn);

$count_fields = mysql_num_fields($result);

echo "	
	  <table border=1 align=center cellspacing=0 cellpadding=0>
	  	<tr bgcolor='#DDDDDD' height=26 align=center>
		  <th> NO </th>
";


for ( $i = 0 ; $i < $count_fields ; $i++)
{
	echo "		  <th> ". mysql_field_name($result, $i). "</th>\n";
}

echo "		</tr>\n";



$counter = 0;
while ($Array = mysql_fetch_array($result))
{
	$nCounter = $nRecno + $counter +1;
	echo "		<tr height=21 align=center>\n";
	echo "	    	  <td>$nCounter</td>\n";

	for ($i = 0 ;  $i < $count_fields ; $i++)
	{
		echo "	 	  <td>$Array[$i]&nbsp;</td>\n";
	}
	echo"		</tr>\n";
	$counter++;
}
echo "
           </table>
         </td>
       </tr>
     </table>
     
     <table width=600 border=0 cellspacing=0 cellpadding=0 align=left>
       <tr height=10>
         <td align=center width=350 height=10> </td>
         <td align=center width=250 height=10> </td>
	   </tr>
       <tr>
         <td align=right>
	 ";

if (($nCountPerJump<$nTotalPage) and ($nJump < $nMaxJump)) {
	for ($co=0 ; $co < $nCountPerJump ; $co++) {
		$nCurrStartRec = ($nJump -1) * $nCountPerPage * $nCountPerJump + ($co * $nCountPerPage) + 1;
		$j = $co + (($nJump - 1) * $nCountPerJump) + 1;
		if ($j>0) {
			if ($nCurrentPage == $j) echo " <b>[$j]</b> ";
			else echo " [<a href=view.php?nRecno=$nCurrStartRec&nJump=$nJump>$j</a>] ";
		}
	}
}
else {
	$Loop = $nTotalPage - (( $nJump - 1 ) * $nCountPerJump);
	for ($co=0 ; $co < $Loop ; $co++) {
		$nCurrStartRec = ($nJump -1) * $nCountPerPage * $nCountPerJump + ($co * $nCountPerPage) + 1;
		$j = $co + (($nJump - 1) * $nCountPerJump) + 1;
		if ($j > 0) {
			if ($nCurrentPage == $j) echo " <b>[$j]</b> ";
			else echo " [<a href=view.php?nRecno=$nCurrStartRec&nJump=$nJump>$j</a>] ";
		}
	}
}

echo "</td><td align=center><b>Jump Page</b>&nbsp;&nbsp;&nbsp;";

if (1 < $nJump)
{	$nPrevRec = ( $nJump - 2 ) * $nCountPerPage * $nCountPerJump + 1;
	$nJumpTemp = $nJump - 1;
	echo " [<a href=view.php?nRecno=$nPrevRec&nJump=$nJumpTemp>이전 $nCountPerJump 개</a>] ";
}
else echo "  [이전 $nCountPerJump 개] ";

if ($nJump < $nMaxJump)
{	
	$nNextRec = $nJump * $nCountPerPage * $nCountPerJump + 1;
	$nJumpTemp = $nJump + 1;
	echo " [<a href=view.php?nRecno=$nNextRec&nJump=$nJumpTemp>다음 $nCountPerJump 개</a>] ";
}
else echo " [다음 $nCountPerJump 개] ";


echo "   </td>
       </tr>
     </table>";;

?>
</body>
</html>