/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { try { $model = new Criteria(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Criteria'])) { $model->attributes = $_POST['Criteria']; if ($model->save()) { Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, '<strong>Well!</strong> Criteria created with sucess!'); Yii::app()->controller->refresh(); } } } catch (Exception $e) { Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, '<strong>Ops!</strong> ERROR!'); Yii::app()->controller->refresh(); } $this->render('create', array('model' => $model)); }
/** * Add notification criteria. * * This method is called by a form on the "Manage Notification Criteria" page * and is used to create a new criteria for generation notifications. */ public function actionAddCriteria() { $criteria = new Criteria(); $users = User::getNames(); $dataProvider = new CActiveDataProvider('Criteria'); unset($users['']); unset($users['Anyone']); $criteria->users = Yii::app()->user->getName(); if (isset($_POST['Criteria'])) { $criteria->attributes = $_POST['Criteria']; $str = ""; $arr = $criteria->users; if ($criteria->type == 'assignment' && count($arr) > 1) { $this->redirect('addCriteria'); } if (isset($arr)) { $str = implode(', ', $arr); } $criteria->users = $str; if ($criteria->modelType != null && $criteria->comparisonOperator != null) { if ($criteria->save()) { } $this->refresh(); } } $this->render('addCriteria', array('users' => $users, 'model' => $criteria, 'dataProvider' => $dataProvider)); }
public function actionAddCriteria() { $criteria = new Criteria(); $users = User::getNames(); $dataProvider = new CActiveDataProvider('Criteria'); unset($users['']); if (isset($_POST['Criteria'])) { $criteria->attributes = $_POST['Criteria']; $str = ""; $arr = $criteria->users; if ($criteria->type == 'assignment' && count($arr) > 1) { $this->redirect('addCriteria'); } if (isset($arr)) { foreach ($arr as $user) { $str .= $user . ", "; } $str = substr($str, 0, -2); } $criteria->users = $str; if ($criteria->modelType != null && $criteria->comparisonOperator != null) { if ($criteria->save()) { } $this->redirect('index'); } } $this->render('addCriteria', array('users' => $users, 'model' => $criteria, 'dataProvider' => $dataProvider)); }