public function actionCreate()
 {
     $event = new Event();
     $event_ru = new Event_ru();
     $event_en = new Event_en();
     $photos = new ActiveDataProvider(['query' => event_photo::find()->where(['event_id' => $id])]);
     if ($event->load(Yii::$app->request->post()) && $event_ru->load(Yii::$app->request->post()) && $event_en->load(Yii::$app->request->post())) {
         $event->author_id = Yii::$app->user->identity->id;
         if ($event->save()) {
             $this->uploadphoto(UploadedFile::getInstances($event, 'images'), $event->id);
             $event_ru->event_id = $event->id;
             $event_ru->publish_status = 0;
             $event_ru->like = 0;
             $event_ru->visited = 0;
             $event_en->event_id = $event->id;
             $event_en->publish_status = 0;
             $event_en->like = 0;
             $event_en->visited = 0;
             $event_ru->save();
             $event_en->save();
         }
         return $this->redirect(['update', 'id' => $event->id]);
     } else {
         return $this->render('create', ['event' => $event, 'event_ru' => $event_ru, 'event_en' => $event_en, 'photos' => $photos]);
     }
 }
Example #2
0
 public function actionAdd()
 {
     if (User::thisUser()->reputation < Event::MIN_REPUTATION_EVENT_CREATE) {
         return Yii::$app->getResponse()->redirect(Url::home());
     }
     $event = new Event();
     if ($event->load(Yii::$app->request->post())) {
         $eventPost = Yii::$app->request->post('Event');
         $event->country = $eventPost['country'];
         $event->description = \yii\helpers\HtmlPurifier::process($event->description, []);
         $event->user_id = Yii::$app->user->identity->getId();
         $event->date = strtotime($eventPost['date']);
         $event->like_count = 0;
         $event->show_count = 0;
         if ($event->save()) {
             // Добавляем теги
             $tagsArr = explode(',', Yii::$app->request->post('tags'));
             $tags = array_shift($tagsArr);
             $event->saveTags($tags);
             // Добавляем картинки к записи
             $imgs = Yii::$app->request->post('imgs');
             if (!empty($imgs) && is_array($imgs)) {
                 $event->saveImgs($imgs);
             } else {
                 $event->saveImgs([]);
             }
             $event->saveLocations(Yii::$app->request->post('location'));
             return Yii::$app->getResponse()->redirect($event->getUrl());
         }
     }
     Yii::$app->params['jsZoukVar']['tagsAll'] = Tags::getTags(Tags::TAG_GROUP_ALL);
     return $this->render('add', ['event' => $event]);
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->Id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #4
0
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($date)
 {
     $model = new Event();
     $model->create_date = $date;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect('index');
     } else {
         return $this->renderAjax('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     $categoryModel = new EventCategory();
     $treeParents = TreeHelper::build($categoryModel->find()->addOrderBy('tree')->addOrderBy('lft')->all());
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['index']);
     } else {
         return $this->render('create', ['model' => $model, 'treeParents' => $treeParents]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  *
  * @param $url_key
  * @return string|\yii\web\Response
  * @throws NotFoundHttpException
  */
 public function actionCreate($url_key)
 {
     $model = new Event();
     /* @var $sport Sport*/
     $sport = $this->findSportModel($url_key);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         Yii::$app->session->setFlash('success', Yii::t('app', 'Event wes successfully created.'));
         return $this->redirect(['sport/update', 'url_key' => $model->sport->url_key]);
     } else {
         $model->sport_id = $sport->id;
         return $this->render('create', ['model' => $model]);
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     if ($model->load(Yii::$app->request->post())) {
         $model->created_date = date("Y-m-d h:i:sa");
         $model->updated_date = date("Y-m-d h:i:sa");
         $model->created_by = Yii::$app->user->id;
         $model->updated_by = Yii::$app->user->id;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionEvent()
 {
     $model = new Event();
     $model['title'] = 'Hội thảo Khoa học bệnh Melioidosis tại Việt Nam lần I';
     $model['category_id'] = 1;
     $model['image'] = '/uploads/demo/event/Poster-Hoi-nghi-Vien-VSV2.jpg';
     $model['content'] = 'Melioidosis (hay còn gọi là bệnh Whitmore) là bệnh truyền nhiễm cấp tính nguy hiểm do loài vi khuẩn Burkholderia pseudomallei sống ở trong đất gây nên. Melioidosis có bệnh cảnh lâm sàng đa dạng, tiến triển nhanh và có nguy cơ dẫn đến tử vong cao, với tỷ lệ tử vong trên 50% nếu bệnh nhân không được chẩn đoán sớm và điều trị kháng sinh kịp thời. Từ lâu, Việt Nam được coi là một nước nằm trong vùng có nguy cơ nhiễm bệnh melioidosis cao nhưng thông tin dịch tễ học về tỷ lệ người mắc bệnh gần như không có. Nhiều bác sỹ và cán bộ xét nghiệm vi sinh lâm sàng tại các bệnh viện tuyến vẫn còn chưa để ý và chưa có nhiều kinh nghiệm phản xạ với các ca nhiễm bệnh. Nhằm nâng cao tinh thần cảnh giác trong xét nghiệm, chẩn đoán và điều trị bệnh melioidosis, cũng như cung cấp các kiến thức mới nhất về tình hình dịch bệnh trong nước và trên Thế giới, Viện Vi sinh vật và Công nghệ Sinh học – Đại học Quốc gia Hà Nội tiến hành tổ chức "Hội thảo Khoa học bệnh Melioidosis tại Việt Nam lần thứ 1" với chủ đề "Nâng cao cảnh giác trong xét nghiệm, chẩn đoán và điều trị bệnh melioidosis". Hội thảo có sự tham gia báo cáo của 05 chuyên gia Quốc tế nghiên cứu chuyên sâu về bệnh melioidosis tại các vùng dịch bệnh trên Thế giới và 05 báo cáo viên trong nước.';
     $model['start_date'] = date('Y-m-d H:i:s', time());
     $model['end_date'] = date('Y-m-d H:i:s', time());
     $model['location'] = 'Phòng Hội thảo tầng 1, Tòa nhà ULIS – SUNWAH, Đại học Quốc gia Hà Nội - 144 – Xuân Thủy, Cầu Giấy, Hà Nội';
     $model['status'] = 10;
     if ($model->save()) {
         echo 'Ok';
     }
 }
 /**
  * Creates a new Event model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Event();
     // $user = $this->findModel(Yii::$app->user->id);
     // $model->location = $user->address;
     if ($model->load(Yii::$app->request->post())) {
         $model->eeopen_date = $model->eopen_date;
         $model->organiser_id = Yii::$app->user->id;
         $model->created_date = date("Y-m-d h:i:sa");
         $model->updated_date = date("Y-m-d h:i:sa");
         $model->created_by = Yii::$app->user->id;
         $model->updated_by = Yii::$app->user->id;
         $model->is_active = 1;
         $model->save();
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #10
0
 /**
  * Events
  */
 public function createEvents()
 {
     if (isset($this->registration_start) && $this->registration_start > $now) {
         $event = new Event();
         $event->object_type = $this->competition_type;
         $event->object_id = $this->competition_id;
         $event->category = Event::TYPE_COMPETITION_REGSTART;
         $event->event_start = $this->registration_start;
         $event->save();
     }
     if (isset($this->registration_end) && $this->registration_end > $now) {
         $event = new Event();
         $event->object_type = $this->competition_type;
         $event->object_id = $this->competition_id;
         $event->category = Event::TYPE_COMPETITION_REGEND;
         $event->event_start = $this->registration_end;
         $event->save();
     }
     if (isset($this->start_date) && $this->start_date > $now) {
         $event = new Event();
         $event->object_type = $this->competition_type;
         $event->object_id = $this->competition_id;
         $event->category = Event::TYPE_COMPETITION;
         $event->event_start = $this->start_date;
         $event->save();
     }
 }
 public function makeCopy($new_start)
 {
     $new_start += $this->start % (60 * 60 * 24);
     $new_end = $new_start + ($this->end - $this->start);
     $time_diff = $new_start - $this->start - floor(($new_start - $this->start) / (60 * 60 * 24));
     var_dump($time_diff);
     //Clone event
     $new_event = new Event();
     $new_event->attributes = $this->attributes;
     $new_event->formStart = date(self::DATE_FORMAT, $new_start);
     $new_event->formEnd = date(self::DATE_FORMAT, $new_end);
     $new_event->name = "Copy of " . $this->name;
     $new_event->save();
     //Clone teams
     $old_teams = $this->teams;
     foreach ($old_teams as $old_team) {
         $new_team = new Team();
         $new_team->attributes = $old_team->attributes;
         $new_team->event_id = $new_event->id;
         $new_team->save();
         //Clone shifts
         $old_shifts = $old_team->shifts;
         foreach ($old_shifts as $old_shift) {
             $new_shift = new Shift();
             $new_shift->attributes = $old_shift->attributes;
             $new_shift->team_id = $new_team->id;
             $new_shift->start_time += $time_diff;
             $new_shift->save();
         }
     }
     return $new_event->id;
 }