<?php
/**
 * jeGroupBuy package
 * @author J-Extension <contact@jextn.com>
 * @link http://www.jextn.com
 * @copyright (C) 2010 - 2011 J-Extension
 * @license GNU/GPL, see LICENSE.php for full license.
**/
defined('_JEXEC') or die('Restricted access');
$lists = $this->lists;
//Ordering allowed ?
$ordering = ($lists['order'] == 'p.ordering');
?>
<script language="javascript">
function deleteAction(id,status)
{
	document.adminForm.task.value = "deleteInvoice";
	document.adminForm.id.value = id;
	if (confirm ("<?php echo JText::_( 'CC_DELETE_CONFIRM_MSG1' ); ?> "+status+"<?php echo JText::_( 'CC_DELETE_CONFIRM_MSG2' ); ?>"))
	{
		document.adminForm.submit();
		document.adminForm.task.value = '';
	}

}
</script>
<form action="index.php" method="post" name="adminForm">
<table>
<tr>
	<td align="left" width="100%">
		<?php echo JText::_( 'JEGROUPBUY_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::_( 'JEGROUPBUY_GO' ); ?></button>
		<button onclick="document.getElementById('search').value='';this.form.getElementById('filter_state').value='';this.form.submit();"><?php echo JText::_( 'JEGROUPBUY_FILTERRESET' ); ?></button>
	</td>
	<td nowrap="nowrap">
		<?php
		echo $this->lists['state'];
		?>
	</td>
</tr>
</table>
<table class="adminlist">
<thead>
	<tr>
		<th width="1%" align="center">
			<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count( $this->items ); ?>);" />
		</th>
		<th  nowrap="nowrap" align="center">
			<?php echo JHTML::_('grid.sort', JText::_( 'JE_GROUPBUY_PRODUCT_NAME' ), 'p.title', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
		</th>
		<th width="15%" nowrap="nowrap" align="center">
			<?php echo JHTML::_('grid.sort', JText::_( 'Shop Name' ), '', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
		</th>
		<th width="15%" nowrap="nowrap" align="center">
			<?php echo JHTML::_('grid.sort', JText::_( 'JE_GROUPBUY_PAYMENT_TYPE' ), 'o.method', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
		</th>
		<th width="15%" nowrap="nowrap" align="center">
			<?php echo JHTML::_('grid.sort', JText::_( 'JE_GROUPBUY_TRANSACTION_ID' ), 'o.transaction_id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
		</th>
		<th width="7%" align="center">
			<?php echo JHTML::_('grid.sort',  JText::_( 'JE_GROUPBUY_PUBLISHED' ), 'o.published', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
		</th>
		<th width="7%" align="center">
			<?php echo JHTML::_('grid.sort',   JText::_( 'JE_USER_ID' ), 'o.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
		</th>
		<th width="10%" align="center">
			<?php echo JHTML::_('grid.sort',   JText::_( 'JE_SEND' ), '', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
		</th>
	</tr>
</thead>
<tfoot>
	<tr>
		<td colspan="9">
			<?php  echo $this->pageNav->getListFooter(); ?>
		</td>
	</tr>
</tfoot>
<?php
$params = array('size'=>array('x'=>100, 'y'=>100));
JHTML::_('behavior.modal', 'a.modal', $params);
$k = 0;
for ($i=0, $n=count( $this->items ); $i < $n; $i++)
{
	$row = &$this->items[$i];
	$checked 	= JHTML::_('grid.id',   $i, $row->id );
	$row->published = $row->status;
	$published		= JHTML::_('grid.published', $row, $i );
	$link 		= JRoute::_( 'index.php?option=com_jegroupbuy&controller=stores&task=edit&cid[]='. $row->id );
	?>
	<tr class="<?php echo "row$k"; ?>">
		<td align="center">
			<?php echo $checked; ?>
		</td>
		<td align="left">
			<a href="<?php echo $link; ?>"><?php echo $row->title; ?></a>
		</td>
		<td align="center">
			<?php echo $row->shop_name; ?>
		</td>
		<td align="center">
			<?php echo $row->method; ?>
		</td>
		<td align="center">
			<?php echo $row->transaction_id; ?>
		</td>
		<td align="center">
			<?php echo $published; ?>
		</td>
		<td align="center">
			<?php
			$user = JFactory::getUser($row->user_id);
			echo $user->username; ?>
		</td>
		<td align="center">
           	<a href="<?php echo JRoute::_('index.php?option=com_jegroupbuy&controller=orders&task=resendmail&id='.(int) $row->id); ?>"><?php echo JText::_( 'JE_SENDMAIL' ); ?></a>
		</td>
	</tr>
	<?php
	$k = 1 - $k;
}
?>
</table>
<input type="hidden" name="option" value="com_jegroupbuy" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="controller" value="orders" />
<input type="hidden" name="boxchecked" value="0" />

<input type="hidden" name="clientid" value="<?php echo $this->clientid; ?>" />
<input type="hidden" name="id" 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']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>
<p class="copyright" align="center">
	<?php require_once( JPATH_COMPONENT . DS . 'copyright' . DS . 'copyright.php' ); ?>
</p>