public function invitation($code) { if (Auth::check()) { $string = base64_decode($code); $ary = explode('-', $string); $email = $ary[0]; $pId = $ary[1]; $user = User::where('email', $email)->first(); if ($user) { $user = $user->toArray(); if (Auth::check()) { if (Auth::user()->email == $user['email']) { ProjectUser::where('project_id', $pId)->where('user_id', $user['id'])->update(['invitation' => 1]); $project = Project::find($pId)->toArray(); $message = 'You are now member of project ' . $project['name']; return Response()->json(ResponseManager::getResult($ary, 10, $message)); } else { Auth::logout(); Session::flush(); $message = 'Please login with the email id on which you receive the invitation.'; return Response()->json(ResponseManager::getError('', 101, $message)); } } else { $message = 'Plese login to accept the invitation'; return Response()->json(ResponseManager::getError('', 1010, $message)); } } else { $message = 'You are not register with us. Please register with us.'; return Response()->json(ResponseManager::getError('', 2020, $message)); } } else { $message = 'Plese login to accept the invitation'; return Response()->json(ResponseManager::getError('', 10, $message)); } }
public function actionSettings($identifier) { $model = Project::find()->identifier($identifier)->one(); if ($model->load(Yii::$app->request->post())) { // store the current logo $old_logo = $model->logo; $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)) { // save the new logo $image->saveAs($path); // get rid of the old logo unlink(Yii::$app->basePath . '/web/uploads/' . $old_logo); } return $this->render('settings', ['model' => $model]); } else { Yii::$app->getSession()->setFlash('danger', Yii::t('app', 'Something went wrong and the settings was not saved.')); } } else { return $this->render('settings', ['model' => $model]); } }
public function store($project_id, $request) { $section = new Section(); $section->fill($request); $project = Project::find($project_id); $project->sections()->save($section); return $section; }
/** * Show the form for editing the specified resource. * GET /tasks/{id}/edit * * @param int $id * @return Response */ public function edit($society, $project, $id) { $data['society'] = $society; $data['task'] = Task::find($id); $data['project'] = Project::find($data['task']->project_id); $data['individuals'] = Individual::all(); return View::make('tasks.edit', $data); }
protected function findModel($id) { $model = Project::find()->andFilterWhere(['OR', ['=', 'user_id', Yii::$app->user->id], ['=', 'executor_id', Yii::$app->user->id]])->andFilterWhere(['id' => $id])->one(); if ($model !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
public function addCommentToProject($id, array $input) { $project = Project::find($id); $mainComment = new Comment(); $mainComment->fill($input); $project->comments()->save($mainComment); $this->linkToCurrentUser($mainComment); return $mainComment; }
public function actionIndex() { if (Yii::$app->user->isGuest) { return $this->render('index'); } else { $projects = Project::find()->byOwner(\Yii::$app->user->identity->id)->all(); return $this->render('dashboard', ['projects' => $projects]); } }
/** * Главный экшн для клиента это отчеты которые пришли от менеджера * Проверен (21.12.15) */ public function actionReports() { //Сессия необходима для создания временного файла для хранения картинок до создания товара $session = new Session(); $session->open(); //cs - CREATE SESSION ID $session['cs_' . Yii::$app->user->identity->id] = md5(time() . rand(0, 10000)); $projects = Project::find()->where(['for_user_id' => Yii::$app->user->identity->id])->all(); return $this->render('reports', compact('projects')); }
public function addComment($projectId) { $user = \Auth::user(); $comment = new Comment(); $comment->comment = \Input::get("comment"); $project = Project::find($projectId); $project->comments()->save($comment); $comment->createdBy()->save($user); return redirect("/users/project/{$projectId}"); }
/** * 配置项目列表 * */ public function actionIndex() { $project = Project::find()->where(['user_id' => $this->uid]); $kw = \Yii::$app->request->post('kw'); if ($kw) { $project->andWhere(['like', "name", $kw]); } $project = $project->asArray()->all(); return $this->render('index', ['list' => $project]); }
/** * 配置项目列表 * */ public function actionIndex() { // 显示该用户为管理员的所有项目 $project = Project::find()->leftJoin(Group::tableName(), '`group`.`project_id`=`project`.`id`')->where(['`group`.`user_id`' => $this->uid, '`group`.`type`' => Group::TYPE_ADMIN]); $kw = \Yii::$app->request->post('kw'); if ($kw) { $project->andWhere(['like', "name", $kw]); } $project = $project->asArray()->all(); return $this->render('index', ['list' => $project]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'is_public' => $this->is_public, 'status_id' => $this->status_id, 'creator_id' => $this->creator_id, 'created_date' => $this->created_date, 'updated_date' => $this->updated_date]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
public function actionCategory($url = null) { $query = Project::find(); $addition = Project::find()->select('id')->orderBy('id ASC')->limit(3)->asArray()->all(); if (!is_null($url)) { $query->innerJoinWith('category', 'category_id = category_id')->where(['url' => $url]); } $dataProvider = new \yii\data\ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 9]]); $projectModel = Project::find()->joinWith('category', 'category.category_id = project.category_id')->orderBy('id ASC')->limit(3)->all(); return $this->render('category', ['dataProvider' => $dataProvider, 'categoryModel' => Category::find()->all(), 'customerModel' => Customer::find()->all(), 'projectModel' => $projectModel]); }
public function actionIndex() { $model = new Messenger(); $projectResult = Project::find()->all(); if ($model->load(Yii::$app->request->post())) { $model->read_chk = 0; $model->del_chk = 0; $model->date = date("Y/m/d H:i:s"); $model->save(); } return $this->render('index', ['model' => $model, 'projectResult' => $projectResult]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($user, $project_name, Request $request) { $project_id = $request->query('id'); $project = Project::find($project_id); if (is_null($project)) { $project = Session::get('project'); } $stories = Story::where('project_id', $project->id)->get(); $count = $stories->count(); $points = $stories->sum('story_point'); return view('user.project.show', compact('project', 'project_name', 'user', 'project_id', 'stories', 'points', 'count')); }
public function actionIndex() { $categoryModel = Category::find()->All(); $projectModel = Project::find()->where(['show_in_index' => '1'])->limit(6)->all(); $customerModel = Customer::find()->All(); $applicationConfig = ApplicationConfig::find()->one(); $newsModel = News::find()->where(['show_in_index' => '1'])->limit(2)->all(); $galleryModel = Gallery::find()->orderBy(new Expression('rand()'))->limit(6)->all(); $visitor = ApplicationConfig::findOne(1); $visitor->visitors_count = $visitor->visitors_count + 1; $visitor->save(); return $this->render('index', ['categoryModel' => $categoryModel, 'projectModel' => $projectModel, 'customerModel' => $customerModel, 'applicationConfig' => $applicationConfig, 'newsModel' => $newsModel, 'galleryModel' => $galleryModel]); }
public function rejectProject($id, array $input) { $project = Project::find($id); if ($project) { /* @var Project $project*/ if ($project->status->key == 'university') { $this->linkToFacultyStatus($project, $input); $this->linkToSuggestion($project, $input); } else { return \Response::json(["error" => "There is something wrong, Please contact administrator."], 400); } } }
/** * Updates an existing Trip model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->idusers == Yii::$app->user->id) { if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'userdata' => Userdata::find()->all(), 'direction' => Direction::find()->asArray()->all(), 'project' => Project::find()->asArray()->all(), 'prikaz' => Prikaz::find()->asArray()->all()]); } } else { throw new NotFoundHttpException('РЕДАКТИРОВАТЬ МОЖЕТ ТОЛЬКО РЕГИСТРАТОР ДАННОЙ КОМАНДИРОВКИ'); } }
/** * @param $project_id * @param bool $force * * @return Video * @throws Swf2VidError */ public function queueProject($project_id, $force = false) { if ($project = Project::find($project_id)) { if (($credits = $this->getVideoCredits($project->user_id)) || $force) { Video::update_all(['set' => ['vid_status' => 'ignore'], 'conditions' => ['project_id = ? and vid_status = ?', $project_id, 'pending']]); return Video::create_direct(['user_id' => $project->user_id, 'project_id' => $project_id, 'vid_status' => 'pending']); } else { App::getInstance()->dispatch(Swf2VidEvent::VIDEO_NO_CREDITS, new Swf2VidEvent($project->user_id, $project)); throw new Swf2VidError("Out of credits"); } } else { throw new Swf2VidError("Project not found", $project_id); } }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'public' => $this->public, 'created' => $this->created, 'modified' => $this->modified]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'homepage', $this->homepage])->andFilterWhere(['like', 'identifier', $this->identifier]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['name_project' => SORT_ASC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id]); $query->andFilterWhere(['like', 'name_project', $this->name_project]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function searchDone($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status, 'deadline' => $this->deadline, 'create_time' => $this->create_time, 'update_time' => $this->update_time]); $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['status' => R::PROJECT_DONE]); return $dataProvider; }
/** * 配置项目列表 * */ public function actionIndex() { // 为了方便用户更改表名,避免表名直接定死 $groupTable = Group::tableName(); $projectTable = Project::tableName(); // 显示该用户为管理员的所有项目 $project = Project::find()->leftJoin(Group::tableName(), "`{$groupTable}`.`project_id`=`{$projectTable}`.`id`")->where(["`{$groupTable}`.`user_id`" => $this->uid, "`{$groupTable}`.`type`" => Group::TYPE_ADMIN]); $kw = \Yii::$app->request->post('kw'); if ($kw) { $project->andWhere(['like', "name", $kw]); } $project = $project->asArray()->all(); return $this->render('index', ['list' => $project]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['like', 'title', $this->title]); $query->orderBY('date DESC'); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['project_id' => $this->project_id, 'create_user_id' => $this->create_user_id, 'regist_date' => $this->regist_date, 'update_date' => $this->update_date, 'del_chk' => $this->del_chk]); $query->andFilterWhere(['like', 'name', $this->name]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'sort' => $this->sort, 'is_active' => $this->is_active, 'is_deleted' => $this->is_deleted, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'deleted_at' => $this->deleted_at]); $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'status' => $this->status]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
public function search($params) { $query = Project::find(); if (Yii::$app->user->identity->isViewingProject) { $query->where(["id" => Yii::$app->user->identity->fkIDWithProjectID]); } $activeDataProvider = new ActiveDataProvider(["query" => $query, "pagination" => ["pageSize" => 20]]); $activeDataProvider->sort->attributes["countInCompletedMilestones"] = ["asc" => [$this->countInCompletedMilestonesSQL => SORT_ASC], "desc" => [$this->countInCompletedMilestonesSQL => SORT_DESC]]; $activeDataProvider->sort->attributes["countCompletedMilestones"] = ["asc" => [$this->countCompletedMilestonesSQL => SORT_ASC], "desc" => [$this->countCompletedMilestonesSQL => SORT_DESC]]; if (!$this->load($params) || !$this->validate()) { return $activeDataProvider; } $query->andFilterWhere(["like", "id", $this->id])->andFilterWhere(["like", "name", $this->name])->andFilterWhere(["like", $this->countInCompletedMilestonesSQL, $this->countInCompletedMilestones])->andFilterWhere(["like", $this->countCompletedMilestonesSQL, $this->countCompletedMilestones])->andFilterWhere(["like", "dueDate", !empty($this->dueDate) ? Yii::$app->formatter->asDate($this->dueDate, "Y-MM-dd") : null])->andFilterWhere(["like", "completed", $this->completed]); return $activeDataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Project::find(); $query->joinWith(['degrees']); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['project.id' => $this->id, 'degree.id' => $this->degree_id]); $query->andFilterWhere(['like', 'project.name', $this->name]); return $dataProvider; }
public function notifyStageBid() { if (Yii::$app->user->identity->role == R::DESIGNER || Yii::$app->user->identity->role == R::FRONTEND || Yii::$app->user->identity->role == R::COPYRIGHTER || Yii::$app->user->identity->role == R::PROTOTYPER || Yii::$app->user->identity->role == R::TESTER || Yii::$app->user->identity->role == R::BACKEND || Yii::$app->user->identity->role == R::CONTENTER) { // Samy tupoi variant reweniya uvedomleny $bids = Bid::find()->where(['user_id' => Yii::$app->user->identity->id, 'status' => [R::BID_REFUSED_BY_MANAGER, R::BID_REFUSED_BY_CLIENT, R::BID_APPROVED_BY_MANAGER, R::BID_APPROVED_BY_CLIENT, R::BID_DONE], 'notify_status' => R::NOTIFY_ACTIVE, 'bid_type' => R::BID_STAGE])->all(); foreach ($bids as $bid) { // if ($bid->notify_times == 1) { $bid->notify_status = R::NOTIFY_NOTIFIED; $bid->save(); // } else { // $bid->notify_times += 1; // $bid->save(); // } } } if (Yii::$app->user->identity->role == R::ADMIN) { // Samy tupoi variant reweniya uvedomleny $bids = Bid::find()->where(['status' => [R::BID_SENT_TO_MANAGER, R::BID_REFUSED_BY_CLIENT, R::BID_APPROVED_BY_CLIENT], 'notify_status' => R::NOTIFY_ACTIVE, 'bid_type' => R::BID_STAGE])->all(); foreach ($bids as $bid) { // if ($bid->notify_times == 1) { $bid->notify_status = R::NOTIFY_NOTIFIED; $bid->save(); // } else { // $bid->notify_times += 1; // $bid->save(); // } } } if (Yii::$app->user->identity->role == R::CLIENT) { $projects = Project::find()->where(['for_user_id' => Yii::$app->user->identity->id])->all(); foreach ($projects as $project) { foreach ($project->stages as $stage) { foreach ($stage->bids as $bid) { if ($bid->status == R::BID_SENT_TO_CLIENT && $bid->notify_status == R::NOTIFY_ACTIVE) { // if ($bid->notify_times == 2) { $bid->notify_status = R::NOTIFY_NOTIFIED; $bid->save(); // } else { // $bid->notify_times += 1; // $bid->save(); // } } } } } } }