/**
  * Show the PIM - Termination Reasons.
  *
  * @Get("pim/configuration/termination-reasons")
  *
  * @param TerminationReasonsRequest $request
  * @return \Illuminate\View\View
  * @author Bertrand Kintanar
  */
 public function index(TerminationReasonsRequest $request)
 {
     $this->data['employee'] = $this->employee->whereUserId($this->logged_user->id)->first();
     $termination_reasons = $this->termination_reason->get();
     $this->data['table'] = $this->setupDataTable($termination_reasons);
     $this->data['pageTitle'] = 'Termination Reasons';
     return $this->template('pages.pim.configuration.termination-reasons.view');
 }
Exemplo n.º 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @Get("profile/work-shifts/edit")
  * @Get("pim/employee-list/{id}/work-shifts/edit")
  *
  * @param  WorkShiftRequest $request
  * @param null $employee_id
  * @return Response
  * @author Bertrand Kintanar
  */
 public function show(WorkShiftRequest $request, $employee_id = null)
 {
     if (Input::get('success')) {
         return redirect()->to($request->path())->with('success', SUCCESS_UPDATE_MESSAGE);
     }
     $employee = $this->employee->getEmployeeById($employee_id, $this->logged_user->id);
     $this->data['employee'] = $employee;
     $this->data['workshift_history'] = $employee->employeeWorkShift;
     $this->data['disabled'] = '';
     $this->data['pim'] = $request->is('*pim/*') ?: false;
     $this->data['pageTitle'] = $this->data['pim'] ? 'Edit Employee Job Details' : 'Edit My Job Details';
     return $this->template('pages.profile.workshift.edit');
 }
Exemplo n.º 3
0
 /**
  * Show the Profile - Dependents.
  *
  * @Get("profile/dependents")
  * @Get("pim/employee-list/{id}/dependents")
  *
  * @param DependentsRequest $request
  * @param null $employee_id
  * @return \Illuminate\View\View
  * @author Bertrand Kintanar
  */
 public function index(DependentsRequest $request, $employee_id = null)
 {
     $employee = $this->employee->getEmployeeById($employee_id, $this->logged_user->id);
     if (!$employee) {
         return response()->make(view()->make('errors.404'), 404);
     }
     $this->data['employee'] = $employee;
     $dependents = $this->dependent->whereEmployeeId($employee->id)->get();
     $this->data['pim'] = $request->is('*pim/*') ?: false;
     $this->data['table'] = $this->setupDataTable($dependents);
     $this->data['pageTitle'] = $this->data['pim'] ? 'Employee Dependents' : 'My Dependents';
     return $this->template('pages.profile.dependents.view');
 }
Exemplo n.º 4
0
 /**
  * Update the Profile - Personal Details.
  *
  * @Patch("profile/personal-details")
  * @Patch("pim/employee-list/{id}/personal-details")
  *
  * @param PersonalDetailsRequest $request
  * @return \Illuminate\Http\RedirectResponse
  * @author Bertrand Kintanar
  */
 public function update(PersonalDetailsRequest $request)
 {
     $id = $request->get('id');
     $employee_id = $request->get('employee_id');
     $employee = $this->employee->whereId($id)->first();
     if (!$employee) {
         return redirect()->to($request->path())->with('danger', UNABLE_UPDATE_MESSAGE);
     }
     // If user is trying to update the employee_id to a used employee_id.
     $original_employee_id = $this->employee->whereEmployeeId($employee_id)->pluck('id');
     if ($id != $original_employee_id && !is_null($original_employee_id)) {
         $path = $request->path();
         // pim/employee-list/{id}/personal-details
         if ($request->is('*pim/*')) {
             $path = explode('/', $path);
             $path[2] = $employee->employee_id;
             $path = implode('/', $path);
         }
         return redirect()->to($path)->with('danger', EMPLOYEE_ID_IN_MESSAGE);
     }
     try {
         $employee->update($request->all());
     } catch (Exception $e) {
         return redirect()->to($request->path())->with('danger', UNABLE_UPDATE_MESSAGE);
     }
     return redirect()->to($request->path())->with('success', SUCCESS_UPDATE_MESSAGE);
 }
