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

//HTML 시작


$mk_q1="select * from servicedb where service_line NOT IN ('onetime','vpn','substitution','event','office','test') order by client_code,service_request_date,service_line asc";
$mk_q1_query = @mysql_query($mk_q1 , $db_connect) or die($db_q_error);
$mk_q1_num = mysql_num_rows($mk_q1_query);

$mk_summary="select sum(amount_rack),sum(amount_line),sum(amount_cpu),sum(amount_ip),sum(amount_cs),sum(amount_vpc),sum(amount_defence),sum(amount_etc) from amountdb";
$mk_summary_query=@mysql_query($mk_summary , $db_connect) or die($db_q_error);
$mk_summary_data=mysql_fetch_assoc($mk_summary_query);
?>
<?=$mk_summary_data['sum(amount_rack)']+$mk_summary_data['sum(amount_line)']+$mk_summary_data['sum(amount_cpu)']+$mk_summary_data['sum(amount_ip)']+$mk_summary_data['sum(amount_cs)']+$mk_summary_data['sum(amount_vpc)']+$mk_summary_data['sum(amount_defence)']+$mk_summary_data['sum(amount_etc)']?> / <?=$mk_summary_data['sum(amount_rack)']?> / <?//=$mk_summary_data?>
<table border=1>
<tr>
	<th>업체명</th>
	<th>회선</th>
	<th>장비번호</th>
	<th>장비사양</th>
	<th>스위치</th>
	<th>OS</th>
	<th>기본IP</th>
	<th>정상가</th>
	<th>할인금액</th>
	<th>서비스가</th>
</tr>
<?
for ($i=0;$i<$mk_q1_num;$i++){
$mk_q1_data=mysql_fetch_assoc($mk_q1_query);

$mk_q2="select * from clientdb where Client_Code like '".$mk_q1_data[client_code]."'";
$mk_q2_query = @mysql_query($mk_q2 , $db_connect) or die($db_q_error);
$mk_q2_data=mysql_fetch_assoc($mk_q2_query);

$mk="select * from amountdb where service_code like '".$mk_q1_data[service_code]."' order by service_code asc";
$mk_query = @mysql_query($mk , $db_connect) or die($db_q_error);
$mk_num = mysql_num_rows($mk_query);
$mk_data=mysql_fetch_assoc($mk_query);
$mk_default=$mk_data[amount_rack]+$mk_data[amount_line]+$mk_data[amount_cpu]+$mk_data[amount_ip]+$mk_data[amount_cs]+$mk_data[amount_vpc]+$mk_data[amount_defence]+$mk_data[amount_etc];
$mk_discount=$mk_data[amount_total_discount]+$mk_data[amount_sub_discount]+$mk_data[amount_defence_discount];
$mk_service=$mk_default-$mk_discount;


$mk_q3="select * from serverdb where server_code like '".$mk_q1_data[server_code]."'";
$mk_q3_query = @mysql_query($mk_q3 , $db_connect) or die($db_q_error);
$mk_q3_data=mysql_fetch_assoc($mk_q3_query);
?>
<tr>
	<td><?=$mk_q2_data[Client_Name]?></td>
	<td><?=$mk_q1_data[service_line]?></td>
	<td><?=$mk_q1_data[server_code]?></td>
	<td><?=$mk_q3_data[server_spec]?></td>
	<td><?=$mk_q1_data[service_sw]?></td>
	<td><?=$mk_q1_data[service_os]?></td>
	<td><?=$mk_q1_data[service_ip]?></td>
	<td><?=$mk_default?></td>
	<td><?=$mk_discount?></td>
	<td><?=$mk_service?></td>
</tr>
<? } ?>
</table>

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

/*

$mk="select * from amountdb order by service_code asc";
$mk_query = @mysql_query($mk , $db_connect) or die($db_q_error);
$mk_num = mysql_num_rows($mk_query);
?>
<ul class="table-ul">
<?
for ($i=0;$i<$mk_num;$i++){
        $mk_data=mysql_fetch_assoc($mk_query);
		$mk_default=$mk_data[amount_rack]+$mk_data[amount_line]+$mk_data[amount_cpu]+$mk_data[amount_ip]+$mk_data[amount_cs]+$mk_data[amount_vpc]+$mk_data[amount_defence]+$mk_data[amount_etc];
		$mk_discount=$mk_data[amount_total_discount]+$mk_data[amount_sub_discount]+$mk_data[amount_defence_discount];
		$mk_service=$mk_default-$mk_discount;
?>
<li>
<?
echo $mk_default;
echo "/";
echo $mk_discount;
echo "/";
echo $mk_service;
?>
</li>
<? } ?>
</ul>



echo .$mk_q1_data[service_line].$mk_q1_data[server_code].$mk_q1_data[service_sw].$mk_q1_data[service_os].$mk_q1_data[service_ip];
echo "/";
echo $mk_default;
echo "/";
echo $mk_discount;
echo "/";
echo $mk_service;
echo "<br>";
*/
?>
