コード例 #1
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $staff_team = '';
     $leader = '';
     $pie_leader = '';
     $department = '';
     $department = Department::leftJoin('staff', 'department.id', '=', 'staff.department_id')->join('level', 'staff.level_id', '=', 'level.id')->join('role', 'level.role_id', '=', 'role.id')->select(DB::raw('department.name as name_dep,role.name,count(*) as num'))->groupBy('department.name', 'role.name')->get()->toArray();
     $num_staff = $department;
     $pie = array();
     foreach ($department as $value) {
         $pie[$value['name_dep']][] = array($value['name'], (int) $value['num']);
     }
     // is Leader
     if (Gate::allows('check-leader')) {
         $department = Department::leftJoin('staff', 'department.id', '=', 'staff.department_id')->join('level', 'staff.level_id', '=', 'level.id')->join('role', 'level.role_id', '=', 'role.id')->select(DB::raw('department.name as name_dep,role.name,count(*) as num'))->where(['department.id' => Auth::user()->department_id, 'department.active' => 1])->groupBy('department.name', 'role.name')->get()->toArray();
         $num_staff = $department;
         $pie = array();
         foreach ($department as $value) {
             $pie[$value['name_dep']][] = array($value['name'], (int) $value['num']);
         }
     }
     // is Developer
     // if is manager / != department / yourself
     // denied
     if (Gate::allows('check-developer')) {
         $staff = StaffTeam::where('staff_id', Auth::user()->id)->get()->first();
         if (isset($staff) && !empty($staff)) {
             $staff_team = StaffTeam::where('team_id', $staff->team_id)->where('staff_id', '!=', Auth::user()->id)->get();
             $team = Team::where('id', $staff->team_id)->get()->first();
             $leader = Staff::find($team->creator);
         }
     }
     return view('admin.department.home', compact('pie', 'staff_team', 'leader', 'num_staff'));
 }
コード例 #2
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data['title'] = 'Home';
     $data['home'] = 1;
     $staff = Staff::find(\Session::get('user')->staff_id);
     // dd($staff);
     if ($staff) {
         $classes = array('Please select a class');
         foreach ($staff->classes as $class) {
             $classes[$class->id] = $class->name;
         }
         $data['classes'] = $classes;
     }
     if (session('user')->inRole('coder') || session('user')->inRole('principal')) {
         return view('dashboard', $data);
     } elseif (session('user')->inRole('head_teacher')) {
         return view('dashboard_head_teacher', $data);
     } elseif (session('user')->inRole('billing_officer')) {
         // return view('dashboard_billing_officer', $data);
         return redirect()->route('billing.fee_schedules.index');
     } elseif (session('user')->inRole('admin_dept_officer')) {
         return view('dashboard_head_teacher', $data);
     } else {
         return view('unauthorized', $data);
     }
 }
コード例 #3
0
ファイル: AdminController.php プロジェクト: eyamu/sms
 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update(Requests\UpdateAdminRequest $request, $id)
 {
     $staff = Staff::find($id);
     $updated = $staff->fill($request->input())->save();
     if ($updated) {
         return \Redirect::route('show_profile', $id)->with('message', 'Profile successfuly Updated!');
     } else {
         return \Redirect::route('edit_admin')->with('error-message', 'Failed to Update Profile!');
     }
 }
コード例 #4
0
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $data['title'] = 'Invoices';
     $data['invoice_menu'] = 1;
     $staff = Staff::find(\Session::get('user')->staff_id);
     foreach ($staff->classes as $class) {
         $classes[$class->id] = $class->name;
     }
     //create array to hole school session starting 10 yrs from current date
     $sessions = ['Select Session'];
     for ($i = intval(date('Y')) - 10; $i < intval(date('Y')) + 15; $i++) {
         $session = $i . '-' . ($i + 1);
         $sessions[$session] = $session;
     }
     $data['sessions'] = $sessions;
     $data['terms'] = ['Select Term', 1, 2, 3];
     $data['classes'] = studentClass::lists('name', 'id')->prepend('Select Class');
     $data['fee_elements'] = FeeElement::where('status_id', 1)->get();
     return view('billing.invoices.class_invoices', $data);
 }
