Ejemplo n.º 1
0
 public function create($id, $tech_number = 1)
 {
     if (Auth::user()->can('create-service')) {
         $data['title'] = $tech_number == 1 ? "Create Service ~ " . $tech_number . " technician" : "Create Service ~ " . $tech_number . " technicians";
         $data['companies'] = Company::all();
         $data['company_id'] = $id;
         $data['contacts'] = CompanyPersonController::API()->all(["where" => ["company_person.company_id|=|" . $id], "order" => ["people.last_name|ASC", "people.first_name|ASC"], "paginate" => "false"]);
         $data['technicians'] = CompanyPersonController::API()->all(["where" => ["company_person.company_id|=|" . ELETTRIC80_COMPANY_ID], "order" => ["people.last_name|ASC", "people.first_name|ASC"], "paginate" => "false"]);
         $data['divisions'] = Division::orderBy("name")->get();
         $data['hotels'] = Hotel::where('company_id', $id)->orderBy("name")->get();
         $tech_number = $tech_number < 1 ? 1 : $tech_number;
         $tech_number = $tech_number > 5 ? 5 : $tech_number;
         $data['technician_number'] = $tech_number;
         foreach ($data['hotels'] as &$hotel) {
             $hotel['name_address'] = $hotel['name'] . " @ " . $hotel['address'];
         }
         return view('services/create', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to service create page']);
     }
 }
Ejemplo n.º 2
0
 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']);
     }
 }
 public function edit($id)
 {
     $company_person = CompanyPerson::find($id);
     if (Auth::user()->can('update-contact') || Auth::user()->active_contact->id == $id && Auth::user()->can('update-own-contact') || !$company_person->isE80() && Auth::user()->can('update-customer-contact')) {
         $data['title'] = "Edit Contact";
         $data['titles'] = Title::orderBy("name")->get();
         $data['departments'] = Department::orderBy("name")->get();
         $data['companies'] = Company::orderBy("name")->get();
         $data['contact'] = CompanyPerson::find($id);
         $data['divisions'] = Division::orderBy("name")->get();
         $data['groups'] = Group::where("group_type_id", "=", $company_person->group_type_id)->orderBy("name")->get();
         return view('company_person/edit', $data);
     } else {
         return redirect()->back()->withErrors(['Access denied to contacts edit page']);
     }
 }