/** * 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(); } } } }
function setAttendance() { try { $input = Input::all(); $date = time(); if ($input['mode'] === 'checkIn') { $checkIn = date('h:i:s', $date); $data['check_in'] = $checkIn; } if ($input['mode'] === 'checkOut') { $checkOut = date('h:i:s', $date); $data['check_out'] = $checkOut; } $data['month'] = date('F', $date); $data['date'] = date('Y-m-d', $date); // // if($checkIn){ // $data['check_in']=$checkIn; // $data['month']=date('F', $date); // $data['date'] =date('Y-m-d', $date); // } // // if($checkOut){ // $data['check_out']=$checkOut; // } $attendance = new Attendance(); $attendance->make($data); return Redirect::to('/auth/dashboard')->withFlashMessage($input['mode'] . ' successful'); } catch (Exception $e) { return Redirect::to('/auth/dashboard')->withFlashMessage($e->getMessage()); //return Redirect::to('/admin/attendance')->withFlashMessage($a->getMessage()); } }
function make($data) { $month = Month::ForMonth('January')->first(); $config['month_id'] = $month->id; $config['member_id'] = Session::get('memberId'); $config['date'] = $data['date']; if (array_key_exists('check_in', $data)) { $config['check_in'] = $data['check_in']; $attendance = Attendance::ForUniqueCheck($config['member_id'], $config['date'])->first(); if (empty($attendance)) { Attendance::create($config); } else { throw new Exception('You Already have check In for the day'); } } if (array_key_exists('check_out', $data)) { $config['check_out'] = $data['check_out']; // foreach($data as $key => $value) // { // $this->is_empty($value); // } // $this->is_valid($this->checkInFlag); $attendance = Attendance::ForUniqueCheck($config['member_id'], $config['date'])->first(); if (empty($attendance)) { throw new Exception('You Havent check in yet'); } if ($attendance->check_out === '00:00:00') { $attendance->update($data); } else { throw new Exception('You Already have check out for the day'); } } }
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $aboutfacture = SchoolYear::checkNextMonth(); PromotionStatus::fillStatusesFirst(); $client = new Google_Client(); $client->setClientId('548520090024-i8jmtdmdi5ijvj3mn2sbqe2u3a431gh6.apps.googleusercontent.com'); $client->setClientSecret('IX-SilXd0ctCrKUX1a5oP9is'); $client->setRedirectUri('http://laravel.dev:8000/schools/boite'); $client->addScope('https://mail.google.com'); $service = new Google_Service_Gmail($client); $count = Attendance::whereRaw('EXTRACT(year from start) = ?', [Carbon::now()->year])->whereRaw('EXTRACT(month from start) = ?', [Carbon::now()->month])->whereRaw('EXTRACT(day from start) = ?', [Carbon::now()->day])->where('user_id', \Auth::user()->id)->groupBy('child_id')->get(); $count = $count->count(); return view('index')->with(['client' => $client, 'service' => $service, 'count' => $count, 'aboutfacture' => $aboutfacture]); }
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 testStore() { Session::start(); $date = '2015-01-01'; $time = '20:00'; $payload = ['date' => $date, 'time' => $time, 'customers' => [$this->customers[0]->id, $this->customers[1]->id], '_token' => csrf_token()]; $response = $this->call('POST', route('attendance.store', [$this->group->id]), $payload); $this->assertRedirectedTo('/auth/login'); $this->be($this->user); $response = $this->call('POST', route('attendance.store', [$this->group->id]), $payload); $this->assertRedirectedTo(route('attendance.index', [$this->group->id])); $this->assertSessionHas('status'); $attendance = \App\Attendance::where('group_id', $this->group->id)->where('was_at', sprintf('%s %s', $date, $time))->get(); $this->assertEquals(2, count($attendance)); }
public function traineeHome() { $id = Auth::user()->id; $regId = Registration::where('user_id', '=', Auth::user()->id)->pluck('id'); $user_id = Auth::user()->id; $course_ids = TraineeCourse::where('trainee_id', $user_id)->select('course_id')->get(); //$course_ids=Info::where('trainee_login_id', $user_id)->get(); $courseAttendance = []; foreach ($course_ids as $course_id) { $course_name = $this->course_name_by_course_id($course_id->course_id); if (!$course_name->isempty()) { $absent = Attendance::where('course_id', $course_id->course_id)->where('trainee_id', $user_id)->where('trainee_attendance', '=', 'A')->count('id'); $courseAttendance[] = array('course_name' => $course_name, 'absent' => $absent); } } $info = Info::wheretrainee_login_id($user_id)->firstOrFail(); return view('trainee.trainee', compact('regId', 'courseAttendance', 'info')); //dd($regId); return view('trainee.trainee', compact('regId'))->with('id', $id); }
public function updateAttendance(Request $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 = Attendance::wheretrainee_id($trainee_id)->whereCourse_id($course_id)->whereSession_name($session_name)->where('day', '=', Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $day . ' 00:00:00'))->firstorFail(); $attendance->trainee_attendance = $request->get('ta__' . $trainee_id); $attendance->update(); } $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); }
/** * Remove the specified resource from storage. * * @param int $id * @return \Illuminate\Http\Response */ public function destroy($id) { Attendance::destroy($id); // AttendanceUser::destroy($id); return Redirect::route('attendance.allAttendance'); }
public function getYearAndMonth() { if (\Request::ajax()) { $year = \Input::get('year'); $month = \Input::get('month'); $monthtext = \Input::get('monthtext'); //Absences selon le tri ajax $count_absence = Attendance::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->count(); $count_abs_normale = Attendance::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->where('title', 'Normal')->count(); $count_abs_maladie = Attendance::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('title', 'Maladie')->where('user_id', \Auth::user()->id)->count(); /* statistics new subscribers selon le tri ajax */ $ns_number = Child::whereRaw('EXTRACT(month from created_at) = ?', [$month])->whereRaw('EXTRACT(year from created_at) = ?', [$year])->where('user_id', \Auth::user()->id)->count(); $garcons = Child::whereRaw('EXTRACT(month from created_at) = ?', [$month])->whereRaw('EXTRACT(year from created_at) = ?', [$year])->where('user_id', \Auth::user()->id)->where('sexe', 'Garçon')->count(); $filles = Child::whereRaw('EXTRACT(month from created_at) = ?', [$month])->whereRaw('EXTRACT(year from created_at) = ?', [$year])->where('user_id', \Auth::user()->id)->where('sexe', 'fille')->count(); /* bills par le trix ajax */ $count_bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->count(); $regled_bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->where('status', 1)->count(); $non_regled_bills = Bill::whereRaw('EXTRACT(month from start) = ?', [$month])->whereRaw('EXTRACT(year from start) = ?', [$year])->where('user_id', \Auth::user()->id)->where('status', 0)->count(); // for counting bills $somme = Bill::whereRaw('EXTRACT(year from start) = ?', [$year])->whereRaw('EXTRACT(month from start) = ?', [$month])->where('user_id', \Auth::user()->id)->sum('somme'); $encaisse = Bill::whereRaw('EXTRACT(year from start) = ?', [$year])->whereRaw('EXTRACT(month from start) = ?', [$month])->where('user_id', \Auth::user()->id)->where('status', 1)->sum('somme'); $reste = Bill::whereRaw('EXTRACT(year from start) = ?', [$year])->whereRaw('EXTRACT(month from start) = ?', [$month])->where('user_id', \Auth::user()->id)->where('status', 0)->sum('somme'); echo ' <div class="row partie-up"> <div class="col-md-4"> <section class="panel bloc"> <div class="panel-body"> <a href="' . action('StatisticsController@monthly_absence', [$year, $month]) . '"> <div class="bloc_statistique"><img src="images/pointages.png" ><span class="count"> ' . $count_absence . '</span><p>Cas d\'absence Ce Mois</p></div> <div class="bloc_statistique_details"> <div class="bloc_statistique_d1"> <span class="count">' . $count_abs_normale . '</span><p>Justifiées</p> </div> <div class="bloc_statistique_d2"> <span class="count">' . $count_abs_maladie . '</span><p>Non Justifiées</p> </div> </div> </a> </div> </section> </div> <div class="col-md-4"> <section class="panel bloc"> <div class="panel-body"> <a href="' . action('StatisticsController@new_subscribers', [$year, $month]) . '"> <div class="bloc_statistique"><img src="images/inscription.png" > <span class="count">' . $ns_number . '</span><p>Nouvelles inscriptions Ce Mois</p></div> <div class="bloc_statistique_details"> <div class="bloc_statistique_d1"> <span class="count">' . $garcons . ' </span><p>Garçons</p> </div> <div class="bloc_statistique_d2"> <span class="count">' . $filles . '</span><p>Filles</p> </div> </div> </a> </div> </section> </div> <div class="col-md-4"> <section class="panel bloc"> <div class="panel-body"> <a href="' . action('StatisticsController@monthly_bills', [$year, $month]) . '"> <div class="bloc_statistique"><img src="images/factures.png" ><span class="count"> ' . $count_bills . '</span><p>Factures générées Ce Mois</p></div> <div class="bloc_statistique_details"> <div class="bloc_statistique_d1"> <span class="count">' . $regled_bills . '</span><p>Réglées</p> </div> <div class="bloc_statistique_d2"> <span class="count">' . $non_regled_bills . '</span><p>Non réglées</p> </div> </div> </a> </div> </section> </div> </div> <div class="row partie-down"> <div class="col-md-4"> <section class="panel bloc"> <div class="panel-body"> <a href="#"> <div class="bloc_statistique"><img src="images/statistiques.png" > <span class="count">' . $somme . ' </span><p>Dhs total estimé Ce Mois</p></div> <div class="bloc_statistique_details"> <div class="bloc_statistique_d1"> <span class="count">' . $encaisse . '</span><p>Dhs encaissé</p> </div> <div class="bloc_statistique_d2"> <span class="count">' . $reste . ' </span><p>Dhs qui reste</p> </div> </div> </a> </div> </section> </div> </div> '; } }
/** * Remove the specified resource from storage. * * @param int $id * @return Response */ public function destroy($id) { $attendance = Attendance::get_attendance($id); $congregation = Congregation::get_congregation($attendance->congregation_id); $deleted_message = 'Attendance for "' . $congregation->name . '" on ' . $attendance->service_date . ' has been deleted successfully.'; Attendance::destroy_attendance($id); return redirect('attendances')->withSuccess($deleted_message); }
public function store(RecordAttendance $request) { Attendance::create($request->all()); }
/** * */ public function run() { $faker = Faker::create(); $eventIds = Event::lists('id'); $userIds = User::lists('id'); foreach (range(1, 200) as $index) { Attendance::create(['user_id' => $faker->randomElement($userIds), 'event_id' => $faker->randomElement($eventIds)]); } }
public function change_hw_status(Request $request) { $attendance_id = $request->attendance_id; $attendance = Attendance::find($attendance_id); $attendance->hw_status = $attendance->hw_status == 1 ? 0 : 1; $attendance->checker_id = $this->user->id; $attendance->save(); return $attendance->status; }
public function attendance($domain, $attendance_id, Request $request) { $attendance = Attendance::find($attendance_id); if (!$attendance) { return response()->json(['error' => "Attendance không tồn tại"], 404); } if ($request->status != null && $request->hw_status != null) { if ($request->status != 1 && $request->status != 0 || $request->hw_status != 1 && $request->hw_status != 0) { return response()->json(['error' => "status và hw_status phải bằng 0 hoặc 1"], 400); } $attendance->status = $request->status == 0 ? 0 : 1; $attendance->hw_status = $request->status == 0 ? 0 : 1; $user = JWTAuth::parseToken()->authenticate(); $attendance->checker_id = $user->id; $attendance->save(); return response()->json(['message' => 'success', 'attendance' => $attendance]); } else { return response()->json(['error' => "dữ liệu truyền lên cần có status và hw_status"], 400); } }
/** * Update the specified resource in storage. * * @param Request $request * @param int $id * @return Response */ public function update(Request $request, $activityId, $attId) { $oldId = 0; $newId = 0; // ?action = [ late | sms | leave | update ] $action = $request->query('action', 'update'); // TODO: Set the correct "Recorded By" as a system user $recordedBy = 1; // This value should be set by the SESSION $postData = $request->input('attendance', []); $comments = $request->input('comments', ''); try { $activity = Activity::findOrFail($activityId); $requestedAtt = Attendance::findOrFail($attId); if ($activity->acty_id != $requestedAtt->acty_id) { throw new Exception("Requested att record {$attId} does not belong to activity {$activityId}", 'ERR_MISMATCH'); } if ($action == 'update') { if (array_key_exists('recorded_value', $postData)) { $recordedValue = $postData['recorded_value']; // value to be recorded $ultimateAtt = $this->chainLookupUltimate($requestedAtt); $oldId = $ultimateAtt->att_id; if ($ultimateAtt->recorded_value == '0') { // Case 1: If the attendance record is "blank" i.e. recorded_value = '0' // Update the existing record $ultimateAtt->comments = $comments; $ultimateAtt->recorded_value = $recordedValue; $ultimateAtt->recorded_by = $recordedBy; $ultimateAtt->save(); $newId = $ultimateAtt->att_id; } else { // Case 2: The attendance record was already filled. // Make a superseding one $newAtt = new Attendance(); $newAtt->regt_num = $ultimateAtt->regt_num; $newAtt->prev_att_id = $ultimateAtt->att_id; $newAtt->recorded_value = $recordedValue; $newAtt->recorded_by = $recordedBy; $savedAtt = $activity->attendances()->save($newAtt); $newId = $savedAtt->att_id; } } else { // Payload didn't specify an attendance value. return an error throw new \Exception('No attendance value in payload', ResponseCodes::ERR_POSTDATA_MISSING); } } else { $oldId = $requestedAtt->att_id; if ($action == 'late') { // Case 3: If the update mode is "lateness" // Update the existing record if (array_key_exists('is_late', $postData)) { $requestedAtt->is_late = $postData['is_late'] == '1' ? 1 : 0; $requestedAtt->save(); $newId = $requestedAtt->att_id; } else { throw new \Exception('Expected is_late value in post data', self::ERR_POSTDATA_MISSING); } } elseif ($action == 'leave') { // Case 4: If the update mode is "linking a leave record" // Update the existing record // $leaveId = $request->input('leave', 0); // if ($leaveId){ // $requestedAtt->leave_id = ; // $requestedAtt->save(); // $newId = $requestedAtt->att_id; // } // else { // $error = ['code' => 'EX', 'reason' => $ex->getMessage()]; // } } elseif ($action == 'sms') { // Case 5: Updating the SMS sent status // Update the existing record foreach (['is_sms_sent' => 0, 'sms_timestamp' => date('Y-m-d'), 'sms_mobile' => 'unknown', 'sms_failure' => 'N/A'] as $smsKey => $defaultValue) { if (array_key_exists($smsKey, $postData)) { $ultimateAtt->{$smsKey} = $postData[$smsKey]; // $ultimateAtt->is_sms_sent = $request->input('smsSent', 0); // $ultimateAtt->sms_timestamp = $request->input('smsTimestamp', date('Y-m-d')); // $ultimateAtt->sms_mobile = $request->input('smsMobile', 'unknown'); // $ultimateAtt->sms_failure = $request->input('smsFailure', 'N/A'); } else { $ultimateAtt->{$smsKey} = $defaultValue; } } $ultimateAtt->save(); $newId = $ultimateAtt->att_id; } } return response()->json(['attId' => $attId, 'oldRecordId' => $oldId, 'recordId' => $newId]); } catch (\Exception $ex) { return response()->json(['error' => ['code' => $ex->getCode(), 'reason' => $ex->getMessage()]], 400); } }
public function getPresentAttribute() { $dateId = Attendance::latest('att_date')->first()->id; return $this->attendance()->where('id', '=', $dateId)->first()->pivot->attended; }
public function index($groupId) { $list = \App\Attendance::distinct()->select(['id', 'was_at'])->where('group_id', $groupId)->get(); return view('attendance.index')->withAttendance($list); }
public function absence_raison_today() { if (\Request::ajax()) { $status = \Input::get('status'); $att = Attendance::where('user_id', \Auth::user()->id)->where('title', $status)->whereRaw('EXTRACT(year from start) = ?', [Carbon::now()->year])->whereRaw('EXTRACT(month from start) = ?', [Carbon::now()->month])->whereRaw('EXTRACT(day from start) = ?', [Carbon::now()->day])->orderBy('start', 'desc')->get(); foreach ($att as $t) { if ($t->child->photo) { $photo = asset('uploads/' . $t->child->photo); } else { $photo = asset('images/no_avatar.jpg'); } if ($t->title == 'Maladie') { $class = 'label-info'; $text = 'Non Justifiée'; } elseif ($t->title == 'Normal') { $class = 'label-primary'; $text = 'Justifiée'; } else { $class = 'retard'; $text = 'Retard'; } echo ' <tr> <td><div class="minimal single-row"> <div class="checkbox_liste"> <input type="checkbox" value="' . $t->id . '" name="select[]"> </div> </div></td> <td><img class="avatar" src="' . $photo . '"></td> <td>' . ucwords($t->child->nom_enfant) . '</td> <td>' . Carbon::parse($t->start)->format('d-m-Y') . '</td> <td><span class="label ' . $class . ' label-mini">' . $text . '</span></td> <td> <a href="' . action('StatisticsController@delete_att', [$t]) . '" class="actions_icons delete-att"> <i class="fa fa-trash-o liste_icons"></i></a> <!-- <a class="archive-att" href="' . action('StatisticsController@archive_att', [$t]) . '"><i class="fa fa-archive liste_icons"></i> </a>--> </td> <td><a href="' . action('AttendancesController@show', [$t->child->id]) . '"><div class="btn_details">Détails</div></a></td> </tr>'; } } }
public function delatt() { $tab = \Input::all(); $obj = Attendance::findOrFail($tab['id']); $obj->delete(); }
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; }
public function getDateId() { return Attendance::latest('att_date')->first()->id; }