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]);
     }
 }
 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 #3
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 addProject(array $input)
 {
     $project = new Project();
     $project->fill($input);
     $project->save();
     $this->linkToCurrentUser($project, $input);
     $this->linkToFaculty($project, $input);
     $this->linkToDraftStatus($project, $input);
     return $project;
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $firstCondition = new Condition(['type' => 'if', 'field' => 'event.type', 'operator' => '==', 'value' => 'push']);
     $firstCondition->save();
     $splitter = new Splitter();
     $splitter->save();
     $firstSplit = new Split();
     $firstSplit->save();
     $secondSplit = new Split();
     $secondSplit->save();
     $secondCondition = new Condition(['type' => 'contains', 'field' => '', 'operator' => '==', 'value' => '']);
     $secondCondition->save();
     $firstAction = new Action(['type' => 'ssh']);
     $host = new Host(['host' => 'ssh', 'port' => '22']);
     $auth = new Auth();
     $accountAuth = new AuthAccount();
     $accountAuth->username = getenv('SSH_USERNAME');
     $accountAuth->password = getenv('SSH_PASSWORD');
     $accountAuth->save();
     try {
         $file = new File();
         $keyAuth = new AuthKey();
         $keyAuth->username = '******';
         $keyAuth->key = $file->get('.docker/builds/ssh/ssh_keys/id_rsa');
         $keyAuth->key_public = $file->get('.docker/builds/ssh/ssh_keys/id_rsa.pub');
         $keyAuth->save();
     } catch (Illuminate\Filesystem\FileNotFoundException $exception) {
         dump("SSH Key Not Found");
     }
     $auth->credentials()->associate($keyAuth);
     $auth->save();
     $host->auth()->associate($auth);
     $host->save();
     $firstAction->host()->associate($host);
     $firstAction->save();
     $firstAction->addCommand('touch testing');
     $firstAction->addCommand('ls');
     $secondAction = new Action();
     $secondAction->save();
     $secondAction->addCommand('composer install');
     $secondCondition->successPipeable()->associate($secondAction)->save();
     $firstSplit->pipeable()->associate($secondCondition);
     $secondSplit->pipeable()->associate($firstAction);
     $splitter->splits()->save($firstSplit);
     $splitter->splits()->save($secondSplit);
     $firstCondition->successPipeable()->associate($splitter)->save();
     $project = new Project();
     $project->name = 'example';
     $project->group = 'exampleGroup';
     $project->url = 'http://localhost/exampleGroup/example';
     $project->project_id = 2;
     $project->save();
     $project->conditions()->save($firstCondition);
 }
Example #6
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]);
 }
Example #7
0
 public function actionCreateproject()
 {
     $projectModel = new Project();
     $projectModel->attributes = $_POST['Project'];
     $projectModel->startDate = date('Y-m-d', strtotime($_POST['Project']['startDate']));
     $projectModel->endDate = date('Y-m-d', strtotime($_POST['Project']['endDate']));
     $projectModel->delayedDeliveryDate = date('Y-m-d', strtotime($_POST['Project']['delayedDeliveryDate']));
     if ($projectModel->save()) {
         Yii::$app->getSession()->setFlash('success', 'Project has been added successfully');
         return $this->redirect(['index']);
     }
 }
