public function getDropoutTransfereesByInstitutionID($institution_id) { $result = DropoutTransferee::select(DB::raw(' sum(regular_level1_to_level2_male) as reg_level1_to_level2_male, sum(regular_level1_to_level2_female) as reg_level1_to_level2_female, sum(regular_level1_to_level2_male) + sum(regular_level1_to_level2_female) as reg_level1_to_level2_total, sum(regular_level2_to_level3_male) as reg_level2_to_level3_male, sum(regular_level2_to_level3_female) as reg_level2_to_level3_female, sum(regular_level2_to_level3_male) + sum(regular_level2_to_level3_female) as reg_level2_to_level3_total, sum(regular_level3_to_level4_male) as reg_level3_to_level4_male, sum(regular_level3_to_level4_female) as reg_level3_to_level4_female, sum(regular_level3_to_level4_male) + sum(regular_level3_to_level4_female) as reg_level3_to_level4_total, sum(regular_level4_to_level5_male) as reg_level4_to_level5_male, sum(regular_level4_to_level5_female) as reg_level4_to_level5_female, sum(regular_level4_to_level5_male) + sum(regular_level4_to_level5_female) as reg_level4_to_level5_total, sum(extension_level1_to_level2_male) as ext_level1_to_level2_male, sum(extension_level1_to_level2_female) as ext_level1_to_level2_female, sum(extension_level1_to_level2_male) + sum(extension_level1_to_level2_female) as ext_level1_to_level2_total, sum(extension_level2_to_level3_male) as ext_level2_to_level3_male, sum(extension_level2_to_level3_female) as ext_level2_to_level3_female, sum(extension_level2_to_level3_male) + sum(extension_level2_to_level3_female) as ext_level2_to_level3_total, sum(extension_level3_to_level4_male) as ext_level3_to_level4_male, sum(extension_level3_to_level4_female) as ext_level3_to_level4_female, sum(extension_level3_to_level4_male) + sum(extension_level3_to_level4_female) as ext_level3_to_level4_total, sum(extension_level4_to_level5_male) as ext_level4_to_level5_male, sum(extension_level4_to_level5_female) as ext_level4_to_level5_female, sum(extension_level4_to_level5_male) + sum(extension_level4_to_level5_female) as ext_level4_to_level5_total'))->where('report_date_id', $this->report_date_id)->where('institution_id', $institution_id)->get(); return $result; }
/** * @param Request $request * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector */ public function saveAs(Request $request) { $user = Auth::user(); $criteria = array('report_date_id' => $request->report_date_id_target, 'institution_id' => $user->institution->id); $target_report_id_exist = DropoutTransferee::where($criteria)->get(); if (count($target_report_id_exist) > 0) { // send a flash message $request->session()->flash('alert-danger', 'Save-as report operation failed. Target report already exists.'); return redirect('dropout-from-transferees'); } // retrieve all records as collection $records = DropoutTransferee::select('report_date_id', 'institution_id', 'occupation_id', 'regular_level1_to_level2_male', 'regular_level1_to_level2_female', 'regular_level2_to_level3_male', 'regular_level2_to_level3_female', 'regular_level3_to_level4_male', 'regular_level3_to_level4_female', 'regular_level4_to_level5_male', 'regular_level4_to_level5_female', 'extension_level1_to_level2_male', 'extension_level1_to_level2_female', 'extension_level2_to_level3_male', 'extension_level2_to_level3_female', 'extension_level3_to_level4_male', 'extension_level3_to_level4_female', 'extension_level4_to_level5_male', 'extension_level4_to_level5_female')->where('report_date_id', $request->report_date_id_source)->get(); if (count($records) > 0) { // update report date id to target report date id foreach ($records as $rec) { $rec->report_date_id = $request->report_date_id_target; } // insert into the table DropoutTransferee::insert($records->toArray()); // send a flash message $request->session()->flash('alert-success', 'Save as operation was successful!'); } else { // send a flash message $request->session()->flash('alert-danger', 'Save as operation failed! No records found.'); } return redirect('dropout-from-transferees'); }
public function getExtensionDropoutTransfereesByOccupation($occupation_id) { $result = DropoutTransferee::select(DB::raw(' sum(extension_level1_to_level2_male) as ext_level1_to_level2_male, sum(extension_level1_to_level2_female) as ext_level1_to_level2_female, sum(extension_level1_to_level2_male) + sum(extension_level1_to_level2_female) as ext_level1_to_level2_total, sum(extension_level2_to_level3_male) as ext_level2_to_level3_male, sum(extension_level2_to_level3_female) as ext_level2_to_level3_female, sum(extension_level2_to_level3_male) + sum(extension_level2_to_level3_female) as ext_level2_to_level3_total, sum(extension_level3_to_level4_male) as ext_level3_to_level4_male, sum(extension_level3_to_level4_female) as ext_level3_to_level4_female, sum(extension_level3_to_level4_male) + sum(extension_level3_to_level4_female) as ext_level3_to_level4_total, sum(extension_level4_to_level5_male) as ext_level4_to_level5_male, sum(extension_level4_to_level5_female) as ext_level4_to_level5_female, sum(extension_level4_to_level5_male) + sum(extension_level4_to_level5_female) as ext_level4_to_level5_total'))->where('report_date_id', $this->report_date_id)->where('occupation_id', $occupation_id)->whereIn('institution_id', Institution::select('id')->where('region_id', $this->region_id)->where('ownership', 'Public')->lists('id'))->get(); return $result; }
public function show_report2_non_government(Request $request) { $user = Auth::user(); $region = Region::findOrFail($user->region_id); $report_date = ReportDate::findOrFail($request->get('petsa')); $rpt2 = new RTAReport2NonGovernment($report_date->id, $user->region_id); switch ($request->get('report')) { case 0: $institutions = Institution::where('region_id', $region->id)->where('ownership', '!=', 'Public')->whereIn('id', NewEnrollee::where('report_date_id', $request->get('petsa'))->lists('institution_id'))->orderBy('name')->get(); return view('rtaadmin.show_rpt2nongov_1', compact('rpt2', 'region', 'report_date', 'institutions')); break; case 1: $institutions = Institution::where('region_id', $region->id)->where('ownership', '!=', 'Public')->whereIn('id', ReEnrollee::where('report_date_id', $request->get('petsa'))->lists('institution_id'))->orderBy('name')->get(); return view('rtaadmin.show_rpt2nongov_2', compact('rpt2', 'region', 'report_date', 'institutions')); break; case 2: $institutions = Institution::where('region_id', $region->id)->where('ownership', '!=', 'Public')->whereIn('id', Transferee::where('report_date_id', $request->get('petsa'))->lists('institution_id'))->orderBy('name')->get(); return view('rtaadmin.show_rpt2nongov_3', compact('rpt2', 'region', 'report_date', 'institutions')); break; case 3: $institutions = Institution::where('region_id', $region->id)->where('ownership', '!=', 'Public')->whereIn('id', Graduate::where('report_date_id', $request->get('petsa'))->lists('institution_id'))->orderBy('name')->get(); return view('rtaadmin.show_rpt2nongov_4', compact('rpt2', 'region', 'report_date', 'institutions')); break; case 4: $institutions = Institution::where('region_id', $region->id)->where('ownership', '!=', 'Public')->whereIn('id', ShortTermTrainee::where('report_date_id', $request->get('petsa'))->lists('institution_id'))->orderBy('name')->get(); return view('rtaadmin.show_rpt2nongov_5', compact('rpt2', 'region', 'report_date', 'institutions')); break; case 5: $institutions = Institution::where('region_id', $region->id)->where('ownership', '!=', 'Public')->whereIn('id', DropoutTransferee::where('report_date_id', $request->get('petsa'))->lists('institution_id'))->orderBy('name')->get(); return view('rtaadmin.show_rpt2nongov_6', compact('rpt2', 'region', 'report_date', 'institutions')); break; case 6: $institutions = Institution::where('region_id', $region->id)->where('ownership', '!=', 'Public')->whereIn('id', DropoutGraduate::where('report_date_id', $request->get('petsa'))->lists('institution_id'))->orderBy('name')->get(); return view('rtaadmin.show_rpt2nongov_7', compact('rpt2', 'region', 'report_date', 'institutions')); break; } }