<?php
/**
* @version 1.0.0
* @package RSEvents! 1.0.0
* @copyright (C) 2009 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

defined( '_JEXEC' ) or die( 'Restricted access' ); 
jimport( 'joomla.application.component.view');
jimport( 'joomla.application.component.model' );

class rseventsViewArchive extends JView
{
	function display($tpl = null)
	{
				global $mainframe;
				$db = & JFactory::getDBO();
				
				JToolBarHelper::title(JText::_('RSE_ARCHIVE'),'generic.png');
				JToolBarHelper::unarchiveList();
				JToolBarHelper::deleteList("Are you sure you want to delete?", 'remove' , "Delete");
				JToolBarHelper::cancel();
				JToolBarHelper::custom('main','preview.png','preview_f2.png',JText::_('RSE_RS_PRODUCT'),false);
				
				$filter			=JRequest::getVar('rs_filter');
				$category_filter = JRequest::getVar('rs_cat_filter');
				$location_filter=JRequest::getVar('rs_loc_filter');
				$sortColumn		=JRequest::getVar('filter_order','e.EventStartDate');
				$sortOrder	=JRequest::getVar('filter_order_Dir','desc');
				$listEvents=$this->get('data');
				$pagination=$this->get('pagination');
				
				// loads the settings
				$rseventsConfig = $mainframe->getUserState('rseventsConfig');
				$this->assignRef('rseventsConfig',$rseventsConfig);
				
				$sql = 'SELECT IdCategory, CategoryName  FROM #__rsevents_categories';
				$db->setQuery($sql);

				$catlist[]         = JHTML::_('select.option',  '0', JText::_( 'RSE_EVENT_SELECT_CATEGORY' ), 'IdCategory', 'CategoryName' );
				$catlist         = array_merge( $catlist, $db->loadObjectList() );
				$lists['categories']      = JHTML::_('select.genericlist', $catlist, 'rs_cat_filter', 'class="inputbox" size="1" onchange="submitbutton(\'archive\');"','IdCategory', 'CategoryName', $category_filter  );
				
				$sql = 'SELECT LocationName as val, LocationName  FROM #__rsevents_locations';
				$db->setQuery($sql);

				$catlist1[]         = JHTML::_('select.option',  '0', JText::_( 'RSE_EVENT_SELECT_LOCATION' ), 'val', 'LocationName' );
				$catlist1         = array_merge( $catlist1, $db->loadObjectList() );
				$lists['locations']      = JHTML::_('select.genericlist', $catlist1, 'rs_loc_filter', 'class="inputbox" size="1" onchange="submitbutton(\'archive\');"','val', 'LocationName', $location_filter  );
			

				$this->assignRef('location_filter',$category_filter);
				$this->assignRef('category_filter',$category_filter);
				$this->assignRef('lists'      	, $lists);
				$this->assignRef('filter',$filter);
				$this->assignRef('sortColumn',$sortColumn);
				$this->assignRef('sortOrder',$sortOrder);
				$this->assignRef('EventList',$EventList);
				$this->assignRef('data',$listEvents);
				$this->assignRef('pagination',$pagination);
		
		
		parent::display($tpl);
	}
}