public function postIndex() { // return Input::all(); $competency = Competency::getActive(); $totalCompetency = 0; $totalValue = 0; if (count($competency) > 0) { //list recap $listRecap = CompetencyRecap::getlistAll($competency->id); foreach ($listRecap as $recap) { //clean recap individual DB::table('competency_recap_individuals')->where('competency_recap_id', $recap->id)->delete(); //get profile $sql = "SELECT c.competency_dictionary_id,c.rcl,c.itj,b.user_nip,a.level,d.value FROM competency_tests a, competency_dictionary_levels d, competency_recaps b RIGHT JOIN competency_profiles c on c.jabatan_id=b.occupation_id WHERE a.level=d.id AND a.competency_recap_id=b.id AND a.competency_dictionary_id=c.competency_dictionary_id AND b.competency_id=" . $competency->id . " and b.id=" . $recap->id . ""; $arr = DB::select(DB::raw($sql)); $arr = CompetencyProfile::getProfilefromRecapNip($recap->user_nip); $total = 0; foreach ($arr as $row) { $test = CompetencyTest::getAvgTest($row->competency_dictionary_id, $recap->user_nip); $recapInv = new CompetencyRecapIndividuals(); $recapInv->competency_recap_id = $recap->id; $recapInv->competency_dictionary_id = $row->competency_dictionary_id; $recapInv->rcl = $row->rcl; $recapInv->itj = $row->itj; $recapInv->ccl = $test->lvl; $recapInv->gap = $test->lvl - $row->rcl; $recapInv->priority = ($test->lvl - $row->rcl) * $row->itj; $recapInv->save(); if ($recapInv->gap >= 0) { $total = $total + 1; } } $updateRecap = CompetencyRecap::find($recap->id); if ($total == 0) { $updateRecap->total = 0; } else { $updateRecap->total = $total / count($arr) * 100; } $updateRecap->save(); $totalCompetency = $totalCompetency + count($arr); $totalValue = $totalValue + $total; } //update Competency $updateCompetency = Competency::find($competency->id); if ($totalValue == 0) { $updateCompetency->value = 0; } else { $updateCompetency->value = $totalValue / $totalCompetency * 100; } $updateCompetency->save(); return Redirect::to('admin/competency/recap/result'); } else { dd('fatal error'); } }
public function postIndex() { $breadcrumbs = array(array('Competency' => ""), array('Diklat' => "")); $competencyAll = Competency::all(); $recap = CompetencyRecap::where('competency_id', Input::get('cli'))->first(); $recapInv = CompetencyRecapIndividuals::with('dictionary')->where('competency_recap_id', $recap->id)->where('gap', '<', 0)->get(); //return $recapInv; $this->layout->content = View::make('development::useridentification.index', compact('competencyAll', 'recap', 'recapInv')); }