<?php
$cs=Yii::app()->clientScript;
		$cs->scriptMap=array(
    'jquery.js'=>false,
);
?>
<?php $id	=	uniqid('ppp'); ?>
<?php
Yii::app()->clientScript->registerScript('dynamic'.$id,"
jQuery('#remove_this".$id."').click(function()
{
	$('#mapping".$id."').remove();
});
");
?>
<table id="mapping<?php echo $id; ?>" width="96%" border="0" align="center" cellpadding="2" cellspacing="2">
                <tr>
                  <td><strong>Product Mapping</strong></td>
                  <td width="46%">&nbsp;</td>
                  <td width="12%"><a href="javascript:;" id="remove_this<?php echo $id; ?>" title="Remove"><img class="plus_position" height="15" width="15" src="/partner/images/admin/green--sign-md.png"></a></td>
                </tr>
                <tr>
                  <td width="42%">User Group</td>
                  <td colspan="2"><?php echo CHtml::dropDownList('user_group_id[]','',UserGroup::getGroups(),
											 array(
											 	'id'=>'user_group_id'.$id,
												'style'=>'width:150px',
												'prompt'=>'Select user group',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('Product/updateProductGroup'), 
												'data'=>array('user_group_id'=>'js:this.value'), 
												'success'=>'js:function(data){
													$("#product_group_id'.$id.'").html(data)
													$("#product_category_id'.$id.'").html("<option value=\"0\">No category</option>")
													$("#type_id'.$id.'").html("<option value=\"0\">No Type</option>")
													}'
            ))); ?></td>
                </tr>
                <tr>
                  <td>Product Group</td>
                  <td colspan="2"><?php echo CHtml::dropDownList('product_group_id[]','',array(),array(
				  								'id'=>'product_group_id'.$id,
												'style'=>'width:150px',
												'prompt'=>'Select group',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('Product/updateProductCategory'), 
												'success'=>'js:function(data){
													$("#product_category_id'.$id.'").html(data)
													$("#type_id'.$id.'").html("<option value=\"0\">No Type</option>")
													}',
												'data'=>array(
															  'user_group_id'=>'js:$("#user_group_id'.$id.' :selected").val()',  
															  'product_group_id'=>'js:this.value'
															  ),  
																		  ))); ?></td>
                </tr>
                <tr>
                  <td>Product category</td>
                  <td colspan="2"><?php echo CHtml::dropDownList('category_id[]','',array(),array(
				  								'id'=>'product_category_id'.$id,
												'style'=>'width:150px',
												'empty'=>array(0=>'No category'),
												'style'=>'width:150px',
												'ajax' => array(
												'type'=>'POST',
												'url'=>CController::createUrl('Product/updateProductType'), 
												'data'=>array(
															  'user_group_id'=>'js:$("#user_group_id'.$id.' :selected").val()',  
															  'product_group_id'=>'js:$("#product_group_id'.$id.' :selected").val()',
															  'product_category_id'=>'js:$("#product_category_id'.$id.' :selected").val()',
															  ),
												'success'=>'js:function(data){
													$("#type_id'.$id.'").html(data)
													}'
            )
												
												)); ?>
                   </td>
                </tr>
                <tr>
                  <td>Product type</td>
                  <td colspan="2"><?php echo CHtml::dropDownList('type_id[]','',array(),array(
												'style'=>'width:150px',
												'empty'=>array(0=>'No Type'),
												)); ?>
                    </td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td colspan="2">&nbsp;</td>
                </tr>
              </table>
