Ejemplo n.º 1
0
 /**
  * Creates a new TblAssetLoan model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new TblAssetLoan();
     $external = new TblExternalUser();
     if ($model->load(Yii::$app->request->post()) && $external->load(Yii::$app->request->post())) {
         $model->user_id = Yii::$app->user->id;
         $model->form_type = 1;
         $model->start_date = date('Y-m-d h:m:s');
         $model->update_date = date('Y-m-d h:m:s');
         $model->loan_date = date('Y-m-d h:m:s');
         $model->status = 3;
         $model->save();
         if ($external->first_name != '') {
             $external->save();
         }
         return $this->redirect(['view', 'id' => $model->entry_id]);
     } else {
         return $this->render('create', ['model' => $model, 'external' => $external]);
     }
 }