<?
// 기본 설정 로딩
require_once 'config.php';
require_once 'function.php';
require_once 'lib.php';

//HTML 시작

$query = "select * from onetimedb where onetime_case like 'domain' order by onetime_request_date desc";
#$query="select * from onetimedb inner join memberdb where onetime_case like 'domain' order by onetime_request_date desc";

$list_no = (!$_GET[ea]) ? '500' : $_GET[ea];

$total_num = mysql_num_rows(mysql_query($query, $db_connect));

$total = $total_num;
if ($list_no > $total) {$list_no = $total;}
$total_page = ($total != '0') ? ceil($total / $list_no) : '0';

$page = $_GET[page];

if (!$page) {$page = 1;} elseif ($page >= $total_page) {$page = $total_page;} else { $page = $page;}

$next_page = ($page-'1') * $list_no;
$next_no = $next_page + $list_no;

$result = @mysql_query($query, $db_connect) or die($db_q_error);
?>
<br>
2015년 전체구매건수 : <?=$total?>
<br>
<?=$msg?>
<div class="table-responsive" id="table">
<table class="table table-bordered table-hover table-striped">
<thead>
<tr>
<th style="width:120px;text-align:center;">고객명</th>
<th style="width:130px;text-align:center;">서비스코드</th>
<th style="width:40px;text-align:center;">수량</th>
<th style="width:100px;text-align:center;">결제금액</th>
<th style="width:100px;text-align:center;">미납금액</th>
<th style="width:100px;text-align:center;">신청일</th>
<!--<td style="width:100px;text-align:center;">결제일</td>-->
<th style="text-align:center;">비 고</th>
<th style="width:80px;text-align:center;">담당자</th>
</tr>
</thead>
<tbody>
<?

for ($i = $next_page; $i < $next_no; $i++) {
    $data = mysql_fetch_assoc($result);
    $num = ($total) - $i;
#        $reg_date=date("Y/m/d H:i", $data['reg_date']);
    # ($data[onetime_manager])
    /*
    switch($_GET[mode]){
    case "today":
    //당일
    $name="";
    break;
    case "1day":
     */
    $mk1 = "select Client_Code,Client_Name from clientdb where Client_Code='" . $data[client_code] . "'";
    $mk1_result = @mysql_query($mk1, $db_connect) or die($db_q_error);
    $mk1_data = mysql_fetch_assoc($mk1_result);

    $mk2 = "select id,name from memberdb where id='" . $data[onetime_manager] . "'";
    $mk2_result = @mysql_query($mk2, $db_connect) or die($db_q_error);
    $mk2_data = mysql_fetch_assoc($mk2_result);

    $mk_num = preg_replace("/[^0-9]*/s", "", $data[onetime_sub]);

    ?>

<tr>
<td style="text-align:center;">
<?=$mk1_data[Client_Name]?></td>
<td style="text-align:center;"><a href="/IdcDepositNonPaymentList.dep?searchContent=<?=$data[service_code]?>"><?=$data[service_code]?></a></td>
<td style="text-align:center;"><?=$mk_num?></td>
<td style="text-align:center;"><?=$data[onetime_amount]?></td>
<td style="text-align:center;"><?=$data[onetime_nonpayment]?></td>
<td style="text-align:center;"><?=$data[onetime_request_date]?></td>
<!--<td style="text-align:center;"><?=$data[onetime_payment_date]?></td>-->
<td><?=$data[onetime_note]?></td>
<!--<td><?=$data[name]?></td>-->
<td style="text-align:center;"><?=$mk2_data[name]?></td>
</td>
</tr>
<?}?>
</tbody>
<tfoot></tfoot>
</table>
<!--
<div align='center'>
<?
$setup_dir = "http://" . $_SERVER['HTTP_HOST'] . ":6752";
$page_scale = 10;
$page3 = floor(($total_page-'1') / $page_scale);
$n_page = floor(($page-'1') / $page_scale);

if ($n_page > 0) {

    $p_start = (($n_page - 1) * $page_scale)+'1';
    $link = "<a onfocus=blur() href='" . $setup_dir . "/IdcDomainBuyListMK.cup?mode=$_GET[mode]&ea=$_GET[ea]&page=" . $p_start . "'>";
    $link .= "<<";
    $link .= "</a>";
    echo $link . " ";
}
$is = ($n_page * $page_scale)+'1';
for ($i = $is; $i < $is + $page_scale; $i++) {

    if ($i < $total_page+'1') {
        if ($i == $page) {$ib = "<b>$i</b>";} else { $ib = $i;}
        $link = "<a onfocus=blur() href='" . $setup_dir . "/IdcDomainBuyListMK.cup?mode=$_GET[mode]&ea=$_GET[ea]&page=" . $i . "'>";
        $link .= $ib;
        $link .= "</a>";
        echo $link . " ";
    }
}
if ($n_page < $page3) {
    $link = "<a onfocus=blur() href='" . $setup_dir . "/IdcDomainBuyListMK.cup?mode=$_GET[mode]&ea=$_GET[ea]&page=" . $i . "'>";
    $link .= ">>";
    $link .= "</a>";
    echo $link;
}
?>
</div>
-->
<?
//DB닫기
mysql_close($db_connect);
?>
