예제 #1
0
 public function index($month = '2015-09-01')
 {
     //
     if (isset($month)) {
         $reports = Report::with('employee', 'employee.company', 'employee.department', 'employee.level', 'flag')->where('months', '=', $month)->get();
     } else {
         $month = Carbon::now()->firstOfMonth();
     }
     $reports = Report::with('employee', 'employee.company', 'employee.department', 'employee.level', 'flag')->where('months', '=', $month)->get();
     $reportStatus['counts'] = Report::where('months', '=', $month)->where('flag_id', 1)->count();
     $reportStatus['total'] = Report::where('months', '=', $month)->count();
     return view('report.index')->with('reports', $reports)->with('reportStatus', $reportStatus);
 }
 /**
  * Reverse the migrations.
  *
  * @return void
  */
 public function down()
 {
     Schema::table('reports', function (Blueprint $table) {
         $table->string('board_uri', 32)->nullable()->change();
     });
     Report::with('post')->chunk(100, function ($reports) {
         foreach ($reports as $report) {
             $report->board_uri = $report->global ? null : $report->post->board_uri;
             $report->save();
         }
     });
     Schema::table('reports', function (Blueprint $table) {
         $table->dropColumn('global');
     });
 }
예제 #3
0
 public function pdf(ReportRepository $reportRepository, ExcelRepository $excelRepository, $id)
 {
     $report = Report::with('users', 'indicators')->find($id);
     $this->authorize($report);
     $results = $reportRepository->getResultsTable($report);
     return $excelRepository->getPdf($results);
 }
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $user = Report::with('user')->where('user_id', '=', $id)->get();
     return view('reports.show', compact(['user']));
 }
 public function paginateDepartment($departmentID)
 {
     $report = Report::with(['performances' => function ($query) {
         $query->with('member', 'position', 'project', 'result');
     }])->where('department_id', $departmentID)->orderBy('date_start', 'desc')->paginate(4);
     $report_array = array();
     // will fetch every performance and results for the specific report
     foreach ($report as $key => $value) {
         $query = DB::table('reports')->join('performances', 'performances.report_id', '=', 'reports.id')->join('results', 'results.performance_id', '=', 'performances.id')->join('positions', 'positions.id', '=', 'performances.position_id')->join('projects', 'projects.id', '=', 'reports.project_id')->join('members', 'members.id', '=', 'performances.member_id')->select('members.*', 'performances.*', DB::raw('DATE_FORMAT(performances.date_start, "%b. %d, %Y") as date_start_formatted'), DB::raw('DATE_FORMAT(performances.date_end, "%b. %d, %Y") as date_end_formatted'), 'results.*', 'projects.*', 'projects.name as project', 'positions.name as position', 'reports.id as id')->whereNull('reports.deleted_at')->whereNull('performances.deleted_at')->where('performances.report_id', $value->id)->where('results.report_id', $value->id)->groupBy('performances.id')->orderBy('positions.name')->orderBy('members.full_name')->get();
         foreach ($query as $queryKey => $queryValue) {
             $quality_target = DB::table('targets')->join('positions', 'positions.id', '=', 'targets.position_id')->join('members', 'members.experience', '=', 'targets.experience')->select('*')->where('targets.position_id', $queryValue->position_id)->where('targets.experience', $queryValue->experience)->where('targets.type', 'Quality')->where('targets.created_at', '<=', $value->date_end)->orderBy('targets.created_at', 'desc')->first();
             if (!$quality_target) {
                 $quality_target = DB::table('targets')->join('positions', 'positions.id', '=', 'targets.position_id')->join('members', 'members.experience', '=', 'targets.experience')->select('*')->where('targets.position_id', $queryValue->position_id)->where('targets.experience', $queryValue->experience)->where('targets.type', 'Quality')->where('targets.active', true)->first();
             }
             if ($queryValue->productivity < 100 && $queryValue->quality >= 100) {
                 $queryValue->quadrant = 'Quadrant 1';
             } else {
                 if ($queryValue->productivity >= 100 && $queryValue->quality >= 100) {
                     $queryValue->quadrant = 'Quadrant 2';
                 } else {
                     if ($queryValue->productivity >= 100 && $queryValue->quality < 100) {
                         $queryValue->quadrant = 'Quadrant 3';
                     } else {
                         $queryValue->quadrant = 'Quadrant 4';
                     }
                 }
             }
             // $queryValue->quota = (($queryValue->productivity >= 100) && ($queryValue->quality >= $quality_target->value)) ? 'Met' : 'Not met';
         }
         // push each results to custom array
         array_push($report_array, $query);
     }
     return response()->json($report_array);
 }