public function postPerfReports() { $filter = "go"; $deptL = Input::get('deptid'); $sem = Input::get('semester'); $year = Input::get('year'); /*if($dept == "*"){ $users = Performance::all(); $deptid = "*"; }else{ $users = User::where('department_id', $dept)->get(); $deptid = Department::where('id', $dept)->get(); }*/ $sampleArray = ['dept_id' => '1', 'semester' => '2015']; $sample = Performance::where($sampleArray)->get(); $users = 'Performance'; $matchThese = array(); //If user chooses from dropdown if ($deptL != "*") { //If true insert this to variable $matchThese = array_add($matchThese, 'dept_id', $deptL); /***********Add Array*****************/ //If user chooses from dropdown if ($sem != "*") { //If true insert this to variable $matchThese = array_add($matchThese, 'semester', $sem); if ($year != "All") { $matchThese = array_add($matchThese, 'year', $year); $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } else { $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } } else { //===========Else of Semester if ($year != "All") { $matchThese = array_add($matchThese, 'year', $year); $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } else { //===========Else of Year $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } /***********End Add Array*****************/ } else { //===========Else of Department /*************Add Array***************/ if ($sem != "*") { //If true insert this to variable $matchThese = array_add($matchThese, 'semester', $sem); if ($year != "All") { $matchThese = array_add($matchThese, 'year', $year); $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } else { $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } } else { //===========Else of Semester if ($year != "All") { $matchThese = array_add($matchThese, 'year', $year); $query = $users::where($matchThese)->orderBy('overall', 'desc')->get(); } else { //===========Else of Year $query = $users::all(); } } /************End Add Array****************/ } $count = $query->count(); if (empty($count)) { return Redirect::route('perf-reports'); } $out = 0; $exemP = 0; $exem = 0; $noteP = 0; $note = 0; $satP = 0; $sat = 0; $fair = 0; $un = 0; foreach ($query as $perf) { $u = $perf->utilities; $qow = $perf->workQuality; $pffp = $perf->potential; $overall = number_format(($u + $qow + $pffp) / 3, 2); $rating = ParRatingsRef::where('upper_limit', '>=', $overall)->where('lower_limit', '<=', $overall)->first(); //============================Conditions=================// if ($rating->adjectival == 'O') { $out++; } elseif ($rating->adjectival == 'E+') { $exemP++; } elseif ($rating->adjectival == 'E') { $exem++; } elseif ($rating->adjectival == 'N+') { $noteP++; } elseif ($rating->adjectival == 'N') { $note++; } elseif ($rating->adjectival == 'S+') { $satP++; } elseif ($rating->adjectival == 'S') { $sat++; } elseif ($rating->adjectival == 'F') { $fair++; } elseif ($rating->adjectival == 'U') { $un++; } } //========================Percentage================// $percent_out = $out / $count * 100; $percent_exemP = $exemP / $count * 100; $percent_exem = $exem / $count * 100; $percent_satP = $satP / $count * 100; $percent_sat = $sat / $count * 100; $percent_noteP = $noteP / $count * 100; $percent_note = $note / $count * 100; $percent_fair = $fair / $count * 100; $percent_un = $un / $count * 100; //====================================LavaChart==================================// $lava = new Lavacharts(); // See note below for Laravel $overall = Lava::DataTable(); $overall->addStringColumn('Reasons')->addNumberColumn('Percent')->addRow(array('Outstanding (' . $out . ')', $percent_out))->addRow(array('Exemplary Plus (' . $exemP . ')', $percent_exemP))->addRow(array('Exemplary (' . $exem . ')', $percent_exem))->addRow(array('Noteworthy Plus(' . $noteP . ')', $percent_noteP))->addRow(array('Noteworthy (' . $note . ')', $percent_note))->addRow(array('Satisfactory Plus (' . $satP . ')', $percent_satP))->addRow(array('Satisfactory (' . $sat . ')', $percent_sat))->addRow(array('Fair (' . $fair . ')', $percent_fair))->addRow(array('Unutilized (' . $un . ')', $percent_un)); $piechart = Lava::PieChart('IMDB')->setOptions(array('datatable' => $overall, 'title' => 'Performance Overall Rating (Total: ' . $count . ')', 'is3D' => true, 'slices' => array(Lava::Slice(array('offset' => 0.2)), Lava::Slice(array('offset' => 0.25)), Lava::Slice(array('offset' => 0.3))))); /* $userquery = User::query(); $deptidquery = Department::query(); if($dept == "*"){ $deptidquery = "*"; $users = User::all(); }else{ $userquery = $userquery->where('department_id', $dept); $deptidquery = $deptidquery->where('id', $dept); } $users = $userquery->get(); $deptid = $deptidquery->get();*/ Session::put('deptpdf', $deptL); if ($deptL == '*') { $deptL = 'All'; } else { $deptL = Department::where('id', $deptL)->pluck('name'); } //------------------------------ if ($sem == '*') { $sem = 'All'; } if ($year == '*') { $year = 'All'; } Session::put('sempdf', $sem); Session::put('yearpdf', $year); $audit = AuditTrail::create(['user_id' => Auth::id(), 'role' => 'Performance System Admin', 'action' => 'filtered the performance reports.']); return View::make('perf.perf-reports')->with('query', $query)->with('filter', $filter)->with('deptL', $deptL)->with('sem', $sem)->with('year', $year); /* if($dept == "*"){ $users = User::all(); $deptid = "*"; }else{ $users = User::where('department_id', $dept)->get(); $deptid = Department::where('id', $dept)->get(); } return View::make('emp.ems-reports') ->with('users', $users) ->with('deptid', $deptid);*/ }
public function getViewResults($id) { $perf = Performance::find($id); $user_perfs = Performance::where('user_id', $perf->user_id)->orderBy('year')->orderBy('semester')->get(); if (!$perf) { App::abort(404); } //=================Variable Declaration============ $u = $perf->utilities; $qow = $perf->workQuality; $pffp = $perf->potential; //========================Computation================= $overall = number_format(($u + $qow + $pffp) / 3, 2); $rating = ParRatingsRef::where('upper_limit', '>=', $overall)->where('lower_limit', '<=', $overall)->first(); $overpercent = number_format($overall / 6 * 100, 2); //========================= The color of the percent bar ===============// if ($overpercent >= 85) { $color = 'progress-bar-success'; } elseif ($overpercent >= 75 and $overpercent <= 84.98999999999999) { $color = ''; } elseif ($overpercent >= 40 and $overpercent <= 74.98999999999999) { $color = 'progress-bar-warning'; } else { $color = 'progress-bar-danger'; } //======================================Line Graph===============================// $lava = new Lavacharts(); // See note below for Laravel $overall_chart = Lava::DataTable(); $overall_chart->addStringColumn('Date')->addNumberColumn('Overall Rating'); foreach ($user_perfs as $user_perf) { $overall_chart->addRow([$user_perf->year . ' (' . $user_perf->semester . ' sem)', $user_perf->overall]); } $linechart = Lava::LineChart('Overall')->setOptions(['datatable' => $overall_chart, 'title' => 'Overall Performance Line Chart', 'pointSize' => 10, 'lineWidth' => 6]); //======================================Line Graph===============================// return View::make('viewresults')->with('perf', $perf)->with('overall', $overall)->with('rating', $rating)->with('overpercent', $overpercent)->with('color', $color); }