/** * @return mixed */ public function reportIniciativaLocalizacao(Request $request = null) { if ($request != null) { switch ($request['type']) { case 'geral': return $this->reportIniciativaLocalizacaoGeral()->toJson(); break; case 'regiao': switch ($request['regiao']) { case 1: return $this->reportIniciativaLocalizacaoByUf([50, 51, 52, 53])->toJson(); break; case 2: return $this->reportIniciativaLocalizacaoByUf([11, 12, 13, 14, 15, 16, 17])->toJson(); break; case 3: return $this->reportIniciativaLocalizacaoByUf([21, 22, 23, 24, 25, 26, 27, 28, 29])->toJson(); break; case 4: return $this->reportIniciativaLocalizacaoByUf([41, 42, 43])->toJson(); break; case 5: return $this->reportIniciativaLocalizacaoByUf([31, 32, 33, 35])->toJson(); break; } break; case 'estado': if ($request['cidade'] != '') { return $this->reportIniciativaLocalizacaoByCidade($request['cidade'])->toJson(); } else { return $this->reportIniciativaLocalizacaoByUf([$request['uf']])->toJson(); } break; } } else { $dados = $this->reportIniciativaLocalizacaoGeral(); $graph = \Lava::PieChart('IniciativaLocalizacao')->setOptions(['datatable' => $dados, 'is3D' => true, 'slices' => [\Lava::Slice(['offset' => 0.2])]]); return $graph; } }
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);*/ }