/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new Warranty(); if (isset($_GET['id'])) { $model->dev_id = $_GET['id']; } // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Warranty'])) { $model->attributes = $_POST['Warranty']; $model->status = 1; $model->dt_start = UserFunctions::toFull($model->dt_start); $model->dt_end = UserFunctions::toFull($model->dt_end); if (Warranty::getCompanyID($model->dev_id) == User::getMyCompany() || Yii::app()->user->role == 1) { if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } else { throw new CHttpException(403, 'У вас нет прав в этой организации'); } } $this->render('create', array('model' => $model)); }