public function destroy(Department $department)
 {
     if (!Helper::getMode()) {
         return redirect()->back()->withErrors(config('constants.DISABLE_MESSAGE'));
     }
     $department->delete();
     return redirect('/configuration#department')->withSuccess(config('constants.DELETED'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('departments')->delete();
     $department = new Department(['deptHeadId' => '1001', 'department' => 'Neurology']);
     $department->save();
     $department = new Department(['deptHeadId' => '1002', 'department' => 'Emergency Room']);
     $department->save();
     $department = new Department(['deptHeadId' => '1003', 'department' => 'ICU']);
     $department->save();
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $departments = ['Unknown', 'City Administrator', 'Community Services', 'Corporate Services', 'Communications and Economic Development', 'Planning and Development', 'Public Safety', 'Public Works and Engineering'];
     foreach ($departments as $name) {
         $department = new Department();
         $department->active = true;
         $department->name = $name;
         $department->save();
     }
 }
 /**
  * Show the form for creating a new resource.
  *
  * @return Response
  */
 public function create($filing_type = '')
 {
     //Initialization
     $projects = new Project();
     $EASRequest = new EASRequest();
     $RequestType = new RequestType();
     $RequestTypeApprover = new RequestTypeApprover();
     $User = new User();
     $Department = new Department();
     $data['filing_type'] = $filing_type;
     $user_id = trim(Auth::user()->app_code);
     //Retrieve user granted projects
     if ($filing_type == 'PR') {
         $data['data_charge_to_projects'] = $projects->getProjects('', $filing_type, '3');
     } else {
         $data['projects'] = $projects->getProjects($user_id, $filing_type, '3');
     }
     //Additional variables per request type, if any.
     if ($filing_type == 'RFR') {
         $data['granted_request_types'] = $RequestTypeApprover->getUserGrantedRequestTypes($user_id, 'RFR');
     } else {
         if ($filing_type == 'PR') {
             $data['data_pr_request_types'] = $RequestType->getRequestType($filing_type, 'all');
             $data['data_charge_to_teams'] = $Department->getDepartments();
             $data['requesting_department'] = $User->getDepartment($user_id);
             $data['pr_no'] = $data['requesting_department']['dept_initial'] . '-' . date('mmddY') . '-';
             $data['team_members'] = $User->getCoTeamMembers($user_id);
         }
     }
     //Return View
     if ($filing_type == 'PR') {
         return view('request.purchase.file', $data);
     }
     return view('request.file', $data);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     //
     $data = $request->except('_token');
     Department::create($data);
     return back();
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     Schema::create('delegations', function (Blueprint $table) {
         $table->increments('id');
         $table->integer('delegate_to_id')->unsigned();
         $table->integer('delegate_from_id')->unsigned();
         $table->integer('department_id')->unsigned();
         $table->boolean('user_set')->default(0);
         $table->timestamps();
     });
     Schema::table('delegations', function ($table) {
         $table->unique(array('department_id', 'delegate_from_id'));
         //A user can only vote once on a motion
         $table->foreign('delegate_to_id')->references('id')->on('users');
         $table->foreign('delegate_from_id')->references('id')->on('users');
         $table->foreign('department_id')->references('id')->on('departments');
     });
     $validUsers = User::notCouncillor()->get();
     $departments = Department::all();
     $numberOfCouncilors = User::councillor()->count();
     if ($numberOfCouncilors) {
         foreach ($validUsers as $user) {
             foreach ($departments as $department) {
                 $councillors = User::councillor()->get();
                 $leastDelegatedToCouncillor = $councillors->sortBy('totalDelegationsTo')->first();
                 $newDelegation = new Delegation();
                 $newDelegation->department_id = $department->id;
                 $newDelegation->delegate_from_id = $user->id;
                 $newDelegation->delegate_to_id = $leastDelegatedToCouncillor->id;
                 $newDelegation->save();
             }
         }
     }
 }
Exemple #7
0
 public function run()
 {
     $depts = Department::filterByDomain(1)->lists('name', 'id')->toArray();
     $prompt = [0 => 'Department'];
     $departments = $prompt + $depts;
     return view("widgets.select_department", ['departments' => $departments]);
 }
 /**
  * Run the migrations.
  *
  * @return void
  */
 public function up()
 {
     // Create level 0 : member
     Level::create(['level' => 0, 'name' => 'membre']);
     // Create level 1 : band_creator
     Level::create(['level' => 1, 'name' => 'manager']);
     // Create level 2 : teacher
     Level::create(['level' => 2, 'name' => 'professeur']);
     // Create level 3 : admin
     Level::create(['level' => 3, 'name' => 'admin']);
     // Create level 10 : webmaster
     Level::create(['level' => 10, 'name' => 'webmaster']);
     // Create departement : "aucun"
     Department::create(['name' => 'Aucun', 'short_name' => 'Aucun']);
     // Create user : Webmaster (lvl 10)
     User::create(['first_name' => 'Webmaster', 'last_name' => 'Webmaster', 'email' => 'webm@ster', 'school_year' => 0, 'department_id' => 1, 'password' => bcrypt('webmastercmt'), 'level_id' => 5, 'slug' => 'webmaster-webmaster-1']);
     Category::create(['name' => 'Aucune']);
     Category::create(['name' => 'Autre']);
     Category::create(['name' => 'Présentation']);
     Category::create(['name' => 'Création de groupe']);
     Category::create(['name' => 'Recherche de groupe']);
     Category::create(['name' => 'Échange/Vente']);
     //Creation basic instruments :
     $instruments = ['autre', 'guitare', 'piano', 'basse', 'chant', 'flûte', 'violon', 'contrebasse', 'clarinette', 'saxophone', 'batterie', 'violoncelle', 'guitare électrique', 'flûte traversière', 'trompette', 'cor', 'trombone', 'tuba'];
     $this->create_instrument($instruments);
 }
 public function index(Request $request)
 {
     $query = $request->input();
     $changes = Change::select('*');
     if ($request->input('user')) {
         $changes = $changes->where('user_id', $request->input('user'));
     }
     if ($request->input('start')) {
         $changes = $changes->where('changes.created_at', '>=', $request->input('start'));
     }
     if ($request->input('end')) {
         $changes = $changes->where('changes.created_at', '<=', $request->input('end'));
     }
     if ($request->input('goat')) {
         $changes = $changes->where('goat_id', $request->input('goat'));
     }
     if ($request->input('type')) {
         $changes = $changes->where('change_type', $request->input('type'));
     }
     $changes = $changes->join('goats', 'goats.id', '=', 'changes.goat_id')->select('changes.description as description', 'changes.created_at as created_at', 'changes.change_type as change_type', 'changes.user_id as user_id', 'changes.goat_id as goat_id');
     if ($request->input('dept')) {
         $changes = $changes->where('department_id', $request->input('dept'));
     }
     return view('changelog')->with(['changes' => $changes->orderBy('created_at', 'desc')->paginate(20), 'users' => \App\User::all(), 'depts' => \App\Department::all(), 'query' => $query]);
 }
 /**
  * User chose single employee from dropdown to be edited
  *
  * @param Request $request
  * @return mixed
  */
 public function doChooseEmployee(Request $request)
 {
     $employee = Employee::find($request->input('choose'));
     $dept = ['' => 'Choose...'] + Department::lists('name', 'id')->all();
     $location = ['' => 'Choose...'] + Location::lists('name', 'id')->all();
     return view('admin.edit-employee', compact('dept', 'location', 'employee'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $faker = Faker\Factory::create();
     foreach (range(1, 10) as $index) {
         Department::create(['title' => $faker->company]);
     }
 }
 public function departmentView($department_code, $filter)
 {
     $ticketFilter = new TicketFilter($department_code, $filter);
     $tickets = $ticketFilter->departmentViewFilter();
     $department = \App\Department::where('department_code', $department_code)->first();
     return view('helpdeskviews.department', compact('department', 'tickets', 'filter'));
 }
 public function search(Request $request)
 {
     $results = array();
     $term = $request->get('term');
     $goals = Goal::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $objectives = Objective::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $actions = Action::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $tasks = Task::where('body', 'like', '%' . $term . '%')->orderBy('body', 'asc')->get();
     $teams = Team::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get();
     $departments = Department::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get();
     $users = User::where('name', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get()->all();
     foreach (User::where('email', 'like', '%' . $term . '%')->orderBy('name', 'asc')->get() as $matching_user_email) {
         if (in_array($matching_user_email, $users)) {
             continue;
         }
         $users[] = $matching_user_email;
     }
     $notes = Note::where('content', 'like', '%' . $term . '%')->orderBy('content', 'asc')->get();
     $types = [$goals, $objectives, $actions, $tasks, $teams, $departments, $users, $notes];
     foreach ($types as $type) {
         foreach ($type as $result) {
             $results[] = $result;
         }
     }
     return view('search.show')->with('results', $results)->with('term', $term);
 }
 public function update(Request $request)
 {
     $department = Department::find($request->department_id);
     $department->name = $request->name;
     $department->save();
     return Redirect::to('/admin/department');
 }
 public function importDept($destfile)
 {
     $this->count['dept->success'] = 0;
     $this->count['dept->failed'] = 0;
     Excel::load($destfile, function ($reader) {
         $rules = ['name' => 'required|unique_with:departments,company_id,costcent', 'company_id' => 'required|exists:companies,id', 'costcent' => 'required'];
         $sheetsCount = $reader->getSheetCount();
         for ($i = 0; $i < $sheetsCount; $i++) {
             $sheets = $reader->getSheet($i)->toArray();
             $company_name = $reader->getSheet($i)->getTitle();
             $dept['company_id'] = Company::where('name', $company_name)->value('id');
             $sheetCount = count($sheets);
             for ($j = 6; $j < $sheetCount; $j++) {
                 $dept['name'] = trim($sheets[$j][1]);
                 $dept['costcent'] = trim($sheets[$j][10]);
                 $dept['description'] = $dept['name'];
                 $dept_v = \Validator::make($dept, $rules);
                 if ($dept_v->passes()) {
                     Department::create($dept);
                     $this->count['dept->success'] += 1;
                 } else {
                     $this->count['dept->failed'] += 1;
                 }
             }
         }
         //END
     });
     return $this->count;
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $rules = ['name' => ['required', 'unique:archive,name', 'regex:' . config('app.expressions.dir')]];
     if ($this->systemAdmin) {
         $rules['department_id'] = 'required';
     }
     $validator = Validator::make($request->all(), $rules);
     if ($validator->fails()) {
         return redirect()->back()->withErrors($validator)->withInput();
     }
     DB::transaction(function () use($request) {
         #add all papers from department to archive
         $archive = Archive::create($request->all());
         $department = Department::findOrFail($request->get('department_id'));
         $paperObj = new PaperClass();
         $archivePath = 'archive/';
         if (!File::exists($archivePath . $archive->name)) {
             File::makeDirectory($archivePath . $archive->name);
         }
         $newPath = $archivePath . $archive->name . '/';
         $oldPath = $paperObj->prefix() . '/' . $department->keyword . '/';
         foreach ($department->papers()->archived()->get() as $paper) {
             $paper->archive()->associate($archive);
             $paper->save();
             File::move($oldPath . $paper->source, $newPath . $paper->source);
             if ($paper->payment_source) {
                 File::move($oldPath . $paper->payment_source, $newPath . $paper->payment_source);
             }
         }
     });
     return redirect()->action('Admin\\ArchiveController@index')->with('success', 'updated');
 }
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function edit($id)
 {
     $departments = Department::all();
     $subjects = Subject::all();
     $department_subject = DepartmentSubject::find($id);
     return view('admin.department_subject.department_subject_edit', compact('departments', 'subjects', 'department_subject'));
 }
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     DB::table('departments')->delete();
     Department::create(['title' => 'Администрация']);
     Department::create(['title' => 'Отдел 1']);
     Department::create(['title' => 'Отдел 2']);
     Department::create(['title' => 'Отдел 3']);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(DepartmentRequest $request)
 {
     $dept = Department::where('id', $request['deptID'])->first();
     $dept->name = $request['name'];
     $dept->save();
     \Session::flash('success', $request['name'] . ' has been successfully updated!');
     return redirect()->back();
 }
 /**
  * Show information update form. Please note
  * that a departmentStaff can only update
  * his name, email and password
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function showUpdateInfoForm()
 {
     // Get the logged in departmentStaff
     $departmentStaff = DepartmentStaff::find(Auth::guard('departmentStaff')->user()->id);
     // Get the list of departments present in databse
     $departments = Department::all();
     return view($this->updateInfoView, ['departmentStaff' => $departmentStaff, 'departments' => $departments]);
 }
 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function showRegistrationForm()
 {
     // Get the list of departments
     $departmentArr = Department::all();
     // Get the list of sections
     $sectionArr = Section::all();
     return view($this->registerView)->with(['departments' => $departmentArr, 'sections' => $sectionArr]);
 }
 public function show($id)
 {
     $user = User::find($id);
     $sections = Section::lists('name', 'id');
     $departments = Department::lists('name', 'id');
     $subjects = $user->type == 'student' ? $user->studentSubjects : $user->teacherSubjects;
     return view('admin.user.show', compact('user', 'sections', 'subjects', 'departments'));
 }
 /**
  * @param Request $request
  * @return \Illuminate\Contracts\Routing\ResponseFactory|\Symfony\Component\HttpFoundation\Response
  */
 public function getCourse(Request $request)
 {
     if ($request->ajax()) {
         $department = Department::where('name', $request->input('name'))->first();
         $courses = $department->courses->pluck('name');
         return response($courses);
     }
 }
Exemple #24
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $this->data['user'] = User::where('deleted_at', null)->count();
     $this->data['user_disabled'] = User::where('deleted_at', !null)->count();
     $this->data['department'] = Department::where('enabled', 1)->count();
     $this->data['position'] = Position::where('enabled', 1)->count();
     return view('pages.admin.dashboard', $this->data);
 }
 /**
  * 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');
 }
 /**
  * Show the application registration form.
  *
  * @return \Illuminate\Http\Response
  */
 public function getRegister()
 {
     $departmentList = Department::orderBy('created_at')->get();
     $deptSelectValues = [];
     foreach ($departmentList as $dept) {
         $deptSelectValues[$dept['id']] = $dept['dept_name'];
     }
     return view('auth.register')->with(compact('deptSelectValues'));
 }
 public function searchAll()
 {
     $query = Request::input('q');
     if (empty($query)) {
         return Response::json(array(), 400);
     }
     $data = array_merge(Employee::search($query)->toArray(), Department::search($query)->toArray());
     return Response::json($data);
 }
 /**
  * Update the specified resource in storage.
  *
  * @param  Request  $request
  * @param  int  $id
  * @return Response
  */
 public function update(DepartmentRequest $request)
 {
     $dept = Department::where('id', $request['deptID'])->first();
     $dept->name = $request['name'];
     $dept->updated_by = \Auth::user()->id;
     $dept->save();
     \Session::flash('success', 'well done! Role ' . $request['name'] . ' has been successfully added!');
     return redirect()->back();
 }
 /**
  * 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');
 }
Exemple #30
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next, $department)
 {
     $department = Department::findOrFail($department);
     $lock = $department->settings()->key('papers');
     if (isset($lock->value) && $lock->value) {
         return redirect()->back()->with('error', 'lock-papers');
     }
     return $next($request);
 }