<?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');

class rseventsViewTickets extends JView
{
	function display($tpl = null)
	{
		$task=JRequest::getVar('task','','request');
		switch($task)
		{
			
			case 'listtickets':
			{
			
			$evName = $this->get('EventName');
			JToolbarHelper::title(JText::_('RSE_MANAGE_TICKET').' '.$evName,'generic.png');
			JToolbarHelper::addNewX('editticket');
			JToolbarHelper::editListX('editticket');
			JToolBarHelper::deleteList();
			JToolbarHelper::custom('back','back.png','back_f2.png',JText::_('RSE_BACK'),false);
			
			$idEvent = intval(JRequest::getVar('IdEvent',0,'request'));
			$sortColumn		=JRequest::getVar('filter_order','#__rsevents_tickets.ordering');
			$sortOrder	=JRequest::getVar('filter_order_Dir','asc');
			$pagination=$this->get('pagination');
			$tickets = $this->get('data');


			$this->assignRef('data',$tickets);
			$this->assignRef('idEvent',$idEvent);
			$this->assignRef('sortColumn',$sortColumn);
			$this->assignRef('sortOrder',$sortOrder);
			$this->assignRef('pagination',$pagination);
			
			} break;
			
			case 'editticket':
			{
			
				$cid=JRequest::getVar('cid',array(0),'request','array');
				$idEvent=JRequest::getVar('IdEvent',0,'post');
				if(is_array($cid)) $cid=intval($cid[0]);
				if($cid==0)
					JToolBarHelper::title(JText::_('RSE_NEW_TICKET','generic.png'));
				else 
					JToolBarHelper::title(JText::_('RSE_EDIT_TICKET','generic.png'));
				JToolBarHelper::save();
				JToolBarHelper::apply();
				JToolBarHelper::cancel();
				
				$ticket = $this->get('Ticket');
				if(empty($ticket->IdEvent))
				$ticket->IdEvent = $idEvent;
				$this->assignRef('data',$ticket);
			
			}
		}
		
		
		parent::display($tpl);
	}
}