public function saveAs(Request $request)
 {
     // retrieve all records as collection
     $records = Assessment::select('report_date_id', 'institution_id', 'occupation_id', 'assessed_regular_male', 'assessed_regular_female', 'assessed_extension_male', 'assessed_extension_female', 'assessed_short_term_male', 'assessed_short_term_female', 'competent_regular_male', 'competent_regular_female', 'competent_extension_male', 'competent_extension_female', 'competent_short_term_male', 'competent_short_term_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
         Assessment::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 from source.');
     }
     return redirect('assessments');
 }
Example #2
0
 public function update(Request $request, $id)
 {
     $assessment = Assessment::find($id);
     if (is_null($assessment)) {
         return redirect()->back()->with('status', 'Missing Reference');
     }
     $inquiry_id = $assessment->inquiry_id;
     $chks = array('eie', 'dss');
     foreach ($chks as $chk) {
         $assessment->setAttribute($chk, Input::has($chk) ? true : false);
     }
     //$assessment->fname = $request->input('fname');
     //$assessment->lname = $request->input('lname');
     //$assessment->sfname = $sfname;
     //$assessment->slname = $slname;
     //$assessment->datedoc = $datedoc;
     //$assessment->staff_id = $staff_id;
     $assessment->result = $request->input('result');
     //=== this section checks for ids ====
     //      $inquiry_id = $request->input('inquiry_id');
     //      $client_id = $request->input('client_id');
     //      $episode_id = $request->input('episode_id');
     //
     //          $looper = 0;
     //        $vals = array($inquiry_id,$client_id,$episode_id);
     //      $flds = array('inquiry_id','client_id','episode_id');
     //    foreach ($flds as $fld) {
     //      $assessment->setAttribute($fld, (Input::has($fld)) ? $vals[$looper] : '0');
     //          $looper++;
     //    }
     //=======================
     //    $morechks = array('eie','dss');
     //      foreach ($morechks as $morechk) {
     //          $assessment->setAttribute($morechk, (Input::has($morechk)) ? true : false);
     //      }
     $assessment->save();
     return redirect()->route('inquiryview', $inquiry_id);
 }
Example #3
0
 public function reportsview()
 {
     $input = Input::all();
     if (empty($input)) {
         abort(404);
     }
     $assessment = Assessment::where('status', 1);
     if (!empty($input['user'])) {
         $this->data['user'] = User::findOrFail($input['user']);
         $assessment = $assessment->with('user')->where('user_id', $input['user']);
     }
     if (!empty($input['key'])) {
         $assessment = $assessment->whereHas('user', function ($qq) use($input) {
             return $qq->where('fullname', 'LIKE', '%' . trim($input['key']) . '%');
         });
     }
     if (!empty($input['type'])) {
         $assessment = $assessment->whereHas('exam', function ($qq) use($input) {
             return $qq->where('type', strtolower($input['type']));
         });
     }
     if (!empty($input['from']) && !empty($input['to'])) {
         $assessment = $assessment->whereBetween('created_at', [Carbon::createFromFormat('Y-m-d', $input['from'])->subDays(1)->toDateTimeString(), Carbon::createFromFormat('Y-m-d', $input['to'])->addDays(1)->toDateTimeString()]);
     }
     $this->data['assessment'] = $assessment->get();
     $this->data['input'] = $input;
     if (!empty($input['download']) && $input['download'] == 'pdf') {
         unset($this->data['input']['download']);
         $pdf = \App::make('dompdf.wrapper');
         return $pdf->loadView('home.reportsprint', $this->data)->download(str_slug('exam ' . $input['type'] . ' report export ' . date('Y-m-d')) . '.pdf');
     }
     return view('home.reportsview', $this->data);
 }
Example #4
0
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $assessment = Assessment::find($id);
     if (Gate::denies('delete-assessment', $assessment)) {
         abort(403);
     }
     $exec = $assessment->delete();
     if ($exec) {
         return response()->json(["status" => "success"]);
     }
 }
    public function competent()
    {
        $result = Assessment::select(DB::raw('sum(competent_regular_male) as regular_male,
                                        sum(competent_regular_female) as regular_female,
                                        sum(competent_extension_male) as extension_male,
                                        sum(competent_extension_female) as extension_female,

                                        sum(competent_regular_male) + sum(competent_regular_female) as regular_total,
                                        sum(competent_extension_male) + sum(competent_extension_female) as extension_total,

                                        sum(competent_regular_male) + sum(competent_regular_female) +
                                        sum(competent_extension_male) + sum(competent_extension_female) as total'))->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;
    }