<?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.orders');
$saveOrder	= $listOrder == 'ord.ordering';
$n = count($this->items);
?>
<?php  foreach($this->items as $i => $item): ?>
<?php
				$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->id); ?>
                </td>
				<td>
					<?php if ($canEdit || $canEditOwn) : ?>
						<a href="<?php echo JRoute::_('index.php?option=com_jegroupbuy&task=order.edit&id='.(int) $item->id); ?>">
							<?php echo $this->escape($item->title); ?></a>
					<?php else : ?>
						<?php echo $this->escape($item->title); ?>
					<?php endif; ?>
				</td>
				<td class="center">
					<?php echo $this->escape($item->shopname); ?>
				</td>
       			<td class="center">
					<?php echo $this->escape($item->method); ?>
				</td>
       			<td class="center">
					<?php echo $this->escape($item->transaction_id); ?>
				</td>
                <td class="center">
					<?php
						// echo JHtml::_('jgrid.published', $item->status, $i, 'orders.', $canChange, 'cb');

						//if()

						if($item->status == 1)
							$change_stat = 'orders.unstatus';
						else
							$change_stat = 'orders.status';
					?>

					<a class="jgrid" title="<?php if($item->status == 1) { echo "Publish"; } else { echo "Unpublish"; } ?> Item" onclick="return listItemTask('cb<?php echo $item->id; ?>','<?php echo $change_stat ?>')" href="javascript:void(0);">
						<span class="state <?php if($item->status == 1) { echo "publish"; } else { echo "unpublish"; } ?>"></span>
					</a>


                </td>
                <td class="center">
					<?php
					$user = JFactory::getUser($item->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->id); ?>"><?php echo JText::_( 'JE_SENDMAIL' ); ?>
					</a>
				</td>
        </tr>
<?php endforeach;  ?>
