function save_instructor(Request $request) { $acam = Session::get('phaseterm'); $instructor = $request->instructor; $class_id = $request->cl_id; // no point if the instructor = 0 if ($instructor != 0) { $time = Time::getPeriod($class_id); $day = Day::getShortDay($class_id); $conflict = Api::checkInstructor($instructor, $time, $day); if ($conflict == false) { $class = Classallocation::find($class_id); $class->instructor = $instructor; $class->save(); if ($request->ajax == 0) { Session::flashdata('message', htmlAlert('Successfully Assigned', 'success')); return back(); } } else { if ($request->ajax == 0) { Session::flashdata('message', htmlAlert('Conflict')); return back(); } else { echo 'conflict'; } } } else { if ($request->ajax == 0) { Session::flashdata('message', htmlAlert('Please Select a instructor')); return back(); } else { echo 'no'; } } }
public function update(UpdateRegistrationRequest $request) { $party = Party::find($request->student); $party->firstname = $request->firstname; $party->lastname = $request->lastname; $party->middlename = $request->middlename; $party->emailaddres = $request->emailadd; $party->sex = $request->gender; $party->mobilenumber = $request->contact; $party->address1 = $request->mailing_add; Session::flashdata('message', htmlAlert('Successfully Updated', 'success')); return redirect('update_registration'); }
public function store(Request $request) { // TODO: recent coursemajor must not match wil the current coursemajor $system = Api::systemValue(); $coursemajor = DB::table('tbl_coursemajor')->where('course', $request->course)->where('major', $request->major)->first(); $registration = new Registration(); $registration->coursemajor = $coursemajor->id; $registration->student = $request->student; $registration->academicterm = $system->currentacademicterm; $registration->status = 'P'; $registration->curriculum = Curriculum::getCurrentCurriculum($request->course, $request->major, $system); $registration->datecreated = date('Y-m-d'); $registration->save(); Session::flashdata('message', htmlAlert('Successfully Saved', 'success')); return redirect('shift_student'); }
function login($request) { $username = $request->username; $password = $request->password; $validator = Validator::make($request->all(), ['username' => 'required', 'password' => 'required']); if (!$validator->fails()) { if (Auth::attempt(['username' => $username, 'password' => $password])) { $system = Api::systemValue(); $sy = Academicterm::find($system->currentacademicterm); $ses = ['current_sy' => $sy->systart . '-' . $sy->syend, 'term' => $sy->term, 'phaseterm' => $system->phaseterm]; Session::put($ses); return redirect('/'); } else { return view('index', ['error' => htmlAlert('Authentication Failed')]); } } else { return view('index', ['error' => '']); } }
public function register_new_student(NewStudentRegRequest $request) { DB::transaction(function () { $party = new Party(); $party->firstname = $request->firstname; $party->lastname = $request->lastname; $party->middlename = $request->middlename; $party->sex = $request->gender; $party->placeofbirth = $request->pob; $party->dateofbirth = $request->dob; $party->mobilenumber = $request->contact; $party->religion = $request->religion; $party->emailaddress = $request->emailadd; $party->civilstatus = $request->maritalstatus; $party->legacyid = $this->system->laststudentid; $party->address1 = $request->mailing_add; // insert into party $party->save(); // get the inserted id $party_id = $party->id; // set the laststudentid $this->setLastStudentId(); $curriculum = Curriculum::getCurrentCurriculum($request->course, $request->major, $this->system); $coursemajor = DB::table('coursemajor')->where('course', $request->course)->where('major', $request->major)->first(); $registration = new ModelRegistration(); $registration->curriculum = $curriculum; $registration->student = $party_id; $registration->academicterm = $this->system->currentacademicterm; $registration->status = 'P'; $registration->date = date('Y-m-d'); $registration->coursemajor = $coursemajor->id; // insert into registration $registration->save(); DB::table('tbl_student')->insert(['id' => $party_id, 'fathername' => $request->father_name, 'fatherproffession' => $request->father_occupation, 'mothername' => $request->mother_name, 'motherproffession' => $request->mother_occupation]); DB::table('tbl_useraccess')->insert(['id' => $party_id, 'username' => $request->username, 'password' => password_hash($request->password, PASSWORD_BCRYPT)]); // TODO: insert into tbl_useroption }); Session::put('message', htmlAlert('Successfully Registered', 'success')); return back(); }
function copy(Request $request) { // academicterm must be not equal from the source $past_cur = DB::table('tbl_curriculum')->where('id', $request->curriculum_id)->first(); if ($past_cur->academicterm == $request->sy_id) { Session::flash('message', htmlAlert('The Same Academicterm')); } else { $cur['coursemajor'] = $past_cur->coursemajor; $cur['academicterm'] = $past_cur->academicterm; $cur['yearlevel'] = $past_cur->yearlevel; $cur['description'] = $past_cur->description; $id = DB::table('tbl_curriculum')->insertGetId($cur); $past_detail = DB::table('tbl_curriculumdetail')->where('curriculum', $request->curriculum_id)->orderBy('yearlevel')->orderBy('term')->get(); foreach ($past_detail as $detail) { $data['curriculum'] = $id; $data['subject'] = $detail->subject; $data['term'] = $detail->term; $data['yearlevel'] = $detail->yearlevel; DB::table('tbl_curriculumdetail')->insert($data); } } return back(); }
function assign($request) { $day = $request->day; $cid = $request->class_id; $days = array('Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'); foreach ($day as $key => $value) { $start_time = $request->input('start_time' . $value); $end_time = $request->input('end_time' . $value); // check if the user select the noon break time period if ($start_time != 11 and $end_time != 13) { //end time period must be greater than the start time period if ($end_time > $start_time) { // check if schedule overlaps if ($start_time >= 1 and $end_time <= 11 or $start_time >= 13 and $end_time <= 28) { // delete first the days and period before inserting Day_period::where('classallocation', $cid)->delete(); $day_period = new Day_period(); $day_period->classallocation = $cid; $day_period->day = $value; $day_period->from_time = $start_time; $day_period->to_time = $end_time; $day_period->save(); } else { $this->error = htmlAlert('Overlaps Noon Break in <strong>' . $days[$value - 1] . '</strong>'); return false; } } else { $this->error = htmlAlert('End Time Period must be greater than Start Time in <strong>' . $days[$value - 1] . '</strong>'); return false; } } else { if ($start_time == 11 and $end_time == 13) { $this->error = htmlAlert('Time Period must not in 12:00 pm - 1:00 pm in <strong>' . $days[$value - 1] . '</strong>'); } elseif ($start_time == 11) { $this->error = htmlAlert('Start Time must not 12:00 pm in <strong>' . $days[$value - 1] . '</strong>'); } elseif ($end_time == 13) { $this->error = htmlAlert('End Time must not 1:00 pm in <strong>' . $days[$value - 1] . '</strong>'); } return false; } } Session::flashdata('message', htmlAlert('Successfully added', 'success')); return true; }