public function search($params, $dueDateOperator = null, $dueDate = null, $inCompleted = false) { $query = Task::find(); $query->joinWith(["milestone.project", "milestone", "user"]); if (Yii::$app->user->identity->isViewingProject) { $query->andWhere(["project.id" => Yii::$app->user->identity->fkIDWithProjectID]); } if ($dueDateOperator != null && $dueDate != null) { $query->andWhere("task.dueDate " . $dueDateOperator . " '" . $dueDate . "'"); } if ($inCompleted) { $query->andWhere(["task.completed" => 0]); } $activeDataProvider = new ActiveDataProvider(["query" => $query, "pagination" => ["pageSize" => 20]]); $activeDataProvider->sort->attributes["userFullName"] = ["asc" => ["user.fullName" => SORT_ASC], "desc" => ["user.fullName" => SORT_DESC]]; $activeDataProvider->sort->attributes["projectName"] = ["asc" => ["project.name" => SORT_ASC], "desc" => ["project.name" => SORT_DESC]]; $activeDataProvider->sort->attributes["milestoneName"] = ["asc" => ["milestone.name" => SORT_ASC], "desc" => ["milestone.name" => SORT_DESC]]; if (!$this->load($params) || !$this->validate()) { if (Yii::$app->user->identity->defaultTasksAssignedToMe) { $this->userFullName = Yii::$app->user->id; } return $activeDataProvider; } $query->andFilterWhere(["like", "task.id", $this->id])->andFilterWhere(["like", "task.name", $this->name])->andFilterWhere(["like", "user.id", $this->userFullName])->andFilterWhere(["like", "project.name", $this->projectName])->andFilterWhere(["like", "milestone.name", $this->milestoneName])->andFilterWhere(["like", "task.dueDate", !empty($this->dueDate) ? Yii::$app->formatter->asDate($this->dueDate, "Y-MM-dd") : null])->andFilterWhere(["like", "task.completed", $this->completed]); return $activeDataProvider; }
/** * */ public function actionView() { /** @var User[] $users */ $users = User::find()->all(); /** @var Task[] $tasks */ $tasks = Task::find()->all(); foreach ($users as $user) { echo 'Username : '******'TimeZone : ' . $user->timeZone . "\n"; echo 'Tasks : ' . "\n"; foreach ($tasks as $task) { echo "\t" . 'Task : ' . $task->title . "\n"; \Yii::$app->formatter->timeZone = 'UTC'; echo "\t" . 'Time UTC start : ' . \Yii::$app->formatter->asDatetime($task->timeStart) . "\n"; echo "\t" . 'Time UTC end : ' . \Yii::$app->formatter->asDatetime($task->timeEnd) . "\n\n"; \Yii::$app->formatter->timeZone = $user->timeZone; echo "\t" . 'Time ' . $user->timeZone . ' start : ' . \Yii::$app->formatter->asDatetime($task->timeStart) . "\n"; echo "\t" . 'Time ' . $user->timeZone . ' end : ' . \Yii::$app->formatter->asDatetime($task->timeEnd) . "\n"; echo "\t--------\n"; // timestamp wont change if we apply timezone // $date = new \DateTime(); // $date->setTimestamp($task->timeStart); // $date->setTimezone(new \DateTimeZone($user->timeZone)); // echo $task->timeStart . ' => ' . $date->getTimestamp() . "\n"; // same timestamp } echo "=========== \n"; } }
public function actionDashboard() { $searchModel = new WindowSearch(); $searchModel->dateFrom = date('Y-m-d'); $searchModel->dateTo = date('Y-m-d'); $dataProvider = $searchModel->search(Yii::$app->request->post()); // eagerly load process info $dataProvider->query->with('process'); $from = strtotime('today', $searchModel->timestampFrom); $to = strtotime('tomorrow', $searchModel->timestampTo); $processList = StatsHelper::getProcessList($from, $to); $this->view->registerJs('var dashboardProcess = ' . json_encode($processList), View::POS_HEAD); $timeline = StatsHelper::timeline($from, $to); $this->view->registerJs('var dashboardTimeline = ' . json_encode($timeline), View::POS_HEAD); $this->view->registerAssetBundle(ColorStripAsset::className()); // Durations split by process $durations = StatsHelper::getProcessWindowHierarchy($from, $to); $this->view->registerJs('var dashboardDurations = ' . json_encode($durations), View::POS_HEAD); $this->view->registerAssetBundle(SunburstAsset::className()); // Durations split by task $durations = StatsHelper::getTaskWindowHierarchy($from, $to); $this->view->registerJs('var dashboardTaskDurations = ' . json_encode($durations), View::POS_HEAD); // Keys $keysActivity = StatsHelper::keysActivity($from, $to); $this->view->registerJs('var dashboardKeys = ' . json_encode($keysActivity), View::POS_HEAD); $this->view->registerAssetBundle(KeysAsset::className()); $this->view->registerAssetBundle(KeysAreaAsset::className()); $this->clusterChart($searchModel); $tasks = array_map(function ($task) { return ['id' => $task->id, 'name' => $task->name]; }, Task::find()->all()); $this->view->registerJs('var dashboardTasks = ' . json_encode($tasks), View::POS_HEAD); $this->view->registerAssetBundle(DashboardAsset::className()); return $this->render('dashboard', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel, 'totalActivity' => StatsHelper::totalActivity($from, $to)]); }
public function actionIndex() { $user = Yii::$app->user; $dashboard = []; if ($user->can('partner_view')) { $dashboard[] = ['name' => Html::tag('b', __('Partners')), 'link' => Url::to(['partner/index']), 'count' => Partner::find()->count()]; } if ($user->can('visit_view') || $user->can('visit_view_all')) { $dashboard[] = ['name' => __('Visits'), 'link' => Url::to(['visit/index']), 'count' => Visit::find()->count()]; } if ($user->can('donate_view') || $user->can('donate_view_all')) { $dashboard[] = ['name' => __('Donates'), 'link' => Url::to(['donate/index']), 'count' => Donate::find()->count()]; } if ($user->can('task_view') || $user->can('task_view_all')) { $dashboard[] = ['name' => __('Tasks'), 'link' => Url::to(['task/index']), 'count' => Task::find()->count()]; } if ($user->can('newsletter_view')) { $dashboard[] = ['name' => __('Mailing lists'), 'link' => Url::to(['mailing-list/index']), 'count' => MailingList::find()->count()]; $dashboard[] = ['name' => __('Newsletters'), 'link' => Url::to(['newsletter/index']), 'count' => Newsletter::find()->count()]; $dashboard[] = ['name' => __('Printing templates'), 'link' => Url::to(['print-template/index']), 'count' => PrintTemplate::find()->count()]; } if ($user->can('user_manage')) { $dashboard[] = ['name' => __('Users'), 'link' => Url::to(['user/index']), 'count' => User::find()->count()]; } return $this->render('index', ['dashboard' => $dashboard]); }
/** * Returns first nearest tasks * @param int $iTotalCount if provided total count will be returned to this value * @return Task[] */ public static function getTasksNearest(&$iTotalCount = 0) { $query = Task::find()->where(['closed' => 0])->orderBy('date')->limit(10); if (func_num_args()) { $iTotalCount = $query->count(); } return $query->andWhere('date')->all(); }
/** * Lists all Task models. * @return mixed */ public function actionIndex() { if (($role = priviledge::getRole()) == 'Admin') { $dataProvider = new ActiveDataProvider(['query' => Task::find(), 'pagination' => ['pageSize' => 15]]); return $this->render('index', ['dataProvider' => $dataProvider]); } else { throw new ForbiddenHttpException(); } }
/** * Выборка из базы данных с сортировкой и отрисовка главного view * @return view */ public function actionIndex() { //Определение языка SiteController::locale(); //Выборка из таблицы tasks с комментариями из comments, отсортированные по дате и активности $data = Task::find()->with('comment')->orderBy(['status' => SORT_DESC, 'date' => SORT_DESC])->all(); //Отрисовка главного представления return $this->render('index', ['data' => $data]); }
public function destroy() { $task = Task::find(Input::get("id")); if (!$task) { return response()->json(['status' => 'error', 'msg' => "Invalid task!"]); } $task->delete(); return response()->json(['status' => 'success']); }
/** * Displays a single Goal model. * @param $alias * @return mixed */ public function actionView($alias) { $goal = $this->findModel(['alias' => $alias]); $id = $goal->id; $logRows = Log::find()->where(['goal_id' => $id])->orderBy('created_at DESC')->limit(5)->all(); $taskQuery = Task::find()->where(['goal_id' => $id, 'closed' => 0])->orderBy('date')->limit(5); $taskRows = $taskQuery->all(); $taskCount = $taskQuery->count(); return $this->render('view', ['goal' => $goal, 'logRows' => $logRows, 'taskRows' => $taskRows, 'taskCount' => $taskCount, 'logModel' => new Log(['goal_id' => $id])]); }
/** * Updates an existing Report 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); $tasks = Task::find(['deleted' => '0'])->all(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id]); } else { return $this->render('update', ['model' => $model, 'tasks' => $tasks]); } }
public function find() { if ($this->ids) { return TaskModel::find()->where(['id' => $this->ids])->orderBy(['created_at' => SORT_DESC]); } else { $search = new TaskSearch(); $dataProvider = $search->search($this->queryParams); $dataProvider->pagination = false; return $dataProvider->query; } }
/** * Expose data to Javascript * @throws \yii\base\InvalidConfigException */ public function exposeData() { $searchModel = new WindowSearch(); $searchModel->date = date('Y-m-d'); $dataProvider = $searchModel->search(Yii::$app->request->post()); // eagerly load process info $dataProvider->query->with('process'); $from = strtotime('today', $searchModel->timestamp); $to = strtotime('tomorrow', $searchModel->timestamp); $processList = StatsHelper::getProcessList($from, $to); $this->exposeToJs('dashboardProcess', $processList); $timeline = StatsHelper::timeline($from, $to); $this->exposeToJs('dashboardTimeline', $timeline); // $this->view->registerAssetBundle(ColorStripAsset::className()); // Durations split by process $durations = StatsHelper::getProcessWindowHierarchy($from, $to); $this->exposeToJs('dashboardDurations', $durations); // $this->view->registerAssetBundle(SunburstAsset::className()); // Durations split by task $durations = StatsHelper::getTaskWindowHierarchy($from, $to); $this->exposeToJs('dashboardTaskDurations', $durations); // Keys $keysActivity = StatsHelper::keysActivity($from, $to); $this->exposeToJs('dashboardKeys', $keysActivity); $this->view->registerAssetBundle(KeysAsset::className()); $this->view->registerAssetBundle(KeysAreaAsset::className()); $this->clusterChart($searchModel); $tasks = array_map(function ($task) { return ['id' => $task->id, 'name' => $task->name]; }, Task::find()->all()); $this->exposeToJs('dashboardTasks', $tasks); $this->view->registerAssetBundle(DashboardAsset::className()); // Transition matrix $transitionMatrix = StatsHelper::transitionMatrix($from, $to, 30000); $windows = StatsHelper::windows($from, $to); $windowList = StatsHelper::windowsList($windows); $links = $transitionMatrix->flatten(Matrix::FLATTEN_MATRIX_BY_ID); $clusters = $transitionMatrix->clusterization()->mapToClusters(array_values(ArrayHelper::map($windowList, 'id', 'id'))); foreach ($windowList as $key => &$w) { $w['cluster'] = (int) $clusters[$key]; } $this->exposeToJs('dashboardWindows', $windowList); $this->exposeToJs('dashboardLinks', $links); $this->view->registerAssetBundle(D3TipAsset::className()); // $graphJson = AlchemyHelper::buildData($transitionMatrix, $windows, $winIdCluster); // // $this->view->registerJs( // 'var dashboardGraphJson = ' . json_encode($graphJson), // View::POS_HEAD); }
public function searchChild($params) { $query = Task::find(); $query->where(['task_from' => Yii::$app->user->id]); $query->andWhere(['parent_task_id' => $params]); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Task::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(['task_id' => $this->task_id, 'project_id' => $this->project_id, 'user_id' => $this->user_id, 'start_date' => $this->start_date, 'end_date' => $this->end_date, 'estimated_time' => $this->estimated_time, 'operating_time' => $this->operating_time, '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 = Task::find(); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'start' => $this->start, 'end' => $this->end, 'family_id' => $this->family_id]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'description', $this->description]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Task::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, 'goal_id' => $this->goal_id, 'closed' => $this->closed]); $query->andFilterWhere(['like', 'title', $this->title]); return $dataProvider; }
/** * Company Tasks for given site + date * * @return array */ public function companyTasksForSiteOnDate($company_id, $site_id, $date) { $carbon_date = Carbon::createFromFormat('Y-m-d H:i:s', $date . ' 00:00:00'); $weekend = $carbon_date->isWeekend() ? 1 : 0; $planner = SitePlanner::where('site_id', $site_id)->whereDate('from', '<=', $date)->whereDate('to', '>=', $date)->where('weekend', $weekend)->get(); $tasks = []; foreach ($planner as $plan) { if ($plan->task_id) { $task = Task::find($plan->task_id); $tasks[$task->id] = $task ? $task->name : 'Task Unassigned'; } } return $tasks; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Task::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, 'category_id' => $this->category_id, 'user_id' => $this->user_id, 'status' => $this->status, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]); $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 = Task::find()->permission()->dependent(); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSizeLimit' => [10, 100], 'pageParam' => 'task-page', 'pageSizeParam' => 'task-per-page'], 'sort' => ['defaultOrder' => ['timestamp' => SORT_ASC]]]); $params = $this->processParams($params); if (!($this->load($params) && $this->validate())) { return $dataProvider; } $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'done' => $this->done, 'task_partner.partner_id' => $this->partner_id]); $query->andFilterWhere(['like', 'task.name', $this->name]); $query->andFilterWhere(['like', 'notes', $this->notes]); $this->addRangeCondition($query, 'timestamp'); $this->addRangeCondition($query, 'created_at'); $this->addRangeCondition($query, 'updated_at'); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { var_dump($params); //exit();*/ $query = Task::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, 'from_device_id' => $this->from_device_id, 'to_device_id' => $this->to_device_id, 'action_id' => $this->action_id, 'created_at' => $this->created_at]); $query->andFilterWhere(['like', 'data', $this->data]); return $dataProvider; }
public function actionIndex($page = 1, $size = 10) { $size = $this->getParam('per-page') ?: $size; $list = Task::find()->with('user')->with('project'); if (\Yii::$app->user->identity->role != User::ROLE_ADMIN) { $list->where(['user_id' => $this->uid]); } $kw = \Yii::$app->request->post('kw'); if ($kw) { $list->andWhere(['or', "commit_id like '%" . $kw . "%'", "title like '%" . $kw . "%'"]); } $tasks = $list->orderBy('id desc'); $list = $tasks->offset(($page - 1) * $size)->limit(10)->asArray()->all(); $view = \Yii::$app->user->identity->role == User::ROLE_ADMIN ? 'admin-list' : 'dev-list'; $pages = new Pagination(['totalCount' => $tasks->count(), 'pageSize' => 10]); return $this->render($view, ['list' => $list, 'pages' => $pages]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Task::find(); $query->where(['task_to' => Yii::$app->user->id]); $query->andWhere(['parent_task_id' => 0]); $dataProvider = new ActiveDataProvider(['query' => $query]); $this->load($params); $dataProvider->sort->defaultOrder = ['id' => SORT_DESC]; $query->andFilterWhere(['task_from' => $this->task_from]); $query->andFilterWhere(['task_title' => $this->task_title]); if (!$this->validate()) { // uncomment the following line if you do not want to any records when validation fails // $query->where('0=1'); return $dataProvider; } return $dataProvider; }
public function actionIndex($page = 1, $size = 10) { $size = $this->getParam('per-page') ?: $size; $list = Task::find()->with('user')->with('project')->where(['user_id' => $this->uid]); // 有审核权限的任务 $auditProjects = Group::getAuditProjectIds($this->uid); if ($auditProjects) { $list->orWhere(['project_id' => $auditProjects]); } $kw = \Yii::$app->request->post('kw'); if ($kw) { $list->andWhere(['or', "commit_id like '%" . $kw . "%'", "title like '%" . $kw . "%'"]); } $tasks = $list->orderBy('id desc'); $list = $tasks->offset(($page - 1) * $size)->limit(10)->asArray()->all(); $pages = new Pagination(['totalCount' => $tasks->count(), 'pageSize' => 10]); return $this->render('list', ['list' => $list, 'pages' => $pages, 'audit' => $auditProjects]); }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params, $course_id) { if (empty($course_id)) { $query = Task::find(); } else { $query = Task::find()->where(['course_id' => $course_id]); } $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, 'course_id' => $this->course_id, 'score' => $this->score, 'task_type' => $this->task_type, 'is_timing' => $this->is_timing, 'create_time' => $this->create_time, 'update_time' => $this->update_time, 'complete_time' => $this->complete_time]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'option_json', $this->option_json])->andFilterWhere(['like', 'answer_json', $this->answer_json])->andFilterWhere(['like', 'image', $this->image])->andFilterWhere(['like', 'complete_time', $this->complete_time]); return $dataProvider; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Task::find(); $query->joinWith(['dicUnit' => function ($q) { $q->from('dic_units du'); }]); $query->joinWith(['category' => function ($q) { $q->from('categories cat'); }]); $dataProvider = new ActiveDataProvider(['query' => $query]); $dataProvider->sort->attributes['dicUnit'] = ['asc' => ['du.name' => SORT_ASC], 'desc' => ['du.name' => SORT_DESC]]; $dataProvider->sort->attributes['category'] = ['asc' => ['cat.name' => SORT_ASC], 'desc' => ['cat.name' => 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, 'category_id' => $this->category_id, 'unit_id' => $this->unit_id, 'deleted' => $this->deleted]); $query->andFilterWhere(['like', 'du.name', $this->dicUnit]); $query->andFilterWhere(['like', 'cat.name', $this->category]); $query->andFilterWhere(['like', 'tasks.name', $this->name]); return $dataProvider; }
protected function findModel($id) { $model = Task::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.'); } }
/** * Deletes an existing Task model. * If deletion is successful, the browser will be redirected to the 'index' page. * @param integer $id * @return mixed */ public function actionDelete($id) { $model = $this->findModel($id); $parent_id = $model->id; if (!empty($model) && $model->task_from == Yii::$app->user->getId()) { if ($model->delete()) { if (!empty($model->attachment)) { @unlink('uploads/' . $old_attachment); } $detil = Task::find(['parent_task_id' => $parent_id])->all(); if (!empty($detil)) { foreach ($detil as $attachmentItem) { if (!empty($attachmentItem->attachment)) { @unlink('uploads/' . $attachmentItem->attachment); } } Task::deleteAll('parent_task_id = :parent_task_id', [':parent_task_id' => $parent_id]); } Yii::$app->getSession()->setFlash('success', Yii::t('app', 'Data Tugas Berhasil Dihapus')); } else { Yii::$app->getSession()->setFlash('error', Yii::t('app', 'Data Tugas Gagal Dihapus')); } } return $this->redirect(['index']); }
<?php echo Html::beginForm(['window/clear-task', 'id' => $model->id]); ?> <?php echo Html::submitButton('Clear all tasks'); ?> <?php echo Html::endForm(); ?> <?php echo Html::beginForm(['window/assign-task', 'id' => $model->id]); ?> <?php echo Html::dropDownList('task_id', null, ArrayHelper::map(Task::find()->all(), 'id', 'name')); ?> <?php echo Html::submitButton('Assign task'); ?> <?php echo Html::endForm(); ?> <?php echo RecordGridView::widget(['dataProvider' => $recordsDataProvider]); ?>
/** * 可回滚的版本设置 * * @return int */ private function _enableRollBack() { $where = ' status = :status AND project_id = :project_id '; $param = [':status' => Task::STATUS_DONE, ':project_id' => $this->task->project_id]; $offset = Task::find()->select(['id'])->where($where, $param)->orderBy(['id' => SORT_DESC])->offset($this->conf->keep_version_num)->limit(1)->scalar(); if (!$offset) { return true; } $where .= ' AND id <= :offset '; $param[':offset'] = $offset; return Task::updateAll(['enable_rollback' => Task::ROLLBACK_FALSE], $where, $param); }
public function done($society, $project, $id) { $task = Task::find($id); $task->donedate = date('Y-m-d'); $task->save(); return Redirect::back()->with('okmessage', 'Task completed today'); }