Example #8
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|unique:projects|max:255', 'description' => 'required', 'project_type_id' => 'required', 'image' => 'required']);
     $image = ImageuploadFacade::upload($request->file('image'));
     $project = new Project();
     $project->name = $request->input('name');
     $project->description = $request->input('description');
     $project->client = $request->input('client');
     $project->image = $image['basename'];
     $project->image_ext = $image['original_extension'];
     $project->project_type_id = $request->input('project_type_id');
     $project->save();
     return back();
 }
 /**
  *
  * @param $payer_email
  * @param $description
  * @param $rate
  * @return Project
  */
 public function createProject($payer_email, $description, $rate)
 {
     $project = new Project(['description' => $description, 'rate_per_hour' => $rate]);
     // @TODO Check if the user was added as payer before!! :)
     $payer = User::whereEmail($payer_email)->firstOrFail();
     $payee = Auth::user();
     $project->payer()->associate($payer);
     $project->payee()->associate($payee);
     $project->save();
     //Pusher
     $pusher = new Pusher(env('PUSHER_PUBLIC_KEY'), env('PUSHER_SECRET_KEY'), env('PUSHER_APP_ID'));
     $data = ['payee_id' => Auth::user()->id, 'payer_id' => $payer->id, 'project' => $project, 'message' => Auth::user()->name . ' would like to start a new project with you, with the description \'' . $project->description . ',\' and at $' . $rate . '/hour. Is this ok?'];
     $pusher->trigger('channel', 'insertProject', $data);
     return $project;
 }
 public function store(CreateProjectRequest $request, Project $project)
 {
     //$obj = $project->create($request->all());
     $project->user_id = $request->user_id;
     $project->client_id = $request->clt_id;
     $project->title = $request->title;
     $project->slug = $request->slug;
     $project->unit = $request->unit;
     $project->tags = $request->tags;
     $project->desc = $request->desc;
     $project->authorized_users = $request->authorized_users;
     $project->status = $request->status;
     //		dd($project->all());
     $project->save();
     return redirect()->route('projects.index');
 }
 /**
  * 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 #12
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 #13
0
 public function postUpdateproject(ProjectFormRequest $request)
 {
     $step = $request->get('step');
     $secret_key = $request->get('_secret_key_');
     if (empty($secret_key)) {
         $project = new Project();
         $project->fill($request->except('_token'));
         $project->user_id = $request->input('user_id');
         $project->slug = Str::slug($request->input('name'));
         # Attach file with project
         if ($request->hasFile('file_attachment')) {
             $response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth]));
             if (count($response) > 0) {
                 $project->file_attachment = $response[0];
             }
         }
         # Attach file with project : End
         if ($project->save()) {
             $auto_id = $project->id;
             //$secret_id = Crypt::encrypt($auto_id);
             $request->session()->flash('alert-success', 'Project has been updated successfully');
             $step = $step + 1;
             Session::put('editfstep', $step);
             Session::put('editfs_id', $auto_id);
             return \Redirect::to('/project/projectedit');
         } else {
             Session::put('editfstep', $step);
             $request->session()->flash('alert-warning', 'Error on project creation ! ');
             return redirect()->back()->withInput();
         }
     } else {
         $project_id = $secret_key;
         if ($step == 1) {
             $project = Project::find($project_id);
             $project->fill($request->except('_token'));
             $project->slug = Str::slug($request->input('name'));
             if ($request->hasFile('file_attachment')) {
                 $response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth]));
                 if (count($response) > 0) {
                     $project->file_attachment = $response[0];
                 }
             }
             if ($project->save()) {
                 $request->session()->flash('alert-success', 'Project has been updated successfully');
                 $step = $step + 1;
                 Session::put('editfstep', $step);
                 return \Redirect::to('/project/projectedit');
             }
         }
         if ($step == 2) {
             $projectData = array();
             $projectData['details_description'] = $request->get('details_description');
             $projectData['address'] = $request->get('address');
             $projectData['address_alternate'] = $request->get('address_alternate');
             $projectData['city'] = $request->get('city');
             $projectData['state'] = $request->get('state');
             $projectData['country_id'] = $request->get('country_id');
             $projectData['feed_url'] = $request->get('feed_url');
             $projectData['pincode'] = $request->get('pincode');
             $projectData['external_video_url'] = $request->get('external_video_url');
             //$projectData['media_file_attachment'] = $request->get('media_file_attachment');
             $projectData['media_file_short_note'] = $request->get('media_file_short_note');
             if ($request->hasFile('media_file_attachment')) {
                 $response = Event::fire(new FileAttachment($request, ['input_file_tag' => 'media_file_attachment', 'width' => $this->width, 'height' => $this->height, 'mHeight' => $this->mHeight, 'mWidth' => $this->mWidth]));
                 if (count($response) > 0) {
                     $projectData['media_file_attachment'] = $response[0];
                 }
             }
             if (Project::where('id', $project_id)->update($projectData)) {
                 $request->session()->flash('alert-success', 'Project has been updated successfully');
                 $step = $step + 1;
                 Session::put('editfstep', $step);
                 return \Redirect::to('/project/projectedit');
             } else {
                 Session::put('editfstep', $step);
                 $request->session()->flash('alert-warning', 'Error on project creation ! ');
                 return redirect()->back()->withInput();
             }
         }
         if ($step == 3) {
             $projectData = array();
             //dd( $request->all());
             $reward_row_count = $request->get('reward_row_count');
             $past_row_count = $request->get('past_row_count');
             $pledge_amount = $request->get('pledge_amount');
             $short_note = $request->get('short_note');
             $user_limit = $request->get('user_limit');
             $delevery_year = $request->get('delevery_year');
             $delevery_month = $request->get('delevery_month');
             $shipping_details = $request->get('shipping_details');
             $present_id = $request->get('editid');
             $file = $request->file('file_attachment');
             $startcounter = $past_row_count + 1;
             $endcounter = $reward_row_count - 1;
             if (count($pledge_amount) > 0) {
                 $rewardsData = array();
                 for ($k = 0; $k <= $past_row_count; $k++) {
                     /* $reward = new Reward(); */
                     $rewaedid = $present_id[$k];
                     $reward = Reward::find($rewaedid);
                     if (Reward::find($rewaedid)) {
                         if ($file[$k] != '') {
                             $imageName = uniqid('project-reward-', true) . '.' . $file[$k]->getClientOriginalExtension();
                             $realPath = base_path() . '/public/images/file-attached-to-project/';
                             $resizePath = base_path() . '/public/images/file-attached-to-project/resize/' . $imageName;
                             $openMakePath = $realPath . $imageName;
                             $file[$k]->move($realPath, $imageName);
                             Image::make($openMakePath)->resize(1400, 623)->save($resizePath);
                             $reward->reword_image = $imageName;
                         }
                         $reward->pledge_amount = $pledge_amount[$k];
                         $reward->short_note = $short_note[$k];
                         $reward->user_limit = $user_limit[$k];
                         $reward->delevery_year = $delevery_year[$k];
                         $reward->delevery_month = $delevery_month[$k];
                         $reward->shipping_details = $shipping_details[$k];
                         $reward->P_ID = $project_id;
                         $reward->active = 1;
                         $reward->save();
                     }
                 }
                 for ($m = $startcounter; $m <= $endcounter; $m++) {
                     $addreward = new Reward();
                     if ($file[$k] != '') {
                         $imageName = uniqid('project-reward-', true) . '.' . $file[$k]->getClientOriginalExtension();
                         $realPath = base_path() . '/public/images/file-attached-to-project/';
                         $resizePath = base_path() . '/public/images/file-attached-to-project/resize/' . $imageName;
                         $openMakePath = $realPath . $imageName;
                         $file[$k]->move($realPath, $imageName);
                         Image::make($openMakePath)->resize(1400, 623)->save($resizePath);
                         $addreward->reword_image = $imageName;
                     }
                     $addreward->pledge_amount = $pledge_amount[$m];
                     $addreward->short_note = $short_note[$m];
                     $addreward->user_limit = $user_limit[$m];
                     $addreward->delevery_year = $delevery_year[$m];
                     $addreward->delevery_month = $delevery_month[$m];
                     $addreward->shipping_details = $shipping_details[$m];
                     $addreward->P_ID = $project_id;
                     $addreward->active = 1;
                     $addreward->save();
                 }
                 $step = $step + 2;
                 Session::put('editfstep', $step);
                 return \Redirect::to('/project/projectedit');
             }
         }
     }
 }
