/** * This command echoes what you have entered as the message. * @param string $message the message to be echoed. */ public function actionIndex() { // EVENTOS $events = \app\models\CalendarEventAssign::findAll(['notification_status' => \app\enum\NotificationStatus::Envia_notificacao]); if (count($events) > 0) { foreach ($events as $event) { $family_name = $event->familyMember->family->name; $name = $event->familyMember->name; $email = $event->familyMember->user->username; if (self::sendNotificationNewEvent($name, $family_name, $email)) { $event->notification_status = \app\enum\NotificationStatus::Notificacao_enviada; $event->notification_date = time(); $event->save(); } } } // TAREFAS $tasks = \app\models\TaskAssign::findAll(['notification_status' => \app\enum\NotificationStatus::Envia_notificacao]); if (count($tasks) > 0) { foreach ($tasks as $task) { $family_name = $task->familyMember->family->name; $name = $task->familyMember->name; $email = $task->familyMember->user->username; if (self::sendNotificationNewTask($name, $family_name, $email)) { $task->notification_status = \app\enum\NotificationStatus::Notificacao_enviada; $task->notification_date = time(); $task->save(); } } } return 0; }
public static function getTasksWaitingForResponseArray($members) { $condition = ['member_id' => $members, 'response' => \app\enum\TaskResponse::Sem_resposta]; $res = TaskAssign::findAll($condition); if ($res) { foreach ($res as $record) { $resArray[] = $record->task_id; } } else { $resArray[] = -1; } return $resArray; }
public function actionView($id) { $model = Task::findOne($id); if (Yii::$app->request->isPost) { //Só salva tudo quando é dono if ($model->created_by == \Yii::$app->user->id) { $model->load(Yii::$app->request->post()); return $model->save(); } else { //Salva status e %concluido $model->status = Yii::$app->request->post('Task')['status']; $model->done = Yii::$app->request->post('Task')['done']; return $model->savePartial(['status', 'done']); } } //Regras //Se a tarefa foi criada por mim (pode ser privada ou não) usa vista: _private //Se a tarefa é familiar usa vista: _homy //Se a tarefa me foi atribuida: //--pode editar se: // precisa de Aceitar a tarefa, caso lhe tenha sido atribuida // alterar estado e %conclusão se aceitou // alterar estado e %conclusão se lhe foi atribuida e não precisa de resposta $modelAssigned = TaskAssign::findAll(['task_id' => $id]); if ($model->created_by == \Yii::$app->user->id) { $modelMembers = \Yii::$app->user->identity->familyMembers; return json_encode($this->renderAjax('_user', ['model' => $model, 'modelMembers' => $modelMembers, 'modelAssigned' => $modelAssigned])); } $edit = false; if ($model->assigned == 1) { foreach ($modelAssigned as $record) { if ($record->member_id == \Yii::$app->user->identity->family_member_id) { if ($model->response_required == 1) { $edit = $record->response == \app\enum\TaskResponse::Aceitou; } else { $edit = true; } } } } return json_encode($this->renderAjax('_homy', ['model' => $model, 'modelAssigned' => $modelAssigned, 'edit' => $edit])); }