示例#1
0
 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;
 }
 /**
  * Display a listing of attendances
  *
  * @return Response
  */
 public function index()
 {
     if (!Sentry::getUser()) {
         return Redirect::route('sessions.create');
     }
     $attendances = Attendance::where('user_id', '=', Sentry::getUser()->id)->get();
     return View::make('attendances.index', compact('attendances'));
 }
示例#3
0
 static function getDaysAttendanceForStudent($studentId, $batchId, $attendanceDate)
 {
     //echo "student_id".$studentId.' batchId'.$batchId.' attendanceDate'.$attendanceDate;
     $attendance = Attendance::where('student_id', '=', $studentId)->where('batch_id', '=', $batchId)->where('attendance_date', '=', $attendanceDate)->first();
     //print_r(DB::getQueryLog());
     if ($attendance) {
         return $attendance;
     }
     return false;
 }
示例#4
0
 public function __construct()
 {
     $this->data['setting'] = Setting::all()->first();
     if (!isset($this->data['setting']) && count($this->data['setting']) == 0) {
         die('Database not uploaded.Please Upload the database');
     }
     if (count($this->data['setting'])) {
     }
     $this->data['loggedAdmin'] = Auth::admin()->get();
     $this->data['pending_applications'] = Attendance::where('application_status', '=', 'pending')->get();
 }
示例#5
0
 /**
  * Get the last absent days
  * If the user is not absent since joining then.Joining date is last absent date
  */
 public function lastAbsent($employeeID, $type = 'days')
 {
     $absent = Attendance::where('status', '=', 'absent')->where('employeeID', '=', $employeeID)->where(function ($query) {
         $query->where('application_status', '=', 'approved')->orWhere('application_status', '=', null);
     })->orderBy('date', 'desc')->first();
     $joiningDate = Employee::select('joiningDate')->where('employeeID', '=', $employeeID)->first();
     $lastDate = date('Y-m-d');
     $old_date = isset($absent->date) ? $absent->date : $joiningDate->joiningDate;
     $diff = date_diff(date_create($old_date), date_create($lastDate));
     $difference = $diff->format('%R%a') . ' day ago';
     if ($type == 'days') {
         return $difference;
     } elseif ($type == 'date') {
         return date_create($old_date)->format('d-M-Y');
     }
 }
 public function apiSearchFastTree($phrase, $except = [], $dateTimeforCheck = [])
 {
     if (!is_array($except) && strlen($except) > 0) {
         $except = explode(",", $except);
     }
     if (!is_array($except) && strlen($except) > 0) {
         $except = explode(",", $except);
     }
     $strict_option = intval(Settings_controller::getOther('attendance_strict'));
     $result = [];
     $points = Attendance::where("name", "like", "%" . $phrase . "%")->where('active', 1)->whereNotIn("id", $except)->take(500)->get();
     foreach ($points as $point) {
         $point->free = true;
         $point->selectable = true;
         $point->path = $this->makePathString($this->fullParentInfo($point->id));
         if ($point->container) {
             $result['containers'][] = $point;
         } else {
             if ($point->check) {
                 if (count($dateTimeforCheck)) {
                     foreach ($dateTimeforCheck as $dateTimeArr) {
                         $start = date_create($dateTimeArr['date'] . " " . $dateTimeArr['start_time']);
                         $end = date_create($dateTimeArr['date'] . " " . $dateTimeArr['end_time']);
                         //                            dump($point->id, $start, $end);
                         $check = $this->isFree($point->id, $start, $end);
                         //                            die;
                         if (!$check) {
                             $point->free = false;
                             if ($strict_option) {
                                 if (!Auth::isAdmin(App::$instance)) {
                                     $point->selectable = false;
                                 }
                             }
                             break;
                         }
                     }
                 }
             }
             $result['points'][] = $point;
         }
     }
     print json_encode($result);
 }