コード例 #5
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function staffIndex()
 {
     //
     $staff_options = Staff::select('Id', DB::raw('CONCAT(first_name, " ", last_name) AS full_name'))->orderBy('first_name')->lists('full_name', 'Id');
     $print = Input::get('print');
     $staff_id = Input::get('staff_id');
     if ($staff_id) {
         $staff = Staff::find($staff_id);
         $posts = $staff->posts;
         $media_mention = $staff->posts->sum('media_mention');
         $presentation = $staff->posts->sum('presentation');
         $meeting = $staff->posts->sum('meeting');
         $testimonial = $staff->posts->sum('testimonial');
         $sponsored_event = $staff->posts->sum('sponsored_event');
         $on_campus_collaboration = $staff->posts->sum('on_campus_collaboration');
         $off_campus_collaboration = $staff->posts->sum('off_campus_collaboration');
         $achievement = $staff->posts->sum('achievement');
         $satifaction_survey = $staff->posts->sum('satifaction_survey');
         $other = $staff->posts->sum('other');
         $total = $staff->posts->count();
         $today = Carbon::now();
     } else {
         $posts = Post::orderBy('created_at', 'DESC')->get();
         $media_mention = DB::table('posts')->sum('media_mention');
         $presentation = DB::table('posts')->sum('presentation');
         $meeting = DB::table('posts')->sum('meeting');
         $testimonial = DB::table('posts')->sum('testimonial');
         $sponsored_event = DB::table('posts')->sum('sponsored_event');
         $on_campus_collaboration = DB::table('posts')->sum('on_campus_collaboration');
         $off_campus_collaboration = DB::table('posts')->sum('off_campus_collaboration');
         $achievement = DB::table('posts')->sum('achievement');
         $satifaction_survey = DB::table('posts')->sum('satifaction_survey');
         $other = DB::table('posts')->sum('other');
         $total = DB::table('posts')->count();
         $today = Carbon::now();
     }
     if ($print) {
         return view('print', compact('posts', 'total', 'media_mention', 'presentation', 'meeting', 'testimonial', 'sponsored_event', 'on_campus_collaboration', 'off_campus_collaboration', 'achievement', 'satifaction_survey', 'other', 'today'));
     }
     return view('posts.report_staff', compact('staff_options', 'staff_id', 'posts', 'total', 'media_mention', 'presentation', 'meeting', 'testimonial', 'sponsored_event', 'on_campus_collaboration', 'off_campus_collaboration', 'achievement', 'satifaction_survey', 'other', 'today'));
 }
コード例 #6
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if (Gate::allows('check-leader')) {
         $staff = Staff::find($id)->level->role;
         if ($staff->name != "Developer") {
             return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
         }
     }
     if (Gate::allows('check-admin')) {
         $staff = Staff::find($id)->level->role;
         if ($staff->name == "Developer") {
             return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
         }
     }
     if (Gate::allows('check-developer')) {
         return redirect()->route('admin.department.index')->with('message', 'Access is denied');
     }
     // if staff belongsto one team
     $findStaff = StaffTeam::where('staff_id', $id)->get()->toArray();
     if (!empty($findStaff)) {
         return redirect()->route('admin.staff.index')->with('message', 'The staff belongto team !');
     }
     $staff = Staff::find($id);
     $staff->delete();
     // delete staff in review
     $staffReview = Review::where('reviewer_id', $id)->delete();
     $staffReview = Review::where('staff_id', $id)->delete();
     // delete staff in staff_team
     $staffReview = StaffTeam::where('staff_id', $id)->delete();
     return redirect()->route('admin.staff.index')->with('message', 'Delete staff complete !');
 }
コード例 #7
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     if (Gate::allows('check-leader')) {
         $staff = Staff::find($id)->level->role;
         if ($staff->name != "Developer") {
             return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
         }
     }
     if (Gate::allows('check-admin')) {
         $staff = Staff::find($id)->level->role;
         if ($staff->name == "Developer") {
             return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
         }
     }
     if (Gate::allows('check-developer')) {
         return redirect()->route('admin.department.index')->with('message', 'Access is denied');
     }
     $staff = Staff::find($id);
     $staff->delete();
     return redirect()->route('admin.staff.index')->with('message', 'Delete staff complete !');
 }
