/**
  * 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);
 }
示例#2
0
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot()
 {
     $this->app->bind('ConferenceBaseController', function () {
         return new ConferenceBaseController();
     });
     $departmentsSelect = getNomenclatureSelect(Department::with(['langs' => function ($query) {
         $query->lang();
     }])->sort()->active()->get(), true);
     view()->share('departmentsSelect', $departmentsSelect);
 }
示例#3
0
 /**
  * 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) {
         return view('html.dashboard.manager', compact('title', 'model'));
     } elseif (Auth::user()->role_id == 2) {
         $list = \App\Team::where('created_user_id', Auth::user()->id)->with('detail')->first();
         return view('html.dashboard.leader', compact('title', 'list'));
     } else {
         $var = \App\TeamDetail::select('team_id')->where('staff_id', Auth::user()->id)->first();
         $bol = "";
         if ($var != null) {
             $team = \App\Team::find($var->team_id);
             $leader = User::find($team->created_user_id);
             $bol = "true";
             $list = \App\TeamDetail::select('*')->where('staff_id', '<>', Auth::user()->id)->where('team_id', $var->team_id)->get();
         }
         return view('html.dashboard.developer', compact('title', 'list', 'bol', 'leader'));
     }
 }
 public function evaluationMultiple($date_start, $date_end, $daily_work_hours, $department_id, $position_id, $member_id, $download)
 {
     $download = (int) $download;
     $this->member = DB::table('members')->where('id', $member_id)->first();
     $this->member->position = DB::table('positions')->where('id', $position_id)->first();
     $this->member->average_productivity = 0;
     $this->member->average_quality = 0;
     $this->member->count = 0;
     $this->date_start = Carbon::parse($date_start);
     $this->date_end = Carbon::parse($date_end);
     $this->department_id = (int) $department_id;
     $this->member->department = $this->department_id ? Department::with('projects')->where('id', $this->department_id)->first() : Department::with('projects')->where('id', Auth::user()->department_id)->first();
     foreach ($this->member->department->projects as $project_key => $project) {
         $project->positions = DB::table('positions')->where('project_id', $project->id)->where('name', $this->member->position->name)->get();
         if (count($project->positions)) {
             $project->average_productivity = 0;
             $project->average_quality = 0;
             $overall_productivity = 0;
             $overall_quality = 0;
             $overall_count = 0;
             foreach ($project->positions as $position_key => $position) {
                 $position->total_hours_worked = 0;
                 $position->total_output = 0;
                 $position->total_output_error = 0;
                 $position->total_average_output = 0;
                 $position->productivity = 0;
                 $position->quality = 0;
                 $position->performances = Performance::with(['target' => function ($query) {
                     $query->withTrashed();
                 }])->where('member_id', $member_id)->where('position_id', $position->id)->whereBetween('date_start', [$this->date_start, $this->date_end])->where('daily_work_hours', 'like', $daily_work_hours . '%')->orderBy('date_start')->get();
                 if (count($position->performances)) {
                     foreach ($position->performances as $performance_key => $performance) {
                         $position->total_hours_worked += $performance->hours_worked;
                         $position->total_output += $performance->output;
                         $position->total_output_error += $performance->output_error;
                         $performance->date_start = Carbon::parse($performance->date_start)->toFormattedDateString();
                         $performance->date_end = Carbon::parse($performance->date_end)->toFormattedDateString();
                     }
                     $position->total_average_output = round($position->total_output / $position->total_hours_worked * $daily_work_hours, 2);
                     $position->productivity = round($position->total_average_output / $position->performances[0]->target->productivity * 100, 2);
                     $position->quality = round((1 - $position->total_output_error / $position->total_output) * 100, 2);
                     if ($position->productivity < 100 && $position->quality >= $position->performances[0]->target->quality) {
                         $position->quadrant = 'Quadrant 1';
                     } else {
                         if ($position->productivity >= 100 && $position->quality >= $position->performances[0]->target->quality) {
                             $position->quadrant = 'Quadrant 2';
                         } else {
                             if ($position->productivity >= 100 && $position->quality < $position->performances[0]->target->quality) {
                                 $position->quadrant = 'Quadrant 3';
                             } else {
                                 if ($position->productivity < 100 && $position->quality < $position->performances[0]->target->quality) {
                                     $position->quadrant = 'Quadrant 4';
                                 }
                             }
                         }
                     }
                     $overall_productivity += $position->productivity;
                     $overall_quality += $position->quality;
                     $overall_count++;
                 }
             }
             if ($overall_count) {
                 $project->average_productivity = $overall_productivity / $overall_count;
                 $project->average_quality = $overall_quality / $overall_count;
                 $this->member->average_productivity += $project->average_productivity;
                 $this->member->average_quality += $project->average_quality;
                 $this->member->count++;
             }
         }
     }
     if ($download) {
         Excel::create('Performance Evaluation of ' . $this->member->full_name . ' from ' . $this->date_start->toFormattedDateString() . ' to ' . $this->date_end->toFormattedDateString(), function ($excel) {
             foreach ($this->member->department->projects as $project_key => $project) {
                 $this->project = $project;
                 if ($project->average_productivity && $project->average_quality) {
                     $excel->sheet($project->name, function ($sheet) {
                         $sheet->loadView('excel.performance-evaluation-multiple')->with('project', $this->project)->with('member', $this->member);
                     });
                 }
             }
         })->download('xls');
     }
     $this->member->average_productivity = $this->member->average_productivity / $this->member->count;
     $this->member->average_quality = $this->member->average_quality / $this->member->count;
     return response()->json($this->member);
 }
 public function destroy(Request $request)
 {
     $model = Department::with('users')->find($request->id);
     if (empty($model)) {
         Flash::error('Impossible de supprimer ce département.');
         return Redirect::back();
     }
     $users = $model->users();
     if (!empty($users)) {
         foreach ($users as $u) {
             $u->update(['department_id' => 1]);
         }
     }
     $name = $model->name;
     $sn = $model->short_name;
     $model->delete();
     makeModification('departments', 'The department &laquo; ' . $name . ' (' . $sn . ') &raquo; has been removed.');
     Flash::success('Le département a bien été supprimé.');
     return Redirect::back();
 }
 private function composeNavigation()
 {
     view()->composer(['_shared._sidenav', '_shared._topnav'], function ($view) {
         $view->with('departments', \App\Department::with('categories')->orderBy('order')->where('active', 1)->get());
     });
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     return Department::with('projects', 'members')->where('id', $id)->first();
 }