<?php

/* ====================
  [BEGIN_COT_EXT]
  Hooks=admin.home.mainpanel
  Order=11
  [END_COT_EXT]
  ==================== */

/**
 * EasyAdmin for Giglance
 *
 * @package Payouts stat
 * @version 2.6.9
 * @author CoTEMPLATE
 * @copyright Copyright (c) CoTEMPLATE.com
 */
defined('COT_CODE') or die('Wrong URL');

global $sys;

$t = new XTemplate(cot_tplfile('eadmin.payouts.graph.mainpanel', 'module'));

$totalitems = $db->query("SELECT COUNT(*) FROM $db_payments_outs WHERE out_status = 'process'")->fetchColumn();

if ($totalitems > 0) {

    $payouts = $db->query("SELECT * FROM $db_payments_outs AS o
		LEFT JOIN $db_users AS u ON u.user_id=o.out_userid
		WHERE o.out_status = 'process'
		ORDER BY o.out_id DESC")->fetchAll();

    foreach ($payouts as $payout) {
        $t->assign(array(
            'PAYOUT_ROW_DATE' => $payout['out_date'],
            'PAYOUT_ROW_SUMM' => $payout['out_summ'],
            'PAYOUT_ROW_DETAILS' => $payout['out_details'],
        ));
        $t->assign(cot_generate_usertags($payout, 'PAYOUT_ROW_USER_'));
        $t->parse('MAIN.PAYOUT_ROW');
    }
} else {
    $t->parse('MAIN.PAYOUT_EMPTY');
}

$t->parse('MAIN');
$line = $t->text('MAIN');