<div align="center">
	<h2 class="title text-center">Categories</h2>
</div>
<br />
<div class="wid100p">

		<!-- Middle Area Start -->
	<?php  
		if(empty($product)==false)
		{ 
		foreach($product as $ft)
		{  
		?>

		<div class="cat_item">
		  <div class="row">
			<div class="col-md-4">
			<div id="productBigimage1">
			<?php
			$pure_product_name = cleanspecialchars($ft["Product"]["pname"]);
			$url ='products/show/'.$pure_product_name.'/'.$ft["Product"]["id"];
			?>
			<a href="<?php echo $html->url('/products/show/'.$pure_product_name.'/'.$ft["Product"]["id"]); ?>">
			<?php 
			if(isset($ft["Productimages"]) && trim($ft["Productimages"]) <> '') 
			{
			   $img=explode(".",$ft["Productimages"]);
				$ext	= '.'.end(explode(".",$ft["Productimages"]));
				 if($img[0] <> '')
				  {
					echo $html->image('/img/products/'.$img[0]."_disp".$ext,array('border' => '0','title' => 'View More'));
				  }
			  }
			 else
			   {
			   echo $html->image('/img/noimages_disp.gif',array('border' => '0','title' => 'No Image'));
			   } 
			 ?>
			</a>
			</div>														
			</div>
			<div class="col-md-8">
				<div class="categorieslist">
				
					<h3><?php echo $ft["Product"]["pname"]; ?></h3>
				  
					<p><?php echo substr($ft["Product"]["descr"],0,150); ?></p>
				  
					<div class="productPrice1">
						<?php											
		//Setting the Prices & Discount for Wholesale/Retail Users
		$prod_price=0;
		$discnt_type='';
		$discnt_price=0;	
		if(isset($ft["Product"]["discount"]) && $ft["Product"]["discount"] > 0)
		{ 
		$discnt_type=$ft["Product"]["discount_type"];
		$discnt_price=$ft["Product"]["discount"];	
		}									
		if(isset($sus) && empty($sus)===false)
		{
		if($sus["usertype"]=='wholesale')
		{										 		
		if(isset($ft["Product"]["wholesale_price"]))
		$wholesale_price=$ft["Product"]["wholesale_price"];
		$utype='wholesale';
		display_price($utype,$wholesale_price,$discnt_type,$discnt_price,$curlogo);
		//echo "<br>";
		//if(isset($ft["Product"]["retail_price"]))
		//$retail_price=$ft["Product"]["retail_price"];
		//$utype='retail';
		//display_price($utype,$retail_price,$discnt_type,$discnt_price,$curlogo);
		}	
		else if($sus["usertype"]=='retail')
		{										 		
		if(isset($ft["Product"]["price"]))
		$retail_price=$ft["Product"]["price"];
		$utype='retail';
		display_price($utype,$retail_price,$discnt_type,$discnt_price,$curlogo);
		}												 									 
		}	
		else
		{  
		if(isset($ft["Product"]["price"]))
		$retail_price=$ft["Product"]["price"];
		$utype='normal';
		display_price($utype,$retail_price,$discnt_type,$discnt_price,$curlogo);
		}												  
		//Setting the Prices for Wholesale/Retail Users 	
		?>							
					</div>
				  
					<div class="pull-left">
						<?php 
							if($ft["Product"]["stock"] > 0 && $ft["Product"]["combination"]=='Y' )
							{ ?>
							<a href="<?php echo $html->url('/products/show/'.$pure_product_name.'/'.$ft["Product"]["id"]); ?>">
							<?php echo $html->image('/img/viewmore.gif',array('border' => '0','title' => 'View More')); ?>
							</a>
							<?php  }
							else if($ft["Product"]["stock"] > 0 && ($ft["Product"]["combination"]=='' || $ft["Product"]["combination"]=='N'))
							{ ?>
							<a href="<?php echo $html->url('/carts/add/'.$ft["Product"]["id"]."/".$ft["Product"]["category_id"]); ?>">
							<?php echo $html->image('/img/addtocart.gif',array('border' =>'0','title' => 'Add to Cart')); ?>
							</a> 
							<?php }
						  ?>
					</div>
				</div>
		  </div>
		</div>
		</div>
		<?php }  ?>
		<div class="result" >
		<?php
		if($pagination->setPaging($paging)):
		$leftArrow = "<";//$html->image("nav/arrowleft.gif", Array('height'=>15));
		$rightArrow = ">";//$html->image("nav/arrowright.gif", Array('height'=>15));
		
		$prev = $pagination->prevPage($leftArrow,false);
		$prev = $prev?$prev:$leftArrow;
		$next = $pagination->nextPage($rightArrow,false);
		$next = $next?$next:$rightArrow;
		
		$pages = $pagination->pageNumbers(" | ");
		
		echo $pagination->result();
		echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		echo $prev." ".$pages." ".$next;
		echo "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";
		echo "Results per page : ";
		echo $pagination->resultsPerPage(NULL, ' ');
		endif;
		?>
		<?php } else { ?>		
		<br />
		<strong>No Search results Found.</strong>
		<?php } ?>
		</div>														
														
		<!-- Middle Area End -->									
												
		
		
		
		</div>
		 <?php
		//Function to display price for Wholesale and Retail Users
		function display_price($utype='',$prod_price='',$discnt_type='',$discnt_price='',$curlogo='')
		{										
			   if($utype=='wholesale')
			   echo "<b>Price:</b>";
			   else if($utype=='retail')
			   echo "<b>Price:</b>";
			   else if($utype=='normal')
			   echo "<b>Price:</b>";

			   if(isset($discnt_type) && $discnt_type <> '')
				{ 
					if($discnt_type=='per')
					{
						if(isset($discnt_price) && $discnt_price <> '' && $discnt_price > 0)
						{
						$discounted_price=($prod_price-(($prod_price * $discnt_price)/100));
						echo "<strike>".$curlogo.number_format($prod_price,2)."</strike>&nbsp;&nbsp;".$curlogo.number_format($discounted_price,2);								 
						}		
						else
						echo $curlogo.number_format($prod_price,2);											 
					}
					else if($discnt_type=='amnt')
					{	 
						if(isset($discnt_price) && $discnt_price <> '' && $discnt_price > 0)
						{
						$discounted_price=($prod_price-$discnt_price);
						echo "<strike>".$curlogo.number_format($prod_price,2)."</strike>&nbsp;&nbsp;".$curlogo.number_format($discounted_price,2);								 
						}		
						else
						echo $curlogo.number_format($prod_price,2);		
					}
				}
				else
				{
				echo $curlogo.number_format($prod_price,2);		
				}							
		}
		
		function cleanspecialchars($text)
		{
			$code_entities_match = array(' 
','--','&quot;','!','@','#','$','%','^','&','*','(',')','_','+','{','}','|',':','"','<','>','?','[',']','\\',';',"'",',','.','/','*','+','~','`','=');
			$code_entities_replace =
			array('-','-','','','','','','','','','','','','','','','','','','','','','','','','');
			$text = str_replace($code_entities_match, $code_entities_replace, $text);
			return $text;
		}
      ?>