public static function updateLeaveType($data, $id) { $leavetype = Leavetype::find($id); $leavetype->name = array_get($data, 'name'); $leavetype->days = array_get($data, 'days'); $leavetype->update(); }
public function run() { $faker = Faker::create(); foreach (range(1, 10) as $index) { Leavetype::create([]); } }
public static function amendLeaveApplication($data, $id) { $leavetype = Leavetype::find(array_get($data, 'leavetype_id')); $application = Leaveapplication::find($id); $application->applied_start_date = array_get($data, 'applied_start_date'); $application->applied_end_date = array_get($data, 'applied_end_date'); $application->status = 'amended'; $application->date_amended = date('Y-m-d'); $application->leavetype()->associate($leavetype); $application->update(); }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { Leavetype::destroy($id); return Redirect::route('leavetypes.index'); }
public function individualleave() { $id = Input::get("employeeid"); $employee = Employee::find($id); $leavetypes = Leavetype::all(); $organization = Organization::find(1); $pdf = PDF::loadView('leavereports.individualReport', compact('leavetypes', 'employee', 'organization'))->setPaper('a4')->setOrientation('potrait'); return $pdf->stream($employee->first_name . '_' . $employee->last_name . '_Leave_Report.pdf'); }
public static function absentEveryEmployee() { $employees = Employee::where('status', '=', 'active')->get(); $absentess = []; foreach ($employees as $employee) { //Count the absent except half days foreach (Leavetype::where('leaveType', '<>', 'half day')->get() as $leave) { //$absentess[$employee->employeeID][$leave->leaveType] = 0; // Half Day leaves are added to casual leaves.2 half days are equal to one Casual Leave $absentess[$employee->employeeID][$leave->leaveType] = Attendance::where('status', '=', 'absent')->where('employeeID', '=', $employee->employeeID)->where(function ($query) { $query->where('application_status', '=', 'approved')->orWhere('application_status', '=', null); })->where('leaveType', '=', $leave->leaveType)->count(); } // half days count foreach (Leavetype::where('leaveType', '=', 'half day')->get() as $leave) { $half_day = Attendance::select('halfDayType', DB::raw('count(*) as total'))->where('status', '=', 'absent')->where('employeeID', '=', $employee->employeeID)->where(function ($query) { $query->where('application_status', '=', 'approved')->orWhere('application_status', '=', null); })->where('leaveType', '=', $leave->leaveType)->groupBy('halfDayType')->get(); foreach ($half_day as $half) { $absentess[$employee->employeeID][$half->halfDayType] += $half->total / 2; } } // Total of All leaves $absentess[$employee->employeeID]['total'] = array_sum($absentess[$employee->employeeID]); } return $absentess; }
public function redeem() { $employee = Employee::find(Input::get('employee_id')); $leeavetype = Leavetype::find(Input::get('leavetype_id')); Leaveapplication::RedeemLeaveDays($employee, $leavetype); return Redirect::route('leaveapplications.index'); }
public static function getName($id) { $leavetype = Leavetype::find($id); return $leavetype->name; }
Route::get('css/leave', function () { $employeeid = DB::table('employee')->where('personal_file_number', '=', Confide::user()->username)->pluck('id'); $employee = Employee::findorfail($employeeid); $leaveapplications = DB::table('leaveapplications')->where('employee_id', '=', $employee->id)->get(); return View::make('css.leave', compact('employee', 'leaveapplications')); }); Route::get('css/leaveapply', function () { $employeeid = DB::table('employee')->where('personal_file_number', '=', Confide::user()->username)->pluck('id'); $employee = Employee::findorfail($employeeid); $leavetypes = Leavetype::all(); return View::make('css.leaveapply', compact('employee', 'leavetypes')); }); Route::get('css/balances', function () { $employeeid = DB::table('employee')->where('personal_file_number', '=', Confide::user()->username)->pluck('id'); $employee = Employee::findorfail($employeeid); $leavetypes = Leavetype::all(); return View::make('css.balances', compact('employee', 'leavetypes')); }); /* *##########################ERP REPORTS####################################### */ Route::get('erpReports', function () { return View::make('erpreports.erpReports'); }); Route::get('erpReports/clients', 'ErpReportsController@clients'); Route::get('erpReports/items', 'ErpReportsController@items'); Route::get('erpReports/expenses', 'ErpReportsController@expenses'); Route::get('erpReports/paymentmethods', 'ErpReportsController@paymentmethods'); Route::get('erpReports/payments', 'ErpReportsController@payments'); Route::get('erpReports/locations', 'ErpReportsController@locations'); Route::get('erpReports/stock', 'ErpReportsController@stock');