<?php
/**
* @version		3.0.0
* @package		JomLand TicketCenter
* @copyright	Copyright (C) 2010 JomLand.com. All rights reserved.
* @link 		www.jomland.com
* @license		GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
*/
defined( '_JEXEC' ) or die( 'Restricted access' );

jimport( 'joomla.application.component.view');


class JLTicketCenterViewVenues extends JViewLegacy
{
	function display($tpl = null)
	{
		global $mainframe, $option;
		
		$mainframe = &JFactory::getApplication();
		$pathway   =& $mainframe->getPathway();
		$document =& JFactory::getDocument();
		$document->addStyleSheet(JURI::base().'components/com_jlticketcenter/assets/jlticketcenter.css');
		
		$pparams = new JLTicketCenterHelperSetup;
		
		$menu = JSite::getMenu()->getActive();
		if ($menu->component!='com_jlticketcenter'){
			$menu 		= JSite::getMenu();
			$bit_itemid = $menu->getItems('component','com_jlticketcenter');
			$itemid  	= $bit_itemid[0]->id;
		}
		else{
			$itemid  	= $menu->id;
		}
		
		 if ($itemid ){
		    $menu = JSite::getMenu();
		    $menuparams = $menu->getParams($itemid);
		 }else{
			$menuparams = JComponentHelper::getParams('com_jlticketcenter');
		 }
		 
		 // Assign Menu Params to Request
		 if (!JRequest::getInt('city',0) && !JRequest::getInt('state',0)&& !JRequest::getInt('country',0) ){
		 	
		 	if ($menuparams->get('city',0)>0){
		 		JRequest::setVar('city',$menuparams->get('city',0));
		 	}
		 	elseif ($menuparams->get('state',0)>0){
		 		JRequest::setVar('state',$menuparams->get('state',0));
		 	}
		 	elseif ($menuparams->get('country',0)>0){
		 		JRequest::setVar('country',$menuparams->get('country',0));
		 	}
		 }
		 
		 if (JRequest::getInt('city',0)>0){
		 		
		 		$city = $this->get('City');
		 		
		 		if ($city){
		 			if ($pparams->get('display_country')>0){
		 				$pathway->addItem($city->country, JRoute::_('index.php?option=com_jlticketcenter&view=venues&country='.$city->country_id.'&Itemid='.$itemid));
		 				$pageTitle = ' - '.$city->country;
		 			}
		 			if ($city->state_id){
			 			$pathway->addItem($city->state_name, JRoute::_('index.php?option=com_jlticketcenter&view=venues&state='.$city->state_id.'&Itemid='.$itemid));
			 			$pageTitle = ' - '.$city->state_name . $pageTitle;
					}
		 			
		 			$pathway->addItem($city->city_name, '');
		 			$pageTitle = $city->city_name .$pageTitle;

		 			 $document->setTitle(JText::_('Venues').' - '.$pageTitle );       
		 		}
		 		
		 		$this->assignRef('city', $city);
		 		$this->setLayout('city');
	 		}elseif (JRequest::getInt('state',0)>0){
		 		$state = $this->get('State');
		 		if ($state){
		 			if ($pparams->get('display_country')>0){
		 				$pathway->addItem($state->country, JRoute::_('index.php?option=com_jlticketcenter&view=venues&country='.$state->country_id.'&Itemid='.$itemid));
		 				$pageTitle = ' - '.$state->country;
		 			}

		 			$pathway->addItem($state->state_name, '');
		 			$pageTitle = $state->state_name . $pageTitle;
		 			 
		 			$document->setTitle(JText::_('Venues').' - '.$pageTitle );
		 		}
		 		$this->assignRef('state', $state);
		 		$this->setLayout('state');
		 	}
		 	elseif (JRequest::getInt('country',0)>0){
		 		$country = $this->get('Country');
		 		if ($country){
		 			$pathway->addItem($country->country, '');
		 			$pageTitle = $country->country;
		 			$document->setTitle(JText::_('Venues').' - '.$pageTitle );
		 		}
		 		$this->assignRef('country', $country);
		 		$this->setLayout('country');
		 	}
		 
		$venues = $this->get('Venues');
		
		
		$this->assignRef('venues', $venues);
		$this->assignRef('params', $pparams);
		$this->assignRef('menuparams', $menuparams);
		
		$this->assignRef('itemid',	$Itemid );
		
		parent::display($tpl);
		
		JLTicketCenterLinksHelper::renderinfo();
	}
} // EOC VIEW