<?php 
defined('_JEXEC') or die('Restricted access');

$this->setLayout('listing_price');
$this->params->set('show_quantity_field', -1);
$desc = $this->params->get('comp_description');
if(empty($desc)){
	$this->params->set('comp_description',JText::_('CART_EMPTY'));
}
if(JRequest::getWord('tmpl','')=='component'){
	header( 'Cache-Control: no-store, no-cache, must-revalidate' );
	header( 'Cache-Control: post-check=0, pre-check=0', false );
	header( 'Pragma: no-cache' );
}

if(JRequest::getVar('option','')=='com_hikashop' && JRequest::getVar('ctrl')=='checkout'){ 
 // display nothing on the checkout 
}else{
 // display the normal cart page 
 
?>
<div id="hikashop_cart" class="hikashop_cart">
	<?php 
	if(empty($this->rows)){
		echo $this->params->get('comp_description');
	}else{
	$row_count = 1;
	global $Itemid;
	$url_itemid='';
	if(!empty($Itemid)){
		$url_itemid='&Itemid='.$Itemid;
	}
	?>
	<form action="<?php echo hikashop::completeLink('product&task=updatecart'.$url_itemid,false,true); ?>" method="post" name="hikashop_cart_form">
		<table width="100%">
			<thead>
				<tr>
					<th class="hikashop_cart_title">
						<?php echo JText::_('CART_PRODUCT_NAME'); ?>
					</th>
					<?php if($this->params->get('show_cart_quantity',1)){
						$row_count++; ?>
						<th class="hikashop_cart_title">
							<?php echo JText::_('CART_PRODUCT_QUANTITY'); ?>
						</th>
					<?php }
					if($this->params->get('show_cart_price',1)){
						$row_count++; ?>
					<th class="hikashop_cart_title">
						<?php echo JText::_('CART_PRODUCT_PRICE'); ?>
					</th>
					<?php }
					if($this->params->get('show_cart_delete',1)){
						$row_count++; ?>
					<th class="hikashop_cart_title">
					</th>
					<?php }
					if($row_count<2){ ?>
					<th></th>
					<?php }?>
				</tr>
			</thead>
			<tbody>
				<?php 
					$k = 0;
					
					foreach($this->rows as $i => $row){
						if(empty($row->cart_product_quantity)) continue;
						?>
						<tr class="<?php echo "row$k"; ?>">
							<td>
								<a href="<?php echo hikashop::completeLink('product&task=show&cid='.$row->product_id.$url_itemid);?>" ><?php echo $row->product_name; ?></a>
							</td>
							<?php if($this->params->get('show_cart_quantity',1)){ ?>
							<td>
								<input id="hikashop_cart_quantity_<?php echo $row->product_id;?>" type="text" name="data[<?php echo $row->product_id;?>]" class="hikashop_product_quantity_field" value="<?php echo $row->cart_product_quantity; ?>" onchange="return hikashopModifyQuantity(<?php echo $row->product_id;?>,this)" />
							</td>
							<?php }
							if($this->params->get('show_cart_price',1)){ ?>
							<td>
								<?php 
								$this->row=&$row;
								$this->cart_product_price = true;
								echo $this->loadTemplate();
								?>
							</td>
							<?php }
							if($this->params->get('show_cart_delete',1)){ ?>
							<td>
								<a href="<?php echo hikashop::completeLink('product&task=updatecart&product_id='.$row->product_id.'&quantity=0&url='.$this->params->get('url')); ?>" onclick="var qty_field = document.getElementById('hikashop_cart_quantity_<?php echo $row->product_id;?>'); qty_field.value=0; return hikashopModifyQuantity(<?php echo $row->product_id;?>,qty_field);" ><img src="<?php echo HIKASHOP_IMAGES . 'delete2.png';?>" border="0" alt="remove product" /></a>
							</td>
							<?php }
							if($row_count<2){ ?>
							<td></td>
							<?php }?>
						</tr>
						<?php 
						$k = 1-$k;
					}
				?>
			</tbody>
			<?php if($this->params->get('show_cart_price',1)){ ?>
			<tfoot>
				<tr>
					<td colspan="<?php echo $row_count;?>">
						<hr></hr>
					</td>
				</tr>
				<tr>
					<?php if($this->params->get('show_cart_quantity',1)){ ?>
						<td>
						</td>
					<?php }?>
					<td>
						<?php echo JText::_('HIKASHOP_TOTAL'); ?>
					</td>
					<td>
					<?php 
						$this->row=$this->total;
						echo $this->loadTemplate();
					?>
					</td>
					<?php if($this->params->get('show_cart_delete',1)){ ?>
						<td>
						</td>
					<?php }?>
				</tr>
			</tfoot>
			<?php } ?>
		</table>
			<?php  
			if($this->params->get('show_cart_quantity',1)){ ?>
				<noscript>
					<input type="submit" class="button" name="refresh" value="<?php echo JText::_('REFRESH_CART');?>"/>
				</noscript>
			<?php }
		if($this->params->get('show_cart_proceed',1)){ 
			echo $this->cart->displayButton(JText::_('PROCEED_TO_CHECKOUT'),'checkout',$this->params,hikashop::completeLink('checkout'.$url_itemid),'');
		} ?>
		<input type="hidden" name="url" value="<?php echo $this->params->get('url');?>"/>
		<input type="hidden" name="ctrl" value="product"/>
		<input type="hidden" name="task" value="updatecart"/>
	</form>
	<?php } ?>
</div>
<div class="clear_both"></div>
<?php 
}
if(JRequest::getWord('tmpl','')=='component'){
	exit;
}