⚝
One Hat Cyber Team
⚝
Your IP:
216.73.216.94
Server IP:
178.33.27.10
Server:
Linux cpanel.dev-unit.com 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64
Server Software:
Apache/2.4.57 (Unix) OpenSSL/1.0.2k-fips
PHP Version:
8.2.11
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
id
/
hrms.dev-unit.com
/
app
/
Http
/
Controllers
/
View File Name :
SetSalaryController.php
<?php namespace App\Http\Controllers; use App\Models\AccountList; use App\Models\Allowance; use App\Models\AllowanceOption; use App\Models\Commission; use App\Models\DeductionOption; use App\Models\Employee; use App\Models\Loan; use App\Models\LoanOption; use App\Models\OtherPayment; use App\Models\Overtime; use App\Models\PayslipType; use App\Models\SaturationDeduction; use Illuminate\Http\Request; use Illuminate\Support\Facades\Crypt; class SetSalaryController extends Controller { public function index() { if (\Auth::user()->can('Manage Set Salary')) { $employees = Employee::where( [ 'created_by' => \Auth::user()->creatorId(), ] )->get(); return view('setsalary.index', compact('employees')); } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function edit($id) { if (\Auth::user()->can('Edit Set Salary')) { $payslip_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $allowance_options = AllowanceOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $loan_options = LoanOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $deduction_options = DeductionOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if (\Auth::user()->type == 'employee') { $currentEmployee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $allowances = Allowance::where('employee_id', $currentEmployee->id)->get(); $commissions = Commission::where('employee_id', $currentEmployee->id)->get(); $loans = Loan::where('employee_id', $currentEmployee->id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $currentEmployee->id)->get(); $otherpayments = OtherPayment::where('employee_id', $currentEmployee->id)->get(); $overtimes = Overtime::where('employee_id', $currentEmployee->id)->get(); $employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); return view('setsalary.employee_salary', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } else { $allowances = Allowance::where('employee_id', $id)->get(); $commissions = Commission::where('employee_id', $id)->get(); $loans = Loan::where('employee_id', $id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $id)->get(); $otherpayments = OtherPayment::where('employee_id', $id)->get(); $overtimes = Overtime::where('employee_id', $id)->get(); $employee = Employee::find($id); return view('setsalary.edit', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } } else { return redirect()->back()->with('error', __('Permission denied.')); } } public function show($id) { try { $id = Crypt::decrypt($id); } catch (\Throwable $th) { return redirect()->back()->with('error', __('Permission Denied.')); } $payslip_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $allowance_options = AllowanceOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $loan_options = LoanOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $deduction_options = DeductionOption::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); if (\Auth::user()->type == 'employee') { $currentEmployee = Employee::where('user_id', '=', \Auth::user()->id)->first(); $allowances = Allowance::where('employee_id', $currentEmployee->id)->get(); $commissions = Commission::where('employee_id', $currentEmployee->id)->get(); $loans = Loan::where('employee_id', $currentEmployee->id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $currentEmployee->id)->get(); $otherpayments = OtherPayment::where('employee_id', $currentEmployee->id)->get(); $overtimes = Overtime::where('employee_id', $currentEmployee->id)->get(); $employee = Employee::where('user_id', '=', \Auth::user()->id)->first(); foreach ($allowances as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($commissions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($loans as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($saturationdeductions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($otherpayments as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } return view('setsalary.employee_salary', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } else { $allowances = Allowance::where('employee_id', $id)->get(); $commissions = Commission::where('employee_id', $id)->get(); $loans = Loan::where('employee_id', $id)->get(); $saturationdeductions = SaturationDeduction::where('employee_id', $id)->get(); $otherpayments = OtherPayment::where('employee_id', $id)->get(); $overtimes = Overtime::where('employee_id', $id)->get(); $employee = Employee::find($id); foreach ($allowances as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($commissions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($loans as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($saturationdeductions as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } foreach ($otherpayments as $value) { if ($value->type == 'percentage') { $employee = Employee::find($value->employee_id); $empsal = $value->amount * $employee->salary / 100; $value->tota_allow = $empsal; } } return view('setsalary.employee_salary', compact('employee', 'payslip_type', 'allowance_options', 'commissions', 'loan_options', 'overtimes', 'otherpayments', 'saturationdeductions', 'loans', 'deduction_options', 'allowances')); } } public function employeeUpdateSalary(Request $request, $id) { $validator = \Validator::make( $request->all(), [ 'salary_type' => 'required', 'salary' => 'required', 'account_type' => 'required', ] ); if ($validator->fails()) { $messages = $validator->getMessageBag(); return redirect()->back()->with('error', $messages->first()); } $employee = Employee::findOrFail($id); $input = $request->all(); $employee->fill($input)->save(); return redirect()->back()->with('success', 'Employee Salary Updated.'); } public function employeeSalary() { if (\Auth::user()->type == "employee") { $employees = Employee::where('user_id', \Auth::user()->id)->get(); return view('setsalary.index', compact('employees')); } } public function employeeBasicSalary($id) { $payslip_type = PayslipType::where('created_by', \Auth::user()->creatorId())->get()->pluck('name', 'id'); $payslip_type->prepend('Select Payslip Type', ''); $accounts = AccountList::where('created_by', \Auth::user()->creatorId())->get()->pluck('account_name', 'id'); $accounts->prepend('Select Account Type', ''); $employee = Employee::find($id); return view('setsalary.basic_salary', compact('employee', 'payslip_type', 'accounts')); } }