Ejemplo n.º 1
0
 public function getTransfereesByInstitutionID($institution_id)
 {
     $result = Transferee::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;
 }
Ejemplo n.º 2
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');
 }
Ejemplo n.º 3
0
 public function getExtensionTransfereesByOccupation($occupation_id)
 {
     $result = Transferee::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;
 }
Ejemplo n.º 4
0
 public function for_print_rpt1_non_gov_trans($id)
 {
     $user = Auth::user();
     $region = Region::findOrFail($user->region_id);
     $report_date = ReportDate::findOrFail($id);
     $rpt1 = new RTAReport1NonGovernment($report_date->id, $user->region_id);
     // get occupations
     $occupations = Occupation::whereIn('id', Transferee::select('occupation_id')->where('report_date_id', $id)->whereIn('institution_id', Institution::select('id')->where('region_id', $region->id)->where('ownership', '!=', 'Public')->lists('id'))->lists('occupation_id'))->orderBy('name')->get();
     // get sectors
     $sectors = Sector::whereIn('id', Subsector::select('sector_id')->whereIn('id', $occupations->lists('subsector_id'))->get())->get();
     // get subsectors
     $subsectors = Subsector::whereIn('id', $occupations->lists('subsector_id'))->get();
     return view('rtaadmin.print_rpt1nongov_3', compact('rpt1', 'region', 'report_date', 'sectors', 'subsectors', 'occupations'));
 }