public function postCreate() { // validate against the inputs from our form $validator = Validator::make(Input::all(), $this->rules); if ($validator->fails()) { // get the error messages from the validator $messages = $validator->messages(); // redirect our user back to the form with the errors from the validator return Redirect::back()->withErrors($messages); } else { $year = substr(Input::get('year'), 0, 5); if (Input::get('status') == 'active' && count(Competency::getActive()) > 0) { //check active return Redirect::back()->with('message', 'data gagal ditambah'); } else { $schedule = new Competency(); $schedule->year = (int) $year; $schedule->date_start = Input::get('date_start'); $schedule->date_end = Input::get('date_end'); $schedule->status = Input::get('status'); $schedule->save(); return Redirect::to('admin/competency/schedule/')->with('message', 'data berhasil ditambah'); } } }
public function jabatanpengukuran() { $competency = Competency::getActive(); return $this->hasMany('Meniqa\\EmployeeMenpan\\Models\\RiwJabStruk', 'nip', 'nip')->where('tmt_mulai', '<=', $competency->date_start)->where(function ($query) use($competency) { $query->where('tmt_selesai', '>=', $competency->date_start)->orWhere('tmt_selesai', '=', '0000-00-00'); }); }
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 apiDetail($id) { $competencyActive = Competency::getActive(); $peers = CompetencyPeers::with('rater.jabatanpengukuran.jabatan.unit')->find($id); return $peers; }