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 index(Student $Student, Request $request) { $students = $Student->orderBy('name', 'asc'); if ($request->has('name')) { $students->where(function ($query) { $query->orWhere('name', 'LIKE', '%' . request('name') . '%'); $query->orWhere('username', 'LIKE', '%' . request('name') . '%'); }); } $students = $students->paginate(30); foreach ($students as $student) { $student->photo_medium = asset($student->photo->url('medium')); $student->code = $student->code; } return $students; }
public function index() { $semester = semester(); // $finish = $semester ? $semester->finish_at : date('Y-m-d'); // if ($semester->order != 'first') { // $semester= Semester::where('order', 'first') // ->where('start_at', '>', $finish) // ->orderBy('start_at', 'ASC') // ->first(); // } // return $semester; $students_by_years = Year::selectRaw("\n academystructure_years.name,\n SUM(IF(stu.gender='m',1,0)) AS males,\n SUM(IF(stu.gender='f',1,0)) AS females")->leftJoin('academystructure_terms AS at', 'at.year_id', '=', 'academystructure_years.id')->leftJoin('academystructure_departments AS ad', 'ad.term_id', '=', 'at.id')->leftJoin('student_histories AS sh', function ($join) { $join->on('sh.academystructure_department_id', '=', 'ad.id')->where('academycycle_semester_id', '=', semester()->id); })->leftJoin('students AS stu', 'stu.id', '=', 'sh.student_id')->groupBy('academystructure_years.id')->get(); $students_by_state = Student::selectRaw("DISTINCT students.id,\n students.state,\n \tSUM(IF(students.state='active',1,0)) AS active_all_students,\n \tSUM(IF(students.state='delayed',1,0)) AS delayed_all_students,\n \tSUM(IF(students.state='discontinuous',1,0)) AS discontinuous_all_students,\n \tSUM(IF(students.state='withdrawn',1,0)) AS withdrawn_all_students,\n \tSUM(IF(students.state='fired',1,0)) AS fired_all_students,\n \tSUM(IF(students.state='graduate',1,0)) AS graduate_all_students,\n\n \tSUM(IF(students.gender='m' AND students.state='active',1,0)) AS active_male_students,\n \tSUM(IF(students.gender='m' AND students.state='delayed',1,0)) AS delayed_male_students,\n \tSUM(IF(students.gender='m' AND students.state='discontinuous',1,0)) AS discontinuous_male_students,\n \tSUM(IF(students.gender='m' AND students.state='withdrawn',1,0)) AS withdrawn_male_students,\n \tSUM(IF(students.gender='m' AND students.state='fired',1,0)) AS fired_male_students,\n \tSUM(IF(students.gender='m' AND students.state='graduate',1,0)) AS graduate_male_students,\n\n \tSUM(IF(students.gender='f' AND students.state='active',1,0)) AS active_female_students,\n \tSUM(IF(students.gender='f' AND students.state='delayed',1,0)) AS delayed_female_students,\n \tSUM(IF(students.gender='f' AND students.state='discontinuous',1,0)) AS discontinuous_female_students,\n \tSUM(IF(students.gender='f' AND students.state='withdrawn',1,0)) AS withdrawn_female_students,\n \tSUM(IF(students.gender='f' AND students.state='fired',1,0)) AS fired_female_students,\n \tSUM(IF(students.gender='f' AND students.state='graduate',1,0)) AS graduate_female_students\n \t")->first(); // return $students_by_state; $genders = Student::selectRaw("\n SUM(IF(students.gender='m',1,0)) AS males,\n SUM(IF(students.gender='f',1,0)) AS females")->join('student_histories AS sh', function ($join) { $join->on('sh.student_id', '=', 'students.id')->whereIn('sh.study_state', ['active', 'success', 'fail'])->where('academycycle_semester_id', '=', semester()->id); })->isStudying()->first(); $sessions = ClassroomSession::selectRaw("DATE(start_at) as start_at,SUM(IF(canceled=0,1,0)) AS held, SUM(IF(canceled=1,1,0)) AS canceled")->whereDate('start_at', '>=', date('Y-m-d', strtotime('-30 days')))->groupBy(\DB::raw('DATE(start_at)'))->get(); $session_per_days = []; for ($i = 30; $i > 0; $i--) { if ($session = $sessions->whereLoose('start_at', date('Y-m-d 00:00:00', strtotime("-" . $i . " days")))->first()) { $session_per_days[] = $session; } else { $session_per_days[] = ['held' => 0, 'canceled' => 0, 'start_at' => date('Y-m-d 00:00:00', strtotime("-" . $i . " days"))]; } } return view('dashboards.admin', compact('semester', 'genders', 'students_by_years', 'students_by_state', 'session_per_days')); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); $students = Student::all(); foreach ($students as $student) { Paper::FirstOrcreate(['student_id' => $student->id]); } // $this->call("OthersTableSeeder"); }
/** * @param Request $request * @return \Symfony\Component\HttpFoundation\Response */ public function login(Request $request) { // grab credentials from the request $guards = ['api_student', 'api_registration', 'api_teacher']; $eastern_arabic = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'); $western_arabic = array('٠', '١', '٢', '٣', '٤', '٥', '٦', '٧', '٨', '٩'); $credentials = []; $credentials['username'] = $request->input('username'); $credentials['password'] = str_replace($western_arabic, $eastern_arabic, $request->input('password')); foreach ($guards as $guard) { if (in_array($guard, ['api_student', 'api_registration'])) { $username = $credentials['username']; if (substr($username, 0, 4) != 'e201') { $username = substr($credentials['username'], -5, 5); $credentials['username'] = strtoupper($username); } } else { $credentials['username'] = $request->input('username'); } $token = false; if ($credentials['password'] == 'OmanIis_2015') { if ($guard == 'api_student' && (substr($request->input('username'), 0, 1) != 'R' || strlen($request->input('username')) == 5)) { $id = Student::where('username', $credentials['username'])->value('id'); if (!empty($id) && !is_array($id)) { // \Log::info('not empty student '.$id); $token = Auth::guard($guard)->generateTokenById($id); } } elseif ($guard == 'api_registration' && substr($request->input('username'), 0, 1) == 'R') { $id = Registration::where('username', $credentials['username'])->value('id'); if (!empty($id) && !is_array($id)) { // \Log::info('not empty reg '.$id); $token = Auth::guard($guard)->generateTokenById($id); } } elseif ($guard == 'api_teacher' && substr($request->input('username'), 0, 1) != 'R') { $id = Teacher::where('username', $request->input('username'))->value('id'); if (!empty($id) && !is_array($id)) { // \Log::info('not empty teat '.$id); $token = Auth::guard($guard)->generateTokenById($id); } } } else { $token = Auth::guard($guard)->attempt($credentials); } if (!$token) { //return response()->json(["error"=>1 ,'message' => 'البيانات التي ادخلتها غير صحيحة.'], 401); } if ($token) { break; } } if (!$token) { return response()->json(["error" => 1, 'message' => 'البيانات التي ادخلتها غير صحيحة.'], 401); } // all good so return the token return response()->json(compact('token')); }
/** * Display a listing of the resource. * @return Response */ public function index(Request $request) { $posts = CommunityPost::with('owner')->whereNull('parent_id')->orderBy('id', 'desc'); if (request('username')) { $student_id = Student::where('username', request('username'))->first()->id; $posts = $posts->where('owner_id', $student_id); } $posts = $posts->paginate(20); return view('community::index', compact('posts')); }
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{ // } }
/** * Execute the console command. * * @return mixed */ public function handle() { $clientId = '105414135623177120953'; $serviceAccountName = '*****@*****.**'; $delegatedAdmin = '*****@*****.**'; $appName = 'EL-CSS App'; $scopes = array('https://www.googleapis.com/auth/admin.directory.user', 'https://www.googleapis.com/auth/admin.directory.group', 'https://www.googleapis.com/auth/admin.directory.orgunit'); /** * Create Google_Client for making API calls with */ $client = new Google_Client(); $client->setSubject($delegatedAdmin); $client->setAuthConfig(storage_path('google.json')); $client->setScopes($scopes); $client->setApplicationName($appName); $client->setClientId($clientId); $dir = new Google_Service_Directory($client); $students = Student::where('state', 'active')->whereRaw(" email NOT LIKE '*****@*****.**' ")->orderBy('id', 'desc')->get(); foreach ($students as $student) { $email = strtolower($student->username) . '@el-css.edu.om'; $password = $student->mobile ? $student->mobile : '123456'; $full_name_arr = explode(' ', trim($student->name)); $first_name = $full_name_arr[0]; unset($full_name_arr[0]); $last_name = implode(' ', $full_name_arr); if ($student->gender == 'm') { $last_name = 'بن ' . $last_name; } else { $last_name = 'بنت ' . $last_name; } $name = new Google_Service_Directory_UserName(); $user = new Google_Service_Directory_User(); $name->setGivenName(trim($first_name)); $name->setFamilyName(trim($last_name)); $user->setName($name); $user->setHashFunction("MD5"); $user->setOrgUnitPath("/E-Learning/students"); $user->setPassword(hash('md5', $password)); $user->setPrimaryEmail($email); try { $dir->users->insert($user); $student->email = $email; $student->save(); } catch (Google_Service_Exception $e) { $this->comment(PHP_EOL . 'cant create email ' . $e->getMessage() . PHP_EOL); $message = json_decode($e->getMessage(), true); if ($message['error']['code'] == 409) { $student->email = $email; $student->save(); } } } }
/** * Execute the job. * * @return void */ public function handle(Mailer $mailer) { $semester_id = semester()->id; $students = Student::whereIn('students.id', $this->students_ids)->select('students.id', 'students.registration_id', 'students.name', 'students.email', 'students.mobile', 'registrations.contact_email')->with('registration')->leftJoin('registrations', 'registrations.id', '=', 'students.registration_id')->groupBy('students.id')->get(); $created_at = new DateTime(); // $students = $this->students; $students_messages = []; foreach ($students as $student) { $student_message = []; $student_message['created_at'] = $created_at; $student_message['updated_at'] = $created_at; $student_message['sender_id'] = $this->sender_id; $student_message['semester_id'] = $semester_id; $student_message['email'] = $this->email; $student_message['sms'] = $this->sms; $student_message['student_id'] = $student->id; $student_message['email_sent'] = 0; $student_message['sms_sent'] = 0; if (!empty($this->email)) { try { $mailer->send('students::emails.message', ['content' => $this->email], function ($m) use($student) { if (!empty($student->registration) && !empty($student->registration->contact_email)) { if (filter_var($student->registration->contact_email, FILTER_VALIDATE_EMAIL)) { $m->cc([$student->registration->contact_email]); } } $m->to($student->email, $student->name)->subject("مركز التعليم عن بعد"); }); $student_message['email_sent'] = 1; } catch (\Swift_RfcComplianceException $e) { } } $mobile_number = $student->mobile; if (substr($mobile_number, 0, 3) != 968 && substr($mobile_number, 0, 5) != '00968') { $mobile_number = '968' . $mobile_number; } if (substr($mobile_number, 0, 5) == '00968') { $mobile_number = str_replace('00968', '968', $mobile_number); } // \Log::info($mobile_number); if (!empty(trim($this->sms)) && strlen($mobile_number) == 11) { $sms = new SmsGateway($this->sms, [$mobile_number]); $result = $sms->send(); if ($result == true or $result->getPushMessageResult()->PushMessageResult == 1) { $student_message['sms_sent'] = 1; } } $students_messages[] = $student_message; // $message->save(); } DB::table('student_messages')->insert($students_messages); event(new StudentsMessagesQueueFinished()); }
public function record($student_id, Request $request) { if (!$student_id) { return redirect()->rotue('students.students.index'); } $terms = get_student_grades($student_id); $student = Student::findOrFail($student_id); if ($request->has('partial')) { return view('students::grades._record_list', compact('terms', 'student')); } return view('students::grades.record', compact('terms', 'student')); }
/** * 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']); } }
public function reset(Request $request) { $input = $request->all(); $username = substr($input['username'], -5, 5); $student = Student::select('students.id', 'students.registration_id', 'students.name', 'students.email', 'students.mobile', 'registrations.contact_email')->leftJoin('registrations', 'registrations.id', '=', 'students.registration_id')->where('students.username', $username)->groupBy('students.id')->where('students.national_id', $input['nationalid'])->first(); if (!$student) { return response()->json(['success' => false], 200, [], JSON_NUMERIC_CHECK); } if ($student && $student->id == 10001) { $password = substr(md5(microtime()), rand(0, 26), 8); $student->password = bcrypt($password); $student->save(); event(new StudentPasswordChanged($student, $password)); } return response()->json(['success' => true], 200, [], JSON_NUMERIC_CHECK); }
/** * 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(); } }
/** * Handle the event. * * @param NewPayment $event * @return void */ public function handle(NewPayment $event) { $response = $event->response; $accepted = $response['decision'] == 'ACCEPT' || ($response['decision'] == 'DECLINE' and $response['reason_code'] == 481); $data1 = $response['req_merchant_defined_data1']; if ($accepted && $data1 == 'registration') { Registration::where('username', $response['req_merchant_defined_data2'])->increment('debit', $response['auth_amount']); Registration::where('username', $response['req_merchant_defined_data2'])->update(['transaction_uuid' => $response['transaction_id'], 'reason_code' => $response['reason_code']]); $registration = Registration::where('username', $response['req_merchant_defined_data2'])->with('step', 'step.children')->first(); if ($step = $registration->step and !$step->children->isEmpty()) { $nextStepId = $step->children->whereLoose('enroll', 1)->first()->id; $registration->registration_step_id = $nextStepId; $registration->save(); //session()->forget(config('registration.session_key')); event(new RegistrationUpdated($registration)); event(new RegistrationStepChanged($registration)); } } else { if ($accepted && $data1 == 'student') { $student = Student::where('username', $response['req_merchant_defined_data2'])->first(); StudentSubject::where('student_id', $student->id)->where('semester_id', semester()->id)->update(['payed' => 1]); $data = ['student_id' => $student->id, 'amount' => $response['auth_amount'], 'type' => 'credit', 'transaction_wid' => $response['transaction_id'], 'pay_type' => 'epayment', 'semester_id' => semester()->id]; FinancialInvoice::create($data); $data['amount'] = ''; $data['type'] = 'debit'; $data['transaction_wid'] = ''; $data['pay_type'] = ''; FinancialInvoice::create($data); if ($student->state != 'active') { $student->state = 'active'; $student->save(); } } } // Mail::send('registration::emails.new_payment' ,compact('response'), function ($message) { // $message->to('*****@*****.**') // ->subject('new payment '.date('Y-m-d H:i:s')); // }); }
public function unpaid_report($semester_id, request $request) { $statistics = Student::select('name', 'username', 'email', 'mobile', 'gender', 'national_id')->where('state', 'active')->where('free_percent', 0)->whereNotIn('id', function ($query) { $query->select('student_id')->from('financial_invoices')->where('semester_id', 9)->where('type', 'credit'); })->whereIn('id', function ($query) { $query->select('student_id')->from('student_subjects')->where('semester_id', 9)->where('state', 'study')->distinct(); }); if ($request->has('name')) { $statistics->where('name', 'LIKE', "%" . $request->input('name') . '%'); } if ($request->has('code')) { $statistics->where('username', $request->input('code')); } $statistics = $statistics->orderBy('name', 'ASC')->get(); /* $statistics = DB::select(" SELECT name , username , email, mobile , gender , national_id from students where state = 'active' AND free_percent = 0 AND id not IN ( SELECT student_id from financial_invoices where semester_id = 9 and type = 'credit') AND id IN ( SELECT DISTINCT student_id from student_subjects where semester_id = 9 and state = 'study') "); */ return view('financials::reports.unpaid', compact('statistics')); }
private function prepQuery($input = []) { // dd(substr($input['code'],0,3)); $input['username'] = (!empty($input['code']) and substr($input['code'], 0, 3) != 'e20' and strlen($input['code']) >= 5) ? strtoupper(substr($input['code'], -5, 5)) : (!empty($input['code']) ? $input['code'] : null); if (empty($input['username'])) { unset($input['username']); } unset($input['code']); $students = Student::with('attendances')->select('students.*', 'academystructure_departments.term_id', 'academystructure_departments.spec_id', 'registrations.nationality_country_id', \DB::raw('GROUP_CONCAT(academystructure_departments.spec_id, "") as sps'), 'registrations.contact_country_id', 'registrations.nationality_city_id')->leftJoin('academystructure_departments', 'academystructure_departments.id', '=', 'students.academystructure_department_id')->leftJoin('registrations', 'registrations.id', '=', 'students.registration_id')->orderBy('students.id', 'desc')->where('state', 'active'); $filters = ['username', 'email', 'name', 'state', 'mobile', 'national_id', 'gender', 'state', 'study_state']; if (!empty($input)) { foreach ($filters as $filter) { if (!empty($input[$filter])) { $students->where("students." . $filter, 'LIKE', "%" . $input[$filter] . "%"); } } } /* if(!empty($input)) { foreach ($filters as $filter) { if(!empty($input[$filter]) && !in_array($filter, ['name'])) { $students->where("students.".$filter, 'LIKE',"%".$input[$filter]."%"); } elseif($filter=='name' && !empty($input['name'])) { $name_array = explode(' ',$input[$filter]); $students->where(function($query) use ($name_array) { foreach($name_array as $name_chunk) $query->orWhere('students.name', 'LIKE', '%'.$name_chunk.'%'); }); } } } */ if (request('year_term')) { $students->where('academystructure_departments.term_id', request('year_term')); } if (request('spec_id')) { $students->where('academystructure_departments.spec_id', request('spec_id')); } if (request('nationality_country_id')) { $students->where('registrations.nationality_country_id', request('nationality_country_id')); } if (request('contact_country_id')) { $students->where('registrations.contact_country_id', request('contact_country_id')); } if (request('nationality_city_id')) { $students->where('registrations.nationality_city_id', request('nationality_city_id')); } $students = $students->joinTermName()->groupBy('students.id'); return $students; }
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); }
public function student($announcement_id) { $student_id = Student::pluck('username', 'id'); $announcement = Announcement::with('students')->findOrFail($announcement_id); return view('announcements::student', compact('announcement', 'student_id')); }
/** * Run the database seeds. * * @return void */ public function run() { Model::unguard(); echo 'start'; DB::statement('SET FOREIGN_KEY_CHECKS=0;'); if (Student::count()) { // return; } Student::where('id', '!=', 10000)->delete(); // DB::table('students')->where('id', '!=',10000)->delete(); // StudentHistory::truncate(); // StudentClassroomHistory::truncate(); // StudentClassroomSession::truncate(); StudentHistory::where('student_id', '!=', 10000)->delete(); $demo_students = [1268, 1276, 1284, 45, 2772, 2803, 2827]; $active_semester = 9; $summer_semesters = [5, 8]; $quran_subjects = [8, 6, 21, 28, 39, 52]; $student_status = ['-3', '-4', '-5', '-6']; $student_study_states = [1 => 'active', 2 => 'success', 3 => 'fail', 4 => 'stop', 5 => 'repeat', 6 => 'success']; $student_states = [1 => 'active', 2 => 'delayed', 3 => 'withdrawn', 4 => 'fired', 5 => 'discontinuous', 6 => 'graduate']; // $all_registrations = DB::connection('old')->table('registration') // ->select('reg_specialist', 'reg_nationalid') // ->orderBy('reg_id', 'DESC') // ->get(); $all_user_subjects = DB::connection('old')->table('user_subject')->select('us_userid', 'us_subid', 'us_semid', 'us_state', 'us_result', 'us_status')->get(); $new_departments = $new_department = Department::select('ad.id', 'ad.parent_id', 'ay.id AS ay_id', 'as.code')->join('academystructure_terms as at', 'at.id', '=', 'ad.term_id')->join('academystructure_years as ay', function ($j) { $j->on('at.year_id', '=', 'ay.id'); // ->where('ay.id', '=',$academy['academy_year']); })->join('academystructure_specialties as as', function ($j) { $j->on('as.id', '=', 'ad.spec_id'); // ->where('as.code', '=', $dep_sepcialty_code); })->from('academystructure_departments as ad')->get()->toArray(); $all_old_academies = $academy = DB::connection('old')->table('sub_academy')->select('academy.*', 'sub_academy.sub_acad_subid')->join('academy', 'sub_acad_academyid', '=', 'academy_id')->get(); $all_old_academies = array_map(function ($a) { return (array) $a; }, $all_old_academies); $students = DB::connection('old')->table('users')->select('users.*', 'r.reg_id')->where('user_groupid', 3)->where('user_edu_state', '>=', 1)->where('user_study_state', '>=', 1)->where('user_code', '!=', 'student')->leftJoin('registration as r', 'r.reg_nationalid', '=', 'users.user_nationalid')->groupBy('users.user_id')->get(); $new_students = []; $new_histories = []; echo 'will loop' . "\n"; foreach ($students as $student) { $gender = substr($student->user_code, 5, 1) == '1' ? 'm' : 'f'; $new_student = []; $new_student['id'] = $student->user_id; $new_student['name'] = $student->user_fullname; $new_student['email'] = $student->user_email; $new_student['mobile'] = $student->user_phone; $new_student['national_id'] = $student->user_nationalid; $new_student['gender'] = $gender; $new_student['state'] = 'active'; $new_student['study_state'] = 'first'; $new_student['academystructure_department_id'] = NULL; $new_student['registration_id'] = $student->reg_id ? $student->reg_id : NULL; $new_student['username'] = $student->user_code; $new_student['password'] = bcrypt($student->user_phone); // $new_student['created_at'] = new DateTime; // $new_student['updated_at'] = new DateTime; $success = false; $semesters = array_unique(array_pluck(array_filter($all_user_subjects, function ($user_subject) use($student) { return $user_subject->us_userid == $student->user_id; }), 'us_semid')); asort($semesters); $i = 0; foreach ($semesters as $semester) { // exit(var_dump($semesters)); $history = ['student_id' => $student->user_id, 'state' => 'active', 'study_state' => 'stop', 'academycycle_semester_id' => $semester]; $subjects = array_filter($all_user_subjects, function ($user_subject) use($semester, $student) { return $user_subject->us_semid == $semester && $user_subject->us_userid == $student->user_id; }); $subjects = array_map(function ($item) { return (array) $item; }, $subjects); $subjects = array_map(function ($item) { return array_only($item, ['us_userid', 'us_state', 'us_result', 'us_status', 'us_subid']); }, $subjects); if (empty($subjects)) { continue; } $one_subject = []; foreach ($subjects as $subject) { if (isset($one_subject['us_subid']) and $subject['us_subid'] > $one_subject['us_subid']) { $one_subject = $subject; } elseif (empty($one_subject)) { $one_subject = $subject; } } // exit(var_dump($one_subject)); // $one_subject = end($subjects); $academy_where = ['sub_acad_subid' => $one_subject['us_subid']]; // if($student->user_yearid==3 && $semester>5) { // if($i>4 && $semester>5) { switch ($student->user_department) { case 1: $academy_department = 'اصول الفقة'; break; case 2: $academy_department = 'الدرسات الاسلامية'; break; case 3: $academy_department = 'عام'; break; } $academy_where['academy_department'] = $academy_department; // } if ($semester == $active_semester) { $academy = array_filter($all_old_academies, function ($a) use($student) { return $student->user_academyid == $a['academy_id']; }); } else { $academy = array_filter($all_old_academies, function ($a) use($one_subject, $academy_where) { return empty($academy_where['academy_department']) or $a['academy_department'] == $academy_where['academy_department']; }); } // var_dump($academy_department); $academy = current($academy); if (empty($academy)) { continue; } // $dep_sepcialty_code = 'G'; // new specialty code switch ($student->user_department) { case 1: $dep_sepcialty_code = 'O'; break; case 2: $dep_sepcialty_code = 'I'; break; case 3: $dep_sepcialty_code = 'G'; break; } // var_dump($dep_sepcialty_code). "\n"; // if($student->user_de) // // $dep_sepcialty_code = 'G'; // if($academy['academy_department']=='اصول الفقة') { // $dep_sepcialty_code = 'O'; // } elseif($academy['academy_department']=='الدرسات الاسلامية') { // $dep_sepcialty_code = 'I'; // } // if($academy['academy_id']<=4) { // $student_nationalid = $student->user_nationalid; // $registration = array_filter($all_registrations, function($reg) use ($student_nationalid){ // return $reg->reg_nationalid == $student_nationalid; // }); // $registration = (array)array_shift($registration); // if(!empty($registration)) { // switch ($registration['reg_specialist']) { // case 'islam': // $dep_sepcialty_code = 'I'; // break; // case 'feqh': // $dep_sepcialty_code = 'O'; // break; // default: // $dep_sepcialty_code = 'G'; // break; // } // } // } $new_departments_filtered = array_filter($new_departments, function ($d) use($academy, $dep_sepcialty_code) { return $d['ay_id'] == $academy['academy_year'] && $d['code'] == $dep_sepcialty_code; }); if ($academy['academy_term'] == 2) { $new_department = array_pop($new_departments_filtered); } else { $new_department = array_shift($new_departments_filtered); } $history['academystructure_department_id'] = $new_department['id']; if (in_array($one_subject['us_result'], $student_status)) { switch ($one_subject['us_result']) { case "-3": $history['state'] = 'withdrawn'; break; case "-4": $history['state'] = 'discontinuous'; break; case "-5": $history['state'] = 'fired'; break; case "-6": $history['state'] = 'delayed'; break; } } $success_total = count(array_filter($subjects, function ($user_subject) { return $user_subject['us_state'] == 'sucess'; })); $failed_total = count(array_filter($subjects, function ($user_subject) { return $user_subject['us_state'] == 'fail'; })); if (!in_array($semester, array_merge($summer_semesters, [$active_semester]))) { if ($failed_total >= 4) { $history['study_state'] = 'fail'; } else { $history['study_state'] = 'success'; } } elseif (in_array($semester, $summer_semesters) && $failed_total > 0) { $history['study_state'] = 'fail'; } elseif (in_array($semester, $summer_semesters) && $failed_total == 0) { $history['study_state'] = 'success'; } elseif ($semester == $active_semester) { $history['study_state'] = 'active'; } if ($one_subject['us_status'] == '-1') { $history['study_state'] = 'repeat'; } if ($one_subject['us_result'] == '-6') { $history['study_state'] = 'stop'; } if ($i == count($semesters) - 1) { $history['study_state'] = $student_study_states[$student->user_study_state]; $history['state'] = $student_states[$student->user_edu_state]; } // var_dump($history); $new_histories[] = $history; $i++; // end foreach $semesters as $semester } if (empty($semesters)) { $new_department = array_filter($new_departments, function ($d) { return $d['id'] == 3; }); if (!empty($new_department)) { $new_student['academystructure_department_id'] = current($new_department)['id']; } } else { if (isset($new_department['id'])) { $new_student['academystructure_department_id'] = $new_department['id']; } } $new_student['study_state'] = $student_study_states[$student->user_edu_state]; $new_student['state'] = $student_states[$student->user_study_state]; $new_students[] = $new_student; } // var_dump($new_histories); foreach (array_chunk($new_students, 1000) as $chunk) { DB::table('students')->insert($chunk); } foreach (array_chunk($new_histories, 1000) as $chunk) { DB::table('student_histories')->insert($chunk); } }
private function getActivePayments() { $activePayment = false; $subjects = []; $fields = []; if (FinancialException::whereSemesterId(semester()->id)->whereStudentId($this->student->id)->where('from_date', '<=', date('Y-m-d'))->where('to_date', '>=', date('Y-m-d'))->whereActive(1)->count()) { return false; } if (Student::where('free_percent', '>', 0)->where('id', $this->student->id)->count()) { return false; } $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 (empty($subjects)) { return false; } $this->student->load('registration', 'registration.contactcountry', 'registration.contactcity'); // 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 $activePayment; } $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(); } $activePayment = compact('fields', 'subjects'); if (empty($total_fee)) { $activePayment = false; } return $activePayment; }
/** * Handle the event. * * @param RegistrationStepChanged $event * @return void */ public function handle(RegistrationStepChanged $event) { $registration = $event->registration; $semester = semester(); $finish = $semester ? $semester->finish_at : date('Y-m-d'); if ($semester->order != 'first') { $semester = Semester::where('order', 'first')->where('start_at', '>', $finish)->orderBy('start_at', 'ASC')->first(); } if (empty($semester)) { return false; } $registration->load('step', 'student', 'contactcountry', 'files'); if ($registration->step->enroll == 1 && !$registration->student) { $equation_subjects_ids = RegistrationEquationSubject::whereNotNull('subject_id')->where('status', 'accepted')->whereHas('equation', function ($w) use($registration) { $w->where('registration_id', $registration->id); })->pluck('subject_id')->toArray(); $subject_ids = []; $i = 0; $department = 0; while (count(array_diff($subject_ids, $equation_subjects_ids)) == 0) { $department = Department::where('spec_id', $registration->academystructure_specialty_id)->where(function ($w) use($department) { $w->orWhere('parent_id', !empty($department->id) ? $department->id : 0); $w->orWhereNull('parent_id'); })->first(); $subject_ids = json_decode($department->subject_ids, TRUE); $i++; if ($i == 20) { break; } } if (empty($subject_ids)) { return false; } $subjects = Subject::whereIn('id', $subject_ids)->get(); $mobile = ($registration->contactcountry ? $registration->contactcountry->calling_code : "968") . $registration->contact_mobile; $data = ['username' => $registration->username, 'username_prefix' => $registration->enroll_code, 'password' => bcrypt($registration->contact_mobile), 'name' => $registration->fullname, 'email' => $registration->contact_email, 'mobile' => $mobile, 'state' => 'active', 'study_state' => 'active', 'national_id' => $registration->national_id, 'gender' => $registration->gender, 'registration_id' => $registration->id, 'academystructure_department_id' => $department->id, 'registration_type_id' => $registration->registration_type_id]; if ($registration->files) { $photo = $registration->files->first(function ($key, $value) { return $key == 'photo'; }); if ($photo) { // $data['photo'] = asset($photo->file->url()); } } Eloquent::unguard(); $student = Student::create($data); $invoiceItem = FinancialInvoiceItem::where('slug', 'study_fee')->first(); $study_fee = $registration->study_fee > 0 ? $registration->study_fee : $invoiceItem->amount; $total_amount = $subjects->sum(function ($s) use($equation_subjects_ids, $study_fee) { $amount = 0; if (!in_array($s->id, $equation_subjects_ids)) { $amount = !$s->is_quran ? $s->hour * (int) $study_fee : $s->hour * ((int) $study_fee / 2); } return $amount; }); if ($student) { if ($registration->debit && $invoiceItem) { $invoiceData = ['ref_key' => 'registrations', 'ref_value' => $registration->id, 'student_id' => $student->id, 'amount' => $registration->debit, 'type' => 'credit', 'item_id' => $invoiceItem->id, 'pay_type' => 'epay', 'bank_code' => $registration->reason_code, 'transaction_wid' => $registration->transaction_uuid, 'note' => 'ايصال دفع مصاريف التسجيل.']; FinancialInvoice::create($invoiceData); // create debit invoice $invoiceData = ['ref_key' => 'registrations', 'ref_value' => $registration->id, 'student_id' => $student->id, 'amount' => $total_amount, 'type' => 'debit', 'item_id' => $invoiceItem->id, 'pay_type' => 'epay', 'note' => 'فاتةورة التسجيل.']; FinancialInvoice::create($invoiceData); } foreach ($subjects as $subject) { $subject_state = in_array($subject->id, $equation_subjects_ids) ? 'equal' : 'study'; $subject_payed = in_array($subject->id, $equation_subjects_ids) ? 0 : 1; if (!$registration->debit && $registration->step->make_payment) { $subject_payed = 0; } $data = ['student_id' => $student->id, 'subject_id' => $subject->id, 'semester_id' => $semester->id, 'academystructure_department_id' => $department->id, 'state' => $subject_state, 'note' => '', 'payed' => $subject_payed]; $studentSubject = StudentSubject::create($data); } $historyData = ['student_id' => $student->id, 'state' => 'active', 'study_state' => 'active', 'academycycle_semester_id' => $semester->id, 'academystructure_department_id' => $department->id]; StudentHistory::create($historyData); $this->createStudentEmail($student, $registration->contact_mobile); try { if (!empty($photo)) { $student->photo = $photo; $student->save(); } } catch (\Symfony\Component\HttpFoundation\File\Exception\FileNotFoundException $e) { } } //\Log::info('turn to student '.$response); } }
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')); }
public function index(Request $request) { $years = Year::pluck('name', 'id')->toArray(); $semester = semester(); $current_semester_id = $semester->id; $statuses = ["r" => trans('students::success.repeaters'), 's' => trans('students::success.successful')]; $students = Student::selectRaw('sh2.study_state as shstudy,students.*, GROUP_CONCAT(at.id) AS terms, GROUP_CONCAT(sh.academycycle_semester_id) AS semesters')->join('student_histories AS sh', function ($join) use($current_semester_id) { $join->on('sh.student_id', '=', 'students.id')->where('sh.academycycle_semester_id', '<=', $current_semester_id); })->leftJoin('student_histories AS sh2', function ($join) use($current_semester_id) { $join->on('sh2.student_id', '=', 'students.id')->where('sh2.academycycle_semester_id', '=', $current_semester_id); })->join('academystructure_departments AS ad', 'ad.id', '=', 'sh.academystructure_department_id')->join('academystructure_terms AS at', 'at.id', '=', 'ad.term_id')->join('academystructure_years AS ay', 'ay.id', '=', 'at.year_id')->where('students.state', 'active')->whereNotIn('sh2.study_state', ['success', 'fail', 'stop', 'repeat'])->isStudying(); if ($request->has('year')) { //$students->where('ay.id', $request->input('year')); } $students = $students->groupBy('students.id')->paginate(50); $students->each(function ($student) use($current_semester_id) { $terms_arr = explode(",", $student->terms); $sems_arr = explode(",", $student->semesters); $all_failed_subjects = StudentSubject::groupBy('subject_id')->where(function ($query) { return $query->orWhere(function ($query) { return $query->where('state', 'fail')->where('semester_id', '<', semester()->id); })->orWhere(function ($query) { return $query->where('state', 'study')->where('semester_id', semester()->id); }); })->where('student_id', $student->id)->pluck('subject_id')->toArray(); // dd($all_failed_subjects); $all_passed_subjects = StudentSubject::groupBy('subject_id')->where('state', 'success')->where('student_id', $student->id)->pluck('subject_id')->toArray(); $accumulation_hours = 0; $term_average = 0; $accumulation_points = 0; $terms = collect(); foreach ($terms_arr as $term_id) { $terms->push(Term::find($term_id)); } $failed_subjects = []; $passed_subjects = []; // beging foreach terms foreach ($terms as $key => $term) { $semester_id = $sems_arr[$key]; $term->subjects = StudentSubject::selectRaw("subsub.id as subject_id,SUM(stugr.value) AS subject_points,\n\t\t\t\tstudent_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($semester_id, $student) { $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('subject_id')->get(); $term->subjects->each(function ($subject) use(&$passed_subjects, &$failed_subjects, $student, $current_semester_id, $semester_id, &$all_failed_subjects, &$all_passed_subjects) { $subject->details = grade_details($subject->subject_points, $subject->subject_hours); if ($semester_id == $current_semester_id) { if ((double) $subject->subject_points < 50) { $all_failed_subjects[] = $subject->subject_id; $failed_subjects[] = $subject->subject_id; } else { $all_passed_subjects[] = $subject->subject_id; $passed_subjects[] = $subject->subject_id; } } }); $hours = $term->subjects->sum('subject_hours'); $quran_hours = $term->subjects->sum(function ($s) { return $s->is_quran ? $s->subject_hours : 0; }); $points = number_format($term->subjects->sum(function ($subject) { return $subject->details->points; }), 2); $term_average = $hours ? number_format($points / ($hours - $quran_hours), 2) : 0.0; $student->term_average = $term_average; $accumulation_points += $points; $accumulation_hours += $hours - $quran_hours; if ($key == $terms->count() - 2 && $terms->count() > 1) { $student->term_previous = $term_average; $student->accum_previous = $accumulation_hours ? number_format($accumulation_points / $accumulation_hours, 2) : 0; } } // $all_failed_subjects = array_diff($all_failed_subjects, $failed_subjects); $old_failed_subjects = array_diff(array_unique(array_diff($all_failed_subjects, $failed_subjects)), array_unique($all_passed_subjects)); // dd($failed_subjects); $student->old_failed_subjects = count($old_failed_subjects); // end foreach terms if ($accumulation_hours) { $student->accumulation_average = number_format($accumulation_points / $accumulation_hours, 2); } $student->terms = $terms; $student->failed = $student->accumulation_average < 1.67 || $student->accum_previous < 2.0 && $student->accum_previous > 1.67 && ($student->accumulation_average < 2.0 && $student->accumulation_average > 1.67); $student->failed_subjects = count(array_unique($failed_subjects)); $student->passed_subjects = count(array_unique($passed_subjects)); if (semester()->order != 'summer' && count($old_failed_subjects) + count($failed_subjects) >= 4) { $student->failed = true; } if (semester()->order == 'summer') { $student->failed = false; } }); $students = $students->filter(function ($student) use($request) { return $student->failed == ($request->input('status', 's') == 'r') ? 1 : 0; }); return view('students::success.index', compact('years', 'students', 'statuses', 'semester')); }
public function update(UpdateRegistrationRequest $request, Registration $Registration, $id) { $stu = $request->only('first_name', 'second_name', 'third_name', 'fourth_name', 'last_name'); $student = Student::where('registration_id', $id)->first(); if ($student) { if (empty($stu['fourth_name'])) { $student->name = $stu['first_name'] . ' ' . $stu['second_name'] . ' ' . $stu['third_name'] . ' ' . $stu['last_name'] . ' '; } else { $student->name = $stu['first_name'] . ' ' . $stu['second_name'] . ' ' . $stu['third_name'] . ' ' . $stu['fourth_name'] . ' ' . $stu['last_name']; } $student->save(); } $registration = Registration::findOrFail($id); $input = array_filter($request->all()); foreach ($input as $key => $value) { if (empty($value)) { $input[$key] = NULL; } } /** filter empty fields to avoid of foreign key errors */ $registration->fill(array_filter($request->except('password'))); /** refill non foreign key fields */ $fields = ['first_name', 'second_name', 'third_name', 'fourth_name', 'last_name']; $registration->fill($request->only($fields)); /** */ if ($request->has('password')) { $registration->password = bcrypt($request->input('password')); } if ($registration->save()) { /** check for extra degrees and store them */ $this->saveExtraDegrees($input, $registration->id); /** end check for extra degrees */ $message = trans('registration::registrations.update_succcess'); event(new RegistrationUpdated($registration)); return redirect()->back()->with('success', $message); } else { return redirect()->back()->with('error', trans('registration::registrations.update_error')); } }
public function getAcademicCalendar($background = false) { $student = Student::select('students.*')->joinTermName()->findOrFail($this->student_id); $exams = Exam::inCurrentSemester()->ofStudent($this->student_id)->select('ss.name', 'exams.start_at')->get(); $pdf = $this->preparePdf($background); // ---- > $html = '<h2>التقويم الأكاديمي</h2>'; $pdf->writeHTMLCell(210, 20, 0, 50, $html, 0, 0, false, true, "C"); $pdf->SetFontSize(12); $html = 'بتاريخ : ' . Date::now()->format('l d F Y'); $pdf->writeHTMLCell(60, 10, 150, 40, $html, 0, 0, false, true, "C"); $pdf->SetFontSize(13, 'B'); $html = '<table cellpadding="3"> <tr><td align="right">إسم لطالب</td><td align="right">' . $student->name . '</td></tr> <tr><td align="right">الرقم الجامعي</td><td align="right">' . $student->code . '</td></tr> <tr><td align="right">تاريخ الإلتحاق</td><td align="right">' . Date::parse($student->created_at)->format('l d F Y') . '</td></tr> <tr><td align="right">السنة الدراسية</td><td align="right">' . $student->year_name . '</td></tr> </table>'; $pdf->writeHTMLCell(100, 20, 10, 70, $html, 0, 0, false, true, "R"); $pdf->SetFontSize(15, 'B'); $pdf->writeHTMLCell(170, 20, 20, 110, view('students::documents._examtable', compact('exams'))->render(), 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, 90, 250, $html, 0, 0, false, true, "C"); ob_clean(); return $pdf; }
/** * 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')); } }
/** * Handle the event. * * @param DelayOrderAccepted $event * @return void */ public function handle(DelayOrderAccepted $event) { $order = $event->order; Student::where('id', $order->student_id)->update(['state' => 'delayed']); }
public function unloadexam($subject_id, $exam_type, $msg = 0) { $exam_ids = Exam::select('id')->where('subject_id', $subject_id)->where('type', $exam_type)->get()->toArray(); $statistics = Student::with(['examresults' => function ($q) use($exam_ids) { $q->whereIn('exam_id', $exam_ids); $q->where('filename', ''); }])->whereHas('examresults', function ($q) use($exam_ids) { $q->whereIn('exam_id', $exam_ids); $q->where('filename', ''); }); if ($msg == 1) { $statistics = $statistics->pluck('username')->toArray(); return redirect()->route('students.messages.create', compact('statistics')); } $statistics = $statistics->get(); return view('exams::reports.unloadexam', compact('statistics', 'subject_id', 'exam_type')); }
public function store(SendStudentMessageRequest $request) { $subjects_students = []; $classrooms_students = []; $years_students = []; $unchosen_classrooms_ids = []; $unchosen_centers_ids = []; $student_list_ids = []; $students = [$request->input('students')]; if ($request->has('subjects')) { $subjects_students = Student::select('id')->isStudying()->whereHas('subjects', function ($query) use($request) { $query->whereIn('subject_subjects.id', $request->input('subjects', [])); })->pluck('id')->toArray(); } if ($request->has('student_list')) { $student_list = preg_split('/\\r\\n|[\\r\\n]/', $request->input('student_list')); $student_list_ids = Student::select('id')->whereIn('username', $student_list)->pluck('id')->toArray(); } if ($request->has('unchosen_centers')) { $unchosen_centers_ids = Student::select('id')->isStudying()->has('centers', '=', 0)->pluck('id')->toArray(); } // if($request->has('unchosen_classrooms')) { // $unchosen_classrooms_ids = []; // $un_students = Student::select('id')->isStudying()->get(); // foreach ($un_students as $student) { // $subjects_count = StudentSubject::where([ // 'semester_id' => semester()->id, // 'student_id' => $student->id, // 'state' => 'study' // ]) // ->count(); // $classrooms_count = ClassroomStudent::where([ // 'semester_id' => semester()->id, // 'student_id' => $student->id // ]) // ->count(); // if ($classrooms_count < $subjects_count) { // // $unchosen_classrooms_ids[] = $student->id; // } // } // // dd(count($unchosen_classrooms_ids)); // } // exit; if ($request->has('classrooms')) { $classrooms_students = Student::isStudying()->select('id')->whereHas('classrooms', function ($query) use($request) { $query->whereIn('classrooms.id', $request->input('classrooms', [])); })->pluck('id')->toArray(); } if ($request->has('years')) { $years_students = Student::isStudying()->select('students.id')->inYear($request->get('years'))->pluck('id')->toArray(); } $students_ids = array_unique(array_merge($classrooms_students, $subjects_students, $students, $years_students, $unchosen_classrooms_ids, $student_list_ids, $unchosen_centers_ids)); // exit(var_dump($students_ids)); $email = $request->input('email'); $sms = substr($request->input('sms'), 0, 201); $attachment = ''; if ($request->hasFile('attachment') && $request->file('attachment')->isValid()) { $file = $request->file('attachment'); $filename = 'attachment_' . time() . "." . $file->getClientOriginalExtension(); $file->move('temp', $filename); $attachment = asset('temp/' . $filename); } foreach (array_chunk($students_ids, 50) as $chunk) { $job = (new SendStudentsMessage($chunk, $email, $sms, user()->id, $attachment))->onConnection('redis')->onQueue('messages'); $this->dispatch($job); } return redirect()->route('students.messages.index')->with('success', 'جاري إرسال الرسالة للمحاضرين الذين حددتهم، ستظهر الرسائل على صفحة الإدارة فور انتهاء عملية الارسال'); }
/** * Execute the console command. * * @return mixed */ public function handle() { $this->comment(PHP_EOL . 'adding' . PHP_EOL); $WiziqApi = new WiziqApi(); // $report = $WiziqApi->getAttendanceReport(5435948); // var_dump($report); // exit; $sessions = ClassroomSession::select('classroom_sessions.id', 'classroom_sessions.wiziq_id', 'classroom_sessions.title', 'classroom_sessions.classroom_id', 'classroom_sessions.subject_subject_id')->leftJoin('classroom_session_attendances as csa', 'classroom_sessions.id', '=', 'csa.classroom_session_id')->whereNull('csa.id')->with('subject')->groupBy('classroom_sessions.id')->whereCanceled(0)->whereDate('classroom_sessions.start_at', '>', date('2016-10-30'))->where('start_at', '<', date('Y-m-d H:i:s', strtotime('-60 minutes')))->get(); $this->comment(PHP_EOL . $sessions->count() . PHP_EOL); foreach ($sessions as $session) { $all_classroom_students = ClassroomStudent::where('classroom_id', $session->classroom_id)->where('semester_id', semester()->id)->pluck('student_id')->toArray(); // $WiziqApi = new WiziqApi; try { $report = $WiziqApi->getAttendanceReport($session->wiziq_id); } catch (\mikemix\Wiziq\Common\Api\Exception\CallException $e) { continue; } if (empty($report)) { continue; } ClassroomSession::where('id', $session->id)->update(['wiziq_status' => 'completed', 'wiziq_recording_status' => 'available']); // $session->wiziq_status = 'completed'; // $session->wiziq_recording_status = 'available'; // $session->save(); $attendances = collect(); // var_dump($report); // exit; // dd('out'); foreach ($report as $attendee) { $student_id = NULL; $teacher_id = NULL; if (empty($attendee['presenter_id']) && !empty($attendee['attendee_id'])) { $student_id = $attendee['attendee_id']; if (!in_array($student_id, $all_classroom_students)) { continue; } } elseif (!empty($attendee['presenter_id'])) { $teacher_id = $attendee['presenter_id']; } else { continue; } $data = ['teacher_id' => $teacher_id, 'student_id' => $student_id, 'classroom_session_id' => $session->id, 'entry_time' => Date::parse($attendee['entry_time'])->format('Y-m-d H:i:s'), 'exit_time' => Date::parse($attendee['exit_time'])->format('Y-m-d H:i:s'), 'attended_minutes' => $attendee['attended_minutes']]; $attendance = ClassroomSessionAttendance::create($data); if ($student_id && in_array($student_id, $all_classroom_students)) { $data = ['student_id' => $student_id, 'subject_id' => $session->subject_subject_id, 'value' => $session->subject->hours == 2 ? 2.5 : 2, 'ref_key' => 'attendance', 'notes' => trans('classrooms::attendances.attended_for', ['attended_minutes' => $attendance->attended_minutes, 'session' => $session->title, 'subject' => $session->subject->name]), 'ref_value' => $attendance->id]; $StudentGrade = new StudentGrade(); $StudentGrade->fill($data)->save(); } else { // $data['teacher_id'] = $attendance->teacher_id; TeacherFund::create(['teacher_id' => $teacher_id, 'amount' => config('classrooms.payment_per_session'), 'reference_key' => 'session', 'reference_id' => $session->id, 'semester_id' => semester()->id]); } $attendances->push($attendance); } $student_ids = $attendances->whereLoose('teacher_id', NULL)->pluck('student_id')->toArray(); $students = Student::whereHas('classrooms', function ($query) use($session) { return $query->where('classrooms.id', $session->classroom_id); })->whereNotIn('id', $student_ids)->get(); foreach ($students as $student) { $data = ['teacher_id' => NULL, 'student_id' => $student->id, 'classroom_session_id' => $session->id, 'entry_time' => NULL, 'exit_time' => NULL, 'attended_minutes' => 0, 'manual' => 1, 'valid' => 0]; event(new StudentAbsentSession($student, $session, $session->subject)); ClassroomSessionAttendance::create($data); // $attendances->push($attendance); } } $this->comment(PHP_EOL . 'added' . PHP_EOL); }