<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: 			*/
// +----------------------------------------------------------------------+
// | PHP version 4/5                                                      |
// +----------------------------------------------------------------------+
// | Copyright (c) 2004-2010 ARMIA INC                                    |
// +----------------------------------------------------------------------+
// | This source file is a part of iScripts VistaCart                     |
// +----------------------------------------------------------------------+
// | Authors: Jipson<jipson.thomas@armiasystems.com>             		  |
?>
<?php echo $html->css('tooltip.css'); ?>
<?php echo $javascript->link('jquery.js'); ?>
<?php echo $javascript->link('hint.js'); ?> 
<?php echo $javascript->link('tooltip.js'); ?>
<script language="JavaScript" type="text/JavaScript">
function clickSearch()
{
	document.frmUsers.submit();
}
</script>

<div align="center" class="subheading">
              <div align="left">Products</div>
            </div>
            <br />
			<?php if($session->check('Message.flash')) { ?><div id="okbox"><font color="#446423"><?php $session->flash(); ?></font></div><?php } ?>		
			
			<div align="left" id="item_details_admin">				
					<!--items search area start -->
					<form action="<?php echo $sitebase.$sitefolder.'/'.$this->params["controller"];?>" method="get" name="frmUsers">
					   <div>					   
					   <div style="float:left ">
									<select name="cmbSearchType"  class="box2_admin">
										<option value="name"  <?php if($cmbSearchType == "name" || $cmbSearchType == ""){ echo("selected"); } ?>>Product Name</option>
										<option value="category"  <?php if($cmbSearchType == "category"){ echo("selected"); } ?>>Category</option>
									</select> &nbsp;
									<input type="text" name="txtSearch" maxlength="50" value="<?php echo(htmlentities($txtSearch)); ?>"  class="box2_admin">
									</div>
									<div>
									<a style="cursor:pointer" onClick="javascript:clickSearch();"><?php echo $html->image('/img/search_bttn.gif');?></a>
									</div>
						</div>			
					</form>	
                  <br />		
                 <label class="btn_style-org"><strong><?php echo $html->link('Add New Product','/products/add');?> >></strong></label>
				 <?php if(count($product)> 0) { ?>
				 <label class="btn_style-org"><strong><?php echo $html->link('Export to csv','/products/getcsv');?> >></strong></label>
				 <?php } ?>
				 <div class="clear"></div>
				 <br />	 <br />			
				<!--items search area end -->
				

            <!--items display area start -->
				  <div align="center" id="items_display_area_admin">
						<form name="customlist" method="post" action="/vistacart/customfieldvalues/edit">					
                       <div id="list_admin_top">
										<div class="list9"><strong>#</strong></div>
										<div class="listp6"><strong><?php echo $paginator->sort('Product Name', 'pname'); ?></strong></div>
										<div class="listp6"><strong><?php echo $paginator->sort('Category Name', 'category_id'); ?></strong></div>
										<div class="list14"><strong><?php echo $paginator->sort('Whole sale Price', 'wholesale_price'); ?></strong></div>	
										<div class="list14"><strong><?php echo $paginator->sort('Retail Price', 'price'); ?></strong></div>	
										<div class="list14"><strong>Image</strong></div>
										<div class="list6"><strong>Options</strong></div>										
										<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
						</div>
						<?php
						if(!empty($passedarg) && !isset($passedarg["page"]))								
									$cnt=1;
									else if(!empty($passedarg) && $passedarg["page"]==1)
									$cnt=1;
									else
									$cnt=((($passedarg["page"]-1)*($passedarg["limit"]))+1);
						if(!empty($product)){
						foreach ($product as $product){ ?>   
								<div id="list_admin">
												<div class="list9"><?php echo $cnt++;?></div>
												<div class="listp6">												
												<?php 
												$prodname=Sanitize::html($product['Product']['pname']);
												if(strlen($prodname)>20)
												{
												  $prodname=substr($prodname, 0, 20)."..."; ?>
												  <a href="#" class="tooltip" title="<?php echo Sanitize::html($product['Product']['pname']); ?>" style="text-decoration:none;" onclick="return false;">
												  <?php echo $prodname; ?>
												  </a>		
												  <?php } else {
											     echo $prodname; }?>														
												</div>
												
												<div class="listp6">												
												<?php 
												$catname=Sanitize::html($product['Category']['cname']);
												if(strlen($catname)>20)
												{
												  $catname=substr($catname, 0, 20)."..."; ?>
												  <a href="#" class="tooltip" title="<?php echo Sanitize::html($product['Category']['cname']); ?>" style="text-decoration:none;" onclick="return false;">
												  <?php echo htmlspecialchars_decode($catname); ?>
												  </a>		
												 <?php } else {
											     echo htmlspecialchars_decode($catname); }?>																		
												</div>
												
												<div class="list14">
												<?php echo $curlogo; ?>
												<?php echo Sanitize::html($product['Product']['wholesale_price']); ?>
												</div> 
												
												<div class="list14">
												<?php echo $curlogo; ?>
												<?php echo Sanitize::html($product['Product']['price']); ?>
												</div> 
												
												<div class="list14">
												<?php 
												if(isset($product['Productimages']) && !empty($product['Productimages']))
												{
												 $img	= explode(".",$product['Productimages']);
												 $ext   = '.'.end(explode(".",$product['Productimages']));
												 ?>										
												<a href='<?php echo $cnfg["sitebasefolder"];?>/img/products/<?php echo $img[0].'_thumb'.$ext;?>' class="preview" onclick="return false;"><u>View</u></a>		
												<?php } else { echo 'No Image'; } ?>
												</div>
												
												
												<div class="list6">
												<?php echo $html->link('Edit',"/products/edit/".$product['Product']['id']."/".$product['Product']['category_id'])." / ".$html->link('Delete',"/products/delete/".$product['Product']['id'],null,'Are you sure you want to delete this Product'); ?>
												</div>                                        
												
												<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
								</div>
					 <?php 	}  ?>
					 
									 <div id="admin_bottom">										
												
												<div>
												<?php 
      if($cmbSearchType <> '' &&  $txtSearch <> ''){
       $paginator->options(array('url'=>array_merge(array('cmbSearchType'=>$cmbSearchType,
	   'txtSearch'=>$txtSearch),$this->passedArgs))); }  ?>
	   <?php echo $paginator->numbers(); ?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $paginator->counter(); ?>	   
	   
	    </div>			
												<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
										  </div>			
					 
					 <?php } else { ?>
							  <div id="list_admin">					
												<div>&nbsp;</div>
												<div><strong>Sorry no Products found!</strong></div>										
												<div align="left" class="float_clear"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>
								</div>			     
					 <?php } ?>
                     </form>	
					<!--items display area end -->
					 </div>
              <div align="left" class="float_clear1"></div>           
            <div align="left" class="float_clear1"><?php echo $html->image('/img/clear.gif', array('width' => 1, 'height' => 1));?></div>