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

//HTML 시작
if (!$_GET[limit]){$limit=5;} else {$limit=$_GET[limit];}

//$limit=$limit-1;
$query="select * from servicedb order by service_num desc limit 0,$limit";
$query_data = @mysql_query($query , $db_connect) or die($db_q_error);



?>
                       
                        
                            <table class="table table-bordered table-hover table-striped">
                                <thead>
                                    <tr>
										<th style="text-align:center;width:100px;">서비스코드</th>
                                        <th style="text-align:center;width:100px;">업체명</th>
                                        <th style="text-align:center;width:80px;">구분</th>
                                        <th style="text-align:center;width:100px;">장비번호</th>
                                        <th style="text-align:center;width:140px;">스위치정보</th>
                                        <th style="text-align:center;width:140px;">IP정보</th>
                                        <th style="text-align:center;width:50px;">CS</th>
                                        <th style="text-align:center;width:80px;">등록자</th>
                                        <th style="text-align:center;width:100px;">비고</th>
                                    </tr>
                                </thead>
                                <tbody>
<?
for ($i=0;$i<$limit;$i++){
		$data=mysql_fetch_assoc($query_data);
		$customer= mysql_query("select Client_Code,Client_Name from clientdb where Client_Code like '".$data[client_code]."'",$db_connect) or die($db_q_error);
		$customer=mysql_fetch_assoc($customer);
		$member= mysql_query("select id,name from memberdb where id like '".$data[service_manager]."'",$db_connect) or die($db_q_error);
		$member=mysql_fetch_assoc($member);

		$service_code=$data[service_code];    
		$client_code=$data[client_code];
		$vpc="SELECT COUNT(*) AS cs_count FROM vpcdb WHERE `service_code` = '$service_code'";
		$kcs="SELECT COUNT(*) AS cs_count FROM kcsdb WHERE `service_code` = '$service_code'";
		$resultvpc = @mysql_query($vpc , $db_connect) or die($db_q_error);
		$resultkcs = @mysql_query($kcs , $db_connect) or die($db_q_error);
		$datavpc=mysql_fetch_assoc($resultvpc);
		$datakcs=mysql_fetch_assoc($resultkcs);
		//cut_str($str, $len, $suffix="…")


switch ($data[service_line]) {
    case 'test': $data[service_line]="테스트";break;
    case 'event': $data[service_line]="이벤트";break;
    case 'office': $data[service_line]="자사서버";break;
    case 'onetime': $data[service_line]="일회성장비";break;
    case 'substitution': $data[service_line]="대체";break;
    case 'vpn': $data[service_line]="VPN";break;
    case 'normal': $data[service_line]="일반";break;
    case 'defence': $data[service_line]="방어";break;
    case 'solo': $data[service_line]="전용";break;

}

		
?>
                                    <tr>
                                    	<td style="text-align:center;"><a href="/serviceDetailSolo.sev?client_code=<?=$data[client_code]?>&service_code=<?=$data[service_code]?>"><?=$data[service_code]?></a></td>	
                                        <td style="text-align:center;"><nobr style=" display:block;"><?=cut_str($customer[Client_Name],10)?></nobr></td>
                                        <td style="text-align:center;"><?=$data[service_line]?></td>
                                        <td style="text-align:center;"><nobr style=" display:block;"><?=cut_str($data[server_code],10)?></nobr></td>
                                        <td style="text-align:center;"><nobr style=" display:block;"><?=cut_str($data[service_sw],10)?></nobr></td>
                                        <td style="text-align:center;"><?=$data[service_ip]?></td>
                                        <td style="text-align:center;">
<?
echo "<a href=/vpcInfo.sev?client_code=$client_code&csInfoFlag=true&service_code=$service_code>";
echo $datavpc[cs_count];
echo "</a> / ";
echo "<a href=/vpcInfo.sev?client_code=$client_code&csInfoFlag=false&service_code=$service_code>";
echo $datakcs[cs_count];
echo "</a>";
?>										
										</td>
                                        <td style="text-align:center;"><?=$member[name]?></td>
                                        <td><nobr style=" display:block;"><?=cut_str($data[service_note],30)?></nobr></td> 
                                    </tr>
<? } ?>
                                </tbody>
                            </table>
<?
//DB닫기
mysql_close($db_connect);
?>