<h2 style="float: left;">Handelslogs</h2>
<span style="float: right;color: #f30;cursor:pointer;" onclick="jQuery('#tradepopup').hide(); jQuery('#loginList').show();">x</span>
<br style="clear:both;" />
<?php
define('access', true);
include('../functions.inc.php');
include('../../../../includes/xinc_config.php');


$resTradeGetTradeDatesAndIDs = odbc_exec($odbc_connect, '
    SELECT	a.[TradeID],
            date.[TradeDt]
    FROM	[' . $_CONFIG['db_databases']['log'] . '].[dbo].[tblTradeDetailLog] AS a
        LEFT JOIN [' . $_CONFIG['db_databases']['log'] . '].[dbo].[tblTradeLog] AS date ON date.[TradeID] = a.[TradeID]
    WHERE   [idPlayer] = \'' . mssql_escape_string($_GET['getCharacterID']) . '\'
');
if(@odbc_num_rows($resTradeGetTradeDatesAndIDs) > 0) {
    while($arrayTradeDateAndID = @odbc_fetch_array($resTradeGetTradeDatesAndIDs)) {


        $resGetDetailledTradeInformation = odbc_exec($odbc_connect, '
            SELECT	[m_szName],
                    [ItemIndex],
                    [ItemSerialNum],
                    [ItemCnt]
            FROM [' . $_CONFIG['db_databases']['log'] . '].[dbo].[tblTradeItemLog]
                LEFT JOIN [' . $_CONFIG['db_databases']['chr'] . '].dbo.[CHARACTER_TBL] on [idPlayer] = [m_idPlayer]
            WHERE [TradeID] = ' . $arrayTradeDateAndID['TradeID'] . '
            ORDER BY [m_szName] DESC
        ');

        echo '
        <div id="' . $arrayTradeDateAndID['TradeID'] . '">
            <p><a href="#' . $arrayTradeDateAndID['TradeID'] . '" title="Trade ID: #' . $arrayTradeDateAndID['TradeID'] . '">' . date($_CONFIG['web_date_format']['full'], strtotime($arrayTradeDateAndID['TradeDt'])) . ' Uhr</a>:</p>';

        while($arrayDetailledTradeInformation = odbc_fetch_array($resGetDetailledTradeInformation)) {
            echo '
            <p class="items">
                <b>' . $arrayDetailledTradeInformation['m_szName'] . '</b>:
                ' . $arrayDetailledTradeInformation['ItemCnt'] . 'x
                <a href="#' . $arrayTradeDateAndID['TradeID'] . '" title="Item ID: #' . $arrayDetailledTradeInformation['ItemSerialNum'] . '">' . $arrayDetailledTradeInformation['ItemIndex'] . '</a>
            </p>
            ';
        }

        echo '
        </div>';
    }

}
else {
    echo '<div class="fail">Dieser Charakter hat noch nicht gehandelt.</div>';
}


