public function actionPutExpenses() { $data = Yii::$app->request->post(); Expenses::setExpenses($data); $result = Expenses::getAll($data); print_r(json_encode($result)); return false; }
public function actionFormSubmission($id = null) { $data = Yii::$app->request->post(); if (isset($data['type'])) { Payments::addPayments($data, $id); } $searchModel = new Payments(); $expenses = Expenses::getByid(['id' => $id]); $departments = Departments::getByid(['id' => $expenses[0]['iddepartment']]); $params = ['idexpense' => $id]; $dataProvider = $searchModel->search(Yii::$app->request->queryParams, $params); $breadcrumbs[] = ['label' => $departments[0]['name'], 'url' => ['/department/' . $departments[0]['id']]]; $breadcrumbs[] = $expenses[0]['name']; return $this->render('expenses', ['dataProvider' => $dataProvider, 'breadcrumbs' => $breadcrumbs, 'id' => $id, 'data' => $data, 'searchModel' => $searchModel]); }
public function getDepartments() { return $this->hasOne(Departments::className(), ['id' => 'iddepartment'])->viaTable(Expenses::tableName(), ['id' => 'idexpense']); }
public static function setExpenses($input) { $departments = Expenses::findOne($input['id']); $departments->condition = $input['type']; $departments->save(); }