<?php
/**
 * JE GroupBuy package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2011 - 2012 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/

// No direct access to this file
defined('_JEXEC') or die('Restricted Access');
$listOrder	= $this->state->get('list.ordering');
$listDirn	= $this->state->get('list.direction');
$canOrder	= $this->user->authorise('core.edit.state', 'com_jegroupbuy.products');
$saveOrder	= $listOrder == 'p.ordering';
$n = count($this->items);
?>
<?php  foreach($this->items as $i => $item): ?>
<?php
				$saveOrder	= $listOrder == 'p.ordering';
				$ordering	= $listOrder == 'p.ordering';
				$canCreate	= $this->user->authorise('core.create',		'com_jegroupbuy.category.'.$item->catid);
				$canEdit	= $this->user->authorise('core.edit',		'com_jegroupbuy.category.'.$item->catid);
				$canEditOwn	= $this->user->authorise('core.edit.own',	'com_jegroupbuy.category.'.$item->catid);
				$canChange	= $this->user->authorise('core.edit.state',	'com_jegroupbuy.category.'.$item->catid);
?>
        <tr class="row<?php echo $i % 2; ?>">
        	<td class="order nowrap center hidden-phone">
				<?php if ($canChange) :
					$disableClassName = '';
					$disabledLabel	  = '';

					if (!$saveOrder) :
						$disabledLabel    = JText::_('JORDERINGDISABLED');
						$disableClassName = 'inactive tip-top';
					endif; ?>
					<span class="sortable-handler hasTooltip <?php echo $disableClassName?>" title="<?php echo $disabledLabel?>">
						<i class="icon-menu"></i>
					</span>
					<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $item->ordering;?>" class="width-20 text-area-order " />
				<?php else : ?>
					<span class="sortable-handler inactive" >
						<i class="icon-menu"></i>
					</span>
				<?php endif; ?>
			</td>
            <td class="center hidden-phone">
                 <?php echo JHtml::_('grid.id', $i, $item->id); ?>
            </td>
			<td>
				<?php if ($canEdit || $canEditOwn) : ?>
					<a href="<?php echo JRoute::_('index.php?option=com_jegroupbuy&task=product.edit&id='.(int) $item->id); ?>">
						<?php echo $this->escape($item->title); ?></a>
				<?php else : ?>
					<?php echo $this->escape($item->title); ?>
				<?php endif; ?>
				<p class="smallsub">
					<?php echo JText::sprintf('JGLOBAL_LIST_ALIAS', $this->escape($item->alias));?></p>
			</td>
   			<td class="center">
				<?php echo $this->escape($item->shop_name); ?>
			</td>
   			<td class="center">
				<?php echo $this->escape($item->category_title); ?>
			</td>
   			<td class="center">
				<?php echo $this->escape($item->deal_price); ?>
			</td>
            <td class="center">
				<?php echo JHtml::_('jgrid.published', $item->published, $i, 'products.', $canChange, 'cb'); ?>
            </td>
			<td class="center">
				<?php echo JHtml::_('product.featured', $item->featured, $i, $canChange); ?>
			</td>
			<td align="center">
				<?php echo $item->access_level; ?>
			</td>
			<td class="center">
				<?php if ($item->language=='*'):?>
					<?php echo JText::alt('JALL','language'); ?>
				<?php else:?>
					<?php echo $item->language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?>
				<?php endif;?>
			</td>
            <td>
               <?php echo $item->id; ?>
            </td>
        </tr>
<?php endforeach;  ?>
