<div id="sidesidemenu_wrapper" >
  <ul class="sidemenu" style="padding:0px 24px; width:220px;">
  <?php
$userGroups	=	UserGroup::model()->findAll(array('condition'=>'isActive="Y"'));
foreach($userGroups as $eachUserGroup): ?>
    <li class="item<?php echo $eachUserGroup->id; ?>" style="padding:0px;"><a href="#"><?php echo $eachUserGroup->group_name; ?></a>
      <ul style="padding:0px; width:220px;">
      <?php 
		  $productGroups	=	ProductGroup::model()->findAll(array('condition'=>'user_group_id='.$eachUserGroup->id.' and isActive="Y"'));
		foreach($productGroups as $eachProductGroup):
		  ?>
        <li ><a href="<?php echo Yii::app()->createUrl('site/productgroup',array('id'=>$eachProductGroup->id,'user_group_id'=>$eachUserGroup->id,'name'=>preg_replace('/[^a-z0-9_]/','',strtolower( str_replace(" ", "_", $eachProductGroup->product_group_name))))); ?>"><?php echo $eachProductGroup->product_group_name; ?></a></li>
        <?php endforeach; ?>
        
      </ul>
    </li>
    <?php endforeach; ?>  
  </ul>
</div>
<script type="text/javascript">
	$(function() {
	
	    var sidemenu_ul = $('.sidemenu > li > ul'),
	           sidemenu_a  = $('.sidemenu > li > a');
	    
	    sidemenu_ul.hide();
	
	    sidemenu_a.click(function(e) {
	        e.preventDefault();
	        if(!$(this).hasClass('active')) {
	            sidemenu_a.removeClass('active');
	            sidemenu_ul.filter(':visible').slideUp('normal');
	            $(this).addClass('active').next().stop(true,true).slideDown('normal');
	        } else {
	            $(this).removeClass('active');
	            $(this).next().stop(true,true).slideUp('normal');
	        }
	    });
	
	});
</script>