Example #1
0
 /**
  * Creates a new Project model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Project();
     if ($model->load(Yii::$app->request->post())) {
         $model->status = R::PROJECT_CREATED;
         $model->deadline = date('Y-m-d', strtotime($model->deadline));
         $model->create_time = time();
         $model->update_time = time();
         $model->save();
         if (isset($_POST['stage_name'])) {
             $stage_name = $_POST['stage_name'];
             $stage_description = $_POST['stage_description'];
             $stage_deadline = $_POST['stage_deadline'];
             $stage_who = $_POST['stage_who'];
             foreach ($stage_name as $k => $v) {
                 $stage = new Stage();
                 $stage->name = $v;
                 $stage->description = $stage_description[$k];
                 $stage->deadline = strtotime($stage_deadline[$k]);
                 $stage->user_id = $stage_who[$k];
                 $stage->project_id = $model->id;
                 $stage->status = R::STAGE_CREATED;
                 $stage->create_time = time();
                 $stage->update_time = time();
                 $stage->save();
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #2
0
 /**
  * Creates a new Project model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Project();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
 public function actionCreate()
 {
     $project = new Project();
     if ($project->load(Yii::$app->request->post()) && $project->save()) {
         Yii::$app->getSession()->setFlash("success", 'The record was saved.');
         return $this->redirect(["project/"]);
     }
     return $this->render("create", ["models" => ["project" => $project]]);
 }
Example #4
0
 public function actionCreate()
 {
     if (\Yii::$app->user->isGuest) {
         throw new ForbiddenHttpException('Access denied');
     }
     $model = new Project();
     if ($model->load(\Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['/project/view', 'id' => $model->getPrimaryKey()]);
     }
     return $this->render('create', ['model' => $model]);
 }
 /**
  * Creates a new Project model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Project();
     $user_id = User::find()->where("id=" . Yii::$app->user->id)->one()->id;
     $manager_id = ProjectManager::find()->where("user_id=" . $user_id)->one()->id;
     $model->manager_id = $manager_id;
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         $vacancyValue = $_POST['Project']['vacancy'];
         $newVacancy = new ProjectVacancy();
         $newVacancy->project_id = $model->id;
         $newVacancy->vacancy = $vacancyValue;
         $newVacancy->save();
         $degreesList = $_POST['Project']['degrees1'];
         foreach ($degreesList as $value) {
             $this->createStudentProfile($model->id, $value);
         }
         Yii::$app->getSession()->setFlash('success', 'El proyecto se ha creado exitosamente');
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #6
0
 /**
  * Создание проектов
  * Проверен (21.12.15)
  * Необходимо создать функционал для создания клиента
  * Необходимо вместо выпадающего меню выбора клиента создать AJAX запрос с базы 
  */
 public function actionCreate()
 {
     $model = new Project();
     if ($model->load(Yii::$app->request->post())) {
         $model->status = R::PROJECT_CREATED;
         $model->deadline = date('Y-m-d', strtotime($model->deadline));
         $model->create_time = time();
         $model->update_time = time();
         $model->save();
         if (isset($_POST['stage_name'])) {
             $stage_name = $_POST['stage_name'];
             $stage_description = $_POST['stage_description'];
             $stage_deadline = $_POST['stage_deadline'];
             $stage_who = $_POST['stage_who'];
             foreach ($stage_name as $k => $v) {
                 $stage = new Stage();
                 $stage->name = $v;
                 $stage->description = $stage_description[$k];
                 $stage->deadline = strtotime($stage_deadline[$k]);
                 $stage->user_id = $stage_who[$k];
                 $stage->project_id = $model->id;
                 $stage->status = R::STAGE_CREATED;
                 $stage->notify_status = R::NOTIFY_ACTIVE;
                 $stage->create_time = time();
                 $stage->update_time = time();
                 $stage->save();
                 if ($stage->save()) {
                     Yii::$app->mailer->compose()->setFrom(['*****@*****.**'])->setTo($stage->user->email)->setSubject('Стадия проекта на G5 CRM')->setHtmlBody("\r\n                                " . $stage->user->last_name . " " . $stage->user->first_name . "! <br>\r\n                                К Вам пришла стадия проекта. Пожалуйста, пройдите по \r\n                                <a href='http://78.47.241.234/crm/team/index'>этой</a> ссылке\r\n                                для детального ознакомления. \r\n                            ")->send();
                 }
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #7
0
 /**
  * 复制项目配置
  *
  * @return string
  * @throws \Exception
  */
 public function actionCopy($projectId)
 {
     $project = $this->findModel($projectId);
     // 复制为新项目
     $project->name .= ' - copy';
     $copy = new Project();
     $copy->load($project->getAttributes(), '');
     if (!$copy->save()) {
         throw new \Exception(yii::t('conf', 'copy failed'));
     }
     // 删除ansible配置文件
     if ($project->ansible) {
         copy(Project::getAnsibleHostsFile($project->id), Project::getAnsibleHostsFile($copy->id));
     }
     $this->renderJson([]);
 }
Example #8
0
 /**
  * 复制项目配置
  *
  * @return string
  * @throws \Exception
  */
 public function actionCopy($projectId)
 {
     $project = $this->findModel($projectId);
     // 复制为新项目
     $project->name .= ' - copy';
     $copy = new Project();
     $copy->load($project->getAttributes(), '');
     if (!$copy->save()) {
         throw new \Exception(yii::t('conf', 'copy failed'));
     }
     $this->renderJson([]);
 }
Example #9
0
 /**
  * Creates a new Project model.
  * If creation is successful, the browser will be redirected to the 'overview' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Project();
     $model->loadDefaultValues();
     if ($model->load(Yii::$app->request->post())) {
         $image = UploadedFile::getInstance($model, 'image');
         if (!is_null($image)) {
             // store the source file name
             $model->logoname = $image->name;
             $ext = end(explode(".", $image->name));
             // generate a unique file name
             $model->logo = Yii::$app->security->generateRandomString() . ".{$ext}";
             $path = Yii::$app->basePath . '/web/uploads/' . $model->logo;
         }
         if ($model->save()) {
             if (!is_null($image)) {
                 $image->saveAs($path);
             }
             $member = new Member();
             $member->setAttribute('project_id', $model->id);
             $member->setAttribute('user_id', Yii::$app->user->id);
             $member->setAttribute('role', 'Administrator');
             $member->save();
             return $this->redirect(['overview', 'identifier' => $model->identifier]);
         } else {
             Yii::$app->getSession()->setFlash('danger', Yii::t('app', 'Something went wrong and the settings was not saved.'));
         }
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
Example #10
0
 /**
  * Creates a new Project model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Project();
     $model->scenario = 'create';
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         // Add Twilio Number
         $model->addTwilioNumber();
         Yii::$app->session->setFlash('success', 'Project successfully created');
         return $this->redirect(['update', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }