public function postAdd() { $g_email = Input::get('usernameText'); $guardian = DBGuardianController::getGuardian($g_email); $first_name = Input::get("firstNameText"); $last_name = Input::get("lastNameText"); $gender = Input::get("gender"); $religion = Input::get("religionText"); $year = Input::get("year"); $month = Input::get("month"); $date = Input::get("date"); $dob = $year . "/" . $month . "/" . $date; $nic = $guardian->getNic(); $applicantId = intval(DBStudentApplicantController::getLastApplicantId()) + 1; $pagename = 'userpage/studentadd?username='******'-]+\$/", $first_name)) { return Redirect::back()->withInput()->with('error', "First Name is invalid"); } elseif (!preg_match("/^[a-zA-Z'-]+\$/", $last_name)) { return Redirect::back()->withInput()->with('error', "Last Name is invalid"); } elseif (date("Y") - (int) $year < 6) { return Redirect::back()->withInput()->with('error', "Child should be at least 6 years old"); } elseif (!preg_match("/^[a-zA-Z'-]+\$/", $religion)) { return Redirect::back()->withInput()->with('error', "Religion is invalid"); } else { $applicant = new StudentApplicant(); $applicant->setApplicantId($applicantId); $applicant->setFirstname($first_name); $applicant->setLastName($last_name); $applicant->setGender($gender); $applicant->setReligion($religion); $applicant->setDateOfBirth($dob); $applicant->setSelectedSchool(null); $applicant->setGuardianNic($nic); $result = DBStudentApplicantController::addchild($applicant); if ($result) { return View::make('G1SAS/userpage')->with('guardian', $guardian)->with('username', $g_email)->with('labelText', 'Added successfully'); } else { return View::make('G1SAS/userpage')->with('guardian', $guardian)->with('username', $g_email)->with('labelText', 'Added successfully'); } } }
public static function getSelectedApplicantsForSchool($schoolId) { $db = Connection::getInstance(); $mysqli = $db->getConnection(); $query = "select * from studentApplicant s left join guardian g on g.NIC=s.NIC where selectedSchoolId='{$schoolId}';"; $result = $mysqli->query($query); $appplicants = array(); if ($result->num_rows > 0) { while ($row = $result->fetch_assoc()) { $applicant = new StudentApplicant(); $applicant->setApplicantId($row["applicantId"]); $applicant->setFirstname($row["firstname"]); $applicant->setLastName($row["lastname"]); $applicant->setGender($row["gender"]); $applicant->setReligion($row["religion"]); $applicant->setDateOfBirth($row["dateofBirth"]); $applicant->setSelectedSchool($row["selectedSchoolId"]); $applicant->setGuardianNic($row["NIC"]); $applicant->setGuardian_lastname($row["g_lastName"]); $applicant->setGuardian_firstname($row["g_firstName"]); $applicant->setGuardian_contact($row["contactNumber"]); $appplicants[] = $applicant; } } return $appplicants; }