/** * Execute the console command. * * @return mixed */ public function handle() { //check if have entry for today //check if locked //if good kaliwali //else populate with zeroes //then lock if (Attendance::latest('att_date')->first()->att_date != Carbon::today()) { $currentDate = new Attendance(); $currentDate->att_date = Carbon::today(); $holiday = 0; if (Carbon::today()->format('l') == 'Friday' || Holiday::where('holidate', Carbon::today())->first() != null) { $holiday = 1; } $currentDate->holiday = $holiday; $currentDate->save(); } foreach (Site::all() as $site) { foreach ($site->labor as $labor) { if ($labor->attendance()->where('att_date', Carbon::today()->format('Y-m-d G:i:s'))->first() != null) { $labor->attendance()->where('att_date', Carbon::today()->format('Y-m-d G:i:s'))->first()->pivot->update(['locked' => 'true']); } else { Attendance::latest('att_date')->first()->labor()->attach($labor->id); $att = $labor->attendance()->where('att_date', Carbon::today()->format('Y-m-d G:i:s'))->first(); $att->pivot->locked = 'true'; $att->pivot->attended = $att->holiday == 1 ? 1 : 0; $att->pivot->ot = 0; $att->pivot->bot = 0; $att->pivot->site = $labor->site->code; $att->pivot->save(); } } } }
public function store_attendance(AttendanceFormRequest $request) { $course_id = $request->get('course_id'); $trainee_ids = Info::whereCourse_id($course_id)->lists('trainee_id'); $day = $request->get('date'); $trainee_ids = Info::whereCourse_id($course_id)->lists('trainee_id'); $day = $request->get('date'); $session_name = $request->get('session'); foreach ($trainee_ids as $trainee_id) { $attendance = new Attendance(); $attendance->day = $day; $attendance->trainee_id = $trainee_id; $attendance->session_name = $session_name; $attendance->course_id = $course_id; $attendance->trainee_attendance = $request->get('ta__' . $trainee_id); $attendance->save(); $attendance->trainee_attendance = $request->get('ta__' . $trainee_id); $attendance->save(); //new code $trainee_attendances = Attendance::whereCourse_id($course_id)->lists('trainee_attendance'); return $trainee_attendances; $collection = collect($trainee_attendances); // return $collection->count(); } //new code $trainee_attendances = Attendance::whereCourse_id($course_id)->lists('trainee_attendance'); $present = Attendance::whereCourse_id($course_id)->where("trainee_attendance", "P")->count('trainee_attendance'); //return $present; $absent = Attendance::whereCourse_id($course_id)->where("trainee_attendance", "A")->count('trainee_attendance'); //return $absent; $course_name = $this->course_name_by_course_id($course_id); $session = $request->get('session'); $date = $request->get('date'); return view('attendances.attendance_show')->with('date', $date)->with('session', $session)->with('course_name', $course_name)->with('course_id', $course_id)->with('present', $present)->with('absent', $absent); // $collection = collect($trainee_attendances); // return redirect('/attendance_show'); }
public function pointage() { if (\Request::ajax()) { $tab = \Input::all(); $title = $tab['title']; $start = $tab['start']; $end = $tab['end']; $color = $tab['color']; $allDay = $tab['allDay']; $child_id = $tab['child_id']; $event = new Attendance(); $event->title = $title; $event->start = $start; $event->end = $end; $event->color = $color; $event->allDay = $allDay; $event->child_id = $child_id; $event->user_id = \Auth::user()->id; $event->save(); $child = Child::findOrFail($child_id); } }
public function store_attendance(AttendanceFormRequest $request) { $course_id = $request->get('course_id'); $session_name = $request->get('session'); $day = $request->get('date'); $trainee_ids = Info::whereCourse_id($course_id)->lists('trainee_id'); foreach ($trainee_ids as $trainee_id) { $attendance = new Attendance(); $attendance->day = Carbon\Carbon::createFromFormat('Y-m-d', $day); $attendance->trainee_id = $trainee_id; $attendance->session_name = $session_name; $attendance->course_id = $course_id; $attendance->trainee_attendance = $request->get('ta__' . $trainee_id); $attendance->save(); } $presents = Attendance::whereCourse_id($course_id)->whereSession_name($session_name)->where('day', '=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $day . ' 00:00:00'))->where("trainee_attendance", "P")->select('trainee_id')->get(); $present_att = array(); $i = 0; foreach ($presents as $present) { $present = Info::whereTrainee_id($present->trainee_id)->select('name')->firstorFail(); $present_att[$i++] = $present->name; } $absents = Attendance::whereCourse_id($course_id)->whereSession_name($session_name)->where('day', '=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $day . ' 00:00:00'))->where("trainee_attendance", "A")->select('trainee_id')->get(); $absent_att = array(); $j = 0; foreach ($absents as $absent) { $absent = Info::whereTrainee_id($absent->trainee_id)->select('name')->firstorFail(); $absent_att[$j++] = $absent->name; } $course_name = $this->course_name_by_course_id($course_id); $session = $request->get('session'); $date = $request->get('date'); return view('attendances.attendance_show', compact('present_att', 'absent_att'))->with('date', $date)->with('session', $session)->with('course_name', $course_name)->with('course_id', $course_id); $course_id = $request->get('course_id'); $trainee_ids = Info::whereCourse_id($course_id)->lists('trainee_id'); $day = $request->get('date'); $trainee_ids = Info::whereCourse_id($course_id)->lists('trainee_id'); $day = $request->get('date'); $session_name = $request->get('session'); foreach ($trainee_ids as $trainee_id) { $attendance = new Attendance(); $attendance->day = $day; $attendance->trainee_id = $trainee_id; $attendance->session_name = $session_name; $attendance->course_id = $course_id; $attendance->trainee_attendance = $request->get('ta__' . $trainee_id); $attendance->save(); $attendance->trainee_attendance = $request->get('ta__' . $trainee_id); $attendance->save(); //new code $trainee_attendances = Attendance::whereCourse_id($course_id)->lists('trainee_attendance'); return $trainee_attendances; $collection = collect($trainee_attendances); // return $collection->count(); } //new code $trainee_attendances = Attendance::whereCourse_id($course_id)->lists('trainee_attendance'); $present = Attendance::whereCourse_id($course_id)->where("trainee_attendance", "P")->count('trainee_attendance'); //return $present; $absent = Attendance::whereCourse_id($course_id)->where("trainee_attendance", "A")->count('trainee_attendance'); //return $absent; $course_name = $this->course_name_by_course_id($course_id); $session = $request->get('session'); $date = $request->get('date'); return view('attendances.attendance_show')->with('date', $date)->with('session', $session)->with('course_name', $course_name)->with('course_id', $course_id)->with('present', $present)->with('absent', $absent); }
public function store_attendance(AttendanceFormRequest $request) { $course_id = $request->get('course_id'); $session_name = $request->get('session'); $day = $request->get('date'); $check = Attendance::whereCourse_id($course_id)->whereSession_name($session_name)->where('day', '=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $day . ' 00:00:00'))->count('id'); if ($check) { $trainees = DB::table('traineecourses')->join('users', 'traineecourses.trainee_id', '=', 'users.id')->where('traineecourses.course_id', $course_id)->select('name', 'users.id')->get(); $course_name = $this->course_name_by_course_id($course_id); return view('attendances.attendance_create')->with('trainee_list', $trainees)->with('date', $request->get('date'))->with('session', $request->get('session'))->with('course_name', $course_name)->with('course_id', $course_id)->with('warning', "This attendance is already entered."); } else { $trainee_ids = TraineeCourse::whereCourse_id($course_id)->lists('trainee_id'); foreach ($trainee_ids as $trainee_id) { $attendance = new Attendance(); $attendance->day = Carbon\Carbon::createFromFormat('Y-m-d', $day); $attendance->trainee_id = $trainee_id; $attendance->session_name = $session_name; $attendance->course_id = $course_id; $attendance->trainee_attendance = $request->get('ta__' . $trainee_id); $attendance->save(); } $presents = Attendance::whereCourse_id($course_id)->whereSession_name($session_name)->where('day', '=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $day . ' 00:00:00'))->where("trainee_attendance", "P")->select('trainee_id')->get(); $present_att = array(); $i = 0; foreach ($presents as $present) { $present = User::whereId($present->trainee_id)->select('name')->firstorFail(); $present_att[$i++] = $present->name; } $absents = Attendance::whereCourse_id($course_id)->whereSession_name($session_name)->where('day', '=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $day . ' 00:00:00'))->where("trainee_attendance", "A")->select('trainee_id')->get(); $absent_att = array(); $j = 0; foreach ($absents as $absent) { $absent = User::whereId($absent->trainee_id)->select('name')->firstorFail(); $absent_att[$j++] = $absent->name; } $course_name = $this->course_name_by_course_id($course_id); $session = $request->get('session'); $date = $request->get('date'); return view('attendances.attendance_show', compact('present_att', 'absent_att'))->with('date', $date)->with('session', $session)->with('course_name', $course_name)->with('course_id', $course_id); } }
/** * Display list of labors under the signed in user * * @return Response */ public function showSites() { if (!$this->initialized()) { $currentDate = new Attendance(); $currentDate->att_date = Carbon::today(); $holiday = 0; if (Carbon::today()->format('l') == 'Friday' || Holiday::where('holidate', Carbon::today())->first() != null) { $holiday = 1; } $currentDate->holiday = $holiday; $currentDate->save(); } //$labors = Labor::all()->lists('name','employee_no')->toArray(); //dd($labors); $userID = \Auth::user()->id; $dateId = $this->getDateId(); $user = \Auth::user(); $sites = $user->site; return view('pages.attendance_list', compact('sites', 'dateId', 'userID')); }
public static function create_new_attendance($input) { $attendance = new Attendance(['congregation_id' => $input['congregation_id'], 'staff_id' => $input['staff_id'], 'service_date' => $input['service_date'], 'regular_count' => $input['regular_count'], 'visitor_count' => $input['visitor_count'], 'remarks' => $input['remarks']]); $attendance->save(); return $attendance; }