コード例 #1
0
 function getAttendance($member = '')
 {
     $input = Input::all();
     if ($member == null or $member == '') {
         $memberId = Session::get('memberId');
     } else {
         $memberId = $member;
     }
     if (array_key_exists('date', $input)) {
         $year = date("Y", strtotime($input['date']));
         $startDate = $year . '-01-01';
         $endDate = $startDate . '12-31';
     } else {
         $year = date("Y");
         $startDate = $year . '-01-01';
         $endDate = $year . '-12-31';
     }
     $month = array_key_exists('month', $input) ? $input['month'] : date('F');
     $month = Month::ForMonth($month)->first();
     if (!empty($month)) {
         $attendance = $month->attendances()->DateBetween($startDate, $endDate)->ForMember($memberId)->get();
         $attendances = $this->AverageMonthAttendance($attendance, $month, $year);
         return $attendances;
     } else {
         return Redirect::to('/auth/dashboard')->withFlashMessage('No Attendnce for the month');
     }
 }
コード例 #2
0
 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');
         }
     }
 }