/**
  * Show  Cv information
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $positions = Position::all();
     $employee = Employee::find($id);
     $educations = Education::where('employee_id', '=', $employee->id)->get();
     $employee_skills = EmployeeSkill::where('employee_id', '=', $employee->id)->get();
     $experiences = WorkingExperience::where('employee_id', '=', $employee->id)->get();
     $taken_projects = TakenProject::where('employee_id', '=', $employee->id)->get();
     $nationalities = Nationality::all();
     $category_skill = CategorySkill::all();
     return view('printpreview.printpreview', compact('taken_projects', 'position', 'employee_skills', 'nationalities', 'employee', 'educations', 'experiences', 'category_skill'));
 }
Esempio n. 2
0
 /**
  * Show and Export CV information
  * 
  * @param  [int] $id
  * @return Response
  */
 public function show($id)
 {
     $positions = Position::all();
     $employee = Employee::find($id);
     $educations = Education::where('employee_id', '=', $employee->id)->get();
     $employee_skills = EmployeeSkill::where('employee_id', '=', $employee->id)->get();
     $experiences = WorkingExperience::where('employee_id', '=', $employee->id)->get();
     $taken_projects = TakenProject::where('employee_id', '=', $employee->id)->get();
     $nationalities = Nationality::all();
     $category_skill = CategorySkill::all();
     $parameterr = array();
     $parameter['employee'] = $employee;
     $parameter['educations'] = $educations;
     $parameter['category_skill'] = $category_skill;
     $parameter['employee_skills'] = $employee_skills;
     $parameter['taken_projects'] = $taken_projects;
     $parameter['experiences'] = $experiences;
     $parameter['nationalities'] = $nationalities;
     $pdf = \PDF::loadView('welcome', $parameter)->setPaper('a4')->setOrientation('landscape')->setWarnings(false);
     return $pdf->download('cv.pdf');
 }
 /**
  * Store a newly profile
  * 
  * @param  [int] $id 
  * @return Response
  */
 public function store(AddEditEmployeeRequest $request)
 {
     $positions = Position::all();
     $employee = Auth::user()->employee()->get()->first();
     $img = Request::get('imageup');
     $requestdata = Request::all();
     $requestdata['date_of_birth'] = $this->convert_datepicker_to_datetimesql(Request::input('dateofbirth'));
     if ($img != "") {
         $requestdata['avatar'] = 'avatar/' . $requestdata['avatar'];
         $img = str_replace('data:image/png;base64,', '', $img);
         $img = str_replace(' ', '+', $img);
         $data = base64_decode($img);
         $file = public_path() . "/avatar/" . Request::input('avatar');
         $bytes_written = File::put($file, $data);
     } else {
         $requestdata['avatar'] = $requestdata['avatar_save'];
     }
     $employee->update($requestdata);
     $educations = Education::where('employee_id', '=', $employee->id)->get();
     $employee->date_of_birth = $this->convert_datepicker_to_datetimesql($employee->date_of_birth);
     foreach ($educations as $k_edu => $k_val) {
         $yearstart = Request::input('edu_yearstart' . $k_val->id);
         if ($yearstart == null) {
             Education::destroy($k_val->id);
             continue;
         }
         $yearend = Request::input('edu_yearend' . $k_val->id);
         $education = Request::input('edu_education' . $k_val->id);
         $edu = Education::find($k_val->id);
         $edu->update(['year_start' => $yearstart, 'year_end' => $yearend, 'education' => $education]);
     }
     $yearstart_new = Request::input('edu_yearstart');
     $yearend_new = Request::input('edu_yearend');
     $education_new = Request::input('edu_education');
     if ($yearstart_new != null && $yearstart_new[0] != "") {
         foreach ($yearstart_new as $k_n => $v_n) {
             $user = Education::create(array('employee_id' => $employee->id, 'year_start' => $yearstart_new[$k_n], 'year_end' => $yearend_new[$k_n], 'education' => $education_new[$k_n]));
         }
     }
     $educations = Education::where('employee_id', '=', $employee->id)->get();
     $nationalities = Nationality::all();
     $working_experience = WorkingExperience::where('employee_id', '=', $employee->id)->delete();
     $company = Request::input('company');
     $startdate = Request::input('startdate');
     $enddate = Request::input('enddate');
     $position = Request::input('position');
     $mainduties = Request::input('mainduties');
     if (!empty($startdate)) {
         foreach ($startdate as $key => $value) {
             $startdate[$key] = $this->convert_datepicker_to_datetimesql($value);
         }
         foreach ($enddate as $key => $value) {
             $enddate[$key] = $this->convert_datepicker_to_datetimesql($value);
         }
     }
     if (!empty($company)) {
         foreach ($company as $key => $value) {
             if ($value == "") {
                 continue;
             }
             $companys = WorkingExperience::create(array('employee_id' => $employee->id, 'company' => $value, 'year_start' => $startdate[$key], 'year_end' => $enddate[$key], 'position' => $position[$key], 'main_duties' => $mainduties[$key]));
         }
     }
     $taken_project = TakenProject::where('employee_id', '=', $employee->id)->delete();
     $projectname = Request::input('projectname');
     $customername = Request::input('customername');
     $role = Request::input('role');
     $numberpeople = Request::input('numberpeople');
     $projectdescription = Request::input('projectdescription');
     $projectperiod = Request::input('projectperiod');
     $skillset = Request::input('skillset');
     if (!empty($projectname)) {
         foreach ($projectname as $key => $value) {
             if ($value == "") {
                 continue;
             }
             //dd($numberpeople[$key]);
             $projects = TakenProject::create(array('employee_id' => $employee->id, 'project_name' => $value, 'customer_name' => $customername[$key], 'number_people' => $numberpeople[$key], 'role' => $role[$key], 'project_description' => $projectdescription[$key], 'project_period' => $projectperiod[$key], 'skill_set_ultilized' => $skillset[$key]));
         }
     }
     $skill = array();
     $experience = array();
     $skill = Request::input('skill');
     $experience = Request::input('month_experience');
     EmployeeSkill::where("employee_id", "=", $employee->id)->delete();
     foreach ($skill as $key => $value) {
         if ($value < 0) {
             unset($experience[$key]);
             unset($skill[$key]);
         } else {
             if ($experience[$key] < 0) {
                 $experience[$key] = 0;
             }
             $employeeskill = EmployeeSkill::create(array("employee_id" => $employee->id, "skill_id" => $value, "month_experience" => $experience[$key]));
         }
     }
     $request->session()->flash('flagMessage', 'true');
     return redirect()->route('profiles.index');
 }
 /**
  * Delete employee
  * @param  [int] $id
  * @return [Reponse]
  */
 public function delete($id)
 {
     $employee = Employee::find($id);
     WorkingExperience::where('employee_id', '=', $employee->id)->delete();
     TakenProject::where('employee_id', '=', $employee->id)->delete();
     EmployeeSkill::where('employee_id', '=', $employee->id)->delete();
     Education::where('employee_id', '=', $employee->id)->delete();
     User::where('employee_id', '=', $employee->id)->delete();
     $employee->delete();
     return redirect()->route('employee.index')->with('messageDelete', 'Delete employee successfully!');
 }