/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { self::CheckLogin(); $cs = Yii::app()->getClientScript(); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/ckeditor/ckeditor.js'); $cs->registerCssFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.fileupload.css'); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.ui.widget.js', CClientScript::POS_END); $cs->registerScriptFile(Yii::app()->theme->baseUrl . '/js/jqueryUpload/jquery.fileupload.js', CClientScript::POS_END); $model = new WTestParent(); if (isset($_POST['WTestParent'])) { $model->attributes = $_POST['WTestParent']; $model->test_name = $_POST['WTestParent']['test_name']; $model->code_test = 'ADH' . rand(5, 10); $model->test_cat_id = $_POST['WTestParent']['test_cat_id']; $model->kind_of_test = $_POST['WTestParent']['kind_of_test']; $model->time_test = $_POST['WTestParent']['time_test']; $model->introduce = $_POST['WTestParent']['introduce']; $model->footer = $_POST['WTestParent']['footer']; $model->created_by = Yii::app()->user->id; $model->created_date = date('Y-m-d H:i:s'); $model->total_point = $_POST['WTestParent']['total_point']; $model->if_random = $_POST['WTestParent']['if_random']; $dataConfig = array(); if (isset($_POST["datafix"])) { $dataConfig["datafix"] = $_POST["datafix"]; } if (isset($_POST["datarandom"])) { $dataConfig["datarandom"] = $_POST["datarandom"]; } $model->dataconfig = json_encode($dataConfig); //--------------------------------- if (!empty($_POST['avatar'])) { $model->avatar = Common::createThumb('avatars/test', $_POST['avatar'], $_POST['WTestParent']['test_name']); } if (Yii::app()->session['group_id'] == 2) { $model->company_code = Yii::app()->session['company_code']; } if ($model->save()) { $this->redirect(array('index')); } else { print_r(CHtml::errorSummary($model)); } } $this->render('create', array('model' => $model)); }