/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new StartingDateRevenueLog(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['StartingDateRevenueLog'])) { $model->attributes = $_POST['StartingDateRevenueLog']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
public function actionIndex($username) { $userModel = User::model()->findByAttributes(array('username' => $username)); if (!$userModel) { throw new CHttpException(404, "Can't find username {$username}"); } $newStartingLog = new StartingDateRevenueLog(); $newStartingLog->revert_date = date("Y-m-d H:i:s"); $newStartingLog->user_id = $userModel->id; $newStartingLog->date_inserted = date("Y-m-d H:i:s"); if ($newStartingLog->save()) { $undoIcon = CHtml::image(Yii::app()->theme->baseUrl . '/img/Undo-icon.png', 'Undo action'); $undoButton = CHtml::link('Undo action', array('/resetRevenue/undo', 'username' => $username), array('class' => 'btn btn-default')); Yii::app()->user->setFlash("success", "<strong>Success :</strong> Reset complete for user <b>{$username}. </b> If you are not sure about that action {$undoButton}"); } else { $errorSummary = CHtml::errorSummary($newStartingLog); Yii::app()->user->setFlash("error", "<strong>Error :</strong> {$errorSummary}"); } $this->redirect(Yii::app()->request->urlReferrer); }