<?php
/**
 * @version $Id$
 * @package    Contact_Enhanced
 * @subpackage Views
 * @author     Douglas Machado {@link http://ideal.fok.com.br}
 * @author     Created on 28-Jul-09
 * @license		GNU/GPL, see license.txt
 * Contact Enhanced  is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 */

//--No direct access
defined('_JEXEC') or die('Direct Access NOT Allowed. Please try to access the main page');

JHTML::_('behavior.tooltip');

?>
<form action="index.php" method="post" name="adminForm">
<div style="float:left"><table>
	<tr>
		<td align="left" width="100%">
			<?php echo JText::_( 'Filter' ); ?>:
			<input type="text" name="search" id="search" value="<?php echo $this->lists['search'];?>" class="text_area" onchange="document.adminForm.submit();" />
			<button onclick="this.form.submit();"><?php echo JText::_( 'Go' ); ?></button>
			<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_category').value='';this.form.getElementById('filter_type').value='';this.form.submit();"><?php echo JText::_( 'Reset' ); ?></button>
		</td>
		<td nowrap="nowrap">
			<?php echo $this->lists['filter_type']; ?>
			<?php echo $this->lists['filter_category']; ?>
		</td>
	</tr>
</table>
</div>
<div style="float:right;font-weight:bold"><?php echo JText::_('CUSTOM_VALUES_DESCRIPTION'); ?></div>
<br style="clear:both" />
<div id="tablecell">
	<table class="adminlist">
	<thead>
		<tr>
			<th width="1%">
				<?php echo JText::_( 'NUM' ); ?>
			</th>
			<th width="1%">
				<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
			</th>
			<?php ?>	
			<th>
				<?php echo JHTML::_('grid.sort', 'text', 'text', $this->lists['order_Dir'], $this->lists['order']);?>
			</th>
			<th>
				<?php echo JHTML::_('grid.sort', 'value', 'value', $this->lists['order_Dir'], $this->lists['order']);?>
			</th>
			<th>
				<?php echo JHTML::_('grid.sort', 'description', 'description', $this->lists['order_Dir'], $this->lists['order']);?>
			</th>
			<th width="10%">
				<?php echo JHTML::_('grid.sort', 'ordering', 'ordering', $this->lists['order_Dir'], $this->lists['order']);?>
				<?php echo JHTML::_('grid.order',  $this->items ); ?>
			</th>
			<th>
				<?php echo JHTML::_('grid.sort', 'category', 'category', $this->lists['order_Dir'], $this->lists['order']);?>
			</th>
			<th>
				<?php echo JHTML::_('grid.sort', 'type', 'type', $this->lists['order_Dir'], $this->lists['order']);?>
			</th>
			<th width="3%">
				<?php echo JHTML::_('grid.sort', 'published', 'published', $this->lists['order_Dir'], $this->lists['order']);?>
			</th>
			<th width="1%">
				<?php echo JHTML::_('grid.sort', 'id', 'id', $this->lists['order_Dir'], $this->lists['order']);?>
			</th>
	<?php 
 ?>
		</tr>
	</thead>
	
	<tbody>
	<?php
	$k = 0;
	for ($i=0, $n=count( $this->items ); $i < $n; $i++)
	{
		$row = &$this->items[$i];
		$link = JRoute::_( 'index.php?option=com_contact_enhanced&controller=customvalues&task=edit&cid[]='. $row->id);
		$ordering = true;
		$checked 	= JHTML::_('grid.id',  $i, $row->id );

		$published 	= JHTML::_('grid.published', $row, $i );
	?>
		<tr class="<?php echo "row$k"; ?>">
			<td align="center">
				<span class="editlinktip hasTip" title="<?php echo JText::_('Edit'); ?>">
					<a href="<?php echo $link; ?>">
						<?php echo $this->pagination->getRowOffset($i); ?>
					</a>
				</span>
			</td>
			<td align="center">
				<?php echo $checked; ?>
			</td>
			<td>
				<span class="editlinktip hasTip" title="<?php echo JText::_('Edit'); ?>">
					<?php echo JHTML::_('link',  $link, $row->text ); ?>
				</span>
			</td>
			<td>
				<?php echo $row->value; ?>
			</td>
			<td>
				<?php echo $row->description; ?>
			</td>

			<td class="order">
				<span><?php echo $this->pagination->orderUpIcon( $i, ( $row->category == @$this->items[$i-1]->category ), 'orderup', 'Move Up', $ordering ); ?></span>
				<span><?php echo $this->pagination->orderDownIcon( $i, $n, ( $row->category == @$this->items[$i+1]->category ), 'orderdown', 'Move Down', $ordering ); ?></span>
				<?php $disabled = $ordering ?  '' : 'disabled="disabled"'; ?>
				<input type="text" name="order[]" size="5" value="<?php echo $row->ordering;?>" <?php echo $disabled ?> class="text_area" style="text-align: center" />
			</td>
			<td align="center">
				<?php echo $row->category; ?>
			</td>
			<td align="center">
				<?php echo $row->type; ?>
			</td>
			<td align="center">
				<?php echo $published ?>
			</td>
			<td align="center">
				<?php echo $row->id; ?>
			</td>
			
	<?php 
 ?>
			
		</tr>
		<?php
			$k = 1 - $k;
		}
		?>
	</tbody>
    <tfoot>
    <tr>
      <td colspan="11"><?php echo $this->pagination->getListFooter(); ?></td>
    </tr>
  </tfoot>
	</table>
</div>
	<input type="hidden" name="option" value="com_contact_enhanced" />
	<input type="hidden" name="task" value="" />
	<input type="hidden" name="boxchecked" value="0" />
	<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
	<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
	<input type="hidden" name="controller" value="customvalues" />
	<input type="hidden" name="view" value="customvalues" />
	<?php echo JHTML::_( 'form.token' ); ?>
</form>
