/** * Creates a new Ticket model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate($close = false) { $model = new Ticket(); $model->loadDefaultValues(); if ($model->load(Yii::$app->request->post()) && $model->save()) { if ($close) { return "<script>window.close();</script>"; } return $this->redirect(['view', 'id' => $model->id]); } elseif (!Yii::$app->request->isPost) { $model->load(Yii::$app->request->get()); } if (!empty($model->invoice_id)) { $model->bill_type_id = $model->invoice->location->proactive; } if (Yii::$app->request->isAjax) { return $this->renderAjax('_form', ['model' => $model]); } return $this->render('create', ['model' => $model]); }