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

//HTML 시작
/*
$lineup_data=@mysql_query("select * from serverdb where 
server_cpuname not in ('X4-Q','X6-Q','A1.6','CN2.','C2800','C2600','COL','CUS','NX227','NX20','NX21','DQ28','DQ26','DQ31','DQ18','DQ23','DQ20','DX34','DX38','DX28','DX32','DX36',
'DX30','MD32','MD30','Q16R','Q316','Q310','Q283','Q266','Q25R','Q213','Q20R','Q186','Q24','Q20','Q240','DX3','DQ233') 
and server_process not in ('COLOCATION','CELERON','INTEL i5','INTEL i3','INTEL i7','ATOM','AMD','XEON Single','CUSTOM','INS-일회성','','','') 
and server_spec not in ('DQ266','DQ240','DQ213','Q2.130','Q2.4','Q16','DQ20R12','Q330','i3-3.30','i5-3.20','i7-3.4','i7-3.33','X36','X24','X30','NX213','i7-4790','DQ316','MQ23',
'DQ183','DQ283','Q25','A1.66','','','','','','') 
#and server_spec like 'DH266' 
group by server_cpuname
order by server_process,server_cpuname asc" , $db_connect) or die($db_q_error);
*/


$lineup_data=@mysql_query("select * from gearlist where process not in 
('COLOCATION','','','','','','','XEON Single','CUSTOM','INS-일회성','NEHALEM','Cisco Router','') 
and cpuname not in 
('','X6-Q','','','C2800','C2600','COL','CUS','NX227','NX20','NX21','DQ28','DQ26','DQ31','DQ18','DQ23','DQ20','DX34','DX38','DX28','DX32','DX36',
'DX30','MD32','MD30','Q16R','Q316','Q310','Q283','Q266','Q25R','Q213','Q20R','Q186','Q24','Q20','Q240','DX3','DQ233')
order by process,price,cpuname asc" , $db_connect) or die($db_q_error);

/* 2015년 8월 이후 신장비만 적용
$lineup_data=@mysql_query("select * from gearlist where process not in 
('COLOCATION','CELERON','INTEL i5','INTEL i3','INTEL i7','ATOM','AMD','XEON Single','CUSTOM','INS-일회성','NEHALEM','Cisco Router','') 
and cpuname not in 
('X4-Q','X6-Q','A1.6','CN2.','C2800','C2600','COL','CUS','NX227','NX20','NX21','DQ28','DQ26','DQ31','DQ18','DQ23','DQ20','DX34','DX38','DX28','DX32','DX36',
'DX30','MD32','MD30','Q16R','Q316','Q310','Q283','Q266','Q25R','Q213','Q20R','Q186','Q24','Q20','Q240','DX3','DQ233')
order by cpuname,spec desc" , $db_connect) or die($db_q_error);
*/
$lineup_total = mysql_num_rows($lineup_data);

/*
$query="select * from serverdb where 
server_cpuname not in ('X4-Q','X6-Q','A1.6','CN2.','C2800','C2600','COL','CUS','NX227','NX20','NX21','DQ28','DQ26','DQ31','DQ18','DQ23','DQ20','DX34','DX38','DX28','DX32','DX36',
'DX30','MD32','MD30','Q16R','Q316','Q310','Q283','Q266','Q25R','Q213','Q20R','Q186','Q24','Q20','Q240','DX3','DQ233') 
and server_process not in ('COLOCATION','CELERON','INTEL i5','INTEL i3','INTEL i7','ATOM','AMD','XEON Single','CUSTOM','INS-일회성','','','') 
and server_spec not in ('DQ266','DQ240','DQ213','Q2.130','Q2.4','Q16','DQ20R12','Q330','i3-3.30','i5-3.20','i7-3.4','i7-3.33','X36','X24','X30','NX213','i7-4790','DQ316','MQ23',
'DQ183','DQ283','Q25','A1.66','','','','','','') 
and server_spec like 'DH266' 
order by server_process,server_cpuname asc";
$DH266_all_data = @mysql_query($query , $db_connect) or die($db_q_error);
$DH266_all=mysql_fetch_assoc($server_data);
mysql_num_rows($DH266_all_data);


$query="select * from serverdb where 
server_cpuname not in ('X4-Q','X6-Q','A1.6','CN2.','C2800','C2600','COL','CUS','NX227','NX20','NX21','DQ28','DQ26','DQ31','DQ18','DQ23','DQ20','DX34','DX38','DX28','DX32','DX36',
'DX30','MD32','MD30','Q16R','Q316','Q310','Q283','Q266','Q25R','Q213','Q20R','Q186','Q24','Q20','Q240','DX3','DQ233') 
and server_process not in ('COLOCATION','CELERON','INTEL i5','INTEL i3','INTEL i7','ATOM','AMD','XEON Single','CUSTOM','INS-일회성','','','') 
and server_spec not in ('DQ266','DQ240','DQ213','Q2.130','Q2.4','Q16','DQ20R12','Q330','i3-3.30','i5-3.20','i7-3.4','i7-3.33','X36','X24','X30','NX213','i7-4790','DQ316','MQ23',
'DQ183','DQ283','Q25','A1.66','','','','','','') 
and server_spec like 'DH266' and server_use_status like 'y'
order by server_process,server_cpuname asc";
$server_data = @mysql_query($query , $db_connect) or die($db_q_error);
$server_count=mysql_fetch_assoc($server_data);
echo mysql_num_rows($server_data);
*/
?>

* CPU 명칭 : 
싱글 코어 = 1개 코어 / 
듀얼 코어 = 2개 코어 / 
트리플 코어 = 3개 코어 / 
쿼드 코어(Q) = 4개 코어 / 
헥사 코어(H) = 6개 코어 / 
옥타 코어(O) = 8개 코어 / 
도데카(D) = 12개 코어 <!--(AMD CPU일 경우 옵테론 코어)--> / 
헥사데시멀 코어 = 16개코어<br>
* 도쿄 회선 + 1U상면비 : 60만원 (50+10) / 치바 회선 + 1U상면비 : 40만원 (30+10)<br>
* HDD : 1단위당 일회성 10만원 / 메모리 : 2G당 1회성 5만원 / 방어서비스 : CS방어 40만원 , BL상시 60만원 , CS-Pre상시 300만원 , CF방어 도메인당 40만원 , 인증방어 사이트당 80만원(+유동CS4개 기본)
					<table class="table table-bordered table-hover table-striped" style="text-align:center;">
						<thead>
							<tr>
								<td>구분</td>
								<td>장비사양</td>
								<td>CPU모델명</td>
								<td>임대가격</td>
								<td>전체서버</td>
								<td>임대중</td>
								<td>사용가능</td>
								<td>포맷보류</td>			
							</tr>
						</thead>
						<tbody>
<?
for ($i=0;$i<$lineup_total;$i++){
        $lineup=mysql_fetch_assoc($lineup_data);
        $num=($lineup_total)-$i;
		$lineup_explode=explode('.',$lineup['spec']);
		$all_query = "select count(*) from serverdb where server_cpuname like '%".$lineup['cpuname']."%' and server_spec like '%".$lineup_explode[0]."%'";
		$use_query = "select count(*) from serverdb where server_cpuname like '%".$lineup['cpuname']."%' and server_spec like '%".$lineup_explode[0]."%' and server_use_status='n' ";
		$empty_query = "select count(*) from serverdb where server_cpuname like '%".$lineup['cpuname']."%' and server_spec like '%".$lineup_explode[0]."%' and server_use_status='y'";
		$format_query = "select count(*) from serverdb where server_cpuname like '%".$lineup['cpuname']."%' and server_spec like '%".$lineup_explode[0]."%' and server_fomat_date !='NULL'";

		$all_data = @mysql_query($all_query , $db_connect) or die($db_q_error);
		$use_data = @mysql_query($use_query , $db_connect) or die($db_q_error);
		$empty_data = @mysql_query($empty_query , $db_connect) or die($db_q_error);
		$format_data = @mysql_query($format_query , $db_connect) or die($db_q_error);

		$all=mysql_fetch_assoc($all_data);
		$use=mysql_fetch_assoc($use_data);
		$empty=mysql_fetch_assoc($empty_data);
		$format=mysql_fetch_assoc($format_data);

?>
								<tr>
									<td><?=$lineup['process']?></td>
									<td><?=$lineup['spec']?></td>
									<td><a href="https://www.google.co.jp/search?q=<?=$lineup['cpuname']?>" target=_blank><?=$lineup['cpuname']?></a></td>
									<td><?=$lineup['price']?> 만원</td>
									<td><?=$all['count(*)']?> 대</td>
									<td><?=$use['count(*)']?> 대</td>
									<td><font color=blue><?=$empty['count(*)']?></font> 대</td>
									<td><?=$format['count(*)']?> 대</td>
								</tr>	
<? } ?>

<?
		$all_query = "select count(*) from serverdb where server_cpuname like '%i5-2%' and server_spec like '%i5-2%'";
		$use_query = "select count(*) from serverdb where server_cpuname like '%i5-2%' and server_spec like '%i5-2%' and server_use_status='n' ";
		$empty_query = "select count(*) from serverdb where server_cpuname like '%i5-2%' and server_spec like '%i5-2%' and server_use_status='y'";
		$format_query = "select count(*) from serverdb where server_cpuname like '%i5-2%' and server_spec like '%i5-2%' and server_fomat_date !='NULL'";

		$all_data = @mysql_query($all_query , $db_connect) or die($db_q_error);
		$use_data = @mysql_query($use_query , $db_connect) or die($db_q_error);
		$empty_data = @mysql_query($empty_query , $db_connect) or die($db_q_error);
		$format_data = @mysql_query($format_query , $db_connect) or die($db_q_error);

		$all=mysql_fetch_assoc($all_data);
		$use=mysql_fetch_assoc($use_data);
		$empty=mysql_fetch_assoc($empty_data);
		$format=mysql_fetch_assoc($format_data);

?>
								<tr>
									<td>INTEL i5(구세대)</td>
									<td>i5-2.xx</td>
									<td>i5-2</td>
									<td>23 만원</td>
									<td><?=$all['count(*)']?> 대</td>
									<td><?=$use['count(*)']?> 대</td>
									<td><font color=blue><?=$empty['count(*)']?></font> 대</td>
									<td><?=$format['count(*)']?> 대</td>
								</tr>


<?
		$all_query = "select count(*) from serverdb where server_cpuname like '%i7-2%' and server_spec like '%i7-2%'";
		$use_query = "select count(*) from serverdb where server_cpuname like '%i7-2%' and server_spec like '%i7-2%' and server_use_status='n' ";
		$empty_query = "select count(*) from serverdb where server_cpuname like '%i7-2%' and server_spec like '%i7-2%' and server_use_status='y'";
		$format_query = "select count(*) from serverdb where server_cpuname like '%i7-2%' and server_spec like '%i7-2%' and server_fomat_date !='NULL'";

		$all_data = @mysql_query($all_query , $db_connect) or die($db_q_error);
		$use_data = @mysql_query($use_query , $db_connect) or die($db_q_error);
		$empty_data = @mysql_query($empty_query , $db_connect) or die($db_q_error);
		$format_data = @mysql_query($format_query , $db_connect) or die($db_q_error);

		$all=mysql_fetch_assoc($all_data);
		$use=mysql_fetch_assoc($use_data);
		$empty=mysql_fetch_assoc($empty_data);
		$format=mysql_fetch_assoc($format_data);

?>
								<tr>
									<td>INTEL i7(구세대)</td>
									<td>i7-2.xx</td>
									<td>i7-2</td>
									<td>45 만원</td>
									<td><?=$all['count(*)']?> 대</td>
									<td><?=$use['count(*)']?> 대</td>
									<td><font color=blue><?=$empty['count(*)']?></font> 대</td>
									<td><?=$format['count(*)']?> 대</td>
								</tr>

<?
		$all_query = "select count(*) from serverdb where server_cpuname like '%i7-4%' and server_spec like '%i7-4%'";
		$use_query = "select count(*) from serverdb where server_cpuname like '%i7-4%' and server_spec like '%i7-4%' and server_use_status='n' ";
		$empty_query = "select count(*) from serverdb where server_cpuname like '%i7-4%' and server_spec like '%i7-4%' and server_use_status='y'";
		$format_query = "select count(*) from serverdb where server_cpuname like '%i7-4%' and server_spec like '%i7-4%' and server_fomat_date !='NULL'";

		$all_data = @mysql_query($all_query , $db_connect) or die($db_q_error);
		$use_data = @mysql_query($use_query , $db_connect) or die($db_q_error);
		$empty_data = @mysql_query($empty_query , $db_connect) or die($db_q_error);
		$format_data = @mysql_query($format_query , $db_connect) or die($db_q_error);

		$all=mysql_fetch_assoc($all_data);
		$use=mysql_fetch_assoc($use_data);
		$empty=mysql_fetch_assoc($empty_data);
		$format=mysql_fetch_assoc($format_data);

?>
								<tr>
									<td>INTEL i7(4세대)</td>
									<td>i7-4.xx</td>
									<td>i7-4</td>
									<td>45 만원</td>
									<td><?=$all['count(*)']?> 대</td>
									<td><?=$use['count(*)']?> 대</td>
									<td><font color=blue><?=$empty['count(*)']?></font> 대</td>
									<td><?=$format['count(*)']?> 대</td>
								</tr>
						</tbody>
						<tfoot>
							<tr>
								<td colspan="1">합계</td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
								<td></td>
							</tr>
						</tfoot>
					</table>

<?
		//$rental_query = "select count(*) from serverdb where server_cpuname like 'E5504' and server_spec like 'Q20' and server_use_status='n' and server_rental_date > DATE_ADD(now(), INTERVAL -7 DAY)";
		$rental_query = "select count(*) from serverdb where server_cpuname like 'E5504' and server_spec like 'Q20' and server_use_status='n' and server_rental_date > DATE_ADD(now(), INTERVAL -7 DAY)";

//		WHERE (server_rental_date BETWEEN '2015-09-01' AND '2015-09-30')
		$use_query = "select count(*) from serverdb where server_cpuname like '%i7-4%' and server_spec like '%i7-4%' and server_use_status='n' ";
		$empty_query = "select count(*) from serverdb where server_cpuname like '%i7-4%' and server_spec like '%i7-4%' and server_use_status='y'";
		$format_query = "select count(*) from serverdb where server_cpuname like '%i7-4%' and server_spec like '%i7-4%' and server_fomat_date !='NULL'";
?>

<?
//DB닫기
mysql_close($db_connect);
?>