Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
CRAP | |
0.00% |
0 / 68 |
| LeaveSettingController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 8 |
552 | |
0.00% |
0 / 68 |
| index | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| create | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 6 |
|||
| store | |
0.00% |
0 / 1 |
240 | |
0.00% |
0 / 54 |
|||
| show | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| edit | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| update | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| destroy | |
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
|||
| Wo_ValidEmail | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 3 |
|||
| <?php | |
| namespace App\Http\Controllers\Setting; | |
| use App\Http\Controllers\Controller; | |
| use Illuminate\Http\Request; | |
| use App\Models\Admin\Setting; | |
| use App\Models\Admin\Timezone; | |
| use App\Models\Admin\Leave; | |
| use Session; | |
| use App\Helpers\AttendanceHelper; | |
| class LeaveSettingController extends Controller | |
| { | |
| /** | |
| * Display a listing of the resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function index() | |
| { | |
| } | |
| /** | |
| * Show the form for creating a new resource. | |
| * | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function create(Request $request) | |
| { | |
| $title = '/Leave Setting'; | |
| $setting = Setting::where('category','comp_off_leave')->pluck('value', 'name')->all(); // Setting::all(); | |
| // For Attendance Marking | |
| $val = AttendanceHelper::getAttendanceMarkValue(); | |
| $valTeam = AttendanceHelper::getAttendanceTeam($request); | |
| $valUser = AttendanceHelper::getAttendanceUser($request); | |
| return view('administrationForms.Setting.leaveSetting', compact('title','val','valTeam','valUser'))->with('setting',$setting); | |
| } | |
| /** | |
| * Store a newly created resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function store(Request $request) | |
| { | |
| if(auth()->user()->can('Edit Settings module')){ | |
| if($request['leave_carry_over'] == "yes"){ | |
| $to_carry = 2; | |
| $max_carry_over_balance = $request['max_carry_over_balance']; | |
| }else{ | |
| $to_carry = 0; | |
| $max_carry_over_balance = NULL; | |
| } | |
| if($request['leave_carry_over'] == "yes" && !empty($request['max_carry_over_balance'])){ | |
| $carry_days = $request['max_carry_over_balance']; | |
| }else{ | |
| $carry_days = 0; | |
| } | |
| if($request['allow_coff_for_future_dates'] == 'yes'){ | |
| $future_requests_till_days = $request['future_requests_till_days']; | |
| }else{ | |
| $future_requests_till_days = NULL; | |
| } | |
| if($request['lapse_unutilized_leaves'] == 'yes'){ | |
| $leaves_lapse_after = $request['leaves_lapse_after']; | |
| }else{ | |
| $leaves_lapse_after = NULL; | |
| } | |
| if($request['comp_off'] == 'enable'){ | |
| $arrData = array( | |
| 'comp_off'=>$request['comp_off'], | |
| 'request_approval_days'=>$request['request_approval_days'], | |
| 'include_weekend'=>$request['include_weekend'], | |
| 'comp_off_approval'=>$request['comp_off_approval'], | |
| 'allow_coff_for_future_dates'=>$request['allow_coff_for_future_dates'], | |
| 'future_requests_till_days'=> $future_requests_till_days, | |
| 'leave_carry_over'=>$request['leave_carry_over'], | |
| 'max_carry_over_balance'=> $max_carry_over_balance, | |
| 'lapse_unutilized_leaves'=>$request['lapse_unutilized_leaves'], | |
| 'leaves_lapse_after'=> $leaves_lapse_after | |
| ); | |
| }else{ | |
| $arrData = array( | |
| 'comp_off'=>$request['comp_off']); | |
| } | |
| // Apply loop over Data array then check data is exist ot not ,if exist then update existing record with new value else create new | |
| foreach ($arrData as $key => $value) { | |
| $keyExist = Setting::where('name', $key)->where('category','comp_off_leave')->first(); | |
| if($keyExist){ | |
| Setting::where('name', $key)->where('category','comp_off_leave')->update(['name'=>$key, 'value'=>$value]); | |
| }else{ | |
| Setting::create(['name'=>$key, 'value'=> $value, 'category'=> 'comp_off_leave', 'fieldtype'=>'text']); | |
| } | |
| } | |
| $checkCompOffLeave = Leave::where('name','Comp off Leave - Paid')->where('system_generated',1)->first(); | |
| if( $request['comp_off'] == 'enable'){ | |
| if(empty($checkCompOffLeave)){ | |
| Leave::create(['name' => 'Comp off Leave - Paid', | |
| 'abbr' => 'COFF', | |
| 'type' => 'paid', | |
| 'leave_allocation_type' => 'no_application', | |
| 'n_days' => 0, | |
| 'to_carry' => $to_carry, | |
| 'carry_days' => $carry_days, | |
| 'description' => 'Compensatory Off Leave', | |
| 'system_generated' => 1]); | |
| }else{ | |
| $checkCompOffLeave->update(['to_carry' => $to_carry, | |
| 'carry_days' => $carry_days]); | |
| } | |
| }else if($request['comp_off'] == 'disable'){ | |
| $check_setting = Setting::where('category','comp_off_leave')->get(); | |
| if(count($check_setting) > 0){ | |
| Setting::where('category','comp_off_leave')->where('name','!=','comp_off')->delete(); | |
| } | |
| if(!empty($checkCompOffLeave)){ | |
| Leave::where('name','Comp off Leave - Paid')->where('system_generated',1)->delete(); | |
| } | |
| } | |
| return redirect()->back()->with('success', 'Leave Setting Saved Successfully!'); | |
| }else{ | |
| return redirect()->back()->with('warning', 'You not have permission for edit it!'); | |
| } | |
| } | |
| /** | |
| * Display the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function show($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Show the form for editing the specified resource. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function edit($id) | |
| { | |
| // | |
| } | |
| /** | |
| * Update the specified resource in storage. | |
| * | |
| * @param \Illuminate\Http\Request $request | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function update(Request $request, $id) | |
| { | |
| // | |
| } | |
| /** | |
| * Remove the specified resource from storage. | |
| * | |
| * @param int $id | |
| * @return \Illuminate\Http\Response | |
| */ | |
| public function destroy($id) | |
| { | |
| // | |
| } | |
| function Wo_ValidEmail($email) { | |
| if(filter_var($email, FILTER_VALIDATE_EMAIL) !== false) { | |
| return true; | |
| } else { | |
| return false; | |
| } | |
| } | |
| } |