<?php include('inc/header.php'); ?>
<h1>Herzlich Willkommen im GM-Panel</h1>
<div class="container">
<?php	
	$newticket = odbc_exec($odbc_connect, 'SELECT COUNT(*) as count FROM [' . $_CONFIG['db_databases']['web'] . '].[dbo].[TICKET_THREADS] WHERE [byadmin] is NULL AND status = 0 OR [byadmin] = \''.$_SESSION['user'].'\' AND status = 0');
	if(odbc_result($newticket, 'count') == 1) {echo '<a href="ticketsys.php">There is <b>'.odbc_result($newticket, 'count').'</b> new Ticket</a>';}
	elseif (odbc_result($newticket, 'count') > 1) {echo '<a href="ticketsys.php">There are <b>'.odbc_result($newticket, 'count').'</b> new Tickets</a>';}




	odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['acc'] . ']');
	$accounts = odbc_exec($odbc_connect, 'SELECT * FROM [ACCOUNT_TBL]');
	odbc_exec($odbc_connect, 'USE [' . $_CONFIG['db_databases']['chr'] . ']');
	$characters = odbc_exec($odbc_connect, 'SELECT * FROM [CHARACTER_TBL]');
	$charactersDel = odbc_exec($odbc_connect, 'SELECT * FROM [CHARACTER_TBL] WHERE [isblock] = \'F\'');

	$guilds = odbc_exec($odbc_connect, 'SELECT * FROM [GUILD_TBL]');
	
	$lordquery = odbc_exec($odbc_connect, 'SELECT TOP 1 m_szName FROM [tblLord] a LEFT JOIN CHARACTER_TBL b ON RIGHT(\'0000000\' + CONVERT(VARCHAR(7),a.idLord),7)= b.m_idPlayer ORDER BY s_date DESC');
	if(odbc_result($lordquery, 'm_szName') != '') {
		$lord = odbc_result($lordquery, 'm_szName');
	} else {
		$lord = '-';
	}
	$mvpquery = odbc_exec($odbc_connect, 'SELECT TOP 1 m_szName FROM [tblCombatJoinPlayer] JP LEFT JOIN tblCombatInfo CI ON JP.CombatID = CI.CombatID LEFT JOIN CHARACTER_TBL C ON JP.PlayerID = C.m_idPlayer WHERE CI.[Status] = \'30\' ORDER BY JP.CombatID DESC, Point DESC');
	if(odbc_result($mvpquery, 'm_szName') != '') {
		$mvp = odbc_result($mvpquery, 'm_szName');
	} else {
		$mvp = '-'; 
	}
	
	$gswinquery = odbc_exec($odbc_connect, 'SELECT TOP 1 m_szGuild FROM [tblCombatJoinGuild] JG LEFT JOIN tblCombatInfo CI ON JG.CombatID = CI.CombatID LEFT JOIN GUILD_TBL G ON JG.GuildID = G.m_idGuild WHERE CI.[Status] = \'30\' ORDER BY JG.CombatID DESC, Point DESC');
	if(odbc_result($gswinquery, 'm_szGuild') != '') {
		$gswin = odbc_result($gswinquery, 'm_szGuild');
	} else {
		$gswin = '-'; 
	}
?>
<h2>Serverstatistiken</h2>

<table>
	<tr>
    	<td>Accounts:</td>
        <td><?php echo odbc_num_rows($accounts); ?></td>
    </tr>
	<tr>
    	<td id="key">Charaktere:</td>
        <td id="value"><?php echo odbc_num_rows($characters); ?></td>
    </tr>
	<tr>
    	<td id="key">- davon aktiv:</td>
        <td id="value"><?php echo odbc_num_rows($charactersDel); ?></td>
    </tr>
	<tr>
    	<td id="key">Gilden:</td>
        <td id="value"><?php echo odbc_num_rows($guilds); ?></td>
    </tr>
	<tr>
    	<td id="key">Lord:</td>
        <td id="value"><?php echo $lord; ?></td>
    </tr>
	<tr>
    	<td id="key">MVP:</td>
        <td id="value"><?php echo $mvp; ?></td>
    </tr>
	<tr>
    	<td id="key">GS Sieger:</td>
        <td id="value"><?php echo $gswin; ?></td>
    </tr>
