Esempio n. 1
0
 public function actionPutExpenses()
 {
     $data = Yii::$app->request->post();
     Expenses::setExpenses($data);
     $result = Expenses::getAll($data);
     print_r(json_encode($result));
     return false;
 }
Esempio n. 2
0
 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]);
 }
Esempio n. 3
0
 public function getDepartments()
 {
     return $this->hasOne(Departments::className(), ['id' => 'iddepartment'])->viaTable(Expenses::tableName(), ['id' => 'idexpense']);
 }
Esempio n. 4
0
 public static function setExpenses($input)
 {
     $departments = Expenses::findOne($input['id']);
     $departments->condition = $input['type'];
     $departments->save();
 }