Example #14
0
 public function store(array $input)
 {
     $project = new Project();
     $project->fill($input);
     $project->save();
     $this->linkToFaculty($project, $input);
     $this->linkToStatus($project, $input);
     $this->linkToUser($project, $input);
     return $project;
 }
 public function store($request)
 {
     $project = new Project();
     $project->fill($request);
     $project->save();
     /**
      * Membros
      */
     foreach ($request['members'] as $user_id) {
         $user = User::find($user_id);
         $project->members()->save($user);
     }
     /**
      * Categorias
      */
     foreach ($request['categories'] as $category_id) {
         $category = Category::find($category_id);
         $project->categories()->save($category);
     }
     return $project;
 }
Example #16
0
 /**
  * Return a fresh instance of the model (called on `create()`).
  *
  * @return \Illuminate\Database\Eloquent\Model
  */
 protected function make()
 {
     $model = new Project();
     $model->save();
     return $model;
 }
Example #17
0
 public static function createProject($consultantId, $leadId, $ideaName, $ideaConcept, $hisIdea, $similarProduct, $probIdea, $status)
 {
     $project = new Project();
     $project->consultant_id = $consultantId;
     $project->lead_id = $leadId;
     $project->ideaName = $ideaName;
     $project->ideaConcept = $ideaConcept;
     $project->hisIdea = $hisIdea;
     $project->similarProduct = $similarProduct;
     $project->probIdea = $probIdea;
     $project->status = $status;
     $project->save();
     return $project->id;
 }
 public function store(Request $request)
 {
     $project = new Project();
     $project->project_name = $request->input('project_name');
     $project->project_type = $request->input('project_type');
     $project->project_description = $request->input('project_description');
     $project->project_budget = $request->input('project_budget');
     $project->project_timeline = $request->input('project_timeline');
     $project->project_size = $request->input('project_size');
     $project->project_framework = $request->input('project_framework');
     $project->project_theme = $request->input('project_theme');
     $project->project_cms = $request->input('project_cms');
     $lead = new Lead();
     $lead->lead_name = $request->input('lead_name');
     $lead->lead_company = $request->input('lead_company');
     $lead->lead_email = $request->input('lead_email');
     $lead->lead_phone = $request->input('lead_phone');
     $lead->lead_address = $request->input('lead_address');
     $lead->lead_city = $request->input('lead_city');
     $lead->lead_state = $request->input('lead_state');
     $lead->lead_zip = $request->input('lead_zip');
     $lead->lead_type = $request->input('lead_type');
     $lead->lead_focus = $request->input('lead_focus');
     $lead->lead_involvement = $request->input('lead_involvement');
     $lead->lead_boss = $request->input('lead_boss');
     $lead->save();
     // link the new project and lead together in the database
     $project->user_id = Auth::user()->id;
     $project->lead_id = $lead->id;
     $project->save();
     return redirect('projects');
 }
Example #19
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 #20
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 #21
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]);
     }
 }