/** * @desc Edit Department * @Edit function Open Edit From view * @param Department $department (get department data from provider route model binding $router->model) * @param Specialty $specialty for parent specialty list * @param Subject $subject for parent subject list **/ public function edit(Department $department, Specialty $specialty, Subject $subject) { $subjects = $subject->pluck('name', 'id')->toArray(); $menu = $department->menu()->get(); $specialties = $specialty->get(); return view('academystructure::departments.edit', compact('department', 'menu', 'specialties', 'subjects')); }
public function show(Subject $Subject, $id) { if (!($subject = $Subject->student()->with(['lessons' => function ($query) { $query->orderBy('lesson_order', 'ASC'); }])->findOrFail($id))) { return redirect()->route('students.profile.subjects.index'); } $lessons_arr = $subject->lessons->toArray(); $this->makeSubjectLessonsMenu($subject->id, $lessons_arr); return view('students::profile.subjects.show', compact('subject')); }
public function deleteBulk(Request $req, Subject $SubjectModel) { // if the table_records is empty we redirect to the subject index if (!$req->has('table_records')) { return redirect()->route('subject.index'); } // we get all the ids and put them in a variable $ids = $req->input('table_records'); // we delete all the subject with the ids $ids $SubjectModel->destroy($ids); // we redirect to the user index view with a success message return redirect()->route('subject.index')->with('success'); }
private function createFromExcel() { $semester_id = semester()->id; $results = Excel::load($this->filename)->get()->all(); // dd(get_class_methods($results)); $subjects_codes = []; $teachers_usernames = []; $classrooms_codes = []; foreach ($results as $sheet) { $item = $sheet->all(); if (empty($item[1]) || empty($item[2]) || empty($item[3])) { continue; } $teachers_usernames[] = $item[2]; $subjects_codes[] = $item[1]; $classrooms_codes[] = $item[3]; } $teachers = Teacher::whereIn('username', $teachers_usernames)->pluck('id', 'username')->toArray(); $subjects = Subject::whereIn('code', $subjects_codes)->pluck('id', 'code')->toArray(); $classrooms = Classroom::whereIn('code', $classrooms_codes)->inCurrentSemester()->pluck('id', 'code')->toArray(); $new_classrooms = []; foreach ($results as $sheet) { $item = $sheet->all(); if (empty($item[1]) || empty($item[2]) || empty($item[3])) { continue; } if (!isset($classrooms[$item[3]]) && isset($teachers[$item[2]]) && isset($subjects[$item[1]]) && in_array($item[5], ['m', 'f', 'b'])) { $new_classrooms[] = ['code' => $item[3], 'day' => $item[4] - 1, 'gender' => $item[5], 'teacher_id' => $teachers[$item[2]], 'subject_subject_id' => $subjects[$item[1]], 'semester_id' => $semester_id, 'attendees_limit' => 100, 'created_at' => new DateTime(), 'updated_at' => new DateTime()]; } } if (!empty($new_classrooms)) { Classroom::insert($new_classrooms); } event(new CreateClassroomsFromExcelFinished()); }
/** * Display a listing of the resource. * @return Response */ public function index() { $subjects = Subject::whereHas('teachers', function ($query) { $query->where('teacher_id', teacher()->id); })->get(); return view('teachers::profile.tests.index', compact('subjects')); }
/** * Show the form for creating a new resource. * @return Response */ public function create() { $students = QuranTimeExtend::with('student', 'semester', 'subject')->where('semester_id', semester()->id)->paginate(20); $subjects = Subject::where('is_quran', 1)->pluck('name', 'id')->toArray(); //$name = $students->$student; return view('quran::time_extend.create', compact('students', 'subjects')); }
/** * Register the service provider. * * @return void */ public function register() { Subject::saving(function ($subject) { $subject->pre_request = empty($subject->pre_request) ? null : $subject->pre_request; }); Element::created(function ($element) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'element', 'reference_id' => $element->id]); }); Element::updated(function ($element) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'element', 'reference_id' => $element->id]); }); Element::deleted(function ($element) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'element', 'reference_id' => $element->id]); }); Subject::created(function ($subject) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'subject', 'reference_id' => $subject->id]); }); Subject::updated(function ($subject) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'subject', 'reference_id' => $subject->id]); }); Subject::deleted(function ($subject) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'subject', 'reference_id' => $subject->id]); }); Lesson::created(function ($lesson) { UserLog::create(['operation' => 'create', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'lesson', 'reference_id' => $lesson->id]); }); Lesson::updated(function ($lesson) { UserLog::create(['operation' => 'update', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'lesson', 'reference_id' => $lesson->id]); }); Lesson::deleted(function ($lesson) { UserLog::create(['operation' => 'delete', 'user_id' => user() ? user()->id : NULL, 'reference_key' => 'lesson', 'reference_id' => $lesson->id]); }); }
public function index(Request $request) { $subjects = Subject::whereHas('students', function ($query) use($request) { return $query->where('students.id', $request->input('student_id')); })->get(); return $subjects; }
public function active() { $subjects = []; $fields = []; if (FinancialException::whereSemesterId(semester()->id)->whereStudentId($this->student->id)->whereActive(1)->count()) { return response()->json(false, 200, [], JSON_NUMERIC_CHECK); } $this->student->load('registration', 'registration.contactcountry', 'registration.contactcity'); $subjects = Subject::join('student_subjects as ss', function ($j) { $j->on('ss.subject_id', '=', 'subject_subjects.id')->where('student_id', '=', $this->student->id)->where('state', '=', 'study')->where('semester_id', '=', $this->semester->id)->where('payed', '=', 0); })->get()->toArray(); // if() { $study_fee = FinancialInvoiceItem::where('slug', 'study_fee')->first(); $study_fee = $study_fee ? $study_fee->amount : 0; // } else { // $study_fee = 6; // } $total_fee = 0; foreach ($subjects as &$subject) { $subject['fee'] = !$subject['is_quran'] ? $subject['hour'] * $study_fee : $subject['hour'] * 7.5; $total_fee += $subject['fee']; } if ($total_fee > 0) { if (!$this->student->registration) { return response()->json(false, 200, [], JSON_NUMERIC_CHECK); } $data = ['key' => 'student', 'value' => $this->student->username, 'transaction_id' => time(), 'amount' => $total_fee, 'bill_to_forename' => $this->student->registration->first_name, 'bill_to_surname' => $this->student->registration->last_name, 'bill_to_email' => $this->student->registration->contact_email, 'bill_to_address_line1' => $this->student->registration->adress, 'bill_to_phone' => $this->student->registration->contact_mobile, 'bill_to_address_city' => $this->student->registration->contactcity ? $this->student->registration->contactcity->name : '', 'bill_to_address_country' => 'OM']; $payment = new PaymentGateway($data); $fields = $payment->getData(); } if (empty($total_fee)) { return response()->json(false, 200, [], JSON_NUMERIC_CHECK); } return response()->json(compact('subjects', 'fields'), 200, [], JSON_NUMERIC_CHECK); }
public function edit($user_id) { $subjects = Subject::where('is_quran', 1)->pluck('name', 'id')->toArray(); $students = Student::isStudying()->pluck('name', 'id')->toArray(); $user = User::with('quran_subjects', 'quran_students')->findOrFail($user_id); return view('quran::evaluators.edit', compact('user', 'subjects', 'students')); }
public function create($student_id) { $semesters = Semester::select(\DB::raw('CONCAT(academycycle_semesters.name , "-", academycycle_years.name) as name , academycycle_semesters.id as id'))->join('academycycle_years', 'academycycle_years.id', '=', 'academycycle_semesters.academycycle_year_id')->pluck('name', 'id')->toArray(); $subjects = Subject::all()->pluck('name', 'id')->toArray(); return view('students::subjects.create', compact('student_id', 'subjects', 'semesters')); }
/** * Show the form for creating a new resource. * @return Response */ public function create() { $classrooms = Classroom::inCurrentSemester()->pluck('code', 'id')->toArray(); $subjects = Subject::isCurrent()->pluck('name', 'id')->toArray(); $years = Year::leftJoin('academystructure_terms as acaterm', 'acaterm.year_id', '=', 'ay.id')->leftJoin('academystructure_departments as acadep', 'acadep.term_id', '=', 'acaterm.id')->Leftjoin('students as s', 's.academystructure_department_id', '=', 'acadep.id')->groupBy('ay.id')->from('academystructure_years as ay')->havingRaw('COUNT(s.id)>0')->pluck('ay.name', 'ay.id')->toArray(); return view('exams::Extend.create', compact('years', 'subjects', 'classrooms')); }
/** * Display a listing of the resource. * @return Response */ public function index(Request $request) { $excuses = ExamExcuse::where('semester_id', semester()->id)->with('student', 'subject', 'exam'); if (request('subject_id')) { $subject_id = request('subject_id'); $excuses->whereHas('exam.subject', function ($q) use($subject_id) { $q->where('subject_subjects.id', $subject_id); }); } if (request('exam_year_term')) { $excuses->whereIn('subject_id', explode(',', request('exam_year_term'))); } $per_page = request('per_page') ? request('per_page') : 50; $excuses = $excuses->paginate($per_page); $excuses->appends($request->except("page")); $subjects = Subject::lists('name', 'id')->toArray(); $year_term = Year::join('academystructure_terms', 'academystructure_years.id', '=', 'academystructure_terms.year_id')->join('academystructure_departments', 'academystructure_terms.id', '=', 'academystructure_departments.term_id')->select(\DB::raw('CONCAT(academystructure_years.name, "-", academystructure_terms.name) as name, GROUP_CONCAT(DISTINCT(academystructure_departments.subject_ids)) as sid'))->groupBy('academystructure_terms.name', 'academystructure_years.name')->get()->toArray(); $year_term_options; foreach ($year_term as $key => &$aa) { $a = implode(',', array_unique(array_merge(json_decode(str_replace('],[', ',', $aa['sid']), TRUE)))); $year_term_options[$a] = $aa['name']; } return view('exams::excuses.index', compact('excuses', 'subjects', 'year_term_options')); }
public function level() { $subjects = Subject::with(['questions' => function ($query) { $query->groupBy('questionbank_questions.level', 'subject_lessons.subject_subject_id')->selectRaw("COUNT(questionbank_questions.id) AS total,questionbank_questions.level"); }])->paginate(20); return view('questionbank::report.level', compact('subjects')); }
public function create() { $classrooms = Classroom::inCurrentSemester()->pluck('code', 'id')->toArray(); $subjects = Subject::isCurrent()->lists('name', 'id')->toArray(); $intervals = ClassroomInterval::inCurrentSemester()->pluck('title', 'id')->toArray(); $teachers = Teacher::isActive()->pluck('name', 'id')->toArray(); return view('classrooms::sessions.create', compact('classrooms', 'subjects', 'teachers', 'intervals')); }
public function lesson_report(Request $req, Lesson $UserModel, $subid) { $lessons = $UserModel::with('elements')->where('subject_subject_id', $subid)->paginate(20); $subjects = Subject::where('id', $subid)->first(); if ($req->has('title')) { $lessons = Lesson::where('subject_subject_id', $subid)->where('name', $req->input('title'))->paginate(20); } return view('subject::reports.lesson_report', compact('lessons', 'subid', 'subjects')); }
public function actionBulk(Request $request, $subject_id = 0) { $ids = $request->input('table_records', []); $ids = is_array($ids) ? $ids : [$ids]; $subject = Subject::findOrFail($subject_id); $subject->teachers()->detach($ids); $message = trans('subject::teachers.detached_successfully'); return redirect()->route('subject.teachers.index', $subject->id)->with('success', $message); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); // $this->call("OthersTableSeeder"); $new_subjects = [['id' => 53, 'name' => 'أصول الفقه 3', 'hour' => 3, 'code' => 'ECSS_OSL_7_03', 'type' => 'نظري', 'is_quran' => 0], ['id' => 54, 'name' => 'العقد و توثيقه', 'hour' => 2, 'code' => 'ECSS_AAT_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 55, 'name' => 'اللغة الإنجليزية', 'hour' => 3, 'code' => 'ECSS_ENG_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 56, 'name' => 'الفقه الجنائي مقارنا بالقانون الجنائي العماني (1)', 'hour' => 3, 'code' => 'ECSS_FQHJ_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 57, 'name' => 'الوصية و الوقف', 'hour' => 2, 'code' => 'ECSS_WAW_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 58, 'name' => 'مناهج البحث', 'hour' => 2, 'code' => 'ECSS_SD_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 59, 'name' => 'البلاغة', 'hour' => 2, 'code' => 'ECSS_PRON_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 60, 'name' => 'فقه الأمر بالمعروف و النهي عن المنكر', 'hour' => 2, 'code' => 'ECSS_FQDGDB_8_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 61, 'name' => 'أصول الفقه (4)', 'hour' => 2, 'code' => 'ECSS_OSL_8_04', 'type' => 'نظري', 'is_quran' => 0], ['id' => 62, 'name' => 'الفقه الجنائي و مقارنا بالقانون الجزائي العماني (2)', 'hour' => 3, 'code' => 'ECSS_FQHJ_8_02', 'type' => 'نظري', 'is_quran' => 0], ['id' => 63, 'name' => 'نظام القضاء في الإسلام مقارنا بقانون السلطة القضائية العماني', 'hour' => 2, 'code' => 'ECSS_JSOM_8_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 64, 'name' => 'قانون العمل', 'hour' => 2, 'code' => 'ECSS_JL_8_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 65, 'name' => 'مدخل إلى الإقتصاد الإسلامي', 'hour' => 2, 'code' => 'ECSS_LS_8_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 66, 'name' => 'التفسير التحليلي', 'hour' => 2, 'code' => 'ECSS_TAN_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 67, 'name' => 'منهج تربية الطفل', 'hour' => 3, 'code' => 'ECSS_CSM_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 68, 'name' => 'طرق تدريس التربية الإسلامية', 'hour' => 3, 'code' => 'ECSS_ISSW_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 69, 'name' => 'قضايا فكرية', 'hour' => 2, 'code' => 'ECSS_INTI_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 70, 'name' => 'مهارات الحوار و التفكير', 'hour' => 2, 'code' => 'ECSS_CTT_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 71, 'name' => 'طرق تدريس القران الكريم', 'hour' => 2, 'code' => 'ECSS_SQW_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 72, 'name' => 'قضايا المرأة المسلمة', 'hour' => 3, 'code' => 'ECSS_MWI_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 73, 'name' => 'الدعوة و طرق الاتصال', 'hour' => 2, 'code' => 'ECSS_DACW_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 74, 'name' => 'الإقتصاد و التدبير المنزلي', 'hour' => 3, 'code' => 'ECSS_EAHK_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 75, 'name' => 'علوم القران الكريم', 'hour' => 2, 'code' => 'ECSS_HQS_7_01', 'type' => 'نظري', 'is_quran' => 0], ['id' => 76, 'name' => 'قانون المرافعات', 'hour' => 2, 'code' => 'ECSS_HL_8_1', 'type' => 'نظري', 'is_quran' => 0]]; foreach ($new_subjects as $subject) { Subject::firstOrCreate($subject); } // DB::table('subject_subjects')->insert($new_subjects); }
function getspecialtystruct($specialty_id = 0) { $departments = \Modules\Academystructure\Entities\Department::menu()->where('as.id', $specialty_id)->orderBy('af.id')->orderBy('ay.id')->orderBy('at.id')->get(); $subjects = \Modules\Subject\Entities\Subject::all(); foreach ($departments as &$department) { $department->subjects = $subjects->filter(function ($subject) use($department) { $subject_ids = json_decode($department->subject_ids, TRUE); return is_array($subject_ids) and in_array($subject->id, $subject_ids); }); } return $departments; }
public function index($sid) { //$tasks = Lesson::where('academystructure_subject_id',$id)->paginate(20); $subject_name = Subject::findOrFail($sid)->toArray(); //$lesson_name=Lesson::findOrFail($lessonid)->toArray(); //dd($subject_name); $lessons = Lesson::where('subject_subject_id', $sid)->paginate(20); // $lessons = Lesson::paginate(20); /* OR send model as argument */ return view('subject::lessons.index', compact('lessons', 'sid', 'subject_name')); }
public function index($subid, $lessonid, Request $req) { //$tasks = Lesson::where('academystructure_subject_id',$id)->paginate(20); if ($lessonid === -1) { $subject_name = Lesson::findOrFail($lessonid)->toArray(); } else { $subject_name = Subject::findOrFail($subid)->toArray(); } $lessons = Lesson::where('subject_subject_id', $subid)->orderBy('lesson_order', 'ASC')->paginate(20); if ($req->has('name')) { $lessons = Lesson::where('name', 'LIKE', "%" . $req->input('name') . "%")->where('subject_subject_id', $subid)->orderBy('lesson_order', 'ASC')->paginate(20); } return view('subject::lessons.index', compact('lessons', 'subid', 'subject_name')); }
public function index($subject_id = 0) { if (!($subject = Subject::whereHas('students', function ($q) { $q->where(['students.id' => student()->id, 'semester_id' => semester()->id]); })->find($subject_id))) { return redirect()->route('students.students.index'); } $student = student(); $page = QuranPage::where('subject_id', $subject_id)->first(); if (!$page) { return redirect()->route('students.profile.subjects.index')->with('warning', 'لا يوجد صفحات قران كريم لهذه المادة'); } return view('students::profile.quran.index', compact('page', 'subject', 'student')); }
public function index() { $specialities = Specialty::selectRaw('asp.id, asp.name, asp.short_description, asp.description, GROUP_CONCAT(adp.subject_ids) as subject_ids, COUNT(adt.id) as terms, COUNT(DISTINCT ady.id) as years')->leftJoin('academystructure_departments as adp', 'adp.spec_id', '=', 'asp.id')->leftJoin('academystructure_terms as adt', 'adt.id', '=', 'adp.term_id')->leftJoin('academystructure_years as ady', 'ady.id', '=', 'adt.year_id')->from('academystructure_specialties as asp')->groupBy('asp.id')->with('departments')->get(); foreach ($specialities as $specialty) { $subject_ids = explode(",", preg_replace(['/\\[/', "/\\]/", '/"/', "/'/"], "", $specialty->subject_ids)); $specialty->hours = Subject::whereIn('id', $subject_ids)->sum('hour'); foreach ($specialty->departments as $department) { $subject_ids = explode(",", preg_replace(['/\\[/', "/\\]/", '/"/', "/'/"], "", $department->subject_ids)); $department->subjects = Subject::whereIn('id', $subject_ids)->get(); } } $specialities->makeHidden(['subject_ids']); return response()->json($specialities, 200, [], JSON_NUMERIC_CHECK); }
public function create() { $elements = EvaluationElement::paginate(20); // $years = Year::leftJoin('academystructure_terms as acaterm', 'acaterm.year_id', '=', 'ay.id') // ->leftJoin('academystructure_departments as acadep', 'acadep.term_id', '=', 'acaterm.id') // ->Leftjoin('students as s', 's.academystructure_department_id', '=', 'acadep.id') // ->groupBy('ay.id') // ->from('academystructure_years as ay') // ->havingRaw('COUNT(s.id)>0') // ->pluck('ay.name', 'ay.id') // ->toArray(); $subjects = Subject::where('is_quran', 1)->pluck('name', 'id')->toArray(); // dd($subjects); return view('quran::elements.create', compact('elements', 'subjects')); }
public function index() { if ($subjects = Cache::get('student_' . $this->student->id . '_api_subjects')) { return response()->json($subjects, 200, [], JSON_NUMERIC_CHECK); } $subjects = Subject::select('subject_subjects.id', 'subject_subjects.name', 'subject_subjects.is_quran', 'subject_subjects.hour', 'qp.start as quranPageStart', 'qp.part as partTitle', 'qp.end as quranPageEnd')->leftJoin('quran_pages as qp', 'qp.subject_id', '=', 'subject_subjects.id')->whereHas('students', function ($query) { $query->where('students.id', $this->student->id)->whereIn('student_subjects.state', ['study', 'fail', 'success'])->where('semester_id', $this->semester->id); })->with(['lessons' => function ($query) { $query->orderBy('lesson_order', 'ASC')->select('name', 'type', 'id', 'subject_subject_id', 'lesson_order'); }, 'lessons.elements' => function ($query) { $query->select('id', 'value', 'type', 'title', 'subject_lesson_id', 'file_file_name', 'file_file_size', 'file_content_type', 'file_updated_at'); }])->get(); Cache::put('student_' . $this->student->id . '_api_subjects', $subjects, 600); return response()->json($subjects, 200, [], JSON_NUMERIC_CHECK); }
public function priorexam(Request $request) { $statistics = ExamResult::whereHas('Exam', function ($q) { $q->whereRaw('exams.start_at > exam_results.enter_at'); })->with('student', 'exam'); if (request('student_id')) { $statistics->whereHas('student', function ($q) use($request) { $q->where('students.id', request('student_id')); }); } if (request('exam_subject')) { $statistics->whereHas('exam', function ($q) use($request) { $q->where('subject_id', request('exam_subject')); }); } if (request('exam_type')) { $statistics->whereHas('exam', function ($q) use($request) { $q->where('type', request('exam_type')); }); } $per_page = request('per_page') ? request('per_page') : 100; $statistics = $statistics->paginate($per_page); $statistics->appends($request->except("page")); $subjects = Subject::lists('name', 'id')->toArray(); return view('exams::reports.priorexam', compact('statistics', 'subjects')); }
public function classroom_chose_subject(Request $request) { $chosen_subjects = StudentSubject::whereIn('student_subjects.state', ['study'])->selectRaw('student_subjects.student_id,students.name,students.username, students.name,students.mobile ,student_subjects.subject_id')->join('students', 'student_subjects.student_id', '=', 'students.id')->join('classrooms', function ($j) { $j->on('classrooms.subject_subject_id', '=', 'student_subjects.subject_id')->where('classrooms.semester_id', '=', semester()->id); })->leftJoin('classroom_students', function ($j) { $j->on('classrooms.id', '=', 'classroom_students.classroom_id')->on('classroom_students.student_id', '=', 'student_subjects.student_id'); })->groupBy('student_subjects.subject_id', 'student_subjects.student_id'); if ($request->subject_subject_id) { $chosen_subjects->where('student_subjects.subject_id', '=', $request->subject_subject_id); } if ($request->is_choise) { $chosen_subjects->havingRaw('COUNT(classroom_students.id)=' . $request->is_choise); } $per_page = request('per_page') ? request('per_page') : 30; $chosen_subjects = $chosen_subjects->paginate($per_page); $subjects = Subject::pluck('name', 'id')->toArray(); $classroom_select = config('classrooms.classroom_select'); return view('classrooms::reports.classroom_chose_subject', compact('subjects', 'classroom_select', 'chosen_subjects')); }
public function approve($order_id) { $order = OrderChangeDepartment::findOrFail($order_id); $student_id = $order->student_id; $depid = $order->to; $current_dep = $order->from; $StudentHistory = StudentHistory::where('student_id', $student_id)->where('academycycle_semester_id', semester()->id)->update(['academystructure_department_id' => $depid]); $student = Student::with('subjects')->where('id', $student_id)->first(); $student->academystructure_department_id = $depid; $student->save(); $department = Department::findOrFail($current_dep); $current_subject_ids = json_decode($department->subject_ids, TRUE); $current_payed_subject_ids = StudentSubject::select('subject_id')->where('semester_id', semester()->id)->where('student_id', $student_id)->where('state', 'study')->where('payed', 1)->get(); $cuttent_invoice_amount = 0; if ($current_payed_subject_ids->count() > 0) { $cuttent_invoice_amount = Subject::select(DB::raw('sum(hour*amount) as total_amount'))->whereIn('id', $current_payed_subject_ids)->first(); } $new_department = Department::findOrFail($depid); $new_subject_ids = json_decode($new_department->subject_ids, TRUE); //if($current_dep == 8 or $current_dep == 13 or $current_dep =14 ){ //update department subjects StudentSubject::where('semester_id', semester()->id)->where('student_id', $student_id)->where('state', 'study')->whereIn('subject_id', $current_subject_ids)->update(['state' => 'drop']); foreach ($new_subject_ids as $new_subject_id) { $new_student_subject = new StudentSubject(); $new_student_subject->subject_id = $new_subject_id; $new_student_subject->student_id = $student_id; $new_student_subject->semester_id = semester()->id; $new_student_subject->academystructure_department_id = $depid; $new_student_subject->state = 'study'; $new_student_subject->save(); } if ($current_payed_subject_ids->count() > 0) { $new_payed_subject_ids = StudentSubject::select('subject_id')->where('semester_id', semester()->id)->where('student_id', $student_id)->where('state', 'study')->get(); $new_invoice_amount = Subject::select(DB::raw('sum(hour*amount) as total_amount'))->whereIn('id', $new_payed_subject_ids)->first(); if ($new_invoice_amount < $cuttent_invoice_amount) { StudentSubject::where('semester_id', semester()->id)->where('student_id', $student_id)->where('state', 'study')->update(['payed' => 1]); $invoiceData = ['ref_key' => 'Order_Change_AC_Departments', 'ref_value' => $order_id, 'student_id' => $student_id, 'amount' => $cuttent_invoice_amount->total_amount - $new_invoice_amount->total_amount, 'type' => 'credit', 'semester_id' => semester()->id, 'note' => 'فرق تغيير التخصص']; FinancialInvoice::create($invoiceData); } if ($new_invoice_amount > $cuttent_invoice_amount) { StudentSubject::where('semester_id', semester()->id)->where('student_id', $student_id)->where('state', 'study')->update(['payed' => 1]); } if ($new_invoice_amount > $cuttent_invoice_amount) { StudentSubject::where('semester_id', semester()->id)->where('student_id', $student_id)->where('state', 'study')->where('subject_id', '!=', 35)->update(['payed' => 1]); } } //updtae remain subjects (not in dep id) to be in same depid StudentSubject::where('semester_id', semester()->id)->where('student_id', $student_id)->where('state', 'study')->update(['academystructure_department_id' => $depid]); $order->state = 1; $order->save(); $msg = 'تم تغيير التخصص '; return redirect()->route('orders.change.department.index')->with('success', $msg); // }else{ // } }
public function getGrades() { $student = Student::select('students.*')->with('registration', 'registration.nationalitycountry')->joinTermName()->findOrFail($this->student_id); $registration = $student->registration; $semesters = get_student_grades($student->id); // $gpa = GPA($semesters); $gpa = GPA($semesters); $valuation = check_final_valuation($gpa); $subject_ids = Department::where('spec_id', $student->specialty_id)->pluck('subject_ids'); $subject_ids = array_unique(json_decode(str_replace("][", ",", implode("", json_decode($subject_ids, TRUE))), TRUE)); $success_subjects = StudentSubject::whereIn('subject_id', $subject_ids)->where('state', 'success')->groupBy('subject_id')->where('student_id', $student->id)->pluck('subject_id'); $studied_subjects = StudentSubject::whereIn('subject_id', $subject_ids)->whereIn('state', ['success', 'fail'])->where('student_id', $student->id)->pluck('subject_id'); $student_hours = Subject::whereIn("id", $subject_ids)->sum('hour'); $fail_hours = Subject::whereIn("id", $studied_subjects)->sum('hour'); $success_hours = Subject::whereIn("id", $success_subjects)->sum('hour'); /** setup pdf library for arabic content */ $pdf = $this->preparePdf(); // test some inline CSS $pdf->SetFontSize(22); // $html = '<table border="0" width="100%"><tbody><tr><td>كشف درجات الطالب : '.$student->name.'</td></tr></tbody></table>'; // $pdf->writeHTMLCell(210,20,0,10,$html, 0, 0, false, true, "C"); if ($student->gender == 'f') { $name = $student->registration->first_name . ' بنت ' . $student->registration->second_name . ' بن ' . $student->registration->third_name . ' ' . $student->registration->last_name; } else { $name = $name = $student->registration->first_name . ' بن ' . $student->registration->second_name . ' بن ' . $student->registration->third_name . ' ' . $student->registration->last_name; } $html = '<table cellspacing="0" cellpadding="2" border="1"> <tbody> <tr> <td bgcolor="#D9DEE4" align="center">اسم الطالب</td> <td align="center" colspan="2">' . $name . '</td> <td bgcolor="#D9DEE4" align="center">الجنسية</td> <td align="center">' . (!empty($registration->nationalitycountry) ? $registration->nationalitycountry->name : 'غير محدد') . '</td> <td bgcolor="#D9DEE4" align="center">تاريخ الميلاد</td> <td align="center">' . ($registration ? $registration->birthday : "") . '</td> </tr> <tr> <td bgcolor="#D9DEE4" align="center">التخصص</td> <td align="center" colspan="2">' . $student->specialty_name . '</td> <td bgcolor="#D9DEE4" align="center">الرقم الجامعي</td> <td align="center">' . $student->code . '</td> <td bgcolor="#D9DEE4" align="center">الحالة الدراسية</td> <td align="center">' . config('students.state.' . $student->state) . '</td> </tr> <tr> <td bgcolor="#D9DEE4" align="center">الساعات المعتمدة</td> <td align="center">' . $student_hours . '</td> <td bgcolor="#D9DEE4" align="center">الساعات المكتسبة</td> <td align="center">' . $success_hours . '</td> <td bgcolor="#D9DEE4" align="center" colspan="2">المعدل التراكمي</td> <td align="center">' . $gpa . '</td> </tr> <tr> <td bgcolor="#D9DEE4" align="center">الساعات المسجلة</td> <td align="center">' . $fail_hours . '</td> <td bgcolor="#D9DEE4" align="center">الساعات المحولة</td> <td align="center"> ... </td> <td bgcolor="#D9DEE4" align="center" colspan="2">التقدير العام</td> <td align="center">' . $valuation . '</td> </tr> </tbody> </table>'; $pdf->SetFontSize(11); $chunks = $semesters->groupBy('year_name'); $accumulation_points = 0; $accumulation_hours = 0; $break = 1; $j = 1; // for each year $all_before_failed_subjects = []; $before_hours = 0; $before_points = 0; foreach ($chunks as $i => $chunk) { // for each sem foreach ($chunk as $term_index => $term) { if ($term->semester_id == Semester()->id) { break; } // donot calculate quran hour if sem <= 7 $hours = $term->subjects->sum(function ($s) use($term, &$all_before_failed_subjects, &$before_hours, &$before_points) { if ($s->subject_state == 'fail' && ($term->semester_id >= 7 && $s->is_quran || !$s->is_quran)) { $plus_hours = 0; $plus_points = 0; if (isset($all_before_failed_subjects[$s->subject_id])) { $plus_hours = $all_before_failed_subjects[$s->subject_id]['hours']; $plus_points = $all_before_failed_subjects[$s->subject_id]['points']; } $all_before_failed_subjects[$s->subject_id] = ['hours' => $s->subject_hours + $plus_hours, 'points' => $s->details->points + $plus_points]; } else { if (in_array($s->subject_id, array_keys($all_before_failed_subjects)) && $s->subject_state == 'success') { $before_hours += $all_before_failed_subjects[$s->subject_id]['hours']; $before_points += $all_before_failed_subjects[$s->subject_id]['points']; unset($all_before_failed_subjects[$s->subject_id]); } } return $term->semester_id >= 7 && $s->is_quran || !$s->is_quran ? $s->subject_hours : 0; }); $points = number_format($term->subjects->sum(function ($s) use($term) { return $term->semester_id >= 7 && $s->is_quran || !$s->is_quran ? $s->details->points : 0; }), 2); // var_dump($before_hours, $before_points); $accumulation_hours += $hours - $before_hours; $accumulation_points += $points - $before_points; $before_points = 0; $before_hours = 0; // first or second sem in page if ($break % 2 == 1) { $pdf->writeHTMLCell(180, 20, 15, 50, $html, 0, 0, false, true, "C"); $pdf->writeHTMLCell(180, 20, 15, 85, view('students::documents._semesters', ["term" => $term, 'accumulation_hours' => $accumulation_hours, 'accumulation_points' => $accumulation_points])->render(), 0, 0, false, true, "C"); } else { $pdf->writeHTMLCell(180, 20, 15, 85 * 2 + 10, view('students::documents._semesters', ["term" => $term, 'accumulation_hours' => $accumulation_hours, 'accumulation_points' => $accumulation_points])->render(), 0, 0, false, true, "C"); } if ($break % 2 == 0 && $term->semester_id != Semester()->id - 1) { $pdf->AddPage(); } $break++; } $j++; } // exit; // dd($all_before_failed_subjects); // print signeture $pdf->SetFontSize(20); $html = '<table border="0" width="100%"><tbody><tr><td>القبول و التسجيل</td></tr></tbody></table>'; $pdf->writeHTMLCell(40, 5, 15, 245, $html, 0, 0, false, true, "C"); $html = '<table border="0" width="100%"><tbody><tr><td>المشرف العام على التعليم عن بعد</td></tr> <tr><td>مستشار معالي وزير الأوقاف والشؤون الدينية</td></tr></tbody></table>'; $pdf->writeHTMLCell(130, 5, 80, 245, $html, 0, 0, false, true, "C"); ob_clean(); return $pdf; }
/** * Register the service provider. * * @return void */ public function register() { Subject::saving(function ($subject) { $subject->pre_request = empty($subject->pre_request) ? null : $subject->pre_request; }); }