예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Reimbursement::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => false, 'sort' => ['defaultOrder' => ['id' => SORT_ASC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['tech_id' => $this->tech_id, 'purchase_id' => $this->purchase_id, 'amount' => $this->amount, 'reimbursed' => $this->reimbursed]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Finds the Reimbursement model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Reimbursement the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Reimbursement::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
예제 #3
0
파일: Tech.php 프로젝트: jslight/helpdesk
 /**
  * @return ReimbursementQuery
  */
 public function getReimbursements()
 {
     return $this->hasMany(Reimbursement::className(), ['tech_id' => 'contact_id']);
 }
예제 #4
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]);
 }
예제 #5
0
 /**
  * @return ReimbursementQuery
  */
 public function getReimbursements()
 {
     return $this->hasMany(Reimbursement::className(), ['purchase_id' => 'id'])->inverseOf('purchasedItem');
 }