<?php
/**
 * This is a core PHP file. For customization, create a file in the folder /custom/.
 * Files with the same filename in this folder will automatically be loaded instead of the current file
 */
?>
<form id="form-ticket" method="post" action="<?php echo  __SITE_URL . '/' . __('ticket', 'url') . '/' . __('create', 'url'); ?>" enctype="multipart/form-data">

	<div class="form-group">
		<label><?php echo __('subject'); ?></label>
		<input class="form-control" name="Subject" value="<?php if(isset($ticket->Subject)){ echo normalize($ticket->Subject); } ?>"/>
	</div>


	<div class="form-group">
		<label><?php echo __('ticket message'); ?></label>
		<textarea class="form-control autogrow height1" name="Message"><?php if(isset($ticketmessage->Message)){ echo normalize($ticketmessage->Message); } ?></textarea>
	</div>

	<a href="#" data-event="add-attachment"><span class="fas fa-plus"></span> <?php echo __('add attachment'); ?></a>

	<div class="form-group row">
		<div class="col-sm-12 m-t-1">
			<?php
			// Only show back button when we are not on index page
			if(isset($ticket))
			{
				?>
				<a href="<?php echo __SITE_URL . '/' . __('ticket', 'url'); ?>" class="btn btn-secondary pull-xs-left">
					<span class="fas fa-arrow-left"></span>
					&nbsp;
					<?php echo __('back'); ?>
				</a>
				<?php
			}
			?>
			<button type="submit" class="btn btn-primary pull-xs-right"><?php echo __('create ticket'); ?></button>
		</div>
	</div>

</form>

<?php
if(isset($ticket->ErrorFields))
{
	validate_input($ticket->ErrorFields);
}
if(isset($ticketmessage->ErrorFields))
{
	validate_input($ticketmessage->ErrorFields);
}
?>

<?php
$this->showElement('ticket.js');
?>
