<?php
//print_r($categories);
?>
<!--<div class="main_content">-->

<div class="innercontent_outerbox">
      
    
      <?php if($ProductGroup->banner!=''):?>
      <?php echo CHtml::image('http://dlinkmea.com/images/banner/'.$ProductGroup->banner,"banner",array("width"=>'885px','height'=>'323px')); ?>
      <?php endif; ?><h1><?php echo @$ProductGroup->sub_category; ?> <br/></h1>
      <?php echo $ProductGroup->description;  ?> 
      </div>
<div class="innercontent_outerbox">
  <div class="innerpage_main_contentbox">
      <?php if(is_array($categories) && count($categories)>0) { 
          ?>		
    <div id="overview_rightcontent" style="padding-top: 10px;">
      <div class="compare"> <span style="margin-left:25px"><?php //echo $ProductGroup->category->category; ?> > <?php //echo $ProductGroup->sub_category; ?></span></div>
      
      <ul class="gallery product_categories">
        <?php
        foreach($categories as $eachCategory): ?>
        <li><a href="<?php Yii::app()->createUrl('site/products',array('id'=>$id,'product_category_id' => $eachCategory['id'],)); ?>"><div style="height: 25px; line-height: 14px;"><em><?php echo $eachCategory['product_category']; ?></em></div>
                        <?php
			if (file_exists('media/product_images/'.$eachCategory['image'])) 
			{
				$thumb=Yii::app()->phpThumb->create('media/product_images/'.$eachCategory['image']);
				$thumb->resize(120,75);
				$thumb->save('media/product_images/thumbs/170_120'.$eachCategory['image']);
			}
                        else if(file_exists('images/product/'.$eachCategory['image']))
                        {
                        	$thumb=Yii::app()->phpThumb->create('images/product/'.$eachCategory['image']);
				$thumb->resize(120,75);
				$thumb->save('images/product/'.$eachCategory['image']);    
                        }
		 	?>
                <?php
			if (file_exists('media/product_images/'.$eachCategory['image'])) 
			{
                            ?>
          <div class="image_boarder"> <img title="<?php echo $eachCategory['product_category']; ?>" src="<?php echo Yii::app()->baseUrl; ?>media/product_images/thumbs/170_120<?php echo $eachCategory['image']; ?>" alt="loading.." /> </div>
                     <?php   }
                     else {
                         ?>
          <div class="image_boarder"> <img title="<?php echo $eachCategory['product_category']; ?>" src="<?php echo Yii::app()->baseUrl; ?>images/product/<?php echo $eachCategory['image']; ?>" alt="test.." /> </div>    
          <?php
                     }
                     ?>
          </a></li>
        <?php endforeach; ?>
      </ul>
    </div>
    <?php } ?>
      
    <div class="innerpage_content_box">
      <div class="innerpage_content_box"> <br />
        <div class="sider_shadow_top" > </div>
        <div class="compare"> <span style="margin-left:25px"><?php echo $ProductGroup->sub_category; ?> - <?php 
//        echo ($category[0]->product_category!='')?$category[0]->product_category:'Products'; 
       echo 'Products'; 
        ?></span></div>
      </div>
    </div>
    <div class="innerpage_main_contentbox">
      <div class="innerpage_content_box">
        <div class="product_matter_outer">
          <div>
            <?php if(count($allProductsUnderUserGroup)==0) echo "No products available in this user group"; ?>
            <?php  foreach($allProductsUnderUserGroup as $eachProduct): ?>
            <?php
			/*if(file_exists('media/product_images/'.$eachProduct->product_image)) 
			{
				$thumb=Yii::app()->phpThumb->create('media/product_images/'.$eachProduct->product_image);
				$thumb->resize(198,110);
				$thumb->save('media/product_images/thumbs/198_110'.$eachProduct->product_image);
			}*/
		 ?>
            <div class="compare_matter_outer">
                <?php
                if (file_exists('media/product_images/'.$eachProduct->product_image)) 
			{
                            ?>
              <div class="product_image"><img title="<?php echo ($eachProduct->product_generic_name!='')?$eachProduct->product_generic_name:$eachProduct->product_name; ?>" alt="loading.." src="<?php echo Yii::app()->baseUrl; ?>/media/product_images/thumbs/198_110<?php echo $eachProduct->product_image; ?>" /></div>
              <?php   }
                     else {
                          $mod_pdt_image=new   ProductImages();           
                         $p_image=$mod_pdt_image->find(array('condition' => 'product_id=' . $eachProduct->id.' AND main_image=1'));
if(!empty($p_image))
{
 ?>
                         
              <div class="product_image t1"><img title="<?php echo ($eachProduct->product_generic_name!='')?$eachProduct->product_generic_name:$eachProduct->product_name; ?>" alt="loading.." src="<?php echo Yii::app()->baseUrl; ?>/../images/product/<?php echo $p_image->product_image; ?>" /></div>
              <?php
}else
{
    ?>
 <div class="product_image t1"><img title="<?php echo ($eachProduct->product_generic_name!='')?$eachProduct->product_generic_name:$eachProduct->product_name; ?>" alt="loading.." src="<?php echo Yii::app()->baseUrl; ?>/../images/product/<?php echo $eachProduct->product_image; ?>" /></div>
               <?php
}
}
    ?>

              <div class="product_image_matter">
                <h2><a href="<?php echo Yii::app()->createUrl('site/productdetails',array('id'=>$eachProduct->id,'name'=>
            preg_replace('/[^a-z0-9_]/','',strtolower( str_replace(" ", "_", $eachProduct->product_name))))); ?>"><?php echo ($eachProduct->product_generic_name!='')?$eachProduct->product_generic_name:$eachProduct->product_name; ?><br />
                </h2>
                <?php echo $eachProduct->product_name; ?><br />
                <?php echo substr(strip_tags($eachProduct->description),0,200).'...'; ?><br />
                <br />
              </div>
              <div class="product_compare_box"> <a href="<?php echo Yii::app()->createUrl('site/productdetails',array('id'=>$eachProduct->id,'name'=>
            preg_replace('/[^a-z0-9_]/','',strtolower( str_replace(" ", "_", $eachProduct->product_name))))); ?>">
                <div class="find"> Find out more </div>
                </a> <br />
                <br />
                <br />
              </div>
            </div>
            <?php 
            
            endforeach; 
            ?>
          </div>
        </div>
      </div>
    </div>
  </div>
  
<!--Featured Items List -->
</div>
<!--</div>-->
<?php echo $this->renderPartial('_bottom_common_user_product_group'); ?> 