예제 #1
0
 public function level5($subsector_id)
 {
     $result = FormalTraining::select(DB::raw('SUM(regular_male) as regular_male,
                                               SUM(regular_female) as regular_female,
                                              (SUM(regular_male) + SUM(regular_female)) as regular_total,
                                               SUM(extension_male) as extension_male,
                                               SUM(extension_female) as extension_female,
                                              (SUM(extension_male) + SUM(extension_female)) as extension_total'))->where('report_date_id', $this->report_date_id)->where('institution_id', $this->institution_id)->whereIn('occupation_id', DB::table('occupations')->select('id')->where(array('level' => 'Level V', 'subsector_id' => $subsector_id))->lists('id'))->get();
     return $result;
 }
 public function saveAs(Request $request)
 {
     // retrieve all records as collection
     $records = FormalTraining::select('report_date_id', 'institution_id', 'occupation_id', 'course_started', 'course_ended', 'below17_male', 'below17_female', 'from17to19_male', 'from17to19_female', 'above19_male', 'above19_female', 'regular_male', 'regular_female', 'extension_male', 'extension_female', 'from_grade10_male', 'from_grade10_female', 'from_grade11_male', 'from_grade11_female', 'from_grade12_male', 'from_grade12_female', 'beyond_grade12_male', 'beyond_grade12_female', 'mental_male', 'mental_female', 'visual_male', 'visual_female', 'hearing_male', 'hearing_female', 'physical_male', 'physical_female', 'cooperative_male', 'cooperative_female', 'noncooperative_male', 'noncooperative_female', 'remarks')->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
         FormalTraining::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('formal-trainings');
 }
 public function disabilities()
 {
     $result = FormalTraining::select(DB::raw('sum(mental_male) as mental_male,
                   sum(mental_female) as mental_female,
                   sum(visual_male) as visual_male,
                   sum(visual_female) as visual_female,
                   sum(hearing_male) as hearing_male,
                   sum(hearing_female) as hearing_female,
                   sum(physical_male) as physical_male,
                   sum(physical_female) as physical_female'))->whereIn('report_date_id', ReportDate::select('id')->where('petsa', $this->petsa)->lists('id'))->whereIn('institution_id', Institution::select('id')->where('region_id', $this->region_id)->lists('id'))->get();
     return $result;
 }