public function actionCheckGoals() { $models = FinanceGoal::model()->findAllByAttributes(['state' => FinanceGoal::StateInProgress]); /** * @var $models FinanceGoal[] */ foreach ($models as $model) { $model->data = json_decode($model->data); $typObj = $model->getType($model->type); echo "\nCheck model - " . $model->id; $typObj->checkGoal($model); } echo "\ndone!\n"; }
public function actionCheck($id) { $goal = FinanceGoal::model()->findByPk($id); $goal->data = json_decode($goal->data); $finance = Finance::model()->findByPk($goal->finance_id); /** * @var $finance Finance */ if ($finance->account_id != $this->Account->id) { return false; } $typeObj = FinanceGoal::getType($goal->type); $typeObj->checkGoal($goal); $this->redirect('/financeGoal/detail?id=' . $id); }
<thead> <tr> <th>Номер</th> <th>Название</th> <th>Баланс</th> <th>Количество активных задач</th> <th>Посмотреть</th> </tr> </thead> <tbody> <?php foreach ($models as $index => $model) { $activeGoalsCount = count(FinanceGoal::model()->findAllByAttributes(array('finance_id' => $model->id, 'state' => FinanceGoal::StateInProgress))); ?> <tr> <td><?php echo $index + 1; ?> </td> <td> <?php echo $model->name; ?> </td> <td> <?php echo $model->financeStates[0]->value; ?>