<h3>Ticket System | <small>Administration</small></h3>
<a href="<?php echo adminurl('ticketsystem/open');?>"> View All <b>Open</b> Tickets</a> | <a href="<?php echo adminurl('ticketsystem/assigned');?>"> View All <b>Open</b> Tickets <b>Assigned To Me</b></a>
<table id="tabledlist" class="tablesorter">
	<thead>
		<tr>
			<th>#</th>
			<th>Title</th>
			<th>Opened by</th>
			<th>Created at</th>
			<th>Last Updated at</th>
			<th>Priority</th>
			<th>Status</th>
			<th>Assigned to</th>
			<th>Actions</th>
		</tr>
	</thead>
	<tbody>
		<?php
		if($tickets) foreach($tickets as $ticket) {
		?>
		<tr>
			<td><?php echo $ticket->id;?></td>
			<td><?php echo $ticket->title;?></td>
			<td><a href="<?php echo adminurl('pilotadmin/viewpilots?action=viewoptions&pilotid='.$ticket->creator);?>"><?php echo $ticket->firstname. ' '.$ticket->lastname;?></a></td>
			<td><?php echo $ticket->created_at;?></td>
			<td><?php echo $ticket->updated_at;?></td>
			<td>
				<?php if($ticket->priority == 1) echo '<span style="color:blue">Low</span>';?>
				<?php if($ticket->priority == 2) echo '<span style="color:orange">Medium</span>';?>
				<?php if($ticket->priority == 3) echo '<span style="color:red">High</span>';?>
			</td>
			<td>
				<?php if($ticket->status == 1) echo '<span style="color:red">Unsolved</span>';?>
				<?php if($ticket->status == 2) echo '<span style="color:orange">Pending User Action</span>';?>
				<?php if($ticket->status == 3) echo '<span style="color:green">Solved</span>';?>
			</td>
			<td><?php if($ticket->assigned_to != 0) { ?>
				<a href="<?php echo adminurl('pilotadmin/viewpilots?action=viewoptions&pilotid='.$ticket->assigned_to);?>">
					<?php echo $ticket->asig_fn. ' '.$ticket->asig_ln; ?>
				</a>
				<?php } else echo 'Not assigned yet.';?></td>
			<td>
				<?php if($ticket->status != 3) { ?>
					<a href="<?php echo adminurl('ticketsystem/close/'.$ticket->id);?>">Close</a>
				<?php } else { ?>
					<a href="<?php echo adminurl('ticketsystem/reopen/'.$ticket->id);?>">Reopen</a>
				<?php } ?>
				<a id="dialog" class="jqModal" href="<?php echo SITE_URL;?>/admin/action.php/ticketsystem/comment/<?php echo $ticket->id;?>">Comment</a>

				<a id="dialog" class="jqModal" href="<?php echo SITE_URL;?>/admin/action.php/ticketsystem/assign/<?php echo $ticket->id;?>">Assign</a>
				<a id="dialog" class="jqModal" href="<?php echo SITE_URL;?>/admin/action.php/ticketsystem/edit/<?php echo $ticket->id;?>">Edit</a>
			</td>
		</tr>
		<?php } ?>
	</tbody>
</table>
