public function actionSet()
 {
     if (\Yii::$app->request->post('func') === null) {
         return false;
     }
     $func = \Yii::$app->request->post('func');
     if (\Yii::$app->request->post('value') === null) {
         return false;
     }
     $value = \Yii::$app->request->post('value');
     //        $func = 'resok';
     //        $value = 24;
     switch ($func) {
         case 'resok':
             //aceita tarefa que lhe foi atribuida
             $model = TaskAssign::findOne($value);
             if ($model) {
                 $model->response = \app\enum\TaskResponse::Aceitou;
                 $model->response_date = time();
                 return $model->save();
             }
         case 'resko':
             //aceita tarefa que lhe foi atribuida
             $model = TaskAssign::findOne($value);
             if ($model) {
                 $model->response = \app\enum\TaskResponse::Recusou;
                 $model->response_date = time();
                 return $model->save();
             }
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * 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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 public function actionDelete($id)
 {
     $model = Task::findOne($id);
     TaskAssign::deleteAll(['task_id' => $id]);
     $model->delete();
     return $this->redirect('user');
 }