Exemplo n.º 5
0
 /**
  * Execute the console command.
  *
  * @author Bertrand Kintanar
  */
 public function handle()
 {
     $csv = Reader::createFromPath(storage_path() . '/employee.csv');
     $csv->setOffset(2);
     $data = $csv->query();
     foreach ($data as $lineIndex => $row) {
         $data = [];
         $data['employee_id'] = $row[0];
         $data['joined_date'] = Carbon::parse($row[1])->toDateString();
         $data['birth_date'] = Carbon::parse($row[23])->toDateString() ?: null;
         $data['first_name'] = utf8_encode($row[4]);
         $data['middle_name'] = utf8_encode($row[5]) ?: null;
         $data['last_name'] = utf8_encode($row[6]);
         $data['suffix_name'] = utf8_encode($row[7]) ?: null;
         $data['address_1'] = utf8_encode($row[9]);
         $data['address_city_id'] = City::whereName($row[10])->pluck('id') ?: null;
         $data['address_province_id'] = 25;
         $data['address_country_id'] = 185;
         $data['address_postal_code'] = $row[11] ?: null;
         $data['social_security'] = $row[15] ?: null;
         $data['tax_identification'] = $row[16] ?: null;
         $data['philhealth'] = $row[17] ?: null;
         $data['hdmf_pagibig'] = $row[18] ?: null;
         $data['mid_rtn'] = $row[19] ?: null;
         $new_employee = Employee::create($data);
         $components = SalaryComponent::all();
         foreach ($components as $value) {
             $salary_components = ['employee_id' => $new_employee->id, 'component_id' => $value->id, 'value' => 0];
             EmployeeSalaryComponent::create($salary_components);
         }
     }
 }
Exemplo n.º 6
0
 /**
  * @Get("sandbox")
  * @author Bertrand Kintanar
  */
 public function sandbox()
 {
     // Show attendance of a given employee
     $employee = Employee::whereId(3)->first();
     $timelog = TimeLog::where('swipe_date', '>=', '2015-01-01')->where('swipe_date', '<=', '2015-01-31')->whereFaceId($employee->face_id)->get();
     dd($timelog);
     $this->data['pageTitle'] = 'Dashboard';
     return $this->template('pages.home');
 }
Exemplo n.º 7
0
 /**
  * Save the Profile - Qualifications - Skills.
  *
  * @Post("profile/qualifications/skills")
  * @Post("pim/employee-list/{id}/qualifications/skills")
  *
  * @param QualificationsSkillRequest $request
  * @return \Illuminate\Http\RedirectResponse
  * @author Bertrand Kintanar
  */
 public function storeSkill(QualificationsSkillRequest $request)
 {
     try {
         $employee = $this->employee->whereId($request->get('id'))->first();
         $skill_id = $request->get('skill_id');
         $years_of_experience = $request->get('years_of_experience') or null;
         $comment = $request->get('skill_comment') or null;
         $employee->skills()->attach($skill_id, ['years_of_experience' => $years_of_experience, 'comment' => $comment]);
     } catch (Exception $e) {
         return redirect()->to(str_replace('/skills', '', $request->path()))->with('danger', UNABLE_ADD_MESSAGE);
     }
     return redirect()->to(str_replace('/skills', '', $request->path()))->with('success', SUCCESS_ADD_MESSAGE);
 }
Exemplo n.º 8
0
 /**
  * Updates the Profile - Job.
  *
  * @Patch("profile/job")
  * @Patch("pim/employee-list/{id}/job")
  *
  * @param JobRequest $request
  * @return \Illuminate\Http\RedirectResponse
  * @author Bertrand Kintanar
  */
 public function update(JobRequest $request)
 {
     $employee_id = $request->get('employee_id');
     $job_history = $this->job_history;
     $job_history_fillables = $job_history->getFillable();
     $current_employee_job = $job_history->getCurrentEmployeeJob($job_history_fillables, $employee_id);
     $job_request_fields = $request->only($job_history_fillables);
     if ($current_employee_job != $job_request_fields) {
         $job_history->create($job_request_fields);
     }
     $this->employee->whereId($employee_id)->update($request->only('joined_date', 'probation_end_date', 'permanency_date'));
     return redirect()->to($request->path())->with('success', SUCCESS_UPDATE_MESSAGE);
 }
Exemplo n.º 9
0
 /**
  * @Get("time/attendance/employee-records")
  * @Get("time/attendance/employee-records/{date}")
  *
  * @param null $date
  * @return \Illuminate\View\View
  * @author Bertrand Kintanar
  */
 public function index($date = null)
 {
     if (is_null($date)) {
         $date = Carbon::now()->toDateString();
     }
     $this->data['date'] = $date;
     $this->data['work_date'] = null;
     $this->data['employee'] = Employee::whereId(1)->first();
     $this->data['disabled'] = false;
     $this->data['employee_id'] = null;
     $this->data['pageTitle'] = 'Employee Records';
     return $this->template('pages.time.attendance.employee-records');
 }
