Пример #1
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;
 }
 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');
     switch ($func) {
         case 'yes':
         case 'no':
         case 'maybe':
             $model = CalendarEventAssign::findOne($value);
             if ($model) {
                 if ($func == 'yes') {
                     $model->response = \app\enum\CalendarEventResponse::Sim;
                 }
                 if ($func == 'maybe') {
                     $model->response = \app\enum\CalendarEventResponse::Talvez;
                 }
                 if ($func == 'no') {
                     $model->response = \app\enum\CalendarEventResponse::Nao;
                 }
                 $model->response_date = time();
                 return $model->save();
             }
     }
     return -1;
 }
Пример #3
0
 public function getAssignedTo()
 {
     return $this->hasMany(CalendarEventAssign::className(), ['calendar_event_id' => 'id']);
 }
 public function actionDelete()
 {
     self::validateRequest();
     $id = Yii::$app->request->post('CalendarEvent')['id'];
     $model = CalendarEvent::findOne($id);
     if (!$model || !$model->isMine()) {
         return false;
     }
     //Elimina assigned
     CalendarEventAssign::deleteAll(['calendar_event_id' => $id]);
     //Elimina reminders
     CalendarReminder::findAll(['event_id' => $id]);
     //Elimina evento
     CalendarReminder::deleteAll(['event_id' => $id]);
     return $model->delete();
 }