예제 #1
0
 /**
  * Creates a new Reimbursement model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Reimbursement();
     $model->loadDefaultValues();
     $model->created_by = Yii::$app->user->id;
     if ($model->load(Yii::$app->request->post())) {
         $model->receiptImg = UploadedFile::getInstance($model, 'receiptImg');
         if ($model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     if (!Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->get());
     }
     if (Yii::$app->request->isAjax) {
         return $this->renderAjax('_form', ['model' => $model]);
     }
     return $this->render('create', ['model' => $model]);
 }
예제 #2
0
 public function actionReimbursement($id)
 {
     $purchasedItem = $this->findModel($id);
     $model = new Reimbursement();
     $model->loadDefaultValues();
     $model->scenario = $model::SCENARIO_PURCHASE;
     $model->created_by = Yii::$app->user->id;
     $model->purchase_id = $purchasedItem->id;
     if ($model->load(Yii::$app->request->post())) {
         $model->receiptImg = UploadedFile::getInstance($model, 'receiptImg');
         if ($model->save()) {
             return $this->redirect(['/reimbursement/view', 'id' => $model->id]);
         }
     }
     if (!Yii::$app->request->isPost) {
         $model->load(Yii::$app->request->get());
     }
     if (Yii::$app->request->isAjax) {
         return $this->renderAjax('/reimbursement/_form', ['model' => $model]);
     }
     return $this->render('/reimbursement/create', ['model' => $model]);
 }