<?php
/**
* @version 1.0.0
* @package RStickets! 1.0.0
* @copyright (C) 2007-2008 www.rsjoomla.com
* @license GPL, http://www.gnu.org/copyleft/gpl.html
*/

// DIE()
defined('_JEXEC') or die('Restricted access');

if (!rst_is_logged()) rst_redirect('index.php?option=com_rstickets');

if ($_GET['page'] == 'my_searches') { $search = 'my_searches'; $redirect = 'my_tickets'; }
if ($_GET['page'] == 'searches') { $search = 'searches'; $redirect = 'tickets'; }
?>
<h4 class="rst_h4"><?php echo LBL_MANAGE_SEARCHES; ?></h4>

<a href="<?php echo JRoute::_('index.php?option=com_rstickets&page='.$redirect); ?>" class="backButton"><?php echo BTN_BACK; ?></a>

<table cellspacing="0" cellpadding="4" class="tableGrey wide">
<thead>
<tr class="tableHead">
	<td class="tdGrey"><?php echo $search == 'searches' ? LBL_PREDEFINED_SEARCH_TICKETS : LBL_PREDEFINED_SEARCH_MY_TICKETS; ?></td>
	<td class="tdGrey"><?php echo LBL_DEFAULT_SEARCH; ?></td>
	<td><?php echo LBL_ACTIONS; ?></td>
</tr>
</thead>
<tbody>
	<?php
	$tickets_searches = rst_get_searches($redirect,$_SESSION['RST_User']['UserId'],true);
	if (count($tickets_searches) > 0)
		foreach ($tickets_searches as $tickets_search)
		{
	?>
	<tr>
		<td class="tdGrey"><a href="<?php echo JRoute::_('index.php?option=com_rstickets&page'.($search == 'searches' ? 'save_search_tickets' : 'save_search_my_tickets').'&id='.$tickets_search['SearchId']); ?>"><?php echo $tickets_search['SearchName']; ?></a></td>
		<td class="tdGrey"><?php echo $tickets_search['SearchDefault'] == 1 ? LBL_YES : LBL_NO; ?></td>
		<td><a href="<?php echo JRoute::_('index.php?option=com_rstickets&page='.($search == 'searches' ? 'save_search_tickets' : 'save_search_my_tickets').'&id='.$tickets_search['SearchId']); ?>" class="editButton"><?php echo BTN_EDIT; ?></a> <a onclick="return confirm('<?php echo LBL_SURE; ?>')" href="<?php echo JRoute::_('index.php?option=com_rstickets&page='.$search.'&action=delete_search&id='.$tickets_search['SearchId']); ?>" class="deleteButton"><?php echo BTN_DELETE; ?></a></td>
	</tr>
	<?php
		}
	else
	{
	?>
	<tr>
		<td colspan="3"><?php echo LBL_NO_PREDEFINED_SEARCHES; ?></td>
	</tr>
	<?php
	}
	?>
</tbody>
</table>