<div class="main_content">
<div class="innercontent_outerbox">
  <h1><?php echo $resourceTypeName; ?></h1>
  <?php echo ResourceType::model()->findByPk($_GET['id'])->description; ?> <br />
  <br />
  <table width="885" border="0" align="center" cellpadding="5" cellspacing="5">
    <tr>
      <td><h3>Search by Product Category</h3></td>
    </tr>
    <tr>
      <td><?php $form=$this->beginWidget('CActiveForm', array(
	'id'=>'resource-form',
	'enableAjaxValidation'=>false,
	'htmlOptions' => array(
        'enctype' => 'multipart/form-data',
    ),
)); ?>
          <table width="100%" border="0" cellspacing="5" cellpadding="5">
            <tr>
              <td><?php echo $form->dropDownList($model,'user_group_id',UserGroup::getGroups(),
											 array(
												'class'=>'selectyze2',
												'prompt'=>'Select user group',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('site/updateProductGroup'), 
												//'update'=>'#Product_product_group_id',
												'data'=>array('user_group_id'=>'js:this.value'), 
												'success'=>'js:function(data){
													$("#Resource_product_group_id").html(data)
													$("#Resource_product_category_id").html("<option value=\"\">Select category</option>")
													$("#Resource_product_id").html("<option value=\"\">Select product</option>")
													$("#Resource_product_group_id").next(".DivSelectyze").remove();
													$("#Resource_product_group_id").Selectyze({theme : "mac"});
													}'
            ))); ?></td>
              <td><?php echo $form->dropDownList($model,'product_group_id',ProductGroup::getProductGroup($model->user_group_id),array(
												'class'=>'selectyze2',
												'prompt'=>'Select group',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('site/updateProductCategory'), 
												'data'=>array(
															  'user_group_id'=>'js:$("#Resource_user_group_id :selected").val()',  
															  'product_group_id'=>'js:this.value'
															  ),  
												'success'=>'js:function(data){
													$("#Resource_product_category_id").html(data)
													$("#Resource_product_id").html("<option value=\"\">Select product</option>")
													$("#Resource_product_category_id").next(".DivSelectyze").remove();
													$("#Resource_product_category_id").Selectyze({theme : "mac"});
													}'
																		  ))); ?></td>
              <td><?php  echo $form->dropDownList($model,'product_category_id',ProductCategory::getProductCategory($model->user_group_id,$model->product_group_id),array(
												'class'=>'selectyze2',
												'prompt'=>'Select category',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('site/updateProduct'), 
												'update'=>'#Resource_product_id',
												'data'=>array(
															  'user_group_id'=>'js:$("#Resource_user_group_id :selected").val()',  
															  'product_group_id'=>'js:$("#Resource_product_group_id :selected").val()',  
															  'product_category_id'=>'js:this.value'
															  ),  
																		  ))); ?></td>
              <td><input type="submit" value="Search" name="btValide" class="submit_button" /></td>
            </tr>
          </table>
        <?php $this->endWidget(); ?></td>
    </tr>
  </table>
  <br />
  <br />
  <table width="885" border="1" align="center" cellpadding="5" cellspacing="5" bordercolor="#999999">
  <?php
				if($resource==null && $productResource==null):
				?>
                <tr>
                  <td>No results found</td>
                </tr>
                <?php
				endif;
				$bgcolor="";
				foreach($resource as $eachResource):
				$bgcolor	=	($bgcolor=="#CCCCCC")?"":"#CCCCCC";
				?>
    <tr>
      <td width="277" align="left" valign="middle" bgcolor="<?php echo $bgcolor; ?>" ><?php echo $eachResource->resource_title; ?></td>
      <td width="408" align="left" valign="middle" bgcolor="<?php echo $bgcolor; ?>"><?php echo $eachResource->description; ?></td>
      <td width="142" align="left" valign="middle" bgcolor="<?php echo $bgcolor; ?>"> <?php echo CHtml::link(CHtml::image(Yii::app()->baseUrl."/images/download.png","",array("width"=>"25","height"=>"25")).round(@filesize(Yii::app()->basePath."/../media/resources/".$eachResource->source_file)/1000,2)." KB",Yii::app()->request->getBaseUrl(true).'/media/resources/'.$eachResource->source_file,array('target'=>'_balnk')); ?></td>
    </tr>
    <?php endforeach;?>
	<?php
    foreach($productResource as $eachResource):
    $bgcolor	=	($bgcolor=="#CCCCCC")?"":"#CCCCCC";
    ?>
    <tr>
      <td width="277" align="left" valign="middle" bgcolor="<?php echo $bgcolor; ?>" ><?php echo $eachResource->resource_title; ?></td>
      <td width="408" align="left" valign="middle" bgcolor="<?php echo $bgcolor; ?>"><?php echo $eachResource->description; ?></td>
      <td width="142" align="left" valign="middle" bgcolor="<?php echo $bgcolor; ?>"> <?php echo CHtml::link(CHtml::image(Yii::app()->baseUrl."/images/download.png","",array("width"=>"25","height"=>"25")).round(@filesize(Yii::app()->basePath."/../media/resources/".$eachResource->source_file)/1000,2)." KB",Yii::app()->request->getBaseUrl(true).'/media/resources/'.$eachResource->source_file,array('target'=>'_balnk')); ?></td>
    </tr>
    <?php endforeach;?>
  </table>
</div>
<?php echo $this->renderPartial('_bottom_common_user_product_group'); ?> 