public function actionAdd()
{
$model = new User('create');
$model2 = new UserGroups('create');
$model_group = new Groups('create');
// Uncomment the following line if AJAX validation is needed
$this->performAjaxValidation($model);
$this->performAjaxValidation($model_group);
if(isset( $_POST['User'],$_POST['Groups']))
{
$model->created_dt = new CDbExpression('NOW()');
$model->updated_dt = new CDbExpression('NOW()');
$model->created_by = Yii::app()->user->id;
$model->updated_by = Yii::app()->user->id;
$model->created_by_flag = 2;
$model->updated_by_flag = 2;
$model->ipaddress = $_SERVER['REMOTE_ADDR'];
$model->attributes=$_POST['User'];
$model_group->attributes=$_POST['Groups'];
if($model->save())
{
foreach($_POST['Groups']['name'] as $v)
{
echo $v;
$model2 = new UserGroups('create');
$model2->user_id = $model->id;
$model2->group_id = $v;
$model2->created_dt = new CDbExpression('NOW()');
$model2->save();
}
/******************** Create LOG ***********************/
$id = $model->id;
Log::createLog($this->getAction()->id.'_'.$this->id, $this->id, $id);
/*******************************************************/
$this->redirect(array('list'));
}
}
$this->render('add',array(
'model'=>$model,
'model_group'=>$model_group,
));
}