<div class="table-responsive">
    <table class="table table-hover table-bordered personal-task" id="user_details">
        <tr>
            <th></th>
            <th>Portal</th>
            <th>User Group</th>
        </tr>
        <?php
        $sql_query = "Select * from blskymine_nia_hr_main.erp_mas_portal where auth_needed='Y'";
        $model_mas_portal = Yii::app()->db->createCommand($sql_query)->queryAll();
        if (!empty($model_mas_portal)) {
            foreach ($model_mas_portal as $i => $each) {
                if($model->id>0){
//                    $SQL="SELECT user_group_id,id FROM " . $each['database_name'] . "." . $each['user_table_name'] . "  WHERE id='".$model->id."'";
//                    $data_sql = Yii::app()->db->createCommand($SQL)->queryScalar();
//                    $model_user_group_id = $data_sql->user_group_id;
                }
                ?>
                <tr>
                    <td><input type="checkbox" name="arraycid[]" value="<?php echo $each['id']; ?>">
                    </td>  
                    <td>
                        <?php echo CHtml::HiddenField('MasUser[' . $i . '][portal_id]',$each['id']); ?>
                        <?php echo CHtml::HiddenField('MasUser[' . $i . '][data_base_name]',$each['database_name']); ?>
                        <?php echo CHtml::HiddenField('MasUser[' . $i . '][user_table_name]',$each['user_table_name']); ?>
                        <?php echo CHtml::HiddenField('MasUser[' . $i . '][portal_name]',$each['portal_name']); ?>
                        <?php echo $each['portal_name']; ?>                           
                    </td>
                    <?php
                    $sql_query_usergrp = "Select * from " . $each['user_group_database_name'] . "." . $each['user_group_table_name'] . " where isActive='Y'";
                    $model_usergrp = Yii::app()->db->createCommand($sql_query_usergrp)->queryAll();
                    $m = 0;
                    foreach ($model_usergrp as $k => $id) {
                        $usergrp_details[$m]['id'] = $id['id'];
                        $usergrp_details[$m]['group_name'] = $id['group_name'];
                        $m++;
                    }
                    ?>
                    <td> <?php echo CHtml::dropdownlist('MasUser[' . $i . '][user_group_id]','', CHtml::listData($usergrp_details, 'id', 'group_name'), array('class' => 'form-control', 'empty' => 'Select')); ?>
                    </td>

                </tr>
            <?php }
        }
        ?>
    </table>
</div>
