public function getformAction() { if (!$this->isXmlHttpRequest()) { throw new \Exception('Неверный тип запроса!'); } $project = false; $task = false; if (!is_null($this->request->getPost('projects_id')) && (int) $this->request->getPost('projects_id') > 0) { $projectsId = (int) $this->request->getPost('projects_id'); $projectsModel = new Projects(); $project = $projectsModel->getProjectsDataForEdit($projectsId); } if (!is_null($this->request->getPost('id')) && (int) $this->request->getPost('id') > 0) { $id = (int) $this->request->getPost('id'); $tasksModel = new Tasks(); $task = $tasksModel->getTasksDataById($id); if ($task['projects_id'] > 0) { $projectsModel = new Projects(); $project = $projectsModel->getProjectsDataForEdit($task['projects_id']); } $usersModel = new Users(); $usersModel->setWhere('`roles_id` IN(1,2)'); $this->view->initiators = $usersModel->select(); $usersModel->setWhere('`roles_id` IN(1,3)'); $this->view->executors = $usersModel->select(); $taskstatusModel = new Taskstatus(); $this->view->statuses = $taskstatusModel->select(); } $priorityModel = new Priority(); $this->view->priorities = $priorityModel->select(); $this->view->project = $project; $this->view->task = $task; $this->view->user = $this->session->getCurrentUser(); }
/** * Execute the job. * * @return bool */ public function handle() { $this->priority->user_id = auth()->id(); $this->priority->name = $this->request->input('name'); $this->priority->color = $this->request->input('color'); return $this->priority->save(); }
public function all($params) { $params['order'] = isset($params['order']) ? $params['order'] : ['id|ASC']; $priorities = Priority::select("priorities.*"); $priorities = parent::execute($priorities, $params); return $priorities; }
public function show($id, $num = 3) { if (Auth::user()->can('read-escalation-profiles')) { $data['title'] = "Escalation Profile"; $data['menu_actions'] = [Form::editItem(route('escalation_profiles.edit', $id), "Edit This Profile", Auth::user()->can('update-escalation-profiles'))]; $escalation_profile_events = DB::table('escalation_profile_event')->where('profile_id', $id)->get(); if (count($escalation_profile_events) > 0) { foreach ($escalation_profile_events as $key => $escalation_profile_event) { $data['escalation_profile_events']['delay_time'][$key] = $escalation_profile_event->delay_time; $data['escalation_profile_events']['event_id'][$key] = explode(",", $escalation_profile_event->event_id); $data['escalation_profile_events']['level_id'][$key] = $escalation_profile_event->level_id; $data['escalation_profile_events']['priority_id'][$key] = $escalation_profile_event->priority_id; $data['escalation_profile_events']['email_text'][$key] = $escalation_profile_event->email_text; } } else { $data['escalation_profile_events'] = null; } $data['escalation_profile'] = EscalationProfile::find($id); $data['escalation_events'] = EscalationEvent::all(); $data['levels'] = Level::all(); $data['priorities'] = Priority::all(); $data['delays'] = self::parseDelays(); $count = count($escalation_profile_events); $num = $num > 0 ? $num : 3; $data['rows'] = $count > 0 ? $count > $num ? $count : $num : $num; return view('escalation_profiles/show', $data); } else { return redirect()->back()->withErrors(['Access denied to esclation profiles show page']); } }
/** * Execute the job. * * @return bool */ public function handle() { // We'll make sure the work request doesn't already have a // work order attached to it before we try and create it. if (!$this->workRequest->hasWorkOrder()) { $priority = Priority::findOrCreateRequested(); $status = Status::findOrCreateRequested(); $workOrder = new WorkOrder(); $workOrder->status_id = $status->getKey(); $workOrder->priority_id = $priority->getKey(); $workOrder->request_id = $this->workRequest->getKey(); $workOrder->user_id = $this->workRequest->user_id; $workOrder->subject = $this->workRequest->subject; $workOrder->description = $this->workRequest->description; if ($workOrder->save()) { return $workOrder; } } return false; }
/** * Returns a new form for work orders. * * @param WorkOrder $workOrder * * @return \Orchestra\Contracts\Html\Builder */ public function form(WorkOrder $workOrder) { return $this->form->of('work-orders', function (FormGrid $form) use($workOrder) { if ($workOrder->exists) { $method = 'PATCH'; $url = route('maintenance.work-orders.update', [$workOrder->getKey()]); $form->submit = 'Save'; } else { $method = 'POST'; $url = route('maintenance.work-orders.store'); $form->submit = 'Create'; } $form->with($workOrder); $form->attributes(compact('method', 'url')); $form->fieldset(function (Fieldset $fieldset) { $fieldset->control('select', 'category')->value(function (WorkOrder $workOrder) { return $workOrder->category_id; })->options(function () { return Category::getSelectHierarchy('work-orders'); }); $fieldset->control('select', 'location')->value(function (WorkOrder $workOrder) { return $workOrder->location_id; })->options(function () { return Location::getSelectHierarchy(); }); $fieldset->control('select', 'status')->options(function () { $statuses = Status::all()->pluck('name', 'id'); $statuses[0] = 'None'; return $statuses; }); $fieldset->control('select', 'priority')->value(function (WorkOrder $workOrder) { return $workOrder->priority_id; })->options(function () { $priorities = Priority::all()->pluck('name', 'id'); $priorities[0] = 'None'; return $priorities; }); $fieldset->control('select', 'assets[]')->label('Assets')->options(function () { return Asset::all()->pluck('name', 'id'); })->attributes(['class' => 'select2', 'multiple' => true]); $fieldset->control('input:text', 'subject')->attributes(['placeholder' => 'ex. Worked on HVAC']); $fieldset->control('input:textarea', 'description'); }); }); }
/** * Deletes the specified priority. * * @param int|string $id * * @return bool */ public function destroy($id) { $priority = $this->priority->findOrFail($id); return $priority->delete(); }
public function getCardEditData() { if (!Auth::check()) { return redirect("/"); } $prior = Priority::all('id', 'name'); $member = Membermanagement::with(['member'])->where('Board_id', '=', session()->get('Board'))->get(); $user = User::find(Auth::user()->id); $boardManager = Board::find(session()->get('Board')); $data['priority'] = $prior; $data['manager'] = $member; $data['user'] = $user; $data['boardManager'] = $boardManager; return $data; }
public static function workingTimeData($days, $type) { $result = null; if ($type == "division") { $grouping = Division::whereIn('id', [LGV_DIVISION_ID, PLC_DIVISION_ID, PC_DIVISION_ID, BEMA_DIVISION_ID, FIELD_DIVISION_ID, SPARE_PARTS_DIVISION_ID, RELIABILITY_DIVISION_ID, OTHERS_DIVISION_ID])->orderBy("name")->get(); } elseif ($type == "priority") { $grouping = Priority::orderBy("name")->get(); } elseif ($type == "level") { $grouping = Level::orderBy("name")->get(); } elseif ($type == "company") { $grouping = Company::orderBy("name")->get(); } elseif ($type == "assignee") { $grouping = CompanyPerson::select("company_person.*", "people.first_name", "people.last_name")->leftJoin('people', 'company_person.person_id', '=', 'people.id')->where('company_person.company_id', '=', ELETTRIC80_COMPANY_ID)->orderBy("last_name")->get(); foreach ($grouping as $group) { $group->name = $group->last_name . " " . $group->first_name; } } if (isset($grouping)) { foreach ($grouping as $index => $group) { for ($i = 0; $i < 50; $i++) { $query = "SELECT SUM(resolution_time) as sum, COUNT(*) as ticket_count, AVG(resolution_time) as average, DATE_SUB(NOW(), INTERVAL " . $days * ($i + 1) . " day) as date\n FROM (\n SELECT before.ticket_id, SUM(\n TIMESTAMPDIFF(SECOND, \n GREATEST(DATE_SUB(NOW(), INTERVAL " . $days * ($i + 1) . " day), before.created_at), \n LEAST(DATE_SUB(NOW(), INTERVAL " . $days * $i . " day), IFNULL(after.created_at,NOW()))\n )\n )/3600 as resolution_time\n FROM tickets_history as `before`\n LEFT JOIN tickets_history as `after` ON before.id = after.previous_id\n INNER JOIN tickets ON tickets.id = before.ticket_id \n WHERE (\n after.status_id IN (" . TICKET_NEW_STATUS_ID . "," . TICKET_IN_PROGRESS_STATUS_ID . ",\n " . TICKET_REQUESTING_STATUS_ID . "," . TICKET_SOLVED_STATUS_ID . "," . TICKET_CLOSED_STATUS_ID . ")\n OR \n (before.status_id IN (" . TICKET_NEW_STATUS_ID . "," . TICKET_IN_PROGRESS_STATUS_ID . ",\n " . TICKET_REQUESTING_STATUS_ID . ") AND after.id IS NULL)\n )\n AND tickets.deleted_at IS NULL\n AND tickets." . $type . "_id = {$group->id}\n AND TIMESTAMPDIFF(SECOND, \n GREATEST(before.created_at,DATE_SUB(NOW(), INTERVAL " . $days * ($i + 1) . " day)), \n LEAST(DATE_SUB(NOW(), INTERVAL " . $days * $i . " day), IFNULL(after.created_at,NOW()))) > 0\n GROUP BY before.ticket_id\n ) as " . $type[0] . "_{$index} "; $temp = DB::select(DB::raw($query)); foreach ($temp[0] as $key => $value) { if ($key != "date") { $div_key = str_replace(" ", "_", $group->name); if ($i == 0) { $result[$div_key][$key]['current'] = round($temp[0]->{$key}, 2); } if ($i == 1) { $result[$div_key][$key]['previous'] = round($temp[0]->{$key}, 2); } $result[$div_key][$key]['historical'][$temp[0]->date] = $temp[0]->{$key}; } } } } } return $result; }
/** * Executes the job. * * @return bool */ public function handle() { $this->priority->name = $this->request->input('name', $this->priority->name); $this->priority->color = $this->request->input('color', $this->priority->color); return $this->priority->save(); }
public function edit($id) { if (Auth::user()->can('update-ticket')) { $data['ticket'] = self::API()->find(['id' => $id]); $temp = DB::table("ticket_links")->where("ticket_id", "=", $id)->get(); foreach ($temp as $elem) { $links[] = $elem->linked_ticket_id; } $data['ticket']['linked_tickets_id'] = isset($links) ? implode(",", $links) : ''; $data['companies'] = Company::where('id', '!=', ELETTRIC80_COMPANY_ID)->orderBy('name')->get(); $data['priorities'] = Priority::orderBy('id', 'desc')->get(); $data['divisions'] = Division::orderBy('name')->get(); $data['job_types'] = JobType::orderBy('name')->get(); $data['levels'] = Level::orderBy('name')->get(); $data['assignees'] = CompanyPersonController::API()->all(["where" => ["companies.id|=|" . ELETTRIC80_COMPANY_ID], "order" => ["people.last_name|ASC", "people.first_name|ASC"], "paginate" => "false"]); $data['companies'] = CompaniesController::API()->all(['where' => ['companies.id|!=|' . ELETTRIC80_COMPANY_ID], 'order' => ['companies.name|ASC'], 'paginate' => 'false']); $data['tags'] = ""; foreach ($data['ticket']->tags as $tag) { $data['tags'] .= $tag->name . ","; } $is_draft = $data['ticket']->status_id == TICKET_DRAFT_STATUS_ID ? true : false; $data['title'] = "Edit Ticket #" . $id; return view('tickets/edit', $data); } else { return redirect()->back()->withErrors(['Access denied to tickets edit page']); } }