/**
  * Show the application dashboard to the user.
  *
  * @return Response
  */
 public function index()
 {
     $title = "Dashboard";
     if (Auth::user()->role_id == 4) {
         $model = Department::with(['user', 'developer', 'leader', 'manager'])->get();
         return view('html.dashboard.admin', compact('title', 'model'));
     } elseif (Auth::user()->role_id == 3) {
         $department = Department::get();
         return view('html.dashboard.manager', compact('title', 'model', 'department'));
     } elseif (Auth::user()->role_id == 2) {
         $list = Department::find(Auth::user()->department_id);
         return view('html.dashboard.leader', compact('title', 'list'));
     } else {
         // if(Auth::user()->teamdetail)
         // {
         // 	$sum=0;
         // 	foreach (Auth::user()->teamdetail as $key => $value)
         // 	{
         // 		foreach ($value->team->detail as $key => $item)
         // 		{
         // 			// var_dump(count($value->team->detail));
         // 			foreach ($item->account->review as $key => $review) {
         // 				# code...
         // 				$sum+=($review->point);
         // 			}
         // 		}
         // 		var_dump($sum);
         // 	}
         // 	exit();
         // }
         return view('html.dashboard.developer', compact('title'));
     }
     // // $leader = User::find($team->created_user_id);
 }
 public function update(Request $request)
 {
     $department = Department::find($request->department_id);
     $department->name = $request->name;
     $department->save();
     return Redirect::to('/admin/department');
 }
 /**
  * Display the specified resource.
  *
  * @param  int $id
  *
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $department = Department::find($id);
     if (empty($department)) {
         return response()->json(['status' => 4, 'message' => '数据异常']);
     }
     return $department;
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     //
     $data = $request->except(['_token', '_method']);
     $department = Department::find($id);
     $department->update($data);
     return redirect()->to('departments');
 }
 /**
  * Delete department from DB.  Cannot delete one that's in use.
  *
  * @param $id
  * @return mixed
  */
 public function deleteDept($id)
 {
     $dept = Department::find($id);
     if (count($dept->employees()->get()->toArray())) {
         return redirect()->back()->with('danger_flash_message', 'You cannot delete a department that is in use.');
     }
     $dept->delete();
     return redirect()->route('manageDepartments')->with('flash_message', 'Department ' . $dept->name . ' has been deleted');
 }
 /**
  * 사용자를 json형태로 가져옴
  *
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 private function getUserCollection(Request $request)
 {
     $type = $request->get('type', 'dept_id');
     $value = $request->get('value', '0');
     $list = collect([]);
     switch ($type) {
         case 'dept_id':
             $dept = Department::find($value);
             if ($dept) {
                 $allDepts = $dept->allChildDepartments();
                 $list = User::whereIn('dept_id', $allDepts->pluck('id')->toArray())->get();
             }
             break;
     }
     return $list;
 }
Beispiel #7
0
 /**
  * Get the validation rules that apply to the request.
  *
  * @return array
  */
 public function rules()
 {
     $department = Department::find($this->departments);
     switch ($this->method()) {
         case 'GET':
         case 'DELETE':
             return [];
         case 'POST':
             return ['code' => 'required|unique:departments|max:20', 'name' => 'required|max:254'];
         case 'PUT':
         case 'PATCH':
             return ['code' => "required|unique:departments,code,{$department->id}|max:20", 'name' => 'required|max:254'];
         default:
             break;
     }
 }
 public function getCategories($departmentId = null)
 {
     if ($departmentId) {
         $department = Department::find($departmentId);
     } else {
         $department = $this->getDepartment();
     }
     if ($department) {
         $categories = $department->categories()->active()->with(['langs' => function ($query) {
             $query->lang();
         }])->sort()->get();
     } else {
         $categories = Category::active()->with(['langs' => function ($query) {
             $query->lang();
         }])->sort()->get();
     }
     return $categories;
 }
 public function index(Request $request)
 {
     if ($request->bp) {
         $currentBp = BusinessPlan::find($request->bp);
     } else {
         $currentBp = BusinessPlan::where('start', '<=', Carbon::now())->where('end', '>=', Carbon::now())->first();
         if (!$currentBp) {
             $currentBp = BusinessPlan::all()->last();
         }
     }
     $sorted = Goat::where('bid', $currentBp->id)->where('type', 'G')->orderBy('goal_type')->orderBy('description')->get();
     $bp = Goat::where('bid', $currentBp->id)->where('type', '<>', 'G')->orderByRaw("FIELD(type, 'O', 'A', 'T')")->orderBy('description', 'desc')->get();
     foreach ($bp as $goat) {
         if ($goat->type === 'G') {
             $sorted->push($goat);
             continue;
         }
         for ($i = 0, $len = $sorted->count(); $i < $len; $i++) {
             if ($sorted[$i]->id == $goat->parent_id) {
                 // Hacky fix since when you splice $goat into $sorted,
                 // it converts the $goat into an array instead of
                 // keeping it as a Model object...
                 $sorted->splice($i + 1, 0, "temp");
                 $sorted->put($i + 1, $goat);
                 break;
             }
         }
     }
     $leadOf = array();
     if (Auth::user()) {
         foreach (Auth::user()->leadOf as $dept) {
             array_push($leadOf, $dept->id);
         }
     }
     $collaboratorGoals = array();
     foreach ($leadOf as $dept_id) {
         foreach (Department::find($dept_id)->collaboratorOn as $goat) {
             array_push($collaboratorGoals, $goat->id);
         }
     }
     return view('view_plan')->with(['bp' => $sorted, 'users' => User::orderBy('first_name')->get(), 'depts' => Department::orderBy('name')->get(), 'leadOf' => $leadOf, 'plans' => BusinessPlan::orderBy('id', 'desc')->get(), 'query' => $request, 'bp_id' => $currentBp->id, 'is_bplead' => Auth::user() && Auth::user()->is_bplead, 'collaboratorGoals' => $collaboratorGoals]);
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $student = Auth::user();
     $regs = Registration::where('student_id', '=', $student->id)->get();
     foreach ($regs as $reg) {
         $course = Course::where('id', '=', $reg->course_id)->firstOrFail();
         $reg["course_name"] = $course->name;
         $reg["course_code"] = $course->code;
         $dept = Department::find($course->department_id);
         $reg["department"] = $dept->name;
         $reg["exam_taken"] = false;
         if (Exam::where('student_id', $student->id)->where('course_id', $course->id)->count() > 0) {
             $reg["exam_taken"] = true;
         }
         $reg["exam_ready"] = false;
         if (Question::where('course_id', $reg->course_id)->count() > 0) {
             $reg["exam_ready"] = true;
         }
     }
     return view('reg.index', compact('regs'));
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index(Request $request)
 {
     $pagesize = 15;
     $query = $request->input();
     //unset($query['page']);
     $users = $request->input("dept") ? Department::find($request->input("dept"))->users() : User::select('*');
     switch ($request->input("sort")) {
         case "username":
             $users = $users->orderBy('username')->paginate($pagesize);
             break;
         case "name":
             $users = $users->orderBy('first_name')->paginate($pagesize);
             break;
         case "dept":
             break;
         case "status":
             // TODO: active/inactive
             break;
         default:
             $users = $users->paginate($pagesize);
     }
     $depts = Department::all();
     return view('admin.users', ['users' => $users, 'query' => $query, 'depts' => $depts]);
 }
Beispiel #12
0
/*
|--------------------------------------------------------------------------
| END SUB-CATEGORIES ROUTING
|--------------------------------------------------------------------------
|
*/
/*
|--------------------------------------------------------------------------
| SUB-SUB-CATEGORIES ROUTING
|--------------------------------------------------------------------------
|
*/
Route::get('list-sub-sub-categories/{sub_category}', ['middleware' => 'auth', function ($sub_category) {
    $subCatObj = SubCategory::find($sub_category);
    $catObj = Category::find($subCatObj->category);
    $deptObj = Department::find($catObj->department);
    return view('subsubcategories.list', compact('subCatObj', 'deptObj', 'catObj'));
}]);
Route::get('sub-sub-categories-list/{id}', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@index']);
Route::get('subsubcategories/{id}', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@edit']);
Route::post('addSubSubCategory', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@store']);
Route::post('updateSubSubCategory', ['middleware' => 'auth', 'uses' => 'SubSubCategoriesController@update']);
/*
|--------------------------------------------------------------------------
| END SUB-SUB-CATEGORIES ROUTING
|--------------------------------------------------------------------------
|
*/
/*
|--------------------------------------------------------------------------
| CASES ROUTING
 public function getAvailableParentCategories($departmentId)
 {
     $department = Department::find($departmentId);
     $categories = $department->categories;
     return $categories;
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function delete($id)
 {
     $department = Department::find($id);
     $department->enabled = 0;
     $department->delete();
     return redirect('department');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(DepartmentRequest $request, $id)
 {
     $department = Department::find($id);
     $department->update($request->all());
     return redirect('home/department');
 }
 public function clear(Request $request)
 {
     foreach (Request::input('checkbox') as $key => $value) {
         $model = Department::find($value);
         $model->delete();
     }
     return redirect()->route('admin.department.index')->with('success', 'successfully deleted');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $dep = Department::find($id);
     $dep->delete();
     return redirect()->route('admin.department.listDep')->with('message', 'Delete Department success!');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function edit($id)
 {
     $department = Department::find($id);
     $formTitle = 'Edit department';
     return View('departments.form', compact('department', 'formTitle'));
 }
 public function getCategoryManagers($department)
 {
     $originalUsers = Department::find($department)->users;
     $users = array();
     foreach ($originalUsers as $originalUser) {
         if ($originalUser->hasRole(['category_manager'])) {
             array_push($users, $originalUser);
         }
     }
     return $users;
 }
 public function createChanges(Goat $goat, $department_id, $description, $success_measure, $leads, $userCollabs, $deptCollabs, $due_date, $priority)
 {
     if ($department_id != $goat->department_id) {
         $change = new \App\Change();
         $change->change_type = 'L';
         $change->description = 'Assigned to ' . Department::find($department_id)->name;
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
     if ($description != $goat->description) {
         $change = new \App\Change();
         $change->change_type = 'D';
         $change->description = $description;
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
     if ($success_measure != $goat->success_measure) {
         $change = new \App\Change();
         $change->change_type = 'M';
         $change->description = "Success Measure: " . $success_measure;
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
     $newLeads = $leads ? $leads : array();
     $curLeads = $goat->userLeads()->get()->map(function ($user) {
         return $user->id;
     })->toArray();
     sort($newLeads);
     sort($curLeads);
     if ($newLeads != $curLeads) {
         if ($diff = array_diff($newLeads, $curLeads)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'L';
             $change->description = "Added " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
         if ($diff = array_diff($curLeads, $newLeads)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'L';
             $change->description = "Removed " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
     }
     $newCollaborators = $userCollabs ? $userCollabs : array();
     $curCollaborators = $goat->userCollaborators()->get()->map(function ($user) {
         return $user->id;
     })->toArray();
     sort($newCollaborators);
     sort($curCollaborators);
     if ($newCollaborators != $curCollaborators) {
         if ($diff = array_diff($newCollaborators, $curCollaborators)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'C';
             $change->description = "Added " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
         if ($diff = array_diff($curCollaborators, $newCollaborators)) {
             $users = array_map(function ($id) {
                 return User::findOrFail($id)->name();
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'C';
             $change->description = "Removed " . join(', ', $users);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
     }
     $newCollaborators = $deptCollabs ? $deptCollabs : array();
     $curCollaborators = $goat->departmentCollaborators()->get()->map(function ($dept) {
         return $dept->id;
     })->toArray();
     sort($newCollaborators);
     sort($curCollaborators);
     if ($newCollaborators != $curCollaborators) {
         if ($diff = array_diff($newCollaborators, $curCollaborators)) {
             $depts = array_map(function ($id) {
                 return Department::findOrFail($id)->name;
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'C';
             $change->description = "Added " . join(', ', $depts);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
         if ($diff = array_diff($curCollaborators, $newCollaborators)) {
             $depts = array_map(function ($id) {
                 return Department::findOrFail($id)->name;
             }, $diff);
             $change = new \App\Change();
             $change->change_type = 'C';
             $change->description = "Removed " . join(', ', $depts);
             $change->goat_id = $goat->id;
             $change->user_id = Auth::user()->id;
             $change->save();
         }
     }
     if ($goat->due_date != $due_date) {
         $change = new \App\Change();
         $change->change_type = 'T';
         $change->description = "Changed from " . \Carbon\Carbon::parse($goat->due_date)->toDateString() . " to " . \Carbon\Carbon::parse($due_date)->toDateString();
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
     if ($goat->priority != $priority) {
         $change = new \App\Change();
         $change->change_type = 'P';
         $change->description = "Changed from " . $this->priority_string($goat->priority) . " to " . $this->priority_string($priority);
         $change->goat_id = $goat->id;
         $change->user_id = Auth::user()->id;
         $change->save();
     }
 }
Beispiel #21
0
function parentDepartment($currentDepartment)
{
    $department = Department::find($currentDepartment);
    return $department ? $department->parent_department ? $department->parent_department : $currentDepartment : null;
}
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function postEdit($id)
 {
     $rules = array('name' => 'required|min:6|max:100', 'address' => 'required|min:6|max:100', 'weight_limit' => 'required', 'city_id' => 'required', 'phone' => 'required');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::route('new-department')->withErrors($validator);
     }
     $department = Department::find($id);
     $department->name = Input::get('name');
     $department->phone = Input::get('phone');
     $department->adress = Input::get('address');
     $department->city_id = intval(Input::get('city_id'));
     $department->weight_limit = intval(Input::get('weight_limit'));
     $department->save();
     return Redirect::route('departments', ['category' => 1]);
 }
Beispiel #23
0
 /**
  * Update the specified resource in storage.
  *
  * @param  Requests\PaperRequest $request
  * @param  Paper $paper
  * @return \Illuminate\Http\Response
  */
 public function update(Requests\PaperRequest $request, Paper $paper)
 {
     $this->paper->setPaper($paper);
     $status = $request->get('status_id');
     $reviewer = $request->get('reviewer_id') ?: null;
     if (!$paper->reviewer_id && $reviewer) {
         if ($request->get('status_id') < 2) {
             $status = 2;
         }
     }
     $department = Department::find($request->get('department_id'));
     $this->paper->setUrl($department->keyword);
     if (!in_array($request->get('category_id'), $department->categories->lists('id')->toArray())) {
         return redirect()->back()->with('error', 'department-category');
     }
     if ($paper->department_id != $request->get('department_id')) {
         #if department is changed files must be moved
         $url = $this->paper->prefix();
         $oldPath = $url . '/' . $paper->department->keyword . '/';
         $newPath = $url . '/' . $department->keyword . '/';
         File::move($oldPath . $paper->source, $newPath . $paper->source);
         if ($paper->payment_source) {
             File::move($oldPath . $paper->payment_source, $newPath . $paper->payment_source);
         }
     }
     $paperData = ['department_id' => $department->id, 'category_id' => $request->get('category_id'), 'status_id' => $status, 'title' => $request->get('title'), 'description' => $request->get('description'), 'authors' => $request->get('authors'), 'user_id' => $request->get('user_id'), 'reviewer_id' => $reviewer, 'updated_at' => Carbon::now(), 'payment_description' => $request->get('payment_description')];
     if ($request->file('paper')) {
         $paperData['source'] = $this->paper->buildFileName();
         $this->paper->deleteFile();
     }
     if ($request->file('payment_source')) {
         $paperData['payment_source'] = $this->paper->buildInvoiceName();
         $this->paper->deleteInvoice();
     }
     $this->paper->upload();
     $oldReviewer = $paper->reviewer_id;
     $paper->update($paperData);
     if ($oldReviewer != $paper->reviewer_id) {
         #reviewer changed
         event(new ReviewerPaperSet($paper));
     }
     return redirect()->action('Admin\\PaperController@index')->with('success', 'updated');
 }
 public function getAddMember()
 {
     $dep = Department::find(Auth::user()->department_id);
     $title = "Add Developer To " . $dep->name . " Department";
     return view('html.team.leader.add-member', compact('dep', 'title'));
 }
 /**
  * 打印预约单
  *
  * @param Request $request
  * @param Registration $registration
  */
 public function printInfo(Request $request, Registration $registration)
 {
     $user = $request->user();
     if ($user->id != $registration->user_id) {
         return response()->json(['status' => 1, 'message' => '无权限']);
     }
     if ($registration->is_paid == 1) {
         if ($registration->deals()->count() != 1) {
             return response()->json(['status' => 4, 'message' => '数据异常']);
         }
         $schedule = Schedule::find($registration->schedule_id);
         $doctor = Doctor::find($schedule->doctor_id);
         $department = Department::find($doctor->department_id);
         $hospital = Hospital::find($department->hospital_id);
         $data = array('user_name' => $user->name, 'sex' => $user->sex, 'age' => $user->age, 'doctor' => $doctor->doctor_name, 'doctor_time' => $schedule->doctoring_time, 'doctor_data' => $schedule->doctoring_data, 'department' => $department->department_nam, 'hospital' => $hospital->hospital_name, 'fee' => $registration->fee, 'registration_time' => $registration->created_at);
         return $data;
     } else {
         return response()->json(['status' => 8, 'message' => '未付款,不能打印']);
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     $dept = Department::find($id);
     $dept->fill($request->input())->save();
     return redirect('admin/depts');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     $department = Department::find($id);
     $department->delete();
     return redirect()->route('departments.index');
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $dept = Department::find($id);
     if ($dept && $dept->p_id != null) {
         $dept->delete();
     }
     return Response()->json(['result' => 'success']);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id ID of the department to destroy
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $user = Session::get('user');
     // Only super user can delete departments
     if ($user->is_super_user == false) {
         abort(401, 'Unauthorized');
     }
     // Find selected department
     $department = Department::find($id);
     if ($department == null) {
         return redirect()->route('dashboard.settings.departments.index')->with('message', 'Error: Department not found');
     }
     // No adverts or playlists should depend on the department
     // in order to delete it
     $adCount = $department->Adverts()->count();
     $plCount = $department->Playlists()->count();
     if ($adCount != 0 || $plCount != 0) {
         return redirect()->route('dashboard.settings.departments.index')->with('message', 'Unable to delete ' . $department->name . ', one or more adverts and playlists depend on it');
     }
     // Delete department
     $department->delete();
     return redirect()->route('dashboard.settings.departments.index')->with('message', 'Department deleted successfully');
 }
 /**
  * Toggles a users access level between admin and user
  * @param \Illuminate\Http\Request $request
  * @return \Illuminate\Http\Response
  */
 public function togglePermission(Request $request)
 {
     if (Session::has('departmentID') == false) {
         return redirect()->route('dashboard.settings.privileges.index')->with('message', 'Please select a department to proceed');
     }
     $departmentID = Session::get('departmentID');
     $userID = $request->input('userID');
     // Load theselected user and department
     $user = User::find($userID);
     $department = Department::find($departmentID);
     if ($user == null || $department == null) {
         return redirect()->route('dashboard.settings.privileges.index')->with('message', 'Error: User or Department not found');
     }
     // Toggle based on current privileges
     if ($user->isAdmin($departmentID)) {
         $user->Departments()->updateExistingPivot($departmentID, array('is_admin' => 0));
     } else {
         $user->Departments()->updateExistingPivot($departmentID, array('is_admin' => 1));
     }
     // Update info
     $users = $department->Users()->get();
     $allowed_departments = Session::get('allowed_departments');
     Session::flash('message', 'Account: ' . $user->username . ' access level updated');
     Session::flash('remember_id', $department->id);
     $data = array('allowed_departments' => $allowed_departments, 'department' => $department, 'users' => $users);
     return view('pages/privileges', $data);
 }