<?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>
                        <?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 class="order">
						<?php if ($canChange) : ?>
							<?php if ($saveOrder) :?>
								<?php if ($listDirn == 'asc') : ?>
									<span>
										<?php  echo $this->pagination->orderUpIcon($i, ($item->catid == @$this->items[$i-1]->catid),'products.orderup', 'JLIB_HTML_MOVE_UP', $ordering); ?>
									</span>
									<span>
										<?php echo $this->pagination->orderDownIcon($i, $n, ($item->catid == @$this->items[$i+1]->catid), 'products.orderdown', 'JLIB_HTML_MOVE_DOWN', $ordering); ?>
									</span>
								<?php elseif ($listDirn == 'desc') : ?>
									<span>
										<?php echo $this->pagination->orderUpIcon($i, ($item->catid == @$this->items[$i-1]->catid),'products.orderdown', 'JLIB_HTML_MOVE_UP', $ordering); ?>
									</span>
									<span>
										<?php echo $this->pagination->orderDownIcon($i, $n, ($item->catid == @$this->items[$i+1]->catid), 'products.orderup', 'JLIB_HTML_MOVE_DOWN', $ordering); ?>
									</span>
								<?php endif; ?>
							<?php endif; ?>
							<?php $disabled = $saveOrder ?  '' : 'disabled="disabled"'; ?>
							<input type="text" name="order[]" size="5" value="<?php echo $item->ordering;?>" <?php echo $disabled ?> class="text-area-order" />
						<?php else : ?>
							<?php echo $item->ordering; ?>
						<?php endif; ?>
					</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;  ?>
