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

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

class JLTicketCenterModelOrder extends JModelLegacy
{
	function getOrder(){
		$session = JFactory::getSession();
		$order_id = $session->get('jlticketcenter_order_id');
		
		//$session->clear('jlticketcenter_order_id');
		return $order_id;
	}
	
	function getPayment(){
		$session = JFactory::getSession();
		$paid = $session->get('jlticketcenter_order_paid');
		
		//$session->clear('jlticketcenter_order_id');
		return $paid;
	}
	
	function getOrderLines(){
		$filter = JRequest::getVar('filter', null );// LOWER;
		
		$where[] = "ol.`order_id`='".$filter['order_id']."'";
			
		$query = 'SELECT ol.*,e.`event_name`,e.`event_date`,e.`event_type`,p.`performer_name`,v.`venue_name`,city.`city_name`,state.`state_name`,country.`country`  AS `country`  '
			. ' FROM #__jltcenter_order_lines ol';
			
		$query .= " LEFT JOIN #__jltcenter_events  e  ON e.`id`=ol.`event_id` ";
		$query .= " LEFT JOIN #__jltcenter_performer p  ON p.`id`=e.`performer_id` ";
		$query .= " LEFT JOIN #__jltcenter_venue v  ON v.`id`=e.`venue_id` ";
		$query .= " LEFT JOIN #__jltcenter_city city  ON city.`id`=e.`city_id` ";
		$query .= " LEFT JOIN #__jltcenter_state state  ON state.`id`=e.`state_id` ";
		$query .= " LEFT JOIN #__jltcenter_country country ON country.`id`=e.`country_id` ";		
		
		if ($where){
			$query .=" WHERE ".implode(' AND ',$where);
		}
		
		$this->_db->setQuery( $query);
		//echo $this->_db->getQuery();
		$result = $this->_db->loadObjectList();

		return $result;
	}//EOF getOrderLines;
	
	
}//EOC