/**
  * Создает новую модель Расхода.
  * Если создание прошло успешно - перенаправляет на просмотр.
  *
  * @return void
  */
 public function actionCreate()
 {
     $model = new Outflow();
     if (Yii::app()->getRequest()->getPost('Outflow') !== null) {
         $model->setAttributes(Yii::app()->getRequest()->getPost('Outflow'));
         if ($model->save()) {
             Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('BalanceModule.balance', 'Запись добавлена!'));
             $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['update', 'id' => $model->id]));
         }
     }
     $this->render('create', ['model' => $model]);
 }
 public function actionChange($id)
 {
     if (Yii::app()->request->isAjaxRequest) {
         $model = \Schedule::model()->findByPk($id);
         if ($model->is_active == 1) {
             $price = $model->position->form->price / $model->position->form->number;
             $model->is_active = 0;
             $model->update();
             $outflow = new Outflow();
             $outflow->price = $price;
             $outflow->based = "Отмена урока от " . $model->start_time;
             $outflow->note = $model->id;
             $outflow->branch_id = $model->position->listner->branch_id;
             $outflow->date = date('Y-m-d');
             $outflow->receiver = 'admin';
             $outflow->save();
         } elseif ($model->is_active == 0) {
             $model->is_active = 1;
             $model->update();
             $outflow = Outflow::model()->find("note='{$id}'");
             $outflow->delete();
         }
         echo CJSON::encode($model->is_active);
     } else {
         throw new CHttpException(404, Yii::t('ListnerModule.listner', 'Запрошенная страница не найдена.'));
     }
 }