<?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');

// Joomla predefined function for modal
	JHTML::_('behavior.modal');

$listOrder	= $this->state->get('list.ordering');
$listDirn	= $this->state->get('list.direction');
$canOrder	= $this->user->authorise('core.edit.state', 'com_jegroupbuy.orders');
$saveOrder	= $listOrder == 'ord.ordering';
$n = count($this->items);
?>
<?php  //foreach($this->items as $i => $item): ?>
<?php
for($i=0,$item=$this->items;$i<$n;$i++){

	$saveOrder	= $listOrder == 'ord.ordering';
	$ordering	= $listOrder == 'ord.ordering';
	$canCreate	= $this->user->authorise('core.create',		'com_jegroupbuy');
	$canEdit	= $this->user->authorise('core.edit',		'com_jegroupbuy');
	$canEditOwn	= $this->user->authorise('core.edit.own',	'com_jegroupbuy');
	$canChange	= $this->user->authorise('core.edit.state',	'com_jegroupbuy');
?>
		<tr class="row<?php echo $i % 2; ?>">
            <td>
                <?php
               echo JHtml::_('grid.id', $i, $item[$i]->id); ?>
            </td>
			<td>
				<?php if ($canEdit || $canEditOwn) : ?>
					<a href="<?php echo JRoute::_('index.php?option=com_jegroupbuy&task=order.edit&id='.(int) $item[$i]->id); ?>">
						<?php echo $this->escape($item[$i]->title); ?></a>
				<?php else : ?>
					<?php echo $this->escape($item[$i]->title); ?>
				<?php endif; ?>
			</td>
			<td class="center">
				<?php echo $this->escape($item[$i]->shopname); ?>
			</td>
			<td class="center">
				<?php echo $this->escape($item[$i]->quantity); ?>
			</td>
   			<td class="center">
				<?php echo $this->escape($item[$i]->method); ?>
			</td>
   			<td class="center">
				<?php echo $this->escape($item[$i]->transaction_id); ?>
			</td>
            <td class="center">
				<?php
					if($item[$i]->status == 1)
						$change_stat = 'orders.unstatus';
					else
						$change_stat = 'orders.status';
				?>
				<a class="jgrid" title="<?php if($item[$i]->status == 1) { echo "Publish"; } else { echo "Unpublish"; } ?> Item" onclick="return listItemTask('cb<?php echo $item[$i]->id; ?>','<?php echo $change_stat ?>')" href="javascript:void(0);">
					<span class="state <?php if($item[$i]->status == 1) { echo "publish"; } else { echo "unpublish"; } ?>"></span>
				</a>
            </td>
            <td class="center">
				<?php
					$user = JFactory::getUser($item[$i]->user_id);
					echo $this->escape($user->username);
				?>
            </td>
			<td class="center">
				<a href="<?php echo JRoute::_('index.php?option=com_jegroupbuy&view=orders&task=orders.resendmail&id='.(int) $item[$i]->id); ?>"><?php echo JText::_( 'JE_SENDMAIL' ); ?></a>
			</td>
			<td class="center">
				<a rel='{handler: "iframe",size:{x:560,y:365}}' class="modal" style="overflow-y:auto !important;" href="<?php echo JRoute::_('index.php?option=com_jegroupbuy&view=orders&layout=orderpopup&task=orders.transdetails&tmpl=component&transid='.$item[$i]->transaction_id); ?>"><?php echo JText::_( 'View Transaction' ); ?></a>
			</td>
        </tr>
<?php }  ?>
