function check_for_entries($student_no) { $entries = Students::all(); $counter = 0; foreach ($entries as $entry) { if ($entry->student_id == $student_no) { $counter++; } } return $counter; }
public function home() { if (Auth::check()) { //Super Admin Dashboard // if (priv() == 1) { //return date("Y-m-d", strtotime("-4 months")); /* Current Month Total Day Count Start */ $date = new \DateTime("-6"); $date->modify("-" . ($date->format('j') - 1) . " days"); $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('Y-m-d', $i); $list1[] = date('d D', $i); } $daycount = count($list); //return $mo; //return count($list); /************ Current Month Total Day Count End **************/ /*********** Current Month Total weekend Count Start ***********/ $t = date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y'))); $e = date('Y-m-d', mktime(0, 0, 0, date('m') + 1, 0, date('Y'))); //return $t.'--'.$e; $begin = new \DateTime($t); $end = new \DateTime($e); $interval = new \DateInterval('P1D'); $daterange = new \DatePeriod($begin, $interval, $end); $weekends = []; foreach ($daterange as $date) { if (in_array($date->format('N'), [5])) { $weekends[$date->format('W')][] = $date->format('Y-m-d'); } } $week = count($weekends); //return $week; //echo 'Number of weeks: ' . count($weekends); //echo 'Number of weekend days: ' . (count($weekends, COUNT_RECURSIVE) - count($weekends)); /************ Current Month Total weekend Count End ****************/ $workday = $daycount - $week; /************ Current Month Teacher Attdence Percentage Start ****************/ $teacher = Teacher::all()->count(); $allteacherworkday = $workday * $teacher; $m = date("Y-m"); $teacheratten1 = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $teacheratten2 = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 0)->count(); $total = $teacheratten1 + $teacheratten2; $tcurrent = (int) ($total / $allteacherworkday * 100); /************ Current Month Teacher Attdence Percentage End ****************/ /************ Current Month Student Attdence Percentage Start ****************/ $student = Students::all()->count(); $studentclassday = $workday * $student; //return $studentclassday; $m = date("Y-m"); $studentm = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Student')->where('status', '=', 0)->count(); $sttotal = (int) ($studentm / $studentclassday * 100); /************ Current Month Student Attdence Percentage End ****************/ /*** six month day count Start ***/ $d1 = date("Y-m-d"); $d2 = date("Y-m-d", strtotime("-6 months")); //return $d2.$d1; $date1 = strtotime($d2); $date2 = strtotime($d1); //return $date1.'=='.$date2; $months = 0; while (($date1 = strtotime('+1 DAY', $date1)) <= $date2) { $months++; } //return $months; /*** Week Count For six month Start***/ $t = $d2; $e = $d1; //return $t.'--'.$e; $beginsix = new \DateTime($t); $endsix = new \DateTime($e); //return $begin.'--'.$end; $intervalsix = new \DateInterval('P1D'); $daterangesix = new \DatePeriod($beginsix, $intervalsix, $endsix); $weekendsix = []; foreach ($daterangesix as $date) { if (in_array($date->format('N'), [5])) { $weekendsix[$date->format('W')][] = $date->format('Y-m-d'); } } $weeksix = count($weekendsix); /* Teacher Six month calculation start */ $totaldaycountsix = $months - $weeksix; $t1 = Attendence::whereBetween('created_at', [$d2, $d1])->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $t2 = Attendence::whereBetween('created_at', [$d2, $d1])->where('type', '=', 'Teacher')->where('status', '=', 0)->count(); $ct = $t1 + $t2; $sixmonthtattenpercent = (int) ($ct / $totaldaycountsix * 100); /* Teacher Six month calculation End */ /* Student Six month calculation start */ $s1 = Attendence::whereBetween('created_at', [$d2, $d1])->where('type', '=', 'Student')->where('status', '=', 0)->count(); $studentpercentsixmonth = (int) ($s1 / $totaldaycountsix * 100); /* Student Six month calculation End */ //echo 'Number of weeks: ' . count($weekends); //echo 'Number of weekend days: ' . (count($weekends, COUNT_RECURSIVE) - count($weekends)); /*** Week Count For Six month End ***/ /*** six month day count End ***/ /*** one year day count Start ***/ $dy1 = date("Y-m-d"); $dy2 = date("Y-m-d", strtotime("-12 months")); //return $d2.$d1; $datey1 = strtotime($dy2); $datey2 = strtotime($dy1); //return $date1.'=='.$date2; $monthsy = 0; while (($datey1 = strtotime('+1 DAY', $datey1)) <= $datey2) { $monthsy++; } //return $months; /*** Week Count For six month Start***/ $ty = $dy2; $ey = $dy1; //return $t.'--'.$e; $beginy = new \DateTime($ty); $endy = new \DateTime($ey); //return $begin.'--'.$end; $intervaly = new \DateInterval('P1D'); $daterangey = new \DatePeriod($beginy, $intervaly, $endy); $weekendy = []; foreach ($daterangey as $date) { if (in_array($date->format('N'), [5])) { $weekendy[$date->format('W')][] = $date->format('Y-m-d'); } } $weekyear = count($weekendy); //return $weekyear; $totaldaycountyear = $monthsy - $weekyear; /* Teacher One year Start*/ $ty1 = Attendence::whereBetween('created_at', [$dy2, $dy1])->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $ty2 = Attendence::whereBetween('created_at', [$dy2, $dy1])->where('type', '=', 'Teacher')->where('status', '=', 0)->count(); $cty = $ty1 + $ty2; //return $cty; $yeartattenpercent = (int) ($cty / $totaldaycountyear * 100); /* Teacher One year End*/ /* Student One year Start*/ $sy2 = Attendence::whereBetween('created_at', [$dy2, $dy1])->where('type', '=', 'Student')->where('status', '=', 0)->count(); //return $cty; $styearcount = (int) ($sy2 / $totaldaycountyear * 100); /* Student One year End*/ //return $yeartattenpercent; //echo 'Number of weeks: ' . count($weekends); //echo 'Number of weekend days: ' . (count($weekends, COUNT_RECURSIVE) - count($weekends)); /*** Week Count For Six month End ***/ /*** six month day count End ***/ /***************************************************** Teacher Percent End ********/ //Super Admin $AtotalInstitute = Institute::where('status', '=', 1)->count(); $AtotalStudents = Students::where('status', '=', 1)->count(); $AtotalStudentsMale = Students::where('status', '=', 1)->where('gender', '=', 'Male')->count(); $AtotalStudentsFemale = Students::where('status', '=', 1)->where('gender', '=', 'Female')->count(); $SAtotalTeachers = Teacher::all()->count(); $SAtotalTeachersMale = Teacher::where('gender', '=', 'Male')->count(); $SAtotalTeachersFeMale = Teacher::where('gender', '=', 'Female')->count(); $OthersTeacher = Teacher::where('gender', '=', 'Other')->count(); //today report in % $today = date('Y-m-d'); $y = date("Y"); //$totalTeachesrs=Teacher::where('institute_code', '=', Auth::user()->institute_id)->count(); $teacherAttendence = Attendence::where('type', '=', 'Teacher')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $teacherAttendence1 = Attendence::where('type', '=', 'Teacher')->where('status', '=', 1)->where('created_at', 'LIKE', "%{$today}%")->count(); $total = $teacherAttendence + $teacherAttendence1; //return $total; $today_atten = (int) ($total / $SAtotalTeachers * 100); //return $today_atten; //end today report //This Month Report in % $m = date("Y-m"); $d = date('t'); $at = Holyday::where('holiday_date', 'LIKE', "%{$m}%")->count(); $p = $d - $at; $a12 = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a02 = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 0)->count(); $ay2 = $a12 + $a02; //return $a12.$a02; $t = $SAtotalTeachers * $p; $ms = (int) ($ay2 / $t * 100); //return $ms; //This Month Rreport End return view('welcome')->with('atotalInstitute', $AtotalInstitute)->with('atotalStudents', $AtotalStudents)->with('atotalStudentsMale', $AtotalStudentsMale)->with('atotalStudentsFemale', $AtotalStudentsFemale)->with('satotalteacher', $SAtotalTeachers)->with('satotalmaleteacher', $SAtotalTeachersMale)->with('satotalfemaleteacher', $SAtotalTeachersFeMale)->with('others', $OthersTeacher)->with('today', $today_atten)->with('cmonth', $ms)->with('tattencmonth', $tcurrent)->with('sixmonth', $sixmonthtattenpercent)->with('oneyear', $yeartattenpercent)->with('totalstudentmonth', $sttotal)->with('totalpercentstudentsix', $studentpercentsixmonth)->with('studentoneyear', $styearcount); } elseif (priv() == 2) { /****Student****/ $today = date('Y-m-d'); $y = date("Y"); //return $today; $totalStudents = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->count(); $totalStudentsMale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalStudentsFemale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Female')->count(); $totalTeachesrs = Teacher::where('institute_code', '=', Auth::user()->institute_id)->count(); $teacherAttendence = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Teacher')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $teacherAttendence1 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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', '=', Auth::user()->institute_id)->where('created_at', 'LIKE', "%{$y}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a0 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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); } $totalTeacherMale = Teacher::where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalTeacherFemale = Teacher::where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Female')->count(); $m = date("Y-m"); $d = date('t'); $at = Holyday::where('holiday_date', 'LIKE', "%{$m}%")->count(); $p = $d - $at; //return $p; $a12 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a02 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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); //return $ms; $at = Holyday::where('holiday_date', 'LIKE', "%{$m}%")->count(); $InstiHolyday = InstiHolyday::where('holiday_date', 'LIKE', "%{$m}%")->where('institute_code', '=', Auth::user()->institute_id)->count(); // $InstiHolyday=AcademicCalender::where('holiday_date','LIKE',"%$m%")->where('institute_code', '=', Auth::user()->institute_id)->count(); //return $InstiHolyday; $p = $d - ($at + $InstiHolyday); $ms = (int) ($p / $d * 100); //students attendence report saif... //today attendence calculation $totalStudents = Students::where('institute_code', '=', Auth::user()->institute_id)->count(); $totalstudentsAtten = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Student')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $studentTodayReport = (int) ($totalstudentsAtten / $totalStudents * 100); //monthly calculation $stdPrestAve = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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('welcome')->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); } elseif (priv() == 3) { /****School Admin****/ $totalStudents = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->count(); $totalStudentsMale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalStudentsFemale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Female')->count(); $totalTeachesrs = Teacher::where('institute_code', '=', Auth::user()->institute_id)->count(); $totalTeacherMale = Teacher::where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalTeacherFemale = Teacher::where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Female')->count(); /* Current Month Total Day Count Start */ $date = new \DateTime("-6"); $date->modify("-" . ($date->format('j') - 1) . " days"); $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('Y-m-d', $i); $list1[] = date('d D', $i); } $daycount = count($list); //return $mo; //return count($list); /************ Current Month Total Day Count End **************/ /*********** Current Month Total weekend Count Start ***********/ $t = date('Y-m-d', mktime(0, 0, 0, date('m'), 1, date('Y'))); $e = date('Y-m-d', mktime(0, 0, 0, date('m') + 1, 0, date('Y'))); //return $t.'--'.$e; $begin = new \DateTime($t); $end = new \DateTime($e); $interval = new \DateInterval('P1D'); $daterange = new \DatePeriod($begin, $interval, $end); $weekends = []; foreach ($daterange as $date) { if (in_array($date->format('N'), [5])) { $weekends[$date->format('W')][] = $date->format('Y-m-d'); } } $week = count($weekends); //return $week; //echo 'Number of weeks: ' . count($weekends); //echo 'Number of weekend days: ' . (count($weekends, COUNT_RECURSIVE) - count($weekends)); /************ Current Month Total weekend Count End ****************/ $workday = $daycount - $week; /************ Current Month Teacher Attdence Percentage Start ****************/ $teacher = Teacher::where('institute_code', '=', Auth::user()->institute_id)->count(); $allteacherworkday = $workday * $teacher; //return $allteacherworkday; $m = date("Y-m"); $teacheratten1 = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $teacheratten2 = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Teacher')->where('status', '=', 0)->count(); $total = $teacheratten1 + $teacheratten2; // return $allteacherworkday; if ($allteacherworkday == 0) { // return 1; $tcurrent = (int) ($total / 1 * 100); // return $tcurrent; } elseif ($allteacherworkday != 0) { $tcurrent = (int) ($total / $allteacherworkday * 100); } //return 2; //$tcurrent=(int) (($total/$allteacherworkday)*100); //return $tcurrent; /************ Current Month Teacher Attdence Percentage End ****************/ /************ Current Month Student Attdence Percentage Start ****************/ $student = Students::where('institute_code', '=', Auth::user()->institute_id)->count(); $studentclassday = $workday * $student; //return $studentclassday; $m = date("Y-m"); $studentm = Attendence::where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Student')->where('status', '=', 0)->count(); if ($studentclassday == 0) { $sttotal = (int) ($studentm / 1 * 100); } elseif ($studentclassday != 0) { $sttotal = (int) ($studentm / $studentclassday * 100); } //$sttotal=(int) (($studentm/$studentclassday)*100); /************ Current Month Student Attdence Percentage End ****************/ return view('welcome')->with('totalStudents', $totalStudents)->with('totalTeachesrs', $totalTeachesrs)->with('totalStudentsMale', $totalStudentsMale)->with('totalStudentsFemale', $totalStudentsFemale)->with('m', $totalTeacherMale)->with('f', $totalTeacherFemale)->with('teacherthismonth', $tcurrent)->with('studentrthismonth', $sttotal); } elseif (priv() == 4) { /****Teacher****/ $today = date('Y-m-d'); $y = date("Y"); //return $today; $totalStudents = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->count(); $totalStudentsMale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalStudentsFemale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Female')->count(); $totalTeachesrs = Teacher::where('institute_code', '=', Auth::user()->institute_id)->count(); $teacherAttendence = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Teacher')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $teacherAttendence1 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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', '=', Auth::user()->institute_id)->where('created_at', 'LIKE', "%{$y}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a0 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalTeacherFemale = Teacher::where('institute_code', '=', Auth::user()->institute_id)->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', '=', Auth::user()->institute_id)->where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a02 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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); //return $ms; $at = Holyday::where('holiday_date', 'LIKE', "%{$m}%")->count(); $InstiHolyday = InstiHolyday::where('holiday_date', 'LIKE', "%{$m}%")->where('institute_code', '=', Auth::user()->institute_id)->count(); // $InstiHolyday=AcademicCalender::where('holiday_date','LIKE',"%$m%")->where('institute_code', '=', Auth::user()->institute_id)->count(); //return $InstiHolyday; $p = $d - ($at + $InstiHolyday); $ms = (int) ($p / $d * 100); //students attendence report saif... //today attendence calculation $totalStudents = Students::where('institute_code', '=', Auth::user()->institute_id)->count(); $totalstudentsAtten = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Student')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $studentTodayReport = (int) ($totalstudentsAtten / $totalStudents * 100); //monthly calculation $stdPrestAve = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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('welcome')->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); } elseif (priv() == 5) { /****Parents****/ $today = date('Y-m-d'); $y = date("Y"); //return $today; $totalStudents = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->count(); $totalStudentsMale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalStudentsFemale = Students::where('status', '=', 1)->where('institute_code', '=', Auth::user()->institute_id)->where('gender', '=', 'Female')->count(); $totalTeachesrs = Teacher::where('institute_code', '=', Auth::user()->institute_id)->count(); $teacherAttendence = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Teacher')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $teacherAttendence1 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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', '=', Auth::user()->institute_id)->where('created_at', 'LIKE', "%{$y}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a0 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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', '=', Auth::user()->institute_id)->where('gender', '=', 'Male')->count(); $totalTeacherFemale = Teacher::where('institute_code', '=', Auth::user()->institute_id)->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', '=', Auth::user()->institute_id)->where('created_at', 'LIKE', "%{$m}%")->where('type', '=', 'Teacher')->where('status', '=', 1)->count(); $a02 = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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); //return $ms; $at = Holyday::where('holiday_date', 'LIKE', "%{$m}%")->count(); $InstiHolyday = InstiHolyday::where('holiday_date', 'LIKE', "%{$m}%")->where('institute_code', '=', Auth::user()->institute_id)->count(); // $InstiHolyday=AcademicCalender::where('holiday_date','LIKE',"%$m%")->where('institute_code', '=', Auth::user()->institute_id)->count(); //return $InstiHolyday; $p = $d - ($at + $InstiHolyday); $ms = (int) ($p / $d * 100); //students attendence report saif... //today attendence calculation $totalStudents = Students::where('institute_code', '=', Auth::user()->institute_id)->count(); $totalstudentsAtten = Attendence::where('institute_code', '=', Auth::user()->institute_id)->where('type', '=', 'Student')->where('status', '=', 0)->where('created_at', 'LIKE', "%{$today}%")->count(); $studentTodayReport = (int) ($totalstudentsAtten / $totalStudents * 100); //monthly calculation $stdPrestAve = Attendence::where('institute_code', '=', Auth::user()->institute_id)->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('welcome')->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); } elseif (priv() == 6) { /****Users****/ return "Users"; } elseif (priv() == 7) { /****Thana Officer****/ return "Thana Officer"; } elseif (priv() == 8) { /****District Officer****/ return "District Officer"; } elseif (priv() == 9) { /****Division Officer****/ return "Divission Officer"; } elseif (priv() == 10) { /****Board Officer****/ return "Board Officer"; } else { Session::flash('data', 'Not Logged In! Please Login to Continue.'); return redirect::to('/'); } } else { Session::flash('data', 'Not Logged In! Please Login to Continue.'); return redirect::to('/'); } }
//Route::get('/movies', function () { //$Movies = \App\Movie::where('title','=','shuga')->get(); //$Movies = \App\movie::where('rating','>'2)->get(); //select * from movies where rating > 2 //return $movies; //$movie= new \App\Movie(); //$Movie->title='Akirachix'; //$movie->genre='awesome'; //$movie->rating=5; //$movie->save(); // $movie= \App\Movie::find(5); // $movie->genre='Horror'; // $movie->rating=4; // $movie->save(); // return $movie; //return \App\Movie::all(); Route::get('/students', function () { //$Students = \App\Students::where('lastname','=','Maich')->get(); //return $Students; $students = new \App\Students(); $students->id = '6'; $students->firstname = 'Cate'; $students->lastname = 'Mwai'; $students->save(); // $movie= \App\Movie::find(5); // $movie->genre='Horror'; // $movie->rating=4; // $movie->save(); // return $movie; return \App\Students::all(); Route::get('/movies', 'studentsController@index'); });
/** * Display a listing of the resource. * * @return \Illuminate\Http\Response */ public function index() { $students = Students::all(); $data = array('students' => $students); return view('students.list', $data); }