public function createNew($data)
 {
     $goal = new FinanceGoal();
     $goal->create_date = time();
     $goal->description = $data['description'];
     $goal->finance_id = $data['financeId'];
     $goal->type = $data['type'];
     $goal->state = FinanceGoal::StateInProgress;
     $goalDate = [];
     $goalDate['date'] = $data['date'];
     $goalDate['value'] = $data['value'];
     $jsonGoalDate = json_encode($goalDate);
     $goal->data = $jsonGoalDate;
     return $goal->save();
 }
Example #2
0
 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);
 }
Example #4
0
echo FinanceGoal::getType($model->type)->getDescription();
?>
</p></td>
    </tr>
    <tr>
        <td>Описание пользователя:</td>
        <td><p> <?php 
echo nl2br($model->description);
?>
</p></td>
    </tr>

    <tr>
        <td>Статус</td>
        <td><p><?php 
echo FinanceGoal::getStateName($model->state);
?>
</p></td>
    </tr>

    <tr>
        <td>Дата окончания</td>
        <td><p><?php 
echo $model->data->date;
?>
</p></td>
    </tr>


    <tr>
        <td>Сумма</td>
Example #5
0
    <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;
        ?>