public function instituteReport($Iid) { /****Admin****/ $today = date('Y-m-d'); $y = date("Y"); //return $today; $totalStudents = Students::where('status', '=', 1)->where('institute_code', '=', $Iid)->count(); $totalStudentsMale = Students::where('status', '=', 1)->where('institute_code', '=', $Iid)->where('gender', '=', 'Male')->count(); $totalStudentsFemale = Students::where('status', '=', 1)->where('institute_code', '=', $Iid)->where('gender', '=', 'Female')->count(); $totalTeachesrs = Teacher::where('institute_code', '=', $Iid)->count(); $teacherAttendence = Attendence::where('institute_code', '=', $Iid)->where('type', '=', 'Teacher')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $teacherAttendence1 = Attendence::where('institute_code', '=', $Iid)->where('type', '=', 'Teacher')->where('status', '=', 1)->where('created_at', 'LIKE', "%{$today}%")->count(); $total = $teacherAttendence + $teacherAttendence1; //return $total; $today_atten = (int) ($total / $totalTeachesrs * 100); //return $today_atten; $a1 = Attendence::where('institute_code', '=', $Iid)->where('created_at', 'LIKE', "%{$y}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a0 = Attendence::where('institute_code', '=', $Iid)->where('created_at', 'LIKE', "%{$y}%")->where('type', '=', 'Teacher')->where('status', '=', 0)->count(); $ay = $a1 + $a0; //return $ay; if ($y % 4 == 0) { $x = 366; $year_percent = (int) ($ay / $x * 100); } else { $yx = 365; $year_percent = (int) ($ay / $yx * 100); } //return $atten_percent; // return $AtotalInstitute; $totalTeacherMale = Teacher::where('institute_code', '=', $Iid)->where('gender', '=', 'Male')->count(); $totalTeacherFemale = Teacher::where('institute_code', '=', $Iid)->where('gender', '=', 'Female')->count(); $m = date("Y-m"); ///$h=Holyday::where('holiday_date','LIKE',"%2016-03%")->get(); //$h=Holyday::where('holiday_date','LIKE',"%$m%")->get(); $d = date('t'); $at = Holyday::where('holiday_date', 'LIKE', "%{$m}%")->count(); $p = $d - $at; //return $p; $a12 = Attendence::where('institute_code', '=', $Iid)->where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a02 = Attendence::where('institute_code', '=', $Iid)->where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 0)->count(); $ay2 = $a12 + $a02; //return $a12.$a02; $t = $totalTeachesrs * $p; $ms = (int) ($ay2 / $t * 100); $at = Holyday::where('holiday_date', 'LIKE', "%{$m}%")->count(); $InstiHolyday = InstiHolyday::where('holiday_date', 'LIKE', "%{$m}%")->where('institute_code', '=', $Iid)->count(); $InstiWeekEnd = AcademicCalender::where('institute_code', '=', $Iid)->pluck('weekendday'); $WeekEnd1 = str_limit($InstiWeekEnd, 3, ''); $WeekEnd2 = substr($InstiWeekEnd, 4); $WeekEnd3 = substr($InstiWeekEnd, 9); // return date('d', strtotime($WeekEnd1)); $month = date('m'); $year = date("Y"); $start_date = "01-" . $month . "-" . $year; $start_time = strtotime($start_date); $end_time = strtotime("+1 month", $start_time); for ($i = $start_time; $i < $end_time; $i += 86400) { $list[] = date('D', $i); } $p = $d - ($at + $InstiHolyday); $ms = (int) ($p / $d * 100); //students attendence report saif... //today attendence calculation $totalStudents = Students::where('institute_code', '=', $Iid)->count(); $totalstudentsAtten = Attendence::where('institute_code', '=', $Iid)->where('type', '=', 'Student')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $studentTodayReport = (int) ($totalstudentsAtten / $totalStudents * 100); //monthly calculation $stdPrestAve = Attendence::where('institute_code', '=', $Iid)->where('type', '=', 'Student')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$m}%")->count(); //$presentPersent= (int)(($stdPrestAve/$p)*100); $mtotal = $totalStudents * $p; $monthpresentPersent = (int) ($stdPrestAve / $mtotal * 100); ///yearly calculation return view('superadmin.ListofInstituteReport')->with('totalStudents', $totalStudents)->with('totalTeachesrs', $totalTeachesrs)->with('totalStudentsMale', $totalStudentsMale)->with('totalStudentsFemale', $totalStudentsFemale)->with('today', $today_atten)->with('year', $year_percent)->with('m', $totalTeacherMale)->with('f', $totalTeacherFemale)->with('mon', $ms)->with('studentTodayReport', $studentTodayReport)->with('monthpresentPersent', $monthpresentPersent); }
public function postStudentsAttendenceDetails($uid) { $Cmonth = date("Y-m"); $holi = Holyday::where('holiday_date', '=', '2016-03-26')->count(); $query = Holyday::query(); $AppWE = AcademicCalender::where('institute_code', '=', Auth::user()->institute_id)->pluck('weekendday'); // return date('D', strtotime($gh)); // $App=Holyday::all(); // return strlen($AppWE); $App = str_limit($AppWE, 3, ''); $sewe = substr($AppWE, 4); $sewe3 = substr($AppWE, 9); //return $sewe3; //$App=Holyday::all(); $maxDays = date('t'); //how may day current month $currentDayOfMonth = date('j'); //today numaric $today = date("d"); $Cmonth = date("Y-m"); $y = date("Y"); // return $y; $GetStudents = DB::table('tbl_studets')->join('tbl_attendence', 'tbl_studets.st_id', '=', 'tbl_attendence.uid')->select('tbl_studets.*', 'tbl_attendence.*')->where('tbl_attendence.institute_code', '=', Auth::user()->institute_id)->where('tbl_studets.institute_code', '=', Auth::user()->institute_id)->where('tbl_attendence.type', '=', 'Student')->where('tbl_studets.st_id', '=', $uid)->first(); $stdPrestAve = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('uid', '=', $uid)->where('status', '=', 0)->where('created_at', 'LIKE', "%{$Cmonth}%")->count(); $presentPersent = (int) ($stdPrestAve / $today * 100); //return $presentPersent; $stdClass = ClassAdd::where('class_id', '=', $GetStudents->class)->pluck('class_name'); $month = date('m'); $year = date("Y"); $start_date = "01-" . $month . "-" . $year; $start_time = strtotime($start_date); $end_time = strtotime("+1 month", $start_time); for ($i = $start_time; $i < $end_time; $i += 86400) { $list[] = date('d D', $i); } for ($i = $start_time; $i < $end_time; $i += 86400) { $listdate[] = date('Y-m-d', $i); } //return $rand = substr(uniqid('', true), -4);//uniq random id limit return view('admin.attendence.studentsAttendanceViewDetails')->with('stdInfo', $GetStudents)->with('stdClass', $stdClass)->with('persent', $presentPersent)->with('day', $list)->with('listdate', $listdate)->with('App', $App)->with('sewe', $sewe)->with('sewe3', $sewe3); }