Exemplo n.º 1
0
 public function actionCreate()
 {
     $famil_bud = new FamilyBudget();
     if ($famil_bud->load(Yii::$app->request->post()) && $famil_bud->validate()) {
         //return print_r($_POST);
         $famil_bud['fam_bud_create'] = date("Y-m-d");
         $famil_bud->save();
         return $this->redirect('index');
     }
     $users = new Users();
     $categ = new Categories();
     $inco_exp = new IncoExpenso();
     $mony = new CoursesMoney();
     $users = $users->find()->all();
     $categ = $categ->find()->all();
     $inco_exp = $inco_exp->find()->all();
     $mony = $mony->find()->all();
     return $this->render('create', ['users' => $users, 'categ' => $categ, 'inco_exp' => $inco_exp, 'mony' => $mony, 'famil_bud' => $famil_bud]);
 }
Exemplo n.º 2
0
 public function actionUpdate($id)
 {
     $id = (int) $id;
     if (empty($id)) {
         return $this->redirect('index');
     }
     $famil_bud = new FamilyBudget();
     $sql = $famil_bud->findOne($id);
     if ($famil_bud->load(Yii::$app->request->post()) && $sql->validate()) {
         $sql->updateAll(['categ_id' => $_POST['FamilyBudget']['categ_id'], 'summa' => $_POST['FamilyBudget']['summa'], 'cour_mon_id' => $_POST['FamilyBudget']['cour_mon_id'], 'user_id' => $_POST['FamilyBudget']['user_id']], ['fam_bud_id' => $id]);
         return $this->redirect('index');
     }
     $users = new Users();
     $categ = new Categories();
     $inco_exp = new IncoExpenso();
     $mony = new CoursesMoney();
     $users = $users->find()->where('user_active_to is null')->all();
     $categ = $categ->find()->where('categ_active_to is null')->all();
     $inco_exp = $inco_exp->find()->all();
     $mony = $mony->find()->all();
     return $this->render('update', ['users' => $users, 'categ' => $categ, 'inco_exp' => $inco_exp, 'mony' => $mony, 'famil_bud' => $sql]);
 }