</table>

<?php
	function retJob($job){
		global $odbc_connect, $_CONFIG;
		$jobs = odbc_exec($odbc_connect, 'SELECT * FROM [' . $_CONFIG['db_databases']['chr'] . '].[dbo].[CHARACTER_TBL] WHERE [m_nJob] = \''.$job.'\'');
		return odbc_num_rows($jobs);
	}
	
	echo '<h2>Jobklassen</h2>';
	echo '<table border="0"><tr><td><b>'.$job[0].':</b></td><td>'.retJob(0).'</td></tr></table>';
	echo '<table border="0"><tr>';
	echo '<td><table border="0">
			<tr><td><b>'.$job[1].':</b></td><td>'.retJob(1).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[6].':</td><td style="font-size: 11px">'.retJob(6).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[6].' (M):</td><td style="font-size: 11px">'.retJob(16).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[6].' (H):</td><td style="font-size: 11px">'.retJob(24).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[32].' (L):</td><td style="font-size: 11px">'.retJob(32).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[7].':</td><td style="font-size: 11px">'.retJob(7).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[7].' (M):</td><td style="font-size: 11px">'.retJob(17).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[7].' (H):</td><td style="font-size: 11px">'.retJob(25).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[33].' (L):</td><td style="font-size: 11px">'.retJob(33).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</td></td><td><table border="0">
			<tr><td><b>'.$job[2].':</b></td><td>'.retJob(2).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[8].':</td><td style="font-size: 11px">'.retJob(8).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[8].' (M):</td><td style="font-size: 11px">'.retJob(18).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[8].' (H):</td><td style="font-size: 11px">'.retJob(26).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[34].' (L):</td><td style="font-size: 11px">'.retJob(34).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[9].':</td><td style="font-size: 11px">'.retJob(9).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[9].' (M):</td><td style="font-size: 11px">'.retJob(19).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[9].' (H):</td><td style="font-size: 11px">'.retJob(27).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[35].' (L):</td><td style="font-size: 11px">'.retJob(35).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</td></td><td><table border="0">
			<tr><td><b>'.$job[3].':</b></td><td>'.retJob(3).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[10].':</td><td style="font-size: 11px">'.retJob(10).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[10].' (M):</td><td style="font-size: 11px">'.retJob(20).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[10].' (H):</td><td style="font-size: 11px">'.retJob(28).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[36].' (L):</td><td style="font-size: 11px">'.retJob(36).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[11].':</td><td style="font-size: 11px">'.retJob(11).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[11].' (M):</td><td style="font-size: 11px">'.retJob(21).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[11].' (H):</td><td style="font-size: 11px">'.retJob(29).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[37].' (L):</td><td style="font-size: 11px">'.retJob(37).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</td></td><td><table border="0">
			<tr><td><b>'.$job[4].':</b></td><td>'.retJob(4).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[12].':</td><td style="font-size: 11px">'.retJob(12).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[12].' (M):</td><td style="font-size: 11px">'.retJob(22).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[12].' (H):</td><td style="font-size: 11px">'.retJob(30).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[38].' (L):</td><td style="font-size: 11px">'.retJob(38).'</td></tr>
			<tr><td></td><td></td></tr>
			<tr><td style="font-size: 11px">- '.$job[13].':</td><td style="font-size: 11px">'.retJob(13).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[13].' (M):</td><td style="font-size: 11px">'.retJob(23).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[13].' (H):</td><td style="font-size: 11px">'.retJob(31).'</td></tr>
			<tr><td style="font-size: 11px">- '.$job[39].' (L):</td><td style="font-size: 11px">'.retJob(39).'</td></tr>
		  </table></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td></td><td>';
	echo '</tr></table>';
?>
</div>
<?php include('inc/footer.php'); ?>