<?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
*/ 
// no direct access
defined('_JEXEC') or die('Restricted access');

$event = $this->event;
?>

<?php if ($this->menuparams->get('menuparams', 1)): ?>
<div class="componentheading<?php echo $this->escape($this->menuparams->get('pageclass_sfx')); ?>">
    <h2><?php echo $this->escape($this->menuparams->get('page_title')); ?></h2>
</div>
<?php endif; ?>

<div class="contentpane<?php echo $this->escape($this->menuparams->get('pageclass_sfx')); ?>">
<?php
if ($event){

    if ($this->params->get('display_venue')==2){
		$venue_link = JROUTE::_('index.php?option=com_jlticketcenter&view=event&venue='.$event->venue_id.'&Itemid='.$this->itemid);
		$venue = JHTML::link($venue_link, $event->venue_name);
	}elseif ($this->params->get('display_venue')==1){
		$venue = $event->venue_name;
	}

	if ($this->params->get('display_city')==2){
		$city_link = JROUTE::_('index.php?option=com_jlticketcenter&view=event&city='.$event->city_id.'&Itemid='.$this->itemid);
		$city = JHTML::link($city_link, $event->city_name);
	}elseif ($this->params->get('display_city')==1){
		$city = $event->city_name;
	}

	if ($event->state_id){
		if ($this->params->get('display_state')==2){
			$state_link = JROUTE::_('index.php?option=com_jlticketcenter&view=venues&state='.$event->state_id.'&Itemid='.$this->itemid);
			$state = ',&nbsp;&nbsp;'.JHTML::link($state_link, $event->state_name);
		}elseif ($this->params->get('display_state')==1){
			$state = ',&nbsp;&nbsp;'.$event->state_name;
		}
	}

	if ($event->country_id){
		if ($this->params->get('display_country')==2){
			$country_link = JROUTE::_('index.php?option=com_jlticketcenter&view=venues&country='.$event->country_id.'&Itemid='.$this->itemid);
			$country = ',&nbsp;&nbsp;'.JHTML::link($country_link, $event->country);
		}elseif ($this->params->get('display_country')==1){
			$country = ',&nbsp;&nbsp;'.$event->country;
		}
	}
?>

<div class="event span12 row-fluid">
	<h1 class="summary"><?php echo $event->event_name;?></h1>
    <div class="row-fluid">
        <span class="dtstart"><?php echo JHTML::_('date', $event->event_date, JText::_('DATE_FORMAT_LC2'),null);?>
            <?php if ($event->event_end>'0000-00-00 00:00:00'){
                echo " - " ;
                // compare event dates
                if (JHTML::_('date',$this->event->event_date,'d-m-Y')==JHTML::_('date',$this->event->event_end,'d-m-Y')){
                    echo JHTML::_('date', $event->event_end, 'H:i',null);
                }
                else{
                    echo JHTML::_('date', $event->event_end, JText::_('DATE_FORMAT_LC2'),null);
                }
            }
            ?>
     	</span>
    </div>
	<span class="location row-fluid" >
		<?php echo $venue;?>
		<br />
		<?php
			if (!empty($event->address)){
				echo $event->address."<br/>";
			}
			if (isset($city)){
	 			echo $city;
	 		}
	 		if (isset($state)){
	 			echo $state ;
	 		}
	 		if (isset($country)){
	  			echo $country;
	 		}
		?>
	</span>
	<?php
		if ($event->description || !empty($event->event_img)){?>
		<div clas="row-fluid clearfix">
			<?php if (!empty($event->event_img)){
					echo JHtml::image($event->event_img, $event->event_name, 'class="event_image"');
			}
			?>
			<?php echo $event->description;?>
		</div>
	<?php }?>
</div>

<?php if (!$this->tickets){?>
<h4><?php echo JTExt::_('SOLD_OUT');?></h4>
<?php
}
else{
?>
<div class="row-fluid">
	<h3><?php
		switch($event->event_type){
			case 1:
				echo JText::_('REGISTER_TO_EVENT');
			break;
			case 2:
				echo JText::_('TICKETS_ON_DOOR');
			break;
			default:
				echo JText::_('BOOK_TICKETS');
			break;
		}
		?></h3>

        <div class="span-12">
            <?php foreach($this->tickets as $ticket){?>

                <form class="form-inline" name="jlticketcity_cart" method="post" action="<?php echo $this->formAction;?>">
                    <?php if ($ticket->ticket_desc>''){?>
                    <label><?php echo $ticket->ticket_desc;?></label>
                    <?php }?>
                    <?php if($event->event_type != 1 ){ ?>
                            <?php if(!empty($ticket->pre_sale_price)){?>
                                <label class="pre_sale">
							<?php echo $this->params->get('currency_symbol');?><strike><?php  echo $ticket->ticket_price;?></strike> <?php  echo JText::sprintf('JLTCETNER_PRESALE',JHtml::date($ticket->pre_sale_date,'d-m-Y'));?>
							</label>
                            <label class="pre_sale_discount">
							<?php echo $this->params->get('currency_symbol') .' '. $ticket->pre_sale_price;?> <input type="hidden" name="price" id="price" value="<?php echo $ticket->pre_sale_price;?>" readonly="readonly" />
							</label>
                            <?php }else{ ?>

                                <?php echo $this->params->get('currency_symbol') .' ' . $ticket->ticket_price;;?><input name="price" type="hidden" id="price" value="<?php echo $ticket->ticket_price;?>" readonly="readonly" />
                            <?php }?>
                    <?php }
                        if($event->event_type<2){
                            echo $ticket->dropdown;
                    }?>

                    <?php if($this->params->get('display_stock')==1 && $event->event_type<2){ ?>
                        <span><?php echo $ticket->tickets-$ticket->tickets_sold-$ticket->tickets_ordered  . ' ' .JText::_('JLTC_FREE_PLACES'); ?></span>
                    <?php }	?>

                        <input type="hidden" name="event_id" id="event_id"  value="<?php echo $event->id;?>" />
                        <input type="hidden" name="ticket_type" value="<?php echo $ticket->ticket_type;?>" />
                        <?php switch ($event->event_type){
                            case 1:	?>
                                <input type="hidden" name="price" id="price" value="0" readonly="readonly" />
                                <button type="submit" class="btn"><?php echo JText::_('REGISTER_BTN');?></button>
                                <?php	break;
                            case 2:
                                echo ' '.JText::_('TICKETS_ON_DOOR');
                                break;
                            default:
                                ?>
                                    <input type="submit" class="btn" value="<?php echo JText::_('Book');?>" />
                                <?php
                                break;
                        }
                        echo JHTML::_('form.token');?>
                    </form>

            <?php }?>
        </div>
    </div>

    <?php if ($event->seats_chart > ''){ ?>
        <div class="row-fluid">
           <?php echo JHtml::image($event->seats_chart, $event->venue_name,'id="venue_chart" style="max-width: 100%;"');?>
        <div class="row-fluid">
    <?php }?>
<?php }
}// End ticket if event exist
?>

</div>