protected function updateRowOrder(Task $task, $input) { if (array_key_exists('order', $input) && array_key_exists('ordertask', $input)) { try { $task->updateOrder($input['order'], $input['ordertask']); } catch (MoveNotPossibleException $e) { $result['success'] = false; $result['msg'] = "Cannot make a page a child of self."; return $result; } } }
public function update(CreateCommentRequest $request, $id) { $comment = $this->comment; $comment->user_id = $request->get('name'); $comment->content = $request->get('content'); $comment->project_id = $id; $comment->save(); $project = Project::whereId($id)->first(); $slug = $project->slug; $task = new Task(); $tasks = $task->whereProject_id($id)->orderBy('id', 'desc')->first(); //return view('projects.show', ['project' => $project, 'task' => $tasks]); return redirect()->route('projects.show', ['slug' => $slug, 'task' => $tasks]); }
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]); }
private function saveAssign($new_assign, $send_notification) { $model = Task::findOne($this->id); $old_assigned = $model->getAssignedToArray(); if ($old_assigned) { if (!$new_assign) { return self::deleteAssign($old_assigned); } //remove elementos a mais $to_delete = array_diff($old_assigned, $new_assign); if ($to_delete && !self::deleteAssign($to_delete)) { return false; } $to_create = array_diff($new_assign, $old_assigned); if ($to_create && !self::createAssign($to_create, $send_notification)) { return false; } } else { if ($new_assign) { //Cria novo return self::createAssign($new_assign, $send_notification); } } return true; }
public function down() { $this->dropColumn(Project::tableName(), 'keep_version_num'); $this->dropColumn(Task::tableName(), 'enable_rollback'); echo "m151027_063246_keep_version_num was reverted.\n"; return true; }
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 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"; } }
/** * Run the migrations. * * @return void */ public function up() { $tasks = \App\Models\Task::all(); foreach ($tasks as $task) { $startTime = strtotime($task->start_time); if (!$task->time_log || !count(json_decode($task->time_log))) { $task->time_log = json_encode([[$startTime, $startTime + $task->duration]]); $task->save(); } elseif ($task->getDuration() != intval($task->duration)) { $task->time_log = json_encode([[$startTime, $startTime + $task->duration]]); $task->save(); } } Schema::table('tasks', function ($table) { $table->dropColumn('start_time'); $table->dropColumn('duration'); $table->dropColumn('break_duration'); $table->dropColumn('resume_time'); }); Schema::table('users', function ($table) { $table->boolean('dark_mode')->default(false)->nullable(); }); Schema::table('users', function ($table) { $table->dropColumn('theme_id'); }); }
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; }
/** * Execute the console command. * * @return void */ public function fire() { $tasks = Task::where('date', '>=', Carbon::parse(date('d-m-Y')))->where('date', '<=', Carbon::parse(date('d-m-Y'))->addDay(7))->orderBy('date', 'asc')->get(); \Mail::send('emails.remainder', ['tasks' => $tasks], function ($m) { $m->to(env('REMAINDER_EMAIL'), env('REMAINDER_NAME'))->subject('[SUN TASK] Your Task Reminder.'); }); }
/** * 显示当前课程列表 * @author FuRongxin * @date 2016-03-29 * @version 2.0 * @return \Illuminate\Http\Response 教师课程列表 */ public function index() { $tasks = Task::with(['course' => function ($query) { $query->select('kch', 'kcmc', 'xs'); }])->whereJsgh(Auth::user()->jsgh)->whereNd(session('year'))->whereXq(session('term'))->orderBy('kcxh')->get(); $title = session('year') . '年度' . Term::find(session('term'))->mc . '学期'; return view('tes.index')->withTitle($title . '课程列表')->withTasks($tasks); }
/** * 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(); }
/** * To reset database * * @param $key * * @return \Laravel\Lumen\Http\Redirector */ public function databaseReset($key) { if (env('APP_DATA_RESET_KEY') == $key) { Task::truncate(); return redirect('/'); } return redirect('/'); }
public function monitoring() { //print_r(auth()->user()); $page = 2; $tasks = Task::query()->paginate($page); $links = $tasks->render(); return view('front.task.monitoring', compact('tasks', 'links')); }
public function postCreate(Request $request) { $input = $request->only(['name']); $input['user_id'] = Auth::id(); $input['course_id'] = Auth::user()->course_id; Task::create($input); flash()->message('Zadanie bolo vytvorené'); return redirect()->back(); }
/** * Update the specified resource in storage via ajax. */ public function update(TaskRequest $request, $id) { if ($request->ajax()) { $task = Task::findOrFail($id); $task->update($request->all()); return $task; } return view('errors.404'); }
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']); }
public function edit($id) { $user_group = Auth::user()->user_group_id; if ($user_group == 1) { $tasks = Task::with('component', 'module')->get(); foreach ($tasks as &$task) { $task->list = 1; $task->view = 1; $task->add = 1; $task->edit = 1; $task->delete = 1; $task->report = 1; $task->print = 1; } } else { if ($user_group == $id || $id == 1) { $tasks = DB::table('user_group_roles as ugr')->select('ugr.component_id', 'ugr.module_id', 'ugr.task_id', 'ugr.list', 'ugr.view', 'ugr.add', 'ugr.edit', 'ugr.delete', 'ugr.report', 'ugr.print', 'components.name_en as component_name', 'modules.name_en as module_name', 'tasks.name_en as task_name')->join('tasks', 'tasks.id', '=', 'ugr.task_id')->join('components', 'components.id', '=', 'ugr.component_id')->join('modules', 'modules.id', '=', 'ugr.module_id')->where('tasks.route', 'not like', 'roles%')->where('ugr.user_group_id', $id)->where('ugr.list', 1)->get(); } else { $tasks = DB::table('user_group_roles as ugr')->select('ugr.component_id', 'ugr.module_id', 'ugr.task_id', 'ugr.list', 'ugr.view', 'ugr.add', 'ugr.edit', 'ugr.delete', 'ugr.report', 'ugr.print', 'components.name_en as component_name', 'modules.name_en as module_name', 'tasks.name_en as task_name')->join('tasks', 'tasks.id', '=', 'ugr.task_id')->join('components', 'components.id', '=', 'ugr.component_id')->join('modules', 'modules.id', '=', 'ugr.module_id')->where('ugr.user_group_id', $id)->where('ugr.list', 1)->get(); } } $roleResult = DB::table('user_group_roles as ugr')->select('ugr.id as ugr_id', 'ugr.list', 'ugr.view', 'ugr.add', 'ugr.edit', 'ugr.delete', 'ugr.report', 'ugr.print', 'ugr.component_id', 'ugr.module_id', 'ugr.task_id')->where('ugr.user_group_id', $id)->orderBy('ugr.component_id', 'asc')->orderBy('ugr.module_id', 'asc')->get(); $roles = new stdClass(); $roles->list = []; $roles->view = []; $roles->add = []; $roles->edit = []; $roles->delete = []; $roles->report = []; $roles->print = []; $roles->ugr_id = []; foreach ($roleResult as $result) { $roles->ugr_id[$result->task_id] = $result->ugr_id; if ($result->list) { $roles->list[] = $result->task_id; } if ($result->view) { $roles->view[] = $result->task_id; } if ($result->add) { $roles->add[] = $result->task_id; } if ($result->edit) { $roles->edit[] = $result->task_id; } if ($result->delete) { $roles->delete[] = $result->task_id; } if ($result->report) { $roles->report[] = $result->task_id; } if ($result->print) { $roles->print[] = $result->task_id; } } return view('roles.edit', compact('tasks', 'roles', 'id')); }
public function afterSave($insert, $changed) { if ($insert) { foreach (WorkflowTask::findAll(['workflow_id' => $this->workflow_id]) as $orig) { $task = new Task(); $skips = ['workflow_task_id', 'workflow_id', 'regist_date', 'update_date']; foreach (Task::getTableSchema()->columnNames as $cols) { if (in_array($cols, $skips)) { continue; } $task->{$cols} = $orig->{$cols}; } $task->user_id = Yii::$app->user->id; $task->project_id = $this->project_id; $task->save(); } } parent::afterSave($insert, $changed); }
public function test_completed() { $default = factory(Task::class)->create(['completed' => null]); $active = factory(Task::class)->create(['completed' => false]); $inactive = factory(Task::class)->create(['completed' => true]); $tasks = Task::completed()->lists('id'); $this->assertNotContains($default->id, $tasks); $this->assertNotContains($active->id, $tasks); $this->assertContains($inactive->id, $tasks); }
/** * 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]); } }
/** * @var integer * @return View * */ public function getTable($set_id) { //Набор названия столбцов для таблицы: возможно брать список из таблицы и перевод включать в lang $columns = ['id' => 'Выбрать', 'number_task' => 'Номер задачи', 'image' => 'Задача', 'experience' => 'Опыт', 'gold' => 'Монет', 'grade' => 'Уровень сложности', 'subject_id' => 'id предмета', 'rating' => 'Уровень значимости', 'comment' => 'Комментарий']; $rows = DB::table('tasks')->select(['id', 'number_task', 'image', 'experience', 'gold', 'grade', 'subject_id'])->where('set_of_task', '=', $set_id)->orderBy('id', 'ASC')->get(); $count = Task::count(); //Выбор номера уникальной группы: возможно просто записать в html статично $group = DB::table('users')->select(DB::raw('DISTINCT `group`'))->orderBy('group')->get(); return view('process.table', ['count' => $count, 'columns' => $columns, 'rows' => $rows, 'group' => $group, 'adminTitle' => 'Административная панель', 'user' => AdminAuth::user(), 'menu' => $this->admin->menu->getItems(), 'pageTitle' => '']); }
public function down() { $this->dropColumn(Project::tableName(), 'repo_username'); $this->dropColumn(Project::tableName(), 'repo_password'); $this->renameColumn(Project::tableName(), 'repo_url', 'git_url'); $this->renameColumn(Project::tableName(), 'repo_mode', 'git_type'); $this->dropColumn(Project::tableName(), 'repo_type'); $this->dropColumn(Task::tableName(), 'file_list'); echo "m151018_032238_support_svn be reverted.\n"; return true; }
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; } }
public function validateAttr(Task $model) { if ($model->task_type == static::TYPE_CHOICE) { if (!$model['option_A']) { $model->addError('option_A', Yii::t('app', 'The option_A cannot be blank.')); } if (!$model['option_B']) { $model->addError('option_B', Yii::t('app', 'The option_B cannot be blank.')); } if (!$model['answer_choice']) { $model->addError('answer_choice', Yii::t('app', 'The answer_choice cannot be blank.')); } $optionArr = ['A' => $model['option_A'], 'B' => $model['option_B'], 'C' => $model['option_C'], 'D' => $model['option_D']]; $optionArr = array_filter($optionArr); $choiceArr = $model['answer_choice']; if (!$this->validateAnswer($optionArr, $choiceArr)) { $model->addError('answer_choice', Yii::t('app', 'The answer_choice is not correct.')); } unset($model['answer_choice']); $model->option_json = json_encode($optionArr); $model->answer_json = json_encode($choiceArr); if ($model->is_timing == static::IS_NOT_TIMING) { $model->complete_time = '00:00'; } } // if ($model->task_type == static::TYPE_SHORT_ANSWER || $model->task_type == static::TYPE_CALCULATION) { // if (empty($model->answer_json)) { // $model->addError('answer_json', Yii::t('app', 'The answer_json cannot be blank.')); // } // } if ($model->task_type == static::TYPE_CODING) { if (empty($model['code_test_one_input'])) { $model->addError('code_test_one_input', Yii::t('app', 'code_test_one_input cannot be blank.')); } if (empty($model['code_test_one_output'])) { $model->addError('code_test_one_output', Yii::t('app', 'code_test_one_output cannot be blank.')); } } $model->update_time = Common::getTime(); return $model; }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($publicId) { $client = Client::withTrashed()->scope($publicId)->with('contacts', 'size', 'industry')->firstOrFail(); Utils::trackViewed($client->getDisplayName(), ENTITY_CLIENT); $actionLinks = [['label' => trans('texts.new_task'), 'url' => '/tasks/create/' . $client->public_id]]; if (Utils::isPro()) { array_push($actionLinks, ['label' => trans('texts.new_quote'), 'url' => '/quotes/create/' . $client->public_id]); } array_push($actionLinks, ['label' => trans('texts.enter_payment'), 'url' => '/payments/create/' . $client->public_id], ['label' => trans('texts.enter_credit'), 'url' => '/credits/create/' . $client->public_id]); $data = array('actionLinks' => $actionLinks, 'showBreadcrumbs' => false, 'client' => $client, 'credit' => $client->getTotalCredit(), 'title' => trans('texts.view_client'), 'hasRecurringInvoices' => Invoice::scope()->where('is_recurring', '=', true)->whereClientId($client->id)->count() > 0, 'hasQuotes' => Invoice::scope()->where('is_quote', '=', true)->whereClientId($client->id)->count() > 0, 'hasTasks' => Task::scope()->whereClientId($client->id)->count() > 0, 'gatewayLink' => $client->getGatewayLink()); return View::make('clients.show', $data); }
/** * Display the specified resource. * GET /projects/{id} * * @param int $id * @return Response */ public function show($society, $id) { $data['society'] = $society; $project = Project::find($id); if (Helpers::perm('admin', $society) or Helpers::perm('edit', $society) or $project->individual_id == Auth::user()->individual_id) { $individuals = Individual::orderBy('surname')->get(); $oldtasks = Task::where('project_id', $id)->where('donedate', '!=', '')->get(); $tasks = Task::where('project_id', $id)->where('donedate', '')->get(); return View::make('projects.show', $data)->with('project', $project)->with('oldtasks', $oldtasks)->with('tasks', $tasks)->with('individuals', $individuals); } else { return view('shared.unauthorised'); } }
/** * */ public function actionTasks() { $user = User::findOne(['username' => 'admin']); if (!$user) { throw new \Exception('Admin user not exists.'); } \Yii::$app->db->createCommand('TRUNCATE task; TRUNCATE user_task;')->execute(); $taskList = [['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(8), 'description' => 'some description', 'timeStart' => time() - 60 * 60 * 24 * 7, 'timeEnd' => time() + 60 * 60 * 24 * 7], ['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(6), 'description' => 'some description', 'timeStart' => time() - 60 * 60 * 5, 'timeEnd' => time() + 60 * 60 * 5], ['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(4), 'description' => 'some description', 'timeStart' => time() + 60 * 60 * 2, 'timeEnd' => time() + 60 * 60 * 24], ['userID' => $user->id, 'title' => \Yii::$app->security->generateRandomString(7), 'description' => 'some description', 'timeStart' => time() + 60 * 60 * 24 * 1, 'timeEnd' => time() + 60 * 60 * 24 * 7]]; $tasks = null; foreach ($taskList as $taskEntry) { $task = new Task(); $task->userID = $taskEntry['userID']; $task->title = $taskEntry['title']; $task->description = $taskEntry['description']; $task->timeStart = $taskEntry['timeStart']; $task->timeEnd = $taskEntry['timeEnd']; $task->timeCreated = time(); $task->save(); $tasks[] = $task; } $this->assignRandom($tasks); }
public static function get_tasks($card_id = false, $camp_id = false) { $task = Task::select('tasks.*', 'cards.name as card', 'camps.name as camp'); $task->join('cards', 'cards.id', '=', 'card_id', 'left'); $task->join('camps', 'camps.id', '=', 'camp_id', 'left'); if ($card_id) { $task->where('tasks.card_id', $card_id); } if ($camp_id) { $task->where('tasks.camp_id', $camp_id); } return $task->get(); }
/** * @SWG\Post( * path="/tasks", * tags={"task"}, * summary="Create a task", * @SWG\Parameter( * in="body", * name="body", * @SWG\Schema(ref="#/definitions/Task") * ), * @SWG\Response( * response=200, * description="New task", * @SWG\Schema(type="object", @SWG\Items(ref="#/definitions/Task")) * ), * @SWG\Response( * response="default", * description="an ""unexpected"" error" * ) * ) */ public function store() { $data = Input::all(); $taskId = isset($data['id']) ? $data['id'] : false; if (isset($data['client_id']) && $data['client_id']) { $data['client'] = $data['client_id']; } $task = $this->taskRepo->save($taskId, $data); $task = Task::scope($task->public_id)->with('client')->first(); $transformer = new TaskTransformer(Auth::user()->account, Input::get('serializer')); $data = $this->createItem($task, $transformer, 'task'); return $this->response($data); }