'._DONATIONS_ADMIN_PANEL.'
'; echo ''._DONATIONS_ADMIN_HOME.' | '; echo ''._DONATIONS_CONFIG.' | '; echo ''._DONATIONS_VIEW.' | '; echo ''._DONATIONS_EVENTS.' | '; echo ''._DONATIONS_BLOCKS_MANAGE.' | '; echo ''._DONATIONS_RETURNMAIN.''; echo '
'; CloseTable(); echo '
'; switch($op){ case 'Donations_Blocks': include_once (NUKE_MODULES_DIR.$module_name.'/admin/blocks.php'); break; case 'Donations_Config': include_once (NUKE_MODULES_DIR.$module_name.'/admin/config.php'); break; case 'Donations_Events': include_once (NUKE_MODULES_DIR.$module_name.'/admin/events.php'); break; case 'Donations_View': include_once (NUKE_MODULES_DIR.$module_name.'/admin/view.php'); break; case 'Donations': OpenTable(); echo '
'._DONATIONS.'

'; echo '
'; $res = $db->sql_query('SELECT currency.* FROM `'.$prefix.'_donations_config` AS config LEFT JOIN `'.$prefix.'_donations_currency` AS currency ON config.`currency` = currency.`currency`'); list($currency, $currency_symbol) = $db->sql_fetchrow($res); $res = $db->sql_query('SELECT `site_active`, `site_target` FROM `'.$prefix.'_donations_config`'); list($site_donations_active, $site_target) = $db->sql_fetchrow($res); $res = $db->sql_query('SELECT `user_id`, `first_name`, `last_name`, `settle_amount`, `event_id`, `payment_date` FROM `'.$prefix.'_donations` UNION SELECT `user_id`, `first_name`, `last_name`, `settle_amount`, `event_id`, `payment_date` FROM `'.$prefix.'_donations_archive`'); $donators = array(); $stats['week'] = array('number'=>0, 'amount'=>0); $stats['month'] = array('number'=>0, 'amount'=>0); $stats['sixmonths'] = array('number'=>0, 'amount'=>0); $stats['year'] = array('number'=>0, 'amount'=>0); $stats['life'] = array('number'=>0, 'amount'=>0); $site_amount = 0; while ($row = $db->sql_fetchrow($res)){ if ($row['event_id']==0){ $site_amount += $row['settle_amount']; } if ($row['user_id']!=0){ if (isset($donators[$row['user_id']])){ $donators[$row['user_id']] += $row['settle_amount']; }else{ $donators[$row['user_id']] = $row['settle_amount']; } } $time = time(); $stats['life']['number'] += 1; $stats['life']['amount'] += $row['settle_amount']; if ($row['payment_date']>($time-31556926)){ $stats['year']['number'] += 1; $stats['year']['amount'] += $row['settle_amount']; if ($row['payment_date']>($time-15778463)){ $stats['sixmonths']['number'] += 1; $stats['sixmonths']['amount'] += $row['settle_amount']; if ($row['payment_date']>($time-2629743)){ $stats['month']['number'] += 1; $stats['month']['amount'] += $row['settle_amount']; if ($row['payment_date']>($time-604800)){ $stats['week']['number'] += 1; $stats['week']['amount'] += $row['settle_amount']; } } } } } arsort($donators); $i=1; foreach($donators as $id=>$amount){ if ($i>5){ unset($donators[$id]); } $i++; } if (!empty($donators)){ $in = implode(',', array_keys($donators)); $res = $db->sql_query('SELECT `user_id`, `username` FROM `'.$prefix.'_users` WHERE `user_id` IN ('.$in.')'); $top5 = array(); while($row = $db->sql_fetchrow($res)){ $top5[$row['user_id']] = array('username'=>$row['username'], 'amount'=> $donators[$row['user_id']]); } } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
'._DONATIONS_GLOBAL_STATS.'
'._DONATIONS_LAST_WEEK.''.$stats['week']['number'].''.$currency_symbol.currency($stats['week']['amount']).' '.$currency.'
'._DONATIONS_LAST_MONTH.''.$stats['month']['number'].''.$currency_symbol.currency($stats['month']['amount']).' '.$currency.'
'._DONATIONS_LAST_SIX_MONTHS.''.$stats['sixmonths']['number'].''.$currency_symbol.currency($stats['sixmonths']['amount']).' '.$currency.'
'._DONATIONS_LAST_YEAR.''.$stats['year']['number'].''.$currency_symbol.currency($stats['year']['amount']).' '.$currency.'
'._DONATIONS_LIFETIME.''.$stats['life']['number'].''.$currency_symbol.currency($stats['life']['amount']).' '.$currency.'

'; echo ''; foreach($donators as $key=>$val){ $user = $top5[$key]; echo ''; } echo '
'._DONATIONS_TOP_FIVE_DONATORS.'
'.UsernameColor($user['username']).''.$currency_symbol.currency($user['amount']).' '.$currency.'

'; echo '
'; $res = $db->sql_query('SELECT `event_id`, COUNT(`id`) as c FROM `nuke_donations` GROUP BY `event_id`'); while ($row = $db->sql_fetchrow($res)){ $event_count[$row['event_id']] = $row['c']; } echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if ($site_target>0){ $difference = $site_amount-$site_target; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; } echo '
'._DONATIONS_SITE.(($site_donations_active) ? '' : ' ('._DONATIONS_INACTIVE.')').'
'._DONATIONS_DONATIONS.''.((isset($event_count[0])) ? $event_count[0] : 0).'
'._DONATIONS_CURRENT_AMOUNT.''.$currency_symbol.currency($site_amount).' '.$currency.'
'._DONATIONS_GOAL.''.$currency_symbol.currency($site_target).' '.$currency.'
'.(($difference>0) ? _DONATIONS_ABOVE_GOAL : _DONATIONS_BELOW_GOAL).''.$currency_symbol.currency(abs($difference)).' '.$currency.'
'._DONATIONS_PERCENT_COMPLETE.''.round($site_amount/$site_target*100).'%

'; $res = $db->sql_query('SELECT `id`, `title`, `time_based`, `date_end`, `target`, `current`, `active` FROM `'.$prefix.'_donations_events`'); while ($row = $db->sql_fetchrow($res)){ echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if ($row['target']>0){ echo ''; echo ''; $difference = $row['current']-$row['target']; echo ''; echo ''; echo ''; echo ''; } if ($row['time_based']==1){ echo ''; echo ''; } echo '
'.$row['title'].(($row['active']) ? '' : ' ('._DONATIONS_INACTIVE.')').'
'._DONATIONS_DONATIONS.''.((isset($event_count[$row['id']])) ? $event_count[$row['id']] : 0).'
'._DONATIONS_CURRENT_AMOUNT.''.$currency_symbol.currency($row['current']).' '.$currency.'
'._DONATIONS_GOAL.''.$currency_symbol.currency($row['target']).' '.$currency.'
'.(($difference>0) ? _DONATIONS_ABOVE_GOAL : _DONATIONS_BELOW_GOAL).''.$currency_symbol.currency(abs($difference)).' '.$currency.'
'._DONATIONS_PERCENT_COMPLETE.''.round($row['current']/$row['target']*100).'%
'._DONATIONS_END_DATE.''.date('d/m/Y', $row['date_end']).'

'; } echo '
'; CloseTable(); break; } }else{ OpenTable(); echo '
'._DONATIONS_ERROR.'
'._DONATIONS_NO_PERM.'
'; CloseTable(); } include_once NUKE_BASE_DIR.'footer.php'; ?>