コード例 #8
0
 /**
  * Update the specified resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function update(Request $request, $id)
 {
     // dd($request);
     //get user u ant to update
     $user = \Sentinel::findById($id);
     //get the persons details
     $staff = Staff::find($request->user);
     $data = $request->except('_token');
     $rules = ['password' => 'min:4|required'];
     $validator = \Validator::make($data, $rules);
     if ($validator->passes()) {
         //array to hold final permission values
         $array_of_permissions = Helper::prepPermissions($request->exempt_permission, 'false');
         $credentials = ['email' => $staff->email, 'password' => $request->password, 'permissions' => $array_of_permissions, 'staff_id' => $staff->id, 'first_name' => $staff->fname, 'last_name' => $staff->lname];
         //update user
         $user = \Sentinel::update($user, $credentials);
         //get the id(s) of the current roles of this user in an array
         $current_roles = array();
         foreach ($user->roles as $value) {
             $current_roles[] = $value->id;
         }
         //compute role(s) to add
         $add_roles = array_diff($request->assign_roles, $current_roles);
         //compute role(s) to delete
         $delete_roles = array_diff($current_roles, $request->assign_roles);
         //update user role(s)
         $user = \Sentinel::findById($user->id);
         //add ne role(s)
         foreach ($add_roles as $role_id) {
             $role = \Sentinel::findRoleById($role_id);
             $role->users()->attach($user);
         }
         //delete role(s), if any
         foreach ($delete_roles as $role_id) {
             \DB::table('role_users')->where('role_id', $role_id)->where('user_id', $user->id)->delete();
         }
         return \Redirect::to('settings/users/create');
     } else {
         return \Redirect::back()->withInput()->withErrors($validator);
     }
 }
コード例 #9
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $staff = Staff::find($id);
     $staff->destroy();
     return $this->index();
 }
コード例 #10
0
 public function fetchSheet(Request $request)
 {
     // dd($request->class);
     $class_id = $request->class;
     $data['title'] = 'Scoresheet';
     $data['results_menu'] = 1;
     //data for selecting class
     $staff = Staff::find(\Session::get('user')->staff_id);
     if (\Sentinel::getUser()->inRole('principal') or \Sentinel::getUser()->inRole('coder')) {
         $data['classes'] = studentClass::lists('name', 'id')->prepend('Select a class');
     } else {
         $classes = array('Please select a class');
         foreach ($staff->classes as $class) {
             $classes[$class->id] = $class->name;
         }
         $data['classes'] = $classes;
     }
     // dd($request);
     if ($class_id == 0) {
         session()->flash('flash_message', 'Select a class');
         // session()->flash('flash_message_important', true);
         return \Redirect::to('academics/results');
     }
     $class = studentClass::where(['id' => $class_id])->first();
     $subjects = \DB::table('class_subject')->where(['class_id' => $class_id])->get();
     $students = Student::where(['class_id' => $class_id])->get();
     //add students to class results table with initial values of zero
     foreach ($students as $student) {
         foreach ($class->subjects as $subject) {
             //ensure that at least a session variable has been set. If there is at least on session variable set, the system will run well else it'll throw an error
             if (CurrentTerm::all() !== null) {
                 $table = 'class_results_' . \Session::get('current_session') . '_' . \Session::get('current_term');
                 $positions_table = 'class_positions_' . \Session::get('current_session') . '_' . \Session::get('current_term');
                 $subject_exemption_table = 'subject_ex_' . \Session::get('current_session') . '_' . \Session::get('current_term');
                 //initialize class results table
                 try {
                     \DB::table($table)->insert(['class_id' => $class->id, 'student_id' => $student->id, 'subject_id' => $subject->id, 'created_at' => date('Y-m-d H:i:s'), 'updated_at' => date('Y-m-d H:i:s')]);
                 } catch (\Illuminate\Database\QueryException $e) {
                     $errorCode = $e->errorInfo[1];
                     // if($errorCode == 1062){
                     //     session()->flash('flash_message', 'Session and Term variables have alreaddy been created.');
                     //     return \Redirect::back()->withInput($request->except('element_id', 'amount'));
                     // }
                 }
                 //initialize class positions table
                 try {
                     \DB::table($positions_table)->insert(['class_id' => $class->id, 'student_id' => $student->id]);
                 } catch (\Illuminate\Database\QueryException $e) {
                     $errorCode = $e->errorInfo[1];
                     // if($errorCode == 1050){
                     //     session()->flash('flash_message', 'Result table for chosen session and term already exists.');
                     //     return \Redirect::back()->withInput();
                     // }
                 }
                 //initialize subject exemption table
                 try {
                     \DB::table($subject_exemption_table)->insert(['class_id' => $class->id, 'student_id' => $student->id, 'subject_id' => $subject->id]);
                 } catch (\Illuminate\Database\QueryException $e) {
                     $errorCode = $e->errorInfo[1];
                     if ($errorCode == 1050) {
                         session()->flash('flash_message', 'Result table for chosen session and term already exists.');
                         return \Redirect::back()->withInput();
                     }
                 }
             } else {
                 session()->flash('flash_message', 'Please set session variables. Go to Settings>school settings');
                 return redirect()->back()->withInput();
             }
         }
     }
     $data['class'] = $class;
     $data['subjects'] = $subjects;
     $data['students'] = $students;
     $data['selected_class'] = 1;
     return view('academics.results.index', $data);
 }
コード例 #11
0
 public function editReview($idReview = 0, $idStaff = 0)
 {
     $staff = Staff::find($idStaff);
     $review = Review::find($idReview);
     if (Gate::allows('check-leader')) {
         if ($staff->level->role->name == 'Manager' || $staff->department_id != Auth::user()->department_id || $staff->id == Auth::user()->id || $review->reviewer_id != Auth::user()->id) {
             return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
         }
     }
     // is Manager
     if (Gate::allows('check-manager')) {
         if ($staff->level->role->name == 'Manager') {
             return redirect()->route('admin.staff.index')->with('message', 'Access is denied');
         }
     }
     // is Developer
     // if is manager / != department / yourself
     // denied
     if (Gate::allows('check-developer')) {
         if ($staff->level->role->name == 'Manager' || $staff->department_id != Auth::user()->department_id || $staff->id == Auth::user()->id || $review->reviewer_id != Auth::user()->id) {
             return redirect()->route('admin.department.index')->with('message', 'Access is denied');
         }
     }
     return view('admin.review.update', compact('staff', 'review'));
 }