Exemplo n.º 10
0
 /**
  * Updates the Profile - Contact Details.
  *
  * @Patch("profile/contact-details")
  * @Patch("pim/employee-list/{id}/contact-details")
  *
  * @param ContactDetailsRequest $request
  * @return \Illuminate\Http\RedirectResponse
  * @author Bertrand Kintanar
  */
 public function update(ContactDetailsRequest $request)
 {
     $id = $request->get('id');
     $employee = $this->employee->whereId($id)->first();
     if (!$employee) {
         return redirect()->to($request->path())->with('danger', UNABLE_RETRIEVE_MESSAGE);
     }
     try {
         $employee->update($request->all());
     } catch (Exception $e) {
         return redirect()->to($request->path())->with('danger', UNABLE_UPDATE_MESSAGE);
     }
     return redirect()->to($request->path())->with('success', SUCCESS_UPDATE_MESSAGE);
 }
Exemplo n.º 11
0
 /**
  * Execute the console command.
  *
  * @author Bertrand Kintanar
  */
 public function handle()
 {
     $csv = Reader::createFromPath(storage_path() . '/timelog.csv');
     $csv->setOffset(1);
     $data = $csv->query();
     foreach ($data as $lineIndex => $row) {
         $employee = Employee::whereEmployeeId($row[1])->first();
         if ($employee) {
             $employee->face_id = $row[0];
             $employee->save();
             $this->info($employee);
             Log::info($employee);
         }
     }
 }
Exemplo n.º 12
0
 /**
  * Execute the console command.
  *
  * @author Bertrand Kintanar
  */
 public function handle()
 {
     $employee_ids = [2, 3, 4, 5, 6, 7, 8, 10, 11, 19];
     foreach ($employee_ids as $employee_id) {
         $start = Carbon::parse('2015-01-01');
         $end = Carbon::parse('2015-01-31');
         while ($start <= $end) {
             $employee = Employee::whereId($employee_id)->first();
             $timelog = $employee->getTimeLog($start->toDateString());
             $next_day = $employee->getTimeLog(Carbon::parse($start)->addDay()->toDateString());
             if ($next_day['in_time'] == null and $next_day['out_time'] == null or $timelog['in_time'] == null and $timelog['out_time'] == null) {
                 $start = $start->addDay(1);
                 continue;
             }
             $data = ['employee_id' => $employee->id, 'work_date' => $start->toDateString(), 'in_time' => $timelog['in_time'], 'out_time' => $timelog['out_time']];
             $attendance = Attendance::updateOrCreate($data);
             $this->info($attendance);
             Log::info($attendance);
             $start = $start->addDay(1);
         }
     }
 }
Exemplo n.º 13
0
 /**
  * Delete the profile qualifications skill.
  *
  * @Post("ajax/upload-profile-image")
  * @author Bertrand Kintanar
  */
 public function uploadProfileImage()
 {
     if (Request::ajax()) {
         try {
             $employee = Employee::whereId(Request::get('employeeId'))->first();
             $img = Request::get('imageData');
             $filename = md5($img) . '.png';
             $path = public_path() . '/img/profile/' . $filename;
             File::put($path, file_get_contents($img));
             $employee->avatar = $filename;
             $employee->save();
             print $filename;
         } catch (Exception $e) {
             print 'failed';
         }
     }
 }
Exemplo n.º 14
0
 /**
  * Handle a register request to the application.
  *
  * @Post("auth/register")
  *
  * @param RegisterRequest $request
  * @return \Illuminate\Http\RedirectResponse
  * @author Bertrand Kintanar
  */
 public function postRegister(RegisterRequest $request)
 {
     $auth = $this->auth;
     $email = $request->get('email');
     $credentials = ['email' => $email, 'password' => $request->get('password')];
     $user = $auth::register($credentials);
     $role = $auth::findRoleBySlug('ess');
     $role->users()->attach($user);
     $activation = Activation::create($user);
     $email_data = ['first_name' => $request->get('first_name'), 'last_name' => $request->get('last_name'), 'user_id' => $user->id, 'email' => $email, 'activation_code' => $activation->code];
     // Add to queue the user activation email.
     Mail::queue('emails.activate-user', $email_data, function ($message) use($email) {
         $message->from(env('MAIL_ADDRESS', '*****@*****.**'), env('MAIL_NAME', 'Wizard Mailer'));
         $message->to($email);
         $message->subject(trans('app.account_activation'));
     });
     $employee_data = ['employee_id' => Config::get('company.employee_id_prefix') . $user->id, 'user_id' => $user->id, 'first_name' => $request->get('first_name'), 'last_name' => $request->get('last_name'), 'gender' => 'M', 'work_email' => $request->get('email')];
     $employee = new Employee($employee_data);
     $employee->save();
     $activation_message = 'Please check your email address (' . $email . ') to activate your account.';
     return redirect('/auth/login')->with('activation', $activation_message);
 }