/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ASystemUser(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ASystemUser'])) { //var_dump($_POST['SystemUser']); exit(); $model->attributes = $_POST['ASystemUser']; //var_dump(Yii::app()->params->hashkey); exit(); $model->id = Utils::GUID(); $model->created_date = date("ymdHis"); $model->password = SystemUser::encrypt($_POST['ASystemUser']['password'], Yii::app()->params->hashkey); $model->phonenumber = $_POST['ASystemUser']['phonenumber']; //$model->cp_code = $_POST['ASystemUser']['cp_code']; if (!CFunction::checkPasswordStrength($_POST['ASystemUser']['password'], 8)) { Yii::app()->user->setFlash('warning', 'Yêu cầu Mật khẩu phải chứa ít nhất 1 kí tự thường, ít nhất 1 kí tự HOA, ít nhất 1 chữ số và ít nhất 1 kí tự đặc biệt.'); $this->redirect(array('aSystemUser/create')); exit; } if ($model->save()) { Yii::app()->user->setFlash('success', Yii::t('adm/user', 'success_user') . " <b>{$model->username}</b>"); $this->redirect(array('admin')); //$modelUser = new AUser; // $modelUser->user_id = $model->id; // $modelUser->username = $model->username; // $modelUser->phone = $model->phonenumber; // $modelUser->email = $model->email; // if($modelUser->save()){ // // } } } $this->render('create', array('model' => $model)); }
/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new ASystemUser(); // Uncomment the following line if AJAX validation is needed $this->performAjaxValidation($model); if (isset($_POST['ASystemUser'])) { //var_dump($_POST['SystemUser']); exit(); $model->attributes = $_POST['ASystemUser']; //var_dump(Yii::app()->params->hashkey); exit(); $model->id = Utils::GUID(); $model->created_date = date("ymdHis"); $model->password = SystemUser::encrypt($_POST['ASystemUser']['password'], Yii::app()->params->hashkey); $model->phonenumber = $_POST['ASystemUser']['phonenumber']; $model->cp_code = $_POST['ASystemUser']['cp_code']; if (isset($_POST['ASystemUser']['channel_code'])) { $model->channel_code = serialize($_POST['ASystemUser']['channel_code']); } else { Yii::app()->user->setFlash('unsuccess', Yii::t('adm/user', 'select_channel')); $this->redirect(array('create')); } if ($model->save()) { Yii::app()->user->setFlash('success', Yii::t('adm/user', 'success_user') . " <b>{$model->username}</b>"); $this->redirect(array('admin')); } } $this->render('create', array('model' => $model)); }