<?php

class Brivium_Credits_ViewAdmin_Events_Lists extends XenForo_ViewAdmin_Base
{
	/**
	 * Renders all options, and splits them into groups according to
	 * their 100s display order
	 */
	public function renderHtml()
	{
		$events = array();
		$currencyEvents = array();
		$currencyModel = XenForo_Model::create('Brivium_Credits_Model_Currency');
		$currencies = $currencyModel->getAllCurrencies();
		foreach ($this->_params['events'] AS $eventId => $event)
		{
			if(!isset($currencyEvents[$event['currency_id']])){
				$currencyEvents[$event['currency_id']] = $currencies[$event['currency_id']]?$currencies[$event['currency_id']]:array();
				$currencyEvents[$event['currency_id']]['listEvents'] = array();
			}
			$x = floor($event['display_order'] / 100);
			$currencyEvents[$event['currency_id']]['listEvents'][$x][$eventId] = $event;
		}
		$this->_params['currencyEvents'] = $currencyEvents;
	}
}