<?PHP
$_OPTIMIZATION["title"] = $lang['payments']['title'];
?>

<section class="main races">
    <div class="wrapper-constrained">
        <div class="content-wrapper flex">
            <div class="perfpage">
                                <div class="container elven">
                    <div class="decor big"></div>
                    <h3><span>Payments</span></h3>
                    <div class="container-inner">
                        <h2 class="st-center">Recent payments</h2>
                            <div class="payments-container">

                                <div class="payments-table">
                                    <table id="pay-table">
                                        <thead>
                                        <tr><th></th>
                                        <th>Username</th>
                                        <th>Amount</th>
                                        <th>Payment method</th>
                                        <th>Purse</th>
                                        <th>Date</th>
                                            
                                        </tr></thead>
										<?PHP
                    $dt = time() - 60*60*96;
                    $db->Query("SELECT * FROM db_payment LEFT JOIN db_users_b on db_users_b.user= db_payment.user WHERE db_payment.status = '3' AND db_payment.date_add > '$dt' order by db_payment.id desc  LIMIT 20");
                    if($db->NumRows() > 0){
                        $all_pay = 0;
                        $all_pay_sum = 0;
                        while($data = $db->FetchArray()){
                            $all_pay ++;
                            $all_pay_sum += $data["sum"];
                            ?>
                            <tr class="text-center">
							 <td><img src="<?php echo("/images/avatars/".$data["avatar"]) ;?>" width="40"></td>
                                <td><?php echo $data["user"]; ?></td>
                                <td><?php echo number_format($data["sum"],8); ?></td>
								<td><div class="ic-gold3"></div></td>
                                <td><?php echo substr($data["purse"],0,6); ?><span class='text-blue'>XXX</span></td>
                                <td><?php echo date("d.m.Y H:i:s",$data["date_add"]); ?></td>
                            </tr>
                    <?PHP
                        }
                    ?>
                            <tfoot>
                                <tr>
                                    <td class="text-center" colspan='2'><b><?php echo $lang['payments']['count'];?>:</b> <?php echo $all_pay; ?></td>
                                    <td class="text-center" colspan='2'><b><?php echo $lang['payments']['total'];?>:</b> <?php echo $func->priceFormat($all_pay_sum); ?></td>
                                </tr>
                            </tfoot>
                    <?PHP
                }else echo "<tr><td class='text-center' colspan='4'>{$lang['error_messages']['noresults']}</td></tr>";
                ?>
                </table>
                                        
                                </div>
                            </div>
                    </div>
                    <div class="decor middle"></div>
                    <div class="decor left"></div>
                    <div class="decor right"></div>
                </div>
            </div>
        </div>
    </div>


</section>