Exemplo n.º 1
0
 /**
  * @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 = Transferee::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('trainees-transferees');
     }
     // retrieve all records as collection
     $records = Transferee::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
         Transferee::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('trainees-transferees');
 }
Exemplo n.º 2
0
 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;
     }
 }