<?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');?>
<style>
#tickets_list tr.odd {
	background: #ccc;
}
</style>


<script language="javascript" type="text/javascript">



<!--
function submitbutton(pressbutton) {
	var form = document.adminForm;
	if (pressbutton == 'cancel') {
		submitform(pressbutton);
		return;
	}
	// do field validation

	if (form.event_name.value == ""){
		alert( "<?php echo JText::_('You must provide Event Name.', true ); ?>" );
	}else if(form.event_date.value == ""){
		alert( "<?php echo JText::_('You must provide event Date.', true ); ?>" );
	} 
	else if(form.event_start.value == ""){
		alert( "<?php echo JText::_('You must provide Event Start Time.', true ); ?>" );
	}
	else {
		<?php
			$editor =& JFactory::getEditor();
			echo $editor->save('description');
	     ?>
		submitform(pressbutton);
	}
}
//-->


</script>

<form action="index.php" method="post" name="adminForm" id="adminForm" class="">
	<div class="col100">
    <div class="form-inline form-inline-header">
        <div class="control-group">
            <div class="control-label"><label id="jform_title-lbl" for="event_name" class="hasTooltip required" title="" aria-invalid="false">
                    <?php echo JText::_('Event Name'); ?>:<span class="star">&nbsp;*</span></label>
            </div>
            <div class="controls">
                <input type="text" name="event_name" id="event_name" value="<?php echo $this->event->event_name;?>" class="inputbox input-xxlarge input-large-text" size="100" required aria-required="true" aria-invalid="false">
            </div>
        </div>

        <div class="control-group">
            <div class="control-label"><label id="jform_title-lbl" for="event_name" class="hasTooltip required" title="" aria-invalid="false">
                    <?php echo JText::_('Date'); ?>:<span class="star">&nbsp;*</span></label>
            </div>
            <div class="controls">
                <?php echo JHTML::calendar(JHTML::_('date',$this->event->event_date,'d-m-Y'),'event_date','event_date','%d-%m-%Y');?>
                <input class="inputbox input-mini" type="text" name="event_start" id="event_start" size="5" maxlength="5"
                       value="<?php echo JHTML::_('date',$this->event->event_date,'H:i',null);?>" />
                <?php echo JText::_('24 Hour format'); ?>

            </div>
        </div>

    </div>

    <div class="row form-inline form-horizontal span11">
        <div class="span6">
            <h4><?php echo JText::_('Event Details'); ?></h4>
            <div class="control-group">
                <label class="control-label" for="event_end"><?php echo JText::_('End Time');?></label>
                <div class="controls span10" >
                    <?php
                    if ($this->event->event_end>'0000-00-00 00:00:00'){
                        echo JHTML::calendar(date('d-m-Y', strtotime( $this->event->event_end)),'event_end','event_end','%d-%m-%Y');
                        $end_time =JHTML::_('date',$this->event->event_end,'H:i',null);
                    } else{
                        echo JHTML::calendar('','event_end','event_end','%d-%m-%Y');
                        $end_time ='';
                    }
                    ?>
                    <input class="inputbox input-mini"  type="text" name="event_end_time" id="event_end_time" size="5" maxlength="5" value="<?php echo $end_time ;?>" />
                    <br/>
                    <?php echo JText::_('Leave blank for no End time. 24 Hour format'); ?>
                </div>
            </div>

            <div class="control-group form-inline">
                <label class="control-label" for="published"><?php echo JText::_('Published'); ?></label>
                <div class="controls  span2">
                    <?php echo $this->published;?>
                </div>
            </div>

            <div class="control-group form-inline">
                <label class="control-label" for="performer_id"><?php echo JText::_('Performer'); ?></label>
                <div class="controls span2">
                    <?php echo $this->performers;?>
                </div>
            </div>
            <div class="control-group form-inline">
                <label class="control-label" for="feature"><?php echo JText::_('Featured'); ?></label>
                <div class="controls  span2">
                    <?php echo $this->feature;?>
                </div>
            </div>

        </div> <!-- end of left side -->


        <div class="span6">
            <h4><?php echo JText::_('Venue Details'); ?></h4>
            <?php if ($this->params->get('display_country',1)>0){ ?>
                <div class="control-group form-inline">
                    <label class="control-label" for="country_id"><?php echo JText::_('Country'); ?></label>
                    <div class="controls">
                        <?php echo $this->countries;?>
                    </div>
                </div>
            <?php }?>

            <?php if ($this->params->get('display_state',1)>0){ ?>
                <div class="control-group form-inline">
                    <label class="control-label" for="state_id"><?php echo JText::_('State'); ?></label>
                    <div class="controls">
                        <?php echo $this->states;?>
                    </div>
                </div>
            <?php }?>

            <?php if ($this->params->get('display_city',1)>0){ ?>
                <?php if ($this->params->get('display_state',1)>0){ ?>
                    <div class="control-group form-inline">
                        <label class="control-label" for="city_id"><?php echo JText::_('City'); ?></label>
                        <div class="controls">
                            <?php echo $this->cities;?>
                        </div>
                    </div>
                <?php }?>
            <?php }?>

            <?php if ($this->params->get('display_venue',1)>0){ ?>
                <div class="control-group form-inline">
                    <label class="control-label" for="venue_id"><?php echo JText::_('Venue'); ?></label>
                    <div class="controls">
                        <?php echo $this->venues;?>
                    </div>
                </div>
            <?php }?>

        </div> <!-- end of left side -->
    </div>

    <div class="row form-inline span11">
        <div class="span6">
            <label for="type_desc"> <?php echo JText::_('Description'); ?></label>
                <?php
                $editor = JFactory::getEditor();
                echo $editor->display('description', $this->event->description, '100%', '250', '', '20', false);
            ?>

       </div>

        <div class="span1"></div>

        <div class="span3">
            <h4><?php echo JText::_('Tickets'); ?></h4>

            <fieldset class="adminform">

                <?php
                if(file_exists(JPATH_ADMINISTRATOR.'/components/com_jlticketcenter/views/events/tmpl/form_tickets_list.php')){
                    echo $this->loadTemplate('tickets_list');
                }
                else{
                    if(!empty($this->tickets)){
                        $ticket = $this->tickets[0];
                    }else{
                        $ticket = new stdClass();
                        $ticket->ticket_type=0;
                        $ticket->ticket_desc='';
                        $ticket->ticket_price=0;
                        $ticket->tickets=0;
                        $ticket->tickets_ordered=0;
                        $ticket->tickets_sold=0;
                    }
                    ?>

                    <table class="admintable">
                        <tr>
                            <td class="key" style="width: 80px;"><label for="ticket_price"><?php echo JText::_('Ticket Price'); ?>:</label>
                            </td>
                            <td><input class="input" type="hidden"
                                       name="lines[0][ticket_type]" id="ticket_type"
                                       value="<?php echo $ticket->ticket_type;?>" /> <input
                                    class="input" type="hidden" name="lines[0][ticket_desc]"
                                    id="ticket_desc" size="10" maxlength="100"
                                    value="<?php echo $ticket->ticket_desc;?>" /> <input
                                    class="input" type="text" name="lines[0][ticket_price]"
                                    id="ticket_price" size="10" maxlength="10"
                                    value="<?php echo $ticket->ticket_price;?>" /> <?php echo $this->params->get('currency_symbol');?>
                            </td>
                        </tr>
                        <tr>
                            <td class="key" style="width: 80px;"><label for="tickets"><?php echo JText::_('Available'); ?>:</label>
                            </td>
                            <td><input class="input" type="text" name="lines[0][tickets]"
                                       id="tickets" size="10" maxlength="10"
                                       value="<?php echo $ticket->tickets;?>" />
                            </td>
                        </tr>

                        <tr>
                            <td class="key" style="width: 80px;"><label
                                    for="tickets_ordered"><?php echo JText::_('Ordered'); ?>:</label>
                            </td>
                            <td><input class="input" type="text"
                                       name="lines[0][tickets_ordered]" id="tickets_ordered"
                                       size="10" maxlength="50"
                                       value="<?php echo $ticket->tickets_ordered;?>" />
                            </td>
                        </tr>

                        <tr>
                            <td class="key" style="width: 80px;"><label for="ticktes_sold"><?php echo JText::_('Sold'); ?>:</label>
                            </td>
                            <td><input class="input" type="text"
                                       name="lines[0][ticktes_sold]" id="ticktes_sold" size="10"
                                       maxlength="50" value="<?php echo $ticket->tickets_sold;?>" />
                            </td>
                        </tr>

                        <tr>
                            <td class="key" style="width: 80px;"><label for="ticktes_avail"><?php echo JText::_('Left'); ?>:</label>
                            </td>
                            <td><?php echo $ticket->tickets - $ticket->tickets_ordered - $ticket->tickets_sold;?>
                            </td>
                        </tr>
                    </table>
                <?php }?>
            </fieldset> <?php
            if(file_exists(JPATH_ADMINISTRATOR.'/components/com_jlticketcenter/views/events/tmpl/form_tickets_pre_sale.php')){
                echo $this->loadTemplate('tickets_pre_sale');
            }

            echo $this->loadTemplate('tickets_meta_data');
            ?>

        </div>

    	<table width="100%" cellspacing="0" cellpadding="0" border="0">
			<tbody>
				<tr>
					<td valign="top">
						<fieldset class="adminform">
							<legend>
							<?php echo JText::_('Event Details'); ?>
							</legend>
							<table class="admintable" width="100%" cellspacing="0"
								cellpadding="0" border="0">
								<tr>

									</td>
								</tr>
								<tr>
									<td width="100" class="key"><label for="type_desc"> <?php echo JText::_('Short Description'); ?>:
									</label>
									</td>
									<td><textarea rows="4" cols="50" name="short_desc">
									<?php echo $this->event->short_desc;?>
										</textarea>
									</td>
								</tr>

								<tr>
									<td width="100" class="key"><label for="type_desc"> <?php echo JText::_('Event Image'); ?>:
									</label>
									</td>
									<td><input type="text" name="event_img" id="event_img"
										value="<?php echo $this->event->event_img;?>"
										readonly="readonly" />
										<div class="button2-left">
											<div class="blank">
												<a class="modal" title="Select"
													href="index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;asset=com_menus&amp;author=&amp;fieldid=event_img&amp;folder="
													rel="{handler: 'iframe', size: {x: 800, y: 500}}"> <?php echo JText::_('JLIB_FORM_BUTTON_SELECT');?>
												</a>
											</div>
										</div>
										<div class="button2-left">
											<div class="blank">
												<a title="Clear" href="#"
													onclick="document.getElementById('event_img').value=''; document.getElementById('event_img').onchange();">
													<?php echo JText::_('JLIB_FORM_BUTTON_CLEAR');?> </a>
											</div>

										</div>
									</td>
								</tr>
							</table>
						</fieldset>
					</td>
					<td width="410" valign="top">


					</td>
				</tr>
			</tbody>
		</table>

	</div>
	<div class="clr"></div>

	<input type="hidden" name="option" value="com_jlticketcenter" /> <input
		type="hidden" name="id" value="<?php echo $this->event->id;?>" /> <input
		type="hidden" name="fb_event_id"
		value="<?php echo $this->event->fb_event_id;?>" /> <input
		type="hidden" name="task" value="save" /> <input type="hidden"
		name="controller" value="events" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
<div class="clearfix"></div>

<?php JHTML::script('selection.js','administrator/components/com_jlticketcenter/views/events/');?>
