public function updatestate($student_id, Request $request) { $student = Student::find($student_id); $student->state = $request->input('state'); $student->save(); $message = trans('students::students.update_success', ['name' => $student->name]); return redirect()->route('students.students.show', $student_id)->with('success', $message); }
/** * Execute the job. * * @return void */ public function handle() { $student = Student::find($this->student_id); $currentSemester = semester(); if ($student) { $history = StudentHistory::where('academycycle_semester_id', $currentSemester->id)->where('student_id', $student->id)->first(); if ($history) { $history->update(['state' => 'fired', 'study_state' => 'stop']); } StudentSubject::where('semester_id', $currentSemester->id)->where('student_id', $student->id)->update(['state' => 'fail']); $student->update(['state' => 'fired', 'study_state' => 'stop']); } }
/** * Execute the job. * * @return void */ public function handle() { $student = Student::find($this->student_id); if ($student) { $failed_subjects = []; $success_subjects = []; $semester = semester(); $subjects = StudentSubject::selectRaw("subsub.id as subject_id,SUM(stugr.value) AS subject_points,student_subjects.state as subject_state,subsub.name AS subject_name, subsub.hour AS subject_hours")->join('subject_subjects AS subsub', function ($join) { $join->on('subsub.id', '=', 'student_subjects.subject_id'); })->where('student_subjects.student_id', $student->id)->leftJoin('student_grades AS stugr', function ($join) use($student, $semester) { $join->on('stugr.subject_id', '=', 'subsub.id')->where('stugr.semester_id', '=', $semester->id)->where('stugr.student_id', '=', $student->id); })->whereIn('state', ['study', 'success', 'fail'])->where('student_subjects.semester_id', '=', $semester->id)->where('student_subjects.student_id', $student->id)->groupBy('subsub.id')->get(); $subjects->each(function ($subject) use(&$failed_subjects, $success_subjects) { $subject->details = grade_details($subject->subject_points, $subject->subject_hours); if ((double) $subject->subject_points < 50) { $failed_subjects[] = $subject->subject_id; } else { $success_subjects[] = $subject->subject_id; } }); $semester->load('year'); $currentYear = $semester->year; $nextYear = AcademycycleYear::where('start_at', '>', $currentYear->start_at)->first(); $repeatSemester = Semester::where('order', $semester->order)->where('academycycle_year_id', $nextYear->id)->first(); $currentHistory = StudentHistory::where('student_id', $student->id)->where('academycycle_semester_id', $semester->id)->first(); $repeatSubjects = []; foreach ($failed_subjects as $subject_id) { $repeatSubjects[$subject_id] = ['semester_id' => $repeatSemester->id, 'academystructure_department_id' => $currentHistory->academystructure_department_id, 'state' => 'study']; } $student->subjects()->attach($repeatSubjects); StudentSubject::where('semester_id', $semester->id)->where('student_id', $student->id)->whereIn('subject_id', $success_subjects)->update(['state' => 'success']); StudentSubject::where('semester_id', $semester->id)->where('student_id', $student->id)->whereIn('subject_id', $failed_subjects)->update(['state' => 'fail']); $currentHistory->study_state = 'repeat'; $currentHistory->save(); $repeatHistory = $currentHistory->replicate(); $repeatHistory->study_state = 'active'; $repeatHistory->academycycle_semester_id = $repeatSemester->id; $repeatHistory->save(); $student->study_state = 'repeat'; $student->save(); } }
public function index(Request $request) { $tickets = Ticket::orderBy('open', 'desc')->orderBy('priority', 'desc')->orderBy('tickets.updated_at', 'desc')->select('tickets.*')->with('replies', 'department', 'student')->Join('ticket_departments as td', function ($join) { $join->on('td.id', '=', 'tickets.department_id'); })->Join('ticket_department_user as tdu', function ($join) { $join->on('tdu.department_id', '=', 'td.id')->where('user_id', "=", user()->id); }); if (is_array(request('status'))) { $tickets->whereIn('open', request('status')); } if (is_array(request('department_id'))) { $tickets->whereIn('tickets.department_id', request('department_id')); } if (is_array(request('priority'))) { $tickets->whereIn('priority', request('priority')); } if ($request->has('subject')) { $tickets->where('subject', 'LIKE', '%' . request('subject') . '%'); } if ($request->has('student')) { $tickets->where('tickets.student_id', request('student')); $student = Student::find(request('student')); } if ($request->has('create_at')) { $tickets->where('tickets.created_at', 'LIKE', '%' . request('create_at') . '%'); } if (request('year_term')) { $tickets = $tickets->whereHas('student.department', function ($query) { $query->where('term_id', request('year_term')); }); } if ($request->has('is_new')) { $tickets = $tickets->join('ticket_replies as tr', function ($join) { $join->on('tr.ticket_id', '=', 'tickets.id')->where('seen', '=', 0); }); } $ticket_search_count = $tickets->count(); $tickets = $tickets->paginate(30); $tickets->appends($request->except('page')); $ticketcount = Ticket::selectRaw('SUM(IF(open=0 ,1,0)) AS closed, SUM(IF(open=1 ,1,0)) AS open')->with('replies', 'department')->join('ticket_departments as td', function ($join) { $join->on('td.id', '=', 'tickets.department_id'); })->join('ticket_department_user as tdu', function ($join) { $join->on('tdu.department_id', '=', 'td.id')->where('user_id', "=", user()->id); }); $ticketcount = $ticketcount->first(); //dd($ticketcount); $unseencount = Ticket::orderBy('open', 'desc')->join('ticket_replies as tr', function ($join) { $join->on('tr.ticket_id', '=', 'tickets.id')->where('seen', '=', 0); })->join('ticket_departments as td', function ($join) { $join->on('td.id', '=', 'tickets.department_id'); })->join('ticket_department_user as tdu', function ($join) { $join->on('tdu.department_id', '=', 'td.id')->where('tdu.user_id', "=", user()->id); })->whereNull('tr.user_id')->count(); $categories = TicketCategory::pluck('name', 'id')->toArray(); $categories = [NULL => NULL] + $categories; $year_term = year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name, academystructure_terms.id as tid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->orderBy('academystructure_terms.id')->pluck('name', 'tid')->toArray(); $options = []; $departments = TicketDepartment::withDepth()->defaultOrder()->orderBy('parent_id', 'ASC')->get(); foreach ($departments as $department) { $options[$department->id] = str_repeat("----", $department->depth) . $department->name; } $priorities = trans('tickets::tickets.priorities'); $has_search = count($request->except('page', 'per_page')); if ($request->ajax()) { $unseen = Ticket::orderBy('open', 'desc')->join('ticket_replies as tr', function ($join) { $join->on('tr.ticket_id', '=', 'tickets.id')->where('seen', '=', 0); })->join('ticket_departments as td', function ($join) { $join->on('td.id', '=', 'tickets.department_id'); })->join('ticket_department_user as tdu', function ($join) { $join->on('tdu.department_id', '=', 'td.id')->where('tdu.user_id', "=", user()->id); })->whereNull('tr.user_id')->count(); $view = view('tickets::tickets._table', compact('categories', 'year_term', 'tickets', 'options', 'priorities', 'has_search', 'student', 'ticketcount', 'ticket_search_count'))->render(); return response()->json(['unseen' => $unseen, 'view' => $view]); } return view('tickets::tickets.index', compact('tickets', 'categories', 'year_term', 'options', 'priorities', 'has_search', 'student', 'ticketcount', 'unseencount', 'ticket_search_count')); }
/** * Show the form for editing the specified resource. * @return Response */ public function edit($doc_id) { $doc = PaperDoc::with('paper', 'pfiles')->find($doc_id); $paper = $doc->paper; $student = Student::find($paper->student_id); $category = $doc->category; $types = config('papers.' . $doc->category); $diff[$doc->type] = $types[$doc->type]; if ($category == 'semester_type') { //semester case $Semesters = Semester::select('academycycle_semesters.id', DB::raw('CONCAT(academycycle_semesters.name ,"-", ay.name ) as name '))->join('academycycle_years as ay', 'academycycle_semesters.academycycle_year_id', '=', 'ay.id')->pluck('name', 'id')->toArray(); $users = User::pluck('name', 'id')->toArray(); return view('papers::edit', compact('doc_id', 'student', 'paper', 'diff', 'doc', 'category', 'Semesters', 'users')); } else { return view('papers::edit', compact('doc_id', 'student', 'paper', 'diff', 'doc', 'category')); } }
public function changeClassroom(Request $request, $classroom_id) { $ids = $request->input('table_records'); $new_classroom_id = $request->input('new_classroom_id'); $notes = $request->input('notes'); /*$sem_id = semester()->id; $new_classroom = new classrooms(); $new_classroom->classroom_id = $new_classroom_id; $new_classroom->semester_id = $sem_id; */ if (!empty($ids) && is_array($ids)) { foreach ($ids as $id) { $student = Student::find($id); $student->classrooms()->detach($classroom_id); event(new StudentExitClassroom(Classroom::find($classroom_id), $student, user(), $notes)); $student->classrooms()->attach([$request->input('new_classroom_id') => ['semester_id' => semester()->id]]); event(new StudentChoseClassroom(Classroom::find($new_classroom_id), $student, user(), $notes)); } } return redirect()->route('classrooms.classrooms.students', $new_classroom_id); }
/** * Execute the job. * * @return void */ public function handle() { $student = Student::find($this->student_id); $currentSemester = semester(); $summerSemester = Semester::where('id', '>', $currentSemester->id)->where('order', 'summer')->orderBy('id', 'ASC')->first(); // Log::info($student->id, $currentSemester->id, $summerSemester->id); if ($student && $currentSemester && $summerSemester) { $nextSemester = Semester::where('id', '>', $currentSemester->id)->where('order', '!=', 'summer')->orderBy('id', 'ASC')->first(); if (!$nextSemester) { return false; } $current_department_id = $student->academystructure_department_id; if ($currentSemester->order != 'summer') { $nextDepartment = Department::where('parent_id', $student->academystructure_department_id)->first(); if ($nextDepartment) { $student->state = 'active'; $student->study_state = 'success'; $student->academystructure_department_id = $nextDepartment->id; } } $history = StudentHistory::where('student_id', $student->id)->orderBy('id', 'desc')->where('academycycle_semester_id', $currentSemester->id)->first(); if ($history) { $history->study_state = 'success'; $history->save(); } if ($student->save()) { // get current semester subjects and make them fail or success for current semester $subjects = StudentSubject::selectRaw("subsub.id as subject_id,SUM(stugr.value) AS subject_points,student_subjects.state as subject_state,subsub.name AS subject_name, subsub.hour AS subject_hours")->join('subject_subjects AS subsub', function ($join) { $join->on('subsub.id', '=', 'student_subjects.subject_id'); })->where('student_subjects.student_id', $student->id)->leftJoin('student_grades AS stugr', function ($join) use($currentSemester, $student) { $join->on('stugr.subject_id', '=', 'subsub.id')->where('stugr.semester_id', '=', $currentSemester->id)->where('stugr.student_id', '=', $student->id); })->whereIn('state', ['study'])->where('student_subjects.semester_id', '=', $currentSemester->id)->where('student_subjects.student_id', $student->id)->groupBy('subsub.id')->get(); $failed_subjects_ids = []; $passed_subjects_ids = []; foreach ($subjects as $subject) { if ($subject->subject_points < 50) { $failed_subjects_ids[] = $subject->subject_id; } elseif ($subject->subject_points >= 50) { $passed_subjects_ids[] = $subject->subject_id; } } StudentSubject::where('student_id', $student->id)->whereIn('subject_id', $failed_subjects_ids)->update(['state' => 'fail']); StudentSubject::where('student_id', $student->id)->whereIn('subject_id', $passed_subjects_ids)->update(['state' => 'success']); // end success and fail if ($currentSemester->order != 'summer' && $nextDepartment) { $next_subject_ids = json_decode($nextDepartment->subject_ids, TRUE); $equal_subject_ids = EqualSubject::whereHas('order', function ($w) use($student) { $w->where('student_id', $student->id); })->pluck('equal_subject_id')->toArray(); $next_subject_study_ids = array_diff($next_subject_ids, $equal_subject_ids); $next_subject_equal_ids = array_intersect($next_subject_ids, $equal_subject_ids); $student->subjects()->attach($next_subject_study_ids, ['semester_id' => $nextSemester->id, 'academystructure_department_id' => $nextDepartment->id, 'state' => 'study']); $student->subjects()->attach($next_subject_equal_ids, ['semester_id' => $nextSemester->id, 'academystructure_department_id' => $nextDepartment->id, 'state' => 'equal']); $data = ['state' => 'active', 'study_state' => 'active', 'academycycle_semester_id' => $nextSemester->id, 'academystructure_department_id' => $nextDepartment->id]; $student->histories()->create($data); // create invoice for student if ($next_subject_equal_ids) { $item = FinancialInvoiceItem::where('slug', 'study_fee')->first(); $subjects_count = Subject::whereIn('id', $next_subject_equal_ids)->where('is_quran', 0)->count(); $data = ['student_id' => $student->id, 'type' => 'debit', 'item_id' => $item->id, 'pay_type' => NULL, 'semester_id' => $nextSemester->id, 'amount' => $subjects_count * $item->amount]; FinancialInvoice::create($data); } } // move any failed subjects if less than 3 to summer semester $all_failed_subjects = StudentSubject::groupBy('subject_id')->where('state', 'fail')->pluck('subject_id')->toArray(); $all_passed_subjects = StudentSubject::groupBy('subject_id')->where('state', 'success')->pluck('subject_id')->toArray(); $failed_subjects = array_diff($all_failed_subjects, $all_passed_subjects); if (COUNT($failed_subjects) <= 3) { $summerSemester = Semester::where('id', '>', $currentSemester->id)->where('order', 'summer')->orderBy('id', 'ASC')->first(); $student->subjects()->attach($failed_subjects, ['semester_id' => $summerSemester->id, 'academystructure_department_id' => $current_department_id, 'state' => 'study']); $data = ['state' => 'active', 'study_state' => 'active', 'academycycle_semester_id' => $summerSemester->id, 'academystructure_department_id' => $current_department_id]; $student->histories()->create($data); } } } }
public function classrooms($student_id = 0) { $student = Student::find($student_id); $available_classrooms = Classroom::select('classrooms.attendees_limit', 'classrooms.name', 'classrooms.code', 'classrooms.id', 'classrooms.teacher_id', 'classrooms.subject_subject_id', 'classrooms.day', 'classrooms.hour')->join('student_subjects as stusub', function ($join) use($student) { $join->on('stusub.subject_id', '=', 'classrooms.subject_subject_id')->where('stusub.state', '=', 'study')->where('stusub.student_id', '=', $student->id); })->whereIn('classrooms.gender', [$student->gender, 'b'])->whereHas('students', function ($query) use($student) { return $query->havingRaw('COUNT(students.id) < attendees_limit'); })->whereNotIn('subject_subject_id', function ($query) use($student) { $query->select('classrooms.subject_subject_id')->from('classrooms')->join('classroom_students as clastud', function ($join) use($student) { $join->on('clastud.classroom_id', '=', 'classrooms.id')->where('clastud.student_id', '=', $student->id); }); })->with('teacher', 'subject', 'students')->groupBy('classrooms.id')->get(); //return $available_classrooms; $event = SemesterEvent::classroom()->first(); $chosen_classrooms = Classroom::whereHas('students', function ($query) use($student) { $query->where('students.id', $student->id); })->get(); // // dd($student->id); // # code... // $studentcalss = Student::with('classrooms','subjects')->where('id',$student->id)->first(); // // dd($studentcalss); // $subjects = Subject::with('classroom')->Student($student->id)->get(); // // $classrooms = $studentcalss->classrooms->pluck('subject_subject_id' ,'name' )->toArray(); // // dd($subjects); // // $subjects = $studentcalss; // // dd($studentcalss); return view('students::subjects.classroom', compact('available_classrooms', 'chosen_classrooms', 'event', 'subjects', 'student', 'classrooms', 'studentcalss')); }
public function index($student_id) { $histories = StudentClassroomHistory::inCurrentSemester()->with('creator')->where("student_id", $student_id)->get(); $student = Student::find($student_id); return view('students::classrooms.histories.index', compact('histories', 'student')); }